equilibmodel.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_EQUILIBMODEL_H
00023 #define MECHSYS_EQUILIBMODEL_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 <map>
00034 #include <string>
00035 
00036 #include "tensors/tensors.h"
00037 #include "util/string.h"
00038 #include "util/array.h"
00039 #include "numerical/integschemesctes.h"
00040 
00041 using Tensors::Tensor2;
00042 using Tensors::Tensor4;
00043 
00044 class EquilibModel
00045 {
00046 public:
00047     // Constructor
00048     EquilibModel() : _sig(0.0), _eps(0.0) {}
00049 
00050     // Destructor
00051     virtual ~EquilibModel() {}
00052 
00053     // Methods
00054     virtual String Name         () const =0;
00055     virtual void   TgStiffness  (Tensors::Tensor4 & D) const =0;
00056     virtual void   Actualize    (Tensor2 const & DSig, Tensor2 & DEps) =0;
00057     virtual void   StressUpdate (Tensor2 const & DEps, Tensor2 & DSig) =0;
00058     virtual void   BackupState  () =0;
00059     virtual void   RestoreState () =0;
00060 
00061     // Access methods
00062     Tensor2 const & Sig() const { return _sig; }
00063     Tensor2 const & Eps() const { return _eps; }
00064     virtual int  nInternalStateValues()                              const =0;
00065     virtual void InternalStateValues (Array<REAL>   & IntStateVals ) const =0;
00066     virtual void InternalStateNames  (Array<String> & IntStateNames) const =0;
00067 
00068     // Static
00069     static void SetIntegSchemesCtes(IntegSchemesCtes const & ISC) { _isc=ISC; }
00070 
00071 protected:
00072     // Data
00073     Tensor2 _sig;
00074     Tensor2 _eps;
00075     Tensor2 _sig_bkp;
00076     Tensor2 _eps_bkp;
00077 
00078     // Data (static)
00079     static IntegSchemesCtes _isc; 
00080 
00081 }; // class Model
00082 
00083 
00085 
00086 
00087 IntegSchemesCtes EquilibModel::_isc;
00088 
00089 
00091 
00092 
00093 // Define a pointer to a function that makes (allocate) a new equilibmodel
00094 typedef EquilibModel * (*EquilibModelMakerPtr)(Array<REAL> const & Prms, Array<REAL> const & IniData);
00095 
00096 // Typdef of the array map that contains all the pointers to the functions that makes equilibmodels
00097 typedef std::map<String, EquilibModelMakerPtr, std::less<String> > EquilibModelFactory_t;
00098 
00099 // Instantiate the array map that contains all the pointers to the functions that makes equilibmodels
00100 EquilibModelFactory_t EquilibModelFactory;
00101 
00102 // Allocate a new equilibmodel according to a string giving the name of the equilibmodel
00103 EquilibModel * AllocEquilibModel(String const & Name, Array<REAL> const & Prms, Array<REAL> const & IniData) // {{{
00104 {
00105     EquilibModelMakerPtr ptr=NULL;
00106     ptr = EquilibModelFactory[Name];
00107     if (ptr==NULL)
00108         throw new Fatal(_("FEM::AllocEquilibModel: There is no < %s > implemented in this library"), Name.c_str());
00109     return (*ptr)(Prms, IniData);
00110 } // }}}
00111 
00112 #endif // MECHSYS_EQUILIBMODEL_H
00113 
00114 // vim:fdm=marker

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