![]() |
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_FLOWUPDATE_H 00021 #define MECHSYS_FLOWUPDATE_H 00022 00023 // Std Lib 00024 #include <iostream> 00025 00026 // MechSys 00027 #include <mechsys/models/model.h> 00028 #include <mechsys/models/flowstate.h> 00029 00030 class FlowUpdate 00031 { 00032 public: 00033 // enum 00034 enum Scheme_t { FE_t, ME_t }; 00035 00036 // Constructor 00037 FlowUpdate (Model const * Mdl); 00038 00039 // Methods 00040 void Update (Vec_t const & DGra, State * Sta, Vec_t & DVel) const; 00041 00042 // Data 00043 Model const * Mdl; 00044 00045 // Constants for integration 00046 Scheme_t Scheme; 00047 size_t NDiv; 00048 double STOL; 00049 double dTini; 00050 double mMin; 00051 double mMax; 00052 size_t maxSS; 00053 }; 00054 00055 00057 00058 00059 inline FlowUpdate::FlowUpdate (Model const * TheMdl) 00060 : Mdl (TheMdl), 00061 Scheme (FE_t), 00062 NDiv (1), 00063 STOL (1.0e-5), 00064 dTini (1.0), 00065 mMin (0.1), 00066 mMax (10.0), 00067 maxSS (2000) 00068 { 00069 } 00070 00071 inline void FlowUpdate::Update (Vec_t const & DGra, State * Sta, Vec_t & DVel) const 00072 { 00073 FlowState * sta = static_cast<FlowState*>(Sta); 00074 DVel = sta->Vel; // temporary copy to calculate increment later 00075 00076 Vec_t dvel(size(sta->Vel)); 00077 Vec_t divs(size(sta->Ivs)); 00078 00079 if (Scheme==FE_t) 00080 { 00081 Vec_t dgra(DGra/NDiv); 00082 for (size_t i=0; i<NDiv; ++i) 00083 { 00084 Mdl->TgIncs (sta, dgra, dvel, divs); 00085 sta->Vel += dvel; 00086 sta->Gra += dgra; 00087 sta->Ivs += divs; 00088 } 00089 } 00090 else throw new Fatal("FlowUpdate::Update: Scheme==ME_t is not available yet"); 00091 00092 // return total stress increment 00093 DVel = sta->Vel - DVel; 00094 } 00095 00096 #endif // MECHSYS_FLOWUPDATE_H