XC Open source finite element analysis program
QuadBase4N.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 //QuadBase4N.h
28 
29 #include "ElemPlano.h"
30 
31 #ifndef QuadBase4N_h
32 #define QuadBase4N_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 {
44 template <class PhysProp>
45 class QuadBase4N : public ElemPlano<4,PhysProp>
46  {
47  protected:
48  TritrizPtrElem put_on_mesh(const TritrizPtrNod &,meshing_dir dm) const;
49  public:
50 
51  QuadBase4N(int classTag,const PhysProp &pp);
52  QuadBase4N(int tag, int classTag,const PhysProp &);
53  QuadBase4N(int tag, int classTag, int node1, int node2, int node3, int node4,const PhysProp &pp);
54 
55  Element::NodesEdge getNodesEdge(const size_t &i) const;
56  ID getLocalIndexNodesEdge(const size_t &i) const;
57  int getEdgeNodes(const Node *,const Node *) const;
58 
59  int getVtkCellType(void) const;
60  int getMEDCellType(void) const;
61 
62  void zeroLoad(void);
63  int addLoad(ElementalLoad *theLoad, double loadFactor);
64 
65  };
66 
68 template <class PhysProp>
69  XC::QuadBase4N<PhysProp>::QuadBase4N(int classTag,const PhysProp &pp)
70  : ElemPlano<4,PhysProp>(0,classTag,pp) {}
71 
73 template <class PhysProp>
74 XC::QuadBase4N<PhysProp>::QuadBase4N(int tag,int classTag,const PhysProp &pp)
75  :ElemPlano<4,PhysProp>(tag,classTag,pp) {}
76 
78 template <class PhysProp>
79 XC::QuadBase4N<PhysProp>::QuadBase4N(int tag, int classTag, int node1, int node2, int node3, int node4,const PhysProp &pp)
80  : ElemPlano<4,PhysProp>(tag,classTag,pp)
81  {
82  this->theNodes.set_id_nodes(node1,node2,node3,node4);
83  }
84 
85 
87 template <class PhysProp>
89  { return put_quad4N_on_mesh(*this,nodos,dm); }
90 
92 template <class PhysProp>
94  {
95  Element::NodesEdge retval(2,static_cast<Node *>(nullptr));
97  const size_t sz= nodos.size();
98  if(i<sz)
99  {
100  retval[0]= nodos(i);
101  if(i<(sz-1))
102  retval[1]= nodos(i+1);
103  else
104  retval[1]= nodos(0);
105  }
106  return retval;
107  }
108 
111 template <class PhysProp>
112 int XC::QuadBase4N<PhysProp>::getEdgeNodes(const Node *n1,const Node *n2) const
113  {
114  int retval= -1;
116  const int i1= nodos.find(n1);
117  const int i2= nodos.find(n2);
118  if((i1>=0) && (i2>=0))
119  {
120  const int dif= i2-i1;
121  if(dif==1)
122  retval= i1;
123  else if(dif==-1)
124  retval= i2;
125  else if((i1==3) && (i2==0))
126  retval= 3;
127  else if((i1==0) && (i2==3))
128  retval= 3;
129  }
130  return retval;
131  }
132 
134 template <class PhysProp>
136  {
137  ID retval(2);
139  const size_t sz= nodos.size();
140  if(i<sz)
141  {
142  retval[0]= i;
143  if(i<(sz-1))
144  retval[1]= i+1;
145  else
146  retval[1]= 0;
147  }
148  return retval;
149  }
150 
152 template <class PhysProp>
154  {
156  this->physicalProperties.getMaterialsVector().zeroInitialGeneralizedStrains(); //Removes initial deformations.
157  return;
158  }
159 
161 template <class PhysProp>
162 int XC::QuadBase4N<PhysProp>::addLoad(ElementalLoad *theLoad, double loadFactor)
163  {
164  if(this->isDead())
165  std::cerr << this->nombre_clase()
166  << "; load over inactiva element: "
167  << this->getTag() << std::endl;
168  else
169  {
170  if(const BidimStrainLoad *strainLoad= dynamic_cast<const BidimStrainLoad *>(theLoad)) //Prescribed strains.
171  {
172  static std::vector<Vector> initStrains;
173  initStrains= strainLoad->getStrains();
174  for(std::vector<Vector>::iterator i= initStrains.begin();i!=initStrains.end();i++)
175  (*i)*= loadFactor;
176  this->physicalProperties.getMaterialsVector().addInitialGeneralizedStrains(initStrains);
177  }
178  else
179  {
180  std::cerr << "QuadBase4N::addLoad -- load type unknown for element with tag: " <<
181  this->getTag() << std::endl;
182  return -1;
183  }
184  }
185  return 0;
186  }
187 
189 template <class PhysProp>
191  { return VTK_QUAD; }
192 
194 template <class PhysProp>
196  { return MED_QUAD4; }
197 
198 } // end of XC namespace
199 #endif
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
int getEdgeNodes(const Node *, const Node *) const
Returns the borde of the element que tiene por extremos los nodos being passed as parameters...
Definition: QuadBase4N.h:112
"Tritriz" of pointers to elements.
Definition: TritrizPtrNod.h:51
Element::NodesEdge getNodesEdge(const size_t &i) const
Returns the nodos de un lado of the element.
Definition: QuadBase4N.h:93
NodePtrsWithIDs theNodes
pointers to node.
Definition: ElementBase.h:49
Mesh node.
Definition: Node.h:99
TritrizPtrElem put_on_mesh(const TritrizPtrNod &, meshing_dir dm) const
Put the element on the mesh being passed as parameter.
Definition: QuadBase4N.h:88
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
int getVtkCellType(void) const
Interfaz con VTK.
Definition: QuadBase4N.h:190
ID getLocalIndexNodesEdge(const size_t &i) const
Returns the local indexes of the nodes that lie on the i-th edge.
Definition: QuadBase4N.h:135
iterator find(const int &)
Returns an iterator to the node identified by the tag being passed as parameter.
Definition: NodePtrs.cc:146
Base class for 4 node quads.
Definition: QuadBase4N.h:45
int addLoad(ElementalLoad *theLoad, double loadFactor)
Adds to the element the load being passed as parameter.
Definition: QuadBase4N.h:162
int getMEDCellType(void) const
Interfaz con el formato MED de Salome.
Definition: QuadBase4N.h:195
NodePtrsWithIDs & getNodePtrs(void)
Returns a pointer to the vector de nodos.
Definition: ElementBase.h:107
void zeroLoad(void)
Zeroes loads on element.
Definition: QuadBase4N.h:153
================================================================================
Definition: ContinuaReprComponent.h:34
QuadBase4N(int classTag, const PhysProp &pp)
Constructor.
Definition: QuadBase4N.h:69
TritrizPtrElem put_quad4N_on_mesh(const Element &e, const TritrizPtrNod &, meshing_dir dm)
Place the elements on the mesh passed as parameter.
Definition: aux_meshing.cc:127