MechSys  1.0
Computing library for simulations in continuum and discrete mechanics
/home/dorival/mechsys/lib/models/linelastic.h
Go to the documentation of this file.
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_LINELASTIC_H
00021 #define MECHSYS_LINELASTIC_H
00022 
00023 // MechSys
00024 #include <mechsys/models/model.h>
00025 #include <mechsys/models/equilibstate.h>
00026 
00027 class LinElastic : public Model
00028 {
00029 public:
00030     // Constructor
00031     LinElastic (int NDim, SDPair const & Prms);
00032 
00033     // Methods
00034     void InitIvs   (SDPair const & Ini, State * Sta)                             const;
00035     void Rate      (State const * Sta, Vec_t const & DEpsDt, Vec_t & DSigDt, Vec_t & DIvsDt) const;
00036     void TgIncs    (State const * Sta, Vec_t & DEps, Vec_t & DSig, Vec_t & DIvs) const;
00037     void InvTgIncs (State const * Sta, Vec_t & DSig, Vec_t & DEps, Vec_t & DIvs) const;
00038     void Stiffness (State const * Sta, Mat_t & D)                                const { D = De; }
00039 
00040     // Data
00041     double E;
00042     double nu;
00043     Mat_t  De;
00044 };
00045 
00046 
00048 
00049 
00050 inline LinElastic::LinElastic (int NDim, SDPair const & Prms)
00051     : Model (NDim,Prms,/*niv*/0,"LinElastic")
00052 {
00053     // parameters
00054     E  = Prms("E");
00055     nu = Prms("nu");
00056 
00057     // elastic stiffness
00058     if (NDim==2)
00059     {
00060         De.change_dim (4,4);
00061         if (GTy==pse_t)
00062         {
00063             double c = E/(1.0-nu*nu);
00064             De = c,    c*nu, 0.0,        0.0,
00065                  c*nu, c,    0.0,        0.0,
00066                  0.0,  0.0,  0.0,        0.0,
00067                  0.0,  0.0,  0.0, c*(1.0-nu);
00068         }
00069         else if (GTy==psa_t || GTy==axs_t)
00070         {
00071             double c = E/((1.0+nu)*(1.0-2.0*nu));
00072             De = c*(1.0-nu),       c*nu ,      c*nu ,            0.0,
00073                       c*nu ,  c*(1.0-nu),      c*nu ,            0.0,
00074                       c*nu ,       c*nu , c*(1.0-nu),            0.0,
00075                        0.0 ,        0.0 ,       0.0 , c*(1.0-2.0*nu);
00076         }
00077         else throw new Fatal("LinElastic::Stiffness: 2D: This model is not available for GeometryType = %s",GTypeToStr(GTy).CStr());
00078     }
00079     else
00080     {
00081         if (GTy==d3d_t)
00082         {
00083             De.change_dim (6,6);
00084             double c = E/((1.0+nu)*(1.0-2.0*nu));
00085             De = c*(1.0-nu),       c*nu ,      c*nu ,            0.0,            0.0,            0.0,
00086                       c*nu ,  c*(1.0-nu),      c*nu ,            0.0,            0.0,            0.0,
00087                       c*nu ,       c*nu , c*(1.0-nu),            0.0,            0.0,            0.0,
00088                        0.0 ,        0.0 ,       0.0 , c*(1.0-2.0*nu),            0.0,            0.0,
00089                        0.0 ,        0.0 ,       0.0 ,            0.0, c*(1.0-2.0*nu),            0.0,
00090                        0.0 ,        0.0 ,       0.0 ,            0.0,            0.0, c*(1.0-2.0*nu);
00091         }
00092         else throw new Fatal("LinElastic::Stiffness: 3D: This model is not available for GeometryType = %s",GTypeToStr(GTy).CStr());
00093     }
00094 
00095     // set model in stress update
00096     SUp.SetModel (this);
00097 }
00098 
00099 inline void LinElastic::InitIvs (SDPair const & Ini, State * Sta) const
00100 {
00101     EquilibState * sta = static_cast<EquilibState*>(Sta);
00102     sta->Init (Ini);
00103 }
00104 
00105 inline void LinElastic::InvTgIncs (State const * Sta, Vec_t & DSig, Vec_t & DEps, Vec_t & DIvs) const
00106 {
00107     Mat_t Ce(NCps,NCps);
00108     Inv (De, Ce);
00109     DEps = Ce*DSig;
00110 }
00111 
00112 inline void LinElastic::Rate (State const * Sta, Vec_t const & DEpsDt, Vec_t & DSigDt, Vec_t & DIvsDt) const
00113 {
00114     DSigDt = De*DEpsDt;
00115     if (GTy==pse_t) throw new Fatal("LinElastic::Rate: this method does not work with plane-stress (pse)");
00116 }
00117 
00118 inline void LinElastic::TgIncs (State const * Sta, Vec_t & DEps, Vec_t & DSig, Vec_t & DIvs) const
00119 {
00120     DSig = De*DEps;
00121     if (GTy==pse_t) DEps(2) = -nu*(DSig(0)+DSig(1))/E;
00122 }
00123 
00124 
00126 
00127 
00128 Model * LinElasticMaker(int NDim, SDPair const & Prms, Model const * O) { return new LinElastic(NDim,Prms); }
00129 
00130 int LinElasticRegister()
00131 {
00132     ModelFactory   ["LinElastic"] = LinElasticMaker;
00133     MODEL.Set      ("LinElastic", (double)MODEL.Keys.Size());
00134     MODEL_PRM_NAMES["LinElastic"].Resize(2);
00135     MODEL_PRM_NAMES["LinElastic"] = "E", "nu";
00136     MODEL_IVS_NAMES["LinElastic"].Resize(0);
00137     return 0;
00138 }
00139 
00140 int __LinElastic_dummy_int = LinElasticRegister();
00141 
00142 
00143 #endif // MECHSYS_LINELASTIC_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines