MBDyn-1.7.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
module-constlaw-f90.cc
Go to the documentation of this file.
1 /* $Header: /var/cvs/mbdyn/mbdyn/mbdyn-1.0/modules/module-constlaw-f90/module-constlaw-f90.cc,v 1.15 2017/01/12 14:48:26 masarati Exp $ */
2 /*
3  * MBDyn (C) is a multibody analysis code.
4  * http://www.mbdyn.org
5  *
6  * Copyright (C) 1996-2017
7  *
8  * Pierangelo Masarati <masarati@aero.polimi.it>
9  * Paolo Mantegazza <mantegazza@aero.polimi.it>
10  *
11  * Dipartimento di Ingegneria Aerospaziale - Politecnico di Milano
12  * via La Masa, 34 - 20156 Milano, Italy
13  * http://www.aero.polimi.it
14  *
15  * Changing this copyright notice is forbidden.
16  *
17  * This program is free software; you can redistribute it and/or modify
18  * it under the terms of the GNU General Public License as published by
19  * the Free Software Foundation (version 2 of the License).
20  *
21  *
22  * This program is distributed in the hope that it will be useful,
23  * but WITHOUT ANY WARRANTY; without even the implied warranty of
24  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25  * GNU General Public License for more details.
26  *
27  * You should have received a copy of the GNU General Public License
28  * along with this program; if not, write to the Free Software
29  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30  */
31 
32 #include "mbconfig.h" /* This goes first in every *.c,*.cc file */
33 
34 #include <cmath>
35 #include <cfloat>
36 
37 #include "dataman.h"
38 #include "constltp.h"
39 
40 #include "usrsub.h"
41 
42 template <class T, class Tder>
44 : public ConstitutiveLaw<T, Tder> {
45 private:
46 public:
47  DummyConstitutiveLaw(std::vector<doublereal>& v) {
48  NO_OP;
49  };
50 
51  virtual ~DummyConstitutiveLaw(void) {
52  NO_OP;
53  };
54 
56  return ConstLawType::ELASTIC;
57  };
58 
59  virtual ConstitutiveLaw<T, Tder>* pCopy(void) const {
60  return 0;
61  };
62 
63  virtual std::ostream& Restart(std::ostream& out) const {
64  return out;
65  };
66 
67  virtual void Update(const T& Eps, const T& EpsPrime = mb_zero<T>()) {
70  };
71 
72  virtual void AfterConvergence(const T& Eps, const T& EpsPrime = mb_zero<T>()) {
73  NO_OP;
74  };
75 };
76 
77 template <>
79 : public ConstitutiveLaw<doublereal, doublereal> {
80 private:
81  integer size, err;
82  std::vector<doublereal> m_v;
83 
84 public:
85  DummyConstitutiveLaw(const std::vector<doublereal>& v)
86  : size(v.size()), err(0), m_v(v)
87  {
88  us1init_(&size, &m_v[0], &err);
89  if (err != 0) {
91  }
92  };
93 
94  virtual ~DummyConstitutiveLaw(void) {
95  us1dstr_(&size, &m_v[0], &err);
96  };
97 
99  return ConstLawType::ELASTIC;
100  };
101 
104 
106  SAFENEWWITHCONSTRUCTOR(pCL, cl, cl(m_v));
107  return pCL;
108  };
109 
110  virtual std::ostream& Restart(std::ostream& out) const {
111  out << "dummyf90";
112  for (std::vector<doublereal>::const_iterator i = m_v.begin();
113  i != m_v.end();
114  i++)
115  {
116  out << ", " << *i;
117  }
118  return out;
119  };
120 
121  virtual void Update(const doublereal& Eps, const doublereal& EpsPrime = 0.) {
123 
124  doublereal dF, dFDE, dFDEP;
125  us1updt_(&size, &m_v[0], &Eps, &EpsPrime, &dF, &dFDE, &dFDEP,
126  &err);
127  if (err != 0) {
129  }
133  };
134 
135  virtual void AfterConvergence(const doublereal& Eps, const doublereal& EpsPrime = 0.) {
136  us1aftc_(&size, &m_v[0], &Eps, &EpsPrime, &err);
137  if (err != 0) {
139  }
140  };
141 };
142 
143 template <>
145 : public ConstitutiveLaw<Vec3, Mat3x3> {
146 private:
147  integer size, err;
148  std::vector<doublereal> m_v;
149 
150 public:
151  DummyConstitutiveLaw(const std::vector<doublereal>& v)
152  : size(v.size()), err(0), m_v(v)
153  {
154  us3init_(&size, &m_v[0], &err);
155  if (err != 0) {
157  }
158  };
159 
160  virtual ~DummyConstitutiveLaw(void) {
161  us3dstr_(&size, &m_v[0], &err);
162  };
163 
165  return ConstLawType::ELASTIC;
166  };
167 
168  virtual ConstitutiveLaw<Vec3, Mat3x3>* pCopy(void) const {
170 
172  SAFENEWWITHCONSTRUCTOR(pCL, cl, cl(m_v));
173  return pCL;
174  };
175 
176  virtual std::ostream& Restart(std::ostream& out) const {
177  out << "dummyf90";
178  for (std::vector<doublereal>::const_iterator i = m_v.begin();
179  i != m_v.end();
180  i++)
181  {
182  out << ", " << *i;
183  }
184  return out;
185  };
186 
187  virtual void Update(const Vec3& Eps, const Vec3& EpsPrime = mb_zero<Vec3>()) {
189 
190  doublereal dF[3], dFDE[3*3], dFDEP[3*3];
191  us3updt_(&size, &m_v[0], Eps.pGetVec(), EpsPrime.pGetVec(),
192  dF, dFDE, dFDEP, &err);
193  if (err != 0) {
195  }
199  };
200 
201  virtual void AfterConvergence(const Vec3& Eps, const Vec3& EpsPrime = mb_zero<Vec3>()) {
202  us3aftc_(&size, &m_v[0], Eps.pGetVec(), EpsPrime.pGetVec(),
203  &err);
204  if (err != 0) {
206  }
207  };
208 };
209 
210 template <>
212 : public ConstitutiveLaw<Vec6, Mat6x6> {
213 private:
214  integer size, err;
215  std::vector<doublereal> m_v;
216 
217 public:
218  DummyConstitutiveLaw(const std::vector<doublereal>& v)
219  : size(v.size()), err(0), m_v(v)
220  {
221  us6init_(&size, &m_v[0], &err);
222  if (err != 0) {
224  }
225  };
226 
227  virtual ~DummyConstitutiveLaw(void) {
228  us6dstr_(&size, &m_v[0], &err);
229  };
230 
232  return ConstLawType::ELASTIC;
233  };
234 
235  virtual ConstitutiveLaw<Vec6, Mat6x6>* pCopy(void) const {
237 
239  SAFENEWWITHCONSTRUCTOR(pCL, cl, cl(m_v));
240  return pCL;
241  };
242 
243  virtual std::ostream& Restart(std::ostream& out) const {
244  out << "dummyf90";
245  for (std::vector<doublereal>::const_iterator i = m_v.begin();
246  i != m_v.end();
247  i++)
248  {
249  out << ", " << *i;
250  }
251  return out;
252  };
253 
254  virtual void Update(const Vec6& Eps, const Vec6& EpsPrime = mb_zero<Vec6>()) {
256 
257  doublereal dE[6], dEP[6], dF[6], dFDE[6*6], dFDEP[6*6];
258  Eps.PutTo(dE);
259  EpsPrime.PutTo(dEP);
260  us6updt_(&size, &m_v[0], dE, dEP, dF, dFDE, dFDEP, &err);
261  if (err != 0) {
263  }
267  };
268 
269  virtual void AfterConvergence(const Vec6& Eps, const Vec6& EpsPrime = mb_zero<Vec6>()) {
270  doublereal dE[6], dEP[6];
271  Eps.PutTo(dE);
272  EpsPrime.PutTo(dEP);
273  us6aftc_(&size, &m_v[0], dE, dEP, &err);
274  if (err != 0) {
276  }
277  };
278 };
279 
280 /* specific functional object(s) */
281 template <class T, class Tder>
282 struct DummyCLR : public ConstitutiveLawRead<T, Tder> {
283  virtual ConstitutiveLaw<T, Tder> *
284  Read(const DataManager* pDM, MBDynParser& HP, ConstLawType::Type& CLType) {
285  ConstitutiveLaw<T, Tder>* pCL = 0;
286 
287  CLType = ConstLawType::ELASTIC;
288 
289  std::vector<doublereal> v;
290  int size = HP.GetInt();
291  v.resize(size);
292  for (int i = 0; i < size; i++) {
293  v[i] = HP.GetReal();
294  }
295 
297  SAFENEWWITHCONSTRUCTOR(pCL, L, L(v));
298 
299  return pCL;
300  };
301 };
302 
303 extern "C" int
304 module_init(const char *module_name, void *pdm, void *php)
305 {
306 #if 0
307  DataManager *pDM = (DataManager *)pdm;
308  MBDynParser *pHP = (MBDynParser *)php;
309 #endif
310 
313  if (!SetCL1D("dummyf90", rf1D)) {
314  delete rf1D;
315 
316  silent_cerr("DummyConstitutiveLaw1D: "
317  "module_init(" << module_name << ") "
318  "failed" << std::endl);
319 
320  return -1;
321  }
322 
324  if (!SetCL3D("dummyf90", rf3D)) {
325  delete rf3D;
326 
327  silent_cerr("DummyConstitutiveLaw3D: "
328  "module_init(" << module_name << ") "
329  "failed" << std::endl);
330 
331  return -1;
332  }
333 
335  if (!SetCL6D("dummyf90", rf6D)) {
336  delete rf6D;
337 
338  silent_cerr("DummyConstitutiveLaw6D: "
339  "module_init(" << module_name << ") "
340  "failed" << std::endl);
341 
342  return -1;
343  }
344 
345  return 0;
346 }
347 
void PutTo(doublereal *pd) const
Definition: matvec6.h:216
const Vec6 & mb_zero< Vec6 >(void)
Definition: matvec6.h:631
virtual void Update(const Vec6 &Eps, const Vec6 &EpsPrime=mb_zero< Vec6 >())
integer us3init_(integer *size, doublereal *vec, integer *err)
#define MBDYN_EXCEPT_ARGS
Definition: except.h:63
integer us1aftc_(integer *size, doublereal *vec, const doublereal *const eps, const doublereal *const epsp, integer *err)
Definition: matvec3.h:98
virtual integer GetInt(integer iDefval=0)
Definition: parser.cc:1050
virtual ConstitutiveLaw< T, Tder > * pCopy(void) const
virtual std::ostream & Restart(std::ostream &out) const
integer us1dstr_(integer *size, doublereal *vec, integer *err)
integer us6dstr_(integer *size, doublereal *vec, integer *err)
virtual std::ostream & Restart(std::ostream &out) const
virtual std::ostream & Restart(std::ostream &out) const
const Vec3 & mb_zero< Vec3 >(void)
Definition: matvec3.h:1560
int module_init(const char *module_name, void *pdm, void *php)
This function registers our user defined element for the math parser.
virtual void AfterConvergence(const T &Eps, const T &EpsPrime=mb_zero< T >())
#define NO_OP
Definition: myassert.h:74
virtual ~DummyConstitutiveLaw(void)
integer us6init_(integer *size, doublereal *vec, integer *err)
integer us6aftc_(integer *size, doublereal *vec, const doublereal *const eps, const doublereal *const epsp, integer *err)
ConstLawType::Type GetConstLawType(void) const
virtual ConstitutiveLaw< doublereal, doublereal > * pCopy(void) const
virtual ConstitutiveLaw< T, Tder > * Read(const DataManager *pDM, MBDynParser &HP, ConstLawType::Type &CLType)
Definition: matvec6.h:37
integer us6updt_(integer *size, doublereal *vec, const doublereal *const eps, const doublereal *const epsp, const doublereal *const f, const doublereal *const fde, const doublereal *const fdep, integer *err)
integer us1updt_(integer *size, doublereal *vec, const doublereal *const eps, const doublereal *const epsp, const doublereal *const f, const doublereal *const fde, const doublereal *const fdep, integer *err)
ConstLawType::Type GetConstLawType(void) const
virtual void AfterConvergence(const Vec3 &Eps, const Vec3 &EpsPrime=mb_zero< Vec3 >())
ConstLawType::Type GetConstLawType(void) const
ConstLawType::Type GetConstLawType(void) const
integer us3aftc_(integer *size, doublereal *vec, const doublereal *const eps, const doublereal *const epsp, integer *err)
DummyConstitutiveLaw(const std::vector< doublereal > &v)
integer us3dstr_(integer *size, doublereal *vec, integer *err)
virtual void AfterConvergence(const Vec6 &Eps, const Vec6 &EpsPrime=mb_zero< Vec6 >())
bool SetCL3D(const char *name, ConstitutiveLawRead< Vec3, Mat3x3 > *rf)
virtual void Update(const doublereal &Eps, const doublereal &EpsPrime=0.)
integer us3updt_(integer *size, doublereal *vec, const doublereal *const eps, const doublereal *const epsp, const doublereal *const f, const doublereal *const fde, const doublereal *const fdep, integer *err)
DummyConstitutiveLaw(std::vector< doublereal > &v)
bool SetCL1D(const char *name, ConstitutiveLawRead< doublereal, doublereal > *rf)
DummyConstitutiveLaw(const std::vector< doublereal > &v)
#define SAFENEWWITHCONSTRUCTOR(pnt, item, constructor)
Definition: mynewmem.h:698
virtual ConstitutiveLaw< Vec3, Mat3x3 > * pCopy(void) const
DummyConstitutiveLaw(const std::vector< doublereal > &v)
virtual void AfterConvergence(const doublereal &Eps, const doublereal &EpsPrime=0.)
virtual std::ostream & Restart(std::ostream &out) const
bool SetCL6D(const char *name, ConstitutiveLawRead< Vec6, Mat6x6 > *rf)
virtual void Update(const Vec3 &Eps, const Vec3 &EpsPrime=mb_zero< Vec3 >())
virtual ConstitutiveLaw< Vec6, Mat6x6 > * pCopy(void) const
const doublereal * pGetVec(void) const
Definition: matvec3.h:192
integer us1init_(integer *size, doublereal *vec, integer *err)
double doublereal
Definition: colamd.c:52
long int integer
Definition: colamd.c:51
static std::stack< const HighParser * > pHP
Definition: parser.cc:598
virtual void Update(const T &Eps, const T &EpsPrime=mb_zero< T >())
virtual doublereal GetReal(const doublereal &dDefval=0.0)
Definition: parser.cc:1056