Itasca C++ Interface
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
conmodel.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "conmodelbase.h"
4 #include "state.h"
5 #include "convert.h"
6 #include <vector>
7 #include <iostream>
8 
17 namespace models {
19 
20  struct State;
21 
23 
32  class CONMODEL_EXPORT ConstitutiveModel {
33  public:
40  virtual String getName() const=0;
42  virtual String getPluginName() const { return getName(); }
49  virtual String getFullName() const=0;
51  virtual bool isNull() const { return false; }
54  virtual bool isModelAdvanced() const { return false; }
56  virtual bool isCreep() const { return false; }
58  virtual bool isLiquefaction() const { return false; }
63  virtual UInt getMinorVersion() const;
69  virtual String getProperties() const=0; // comma delimited
76  virtual String getStates() const=0;
82  virtual Variant getProperty(UInt index) const=0;
92  virtual void setProperty(UInt i,const Variant &val,UInt restoreVersion=0) { i; val; restoreVersion; setValid(0); }
96  virtual bool isPropertyReadOnly(UInt i) const { i; return false; }
99  virtual bool isPropertyAdvanced(UInt i) const { i; return false; }
103  virtual void save(std::ostream &o) const;
105  virtual void restore(std::istream &i,UInt restoreVersion);
109  virtual ConstitutiveModel *clone() const=0;
114  virtual Double getConfinedModulus() const=0;
118  virtual Double getShearModulus() const=0;
121  virtual Double getBulkModulus() const=0;
127  virtual void copy(const ConstitutiveModel *mod);
129  virtual bool performMixing() const { return false; }
131  virtual void mixStrain(UByte d,State *s,SymTensor *strains,double *volumes) { d; s; strains; volumes; }
140  virtual void run(UByte d,State *s) { if (!isValid(d)) initialize(d,s); }
142  virtual void mixStress(UByte d,State *s,SymTensor *stresses,double *volumes) { d; s; stresses; volumes; }
154  virtual void initialize(UByte d,State *s) { s; setValid(d); }
159  virtual Double getStressStrengthRatio(const SymTensor &) const { return 10.0; }
165  virtual void scaleProperties(const Double &f,const std::vector<UInt> &v) { f; v; throw std::logic_error("Does not support property scaling"); }
167  virtual bool supportsHystereticDamping() const { return false; }
169  virtual bool supportsStressStrengthRatio() const { return false; }
171  virtual bool supportsPropertyScaling() const { return false; }
174  virtual bool supportsSmallStrainEffect() const { return false; }
176  virtual void destroy() { delete this; }
177 
179  ConstitutiveModel(unsigned short option=0);
181  virtual ~ConstitutiveModel();
185  static UInt getLibraryMinorVersion();
187  bool isValid(UByte d) const { return valid_==d; }
189  void setValid(UByte d) { valid_ = d; }
192  bool canFail() const { return canFail_; }
194  void setIfCanFail(bool b) { canFail_ = b; }
196  std::vector<unsigned short> gEOB() const;
198  void sEOB(const std::vector<unsigned short> &reply);
200  bool cEOB() const;
201 
202 #ifndef DOXYGEN
203  // Memory Allocation Customization
204  // Changing this is very dangerous, as the calling program will make assumptions about
205  // where memory has been allocated to and from.
206  void *operator new(size_t size);
207  void *operator new(size_t size,const char *name,const char *file,unsigned line);
208  void operator delete(void *v);
209  void operator delete(void *v,const char *name,const char *file,unsigned line);
210  typedef void *(*NewFunction)(size_t,const char *,const char *,unsigned);
211  typedef void (*DeleteFunction)(void *,const char *,const char *,unsigned);
212  typedef std::pair<NewFunction,DeleteFunction> AllocFunctions;
213  static AllocFunctions setAllocFunctions(AllocFunctions afunc);
214  static AllocFunctions getDefaultAllocFunctions();
215  static AllocFunctions getAllocFunctions() { return AllocFunctions(newFunc_,deleteFunc_); }
216 #endif
217 
218  private:
219  static NewFunction newFunc_;
220  static DeleteFunction deleteFunc_;
221  Byte valid_ = 0;
222  bool canFail_ = true;
223  unsigned short option_ = 0;
224 
225  protected:
226  // ensure the same bits for all models
227  static const unsigned long shear_now = 0x001;
228  static const unsigned long tension_now = 0x002;
229  static const unsigned long shear_past = 0x004;
230  static const unsigned long tension_past = 0x008;
231  static const unsigned long joint_shear_now = 0x010;
232  static const unsigned long joint_tension_now = 0x020;
233  static const unsigned long joint_shear_past = 0x040;
234  static const unsigned long joint_tension_past = 0x080;
235  static const unsigned long volume_now = 0x100;
236  static const unsigned long volume_past = 0x200;
237  // shared frequently used constants
238  static constexpr double pi = 3.14159265358979323846264338327950;
239  static constexpr double degrad = 0.01745329251994329576923690768488;
240  static constexpr double d1d3 = 0.33333333333333333333333333333333;
241  static constexpr double d2d3 = 0.66666666666666666666666666666667;
242  static constexpr double d4d3 = 1.33333333333333333333333333333333;
243  static constexpr double rt6 = 2.44948974278317809819728407470589; // sqrt(6.0)
244  //
245  static double cos3t(const double& n11, const double& n22, const double& n33,
246  const double& n12, const double& n31, const double& n23, double *tensornorm=0);
247  static double gfunc(const double &c, const double &cos3t, const double &expn=-0.25, double *B=0, double *C=0);
248  };
249 
250 # define C_M ConstitutiveModel
251 } // namespace models
252 
254 // EoF
virtual bool isPropertyAdvanced(UInt i) const
Definition: conmodel.h:99
char Byte
signed 8 bit
Definition: basedef.h:26
virtual void run(UByte d, State *s)
Calculate stress increment given a strain increment.
Definition: conmodel.h:140
virtual String getPluginName() const
There should be no reason for an implementation to override the default behavior of this function.
Definition: conmodel.h:42
A simpler (and slightly faster) version of a QVariant, added for interfaces that do not use Qt.
Definition: variant.h:28
void setValid(UByte d)
Sets the current valid state to dimension dim.
Definition: conmodel.h:189
virtual bool supportsSmallStrainEffect() const
Definition: conmodel.h:174
virtual bool supportsPropertyScaling() const
Returns true if property scaling is supported for factor-of-safety calculations via scaleProperties()...
Definition: conmodel.h:171
The Constitutive Model interface library.
Definition: conmodel.cpp:7
void setIfCanFail(bool b)
Specifies whether or not "failure" is being allowed for this instanced of the constitutive model.
Definition: conmodel.h:194
virtual void setProperty(UInt i, const Variant &val, UInt restoreVersion=0)
Sets the value of the property with index i (base 1).
Definition: conmodel.h:92
virtual bool isNull() const
Returns true if this model represents a NULL material. Only the NULL model should return true.
Definition: conmodel.h:51
virtual bool supportsStressStrengthRatio() const
Returns true if strength-stress ratio calculations are supported via getStrengthStressRatio().
Definition: conmodel.h:169
unsigned int UInt
unsigned 32 bit
Definition: basedef.h:31
virtual void destroy()
There should be no reason for an implementation to change the default behavior of this function.
Definition: conmodel.h:176
A symmetric 2nd order tensor.
Definition: symtensor.h:19
The base class for constitutive model plug-ins.
Definition: conmodel.h:32
virtual void scaleProperties(const Double &f, const std::vector< UInt > &v)
Scales failure property indices v by the factor f.
Definition: conmodel.h:165
virtual void initialize(UByte d, State *s)
Initializes the constitutive model in preparation for calls to run().
Definition: conmodel.h:154
virtual bool isPropertyReadOnly(UInt i) const
Definition: conmodel.h:96
virtual bool isLiquefaction() const
Return TRUE if the model should be considered "Liquefaction" model.
Definition: conmodel.h:58
virtual void mixStress(UByte d, State *s, SymTensor *stresses, double *volumes)
User defined stress mixing technique. .
Definition: conmodel.h:142
EXPORT_TAG const char * getName()
Definition: fishexample.cpp:43
double Double
64 bit floating point
Definition: basedef.h:40
virtual bool isModelAdvanced() const
Definition: conmodel.h:54
unsigned char UByte
unsigned 8 bit
Definition: basedef.h:27
virtual bool performMixing() const
Set true if an alternative mixing technqiue rather than the default one in the code is used....
Definition: conmodel.h:129
virtual Double getStressStrengthRatio(const SymTensor &) const
Returns the ratio of the stress tensor to the current yield strength.
Definition: conmodel.h:159
bool canFail() const
Definition: conmodel.h:192
virtual bool supportsHystereticDamping() const
Returns true if hysteretic damping is supported by run(). See State::hysteretic_damping_.
Definition: conmodel.h:167
virtual bool isCreep() const
Return TRUE if the model should be considered "creep", in that it contains time dependent material be...
Definition: conmodel.h:56
virtual void mixStrain(UByte d, State *s, SymTensor *strains, double *volumes)
User defined strain mixing technique. .
Definition: conmodel.h:131
EXPORT_TAG unsigned getMinorVersion()
Definition: fishexample.cpp:62
The structure used to pass information to the constitutive model.
Definition: state.h:32
The base class for constitutive model plug-ins.
bool isValid(UByte d) const
Indicates whether initializion is necessary - by dimension.
Definition: conmodel.h:187
The base class for constitutive model plug-ins.