ttx.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_TTX_H
00023 #define MECHSYS_LABTESTSIM_TTX_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 #ifndef ZERO
00038   #define ZERO 1.0e-10
00039 #endif
00040 
00041 namespace LabTestSim
00042 {
00043 
00044 template<typename T_Model>
00045 class TTX : public Equipment<T_Model>
00046 {
00047 public:
00048     TTX (T_Model * pModel, String const & strEquipment, bool StopOnFailure, bool SaveIntStates, bool Silent=false)
00049         : Equipment<T_Model>(pModel, strEquipment, StopOnFailure, SaveIntStates, Silent)
00050     {}
00051 
00052 private:
00053     int  _exx_idx() const { return 0; } // Exx component index
00054     bool _do_update_one_increment(State const & DeltaState);
00055 }; // class TTX
00056 
00057 
00059 
00060 
00061 template<typename T_Model>
00062 inline bool TTX<T_Model>::_do_update_one_increment(State const & DeltaState)
00063 {
00064     Tensors::Tensor2 dSig;  dSig = DeltaState.Sa, DeltaState.Sr, DeltaState.St, 0.0,0.0,0.0;
00065     REAL             dPp;   dPp  = DeltaState.Pp;
00066     Tensors::Tensor2 dEps;
00067     try
00068     {
00069 #ifdef USE_COUPLEDMODEL
00070         REAL DnSr;
00071         Equipment<T_Model>::_model->Actualize(dSig, dPp, dEps, DnSr);
00072 #else
00073         Equipment<T_Model>::_model->Actualize(dSig, dEps);
00074 #endif
00075         return true;
00076     }
00077     catch (Exception * e)
00078     {
00079              if (e->IsFatal  ()) throw;
00080         else if (e->IsWarning()) { if (!Equipment<T_Model>::_silent) e->Cout(); delete e; return false; }
00081         else                     { if (!Equipment<T_Model>::_silent) e->Cout(); delete e; return true;  }
00082     }
00083 }
00084 
00085 }; // namespace LabTestSim
00086 
00087 #endif // MECHSYS_LABTESTSIM_TTX_H

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