![]() |
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_LINFLOW_H 00021 #define MECHSYS_LINFLOW_H 00022 00023 // MechSys 00024 #include <mechsys/models/model.h> 00025 #include <mechsys/models/flowstate.h> 00026 00027 class LinFlow : public Model 00028 { 00029 public: 00030 // Constructor 00031 LinFlow (int NDim, SDPair const & Prms); 00032 00033 // Methods 00034 void InitIvs (SDPair const & Ini, State * Sta) const; 00035 void TgIncs (State const * Sta, Vec_t & DGra, Vec_t & DVel, Vec_t & DIvs) const { DVel = -1.0*D*DGra; } 00036 void Stiffness (State const * Sta, Mat_t & TheD) const { TheD = D; } 00037 00038 // Data 00039 double kx; 00040 double ky; 00041 double kz; 00042 Mat_t D; 00043 }; 00044 00045 00047 00048 00049 inline LinFlow::LinFlow (int NDim, SDPair const & Prms) 00050 : Model (NDim,Prms,/*niv*/0,"LinFlow") 00051 { 00052 // parameters 00053 if (Prms.HasKey("k")) 00054 { 00055 double k = Prms("k"); 00056 kx = k; 00057 ky = k; 00058 kz = k; 00059 } 00060 else 00061 { 00062 kx = Prms("kx"); 00063 ky = Prms("ky"); if (NDim==3) 00064 kz = Prms("kz"); 00065 } 00066 00067 // stiffness 00068 D.change_dim (NDim,NDim); 00069 if (NDim==2) 00070 { 00071 D = kx, 0.0, 00072 0.0, ky; 00073 } 00074 else if (NDim==3) 00075 { 00076 D = kx, 0.0, 0.0, 00077 0.0, ky, 0.0, 00078 0.0, 0.0, kz; 00079 } 00080 } 00081 00082 inline void LinFlow::InitIvs (SDPair const & Ini, State * Sta) const 00083 { 00084 FlowState * sta = static_cast<FlowState*>(Sta); 00085 sta->Init (Ini); 00086 } 00087 00088 00090 00091 00092 Model * LinFlowMaker(int NDim, SDPair const & Prms, Model const * O) { return new LinFlow(NDim,Prms); } 00093 00094 int LinFlowRegister() 00095 { 00096 ModelFactory ["LinFlow"] = LinFlowMaker; 00097 MODEL.Set ("LinFlow", (double)MODEL.Keys.Size()); 00098 MODEL_PRM_NAMES["LinFlow"].Resize(3); 00099 MODEL_PRM_NAMES["LinFlow"] = "kx", "ky", "kz"; 00100 MODEL_IVS_NAMES["LinFlow"].Resize(0); 00101 return 0; 00102 } 00103 00104 int __LinFlow_dummy_int = LinFlowRegister(); 00105 00106 00107 #endif // MECHSYS_LINFLOW_H