celastic.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_COUPLEDELASTIC_H
00023 #define MECHSYS_COUPLEDELASTIC_H
00024 
00025 #include "models/coupled/genericc.h"
00026 #include "models/linearelastic.h"
00027 #include "models/flow/linearflow.h"
00028 
00029 class CElastic : public GenericC<LinearElastic, LinearFlow> // GenericC is a generic Coupled model (intermediate class)
00030 {
00031 public:
00032     // Constructor
00033     CElastic(Array<REAL> const & Prms, Array<REAL> const & IniData);
00034 
00035     // Derived methods
00036     String Name() const { return "CElastic"; }; 
00037 
00038 }; // class CElastic
00039 
00040 
00042 
00043 
00044 inline CElastic::CElastic(Array<REAL> const & Prms, Array<REAL> const & IniData) // {{{
00045 {
00046     // ##################################################################### Setup Parameters
00047 
00048     /* example.mat 
00049      * #--------------------------------------
00050      * #        Young  Poisson        k  gamaW
00051      * Elastic  20000     0.25   1.0e-5     10
00052      */
00053 
00054     // Check number of parameters
00055     const size_t n_equi_prms = LinearElastic::NPRMS; // Elastic    { E nu }
00056     const size_t n_flow_prms = LinearFlow   ::NPRMS; // LinearFlow { k gamaW }
00057     const size_t n_prms      = n_equi_prms+n_flow_prms;
00058     if (Prms.size()!=n_prms)
00059         throw new Fatal(_("CElastic::Constructor: The number of parameters (%d) is incorrect. It must be equal to %d"), Prms.size(), n_prms);
00060 
00061     // Parameters
00062     Array<REAL> equi_prms; equi_prms.resize(n_equi_prms); for (size_t i=0; i<n_equi_prms; ++i) equi_prms[i]=Prms[i];
00063     Array<REAL> flow_prms; flow_prms.resize(n_flow_prms); for (size_t i=0; i<n_flow_prms; ++i) flow_prms[i]=Prms[i+n_equi_prms];
00064 
00065     // ##################################################################### Setup Initial State
00066 
00067     // Check number of initial data
00068     const size_t n_equi_idat = LinearElastic::NIDAT; // LinearElastic { SigX SigY SigZ }
00069     const size_t n_flow_idat = LinearFlow   ::NIDAT; // LinearFlow    { Pp }
00070     const size_t n_idat      = n_equi_idat+n_flow_idat;
00071     if (IniData.size()!=n_idat) // Layered analysis
00072         throw new Fatal(_("CElastic::Constructor: The number of initial data (%d) is not sufficiet (it must be equal to %d)"), IniData.size(), n_idat);
00073 
00074     // Initial data
00075     Array<REAL> equi_idat; equi_idat.resize(n_equi_idat); for (size_t i=0; i<n_equi_idat; ++i) equi_idat[i]=IniData[i];
00076     Array<REAL> flow_idat; flow_idat.resize(n_flow_idat); for (size_t i=0; i<n_flow_idat; ++i) flow_idat[i]=IniData[i+n_equi_idat];
00077 
00078     // ##################################################################### Allocate derived models
00079     
00080     // Allocate equilib and flow models
00081     AllocateSubModels(equi_prms, equi_idat, flow_prms, flow_idat);
00082 
00083 } // }}}
00084 
00085 
00087 
00088 // Allocate a new CElastic model
00089 CoupledModel * CElasticMaker(Array<REAL> const & Prms, Array<REAL> const & IniData)
00090 {
00091     return new CElastic(Prms, IniData); 
00092 }
00093 
00094 // Register an CElastic model into ModelFactory array map
00095 int CElasticRegister()
00096 {
00097     CoupledModelFactory["CElastic"] = CElasticMaker;
00098     return 0;
00099 }
00100 
00101 // Execute the autoregistration
00102 int __CElastic_dummy_int = CElasticRegister();
00103 
00104 // }}}
00105 
00106 #endif // MECHSYS_COUPLEDELASTIC_H
00107 
00108 // vim:fdm=marker

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