MBDyn-1.7.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
shapefnc.cc
Go to the documentation of this file.
1 /* $Header: /var/cvs/mbdyn/mbdyn/mbdyn-1.0/mbdyn/struct/shapefnc.cc,v 1.31 2017/01/12 14:46:43 masarati Exp $ */
2 /*
3  * MBDyn (C) is a multibody analysis code.
4  * http://www.mbdyn.org
5  *
6  * Copyright (C) 1996-2017
7  *
8  * Pierangelo Masarati <masarati@aero.polimi.it>
9  * Paolo Mantegazza <mantegazza@aero.polimi.it>
10  *
11  * Dipartimento di Ingegneria Aerospaziale - Politecnico di Milano
12  * via La Masa, 34 - 20156 Milano, Italy
13  * http://www.aero.polimi.it
14  *
15  * Changing this copyright notice is forbidden.
16  *
17  * This program is free software; you can redistribute it and/or modify
18  * it under the terms of the GNU General Public License as published by
19  * the Free Software Foundation (version 2 of the License).
20  *
21  *
22  * This program is distributed in the hope that it will be useful,
23  * but WITHOUT ANY WARRANTY; without even the implied warranty of
24  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25  * GNU General Public License for more details.
26  *
27  * You should have received a copy of the GNU General Public License
28  * along with this program; if not, write to the Free Software
29  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30  */
31 
32 #include "mbconfig.h" /* This goes first in every *.c,*.cc file */
33 
34 #include <limits>
35 #include <cfloat>
36 #include <limits>
37 
38 #include "matvec3.h"
39 #include "shapefnc.h"
40 
41 /* Funzioni di forma e loro derivate */
42 const doublereal dN2_1 = .5; /* ShapeFunc2N(0., 1, 0) */
43 const doublereal dN2_2 = .5; /* ShapeFunc3N(0., 2, 0) */
44 
45 const doublereal dN2P_1 = -.5; /* ShapeFunc2N(0., 1, 1) */
46 const doublereal dN2P_2 = .5; /* ShapeFunc2N(0., 2, 1) */
47 
48 const doublereal dN2PP_1 = 0.; /* ShapeFunc2N(0., 1, 2) */
49 const doublereal dN2PP_2 = 0.; /* ShapeFunc2N(0., 2, 2) */
50 
51 /* Per l'interpolazione piu' compatta */
52 const doublereal dN2[2] = {
53  dN2_1, dN2_2
54 };
55 
56 const doublereal dN2P[2] = {
57  dN2P_1, dN2P_2
58 };
59 
60 const doublereal dN2PP[2] = {
62 };
63 
64 /* Funzioni di interpolazione */
66 ShapeFunc2N(doublereal d, integer iNode, enum Order Ord)
67 {
68  ASSERT(iNode == 1 || iNode == 2);
69 
70  switch (Ord) {
71  case ORD_ALG:
72  switch (iNode) {
73  case 1:
74  return .5*(1.-d);
75 
76  case 2:
77  return .5*(1.+d);
78 
79  default:
81  }
82 
83  case ORD_D1:
84  switch (iNode) {
85  case 1:
86  return -.5;
87 
88  case 2:
89  return .5;
90 
91  default:
93  }
94 
95  case ORD_D2:
96  switch (iNode) {
97  case 1:
98  return 0.;
99 
100  case 2:
101  return 0.;
102 
103  default:
105  }
106  }
107 
108  /* Per evitare warnings */
109  return 0.;
110 }
111 
113 DxDcsi2N(doublereal d, const Vec3& X1, const Vec3& X2)
114 {
115  doublereal dN1p = ShapeFunc2N(d, 1, ORD_D1);
116  doublereal dN2p = ShapeFunc2N(d, 2, ORD_D1);
117  Vec3 DXDcsi(X1*dN1p+X2*dN2p);
118  doublereal dd = DXDcsi.Dot();
119 
120  if (dd > std::numeric_limits<doublereal>::epsilon()) {
121  return std::sqrt(dd);
122  }
123 
124  return 0.;
125 }
126 
127 /* Punto di valutazione */
128 const doublereal dS = 1./sqrt(3.);
129 
130 /* Funzioni di forma e loro derivate - punto I */
131 const doublereal dN1_I = (1.+sqrt(3.))/6.; /* ShapeFunc3N(-dS, 1) */
132 const doublereal dN2_I = 2./3.; /* ShapeFunc3N(-dS, 2) */
133 const doublereal dN3_I = (1.-sqrt(3.))/6.; /* ShapeFunc3N(-dS, 3) */
134 
135 const doublereal dN1P_I = -(2.*sqrt(3.)+3.)/6.; /* ShapeFunc3N(-dS, 1, 1) */
136 const doublereal dN2P_I = 2./sqrt(3.); /* ShapeFunc3N(-dS, 2, 1) */
137 const doublereal dN3P_I = -(2.*sqrt(3.)-3.)/6.; /* ShapeFunc3N(-dS, 3, 1) */
138 
139 const doublereal dN1PP_I = 1.; /* ShapeFunc3N(-dS, 1, 2) */
140 const doublereal dN2PP_I = -2.; /* ShapeFunc3N(-dS, 2, 2) */
141 const doublereal dN3PP_I = 1.; /* ShapeFunc3N(-dS, 3, 2) */
142 
143 /* Funzioni di forma e loro derivate - punto II */
147 
151 
155 
156 /* Per l'interpolazione piu' compatta */
157 const doublereal dN3[2][3] = {
158  { dN1_I, dN2_I, dN3_I },
159  { dN1II, dN2II, dN3II }
160 };
161 
162 const doublereal dN3P[2][3] = {
163  { dN1P_I, dN2P_I, dN3P_I },
164  { dN1PII, dN2PII, dN3PII }
165 };
166 
167 const doublereal dN3PP[2][3] = {
168  { dN1PP_I, dN2PP_I, dN3PP_I },
169  { dN1PPII, dN2PPII, dN3PPII }
170 };
171 
172 doublereal
173 ShapeFunc3N(doublereal d, integer iNode, enum Order Ord)
174 {
175  ASSERT(iNode == 1 || iNode == 2 || iNode == 3);
176 
177  switch (Ord) {
178  case ORD_ALG:
179  switch (iNode) {
180  case 1:
181  return .5*d*(d-1.);
182 
183  case 2:
184  return 1.-d*d;
185 
186  case 3:
187  return .5*d*(d+1.);
188 
189  default:
191  }
192 
193  case ORD_D1:
194  switch (iNode) {
195  case 1:
196  return d-.5;
197 
198  case 2:
199  return -2.*d;
200 
201  case 3:
202  return d+.5;
203 
204  default:
206  }
207  case ORD_D2:
208  switch (iNode) {
209  case 1:
210  return 1.;
211 
212  case 2:
213  return -2.;
214 
215  case 3:
216  return 1.;
217 
218  default:
220  }
221  }
222 
223  /* Per evitare warnings */
224  return 0.;
225 }
226 
228 DxDcsi3N(doublereal d, const Vec3& X1, const Vec3& X2, const Vec3& X3)
229 {
230  doublereal dN1p = ShapeFunc3N(d, 1, ORD_D1);
231  doublereal dN2p = ShapeFunc3N(d, 2, ORD_D1);
232  doublereal dN3p = ShapeFunc3N(d, 3, ORD_D1);
233  Vec3 DXDcsi(X1*dN1p+X2*dN2p+X3*dN3p);
234  doublereal dd = DXDcsi.Dot();
235 
236  if (dd > std::numeric_limits<doublereal>::epsilon()) {
237  return std::sqrt(dd);
238  }
239 
240  return 0.;
241 }
242 
const doublereal dN2PP[2]
Definition: shapefnc.cc:60
#define MBDYN_EXCEPT_ARGS
Definition: except.h:63
Definition: matvec3.h:98
const doublereal dN1PII
Definition: shapefnc.cc:148
doublereal DxDcsi2N(doublereal d, const Vec3 &X1, const Vec3 &X2)
Definition: shapefnc.cc:113
doublereal Dot(const Vec3 &v) const
Definition: matvec3.h:243
const doublereal dN3PP_I
Definition: shapefnc.cc:141
const doublereal dN3_I
Definition: shapefnc.cc:133
const doublereal dN2P_I
Definition: shapefnc.cc:136
doublereal ShapeFunc3N(doublereal d, integer iNode, enum Order Ord)
Definition: shapefnc.cc:173
const doublereal dN3P_I
Definition: shapefnc.cc:137
const doublereal dN2_1
Definition: shapefnc.cc:42
const doublereal dN1PP_I
Definition: shapefnc.cc:139
doublereal ShapeFunc2N(doublereal d, integer iNode, enum Order Ord)
Definition: shapefnc.cc:66
const doublereal dN2[2]
Definition: shapefnc.cc:52
const doublereal dS
Definition: shapefnc.cc:128
const doublereal dN3[2][3]
Definition: shapefnc.cc:157
const doublereal dN1II
Definition: shapefnc.cc:144
const doublereal dN1_I
Definition: shapefnc.cc:131
const doublereal dN2PP_1
Definition: shapefnc.cc:48
const doublereal dN2PPII
Definition: shapefnc.cc:153
#define ASSERT(expression)
Definition: colamd.c:977
const doublereal dN2P[2]
Definition: shapefnc.cc:56
Order
Definition: shapefnc.h:42
GradientExpression< UnaryExpr< FuncSqrt, Expr > > sqrt(const GradientExpression< Expr > &u)
Definition: gradient.h:2974
const doublereal dN2II
Definition: shapefnc.cc:145
const doublereal dN2_I
Definition: shapefnc.cc:132
const doublereal dN1P_I
Definition: shapefnc.cc:135
doublereal DxDcsi3N(doublereal d, const Vec3 &X1, const Vec3 &X2, const Vec3 &X3)
Definition: shapefnc.cc:228
const doublereal dN3PP[2][3]
Definition: shapefnc.cc:167
const doublereal dN1PPII
Definition: shapefnc.cc:152
const doublereal dN2PP_2
Definition: shapefnc.cc:49
const doublereal dN2P_2
Definition: shapefnc.cc:46
const doublereal dN2_2
Definition: shapefnc.cc:43
const doublereal dN2PP_I
Definition: shapefnc.cc:140
const doublereal dN3II
Definition: shapefnc.cc:146
double doublereal
Definition: colamd.c:52
const doublereal dN2PII
Definition: shapefnc.cc:149
long int integer
Definition: colamd.c:51
const doublereal dN2P_1
Definition: shapefnc.cc:45
const doublereal dN3P[2][3]
Definition: shapefnc.cc:162
const doublereal dN3PPII
Definition: shapefnc.cc:154
const doublereal dN3PII
Definition: shapefnc.cc:150