ctx.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_LABTESTSIM_CTX_H
00023 #define MECHSYS_LABTESTSIM_CTX_H
00024 
00025 #ifdef HAVE_CONFIG_H
00026   #include "config.h"
00027 #else
00028   #ifndef REAL
00029     #define REAL double
00030   #endif
00031 #endif
00032 
00033 #include "tensors/functions.h"
00034 #include "util/string.h"
00035 #include "labtestsim/equipment.h"
00036 
00037 namespace LabTestSim
00038 {
00039 
00040 template<typename T_Model>
00041 class CTX : public Equipment<T_Model>
00042 {
00043 public:
00044     CTX (T_Model * pModel, String const & strEquipment, bool StopOnFailure, bool SaveIntStates, bool Silent=false)
00045         : Equipment<T_Model>(pModel, strEquipment, StopOnFailure, SaveIntStates, Silent)
00046     {}
00047 
00048 private:
00049     int  _exx_idx() const { return 0; } // Exx component index
00050     bool _do_update_one_increment(State const & DeltaState);
00051 }; // class CTX
00052 
00053 
00055 
00056 
00057 template<typename T_Model>
00058 inline bool CTX<T_Model>::_do_update_one_increment(State const & DeltaState)
00059 {
00060     Tensors::Tensor2 dSig;  dSig = DeltaState.Sa, DeltaState.Sr, DeltaState.Sr, 0.0,0.0,0.0;
00061     REAL             dPp;   dPp  = DeltaState.Pp;
00062     Tensors::Tensor2 dEps;
00063     try
00064     {
00065 #ifdef USE_COUPLEDMODEL
00066         REAL DnSr;
00067         Equipment<T_Model>::_model->Actualize(dSig, dPp, dEps, DnSr);
00068 #else
00069         Equipment<T_Model>::_model->Actualize(dSig, dEps);
00070 #endif
00071         return true;
00072     }
00073     catch (Exception * e)
00074     {
00075              if (e->IsFatal  ()) throw;
00076         else if (e->IsWarning()) { if (!Equipment<T_Model>::_silent) e->Cout(); delete e; return false; }
00077         else                     { if (!Equipment<T_Model>::_silent) e->Cout(); delete e; return true;  }
00078     }
00079 }
00080 
00081 }; // namespace LabTestSim
00082 
00083 #endif // MECHSYS_LABTESTSIM_CTX_H

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