xc
TriBase3N.h
1 // -*-c++-*-
2 //----------------------------------------------------------------------------
3 // XC program; finite element analysis code
4 // for structural analysis and design.
5 //
6 // Copyright (C) Luis C. Pérez Tato
7 //
8 // This program derives from OpenSees <http://opensees.berkeley.edu>
9 // developed by the «Pacific earthquake engineering research center».
10 //
11 // Except for the restrictions that may arise from the copyright
12 // of the original program (see copyright_opensees.txt)
13 // XC is free software: you can redistribute it and/or modify
14 // it under the terms of the GNU General Public License as published by
15 // the Free Software Foundation, either version 3 of the License, or
16 // (at your option) any later version.
17 //
18 // This software is distributed in the hope that it will be useful, but
19 // WITHOUT ANY WARRANTY; without even the implied warranty of
20 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 // GNU General Public License for more details.
22 //
23 //
24 // You should have received a copy of the GNU General Public License
25 // along with this program.
26 // If not, see <http://www.gnu.org/licenses/>.
27 //----------------------------------------------------------------------------
28 //TriBase3N.h
29 
30 #include "PlaneElement.h"
31 
32 #ifndef TriBase3N_h
33 #define TriBase3N_h
34 
35 #include "preprocessor/multi_block_topology/matrices/ElemPtrArray3d.h"
36 #include "preprocessor/multi_block_topology/aux_meshing.h"
37 #include "preprocessor/prep_handlers/LoadHandler.h"
38 #include "domain/load/plane/BidimStrainLoad.h"
39 #include "vtkCellType.h"
40 
41 namespace XC {
43 //
45 template <class PhysProp> //3 Gauss point by default.
46 class TriBase3N: public PlaneElement<3,PhysProp>
47  {
48  protected:
49  ElemPtrArray3d put_on_mesh(const NodePtrArray3d &,meshing_dir dm) const;
50  public:
51  TriBase3N(int classTag,const PhysProp &);
52  TriBase3N(int tag, int classTag,const PhysProp &);
53  TriBase3N(int tag, int classTag, int node1, int node2, int node3,const PhysProp &pp);
54 
55  BoolArray3d getNodePattern(void) const;
56  Element::NodesEdge getNodesEdge(const size_t &i) const;
57  ID getLocalIndexNodesEdge(const size_t &i) const;
58  int getEdgeNodes(const Node *,const Node *) const;
59 
60  int getVtkCellType(void) const;
61 
62  void zeroLoad(void);
63  int addLoad(ElementalLoad *theLoad, double loadFactor);
64 
65  };
66 
68 template <class PhysProp>
69 XC::TriBase3N<PhysProp>::TriBase3N(int classTag,const PhysProp &pp)
70  : PlaneElement<3,PhysProp>(0,classTag,pp) {}
71 
73 template <class PhysProp>
74 XC::TriBase3N<PhysProp>::TriBase3N(int tag,int classTag,const PhysProp &physProp)
75  :PlaneElement<3,PhysProp>(tag,classTag,physProp) {}
76 
78 template <class PhysProp>
79 XC::TriBase3N<PhysProp>::TriBase3N(int tag, int classTag, int node1, int node2, int node3,const PhysProp &pp)
80  : PlaneElement<3,PhysProp>(tag,classTag,pp)
81  {
82  this->theNodes.set_id_nodes(node1,node2,node3);
83  }
84 
88 template <class PhysProp>
90  {
91  BoolArray3d retval(1,2,2,true); //One layer, two rows, two columns.
92  retval.assign(1,1,1,false); //No fourth corner on a triangle.
93  return retval;
94  }
95 
97 template <class PhysProp>
99  {
100  std::cerr << this->getClassName() << "::" << __FUNCTION__
101  << "; not implemented." << std::endl;
102  ElemPtrArray3d retval;
103  return retval;
104  }
105 
107 template <class PhysProp>
109  {
110  Element::NodesEdge retval(2,static_cast<Node *>(nullptr));
112  const size_t sz= nodes.size();
113  if(i<sz)
114  {
115  retval[0]= nodes(i);
116  if(i<(sz-1))
117  retval[1]= nodes(i+1);
118  else
119  retval[1]= nodes(0);
120  }
121  return retval;
122  }
123 
126 template <class PhysProp>
127 int XC::TriBase3N<PhysProp>::getEdgeNodes(const Node *n1,const Node *n2) const
128  {
129  int retval= -1;
131  const int i1= nodes.find(n1);
132  const int i2= nodes.find(n2);
133  if((i1>=0) && (i2>=0))
134  {
135  const int dif= i2-i1;
136  if(dif==1)
137  retval= i1;
138  else if(dif==-1)
139  retval= i2;
140  else if((i1==3) && (i2==0))
141  retval= 3;
142  else if((i1==0) && (i2==3))
143  retval= 3;
144  }
145  return retval;
146  }
147 
149 template <class PhysProp>
151  {
152  ID retval(2);
154  const size_t sz= nodes.size();
155  if(i<sz)
156  {
157  retval[0]= i;
158  if(i<(sz-1))
159  retval[1]= i+1;
160  else
161  retval[1]= 0;
162  }
163  return retval;
164  }
165 
167 template <class PhysProp>
169  {
171  this->physicalProperties.getMaterialsVector().zeroInitialGeneralizedStrains(); //Removes initial deformations.
172  return;
173  }
174 
176 template <class PhysProp>
177 int XC::TriBase3N<PhysProp>::addLoad(ElementalLoad *theLoad, double loadFactor)
178  {
179  if(this->isDead())
180  std::cerr << this->getClassName()
181  << "; load over inactive element: "
182  << this->getTag() << std::endl;
183  else
184  {
185  if(const BidimStrainLoad *strainLoad= dynamic_cast<const BidimStrainLoad *>(theLoad)) //Prescribed deformations.
186  {
187  static std::vector<Vector> initStrains;
188  initStrains= strainLoad->getStrains();
189  for(std::vector<Vector>::iterator i= initStrains.begin();i!=initStrains.end();i++)
190  (*i)*= loadFactor;
191  this->physicalProperties.getMaterialsVector().incrementInitialGeneralizedStrains(initStrains);
192  }
193  else
194  {
195  std::cerr << "TriBase3N::addLoad -- load type unknown for element with tag: " <<
196  this->getTag() << std::endl;
197  return -1;
198  }
199  }
200  return 0;
201  }
202 
204 template <class PhysProp>
206  { return VTK_TRIANGLE; }
207 
208 } // end of XC namespace
209 #endif
std::vector< const Node * > NodesEdge
Nodes on an element edge.
Definition: Element.h:116
Base class for grids of bool in 3D (used to express if something exists or not in a (layer...
Definition: BoolArray3d.h:34
TriBase3N(int classTag, const PhysProp &)
Constructor.
Definition: TriBase3N.h:69
BoolArray3d getNodePattern(void) const
Return a grid of booleans, one for each of the element nodes.
Definition: TriBase3N.h:89
Element::NodesEdge getNodesEdge(const size_t &i) const
Returns the nodes de un lado of the element.
Definition: TriBase3N.h:108
Vector of integers.
Definition: ID.h:95
Three-dimensional array of pointers to elements.
Definition: ElemPtrArray3d.h:47
iterator find(const int &)
Returns an iterator to the node identified by the tag being passed as parameter.
Definition: NodePtrs.cc:151
int getVtkCellType(void) const
Interfaz con VTK.
Definition: TriBase3N.h:205
Base class for 3 node triangles.
Definition: TriBase3N.h:46
void zeroLoad(void)
Zeroes loads on element.
Definition: TriBase3N.h:168
ID getLocalIndexNodesEdge(const size_t &i) const
Returns the local indexes of the nodes that lies on the i-th edge.
Definition: TriBase3N.h:150
int addLoad(ElementalLoad *theLoad, double loadFactor)
Adds to the element the load being passed as parameter.
Definition: TriBase3N.h:177
Node pointer container for elements.
Definition: NodePtrsWithIDs.h:46
Three-dimensional array of pointers to nodes.
Definition: NodePtrArray3d.h:51
Open source finite element program for structural analysis.
Definition: ContinuaReprComponent.h:35
int getEdgeNodes(const Node *, const Node *) const
Returns the edge of the element that ends in the nodes being passed as parameters.
Definition: TriBase3N.h:127
Base class for loads over elements.
Definition: ElementalLoad.h:79
Load due to restricted material expansion or contraction on bidimensional elements.
Definition: BidimStrainLoad.h:39
Mesh node.
Definition: Node.h:111
ElemPtrArray3d put_on_mesh(const NodePtrArray3d &, meshing_dir dm) const
Put the element on the mesh being passed as parameter.
Definition: TriBase3N.h:98
Base class for plane elements.
Definition: PlaneElement.h:55