xc
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 NNODES>
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 &);
61 
63  static inline const int numNodes(void)
64  { return NNODES; }
65  // public methods to obtain inforrmation about dof & connectivity
66  int getNumExternalNodes(void) const;
68  const NodePtrsWithIDs &getNodePtrs(void) const;
69  Pos3d getCenterOfMassPosition(bool initialGeometry= true) const;
70  };
71 
72 
73 
75 template <int NNODES>
77  : Element(tag,classTag), theNodes(this,NNODES) {}
78 
80 template <int NNODES>
82  : Element(other), theNodes(other.theNodes)
83  { theNodes.set_owner(this); }
84 
86 template <int NNODES>
88  {
89  Element::operator=(other);
90  theNodes= other.theNodes;
91  theNodes.set_owner(this);
92  return *this;
93  }
94 
96 template <int NNODES>
98  { return theNodes.size(); }
99 
101 template <int NNODES>
103  { return theNodes; }
104 
106 template <int NNODES>
108  { return theNodes; }
109 
111 template <int NNODES> 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 << getClassName() << "::" << __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 << getClassName() << "::" << __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 NNODES>
140  {
141  int res= Element::sendData(cp);
142  res+= cp.sendMovable(theNodes,getDbTagData(),CommMetaData(6));
143  return res;
144  }
145 
147 template <int NNODES>
149  {
150  int res= Element::recvData(cp);
151  res+= cp.receiveMovable(theNodes,getDbTagData(),CommMetaData(6));
152  return res;
153  }
154 
156 template <int NNODES>
157 Pos3d XC::ElementBase<NNODES>::getCenterOfMassPosition(bool initialGeometry) const
158  { return theNodes.getCenterOfMassPosition(initialGeometry); }
159 
160 } //end of XC namespace
161 #endif
NodePtrsWithIDs theNodes
pointers to node.
Definition: ElementBase.h:49
int getNumExternalNodes(void) const
Return the number of external nodes.
Definition: ElementBase.h:97
int sendData(CommParameters &cp)
Send members through the channel being passed as parameter.
Definition: ElementBase.h:139
int receiveMovable(MovableObject &, DbTagData &, const CommMetaData &) const
Receives a movable object trhrough the channel being passed as parameter.
Definition: CommParameters.cc:1076
Base class for materials.
Definition: Material.h:91
Data about the index, size,,...
Definition: CommMetaData.h:38
Pos3d getCenterOfMassPosition(bool initialGeometry=true) const
Return position of the element centroid.
Definition: ElementBase.h:157
Base class for the finite elements.
Definition: Element.h:109
int recvData(const CommParameters &cp)
Receives members through the channel being passed as parameter.
Definition: ElementBase.h:148
TIPOMAT * cast_material(const Material *ptr_mat)
Casts the material pointer to a suitable type.
Definition: ElementBase.h:112
ElementBase & operator=(const ElementBase &)
Assignment operator.
Definition: ElementBase.h:87
ElementBase(int tag, int classTag)
Default constructor.
Definition: ElementBase.h:76
Node pointer container for elements.
Definition: NodePtrsWithIDs.h:45
NodePtrsWithIDs & getNodePtrs(void)
Returns a pointer to the node vector.
Definition: ElementBase.h:107
Open source finite element program for structural analysis.
Definition: ContinuaReprComponent.h:34
int getTag(void) const
Returns the tag associated with the object.
Definition: TaggedObject.h:116
Base class for finite element with pointer to nodes container.
Definition: ElementBase.h:46
Communication parameters between processes.
Definition: CommParameters.h:65
int sendMovable(MovableObject &, DbTagData &, const CommMetaData &)
Sends a movable object through the channel being passed as parameter.
Definition: CommParameters.cc:1066
static const int numNodes(void)
Returns the element number of nodes.
Definition: ElementBase.h:63