genericc.h

00001 /*************************************************************************************
00002  * MechSys - A C++ library to simulate (Continuum) Mechanical Systems                *
00003  * Copyright (C) 2005 Dorival de Moraes Pedroso <dorival.pedroso at gmail.com>       *
00004  * Copyright (C) 2005 Raul Dario Durand Farfan  <raul.durand at gmail.com>           *
00005  *                                                                                   *
00006  * This file is part of MechSys.                                                     *
00007  *                                                                                   *
00008  * MechSys is free software; you can redistribute it and/or modify it under the      *
00009  * terms of the GNU General Public License as published by the Free Software         *
00010  * Foundation; either version 2 of the License, or (at your option) any later        *
00011  * version.                                                                          *
00012  *                                                                                   *
00013  * MechSys is distributed in the hope that it will be useful, but WITHOUT ANY        *
00014  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A   *
00015  * PARTICULAR PURPOSE. See the GNU General Public License for more details.          *
00016  *                                                                                   *
00017  * You should have received a copy of the GNU General Public License along with      *
00018  * MechSys; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, *
00019  * Fifth Floor, Boston, MA 02110-1301, USA                                           *
00020  *************************************************************************************/
00021 
00022 #ifndef MECHSYS_GENERICC_H
00023 #define MECHSYS_GENERICC_H
00024 
00025 #include "models/coupled/coupledmodel.h"
00026 
00027 using Tensors::Tensor1;
00028 using Tensors::Tensor2;
00029 
00030 template<class tEquilibModel, class tFlowModel>
00031 class GenericC: public CoupledModel
00032 {
00033 public:
00034     // Constructor
00035     GenericC() : _equilib_model(NULL), _flow_model(NULL) {} 
00036 
00037     // Destructor
00038     ~GenericC();
00039 
00040     // Methods
00041     String Name            () const=0; 
00042     void   TgStiffness     (Tensor4 & D, Tensor2 & d) const;
00043     REAL   Sr              () const { return 1.0;}; // Degree of saturation (for saturated condition only)
00044     REAL   phi             () const { return 1.0;}; // Sig_net = Sig_tot - phi*Suc*I
00045     REAL   n_times_dSr_dPp () const { return 0.0;}; // n:porosity times dSr_dPp (derivative of degree of sat. w.r.t. porepressure)
00046     void   TgPermeability  (Tensor2 & K) const;
00047     void   FlowVelocity    (Tensor1 const & Grad, Tensor1 & Vel) const;
00048     void   Actualize       (Tensor2 const & DSig, REAL const & DPp, Tensor2 & DEps, REAL & DnSr) {}
00049     void   StressUpdate    (Tensor2 const & DEps, REAL const & DPp, Tensor2 & DSig, REAL & DnSr);
00050     void   FlowUpdate      (REAL const & DPp);
00051     void   BackupState     ();
00052     void   RestoreState    ();
00053 
00054     // Access methods
00055     Tensor2 const & Sig() const { return _equilib_model->Sig();   }
00056     Tensor2 const & Eps() const { return _equilib_model->Eps();   } 
00057     REAL            Pp () const { return    _flow_model->Pp();    } 
00058     REAL        GammaW () const { return    _flow_model->GammaW();} 
00059     int  nInternalStateValues ()                              const;
00060     void InternalStateValues  (Array<REAL>   & IntStateVals ) const;
00061     void InternalStateNames   (Array<String> & IntStateNames) const;
00062 
00063 protected:
00064     // Protected methods
00065     void AllocateSubModels(Array<REAL> const & EquilibPrms    ,
00066                            Array<REAL> const & EquilibIniData ,
00067                            Array<REAL> const & FlowPrms       ,
00068                            Array<REAL> const & FlowIniData    );
00069 
00070 private:
00071     // Data
00072     tEquilibModel * _equilib_model;
00073     tFlowModel    * _flow_model;
00074 
00075 }; // class GenericC
00076 
00077 
00079 
00080 
00081 template<class tEquilibModel, class tFlowModel>
00082 inline GenericC<tEquilibModel,tFlowModel>::~GenericC() // {{{
00083 {
00084     if (_equilib_model != NULL) delete _equilib_model;
00085     if (_flow_model    != NULL) delete _flow_model;
00086 } // }}}
00087 
00088 template<class tEquilibModel, class tFlowModel>
00089 inline void GenericC<tEquilibModel,tFlowModel>::TgStiffness (Tensor4 & D, Tensor2 & d) const // {{{
00090 { 
00091     _equilib_model->TgStiffness(D);  
00092     d = 0.0*Tensors::I; // thereis no elasto-plastic part associated with suction in saturated cases
00093 } // }}}
00094 
00095 template<class tEquilibModel, class tFlowModel>
00096 inline void GenericC<tEquilibModel,tFlowModel>::TgPermeability(Tensor2 & K) const // {{{
00097 {
00098    _flow_model->TgPermeability(K);
00099 } // }}}
00100 
00101 template<class tEquilibModel, class tFlowModel>
00102 inline void GenericC<tEquilibModel,tFlowModel>::FlowVelocity(Tensor1 const & Grad, Tensor1 & Vel) const // {{{
00103 {
00104    _flow_model->FlowVelocity(Grad, Vel);
00105 } // }}}
00106 
00107 template<class tEquilibModel, class tFlowModel>
00108 inline void GenericC<tEquilibModel,tFlowModel>::StressUpdate(Tensor2 const & DEps, REAL const & DPp, Tensor2 & DSig, REAL & DnSr) // {{{
00109 {
00110     _equilib_model->StressUpdate(DEps, DSig);
00111     DnSr = -(DEps(0)+DEps(1)+DEps(2))*1.0;   // for saturated cases (Sr=1.0): DnSr = -dEv
00112 } // }}}
00113 
00114 template<class tEquilibModel, class tFlowModel>
00115 inline void GenericC<tEquilibModel,tFlowModel>::FlowUpdate(REAL const & DPp) // {{{
00116 {
00117     _flow_model->FlowUpdate(DPp);
00118 } // }}}
00119 
00120 template<class tEquilibModel, class tFlowModel>
00121 inline void GenericC<tEquilibModel,tFlowModel>::BackupState() // {{{
00122 {
00123     _equilib_model->BackupState();
00124        _flow_model->BackupState();
00125 } // }}}
00126 
00127 template<class tEquilibModel, class tFlowModel>
00128 inline void GenericC<tEquilibModel,tFlowModel>::RestoreState() // {{{
00129 {
00130     _equilib_model->RestoreState();
00131        _flow_model->RestoreState();
00132 } // }}}
00133 
00134 template<class tEquilibModel, class tFlowModel>
00135 inline int GenericC<tEquilibModel,tFlowModel>::nInternalStateValues() const // {{{
00136 {
00137     return _equilib_model->nInternalStateValues() + _flow_model->nInternalStateValues();
00138 } // }}}
00139 
00140 template<class tEquilibModel, class tFlowModel>
00141 inline void GenericC<tEquilibModel,tFlowModel>::InternalStateValues(Array<REAL> & IntStateVals ) const // {{{
00142 {
00143     Array<REAL> FlowIntStateVals;                          // Internal state values for flow model
00144     _equilib_model->InternalStateValues(IntStateVals);     // Get the internal state values for equilibrium model
00145        _flow_model->InternalStateValues(FlowIntStateVals); // Get the internal state values for flow model
00146     for (size_t i=0; i<FlowIntStateVals.size(); i++)
00147         IntStateVals.push_back(FlowIntStateVals[i]);       // Join the state values in one array
00148 } // }}}
00149 
00150 template<class tEquilibModel, class tFlowModel>
00151 inline void GenericC<tEquilibModel,tFlowModel>::InternalStateNames (Array<String> & IntStateNames) const // {{{
00152 {
00153     _equilib_model->InternalStateNames(IntStateNames);
00154 } // }}}
00155 
00156 template<class tEquilibModel, class tFlowModel>
00157 inline void GenericC<tEquilibModel,tFlowModel>::AllocateSubModels(Array<REAL> const & EquilibPrms, // {{{
00158                                                                   Array<REAL> const & EquilibIniData,
00159                                                                   Array<REAL> const & FlowPrms,
00160                                                                   Array<REAL> const & FlowIniData) 
00161 {
00162     _equilib_model = new tEquilibModel(EquilibPrms, EquilibIniData);
00163     _flow_model    = new tFlowModel   (FlowPrms,    FlowIniData);
00164 } // }}}
00165 
00166 #endif // MECHSYS_GENERICC_H
00167 
00168 // vim:fdm=marker

Generated on Wed Jan 24 15:56:27 2007 for MechSys by  doxygen 1.4.7