xc
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  inline virtual std::set<std::string> getMaterialNames(void) const
65  { return physicalProperties.getMaterialNames(); }
66  };
67 
68 template <int NNODOS,class PhysProp>
70  : ElementBase<NNODOS>(tag,classTag) {}
71 
72 template <int NNODOS,class PhysProp>
73 ElemWithMaterial<NNODOS,PhysProp>::ElemWithMaterial(int tag, int classTag,const PhysProp &physProp)
74  : ElementBase<NNODOS>(tag,classTag), physicalProperties(physProp) {}
75 
76 template <int NNODOS,class PhysProp>
78  {
79  int retVal = 0;
80 
81  if((retVal= ElementBase<NNODOS>::commitState()) != 0)
82  {
83  std::cerr << "ElemWithMaterial::commitState () - failed in base class";
84  return (-1);
85  }
86  retVal+= physicalProperties.commitState();
87  return retVal;
88  }
89 
90 template <int NNODOS,class PhysProp>
92  {
93  int retval= physicalProperties.revertToLastCommit();
94  return retval;
95  }
96 
97 template <int NNODOS,class PhysProp>
99  {
101  retval+= physicalProperties.revertToStart();
102  return retval;
103  }
104 
105 template <int NNODOS,class PhysProp>
107  {
108  physicalProperties.getMaterialsVector().zeroInitialGeneralizedStrains();
109  }
110 
111 template <int NNODOS,class PhysProp>
113  { physicalProperties= physProp; }
114 
115 
117 template <int NNODOS,class PhysProp>
119  {
120  int res= ElementBase<NNODOS>::sendData(cp);
122  return res;
123  }
124 
126 template <int NNODOS,class PhysProp>
128  {
129  int res= ElementBase<NNODOS>::recvData(cp);
131  return res;
132  }
133 
134 } //end of XC namespace
135 #endif
int revertToStart(void)
Reverts the element to its initial state.
Definition: ElemWithMaterial.h:98
virtual int revertToStart(void)
Reverts the element to its initial state.
Definition: Element.cpp:140
virtual std::set< std::string > getMaterialNames(void) const
Return the names of the material(s) of the element.
Definition: ElemWithMaterial.h:64
int sendData(CommParameters &cp)
Send members through the channel being passed as parameter.
Definition: ElementBase.h:139
int commitState(void)
Commit the current element state.
Definition: ElemWithMaterial.h:77
int receiveMovable(MovableObject &, DbTagData &, const CommMetaData &) const
Receives a movable object trhrough the channel being passed as parameter.
Definition: CommParameters.cc:1076
Data about the index, size,,...
Definition: CommMetaData.h:38
PhysProp physicalProperties
pointers to the material objects and physical properties.
Definition: ElemWithMaterial.h:43
virtual DbTagData & getDbTagData(void) const
Returns a vector to store class dbTags.
Definition: DistributedBase.cc:39
int recvData(const CommParameters &cp)
Receives members through the channel being passed as parameter.
Definition: ElementBase.h:148
Open source finite element program for structural analysis.
Definition: ContinuaReprComponent.h:34
int sendData(CommParameters &)
Send members through the channel being passed as parameter.
Definition: ElemWithMaterial.h:118
int recvData(const CommParameters &)
Receives members through the channel being passed as parameter.
Definition: ElemWithMaterial.h:127
Base class for finite element with pointer to nodes container.
Definition: ElementBase.h:46
Element with material.
Definition: ElemWithMaterial.h:40
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
int revertToLastCommit(void)
Revert to the last commited state.
Definition: ElemWithMaterial.h:91