MechSys  1.0
Computing library for simulations in continuum and discrete mechanics
/home/dorival/mechsys/lib/fem/elems/lin2.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_LIN2_H
00021 #define MECHSYS_FEM_LIN2_H
00022 
00023 // MechSys
00024 #include <mechsys/fem/node.h>
00025 #include <mechsys/fem/geomelem.h>
00026 
00027 namespace FEM
00028 {
00029 
00030 class Lin2: public GeomElem
00031 {
00032 public:
00033     // Auxiliary structure to map local face IDs to local node IDs
00034     static const int Face2Node[2][1]; // 2 extreme points, 1 point/extremity
00035 
00036     // Constructor
00037     Lin2 (int NDim);
00038 
00039     // Derived methods
00040     void   SetIPs     (int TotNIP);
00041     size_t FNode      (size_t IdxFace, size_t IdxFNode) const { return Face2Node[IdxFace][IdxFNode]; }
00042     void   Shape      (double r, double s, double t)    const;
00043     void   Derivs     (double r, double s, double t)    const;
00044     void   FaceShape  (double r, double s)              const {}
00045     void   FaceDerivs (double r, double s)              const {}
00046     void   NatCoords  (Mat_t & C)                       const;
00047 };
00048 
00049 
00050 /* Local IDs
00051              Nodes              Extremities
00052    y
00053    |
00054    +--x  @-----------@         @-----------@
00055         0             1        0           1
00056 */
00057 const int Lin2::Face2Node[2][1] = {{ 0 },
00058                                    { 1 }};
00059 
00060 
00062 
00063 
00064 inline Lin2::Lin2 (int NDim)
00065     : GeomElem(/*NDim*/1, /*NN*/2, /*NFN*/2, "Lin2")
00066 {
00067     SetIPs (3);
00068 }
00069 
00070 inline void Lin2::SetIPs (int TotNIP)
00071 {
00072          if (TotNIP== 2) IPs = LIN_IP2;
00073     else if (TotNIP== 3) IPs = LIN_IP3;
00074     else if (TotNIP== 4) IPs = LIN_IP4;
00075     else if (TotNIP== 5) IPs = LIN_IP5;
00076     else throw new Fatal("Lin2::SetIPs: Total number of integration points = %d is invalid",TotNIP);
00077 
00078     NIP  = TotNIP;
00079     FIPs = NULL;
00080     NFIP = 0;
00081 }
00082 
00083 inline void Lin2::Shape (double r, double s, double t) const
00084 {
00085 
00086     /*   @---------|---------@  --> r
00087      *  -1         0         1
00088      */
00089     N(0) = (1.0-r)/2.0;
00090     N(1) = (1.0+r)/2.0;
00091 }
00092 
00093 inline void Lin2::Derivs (double r, double s, double t) const
00094 {
00095     /*           _     _ T
00096      *          |  dNi  |
00097      *   dNdR = |  ---  |   , where Rj = r
00098      *          |_ dRj _|
00099      *  
00100      *   dNdR(j,i), j=>local coordinate and i=>shape function
00101      */
00102     dNdR(0,0) = -1.0/2.0;
00103     dNdR(0,1) =  1.0/2.0;
00104 }
00105 
00106 inline void Lin2::NatCoords (Mat_t & C) const
00107 {
00108     C.change_dim(2,3);
00109     C = -1.0, 0.0, 1.0,
00110          1.0, 0.0, 1.0;
00111 }
00112 
00113 
00115 
00116 
00117 // Allocate a new element
00118 GeomElem * Lin2Maker (int NDim) { return new Lin2(NDim); }
00119 
00120 // Register element
00121 int Lin2Register ()
00122 {
00123     GeomElemFactory["Lin2"] = Lin2Maker;
00124     GEOM.Set ("Lin2", (double)GEOM.Keys.Size());
00125     return 0;
00126 }
00127 
00128 // Call register
00129 int __Lin2_dummy_int  = Lin2Register();
00130 
00131 }; // namespace FEM
00132 
00133 #endif // MECHSYS_FEM_LIN2_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines