![]() |
MechSys
1.0
Computing library for simulations in continuum and discrete mechanics
|
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_TRI3_H 00021 #define MECHSYS_FEM_TRI3_H 00022 00023 // MechSys 00024 #include <mechsys/fem/node.h> 00025 #include <mechsys/fem/geomelem.h> 00026 00027 namespace FEM 00028 { 00029 00030 class Tri3: public GeomElem 00031 { 00032 public: 00033 // Auxiliar structure to map local face IDs to local node IDs 00034 static const int Face2Node[3][2]; // 3 edges, 2 nodes/edge 00035 00036 // Constructor 00037 Tri3 (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 Faces 00052 00053 y 2 00054 | @ @ 00055 +--x / \ / \ 00056 / \ / \ 00057 / \ 2 / \ 1 00058 / \ / \ 00059 / \ / \ 00060 @-----------@ @-----------@ 00061 0 1 0 00062 */ 00063 const int Tri3::Face2Node[3][2] = {{ 0, 1 }, 00064 { 1, 2 }, 00065 { 2, 0 }}; // order of nodes is important 00066 00067 00069 00070 00071 inline Tri3::Tri3 (int NDim) 00072 : GeomElem(NDim, /*NN*/3, /*NFN*/2, "Tri3") 00073 { 00074 SetIPs (3); 00075 } 00076 00077 inline void Tri3::SetIPs (int TotNIP) 00078 { 00079 if (TotNIP== 1) IPs = TRI_IP1; 00080 else if (TotNIP== 3) IPs = TRI_IP3; 00081 else if (TotNIP== 4) IPs = TRI_IP4; 00082 else if (TotNIP== 6) IPs = TRI_IP6; 00083 else if (TotNIP== 7) IPs = TRI_IP7; 00084 else if (TotNIP==13) IPs = TRI_IP13; 00085 else throw new Fatal("Tri3::SetIPs: Total number of integration points = %d is invalid",TotNIP); 00086 00087 NIP = TotNIP; 00088 FIPs = LIN_IP2; 00089 NFIP = 2; 00090 } 00091 00092 inline void Tri3::Shape (double r, double s, double t) const 00093 { 00094 00095 /* s 00096 * ^ 00097 * | 00098 * 2 00099 * @,(0,1) 00100 * | ', 00101 * | ', 00102 * | ', 00103 * | ', 00104 * | ', 00105 * | ', 00106 * | ', 00107 * | ', 00108 * |(0,0) ', (1,0) 00109 * @-------------------@ --> r 00110 * 0 1 00111 */ 00112 N(0) = 1.0-r-s; 00113 N(1) = r; 00114 N(2) = s; 00115 } 00116 00117 inline void Tri3::Derivs (double r, double s, double t) const 00118 { 00119 /* _ _ T 00120 * | dNi | 00121 * dNdR = | --- | , where Rj = r, s 00122 * |_ dRj _| 00123 * 00124 * dNdR(j,i), j=>local coordinate and i=>shape function 00125 */ 00126 dNdR(0,0) = -1.0; dNdR(1,0) = -1.0; 00127 dNdR(0,1) = 1.0; dNdR(1,1) = 0.0; 00128 dNdR(0,2) = 0.0; dNdR(1,2) = 1.0; 00129 } 00130 00131 inline void Tri3::FaceShape (double r, double s) const 00132 { 00133 /* 00134 * 0 | 1 00135 * @-----------+-----------@-> r 00136 * -1 | +1 00137 */ 00138 FN(0) = 0.5*(1.0-r); 00139 FN(1) = 0.5*(1.0+r); 00140 } 00141 00142 inline void Tri3::FaceDerivs (double r, double s) const 00143 { 00144 /* _ _ T 00145 * | dNi | 00146 * FdNdR = | --- | , where Rj = r, s 00147 * |_ dRj _| 00148 * 00149 * FdNdR(j,i), j=>local coordinate and i=>shape function 00150 */ 00151 FdNdR(0,0) = -0.5; 00152 FdNdR(0,1) = 0.5; 00153 } 00154 00155 inline void Tri3::NatCoords (Mat_t & C) const 00156 { 00157 C.change_dim(3,3); 00158 C = 0.0, 0.0, 1.0, 00159 1.0, 0.0, 1.0, 00160 0.0, 1.0, 1.0; 00161 } 00162 00163 00165 00166 00167 // Allocate a new element 00168 GeomElem * Tri3Maker (int NDim) { return new Tri3(NDim); } 00169 00170 // Register element 00171 int Tri3Register () 00172 { 00173 GeomElemFactory["Tri3"] = Tri3Maker; 00174 GEOM.Set ("Tri3", (double)GEOM.Keys.Size()); 00175 return 0; 00176 } 00177 00178 // Call register 00179 int __Tri3_dummy_int = Tri3Register(); 00180 00181 }; // namespace FEM 00182 00183 #endif // MECHSYS_FEM_TRI3_H