MechSys  1.0
Computing library for simulations in continuum and discrete mechanics
/home/dorival/mechsys/lib/fem/geomelem.h
Go to the documentation of this file.
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_FEM_GEOMELEM_H
00021 #define MECHSYS_FEM_GEOMELEM_H
00022 
00023 // MechSys
00024 #include <mechsys/geomtype.h>
00025 #include <mechsys/fem/quadrature.h>
00026 #include <mechsys/fem/node.h>
00027 #include <mechsys/util/string.h>
00028 #include <mechsys/linalg/matvec.h>
00029 
00030 namespace FEM
00031 {
00032 
00033 class GeomElem
00034 {
00035 public:
00036     // Constructor & Destructor
00037     GeomElem (int          NDim,                         
00038               size_t       NN,                           
00039               size_t       NFN,                          
00040               char const * Name="__unnamed_geomelem__"); 
00041     virtual ~GeomElem () {}
00042 
00043     // Methods to be overloaded
00044     virtual void   SetIPs     (int TotNIP)                            =0; 
00045     virtual size_t FNode      (size_t IdxFace, size_t IdxFNode) const =0; 
00046     virtual void   Shape      (double r, double s, double t)    const =0; 
00047     virtual void   Derivs     (double r, double s, double t)    const =0; 
00048     virtual void   FaceShape  (double r, double s)              const =0; 
00049     virtual void   FaceDerivs (double r, double s)              const =0; 
00050     virtual void   NatCoords  (Mat_t & C)                       const =0; 
00051 
00052     // Constants
00053     size_t             NN;   
00054     size_t             NFN;  
00055     size_t             NIP;  
00056     size_t             NFIP; 
00057     IntegPoint const * IPs;  
00058     IntegPoint const * FIPs; 
00059     String             Name; 
00060 
00061     // Mutable data
00062     mutable Vec_t N;     
00063     mutable Mat_t dNdR;  
00064     mutable Vec_t FN;    
00065     mutable Mat_t FdNdR; 
00066 };
00067 
00068 
00070 
00071 
00072 inline GeomElem::GeomElem (int NDim, size_t TheNN, size_t TheNFN, char const * TheName)
00073     : NN(TheNN), NFN(TheNFN), Name(TheName)
00074 {
00075     N    .change_dim (NN);
00076     dNdR .change_dim (NDim,NN);
00077     FN   .change_dim (NFN);
00078     FdNdR.change_dim (NDim-1,NFN);
00079 }
00080 
00081 
00083 
00084 
00085 SDPair GEOM;
00086 
00087 typedef GeomElem * (*GeomElemMakerPtr)(int NDim);
00088 
00089 typedef std::map<String, GeomElemMakerPtr> GeomElemFactory_t;
00090 
00091 GeomElemFactory_t GeomElemFactory;
00092 
00093 GeomElem * AllocGeomElem(String const & Name, int NDim)
00094 {
00095     GeomElemFactory_t::iterator it = GeomElemFactory.find(Name);
00096     if (it==GeomElemFactory.end()) throw new Fatal("AllocGeomElem: '%s' is not available", Name.CStr());
00097 
00098     GeomElem * ptr = (*it->second)(NDim);
00099 
00100     return ptr;
00101 }
00102 
00103 }; // namespace FEM
00104 
00105 #ifdef USE_BOOST_PYTHON
00106 double PyGEOM (BPy::str const & Key) { return FEM::GEOM(BPy::extract<char const *>(Key)()); }
00107 #endif
00108 
00109 #endif // MECHSYS_FEM_GEOMELEM
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines