MBDyn-1.7.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
module-constlaw.cc
Go to the documentation of this file.
1 /* $Header: /var/cvs/mbdyn/mbdyn/mbdyn-1.0/modules/module-constlaw/module-constlaw.cc,v 1.17 2017/01/12 14:48:16 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 template <class T, class Tder>
42 : public ConstitutiveLaw<T, Tder> {
43 private:
45 
46 public:
48  : dStiffness(dStiff) {
50  };
51 
52  virtual ~DummyConstitutiveLaw(void) {
53  NO_OP;
54  };
55 
57  return ConstLawType::ELASTIC;
58  };
59 
60  virtual ConstitutiveLaw<T, Tder>* pCopy(void) const {
61  ConstitutiveLaw<T, Tder>* pCL = NULL;
62 
64  SAFENEWWITHCONSTRUCTOR(pCL, cl, cl(dStiffness));
65  return pCL;
66  };
67 
68  virtual std::ostream& Restart(std::ostream& out) const {
69  return out << "dummy, " << dStiffness;
70  };
71 
72  virtual void Update(const T& Eps, const T& /* EpsPrime */ = 0.) {
75  };
76 };
77 
78 /* specific functional object(s) */
79 template <class T, class Tder>
80 struct DummyCLR : public ConstitutiveLawRead<T, Tder> {
81  virtual ConstitutiveLaw<T, Tder> *
82  Read(const DataManager* pDM, MBDynParser& HP, ConstLawType::Type& CLType) {
83  ConstitutiveLaw<T, Tder>* pCL = 0;
84 
85  CLType = ConstLawType::ELASTIC;
86 
87  doublereal dS = HP.GetReal();
88  if (dS <= 0.) {
89  silent_cerr("warning, null or negative stiffness "
90  "at line " << HP.GetLineData() << std::endl);
91  }
92 
94  SAFENEWWITHCONSTRUCTOR(pCL, L, L(dS));
95 
96  return pCL;
97  };
98 };
99 
100 extern "C" int
101 module_init(const char *module_name, void *pdm, void *php)
102 {
103 #if 0
104  DataManager *pDM = (DataManager *)pdm;
105  MBDynParser *pHP = (MBDynParser *)php;
106 #endif
107 
110  if (!SetCL1D("dummy", rf1D)) {
111  delete rf1D;
112 
113  silent_cerr("DummyConstitutiveLaw1D: "
114  "module_init(" << module_name << ") "
115  "failed" << std::endl);
116 
117  return -1;
118  }
119 
121  if (!SetCL3D("dummy", rf3D)) {
122  delete rf3D;
123 
124  silent_cerr("DummyConstitutiveLaw3D: "
125  "module_init(" << module_name << ") "
126  "failed" << std::endl);
127 
128  return -1;
129  }
130 
132  if (!SetCL6D("dummy", rf6D)) {
133  delete rf6D;
134 
135  silent_cerr("DummyConstitutiveLaw6D: "
136  "module_init(" << module_name << ") "
137  "failed" << std::endl);
138 
139  return -1;
140  }
141 
142  return 0;
143 }
144 
virtual ConstitutiveLaw< T, Tder > * pCopy(void) const
virtual std::ostream & Restart(std::ostream &out) const
#define NO_OP
Definition: myassert.h:74
virtual void Update(const T &Eps, const T &=0.)
virtual ~DummyConstitutiveLaw(void)
int module_init(const char *module_name, void *pdm, void *php)
This function registers our user defined element for the math parser.
virtual ConstitutiveLaw< T, Tder > * Read(const DataManager *pDM, MBDynParser &HP, ConstLawType::Type &CLType)
ConstLawType::Type GetConstLawType(void) const
bool SetCL3D(const char *name, ConstitutiveLawRead< Vec3, Mat3x3 > *rf)
bool SetCL1D(const char *name, ConstitutiveLawRead< doublereal, doublereal > *rf)
#define SAFENEWWITHCONSTRUCTOR(pnt, item, constructor)
Definition: mynewmem.h:698
DummyConstitutiveLaw(doublereal dStiff)
bool SetCL6D(const char *name, ConstitutiveLawRead< Vec6, Mat6x6 > *rf)
const doublereal dS
Definition: beamslider.cc:71
double doublereal
Definition: colamd.c:52
virtual HighParser::ErrOut GetLineData(void) const
Definition: parsinc.cc:697
static std::stack< const HighParser * > pHP
Definition: parser.cc:598
virtual doublereal GetReal(const doublereal &dDefval=0.0)
Definition: parser.cc:1056