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

Last change on this file since 3935 was 3935, checked in by Mathieu Morlighem, 15 years ago

Added SpawnBeam method of Penta for Hutter

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