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