XC Open source finite element analysis program
TriBase3N.h
1 //----------------------------------------------------------------------------
2 // XC program; finite element analysis code
3 // for structural analysis and design.
4 //
5 // Copyright (C) Luis Claudio Pérez Tato
6 //
7 // This program derives from OpenSees <http://opensees.berkeley.edu>
8 // developed by the «Pacific earthquake engineering research center».
9 //
10 // Except for the restrictions that may arise from the copyright
11 // of the original program (see copyright_opensees.txt)
12 // XC is free software: you can redistribute it and/or modify
13 // it under the terms of the GNU General Public License as published by
14 // the Free Software Foundation, either version 3 of the License, or
15 // (at your option) any later version.
16 //
17 // This software is distributed in the hope that it will be useful, but
18 // WITHOUT ANY WARRANTY; without even the implied warranty of
19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 // GNU General Public License for more details.
21 //
22 //
23 // You should have received a copy of the GNU General Public License
24 // along with this program.
25 // If not, see <http://www.gnu.org/licenses/>.
26 //----------------------------------------------------------------------------
27 //TriBase3N.h
28 
29 #include "ElemPlano.h"
30 
31 #ifndef TriBase3N_h
32 #define TriBase3N_h
33 
34 #include "preprocessor/cad/matrices/TritrizPtrElem.h"
35 #include "preprocessor/cad/aux_meshing.h"
36 #include "preprocessor/loaders/LoadLoader.h"
37 #include "domain/load/plane/BidimStrainLoad.h"
38 #include "med.h"
39 #include "vtkCellType.h"
40 
41 namespace XC {
43 //
45 template <class PhysProp> //3 Gauss point by default.
46 class TriBase3N: public ElemPlano<3,PhysProp>
47  {
48  protected:
49  TritrizPtrElem put_on_mesh(const TritrizPtrNod &,meshing_dir dm) const;
50  public:
51 
52  TriBase3N(int classTag,const PhysProp &);
53  TriBase3N(int tag, int classTag,const PhysProp &);
54  TriBase3N(int tag, int classTag, int node1, int node2, int node3,const PhysProp &pp);
55 
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  int getMEDCellType(void) const;
62 
63  void zeroLoad(void);
64  int addLoad(ElementalLoad *theLoad, double loadFactor);
65 
66  };
67 
69 template <class PhysProp>
70 XC::TriBase3N<PhysProp>::TriBase3N(int classTag,const PhysProp &pp)
71  : ElemPlano<3,PhysProp>(0,classTag,pp) {}
72 
74 template <class PhysProp>
75 XC::TriBase3N<PhysProp>::TriBase3N(int tag,int classTag,const PhysProp &physProp)
76  :ElemPlano<3,PhysProp>(tag,classTag,physProp) {}
77 
79 template <class PhysProp>
80 XC::TriBase3N<PhysProp>::TriBase3N(int tag, int classTag, int node1, int node2, int node3,const PhysProp &pp)
81  : ElemPlano<3,PhysProp>(tag,classTag,pp)
82  {
83  this->theNodes.set_id_nodes(node1,node2,node3);
84  }
85 
87 template <class PhysProp>
89  {
90  std::cerr << "TritrizPtrElem XC::TriBase3N<PhysProp>::put_on_mesh not implemented" << std::endl;
91  TritrizPtrElem retval;
92  return retval;
93  }
94 
96 template <class PhysProp>
98  {
99  Element::NodesEdge retval(2,static_cast<Node *>(nullptr));
101  const size_t sz= nodos.size();
102  if(i<sz)
103  {
104  retval[0]= nodos(i);
105  if(i<(sz-1))
106  retval[1]= nodos(i+1);
107  else
108  retval[1]= nodos(0);
109  }
110  return retval;
111  }
112 
115 template <class PhysProp>
116 int XC::TriBase3N<PhysProp>::getEdgeNodes(const Node *n1,const Node *n2) const
117  {
118  int retval= -1;
120  const int i1= nodos.find(n1);
121  const int i2= nodos.find(n2);
122  if((i1>=0) && (i2>=0))
123  {
124  const int dif= i2-i1;
125  if(dif==1)
126  retval= i1;
127  else if(dif==-1)
128  retval= i2;
129  else if((i1==3) && (i2==0))
130  retval= 3;
131  else if((i1==0) && (i2==3))
132  retval= 3;
133  }
134  return retval;
135  }
136 
138 template <class PhysProp>
140  {
141  ID retval(2);
143  const size_t sz= nodos.size();
144  if(i<sz)
145  {
146  retval[0]= i;
147  if(i<(sz-1))
148  retval[1]= i+1;
149  else
150  retval[1]= 0;
151  }
152  return retval;
153  }
154 
156 template <class PhysProp>
158  {
160  this->physicalProperties.getMaterialsVector().zeroInitialGeneralizedStrains(); //Removes initial deformations.
161  return;
162  }
163 
165 template <class PhysProp>
166 int XC::TriBase3N<PhysProp>::addLoad(ElementalLoad *theLoad, double loadFactor)
167  {
168  if(this->isDead())
169  std::cerr << this->nombre_clase()
170  << "; load over inactive element: "
171  << this->getTag() << std::endl;
172  else
173  {
174  if(const BidimStrainLoad *strainLoad= dynamic_cast<const BidimStrainLoad *>(theLoad)) //Prescribed deformations.
175  {
176  static std::vector<Vector> initStrains;
177  initStrains= strainLoad->getStrains();
178  for(std::vector<Vector>::iterator i= initStrains.begin();i!=initStrains.end();i++)
179  (*i)*= loadFactor;
180  this->physicalProperties.getMaterialsVector().addInitialGeneralizedStrains(initStrains);
181  }
182  else
183  {
184  std::cerr << "TriBase3N::addLoad -- load type unknown for element with tag: " <<
185  this->getTag() << std::endl;
186  return -1;
187  }
188  }
189  return 0;
190  }
191 
193 template <class PhysProp>
195  { return VTK_TRIANGLE; }
196 
198 template <class PhysProp>
200  { return MED_TRIA3; }
201 
202 } // end of XC namespace
203 #endif
ID getLocalIndexNodesEdge(const size_t &i) const
Returns the local indexes of the nodes that lies on the i-th edge.
Definition: TriBase3N.h:139
void set_id_nodes(int Nd1, int Nd2)
Sets identifiers for nodes 1 and 2.
Definition: NodePtrsWithIDs.cc:97
"Tritriz" of pointers to elements.
Definition: TritrizPtrElem.h:43
std::vector< const Node * > NodesEdge
Definition: Element.h:108
"Tritriz" of pointers to elements.
Definition: TritrizPtrNod.h:51
NodePtrsWithIDs theNodes
pointers to node.
Definition: ElementBase.h:49
TritrizPtrElem put_on_mesh(const TritrizPtrNod &, meshing_dir dm) const
Put the element on the mesh being passed as parameter.
Definition: TriBase3N.h:88
Base class for 3 node triangles.
Definition: TriBase3N.h:46
int addLoad(ElementalLoad *theLoad, double loadFactor)
Adds to the element the load being passed as parameter.
Definition: TriBase3N.h:166
Mesh node.
Definition: Node.h:99
int getVtkCellType(void) const
Interfaz con VTK.
Definition: TriBase3N.h:194
int getMEDCellType(void) const
Interfaz con el formato MED de Salome.
Definition: TriBase3N.h:199
Load due to restricted material expansion or contraction on bidimensional elements.
Definition: BidimStrainLoad.h:38
Base class for loads over elements.
Definition: ElementalLoad.h:73
Base class for plane elements.
Definition: ElemPlano.h:48
virtual void zeroLoad(void)
Anula el load vector aplicadas of the element.
Definition: Element.cpp:185
Node pointer container for elements.
Definition: NodePtrsWithIDs.h:45
PhysProp physicalProperties
pointers to the material objects and physical properties.
Definition: ElemWithMaterial.h:43
Definition: ID.h:77
iterator find(const int &)
Returns an iterator to the node identified by the tag being passed as parameter.
Definition: NodePtrs.cc:146
Element::NodesEdge getNodesEdge(const size_t &i) const
Returns the nodos de un lado of the element.
Definition: TriBase3N.h:97
NodePtrsWithIDs & getNodePtrs(void)
Returns a pointer to the vector de nodos.
Definition: ElementBase.h:107
================================================================================
Definition: ContinuaReprComponent.h:34
void zeroLoad(void)
Zeroes loads on element.
Definition: TriBase3N.h:157
int getEdgeNodes(const Node *, const Node *) const
Returns the borde of the element que tiene por extremos los nodos being passed as parameters...
Definition: TriBase3N.h:116
TriBase3N(int classTag, const PhysProp &)
Constructor.
Definition: TriBase3N.h:70