xc
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 "PlaneElement.h"
30 
31 #ifndef QuadBase4N_h
32 #define QuadBase4N_h
33 
34 #include "preprocessor/multi_block_topology/matrices/ElemPtrArray3d.h"
35 #include "preprocessor/multi_block_topology/aux_meshing.h"
36 #include "preprocessor/prep_handlers/LoadHandler.h"
37 #include "domain/load/plane/BidimStrainLoad.h"
38 #include "vtkCellType.h"
39 
40 namespace XC {
43 template <class PhysProp>
44 class QuadBase4N : public PlaneElement<4,PhysProp>
45  {
46  protected:
47  ElemPtrArray3d put_on_mesh(const NodePtrArray3d &,meshing_dir dm) const;
48  public:
49 
50  QuadBase4N(int classTag,const PhysProp &pp);
51  QuadBase4N(int tag, int classTag,const PhysProp &);
52  QuadBase4N(int tag, int classTag, int node1, int node2, int node3, int node4,const PhysProp &pp);
53 
54  Element::NodesEdge getNodesEdge(const size_t &i) const;
55  ID getLocalIndexNodesEdge(const size_t &i) const;
56  int getEdgeNodes(const Node *,const Node *) const;
57 
58  int getVtkCellType(void) const;
59 
60  void zeroLoad(void);
61  int addLoad(ElementalLoad *theLoad, double loadFactor);
62 
63  };
64 
66 template <class PhysProp>
67  XC::QuadBase4N<PhysProp>::QuadBase4N(int classTag,const PhysProp &pp)
68  : PlaneElement<4,PhysProp>(0,classTag,pp) {}
69 
71 template <class PhysProp>
72 XC::QuadBase4N<PhysProp>::QuadBase4N(int tag,int classTag,const PhysProp &pp)
73  :PlaneElement<4,PhysProp>(tag,classTag,pp) {}
74 
76 template <class PhysProp>
77 XC::QuadBase4N<PhysProp>::QuadBase4N(int tag, int classTag, int node1, int node2, int node3, int node4,const PhysProp &pp)
78  : PlaneElement<4,PhysProp>(tag,classTag,pp)
79  {
80  this->theNodes.set_id_nodes(node1,node2,node3,node4);
81  }
82 
83 
85 template <class PhysProp>
87  { return put_quad4N_on_mesh(*this,nodes,dm); }
88 
90 template <class PhysProp>
92  {
93  Element::NodesEdge retval(2,static_cast<Node *>(nullptr));
95  const size_t sz= nodes.size();
96  if(i<sz)
97  {
98  retval[0]= nodes(i);
99  if(i<(sz-1))
100  retval[1]= nodes(i+1);
101  else
102  retval[1]= nodes(0);
103  }
104  return retval;
105  }
106 
109 template <class PhysProp>
110 int XC::QuadBase4N<PhysProp>::getEdgeNodes(const Node *n1,const Node *n2) const
111  {
112  int retval= -1;
114  const int i1= nodes.find(n1);
115  const int i2= nodes.find(n2);
116  if((i1>=0) && (i2>=0))
117  {
118  const int dif= i2-i1;
119  if(dif==1)
120  retval= i1;
121  else if(dif==-1)
122  retval= i2;
123  else if((i1==3) && (i2==0))
124  retval= 3;
125  else if((i1==0) && (i2==3))
126  retval= 3;
127  }
128  return retval;
129  }
130 
132 template <class PhysProp>
134  {
135  ID retval(2);
137  const size_t sz= nodes.size();
138  if(i<sz)
139  {
140  retval[0]= i;
141  if(i<(sz-1))
142  retval[1]= i+1;
143  else
144  retval[1]= 0;
145  }
146  return retval;
147  }
148 
150 template <class PhysProp>
152  {
154  this->physicalProperties.getMaterialsVector().zeroInitialGeneralizedStrains(); //Removes initial deformations.
155  return;
156  }
157 
159 template <class PhysProp>
160 int XC::QuadBase4N<PhysProp>::addLoad(ElementalLoad *theLoad, double loadFactor)
161  {
162  if(this->isDead())
163  std::cerr << this->getClassName()
164  << "; load over inactiva element: "
165  << this->getTag() << std::endl;
166  else
167  {
168  if(const BidimStrainLoad *strainLoad= dynamic_cast<const BidimStrainLoad *>(theLoad)) //Prescribed strains.
169  {
170  static std::vector<Vector> initStrains;
171  initStrains= strainLoad->getStrains();
172  for(std::vector<Vector>::iterator i= initStrains.begin();i!=initStrains.end();i++)
173  (*i)*= loadFactor;
174  this->physicalProperties.getMaterialsVector().addInitialGeneralizedStrains(initStrains);
175  }
176  else
177  {
178  std::cerr << "QuadBase4N::addLoad -- load type unknown for element with tag: " <<
179  this->getTag() << std::endl;
180  return -1;
181  }
182  }
183  return 0;
184  }
185 
187 template <class PhysProp>
189  { return VTK_QUAD; }
190 
191 
192 } // end of XC namespace
193 #endif
ElemPtrArray3d put_on_mesh(const NodePtrArray3d &, meshing_dir dm) const
Put the element on the mesh being passed as parameter.
Definition: QuadBase4N.h:86
std::vector< const Node * > NodesEdge
Nodes on an element edge.
Definition: Element.h:113
QuadBase4N(int classTag, const PhysProp &pp)
Constructor.
Definition: QuadBase4N.h:67
Vector of integers.
Definition: ID.h:93
Three-dimensional array of pointers to elements.
Definition: ElemPtrArray3d.h:43
iterator find(const int &)
Returns an iterator to the node identified by the tag being passed as parameter.
Definition: NodePtrs.cc:148
Base class for 4 node quads.
Definition: QuadBase4N.h:44
int getVtkCellType(void) const
Interfaz con VTK.
Definition: QuadBase4N.h:188
ID getLocalIndexNodesEdge(const size_t &i) const
Returns the local indexes of the nodes that lie on the i-th edge.
Definition: QuadBase4N.h:133
Element::NodesEdge getNodesEdge(const size_t &i) const
Returns the nodes de un lado of the element.
Definition: QuadBase4N.h:91
Node pointer container for elements.
Definition: NodePtrsWithIDs.h:45
int addLoad(ElementalLoad *theLoad, double loadFactor)
Adds to the element the load being passed as parameter.
Definition: QuadBase4N.h:160
Three-dimensional array of pointers to nodes.
Definition: NodePtrArray3d.h:50
Open source finite element program for structural analysis.
Definition: ContinuaReprComponent.h:34
Base class for loads over elements.
Definition: ElementalLoad.h:77
Load due to restricted material expansion or contraction on bidimensional elements.
Definition: BidimStrainLoad.h:38
Mesh node.
Definition: Node.h:110
Base class for plane elements.
Definition: PlaneElement.h:48
void zeroLoad(void)
Zeroes loads on element.
Definition: QuadBase4N.h:151
int getEdgeNodes(const Node *, const Node *) const
Returns the edge of the element that ends in the nodes being passed as parameters.
Definition: QuadBase4N.h:110
ElemPtrArray3d put_quad4N_on_mesh(const Element &e, const NodePtrArray3d &, meshing_dir dm)
Place the elements on the mesh passed as parameter.
Definition: aux_meshing.cc:127