00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef MECHSYS_LINEARELASTIC_H
00023 #define MECHSYS_LINEARELASTIC_H
00024
00025 #ifdef HAVE_CONFIG_H
00026 #include "config.h"
00027 #else
00028 #ifndef REAL
00029 #define REAL double
00030 #endif
00031 #endif
00032
00033 #include "models/equilibmodel.h"
00034 #include "util/string.h"
00035 #include "tensors/tensors.h"
00036 #include "tensors/operators.h"
00037 #include "tensors/functions.h"
00038
00039 class LinearElastic : public EquilibModel
00040 {
00041 public:
00042
00043 static const size_t NPRMS = 2;
00044 static const size_t NIDAT = 5;
00045
00046
00047 LinearElastic(Array<REAL> const & Prms, Array<REAL> const & IniData);
00048
00049
00050 String Name () const { return "LinearElastic"; }
00051 void TgStiffness (Tensors::Tensor4 & D) const;
00052 void StressUpdate (Tensors::Tensor2 const & DEps, Tensors::Tensor2 & DSig);
00053 void Actualize (Tensors::Tensor2 const & DSig, Tensors::Tensor2 & DEps);
00054 void BackupState ();
00055 void RestoreState ();
00056
00057
00058 int nInternalStateValues () const { return 1; }
00059 void InternalStateValues (Array<REAL> & IntStateVals ) const { IntStateVals .resize(1); IntStateVals [0] = _v; }
00060 void InternalStateNames (Array<String> & IntStateNames) const { IntStateNames.resize(1); IntStateNames[0] = "v"; }
00061
00062 private:
00063
00064 REAL _E;
00065 REAL _nu;
00066 REAL _v;
00067 REAL _v_bkp;
00068
00069 };
00070
00071
00073
00074
00075 inline LinearElastic::LinearElastic(Array<REAL> const & Prms, Array<REAL> const & IniData)
00076 {
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087 if (Prms.size()!=NPRMS)
00088 throw new Fatal(_("LinearElastic::Constructor: The number of parameters (%d) is incorrect. It must be equal to %d \n"));
00089
00090
00091 _E = Prms[0];
00092 _nu = Prms[1];
00093
00094
00095 if (IniData.size()!=NIDAT)
00096 throw new Fatal(_("LinearElastic::Constructor: The number of initial data is not sufficient (it must be equal to %d). { Sx' Sy' Sz' vini(not-used) OCR(not-used) }"), NIDAT);
00097
00098
00099 _sig = IniData[0], IniData[1], IniData[2], 0.0, 0.0, 0.0;
00100 _eps = 0.0,0.0,0.0,0.0,0.0,0.0;
00101
00102
00103 _v = IniData[3];
00104
00105 }
00106
00107 inline void LinearElastic::TgStiffness(Tensors::Tensor4 & De) const
00108 {
00109
00110 Tensors::AddScaled( _E/ (1.0+_nu) , Tensors::IIsym ,
00111 _nu*_E/((1.0+_nu)*(1.0-2.0*_nu)) , Tensors::IdyI , De );
00112
00113 }
00114
00115 inline void LinearElastic::StressUpdate(Tensors::Tensor2 const & DEps, Tensors::Tensor2 & DSig)
00116 {
00117
00118 Tensors::Tensor4 De;
00119 TgStiffness(De);
00120 Tensors::Dot(De,DEps, DSig);
00121
00122
00123 _sig += DSig;
00124 _eps += DEps;
00125
00126
00127 _v += -(DEps(0)+DEps(1)+DEps(2))*_v;
00128
00129 }
00130
00131 inline void LinearElastic::Actualize(Tensors::Tensor2 const & DSig, Tensors::Tensor2 & DEps)
00132 {
00133
00134 Tensors::Tensor4 Ce;
00135 Tensors::AddScaled( (1.0+_nu)/_E , Tensors::IIsym ,
00136 - _nu/_E , Tensors::IdyI , Ce );
00137
00138
00139 Tensors::Dot(Ce,DSig, DEps);
00140
00141
00142 _sig += DSig;
00143 _eps += DEps;
00144
00145
00146 _v += -(DEps(0)+DEps(1)+DEps(2))*_v;
00147
00148 }
00149
00150 inline void LinearElastic::BackupState()
00151 {
00152 _sig_bkp = _sig;
00153 _eps_bkp = _eps;
00154 _v_bkp = _v;
00155 }
00156
00157 inline void LinearElastic::RestoreState()
00158 {
00159 _sig = _sig_bkp;
00160 _eps = _eps_bkp;
00161 _v = _v_bkp;
00162 }
00163
00164
00166
00167
00168
00169 EquilibModel * LinearElasticMaker(Array<REAL> const & Prms, Array<REAL> const & IniData)
00170 {
00171 return new LinearElastic(Prms, IniData);
00172 }
00173
00174
00175 int LinearElasticRegister()
00176 {
00177 EquilibModelFactory["LinearElastic"] = LinearElasticMaker;
00178 return 0;
00179 }
00180
00181
00182 int __LinearElastic_dummy_int = LinearElasticRegister();
00183
00184 #endif // MECHSYS_LINEARELASTIC_H
00185
00186