Itasca C++ Interface
Loading...
Searching...
No Matches
conmodel.h
Go to the documentation of this file.
1#pragma once
2
3#include "conmodelbase.h"
4#include "state.h"
5#include "base/src/property.h"
6#include <vector>
7#include <iostream>
8
18namespace 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 isKGEv() const { return false; }
58 virtual bool isOriented() const { return false; }
61 virtual bool isCreep() const { return false; }
63 virtual bool isLiquefaction() const { return false; }
68 virtual unsigned getMinorVersion() const;
74 virtual string getProperties() const=0; // comma delimited
81 virtual string getStates() const=0;
87 virtual base::Property getProperty(uint32 index) const=0;
97 virtual void setProperty(uint32,const base::Property &,uint32=0) { setValid(0); }
101 virtual bool isPropertyReadOnly(uint32) const { return false; }
104 virtual bool isPropertyAdvanced(uint32) const { return false; }
108 virtual void save(std::ostream &o) const;
110 virtual void restore(std::istream &i,uint32 restoreVersion);
114 virtual ConstitutiveModel *clone() const=0;
119 virtual double getConfinedModulus() const=0;
123 virtual double getShearModulus() const=0;
126 virtual double getBulkModulus() const=0;
132 virtual void copy(const ConstitutiveModel *mod);
134 virtual bool performMixing() const { return false; }
136 virtual void mixStrain(uint32,State *,SymTensor *,double *) { }
145 virtual void run(uint32 d,State *s) { if (!isValid(d)) initialize(d,s); }
147 virtual void mixStress(uint32,State *,SymTensor *,double *) { }
159 virtual void initialize(uint32 d,State *) { setValid(d); }
164 virtual double getStrengthStressRatio(const SymTensor &) const { return 10.0; }
170 virtual void scaleProperties(const double &,const std::vector<uint32> &) { throw std::logic_error("Does not support property scaling"); }
172 virtual bool supportsHystereticDamping() const { return false; }
174 virtual bool supportsStrengthStressRatio() const { return false; }
176 virtual bool supportsPropertyScaling() const { return false; }
179 virtual bool supportsSmallStrainEffect() const { return false; }
181 virtual bool supportsPlaneStress() const { return false; }
183 virtual bool supportsUniaxial() const { return false; }
185 virtual void destroy() { delete this; }
186
188 ConstitutiveModel(unsigned short option=0);
190 virtual ~ConstitutiveModel();
194 static uint32 getLibraryMinorVersion();
196 bool isValid(uint32 d) const { return valid_==to<int8>(d); }
198 void setValid(uint32 d) { valid_ = to<int8>(d); }
201 bool canFail() const { return canFail_; }
203 void setIfCanFail(bool b) { canFail_ = b; }
205 std::vector<unsigned short> gEOB() const;
207 void sEOB(const std::vector<unsigned short> &reply);
209 bool cEOB() const;
210
211#ifndef DOXYGEN
212 // Memory Allocation Customization
213 // Changing this is very dangerous, as the calling program will make assumptions about
214 // where memory has been allocated to and from.
215 void *operator new(size_t size);
216 void *operator new(size_t size,const char *name,const char *file,unsigned line);
217 void operator delete(void *v);
218 void operator delete(void *v,const char *name,const char *file,unsigned line);
219 using NewFunction = void *(*)(size_t, const char *, const char *, unsigned);
220 using DeleteFunction = void (*)(void *, const char *, const char *, unsigned);
221 typedef std::pair<NewFunction,DeleteFunction> MemoryAllocationFunctions;
222 static MemoryAllocationFunctions setMemoryAllocationFunctions(MemoryAllocationFunctions afunc);
223 static MemoryAllocationFunctions getDefaultMemoryAllocationFunctions();
224 static MemoryAllocationFunctions getMemoryAllocationFunctions() { return MemoryAllocationFunctions(newFunc_,deleteFunc_); }
225#endif
226
227 private:
228
229 static NewFunction newFunc_;
230 static DeleteFunction deleteFunc_;
231
232 int8 valid_ = 0;
233 bool canFail_ = true;
234 uint16 option_ = 0;
235
236 public:
237 // ensure the same bits for all models
238 static constexpr uint32 shear_now = 0x001;
239 static constexpr uint32 tension_now = 0x002;
240 static constexpr uint32 shear_past = 0x004;
241 static constexpr uint32 tension_past = 0x008;
242 static constexpr uint32 joint_shear_now = 0x010;
243 static constexpr uint32 joint_tension_now = 0x020;
244 static constexpr uint32 joint_shear_past = 0x040;
245 static constexpr uint32 joint_tension_past = 0x080;
246 static constexpr uint32 volume_now = 0x100;
247 static constexpr uint32 volume_past = 0x200;
248 // shared frequently used constants
249 static constexpr double pi = 3.14159265358979323846264338327950;
250 static constexpr double degrad = 0.01745329251994329576923690768488;
251 static constexpr double d1d3 = 0.33333333333333333333333333333333;
252 static constexpr double d2d3 = 0.66666666666666666666666666666667;
253 static constexpr double d4d3 = 1.33333333333333333333333333333333;
254 static constexpr double rt6 = 2.44948974278317809819728407470589; // sqrt(6.0)
255 };
256
257# define C_M ConstitutiveModel
258} // namespace models
259
261// EoF
A symmetric 2nd order tensor.
Definition symtensor.h:22
Definition property.h:25
The base class for constitutive model plug-ins.
Definition conmodel.h:32
virtual bool supportsStrengthStressRatio() const
Returns true if strength-stress ratio calculations are supported via getStrengthStressRatio().
Definition conmodel.h:174
virtual void setProperty(uint32, const base::Property &, uint32=0)
Sets the value of the property with index i (base 1).
Definition conmodel.h:97
virtual void initialize(uint32 d, State *)
Initializes the constitutive model in preparation for calls to run().
Definition conmodel.h:159
virtual bool isKGEv() const
Return TRUE if the model can input (bulk,shear) or (young,poisson).
Definition conmodel.h:56
virtual bool supportsSmallStrainEffect() const
Definition conmodel.h:179
virtual double getConfinedModulus() const =0
Return estimate of maximum confined modulus.
virtual string getPluginName() const
There should be no reason for an implementation to override the default behavior of this function.
Definition conmodel.h:42
virtual ConstitutiveModel * clone() const =0
Returns an instance this class.
virtual bool supportsPropertyScaling() const
Returns true if property scaling is supported for factor-of-safety calculations via scaleProperties()...
Definition conmodel.h:176
bool isValid(uint32 d) const
Indicates whether initializion is necessary - by dimension.
Definition conmodel.h:196
virtual bool isPropertyReadOnly(uint32) const
Definition conmodel.h:101
virtual void mixStrain(uint32, State *, SymTensor *, double *)
User defined strain mixing technique. .
Definition conmodel.h:136
virtual bool isModelAdvanced() const
Definition conmodel.h:54
virtual double getStrengthStressRatio(const SymTensor &) const
Returns the ratio of the stress tensor to the current yield strength.
Definition conmodel.h:164
virtual string getStates() const =0
Returns a string containing state names.
virtual void scaleProperties(const double &, const std::vector< uint32 > &)
Scales failure property indices v by the factor f.
Definition conmodel.h:170
virtual string getName() const =0
Must be unique, used to identify model in save/restore, on command line, filename.
virtual bool isOriented() const
Return TRUE if the model can input (dip, dip-direction) or (norm).
Definition conmodel.h:58
void setIfCanFail(bool b)
Specifies whether or not "failure" is being allowed for this instanced of the constitutive model.
Definition conmodel.h:203
virtual double getBulkModulus() const =0
Return estimate of tangent bulk-modulus.
virtual void run(uint32 d, State *s)
Calculate stress increment given a strain increment.
Definition conmodel.h:145
virtual bool supportsPlaneStress() const
Returns true if 2D plane-stress is supported by run().
Definition conmodel.h:181
virtual void mixStress(uint32, State *, SymTensor *, double *)
User defined stress mixing technique. .
Definition conmodel.h:147
virtual bool isNull() const
Returns true if this model represents a NULL material. Only the NULL model should return true.
Definition conmodel.h:51
bool canFail() const
Definition conmodel.h:201
virtual void destroy()
There should be no reason for an implementation to change the default behavior of this function.
Definition conmodel.h:185
virtual base::Property getProperty(uint32 index) const =0
Return the value of the property of that index (base 1).
virtual string getFullName() const =0
The full name of the model.
virtual string getProperties() const =0
Returns a string containing the names of model properties.
virtual bool supportsUniaxial() const
Returns true if 1D uniaxial is supported by run().
Definition conmodel.h:183
virtual bool isPropertyAdvanced(uint32) const
Definition conmodel.h:104
virtual bool isCreep() const
Definition conmodel.h:61
void setValid(uint32 d)
Sets the current valid state to dimension dim.
Definition conmodel.h:198
virtual bool isLiquefaction() const
Return TRUE if the model should be considered "Liquefaction" model.
Definition conmodel.h:63
virtual double getShearModulus() const =0
Return estimate of tangent shear-modulus.
virtual bool supportsHystereticDamping() const
Returns true if hysteretic damping is supported by run(). See State::hysteretic_damping_.
Definition conmodel.h:172
virtual bool performMixing() const
Set true if an alternative mixing technqiue rather than the default one in the code is used....
Definition conmodel.h:134
EXPORT_TAG unsigned getMinorVersion()
Definition fishexample.cpp:62
EXPORT_TAG const char * getName()
Definition fishexample.cpp:43
The base class for constitutive model plug-ins.
The Constitutive Model interface library.
Definition conmodel.cpp:7
The structure used to pass information to the constitutive model.
Definition state.h:32