![]() |
MechSys
1.0
Computing library for simulations in continuum and discrete mechanics
|
00001 /************************************************************************ 00002 * MechSys - Open Library for Mechanical Systems * 00003 * Copyright (C) 2005 Dorival M. Pedroso, Raul Durand * 00004 * Copyright (C) 2009 Sergio Galindo * 00005 * * 00006 * This program is free software: you can redistribute it and/or modify * 00007 * it under the terms of the GNU General Public License as published by * 00008 * the Free Software Foundation, either version 3 of the License, or * 00009 * any later version. * 00010 * * 00011 * This program is distributed in the hope that it will be useful, * 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00014 * GNU General Public License for more details. * 00015 * * 00016 * You should have received a copy of the GNU General Public License * 00017 * along with this program. If not, see <http://www.gnu.org/licenses/> * 00018 ************************************************************************/ 00019 00020 #ifndef MECHSYS_NLELASTIC_H 00021 #define MECHSYS_NLELASTIC_H 00022 00023 // MechSys 00024 #include <mechsys/models/model.h> 00025 #include <mechsys/models/equilibstate.h> 00026 00027 class NLElastic : public Model 00028 { 00029 public: 00030 // Constructor 00031 NLElastic (int NDim, SDPair const & Prms); 00032 00033 // Methods 00034 void InitIvs (SDPair const & Ini, State * Sta) const; 00035 void TgIncs (State const * Sta, Vec_t & DEps, Vec_t & DSig, Vec_t & DIvs) const; 00036 void InvTgIncs (State const * Sta, Vec_t & DSig, Vec_t & DEps, Vec_t & DIvs) const; 00037 void Stiffness (State const * Sta, Mat_t & D) const; 00038 00039 // Parameters 00040 double K0; 00041 double G0; 00042 double alp; 00043 double bet; 00044 00045 // Data 00046 Mat_t Psd, IdyI; 00047 00048 // Scratchpad 00049 mutable Mat_t De; 00050 }; 00051 00052 00054 00055 00056 inline NLElastic::NLElastic (int NDim, SDPair const & Prms) 00057 : Model (NDim,Prms,/*niv*/0,"NLElastic") 00058 { 00059 if (GTy==pse_t) throw new Fatal("NLElastic::NLElastic: This model is not available for plane-stress (pse)"); 00060 00061 // parameters 00062 K0 = Prms("K0"); 00063 G0 = Prms("G0"); 00064 alp = Prms("alp"); 00065 bet = Prms("bet"); 00066 00067 // isotropic tensors 00068 Calc_Psd (NCps, Psd); 00069 Calc_IdyI (NCps, IdyI); 00070 00071 // elastic stiffness 00072 De.change_dim (NCps,NCps); 00073 00074 // set model in stress update 00075 SUp.SetModel (this); 00076 } 00077 00078 inline void NLElastic::InitIvs (SDPair const & Ini, State * Sta) const 00079 { 00080 EquilibState * sta = static_cast<EquilibState*>(Sta); 00081 sta->Init (Ini); 00082 } 00083 00084 inline void NLElastic::TgIncs (State const * Sta, Vec_t & DEps, Vec_t & DSig, Vec_t & DIvs) const 00085 { 00086 Stiffness (Sta, De); 00087 DSig = De*DEps; 00088 } 00089 00090 inline void NLElastic::InvTgIncs (State const * Sta, Vec_t & DSig, Vec_t & DEps, Vec_t & DIvs) const 00091 { 00092 /* 00093 Mat_t Ce(NCps,NCps); 00094 Stiffness (Sta, De); 00095 Inv (De, Ce); 00096 DEps = Ce*DSig; 00097 */ 00098 00099 EquilibState const * sta = static_cast<EquilibState const *>(Sta); 00100 double ev = Calc_ev (sta->Eps); 00101 double ed = Calc_ed (sta->Eps); 00102 double K = K0*exp(-alp*ev*100.0); 00103 double G = G0*exp(-bet*ed*100.0); 00104 double ck = (K<1.0e-14 ? 1.0e+14 : (1.0/(9.0*K))); 00105 double cg = (G<1.0e-14 ? 1.0e+14 : (1.0/(2.0*G))); 00106 Mat_t Ce(NCps,NCps); 00107 Ce = cg*Psd + ck*IdyI; 00108 DEps = Ce*DSig; 00109 00110 //cout << ev << " " << K << endl; 00111 } 00112 00113 inline void NLElastic::Stiffness (State const * Sta, Mat_t & D) const 00114 { 00115 EquilibState const * sta = static_cast<EquilibState const *>(Sta); 00116 double ev = Calc_ev (sta->Eps); 00117 double ed = Calc_ed (sta->Eps); 00118 double K = K0*exp(-alp*ev*100.0); 00119 double G = G0*exp(-bet*ed*100.0); 00120 D = (2.0*G)*Psd + K*IdyI; 00121 } 00122 00123 00125 00126 00127 Model * NLElasticMaker(int NDim, SDPair const & Prms, Model const * O) { return new NLElastic(NDim,Prms); } 00128 00129 int NLElasticRegister() 00130 { 00131 ModelFactory ["NLElastic"] = NLElasticMaker; 00132 MODEL.Set ("NLElastic", (double)MODEL.Keys.Size()); 00133 MODEL_PRM_NAMES["NLElastic"].Resize(4); 00134 MODEL_PRM_NAMES["NLElastic"] = "K0", "G0", "alp", "bet"; 00135 MODEL_IVS_NAMES["NLElastic"].Resize(0); 00136 return 0; 00137 } 00138 00139 int __NLElastic_dummy_int = NLElasticRegister(); 00140 00141 00142 #endif // MECHSYS_NLELASTIC_H