XC Open source finite element analysis program
PhysicalProperties.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 //PhysicalProperties.h
28 
29 #ifndef PhysicalProperties_h
30 #define PhysicalProperties_h
31 
32 #include "utility/actor/actor/MovableObject.h"
33 #include "material/MaterialVector.h"
34 
35 namespace XC {
36 
38 //
40 //
42 //
44 template <class MAT>
45 class PhysicalProperties: public EntCmd, public MovableObject
46  {
47  public:
49  protected:
50  material_vector theMaterial;
51 
52  DbTagData &getDbTagData(void) const;
53  int sendData(CommParameters &);
54  int recvData(const CommParameters &);
55 
56  public:
57  PhysicalProperties(const size_t &nMat= 0,const MAT *matModel= nullptr);
58  void setMaterial(const MAT *);
59  void setMaterial(const MAT *,const std::string &tipo);
60  void setMaterial(size_t i,const MAT *);
61 
62  // public methods to set the state of the properties
63  int commitState(void);
64  int revertToLastCommit(void);
65  int revertToStart(void);
66 
67  inline size_t size(void) const
68  { return theMaterial.size(); }
69  inline material_vector &getMaterialsVector(void)
70  { return theMaterial; }
71  inline const material_vector &getMaterialsVector(void) const
72  { return theMaterial; }
73 
74  inline MAT *operator[](const size_t &i)
75  { return theMaterial[i]; }
76  inline const MAT *operator[](const size_t &i) const
77  { return theMaterial[i]; }
78 
79  int sendSelf(CommParameters &);
80  int recvSelf(const CommParameters &);
81 
82  virtual void Print(std::ostream &s, int);
83  };
84 
85 template <class MAT>
86 PhysicalProperties<MAT>::PhysicalProperties(const size_t &nMat,const MAT *matModel)
87  : MovableObject(0), theMaterial(nMat, matModel) {}
88 
89 template <class MAT>
91  { return theMaterial.commitState(); }
92 
93 template <class MAT>
95  { return theMaterial.revertToLastCommit(); }
96 
97 template <class MAT>
99  { return theMaterial.revertToStart(); }
100 
101 template <class MAT>
102 void PhysicalProperties<MAT>::setMaterial(const MAT *matModel)
103  { theMaterial.setMaterial(matModel); }
104 
105 template <class MAT>
106 void PhysicalProperties<MAT>::setMaterial(const MAT *matModel, const std::string &tipo)
107  { theMaterial.setMaterial(matModel,tipo); }
108 
111 template <class MAT>
113  {
114  static DbTagData retval(2);
115  return retval;
116  }
117 
119 template <class MAT>
121  {
122  int res= cp.sendMovable(theMaterial,this->getDbTagData(),CommMetaData(1));
123  return res;
124  }
125 
127 template <class MAT>
129  {
130  int res= cp.receiveMovable(theMaterial,this->getDbTagData(),CommMetaData(1));
131  return res;
132  }
133 
135 template <class MAT>
137  {
138  inicComm(2);
139 
140  int res= this->sendData(cp);
141 
142  const int dataTag= getDbTag();
143  res += cp.sendIdData(getDbTagData(),dataTag);
144  if(res < 0)
145  std::cerr << "PhysicalProperties::sendSelf -- failed to send ID data\n";
146  return res;
147  }
148 
150 template <class MAT>
152  {
153  inicComm(2);
154 
155  const int dataTag= getDbTag();
156  int res= cp.receiveIdData(getDbTagData(),dataTag);
157  if(res<0)
158  std::cerr << "PhysicalProperties::recvSelf -- failed to receive ID data\n";
159  else
160  res+= this->recvData(cp);
161  return res;
162  }
163 
165 template <class MAT>
166 void PhysicalProperties<MAT>::Print(std::ostream &, int)
167  {
168  std::cerr << "PhysicalProperties::Print -- not implemented\n";
169  }
170 
171 } //end of XC namespace
172 #endif
int sendMovable(MovableObject &, DbTagData &, const CommMetaData &)
Sends a movable object through the channel being passed as parameter.
Definition: CommParameters.cc:959
Vector que almacena los dbTags de los miembros de la clase.
Definition: DbTagData.h:43
int sendData(CommParameters &)
Send members through the channel being passed as parameter.
Definition: PhysicalProperties.h:120
int receiveIdData(DbTagData &, const int &) const
Recibe el miembro data through the channel being passed as parameter.
Definition: CommParameters.cc:396
DbTagData & getDbTagData(void) const
Returns a vector para almacenar los dbTags de los miembros de la clase.
Definition: PhysicalProperties.h:112
int sendIdData(const DbTagData &, const int &)
Sends miembro data through the channel being passed as parameter.
Definition: CommParameters.cc:392
virtual void Print(std::ostream &s, int)
Sends object.
Definition: PhysicalProperties.h:166
Object that can move between processes.
Definition: MovableObject.h:91
int receiveMovable(MovableObject &, DbTagData &, const CommMetaData &) const
Receives a movable object trhrough the channel being passed as parameter.
Definition: CommParameters.cc:969
int commitState(void)
Commits materials state (normally after convergence).
Definition: MaterialVector.h:218
int sendSelf(CommParameters &)
Sends object.
Definition: PhysicalProperties.h:136
int recvData(const CommParameters &)
Receives members through the channel being passed as parameter.
Definition: PhysicalProperties.h:128
Base class for element&#39;s physical properties.
Definition: PhysicalProperties.h:45
Material pointer container. It&#39;s used by elements to store materials for each integration point...
Definition: MaterialVector.h:46
material_vector theMaterial
pointers to the material objects
Definition: PhysicalProperties.h:50
int revertToStart(void)
Return materials to its initial state.
Definition: MaterialVector.h:241
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
int revertToLastCommit(void)
Returns materials to its last commited state.
Definition: MaterialVector.h:229
int recvSelf(const CommParameters &)
Receives object.
Definition: PhysicalProperties.h:151