MechSys  1.0
Computing library for simulations in continuum and discrete mechanics
/home/dorival/mechsys/lib/models/unsatflowstate.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  *                                                                      *
00005  * This program is free software: you can redistribute it and/or modify *
00006  * it under the terms of the GNU General Public License as published by *
00007  * the Free Software Foundation, either version 3 of the License, or    *
00008  * any later version.                                                   *
00009  *                                                                      *
00010  * This program is distributed in the hope that it will be useful,      *
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the         *
00013  * GNU General Public License for more details.                         *
00014  *                                                                      *
00015  * You should have received a copy of the GNU General Public License    *
00016  * along with this program. If not, see <http://www.gnu.org/licenses/>  *
00017  ************************************************************************/
00018 
00019 #ifndef MECHSYS_UNSATFLOWSTATE_H
00020 #define MECHSYS_UNSATFLOWSTATE_H
00021 
00022 // MechSys
00023 #include <mechsys/models/model.h>
00024 
00025 class UnsatFlowState : public State
00026 {
00027 public:
00028     // static
00029     static Array<String> Keys;
00030 
00031     // Constructor
00032     UnsatFlowState (int NDim) : State(NDim) {}
00033 
00034     // Methods
00035     void   Init    (SDPair const & Ini, size_t NIvs=0);
00036     void   Backup  () { nBkp=n; SwBkp=Sw; pcBkp=pc; DryingBkp=Drying; RhoWBkp=RhoW; RhoSBkp=RhoS; }
00037     void   Restore () { n=nBkp; Sw=SwBkp; pc=pcBkp; Drying=DryingBkp; RhoW=RhoWBkp; RhoS=RhoSBkp; }
00038     size_t PckSize () const { return 6; }
00039     void   Pack    (Array<double>       & V) const;
00040     void   Unpack  (Array<double> const & V);
00041 
00042     // Auxiliary methods
00043     void Output (SDPair & KeysVals) const;
00044 
00045     // Data
00046     double nBkp,      n;      
00047     double SwBkp,     Sw;     
00048     double pcBkp,     pc;     
00049     bool   DryingBkp, Drying; 
00050     double RhoWBkp,   RhoW;   
00051     double RhoSBkp,   RhoS;   
00052 
00053     Array<double> dndt;
00054     Array<double> dSwdt;
00055     Array<double> dRhoWdt;
00056 };
00057 
00058 Array<String> UnsatFlowState::Keys;
00059 
00060 
00062 
00063 
00064 inline void UnsatFlowState::Init (SDPair const & Ini, size_t NIvs)
00065 {
00066     n      = Ini("n");
00067     Sw     = Ini("Sw");
00068     pc     = Ini("pc");
00069     Drying = false;
00070     RhoW   = Ini("RhoW");
00071     RhoS   = Ini("RhoS");
00072 
00073     if (Keys.Size()==0)
00074     {
00075         Keys.Resize(6);
00076         Keys = "n", "Sw", "pc", "drying", "RhoW", "RhoS";
00077     }
00078 }
00079 
00080 inline void UnsatFlowState::Pack (Array<double> & V) const
00081 {
00082     V.Resize (PckSize());
00083     V[0] = n;
00084     V[1] = Sw;
00085     V[2] = pc;
00086     V[3] = Drying;
00087     V[4] = RhoW;
00088     V[5] = RhoS;
00089 }
00090 
00091 inline void UnsatFlowState::Unpack (Array<double> const & V)
00092 {
00093     if (V.Size()!=PckSize()) throw new Fatal("UnsatFlowState::Unpack: Size of given vector (%zd) is different of correct size of Pack (%zd)",V.Size(),PckSize());
00094     n      = V[0];
00095     Sw     = V[1];
00096     pc     = V[2];
00097     Drying = V[3];
00098     RhoW   = V[4];
00099     RhoS   = V[5];
00100 }
00101 
00102 inline void UnsatFlowState::Output (SDPair & KeysVals) const
00103 {
00104     KeysVals.Set ("n Sw pc drying RhoW RhoS", n, Sw, pc, (double)Drying, RhoW, RhoS);
00105 }
00106 
00107 
00108 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines