linearflow.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_LINEARFLOWMODEL_H
00023 #define MECHSYS_LINEARFLOWMODEL_H
00024 
00025 #include "models/flow/flowmodel.h"
00026 
00027 using Tensors::Tensor1;
00028 using Tensors::Tensor2;
00029 
00030 class LinearFlow: public FlowModel
00031 {
00032 public:
00033     // Constructor
00034     LinearFlow(Array<REAL> const & Prms, Array<REAL> const & IniData);
00035 
00036     // Destructor
00037     virtual ~LinearFlow() {}
00038 
00039     // Constatns
00040     static const size_t NPRMS = 2;
00041     static const size_t NIDAT = 1;
00042 
00043     // Derived methods
00044     String Name() const { return "LinearFlow"; };
00045     void   TgPermeability       (Tensor2 & K) const;
00046     void   FlowVelocity         (Tensor1 const & Grad, Tensor1 & Vel) const;
00047     void   FlowUpdate           (REAL const & DPp);
00048     void   BackupState          ();
00049     void   RestoreState         ();
00050     int    nInternalStateValues () const { return 0; };
00051     void   InternalStateValues  (Array<REAL>   & IntStateVals ) const {}
00052     void   InternalStateNames   (Array<String> & IntStateNames) const {}
00053     REAL   Pp                   () const { return _ppr; }; 
00054     REAL   GammaW               () const { return _gammaW; }
00055 
00056 protected:
00057     // Data
00058     REAL _k;       // isotropic coeficient of permeability
00059     REAL _gammaW;   // Water specific weight
00060     REAL _ppr;     // pore-pressure
00061     REAL _ppr_bkp; // pore-pressure (backup)
00062 
00063 }; // class LinFlow
00064 
00065 
00067 
00068 
00069 inline LinearFlow::LinearFlow(Array<REAL> const & Prms, Array<REAL> const & IniData) // {{{
00070 {
00071     
00072     // ##################################################################### Setup Parameters
00073 
00074     /* example.mat
00075      * #-----------------------
00076      * #             0        1
00077      * #             k      gammaW
00078      * LinearFlow  1.0e-4    10
00079      */
00080 
00081     // Check number of parameters
00082     if (Prms.size()!=NPRMS)
00083         throw new Fatal(_("LinearFlow::Constructor: The number of parameters is incorrect (it must be %d)"),NPRMS);
00084 
00085     // Parameters
00086     _k      = Prms[0];
00087     _gammaW = Prms[1];
00088 
00089     // Check number of initial data
00090     if (IniData.size()!=NIDAT)
00091         throw new Fatal(_("LinearFlow::Constructor: The number of initial (%d) data is incorrect { Pp }"),NIDAT);
00092 
00093     // Initial data
00094     _ppr = IniData[0];
00095 
00096 } // }}}
00097 
00098 inline void LinearFlow::TgPermeability(Tensor2 & K) const // {{{
00099 {
00100     // Linear tangent permeability
00101     K = _k, _k, _k, 0,0,0;
00102 } // }}}
00103 
00104 inline void LinearFlow::FlowVelocity(Tensor1 const & Grad, Tensor1 & Vel) const // {{{
00105 {
00106     Tensor2 K;
00107     TgPermeability(K); 
00108     Tensors::Dot(-K,Grad, Vel);
00109 } // }}}
00110 
00111 inline void LinearFlow::FlowUpdate(REAL const & DPp) // {{{
00112 {
00113     // Update pore-pressure
00114     _ppr += DPp;
00115 } // }}}
00116 
00117 inline void LinearFlow::BackupState() // {{{
00118 {
00119     _ppr_bkp = _ppr;
00120 } // }}}
00121 
00122 inline void LinearFlow::RestoreState() // {{{
00123 { 
00124     _ppr = _ppr_bkp;
00125 } // }}}
00126 
00127 
00129 
00130 // Allocate a new LinFlow model
00131 FlowModel * LinearFlowMaker(Array<REAL> const & Prms, Array<REAL> const & IniData)
00132 {
00133     return new LinearFlow(Prms, IniData);
00134 }
00135 
00136 // Register an LinearFlow model into ModelFactory array map
00137 int LinearFlowRegister()
00138 {
00139     FlowModelFactory["LinearFlow"] = LinearFlowMaker;
00140     return 0;
00141 }
00142 
00143 // Execute the autoregistration
00144 int __LinearFlow_dummy_int = LinearFlowRegister();
00145 
00146 // }}}
00147 
00148 #endif // MECHSYS_LINEARFLOWMODEL_H
00149 
00150 // vim:fdm=marker

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