xc
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 "PlaneElement.h"
30 
31 #ifndef TriBase3N_h
32 #define TriBase3N_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 {
42 //
44 template <class PhysProp> //3 Gauss point by default.
45 class TriBase3N: public PlaneElement<3,PhysProp>
46  {
47  protected:
48  ElemPtrArray3d put_on_mesh(const NodePtrArray3d &,meshing_dir dm) const;
49  public:
50 
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  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 
61  void zeroLoad(void);
62  int addLoad(ElementalLoad *theLoad, double loadFactor);
63 
64  };
65 
67 template <class PhysProp>
68 XC::TriBase3N<PhysProp>::TriBase3N(int classTag,const PhysProp &pp)
69  : PlaneElement<3,PhysProp>(0,classTag,pp) {}
70 
72 template <class PhysProp>
73 XC::TriBase3N<PhysProp>::TriBase3N(int tag,int classTag,const PhysProp &physProp)
74  :PlaneElement<3,PhysProp>(tag,classTag,physProp) {}
75 
77 template <class PhysProp>
78 XC::TriBase3N<PhysProp>::TriBase3N(int tag, int classTag, int node1, int node2, int node3,const PhysProp &pp)
79  : PlaneElement<3,PhysProp>(tag,classTag,pp)
80  {
81  this->theNodes.set_id_nodes(node1,node2,node3);
82  }
83 
85 template <class PhysProp>
87  {
88  std::cerr << "ElemPtrArray3d XC::TriBase3N<PhysProp>::put_on_mesh not implemented" << std::endl;
89  ElemPtrArray3d retval;
90  return retval;
91  }
92 
94 template <class PhysProp>
96  {
97  Element::NodesEdge retval(2,static_cast<Node *>(nullptr));
99  const size_t sz= nodes.size();
100  if(i<sz)
101  {
102  retval[0]= nodes(i);
103  if(i<(sz-1))
104  retval[1]= nodes(i+1);
105  else
106  retval[1]= nodes(0);
107  }
108  return retval;
109  }
110 
113 template <class PhysProp>
114 int XC::TriBase3N<PhysProp>::getEdgeNodes(const Node *n1,const Node *n2) const
115  {
116  int retval= -1;
118  const int i1= nodes.find(n1);
119  const int i2= nodes.find(n2);
120  if((i1>=0) && (i2>=0))
121  {
122  const int dif= i2-i1;
123  if(dif==1)
124  retval= i1;
125  else if(dif==-1)
126  retval= i2;
127  else if((i1==3) && (i2==0))
128  retval= 3;
129  else if((i1==0) && (i2==3))
130  retval= 3;
131  }
132  return retval;
133  }
134 
136 template <class PhysProp>
138  {
139  ID retval(2);
141  const size_t sz= nodes.size();
142  if(i<sz)
143  {
144  retval[0]= i;
145  if(i<(sz-1))
146  retval[1]= i+1;
147  else
148  retval[1]= 0;
149  }
150  return retval;
151  }
152 
154 template <class PhysProp>
156  {
158  this->physicalProperties.getMaterialsVector().zeroInitialGeneralizedStrains(); //Removes initial deformations.
159  return;
160  }
161 
163 template <class PhysProp>
164 int XC::TriBase3N<PhysProp>::addLoad(ElementalLoad *theLoad, double loadFactor)
165  {
166  if(this->isDead())
167  std::cerr << this->getClassName()
168  << "; load over inactive element: "
169  << this->getTag() << std::endl;
170  else
171  {
172  if(const BidimStrainLoad *strainLoad= dynamic_cast<const BidimStrainLoad *>(theLoad)) //Prescribed deformations.
173  {
174  static std::vector<Vector> initStrains;
175  initStrains= strainLoad->getStrains();
176  for(std::vector<Vector>::iterator i= initStrains.begin();i!=initStrains.end();i++)
177  (*i)*= loadFactor;
178  this->physicalProperties.getMaterialsVector().addInitialGeneralizedStrains(initStrains);
179  }
180  else
181  {
182  std::cerr << "TriBase3N::addLoad -- load type unknown for element with tag: " <<
183  this->getTag() << std::endl;
184  return -1;
185  }
186  }
187  return 0;
188  }
189 
191 template <class PhysProp>
193  { return VTK_TRIANGLE; }
194 
195 } // end of XC namespace
196 #endif
std::vector< const Node * > NodesEdge
Nodes on an element edge.
Definition: Element.h:113
TriBase3N(int classTag, const PhysProp &)
Constructor.
Definition: TriBase3N.h:68
Element::NodesEdge getNodesEdge(const size_t &i) const
Returns the nodes de un lado of the element.
Definition: TriBase3N.h:95
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
int getVtkCellType(void) const
Interfaz con VTK.
Definition: TriBase3N.h:192
Base class for 3 node triangles.
Definition: TriBase3N.h:45
void zeroLoad(void)
Zeroes loads on element.
Definition: TriBase3N.h:155
ID getLocalIndexNodesEdge(const size_t &i) const
Returns the local indexes of the nodes that lies on the i-th edge.
Definition: TriBase3N.h:137
int addLoad(ElementalLoad *theLoad, double loadFactor)
Adds to the element the load being passed as parameter.
Definition: TriBase3N.h:164
Node pointer container for elements.
Definition: NodePtrsWithIDs.h:45
Three-dimensional array of pointers to nodes.
Definition: NodePtrArray3d.h:50
Open source finite element program for structural analysis.
Definition: ContinuaReprComponent.h:34
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:114
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
ElemPtrArray3d put_on_mesh(const NodePtrArray3d &, meshing_dir dm) const
Put the element on the mesh being passed as parameter.
Definition: TriBase3N.h:86
Base class for plane elements.
Definition: PlaneElement.h:48