xc
PlateAdaptorMaterial.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 //===============================================================================
29 
30 #ifndef PlateAdaptorMaterial_h
31 #define PlateAdaptorMaterial_h
32 
33 #include "material/nD/NDMaterial.h"
34 #include "material/MaterialWrapper.h"
35 
36 namespace XC {
37 
39 //
41 template <class MaterialWrapper>
43  {
44  public:
45  typedef typename MaterialWrapper::MaterialType MaterialType;
46  private:
47  MaterialWrapper theMaterial;
48 
49  protected:
50  int sendData(Communicator &);
51  int recvData(const Communicator &);
52  public:
53  PlateAdaptorMaterial(int tag, int classTag);
54  PlateAdaptorMaterial(int tag, int classTag, const MaterialType &);
55 
57  inline const MaterialType *getMaterial(void) const
58  { return theMaterial.getMaterial(); }
60  inline MaterialType *getMaterial(void)
61  { return theMaterial.getMaterial(); }
62  virtual void setMaterial(const MaterialType &);
63  void setMaterial(const std::string &);
64 
65  //send back order of strain in vector form
66  int getOrder(void) const;
67 
68  //send back order of strain in vector form
69  const std::string &getType(void) const;
70 
71  //density
72  double getRho(void) const;
73 
74  void Print(std::ostream &s, int flag = 0) const;
75  };
77 template <class MaterialWrapper>
78 void PlateAdaptorMaterial<MaterialWrapper>::setMaterial(const MaterialType &material)
79  { theMaterial.setMaterial(material); }
80 
82 template <class MaterialWrapper>
84  {
85  const Material *ptr_mat= getMaterialByName(matName);
86  if(ptr_mat)
87  {
88  const MaterialType *tmp= dynamic_cast<const MaterialType *>(ptr_mat);
89  if(tmp)
90  setMaterial(*tmp);
91  else
92  std::cerr << getClassName() << "::" << __FUNCTION__ << "; "
93  << "material identified by: '" << matName
94  << "' is not an appropriate material." << std::endl;
95  }
96  else
97  std::cerr << getClassName() << "::" << __FUNCTION__ << "; "
98  << "material identified by: '" << matName
99  << "' not found." << std::endl;
100  }
101 
102 //null constructor
103 template <class MaterialWrapper>
105  : NDMaterial(tag, classTag), theMaterial()
106  { }
107 
108 
109 //full constructor
110 template <class MaterialWrapper>
111 PlateAdaptorMaterial<MaterialWrapper>::PlateAdaptorMaterial(int tag, int classTag, const MaterialType &mat)
112  : NDMaterial(tag, classTag), theMaterial(mat)
113  {}
114 
115 //send back order of strain in vector form
116 template <class MaterialWrapper>
118  { return 5; }
119 
120 template <class MaterialWrapper>
121 const std::string &PlateAdaptorMaterial<MaterialWrapper>::getType(void) const
122  {
123  static const std::string retval("PlateFiber");
124  return retval;
125  }
126 
127 //mass per unit volume
128 template <class MaterialWrapper>
130  { return this->getMaterial()->getRho(); }
131 
132 
134 template <class MaterialWrapper>
135 void PlateAdaptorMaterial<MaterialWrapper>::Print(std::ostream &s, int flag) const
136  {
137  s << getType() << " material tag: " << this->getTag() << std::endl;
138  s << "using material: " << std::endl;
139  this->getMaterial()->Print(s, flag);
140  }
141 
143 template <class MaterialWrapper>
145  {
146  int res= NDMaterial::sendData(comm);
147  res+= comm.sendMovable(theMaterial,getDbTagData(),CommMetaData(1));
148  return res;
149  }
150 
152 template <class MaterialWrapper>
154  {
155  int res= NDMaterial::recvData(comm);
156  res+= comm.receiveMovable(theMaterial,getDbTagData(),CommMetaData(1));
157  return res;
158  }
159 
160 } // end of XC namespace
161 
162 #endif
163 
164 
165 
166 
167 
168 
int sendMovable(MovableObject &, DbTagData &, const CommMetaData &)
Sends a movable object through the communicator argument.
Definition: Communicator.cc:1163
virtual void setMaterial(const MatType &)
Sets the wrapped material.
Definition: MaterialWrapper.h:95
void Print(std::ostream &s, int flag=0) const
print out data
Definition: PlateAdaptorMaterial.h:135
double getRho(void) const
Get material density.
Definition: PlateAdaptorMaterial.h:129
Plate response adaptor.
Definition: PlateAdaptorMaterial.h:42
Communication parameters between processes.
Definition: Communicator.h:66
NDMaterial()
Constructor.
Definition: NDMaterial.cpp:91
const Material * getMaterialByName(const std::string &) const
Definition: Material.cpp:71
int receiveMovable(MovableObject &, DbTagData &, const CommMetaData &) const
Receives a movable object trhrough the communicator argument.
Definition: Communicator.cc:1174
Base class for materials.
Definition: Material.h:93
MaterialType * getMaterial(void)
Return a pointer to the encapsulated material.
Definition: PlateAdaptorMaterial.h:60
Data about the index, size,,...
Definition: CommMetaData.h:39
Encapsulates a copy to a material.
Definition: MaterialWrapper.h:41
const MatType * getMaterial(void) const
Return a pointer to the wrapped material.
Definition: MaterialWrapper.h:58
virtual DbTagData & getDbTagData(void) const
Returns a vector to store class dbTags.
Definition: DistributedBase.cc:43
virtual std::string getClassName(void) const
Returns demangled class name.
Definition: EntityWithOwner.cc:90
int sendData(Communicator &)
Send object members through the communicator argument.
Definition: NDMaterial.cpp:400
int sendData(Communicator &)
Send material data.
Definition: PlateAdaptorMaterial.h:144
virtual void setMaterial(const MaterialType &)
Sets the encapsulated material.
Definition: PlateAdaptorMaterial.h:78
int recvData(const Communicator &)
Receives object members through the communicator argument.
Definition: NDMaterial.cpp:407
Base class for 2D and 3D materials.
Definition: NDMaterial.h:101
const MaterialType * getMaterial(void) const
Return a pointer to the encapsulated material.
Definition: PlateAdaptorMaterial.h:57
Open source finite element program for structural analysis.
Definition: ContinuaReprComponent.h:35
int getTag(void) const
Returns the tag associated with the object.
Definition: TaggedObject.h:119
int recvData(const Communicator &)
Receive material data.
Definition: PlateAdaptorMaterial.h:153