xc
PhysicalProperties.h
1 // -*-c++-*-
2 //----------------------------------------------------------------------------
3 // XC program; finite element analysis code
4 // for structural analysis and design.
5 //
6 // Copyright (C) Luis C. Pérez Tato
7 //
8 // This program derives from OpenSees <http://opensees.berkeley.edu>
9 // developed by the «Pacific earthquake engineering research center».
10 //
11 // Except for the restrictions that may arise from the copyright
12 // of the original program (see copyright_opensees.txt)
13 // XC is free software: you can redistribute it and/or modify
14 // it under the terms of the GNU General Public License as published by
15 // the Free Software Foundation, either version 3 of the License, or
16 // (at your option) any later version.
17 //
18 // This software is distributed in the hope that it will be useful, but
19 // WITHOUT ANY WARRANTY; without even the implied warranty of
20 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 // GNU General Public License for more details.
22 //
23 //
24 // You should have received a copy of the GNU General Public License
25 // along with this program.
26 // If not, see <http://www.gnu.org/licenses/>.
27 //----------------------------------------------------------------------------
28 //PhysicalProperties.h
29 
30 #ifndef PhysicalProperties_h
31 #define PhysicalProperties_h
32 
33 #include "utility/actor/actor/MovableObject.h"
34 #include "material/MaterialVector.h"
35 
36 namespace XC {
37 
38 class Response;
39 
43 //
45 //
47 template <class MAT>
49  {
50  public:
51  typedef MAT material_type;
53  protected:
54  material_vector theMaterial;
55 
56  DbTagData &getDbTagData(void) const;
57  int sendData(Communicator &);
58  int recvData(const Communicator &);
59 
60  public:
61  PhysicalProperties(const size_t &nMat= 0,const MAT *matModel= nullptr);
62  void setMaterial(const MAT *);
63  void setMaterial(const MAT *,const std::string &);
64  void setMaterial(size_t i,const MAT *);
65  void setMaterial(size_t i,const MAT &);
66  void copyMaterialFrom(const PhysicalProperties<MAT> &other)
67  { this->theMaterial= other.theMaterial; }
68 
69  // public methods to set the state of the properties
70  int commitState(void);
71  int revertToLastCommit(void);
72  int revertToStart(void);
73 
74  inline size_t size(void) const
75  { return theMaterial.size(); }
76  inline material_vector &getMaterialsVector(void)
77  { return theMaterial; }
78  inline const material_vector &getMaterialsVector(void) const
79  { return theMaterial; }
80  inline std::set<std::string> getMaterialNames(void) const
81  { return theMaterial.getNames(); }
82  inline boost::python::list getMaterialNamesPy(void) const
83  { return theMaterial.getNamesPy(); }
84  inline std::set<std::string> getMaterialTags(void) const
85  { return theMaterial.getTags(); }
86  inline boost::python::list getMaterialTagsPy(void) const
87  { return theMaterial.getTagsPy(); }
88 
89  inline void copyPropsFrom(const EntityWithProperties *other)
90  { theMaterial.copyPropsFrom(other); }
91 
92  inline MAT *operator[](const size_t &i)
93  { return theMaterial[i]; }
94  inline const MAT *operator[](const size_t &i) const
95  { return theMaterial[i]; }
96 
97  int sendSelf(Communicator &);
98  int recvSelf(const Communicator &);
99 
101  inline Matrix getGeneralizedStresses(void) const
102  { return theMaterial.getGeneralizedStresses(); }
104  inline Matrix getGeneralizedStrains(void) const
105  { return theMaterial.getGeneralizedStrains(); }
106 
107  int getResponse(int responseID, Information &eleInformation);
108  Response *setResponse(const std::vector<std::string> &argv, Information &eleInformation);
109 
110  virtual void Print(std::ostream &s, int) const;
111  };
112 
113  template <class MAT>
114 PhysicalProperties<MAT>::PhysicalProperties(const size_t &nMat,const MAT *matModel)
115  : MovableObject(0), theMaterial(nMat, matModel) {}
116 
117 template <class MAT>
119  { return theMaterial.commitState(); }
120 
121 template <class MAT>
123  { return theMaterial.revertToLastCommit(); }
124 
125 template <class MAT>
127  { return theMaterial.revertToStart(); }
128 
129 template <class MAT>
130 void PhysicalProperties<MAT>::setMaterial(const MAT *matModel)
131  { theMaterial.setMaterial(matModel); }
132 
133 template <class MAT>
134 void PhysicalProperties<MAT>::setMaterial(const MAT *matModel, const std::string &type)
135  { theMaterial.setMaterial(matModel,type); }
136 
137 template <class MAT>
138 void PhysicalProperties<MAT>::setMaterial(size_t i,const MAT *matModel)
139  { theMaterial.setMaterial(i,matModel); }
140 
141 template <class MAT>
142 void PhysicalProperties<MAT>::setMaterial(size_t i,const MAT &matModel)
143  { theMaterial.setMaterial(i,matModel); }
144 
147 template <class MAT>
149  {
150  static DbTagData retval(2);
151  return retval;
152  }
153 
155 template <class MAT>
157  {
158  int res= comm.sendMovable(theMaterial,this->getDbTagData(),CommMetaData(1));
159  return res;
160  }
161 
163 template <class MAT>
165  {
166  int res= comm.receiveMovable(theMaterial,this->getDbTagData(),CommMetaData(1));
167  return res;
168  }
169 
171 template <class MAT>
173  {
174  inicComm(2);
175 
176  int res= this->sendData(comm);
177 
178  const int dataTag= getDbTag();
179  res += comm.sendIdData(getDbTagData(),dataTag);
180  if(res < 0)
181  std::cerr << getClassName() << "::" << __FUNCTION__
182  << "; failed to send ID data\n";
183  return res;
184  }
185 
187 template <class MAT>
189  {
190  inicComm(2);
191 
192  const int dataTag= getDbTag();
193  int res= comm.receiveIdData(getDbTagData(),dataTag);
194  if(res<0)
195  std::cerr << getClassName() << "::" << __FUNCTION__
196  << "; failed to receive ID data\n";
197  else
198  res+= this->recvData(comm);
199  return res;
200  }
201 
203 template <class MAT>
204 int PhysicalProperties<MAT>::getResponse(int responseID, Information &eleInformation)
205  {
206  std::cerr << getClassName() << "::" << __FUNCTION__
207  << "; not implemented yet.\n";
208  return -1;
209  }
210 
212 template <class MAT>
213 Response *PhysicalProperties<MAT>::setResponse(const std::vector<std::string> &argv, Information &eleInformation)
214  {
215  std::cerr << getClassName() << "::" << __FUNCTION__
216  << "; not implemented yet.\n";
217  return nullptr;
218  }
219 
221 template <class MAT>
222 void PhysicalProperties<MAT>::Print(std::ostream &, int) const
223  {
224  std::cerr << getClassName() << "::" << __FUNCTION__
225  << "; not implemented yet.\n";
226  }
227 
228 } //end of XC namespace
229 #endif
int sendMovable(MovableObject &, DbTagData &, const CommMetaData &)
Sends a movable object through the communicator argument.
Definition: Communicator.cc:1163
Base class for element&#39;s physical properties.
Definition: PhysicalProperties.h:48
int sendIdData(const DbTagData &, const int &)
Sends miembro data through the communicator argument.
Definition: Communicator.cc:411
Information about an element.
Definition: Information.h:81
Communication parameters between processes.
Definition: Communicator.h:66
Response * setResponse(const std::vector< std::string > &argv, Information &eleInformation)
Material response.
Definition: PhysicalProperties.h:213
Base class response objects.
Definition: Response.h:81
Object that can return properties as Python objects.
Definition: EntityWithProperties.h:32
int revertToLastCommit(void)
Returns materials to its last committed state.
Definition: MaterialVector.h:266
std::set< std::string > getNames(void) const
Return the names of the materials.
Definition: MaterialVector.h:592
Object that can move between processes.
Definition: MovableObject.h:100
int receiveMovable(MovableObject &, DbTagData &, const CommMetaData &) const
Receives a movable object trhrough the communicator argument.
Definition: Communicator.cc:1174
Vector that stores the dbTags of the class members.
Definition: DbTagData.h:44
Matrix getGeneralizedStresses(void) const
Returns generalized stress values on each integration point.
Definition: MaterialVector.h:338
Data about the index, size,,...
Definition: CommMetaData.h:39
boost::python::list getNamesPy(void) const
Return the names of the materials in a python list.
Definition: MaterialVector.h:602
void copyPropsFrom(const EntityWithProperties *)
copy the user defined properties of the given object on each of the materials.
Definition: MaterialVector.h:210
int getResponse(int responseID, Information &eleInformation)
Obtain information from the analysis results.
Definition: PhysicalProperties.h:204
DbTagData & getDbTagData(void) const
Returns a vector to store the dbTags of the class members.
Definition: PhysicalProperties.h:148
Matrix getGeneralizedStrains(void) const
Return the generalized strains at material points.
Definition: PhysicalProperties.h:104
boost::python::list getTagsPy(void) const
Return the identifiers of the materials in a python list.
Definition: MaterialVector.h:623
Material pointer container.
Definition: MaterialVector.h:48
virtual void Print(std::ostream &s, int) const
Print stuff.
Definition: PhysicalProperties.h:222
virtual std::string getClassName(void) const
Returns demangled class name.
Definition: EntityWithOwner.cc:90
std::set< int > getTags(void) const
Return the identifiers of the materials.
Definition: MaterialVector.h:613
Objet that can execute python scripts.
Definition: CommandEntity.h:40
Matrix getGeneralizedStresses(void) const
Return the generalized stresses at material points.
Definition: PhysicalProperties.h:101
int recvSelf(const Communicator &)
Receives object.
Definition: PhysicalProperties.h:188
material_vector theMaterial
pointers to the material objects
Definition: PhysicalProperties.h:54
Matrix getGeneralizedStrains(void) const
Returns generalized strain values on each integration point.
Definition: MaterialVector.h:353
int commitState(void)
Commits materials state (normally after convergence).
Definition: MaterialVector.h:255
int receiveIdData(DbTagData &, const int &) const
Receives el miembro data through the communicator argument.
Definition: Communicator.cc:415
Open source finite element program for structural analysis.
Definition: ContinuaReprComponent.h:35
MovableObject(int classTag, int dbTag)
Constructor.
Definition: MovableObject.cpp:74
void inicComm(const int &dataSize) const
Initializes communication.
Definition: DistributedBase.cc:61
Matrix of floats.
Definition: Matrix.h:111
int recvData(const Communicator &)
Receives members through the communicator argument.
Definition: PhysicalProperties.h:164
int getDbTag(void) const
Return the object identifier in the database.
Definition: MovableObject.cpp:99
int sendSelf(Communicator &)
Sends object.
Definition: PhysicalProperties.h:172
int revertToStart(void)
Return materials to its initial state.
Definition: MaterialVector.h:278
int sendData(Communicator &)
Send members through the communicator argument.
Definition: PhysicalProperties.h:156