XC Open source finite element analysis program
ElementBase.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 //ElementBase.h
28 
29 #ifndef ElementBase_h
30 #define ElementBase_h
31 
32 #include "Element.h"
33 #include "domain/mesh/element/utils/NodePtrsWithIDs.h"
34 #include "material/Material.h"
35 #include "domain/domain/Domain.h"
36 #include "xc_utils/src/geom/pos_vec/Pos3d.h"
37 
38 namespace XC {
39 class Node;
40 
42 //
45 template <int NNODOS>
46 class ElementBase: public Element
47  {
48  protected:
50 
51  template <class TIPOMAT>
52  TIPOMAT *cast_material(const Material *ptr_mat);
53 
54  int sendData(CommParameters &cp);
55  int recvData(const CommParameters &cp);
56 
57  public:
58  ElementBase(int tag, int classTag);
59  ElementBase(const ElementBase &otro);
60  ElementBase &operator=(const ElementBase &otro);
61 
63  static inline const int numNodos(void)
64  { return NNODOS; }
65  // public methods to obtain inforrmation about dof & connectivity
66  int getNumExternalNodes(void) const;
68  const NodePtrsWithIDs &getNodePtrs(void) const;
69  Pos3d getPosCdg(bool initialGeometry= true) const;
70  };
71 
72 
73 
75 template <int NNODOS>
77  : Element(tag,classTag), theNodes(this,NNODOS) {}
78 
80 template <int NNODOS>
82  : Element(otro), theNodes(otro.theNodes)
83  { theNodes.set_owner(this); }
84 
86 template <int NNODOS>
88  {
89  Element::operator=(otro);
90  theNodes= otro.theNodes;
91  theNodes.set_owner(this);
92  return *this;
93  }
94 
96 template <int NNODOS>
98  { return theNodes.size(); }
99 
101 template <int NNODOS>
103  { return theNodes; }
104 
106 template <int NNODOS>
108  { return theNodes; }
109 
111 template <int NNODOS> template <class TIPOMAT>
113  {
114  TIPOMAT *retval= nullptr;
115  const TIPOMAT *tmp = dynamic_cast<const TIPOMAT *>(ptr_mat);
116  if(tmp)
117  retval= tmp->getCopy();
118  else
119  {
120  std::cerr << nombre_clase() << "::" << __FUNCTION__
121  << "; on element: " << getTag()
122  << " the material " << ptr_mat->getTag()
123  << " has not a suitable type." << std::endl;
124  abort();
125  }
126  if(!retval)
127  {
128  std::cerr << nombre_clase() << "::" << __FUNCTION__
129  << "; on element: " << getTag()
130  << "can't get a copy of the material with tag: "
131  << ptr_mat->getTag() << std::endl;
132  abort();
133  }
134  return retval;
135  }
136 
138 template <int NNODOS>
140  {
141  int res= Element::sendData(cp);
143  return res;
144  }
145 
147 template <int NNODOS>
149  {
150  int res= Element::recvData(cp);
152  return res;
153  }
154 
156 template <int NNODOS>
157 Pos3d XC::ElementBase<NNODOS>::getPosCdg(bool initialGeometry) const
158  { return theNodes.getPosCdg(initialGeometry); }
159 
160 } //end of XC namespace
161 #endif
int sendMovable(MovableObject &, DbTagData &, const CommMetaData &)
Sends a movable object through the channel being passed as parameter.
Definition: CommParameters.cc:959
virtual DbTagData & getDbTagData(void) const
Returns a vector to store class dbTags.
Definition: DistributedBase.cc:39
int sendData(CommParameters &cp)
Send members through the channel being passed as parameter.
Definition: ElementBase.h:139
MovableObject & operator=(const MovableObject &otro)
Operacdor asignación.
Definition: MovableObject.cpp:81
Base class for materials.
Definition: Material.h:85
NodePtrsWithIDs theNodes
pointers to node.
Definition: ElementBase.h:49
TIPOMAT * cast_material(const Material *ptr_mat)
Casts the material pointer to a suitable type.
Definition: ElementBase.h:112
Base calass for the finite elements.
Definition: Element.h:104
int receiveMovable(MovableObject &, DbTagData &, const CommMetaData &) const
Receives a movable object trhrough the channel being passed as parameter.
Definition: CommParameters.cc:969
Node pointer container for elements.
Definition: NodePtrsWithIDs.h:45
Pos3d getPosCdg(bool initialGeometry=true) const
Return position of the element centroid.
Definition: ElementBase.h:157
Base class for finite element with pointer to nodes container.
Definition: ElementBase.h:46
int getNumExternalNodes(void) const
Return the number of external nodes.
Definition: ElementBase.h:97
ElementBase & operator=(const ElementBase &otro)
Assignment operator.
Definition: ElementBase.h:87
static const int numNodos(void)
Returns the element number of nodes.
Definition: ElementBase.h:63
int sendData(CommParameters &cp)
Sends object members through the channel being passed as parameter.
Definition: Element.cpp:939
NodePtrsWithIDs & getNodePtrs(void)
Returns a pointer to the vector de nodos.
Definition: ElementBase.h:107
Communication parameters between processes.
Definition: CommParameters.h:65
ElementBase(int tag, int classTag)
Default constructor.
Definition: ElementBase.h:76
================================================================================
Definition: ContinuaReprComponent.h:34
int recvData(const CommParameters &cp)
Receives object members through the channel being passed as parameter.
Definition: Element.cpp:948
Data about the index, size,,... of the object to transmit.
Definition: CommMetaData.h:38
int recvData(const CommParameters &cp)
Receives members through the channel being passed as parameter.
Definition: ElementBase.h:148
Pos3d getPosCdg(bool initialGeometry=true) const
Returns the centro de gravedad de las posiciones of the nodes.
Definition: NodePtrs.cc:371