xc
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 
40 //
42 //
44 template <class MAT>
45 class PhysicalProperties: public CommandEntity, 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 &);
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  inline std::set<std::string> getMaterialNames(void) const
74  { return theMaterial.getNames(); }
75  inline boost::python::list getMaterialNamesPy(void) const
76  { return theMaterial.getNamesPy(); }
77 
78  inline MAT *operator[](const size_t &i)
79  { return theMaterial[i]; }
80  inline const MAT *operator[](const size_t &i) const
81  { return theMaterial[i]; }
82 
83  int sendSelf(CommParameters &);
84  int recvSelf(const CommParameters &);
85 
86  virtual void Print(std::ostream &s, int);
87  };
88 
89 template <class MAT>
90 PhysicalProperties<MAT>::PhysicalProperties(const size_t &nMat,const MAT *matModel)
91  : MovableObject(0), theMaterial(nMat, matModel) {}
92 
93 template <class MAT>
95  { return theMaterial.commitState(); }
96 
97 template <class MAT>
99  { return theMaterial.revertToLastCommit(); }
100 
101 template <class MAT>
103  { return theMaterial.revertToStart(); }
104 
105 template <class MAT>
106 void PhysicalProperties<MAT>::setMaterial(const MAT *matModel)
107  { theMaterial.setMaterial(matModel); }
108 
109 template <class MAT>
110 void PhysicalProperties<MAT>::setMaterial(const MAT *matModel, const std::string &type)
111  { theMaterial.setMaterial(matModel,type); }
112 
115 template <class MAT>
117  {
118  static DbTagData retval(2);
119  return retval;
120  }
121 
123 template <class MAT>
125  {
126  int res= cp.sendMovable(theMaterial,this->getDbTagData(),CommMetaData(1));
127  return res;
128  }
129 
131 template <class MAT>
133  {
134  int res= cp.receiveMovable(theMaterial,this->getDbTagData(),CommMetaData(1));
135  return res;
136  }
137 
139 template <class MAT>
141  {
142  inicComm(2);
143 
144  int res= this->sendData(cp);
145 
146  const int dataTag= getDbTag();
147  res += cp.sendIdData(getDbTagData(),dataTag);
148  if(res < 0)
149  std::cerr << "PhysicalProperties::sendSelf -- failed to send ID data\n";
150  return res;
151  }
152 
154 template <class MAT>
156  {
157  inicComm(2);
158 
159  const int dataTag= getDbTag();
160  int res= cp.receiveIdData(getDbTagData(),dataTag);
161  if(res<0)
162  std::cerr << "PhysicalProperties::recvSelf -- failed to receive ID data\n";
163  else
164  res+= this->recvData(cp);
165  return res;
166  }
167 
169 template <class MAT>
170 void PhysicalProperties<MAT>::Print(std::ostream &, int)
171  {
172  std::cerr << "PhysicalProperties::Print -- not implemented\n";
173  }
174 
175 } //end of XC namespace
176 #endif
Base class for element&#39;s physical properties.
Definition: PhysicalProperties.h:45
int recvSelf(const CommParameters &)
Receives object.
Definition: PhysicalProperties.h:155
int sendIdData(const DbTagData &, const int &)
Sends miembro data through the channel being passed as parameter.
Definition: CommParameters.cc:392
int revertToLastCommit(void)
Returns materials to its last commited state.
Definition: MaterialVector.h:233
std::set< std::string > getNames(void) const
Return the names of the materials.
Definition: MaterialVector.h:538
Object that can move between processes.
Definition: MovableObject.h:99
int receiveIdData(DbTagData &, const int &) const
Receives el miembro data through the channel being passed as parameter.
Definition: CommParameters.cc:396
int receiveMovable(MovableObject &, DbTagData &, const CommMetaData &) const
Receives a movable object trhrough the channel being passed as parameter.
Definition: CommParameters.cc:1076
Vector that stores the dbTags of the class members.
Definition: DbTagData.h:43
Data about the index, size,,...
Definition: CommMetaData.h:38
boost::python::list getNamesPy(void) const
Return the names of the materials in a python list.
Definition: MaterialVector.h:548
DbTagData & getDbTagData(void) const
Returns a vector to store the dbTags of the class members.
Definition: PhysicalProperties.h:116
Material pointer container.
Definition: MaterialVector.h:46
material_vector theMaterial
pointers to the material objects
Definition: PhysicalProperties.h:50
int recvData(const CommParameters &)
Receives members through the channel being passed as parameter.
Definition: PhysicalProperties.h:132
int sendData(CommParameters &)
Send members through the channel being passed as parameter.
Definition: PhysicalProperties.h:124
int commitState(void)
Commits materials state (normally after convergence).
Definition: MaterialVector.h:222
Open source finite element program for structural analysis.
Definition: ContinuaReprComponent.h:34
Communication parameters between processes.
Definition: CommParameters.h:65
int sendSelf(CommParameters &)
Sends object.
Definition: PhysicalProperties.h:140
virtual void Print(std::ostream &s, int)
Sends object.
Definition: PhysicalProperties.h:170
int sendMovable(MovableObject &, DbTagData &, const CommMetaData &)
Sends a movable object through the channel being passed as parameter.
Definition: CommParameters.cc:1066
int revertToStart(void)
Return materials to its initial state.
Definition: MaterialVector.h:245