xc
QuadBase4N.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 //QuadBase4N.h
29 
30 #include "PlaneElement.h"
31 
32 #ifndef QuadBase4N_h
33 #define QuadBase4N_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 {
44 template <class PhysProp>
45 class QuadBase4N: public PlaneElement<4,PhysProp>
46  {
47  static Matrix &compute_extrapolation_matrix(void);
48  protected:
49  ElemPtrArray3d put_on_mesh(const NodePtrArray3d &,meshing_dir dm) const;
50  public:
51  QuadBase4N(int classTag, const PhysProp &);
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  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  double getRho(void) const;
61  void setRho(const double &);
62  double getThickness(void) const;
63  void setThickness(const double &);
64 
65  int getVtkCellType(void) const;
66 
67  void zeroLoad(void);
68  int addLoad(ElementalLoad *theLoad, double loadFactor);
69 
70  Matrix getTrfMatrix(void) const;
71  Matrix getLocalAxes(bool initialGeometry= true) const;
72  const Matrix &getExtrapolationMatrix(void) const;
73  };
74 
76 template <class PhysProp>
77  XC::QuadBase4N<PhysProp>::QuadBase4N(int classTag,const PhysProp &pp)
78  : PlaneElement<4,PhysProp>(0,classTag,pp) {}
79 
81 template <class PhysProp>
82 XC::QuadBase4N<PhysProp>::QuadBase4N(int tag,int classTag,const PhysProp &pp)
83  :PlaneElement<4,PhysProp>(tag,classTag,pp) {}
84 
86 template <class PhysProp>
87 XC::QuadBase4N<PhysProp>::QuadBase4N(int tag, int classTag, int node1, int node2, int node3, int node4,const PhysProp &pp)
88  : PlaneElement<4,PhysProp>(tag,classTag,pp)
89  {
90  this->theNodes.set_id_nodes(node1,node2,node3,node4);
91  }
92 
96 template <class PhysProp>
98  {
99  BoolArray3d retval(1,2,2,true); //One layer, two rows, two columns.
100  return retval;
101  }
102 
104 template <class PhysProp>
106  { return put_quad4N_on_mesh(*this,nodes,dm); }
107 
109 template <class PhysProp>
111  {
112  Element::NodesEdge retval(2,static_cast<Node *>(nullptr));
114  const size_t sz= nodes.size();
115  if(i<sz)
116  {
117  retval[0]= nodes(i);
118  if(i<(sz-1))
119  retval[1]= nodes(i+1);
120  else
121  retval[1]= nodes(0);
122  }
123  return retval;
124  }
125 
128 template <class PhysProp>
129 int XC::QuadBase4N<PhysProp>::getEdgeNodes(const Node *n1,const Node *n2) const
130  {
131  int retval= -1;
133  const int i1= nodes.find(n1);
134  const int i2= nodes.find(n2);
135  if((i1>=0) && (i2>=0))
136  {
137  const int dif= i2-i1;
138  if(dif==1)
139  retval= i1;
140  else if(dif==-1)
141  retval= i2;
142  else if((i1==3) && (i2==0))
143  retval= 3;
144  else if((i1==0) && (i2==3))
145  retval= 3;
146  }
147  return retval;
148  }
149 
151 template <class PhysProp>
153  {
154  ID retval(2);
156  const size_t sz= nodes.size();
157  if(i<sz)
158  {
159  retval[0]= i;
160  if(i<(sz-1))
161  retval[1]= i+1;
162  else
163  retval[1]= 0;
164  }
165  return retval;
166  }
167 
169 template <class PhysProp>
171  { return this->physicalProperties.getArealRho(); }
172 
174 template <class PhysProp>
175 void XC::QuadBase4N<PhysProp>::setRho(const double &r)
176  { this->physicalProperties.setArealRho(r); }
177 
179 template <class PhysProp>
181  { return this->physicalProperties.getThickness(); }
182 
184 template <class PhysProp>
186  { this->physicalProperties.setThickness(t); }
187 
189 template <class PhysProp>
191  {
193  this->physicalProperties.getMaterialsVector().zeroInitialGeneralizedStrains(); //Removes initial deformations.
194  return;
195  }
196 
198 template <class PhysProp>
199 int XC::QuadBase4N<PhysProp>::addLoad(ElementalLoad *theLoad, double loadFactor)
200  {
201  if(this->isDead())
202  std::cerr << this->getClassName()
203  << "; load over inactive element: "
204  << this->getTag() << std::endl;
205  else
206  {
207  if(const BidimStrainLoad *strainLoad= dynamic_cast<const BidimStrainLoad *>(theLoad)) //Prescribed strains.
208  {
209  static std::vector<Vector> initStrains;
210  initStrains= strainLoad->getStrains();
211  for(std::vector<Vector>::iterator i= initStrains.begin();i!=initStrains.end();i++)
212  (*i)*= loadFactor;
213  this->physicalProperties.getMaterialsVector().incrementInitialGeneralizedStrains(initStrains);
214  }
215  else
216  {
217  std::cerr << this->getClassName() << "::" << __FUNCTION__
218  << "; load type unknown for element with tag: " <<
219  this->getTag() << std::endl;
220  return -1;
221  }
222  }
223  return 0;
224  }
225 
227 template <class PhysProp>
229  { return VTK_QUAD; }
230 
233 template <class PhysProp>
235  {
236  static Vector v1(2);
237  static Vector v2(2);
238 
239  //get two vectors (v1, v2) in plane of shell by
240  // nodal coordinate differences
241 
243  const Vector &coor0= theNodes[0]->getCrds();
244  const Vector &coor1= theNodes[1]->getCrds();
245  const Vector &coor2= theNodes[2]->getCrds();
246  const Vector &coor3= theNodes[3]->getCrds();
247 
248  v1.Zero( );
249  //v1= 0.5 * ( coor2 + coor1 - coor3 - coor0 );
250  v1= coor2;
251  v1+= coor1;
252  v1-= coor3;
253  v1-= coor0;
254  v1*= 0.50;
255 
256  //normalize v1
257  //double length= LovelyNorm( v1 );
258  double length= v1.Norm( );
259  v1/= length;
260 
261  v2.Zero( );
262  //v2= 0.5 * ( coor3 + coor2 - coor1 - coor0 );
263  v2= coor3;
264  v2+= coor2;
265  v2-= coor1;
266  v2-= coor0;
267  v2*= 0.50;
268 
269  //Gram-Schmidt process for v2
270 
271  //double alpha= LovelyInnerProduct( v2, v1 );
272  const double alpha= v2^v1;
273 
274  //v2 -= alpha*v1;
275  static Vector temp(3);
276  temp= v1;
277  temp*= alpha;
278  v2-= temp;
279 
280 
281  //normalize v2
282  //length= LovelyNorm( v2 );
283  length= v2.Norm( );
284  v2/= length;
285 
286  Matrix R(2,2);
287  // Fill in transformation matrix
288  R(0,0)= v1(0); R(0,1)= v1(1);
289  R(1,0)= v2(0); R(1,1)= v2(1);
290  return R;
291  }
292 
295 template <class PhysProp>
297  {
298  if(!initialGeometry)
299  std::cerr << this->getClassName() << "::" << __FUNCTION__
300  << "; for deformed geometry not implemented."
301  << std::endl;
302  return getTrfMatrix();
303  }
304 
305 
308 template <class PhysProp>
310  {
311  const double r3div2= sqrt(3)/2.0;
312  const double dg= 1.0+r3div2;
313  const double m= 1.0-r3div2;
314  static Matrix retval(4,4); // 4 nodes 4 gauss points
315  // Fill in transformation matrix
316  retval(0,0)= dg; retval(0,1)= -0.5; retval(0,2)= m; retval(0,3)= -0.5;
317  retval(1,0)= -0.5; retval(1,1)= dg; retval(1,2)= -0.5; retval(1,3)= m;
318  retval(2,0)= m; retval(2,1)= -0.5; retval(2,2)= dg; retval(2,3)= -0.5; retval(3,0)= -0.5; retval(3,1)= m; retval(3,2)= -0.5; retval(3,3)= dg;
319  return retval;
320 
321  }
322 
325 template <class PhysProp>
327  {
328  static const Matrix retval= compute_extrapolation_matrix();
329  return retval;
330  }
331 
332 } // end of XC namespace
333 #endif
ElemPtrArray3d put_on_mesh(const NodePtrArray3d &, meshing_dir dm) const
Put the element on the mesh being passed as parameter.
Definition: QuadBase4N.h:105
std::vector< const Node * > NodesEdge
Nodes on an element edge.
Definition: Element.h:116
Float vector abstraction.
Definition: Vector.h:94
Base class for grids of bool in 3D (used to express if something exists or not in a (layer...
Definition: BoolArray3d.h:34
double getThickness(void) const
Return material density.
Definition: QuadBase4N.h:180
QuadBase4N(int classTag, const PhysProp &)
Constructor.
Definition: QuadBase4N.h:77
double Norm(void) const
Return the norm of vector.
Definition: Vector.cpp:780
Vector of integers.
Definition: ID.h:95
void Zero(void)
Zeros out the Vector, i.e.
Definition: Vector.h:263
BoolArray3d getNodePattern(void) const
Return a grid of booleans, one for each of the element nodes.
Definition: QuadBase4N.h:97
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
const Matrix & getExtrapolationMatrix(void) const
Return the matrix that can be used to extrapolate the results from the Gauss points to the element no...
Definition: QuadBase4N.h:326
Base class for 4 node quads.
Definition: QuadBase4N.h:45
int getVtkCellType(void) const
Interfaz con VTK.
Definition: QuadBase4N.h:228
ID getLocalIndexNodesEdge(const size_t &i) const
Returns the local indexes of the nodes that lie on the i-th edge.
Definition: QuadBase4N.h:152
void setThickness(const double &)
Return material density.
Definition: QuadBase4N.h:185
double getRho(void) const
Return material density (mass per surface unit).
Definition: QuadBase4N.h:170
void setRho(const double &)
Return material density.
Definition: QuadBase4N.h:175
Matrix getTrfMatrix(void) const
Returns a matrix with the axes of the element as matrix rows [[x1,y1,z1],[x2,y2,z2],...·].
Definition: QuadBase4N.h:234
Element::NodesEdge getNodesEdge(const size_t &i) const
Returns the nodes de un lado of the element.
Definition: QuadBase4N.h:110
Node pointer container for elements.
Definition: NodePtrsWithIDs.h:46
int addLoad(ElementalLoad *theLoad, double loadFactor)
Adds to the element the load being passed as parameter.
Definition: QuadBase4N.h:199
Three-dimensional array of pointers to nodes.
Definition: NodePtrArray3d.h:51
Open source finite element program for structural analysis.
Definition: ContinuaReprComponent.h:35
Matrix of floats.
Definition: Matrix.h:111
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
Base class for plane elements.
Definition: PlaneElement.h:55
void zeroLoad(void)
Zeroes loads on element.
Definition: QuadBase4N.h:190
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:129
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:136
Matrix getLocalAxes(bool initialGeometry=true) const
Returns a matrix with the axes of the element as matrix rows [[x1,y1,z1],[x2,y2,z2],...·].
Definition: QuadBase4N.h:296