embedded.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_FEM_EMBEDDED_H
00023 #define MECHSYS_FEM_EMBEDDED_H
00024 
00025 #ifndef REAL
00026 #define REAL double
00027 #endif
00028 
00029 #include "fem/ele/element.h"
00030 
00031 namespace FEM
00032 {
00033 
00034 class Embedded: public virtual Element
00035 {
00036 public:
00037     void Jacobian(LinAlg::Matrix<REAL> const & derivs, LinAlg::Matrix<REAL> & J) const;
00038     void Initialize(Array<Node*> Emb_connects, Element * Tresspassed)
00039     { 
00040         _n_emb_nodes  = _connects.size();
00041         assert(Emb_connects.size()==_n_emb_nodes);
00042         for (size_t i=0; i<_n_emb_nodes; i++) SetNode(i, Emb_connects[i]);
00043         _tresspassed  = Tresspassed;
00044         _n_nodes      = Tresspassed->nNodes();
00045         _connects     = Tresspassed->Connects();
00046         _emb_connects = Emb_connects;
00047     };
00048     int  nNodes()    const { return _tresspassed->nNodes(); }
00049     int  nEmbNodes() const { return _n_emb_nodes; }
00050 protected:
00051     Element      * _tresspassed;
00052     Array<Node*>   _emb_connects;
00053     size_t         _n_emb_nodes;
00054 }; // class Emb3Equilib
00055 
00056 
00058 
00059 
00060 inline void Embedded::Jacobian(LinAlg::Matrix<REAL> const & derivs, LinAlg::Matrix<REAL> & J) const // {{{
00061 {
00062     // Calculate a matrix with nodal coordinates
00063     LinAlg::Matrix<REAL> cmatrix; // size = _n_nodes x 3
00064     cmatrix.Resize(_n_emb_nodes,3);   // 3 => X,Y,Z (all nodes have X,Y and Z)
00065     
00066     // Loop along all nodes of this element
00067     for (size_t i=0; i<_n_emb_nodes; i++)
00068     {
00069         cmatrix(i,0) = _emb_connects[i]->X();
00070         cmatrix(i,1) = _emb_connects[i]->Y();
00071         cmatrix(i,2) = _emb_connects[i]->Z();
00072     }
00073 
00074     // Calculate the Jacobian
00075     J = derivs*cmatrix;
00076 } // }}}
00077 
00078 }; // namespace FEM
00079 
00080 #endif // MECHSYS_FEM_EMBEDDED_H
00081 
00082 // vim:fdm=marker

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