source: issm/trunk/src/c/objects/Inputs/PentaVertexInput.cpp@ 3938

Last change on this file since 3938 was 3938, checked in by Eric.Larour, 15 years ago

New results API

File size: 27.9 KB
RevLine 
[3683]1/*!\file PentaVertexInput.c
2 * \brief: implementation of the PentaVertexInput object
3 */
4
5#ifdef HAVE_CONFIG_H
6 #include "config.h"
7#else
8#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
9#endif
10
11#include "stdio.h"
12#include <string.h>
[3938]13#include "./InputLocal.h"
[3683]14#include "../objects.h"
15#include "../../EnumDefinitions/EnumDefinitions.h"
16#include "../../shared/shared.h"
17#include "../../DataSet/DataSet.h"
[3775]18#include "../../include/include.h"
[3683]19
20/*Object constructors and destructor*/
21/*FUNCTION PentaVertexInput::PentaVertexInput(){{{1*/
22PentaVertexInput::PentaVertexInput(){
23 return;
24}
25/*}}}*/
[3847]26/*FUNCTION PentaVertexInput::PentaVertexInput(int in_enum_type,double* values){{{1*/
[3683]27PentaVertexInput::PentaVertexInput(int in_enum_type,double* in_values){
28
29 enum_type=in_enum_type;
30 values[0]=in_values[0];
31 values[1]=in_values[1];
32 values[2]=in_values[2];
33 values[3]=in_values[3];
34 values[4]=in_values[4];
35 values[5]=in_values[5];
36}
37/*}}}*/
38/*FUNCTION PentaVertexInput::~PentaVertexInput(){{{1*/
39PentaVertexInput::~PentaVertexInput(){
40 return;
41}
42/*}}}*/
43
44/*Object management*/
45/*FUNCTION PentaVertexInput::copy{{{1*/
46Object* PentaVertexInput::copy() {
47
48 return new PentaVertexInput(this->enum_type,this->values);
49
50}
51/*}}}*/
52/*FUNCTION PentaVertexInput::DeepEcho{{{1*/
53void PentaVertexInput::DeepEcho(void){
54
55 printf("PentaVertexInput:\n");
[3847]56 printf(" enum: %i (%s)\n",this->enum_type,EnumAsString(this->enum_type));
57 printf(" values: [%g %g %g %g %g %g]\n",this->values[0],this->values[1],this->values[2],this->values[3],this->values[4],this->values[5]);
[3683]58}
59/*}}}*/
60/*FUNCTION PentaVertexInput::Demarshall{{{1*/
61void PentaVertexInput::Demarshall(char** pmarshalled_dataset){
62
63 char* marshalled_dataset=NULL;
64 int i;
65
66 /*recover marshalled_dataset: */
67 marshalled_dataset=*pmarshalled_dataset;
68
69 /*this time, no need to get enum type, the pointer directly points to the beginning of the
70 *object data (thanks to DataSet::Demarshall):*/
71 memcpy(&enum_type,marshalled_dataset,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
72 memcpy(&values,marshalled_dataset,sizeof(values));marshalled_dataset+=sizeof(values);
73
74 /*return: */
75 *pmarshalled_dataset=marshalled_dataset;
76 return;
77}
78/*}}}*/
79/*FUNCTION PentaVertexInput::Echo {{{1*/
80void PentaVertexInput::Echo(void){
81 this->DeepEcho();
82}
83/*}}}*/
84/*FUNCTION PentaVertexInput::Enum{{{1*/
85int PentaVertexInput::Enum(void){
86
87 return PentaVertexInputEnum;
88
89}
90/*}}}*/
91/*FUNCTION PentaVertexInput::EnumType{{{1*/
92int PentaVertexInput::EnumType(void){
93
94 return this->enum_type;
95
96}
97/*}}}*/
98/*FUNCTION PentaVertexInput::Id{{{1*/
99int PentaVertexInput::Id(void){ return -1; }
100/*}}}*/
101/*FUNCTION PentaVertexInput::Marshall{{{1*/
102void PentaVertexInput::Marshall(char** pmarshalled_dataset){
103
104 char* marshalled_dataset=NULL;
105 int enum_value=0;
106
107 /*recover marshalled_dataset: */
108 marshalled_dataset=*pmarshalled_dataset;
109
110 /*get enum value of PentaVertexInput: */
111 enum_value=PentaVertexInputEnum;
112
113 /*marshall enum: */
114 memcpy(marshalled_dataset,&enum_value,sizeof(enum_value));marshalled_dataset+=sizeof(enum_value);
115
116 /*marshall PentaVertexInput data: */
117 memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
118 memcpy(marshalled_dataset,&values,sizeof(values));marshalled_dataset+=sizeof(values);
119
120 *pmarshalled_dataset=marshalled_dataset;
121}
122/*}}}*/
123/*FUNCTION PentaVertexInput::MarshallSize{{{1*/
124int PentaVertexInput::MarshallSize(){
125
126 return sizeof(values)+
127 +sizeof(enum_type)+
128 +sizeof(int); //sizeof(int) for enum value
129}
130/*}}}*/
131/*FUNCTION PentaVertexInput::MyRank{{{1*/
132int PentaVertexInput::MyRank(void){
133 extern int my_rank;
134 return my_rank;
135}
136/*}}}*/
[3935]137/*FUNCTION PentaVertexInput::SpawnBeamInput{{{1*/
138Input* PentaVertexInput::SpawnBeamInput(int* indices){
139
140 /*output*/
141 BeamVertexInput* outinput=NULL;
142 double newvalues[2];
143
144 /*Loop over the new indices*/
145 for(int i=0;i<2;i++){
146
147 /*Check index value*/
148 ISSMASSERT(indices[i]>=0 && indices[i]<6);
149
150 /*Assign value to new input*/
151 newvalues[i]=this->values[indices[i]];
152 }
153
154 /*Create new Beam input*/
155 outinput=new BeamVertexInput(this->enum_type,&newvalues[0]);
156
157 /*Assign output*/
158 return outinput;
159
160}
161/*}}}*/
[3847]162/*FUNCTION PentaVertexInput::SpawnTriaInput{{{1*/
163Input* PentaVertexInput::SpawnTriaInput(int* indices){
[3683]164
[3847]165 /*output*/
166 TriaVertexInput* outinput=NULL;
167 double newvalues[3];
168
169 /*Loop over the new indices*/
170 for(int i=0;i<3;i++){
171
172 /*Check index value*/
173 ISSMASSERT(indices[i]>=0 && indices[i]<6);
174
175 /*Assign value to new input*/
176 newvalues[i]=this->values[indices[i]];
177 }
178
179 /*Create new Tria input*/
180 outinput=new TriaVertexInput(this->enum_type,&newvalues[0]);
181
182 /*Assign output*/
183 return outinput;
184
185}
186/*}}}*/
187
[3683]188/*Object functions*/
189/*FUNCTION PentaVertexInput::GetParameterValue(bool* pvalue) {{{1*/
190void PentaVertexInput::GetParameterValue(bool* pvalue){ISSMERROR(" not supported yet!");}
191/*}}}*/
192/*FUNCTION PentaVertexInput::GetParameterValue(int* pvalue){{{1*/
193void PentaVertexInput::GetParameterValue(int* pvalue){ISSMERROR(" not supported yet!");}
194/*}}}*/
195/*FUNCTION PentaVertexInput::GetParameterValue(double* pvalue){{{1*/
196void PentaVertexInput::GetParameterValue(double* pvalue){ISSMERROR(" not supported yet!");}
197/*}}}*/
198/*FUNCTION PentaVertexInput::GetParameterValue(double* pvalue,Node* node){{{1*/
199void PentaVertexInput::GetParameterValue(double* pvalue,Node* node){ISSMERROR(" not supported yet!");}
200/*}}}*/
201/*FUNCTION PentaVertexInput::GetParameterValue(double* pvalue,Node* node1,Node* node2,double gauss_coord){{{1*/
202void PentaVertexInput::GetParameterValue(double* pvalue,Node* node1,Node* node2,double gauss_coord){ISSMERROR(" not supported yet!");}
203/*}}}*/
204/*FUNCTION PentaVertexInput::GetParameterValue(double* pvalue,double* gauss){{{1*/
[3840]205void PentaVertexInput::GetParameterValue(double* pvalue,double* gauss){
206 /*P1 interpolation on Gauss point*/
207
208 /*intermediary*/
209 double l1l6[6];
210
211 /*nodal functions: */
212 GetNodalFunctionsP1(&l1l6[0],gauss);
213
214 /*Assign output pointers:*/
215 *pvalue=l1l6[0]*values[0]+l1l6[1]*values[1]+l1l6[2]*values[2]+l1l6[3]*values[3]+l1l6[4]*values[4]+l1l6[5]*values[5];
216
217}
[3683]218/*}}}*/
219/*FUNCTION PentaVertexInput::GetParameterValue(double* pvalue,double* gauss,double defaultvalue){{{1*/
220void PentaVertexInput::GetParameterValue(double* pvalue,double* gauss,double defaultvalue){ISSMERROR(" not supported yet!");}
221/*}}}*/
222/*FUNCTION PentaVertexInput::GetParameterValues(double* values,double* gauss_pointers, int numgauss){{{1*/
[3840]223void PentaVertexInput::GetParameterValues(double* values,double* gauss_pointers, int numgauss){
224 /*It is assumed that output values has been correctly allocated*/
225
226 int i,j;
227 double gauss[4];
228
229 for (i=0;i<numgauss;i++){
230
231 /*Get current Gauss point coordinates*/
232 for (j=0;j<4;j++) gauss[j]=gauss_pointers[i*4+j];
233
234 /*Assign parameter value*/
235 GetParameterValue(&values[i],&gauss[0]);
236 }
237}
[3683]238/*}}}*/
239/*FUNCTION PentaVertexInput::GetParameterDerivativeValue(double* derivativevalues, double* xyz_list, double* gauss){{{1*/
[3840]240void PentaVertexInput::GetParameterDerivativeValue(double* p, double* xyz_list, double* gauss){
241 /*From grid values of parameter p (p_list[0], p_list[1], p_list[2], p_list[3], p_list[4] and p_list[4]), return parameter derivative value at gaussian point specified by gauss_coord:
242 * dp/dx=p_list[0]*dh1/dx+p_list[1]*dh2/dx+p_list[2]*dh3/dx+p_list[3]*dh4/dx+p_list[4]*dh5/dx+p_list[5]*dh6/dx;
243 * dp/dy=p_list[0]*dh1/dy+p_list[1]*dh2/dy+p_list[2]*dh3/dy+p_list[3]*dh4/dy+p_list[4]*dh5/dy+p_list[5]*dh6/dy;
244 * dp/dz=p_list[0]*dh1/dz+p_list[1]*dh2/dz+p_list[2]*dh3/dz+p_list[3]*dh4/dz+p_list[4]*dh5/dz+p_list[5]*dh6/dz;
245 *
246 * p is a vector of size 3x1 already allocated.
247 */
248
249 const int NDOF3=3;
250 const int numgrids=6;
251 double dh1dh6[NDOF3][numgrids];
252
253 /*Get nodal funnctions derivatives in actual coordinate system: */
254 GetNodalFunctionsP1Derivatives(&dh1dh6[0][0],xyz_list, gauss);
255
256 p[0]=this->values[0]*dh1dh6[0][0]+this->values[1]*dh1dh6[0][1]+this->values[2]*dh1dh6[0][2]+this->values[3]*dh1dh6[0][3]+this->values[4]*dh1dh6[0][4]+this->values[5]*dh1dh6[0][5];
257 p[1]=this->values[0]*dh1dh6[1][0]+this->values[1]*dh1dh6[1][1]+this->values[2]*dh1dh6[1][2]+this->values[3]*dh1dh6[1][3]+this->values[4]*dh1dh6[1][4]+this->values[5]*dh1dh6[1][5];
258 p[2]=this->values[0]*dh1dh6[2][0]+this->values[1]*dh1dh6[2][1]+this->values[2]*dh1dh6[2][2]+this->values[3]*dh1dh6[2][3]+this->values[4]*dh1dh6[2][4]+this->values[5]*dh1dh6[2][5];
259
260}
[3683]261/*}}}*/
[3855]262/*FUNCTION PentaVertexInput::GetVxStrainRate3d(double* epsilonvx,double* xyz_list, double* gauss) {{{1*/
263void PentaVertexInput::GetVxStrainRate3d(double* epsilonvx,double* xyz_list, double* gauss){
[3840]264 int i,j;
265
266 const int numgrids=6;
267 const int DOFVELOCITY=3;
268 double B[8][27];
269 double B_reduced[6][DOFVELOCITY*numgrids];
[3875]270 double velocity[numgrids][DOFVELOCITY];
[3840]271
272 /*Get B matrix: */
273 GetBStokes(&B[0][0], xyz_list, gauss);
274 /*Create a reduced matrix of B to get rid of pressure */
275 for (i=0;i<6;i++){
276 for (j=0;j<3;j++){
277 B_reduced[i][j]=B[i][j];
278 }
279 for (j=4;j<7;j++){
280 B_reduced[i][j-1]=B[i][j];
281 }
282 for (j=8;j<11;j++){
283 B_reduced[i][j-2]=B[i][j];
284 }
285 for (j=12;j<15;j++){
286 B_reduced[i][j-3]=B[i][j];
287 }
288 for (j=16;j<19;j++){
289 B_reduced[i][j-4]=B[i][j];
290 }
291 for (j=20;j<23;j++){
292 B_reduced[i][j-5]=B[i][j];
293 }
294 }
295
296 /*Here, we are computing the strain rate of (vx,0,0)*/
297 for(i=0;i<numgrids;i++){
298 velocity[i][0]=this->values[i];
299 velocity[i][1]=0.0;
300 velocity[i][2]=0.0;
301 }
302 /*Multiply B by velocity, to get strain rate: */
303 MatrixMultiply(&B_reduced[0][0],6,DOFVELOCITY*numgrids,0,&velocity[0][0],DOFVELOCITY*numgrids,1,0,epsilonvx,0);
304
305}
306/*}}}*/
[3855]307/*FUNCTION PentaVertexInput::GetVyStrainRate3d(double* epsilonvy,double* xyz_list, double* gauss) {{{1*/
308void PentaVertexInput::GetVyStrainRate3d(double* epsilonvy,double* xyz_list, double* gauss){
[3840]309 int i,j;
310
311 const int numgrids=6;
312 const int DOFVELOCITY=3;
313 double B[8][27];
314 double B_reduced[6][DOFVELOCITY*numgrids];
[3875]315 double velocity[numgrids][DOFVELOCITY];
[3840]316
317 /*Get B matrix: */
318 GetBStokes(&B[0][0], xyz_list, gauss);
319 /*Create a reduced matrix of B to get rid of pressure */
320 for (i=0;i<6;i++){
321 for (j=0;j<3;j++){
322 B_reduced[i][j]=B[i][j];
323 }
324 for (j=4;j<7;j++){
325 B_reduced[i][j-1]=B[i][j];
326 }
327 for (j=8;j<11;j++){
328 B_reduced[i][j-2]=B[i][j];
329 }
330 for (j=12;j<15;j++){
331 B_reduced[i][j-3]=B[i][j];
332 }
333 for (j=16;j<19;j++){
334 B_reduced[i][j-4]=B[i][j];
335 }
336 for (j=20;j<23;j++){
337 B_reduced[i][j-5]=B[i][j];
338 }
339 }
340
341 /*Here, we are computing the strain rate of (0,vy,0)*/
342 for(i=0;i<numgrids;i++){
343 velocity[i][0]=0.0;
344 velocity[i][1]=this->values[i];
345 velocity[i][2]=0.0;
346 }
347 /*Multiply B by velocity, to get strain rate: */
348 MatrixMultiply(&B_reduced[0][0],6,DOFVELOCITY*numgrids,0,&velocity[0][0],DOFVELOCITY*numgrids,1,0,epsilonvy,0);
349
350}
351/*}}}*/
[3855]352/*FUNCTION PentaVertexInput::GetVzStrainRate3d(double* epsilonvz,double* xyz_list, double* gauss) {{{1*/
353void PentaVertexInput::GetVzStrainRate3d(double* epsilonvz,double* xyz_list, double* gauss){
[3840]354 int i,j;
355
356 const int numgrids=6;
357 const int DOFVELOCITY=3;
358 double B[8][27];
359 double B_reduced[6][DOFVELOCITY*numgrids];
[3875]360 double velocity[numgrids][DOFVELOCITY];
[3840]361
362 /*Get B matrix: */
363 GetBStokes(&B[0][0], xyz_list, gauss);
364 /*Create a reduced matrix of B to get rid of pressure */
365 for (i=0;i<6;i++){
366 for (j=0;j<3;j++){
367 B_reduced[i][j]=B[i][j];
368 }
369 for (j=4;j<7;j++){
370 B_reduced[i][j-1]=B[i][j];
371 }
372 for (j=8;j<11;j++){
373 B_reduced[i][j-2]=B[i][j];
374 }
375 for (j=12;j<15;j++){
376 B_reduced[i][j-3]=B[i][j];
377 }
378 for (j=16;j<19;j++){
379 B_reduced[i][j-4]=B[i][j];
380 }
381 for (j=20;j<23;j++){
382 B_reduced[i][j-5]=B[i][j];
383 }
384 }
385
386 /*Here, we are computing the strain rate of (0,0,vz)*/
387 for(i=0;i<numgrids;i++){
388 velocity[i][0]=0.0;
389 velocity[i][1]=0.0;
390 velocity[i][2]=this->values[i];
391 }
392
393 /*Multiply B by velocity, to get strain rate: */
394 MatrixMultiply(&B_reduced[0][0],6,DOFVELOCITY*numgrids,0,&velocity[0][0],DOFVELOCITY*numgrids,1,0,epsilonvz,0);
395
396}
397/*}}}*/
[3855]398/*FUNCTION PentaVertexInput::GetVxStrainRate3dPattyn(double* epsilonvx,double* xyz_list, double* gauss) {{{1*/
399void PentaVertexInput::GetVxStrainRate3dPattyn(double* epsilonvx,double* xyz_list, double* gauss){
[3840]400
[3855]401 int i;
402 const int numgrids=6;
403 const int NDOF2=2;
404 double B[5][NDOF2*numgrids];
405 double velocity[numgrids][NDOF2];
406
407 /*Get B matrix: */
408 GetBPattyn(&B[0][0], xyz_list, gauss);
409
410 /*Here, we are computing the strain rate of (vx,0)*/
411 for(i=0;i<numgrids;i++){
412 velocity[i][0]=this->values[i];
413 velocity[i][1]=0.0;
[3840]414 }
415
[3855]416 /*Multiply B by velocity, to get strain rate: */
417 MatrixMultiply( &B[0][0],5,NDOF2*numgrids,0,
418 &velocity[0][0],NDOF2*numgrids,1,0,
419 epsilonvx,0);
420
[3840]421}
422/*}}}*/
[3855]423/*FUNCTION PentaVertexInput::GetVyStrainRate3dPattyn(double* epsilonvy,double* xyz_list, double* gauss) {{{1*/
424void PentaVertexInput::GetVyStrainRate3dPattyn(double* epsilonvy,double* xyz_list, double* gauss){
425
426 int i;
427 const int numgrids=6;
428 const int NDOF2=2;
429 double B[5][NDOF2*numgrids];
430 double velocity[numgrids][NDOF2];
431
432 /*Get B matrix: */
433 GetBPattyn(&B[0][0], xyz_list, gauss);
434
435 /*Here, we are computing the strain rate of (0,vy)*/
436 for(i=0;i<numgrids;i++){
437 velocity[i][0]=0.0;
438 velocity[i][1]=this->values[i];
439 }
440
441 /*Multiply B by velocity, to get strain rate: */
442 MatrixMultiply( &B[0][0],5,NDOF2*numgrids,0,
443 &velocity[0][0],NDOF2*numgrids,1,0,
444 epsilonvy,0);
445
446}
447/*}}}*/
[3732]448/*FUNCTION PentaVertexInput::ChangeEnum(int newenumtype){{{1*/
449void PentaVertexInput::ChangeEnum(int newenumtype){
450 this->enum_type=newenumtype;
451}
452/*}}}*/
[3830]453/*FUNCTION PentaVertexInput::GetParameterAverage(double* pvalue){{{1*/
454void PentaVertexInput::GetParameterAverage(double* pvalue){
455 *pvalue=1./6.*(values[0]+values[1]+values[2]+values[3]+values[4]+values[5]);
456}
457/*}}}*/
[3840]458
459/*Intermediary*/
460/*FUNCTION PentaVertexInput::GetNodalFunctionsP1 {{{1*/
461void PentaVertexInput::GetNodalFunctionsP1(double* l1l6, double* gauss_coord){
462
463 /*This routine returns the values of the nodal functions at the gaussian point.*/
464
465 l1l6[0]=gauss_coord[0]*(1-gauss_coord[3])/2.0;
466
467 l1l6[1]=gauss_coord[1]*(1-gauss_coord[3])/2.0;
468
469 l1l6[2]=gauss_coord[2]*(1-gauss_coord[3])/2.0;
470
471 l1l6[3]=gauss_coord[0]*(1+gauss_coord[3])/2.0;
472
473 l1l6[4]=gauss_coord[1]*(1+gauss_coord[3])/2.0;
474
475 l1l6[5]=gauss_coord[2]*(1+gauss_coord[3])/2.0;
476
477}
478/*}}}*/
479/*FUNCTION PentaVertexInput::GetNodalFunctionsMINI{{{1*/
480void PentaVertexInput::GetNodalFunctionsMINI(double* l1l7, double* gauss_coord){
481
482 /*This routine returns the values of the nodal functions at the gaussian point.*/
483
484 /*First nodal function: */
485 l1l7[0]=gauss_coord[0]*(1.0-gauss_coord[3])/2.0;
486
487 /*Second nodal function: */
488 l1l7[1]=gauss_coord[1]*(1.0-gauss_coord[3])/2.0;
489
490 /*Third nodal function: */
491 l1l7[2]=gauss_coord[2]*(1.0-gauss_coord[3])/2.0;
492
493 /*Fourth nodal function: */
494 l1l7[3]=gauss_coord[0]*(1.0+gauss_coord[3])/2.0;
495
496 /*Fifth nodal function: */
497 l1l7[4]=gauss_coord[1]*(1.0+gauss_coord[3])/2.0;
498
499 /*Sixth nodal function: */
500 l1l7[5]=gauss_coord[2]*(1.0+gauss_coord[3])/2.0;
501
502 /*Seventh nodal function: */
503 l1l7[6]=27*gauss_coord[0]*gauss_coord[1]*gauss_coord[2]*(1.0+gauss_coord[3])*(1.0-gauss_coord[3]);
504
505}
506/*}}}*/
507/*FUNCTION PentaVertexInput::GetNodalFunctionsP1Derivatives {{{1*/
508void PentaVertexInput::GetNodalFunctionsP1Derivatives(double* dh1dh6,double* xyz_list, double* gauss_coord){
509
510 /*This routine returns the values of the nodal functions derivatives (with respect to the actual coordinate system: */
511 int i;
512 const int NDOF3=3;
513 const int numgrids=6;
514
515 double dh1dh6_ref[NDOF3][numgrids];
516 double Jinv[NDOF3][NDOF3];
517
518 /*Get derivative values with respect to parametric coordinate system: */
519 GetNodalFunctionsP1DerivativesReference(&dh1dh6_ref[0][0], gauss_coord);
520
521 /*Get Jacobian invert: */
522 GetJacobianInvert(&Jinv[0][0], xyz_list, gauss_coord);
523
524 /*Build dh1dh3:
525 *
526 * [dhi/dx]= Jinv*[dhi/dr]
527 * [dhi/dy] [dhi/ds]
528 * [dhi/dz] [dhi/dn]
529 */
530
531 for (i=0;i<numgrids;i++){
532 *(dh1dh6+numgrids*0+i)=Jinv[0][0]*dh1dh6_ref[0][i]+Jinv[0][1]*dh1dh6_ref[1][i]+Jinv[0][2]*dh1dh6_ref[2][i];
533 *(dh1dh6+numgrids*1+i)=Jinv[1][0]*dh1dh6_ref[0][i]+Jinv[1][1]*dh1dh6_ref[1][i]+Jinv[1][2]*dh1dh6_ref[2][i];
534 *(dh1dh6+numgrids*2+i)=Jinv[2][0]*dh1dh6_ref[0][i]+Jinv[2][1]*dh1dh6_ref[1][i]+Jinv[2][2]*dh1dh6_ref[2][i];
535 }
536
537}
538/*}}}*/
539/*FUNCTION PentaVertexInput::GetNodalFunctionsMINIDerivatives{{{1*/
540void PentaVertexInput::GetNodalFunctionsMINIDerivatives(double* dh1dh7,double* xyz_list, double* gauss_coord){
541
542 /*This routine returns the values of the nodal functions derivatives (with respect to the
543 * actual coordinate system: */
544
545 int i;
546
547 const int numgrids=7;
548 double dh1dh7_ref[3][numgrids];
549 double Jinv[3][3];
550
551
552 /*Get derivative values with respect to parametric coordinate system: */
553 GetNodalFunctionsMINIDerivativesReference(&dh1dh7_ref[0][0], gauss_coord);
554
555 /*Get Jacobian invert: */
556 GetJacobianInvert(&Jinv[0][0], xyz_list, gauss_coord);
557
558 /*Build dh1dh6:
559 *
560 * [dhi/dx]= Jinv'*[dhi/dr]
561 * [dhi/dy] [dhi/ds]
562 * [dhi/dz] [dhi/dzeta]
563 */
564
565 for (i=0;i<numgrids;i++){
566 *(dh1dh7+numgrids*0+i)=Jinv[0][0]*dh1dh7_ref[0][i]+Jinv[0][1]*dh1dh7_ref[1][i]+Jinv[0][2]*dh1dh7_ref[2][i];
567 *(dh1dh7+numgrids*1+i)=Jinv[1][0]*dh1dh7_ref[0][i]+Jinv[1][1]*dh1dh7_ref[1][i]+Jinv[1][2]*dh1dh7_ref[2][i];
568 *(dh1dh7+numgrids*2+i)=Jinv[2][0]*dh1dh7_ref[0][i]+Jinv[2][1]*dh1dh7_ref[1][i]+Jinv[2][2]*dh1dh7_ref[2][i];
569 }
570
571}
572/*}}}*/
573/*FUNCTION PentaVertexInput::GetNodalFunctionsP1DerivativesReference {{{1*/
574void PentaVertexInput::GetNodalFunctionsP1DerivativesReference(double* dl1dl6,double* gauss_coord){
575
576 /*This routine returns the values of the nodal functions derivatives (with respect to the
577 * natural coordinate system) at the gaussian point. Those values vary along xi,eta,z */
578
579 const int numgrids=6;
580 double A1,A2,A3,z;
581
582 A1=gauss_coord[0]; //first area coordinate value. In term of xi and eta: A1=(1-xi)/2-eta/(2*SQRT3);
583 A2=gauss_coord[1]; //second area coordinate value In term of xi and eta: A2=(1+xi)/2-eta/(2*SQRT3);
584 A3=gauss_coord[2]; //third area coordinate value In term of xi and eta: A3=y/SQRT3;
585 z=gauss_coord[3]; //fourth vertical coordinate value. Corresponding nodal function: (1-z)/2 and (1+z)/2
586
587
588 /*First nodal function derivatives. The corresponding nodal function is N=A1*(1-z)/2. Its derivatives follow*/
589 *(dl1dl6+numgrids*0+0)=-0.5*(1.0-z)/2.0;
590 *(dl1dl6+numgrids*1+0)=-0.5/SQRT3*(1.0-z)/2.0;
591 *(dl1dl6+numgrids*2+0)=-0.5*A1;
592
593 /*Second nodal function: The corresponding nodal function is N=A2*(1-z)/2. Its derivatives follow*/
594 *(dl1dl6+numgrids*0+1)=0.5*(1.0-z)/2.0;
595 *(dl1dl6+numgrids*1+1)=-0.5/SQRT3*(1.0-z)/2.0;
596 *(dl1dl6+numgrids*2+1)=-0.5*A2;
597
598 /*Third nodal function: The corresponding nodal function is N=A3*(1-z)/2. Its derivatives follow*/
599 *(dl1dl6+numgrids*0+2)=0.0;
600 *(dl1dl6+numgrids*1+2)=1.0/SQRT3*(1.0-z)/2.0;
601 *(dl1dl6+numgrids*2+2)=-0.5*A3;
602
603 /*Fourth nodal function: The corresponding nodal function is N=A1*(1+z)/2. Its derivatives follow*/
604 *(dl1dl6+numgrids*0+3)=-0.5*(1.0+z)/2.0;
605 *(dl1dl6+numgrids*1+3)=-0.5/SQRT3*(1.0+z)/2.0;
606 *(dl1dl6+numgrids*2+3)=0.5*A1;
607
608 /*Fifth nodal function: The corresponding nodal function is N=A2*(1+z)/2. Its derivatives follow*/
609 *(dl1dl6+numgrids*0+4)=0.5*(1.0+z)/2.0;
610 *(dl1dl6+numgrids*1+4)=-0.5/SQRT3*(1.0+z)/2.0;
611 *(dl1dl6+numgrids*2+4)=0.5*A2;
612
613 /*Sixth nodal function: The corresponding nodal function is N=A3*(1+z)/2. Its derivatives follow*/
614 *(dl1dl6+numgrids*0+5)=0.0;
615 *(dl1dl6+numgrids*1+5)=1.0/SQRT3*(1.0+z)/2.0;
616 *(dl1dl6+numgrids*2+5)=0.5*A3;
617}
618/*}}}*/
619/*FUNCTION PentaVertexInput::GetNodalFunctionsMINIDerivativesReference{{{1*/
620void PentaVertexInput::GetNodalFunctionsMINIDerivativesReference(double* dl1dl7,double* gauss_coord){
621
622 /*This routine returns the values of the nodal functions derivatives (with respect to the
623 * natural coordinate system) at the gaussian point. */
624
625 int numgrids=7; //six plus bubble grids
626
627 double r=gauss_coord[1]-gauss_coord[0];
628 double s=-3.0/SQRT3*(gauss_coord[0]+gauss_coord[1]-2.0/3.0);
629 double zeta=gauss_coord[3];
630
631 /*First nodal function: */
632 *(dl1dl7+numgrids*0+0)=-0.5*(1.0-zeta)/2.0;
633 *(dl1dl7+numgrids*1+0)=-SQRT3/6.0*(1.0-zeta)/2.0;
634 *(dl1dl7+numgrids*2+0)=-0.5*(-0.5*r-SQRT3/6.0*s+ONETHIRD);
635
636 /*Second nodal function: */
637 *(dl1dl7+numgrids*0+1)=0.5*(1.0-zeta)/2.0;
638 *(dl1dl7+numgrids*1+1)=-SQRT3/6.0*(1.0-zeta)/2.0;
639 *(dl1dl7+numgrids*2+1)=-0.5*(0.5*r-SQRT3/6.0*s+ONETHIRD);
640
641 /*Third nodal function: */
642 *(dl1dl7+numgrids*0+2)=0;
643 *(dl1dl7+numgrids*1+2)=SQRT3/3.0*(1.0-zeta)/2.0;
644 *(dl1dl7+numgrids*2+2)=-0.5*(SQRT3/3.0*s+ONETHIRD);
645
646 /*Fourth nodal function: */
647 *(dl1dl7+numgrids*0+3)=-0.5*(1.0+zeta)/2.0;
648 *(dl1dl7+numgrids*1+3)=-SQRT3/6.0*(1.0+zeta)/2.0;
649 *(dl1dl7+numgrids*2+3)=0.5*(-0.5*r-SQRT3/6.0*s+ONETHIRD);
650
651 /*Fith nodal function: */
652 *(dl1dl7+numgrids*0+4)=0.5*(1.0+zeta)/2.0;
653 *(dl1dl7+numgrids*1+4)=-SQRT3/6.0*(1.0+zeta)/2.0;
654 *(dl1dl7+numgrids*2+4)=0.5*(0.5*r-SQRT3/6.0*s+ONETHIRD);
655
656 /*Sixth nodal function: */
657 *(dl1dl7+numgrids*0+5)=0;
658 *(dl1dl7+numgrids*1+5)=SQRT3/3.0*(1.0+zeta)/2.0;
659 *(dl1dl7+numgrids*2+5)=0.5*(SQRT3/3.0*s+ONETHIRD);
660
661 /*Seventh nodal function: */
662 *(dl1dl7+numgrids*0+6)=9.0/2.0*r*(1.0+zeta)*(zeta-1.0)*(SQRT3*s+1.0);
663 *(dl1dl7+numgrids*1+6)=9.0/4.0*(1+zeta)*(1-zeta)*(SQRT3*pow(s,2.0)-2.0*s-SQRT3*pow(r,2.0));
664 *(dl1dl7+numgrids*2+6)=27*gauss_coord[0]*gauss_coord[1]*gauss_coord[2]*(-2.0*zeta);
665
666}
667/*}}}*/
668/*FUNCTION PentaVertexInput::GetJacobian {{{1*/
669void PentaVertexInput::GetJacobian(double* J, double* xyz_list,double* gauss_coord){
670
671 const int NDOF3=3;
672 int i,j;
673
674 /*The Jacobian is constant over the element, discard the gaussian points.
675 * J is assumed to have been allocated of size NDOF2xNDOF2.*/
676
677 double A1,A2,A3; //area coordinates
678 double xi,eta,zi; //parametric coordinates
679
680 double x1,x2,x3,x4,x5,x6;
681 double y1,y2,y3,y4,y5,y6;
682 double z1,z2,z3,z4,z5,z6;
683
684 /*Figure out xi,eta and zi (parametric coordinates), for this gaussian point: */
685 A1=gauss_coord[0];
686 A2=gauss_coord[1];
687 A3=gauss_coord[2];
688
689 xi=A2-A1;
690 eta=SQRT3*A3;
691 zi=gauss_coord[3];
692
693 x1=*(xyz_list+3*0+0);
694 x2=*(xyz_list+3*1+0);
695 x3=*(xyz_list+3*2+0);
696 x4=*(xyz_list+3*3+0);
697 x5=*(xyz_list+3*4+0);
698 x6=*(xyz_list+3*5+0);
699
700 y1=*(xyz_list+3*0+1);
701 y2=*(xyz_list+3*1+1);
702 y3=*(xyz_list+3*2+1);
703 y4=*(xyz_list+3*3+1);
704 y5=*(xyz_list+3*4+1);
705 y6=*(xyz_list+3*5+1);
706
707 z1=*(xyz_list+3*0+2);
708 z2=*(xyz_list+3*1+2);
709 z3=*(xyz_list+3*2+2);
710 z4=*(xyz_list+3*3+2);
711 z5=*(xyz_list+3*4+2);
712 z6=*(xyz_list+3*5+2);
713
714 *(J+NDOF3*0+0)=0.25*(x1-x2-x4+x5)*zi+0.25*(-x1+x2-x4+x5);
715 *(J+NDOF3*1+0)=SQRT3/12.0*(x1+x2-2*x3-x4-x5+2*x6)*zi+SQRT3/12.0*(-x1-x2+2*x3-x4-x5+2*x6);
716 *(J+NDOF3*2+0)=SQRT3/12.0*(x1+x2-2*x3-x4-x5+2*x6)*eta+1/4*(x1-x2-x4+x5)*xi +0.25*(-x1+x5-x2+x4);
717
718 *(J+NDOF3*0+1)=0.25*(y1-y2-y4+y5)*zi+0.25*(-y1+y2-y4+y5);
719 *(J+NDOF3*1+1)=SQRT3/12.0*(y1+y2-2*y3-y4-y5+2*y6)*zi+SQRT3/12.0*(-y1-y2+2*y3-y4-y5+2*y6);
720 *(J+NDOF3*2+1)=SQRT3/12.0*(y1+y2-2*y3-y4-y5+2*y6)*eta+0.25*(y1-y2-y4+y5)*xi+0.25*(y4-y1+y5-y2);
721
722 *(J+NDOF3*0+2)=0.25*(z1-z2-z4+z5)*zi+0.25*(-z1+z2-z4+z5);
723 *(J+NDOF3*1+2)=SQRT3/12.0*(z1+z2-2*z3-z4-z5+2*z6)*zi+SQRT3/12.0*(-z1-z2+2*z3-z4-z5+2*z6);
724 *(J+NDOF3*2+2)=SQRT3/12.0*(z1+z2-2*z3-z4-z5+2*z6)*eta+0.25*(z1-z2-z4+z5)*xi+0.25*(-z1+z5-z2+z4);
725
726}
727/*}}}*/
728/*FUNCTION PentaVertexInput::GetJacobianInvert {{{1*/
729void PentaVertexInput::GetJacobianInvert(double* Jinv, double* xyz_list,double* gauss_coord){
730
731 double Jdet;
732 const int NDOF3=3;
733
734 /*Call Jacobian routine to get the jacobian:*/
735 GetJacobian(Jinv, xyz_list, gauss_coord);
736
737 /*Invert Jacobian matrix: */
738 MatrixInverse(Jinv,NDOF3,NDOF3,NULL,0,&Jdet);
739}
740/*}}}*/
741/*FUNCTION PentaVertexInput::GetBPattyn {{{1*/
742void PentaVertexInput::GetBPattyn(double* B, double* xyz_list, double* gauss_coord){
743 /*Compute B matrix. B=[B1 B2 B3 B4 B5 B6] where Bi is of size 5*NDOF2.
744 * For grid i, Bi can be expressed in the actual coordinate system
745 * by:
746 * Bi=[ dh/dx 0 ]
747 * [ 0 dh/dy ]
748 * [ 1/2*dh/dy 1/2*dh/dx ]
749 * [ 1/2*dh/dz 0 ]
750 * [ 0 1/2*dh/dz ]
751 * where h is the interpolation function for grid i.
752 *
753 * We assume B has been allocated already, of size: 5x(NDOF2*numgrids)
754 */
755
756 int i;
757 const int numgrids=6;
758 const int NDOF3=3;
759 const int NDOF2=2;
760
761 double dh1dh6[NDOF3][numgrids];
762
763 /*Get dh1dh6 in actual coordinate system: */
764 GetNodalFunctionsP1Derivatives(&dh1dh6[0][0],xyz_list, gauss_coord);
765
766 /*Build B: */
767 for (i=0;i<numgrids;i++){
768 *(B+NDOF2*numgrids*0+NDOF2*i)=dh1dh6[0][i];
769 *(B+NDOF2*numgrids*0+NDOF2*i+1)=0.0;
770
771 *(B+NDOF2*numgrids*1+NDOF2*i)=0.0;
772 *(B+NDOF2*numgrids*1+NDOF2*i+1)=dh1dh6[1][i];
773
774 *(B+NDOF2*numgrids*2+NDOF2*i)=(float).5*dh1dh6[1][i];
775 *(B+NDOF2*numgrids*2+NDOF2*i+1)=(float).5*dh1dh6[0][i];
776
777 *(B+NDOF2*numgrids*3+NDOF2*i)=(float).5*dh1dh6[2][i];
778 *(B+NDOF2*numgrids*3+NDOF2*i+1)=0.0;
779
780 *(B+NDOF2*numgrids*4+NDOF2*i)=0.0;
781 *(B+NDOF2*numgrids*4+NDOF2*i+1)=(float).5*dh1dh6[2][i];
782 }
783
784}
785/*}}}*/
786/*FUNCTION PentaVertexInput::GetBStokes {{{1*/
787void PentaVertexInput::GetBStokes(double* B, double* xyz_list, double* gauss_coord){
788
789 /*Compute B matrix. B=[B1 B2 B3 B4 B5 B6] where Bi is of size 3*DOFPERGRID.
790 * For grid i, Bi can be expressed in the actual coordinate system
791 * by: Bi=[ dh/dx 0 0 0 ]
792 * [ 0 dh/dy 0 0 ]
793 * [ 0 0 dh/dy 0 ]
794 * [ 1/2*dh/dy 1/2*dh/dx 0 0 ]
795 * [ 1/2*dh/dz 0 1/2*dh/dx 0 ]
796 * [ 0 1/2*dh/dz 1/2*dh/dy 0 ]
797 * [ 0 0 0 h ]
798 * [ dh/dx dh/dy dh/dz 0 ]
799 * where h is the interpolation function for grid i.
800 * Same thing for Bb except the last column that does not exist.
801 */
802
803 int i;
804 const int calculationdof=3;
805 const int numgrids=6;
806 int DOFPERGRID=4;
807
808 double dh1dh7[calculationdof][numgrids+1];
809 double l1l6[numgrids];
810
811
812 /*Get dh1dh7 in actual coordinate system: */
813 GetNodalFunctionsMINIDerivatives(&dh1dh7[0][0],xyz_list, gauss_coord);
814 GetNodalFunctionsP1(l1l6, gauss_coord);
815
816 /*Build B: */
817 for (i=0;i<numgrids+1;i++){
818 *(B+(DOFPERGRID*numgrids+3)*0+DOFPERGRID*i)=dh1dh7[0][i]; //B[0][DOFPERGRID*i]=dh1dh6[0][i];
819 *(B+(DOFPERGRID*numgrids+3)*0+DOFPERGRID*i+1)=0;
820 *(B+(DOFPERGRID*numgrids+3)*0+DOFPERGRID*i+2)=0;
821 *(B+(DOFPERGRID*numgrids+3)*1+DOFPERGRID*i)=0;
822 *(B+(DOFPERGRID*numgrids+3)*1+DOFPERGRID*i+1)=dh1dh7[1][i];
823 *(B+(DOFPERGRID*numgrids+3)*1+DOFPERGRID*i+2)=0;
824 *(B+(DOFPERGRID*numgrids+3)*2+DOFPERGRID*i)=0;
825 *(B+(DOFPERGRID*numgrids+3)*2+DOFPERGRID*i+1)=0;
826 *(B+(DOFPERGRID*numgrids+3)*2+DOFPERGRID*i+2)=dh1dh7[2][i];
827 *(B+(DOFPERGRID*numgrids+3)*3+DOFPERGRID*i)=(float).5*dh1dh7[1][i];
828 *(B+(DOFPERGRID*numgrids+3)*3+DOFPERGRID*i+1)=(float).5*dh1dh7[0][i];
829 *(B+(DOFPERGRID*numgrids+3)*3+DOFPERGRID*i+2)=0;
830 *(B+(DOFPERGRID*numgrids+3)*4+DOFPERGRID*i)=(float).5*dh1dh7[2][i];
831 *(B+(DOFPERGRID*numgrids+3)*4+DOFPERGRID*i+1)=0;
832 *(B+(DOFPERGRID*numgrids+3)*4+DOFPERGRID*i+2)=(float).5*dh1dh7[0][i];
833 *(B+(DOFPERGRID*numgrids+3)*5+DOFPERGRID*i)=0;
834 *(B+(DOFPERGRID*numgrids+3)*5+DOFPERGRID*i+1)=(float).5*dh1dh7[2][i];
835 *(B+(DOFPERGRID*numgrids+3)*5+DOFPERGRID*i+2)=(float).5*dh1dh7[1][i];
836 *(B+(DOFPERGRID*numgrids+3)*6+DOFPERGRID*i)=0;
837 *(B+(DOFPERGRID*numgrids+3)*6+DOFPERGRID*i+1)=0;
838 *(B+(DOFPERGRID*numgrids+3)*6+DOFPERGRID*i+2)=0;
839 *(B+(DOFPERGRID*numgrids+3)*7+DOFPERGRID*i)=dh1dh7[0][i];
840 *(B+(DOFPERGRID*numgrids+3)*7+DOFPERGRID*i+1)=dh1dh7[1][i];
841 *(B+(DOFPERGRID*numgrids+3)*7+DOFPERGRID*i+2)=dh1dh7[2][i];
842 }
843
844 for (i=0;i<numgrids;i++){ //last column not for the bubble function
845 *(B+(DOFPERGRID*numgrids+3)*0+DOFPERGRID*i+3)=0;
846 *(B+(DOFPERGRID*numgrids+3)*1+DOFPERGRID*i+3)=0;
847 *(B+(DOFPERGRID*numgrids+3)*2+DOFPERGRID*i+3)=0;
848 *(B+(DOFPERGRID*numgrids+3)*3+DOFPERGRID*i+3)=0;
849 *(B+(DOFPERGRID*numgrids+3)*4+DOFPERGRID*i+3)=0;
850 *(B+(DOFPERGRID*numgrids+3)*5+DOFPERGRID*i+3)=0;
851 *(B+(DOFPERGRID*numgrids+3)*6+DOFPERGRID*i+3)=l1l6[i];
852 *(B+(DOFPERGRID*numgrids+3)*7+DOFPERGRID*i+3)=0;
853 }
854
855}
856/*}}}*/
[3938]857/*FUNCTION PentaVertexInput::PatchSize(void);{{{1*/
858int PentaVertexInput::PatchSize(void){
859 return 6;
860}
861/*}}}*/
862/*FUNCTION PentaVertexInput::PatchFill(double* patches);{{{1*/
863void PentaVertexInput::PatchFill(double* patches,Parameters* parameters){
864
865 patches[0]=values[0];
866 patches[1]=values[1];
867 patches[2]=values[2];
868 patches[3]=values[3];
869 patches[4]=values[4];
870 patches[5]=values[5];
871
872 /*Now, post-processing: */
873 ProcessResults(patches,6,this->enum_type,parameters);
874
875}
876/*}}}*/
Note: See TracBrowser for help on using the repository browser.