XC Open source finite element analysis program
ElemWithMaterial.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 //ElemWithMaterials.h
28 
29 #ifndef ElemWithMaterial_h
30 #define ElemWithMaterial_h
31 
32 #include <domain/mesh/element/ElementBase.h>
33 
34 namespace XC {
35 
37 //
39 template <int NNODOS,class PhysProp>
40 class ElemWithMaterial : public ElementBase<NNODOS>
41  {
42  protected:
43  PhysProp physicalProperties;
44 
45  int sendData(CommParameters &);
46  int recvData(const CommParameters &);
47 
48  public:
49  ElemWithMaterial(int tag, int classTag);
50  ElemWithMaterial(int tag, int classTag,const PhysProp &);
51 
52  // public methods to set the state of the element
53  int commitState(void);
54  int revertToLastCommit(void);
55  int revertToStart(void);
56 
57  virtual void zeroInitialGeneralizedStrains(void);
58 
59  inline PhysProp &getPhysicalProperties(void)
60  { return physicalProperties; }
61  inline const PhysProp &getPhysicalProperties(void) const
62  { return physicalProperties; }
63  void setPhysicalProperties(const PhysProp &);
64  };
65 
66 template <int NNODOS,class PhysProp>
68  : ElementBase<NNODOS>(tag,classTag) {}
69 
70 template <int NNODOS,class PhysProp>
71 ElemWithMaterial<NNODOS,PhysProp>::ElemWithMaterial(int tag, int classTag,const PhysProp &physProp)
72  : ElementBase<NNODOS>(tag,classTag), physicalProperties(physProp) {}
73 
74 template <int NNODOS,class PhysProp>
76  {
77  int retVal = 0;
78 
79  if((retVal= ElementBase<NNODOS>::commitState()) != 0)
80  {
81  std::cerr << "ElemWithMaterial::commitState () - failed in base class";
82  return (-1);
83  }
84  retVal+= physicalProperties.commitState();
85  return retVal;
86  }
87 
88 template <int NNODOS,class PhysProp>
90  {
91  int retval= physicalProperties.revertToLastCommit();
92  return retval;
93  }
94 
95 template <int NNODOS,class PhysProp>
97  {
99  retval+= physicalProperties.revertToStart();
100  return retval;
101  }
102 
103 template <int NNODOS,class PhysProp>
105  {
106  physicalProperties.getMaterialsVector().zeroInitialGeneralizedStrains();
107  }
108 
109 template <int NNODOS,class PhysProp>
111  { physicalProperties= physProp; }
112 
113 
115 template <int NNODOS,class PhysProp>
117  {
118  int res= ElementBase<NNODOS>::sendData(cp);
119  res+= cp.sendMovable(physicalProperties,this->getDbTagData(),CommMetaData(7));
120  return res;
121  }
122 
124 template <int NNODOS,class PhysProp>
126  {
127  int res= ElementBase<NNODOS>::recvData(cp);
128  res+= cp.receiveMovable(physicalProperties,this->getDbTagData(),CommMetaData(7));
129  return res;
130  }
131 
132 } //end of XC namespace
133 #endif
int sendMovable(MovableObject &, DbTagData &, const CommMetaData &)
Sends a movable object through the channel being passed as parameter.
Definition: CommParameters.cc:959
Element with material.
Definition: ElemWithMaterial.h:40
int commitState(void)
Consuma el estado of the element.
Definition: ElemWithMaterial.h:75
int recvData(const CommParameters &)
Receives members through the channel being passed as parameter.
Definition: ElemWithMaterial.h:125
int receiveMovable(MovableObject &, DbTagData &, const CommMetaData &) const
Receives a movable object trhrough the channel being passed as parameter.
Definition: CommParameters.cc:969
PhysProp physicalProperties
pointers to the material objects and physical properties.
Definition: ElemWithMaterial.h:43
int sendData(CommParameters &)
Send members through the channel being passed as parameter.
Definition: ElemWithMaterial.h:116
Base class for finite element with pointer to nodes container.
Definition: ElementBase.h:46
Communication parameters between processes.
Definition: CommParameters.h:65
================================================================================
Definition: ContinuaReprComponent.h:34
Data about the index, size,,... of the object to transmit.
Definition: CommMetaData.h:38