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 "../../Container/Container.h"
|
---|
17 | #include "../../include/include.h"
|
---|
18 |
|
---|
19 | /*PentaVertexInput constructors and destructor*/
|
---|
20 | /*FUNCTION PentaVertexInput::PentaVertexInput(){{{1*/
|
---|
21 | PentaVertexInput::PentaVertexInput(){
|
---|
22 | return;
|
---|
23 | }
|
---|
24 | /*}}}*/
|
---|
25 | /*FUNCTION PentaVertexInput::PentaVertexInput(int in_enum_type,double* values){{{1*/
|
---|
26 | PentaVertexInput::PentaVertexInput(int in_enum_type,double* in_values)
|
---|
27 | :PentaRef(1)
|
---|
28 | {
|
---|
29 |
|
---|
30 | /*Set PentaRef*/
|
---|
31 | this->SetElementType(P1Enum,0);
|
---|
32 | this->element_type=P1Enum;
|
---|
33 |
|
---|
34 | enum_type=in_enum_type;
|
---|
35 | values[0]=in_values[0];
|
---|
36 | values[1]=in_values[1];
|
---|
37 | values[2]=in_values[2];
|
---|
38 | values[3]=in_values[3];
|
---|
39 | values[4]=in_values[4];
|
---|
40 | values[5]=in_values[5];
|
---|
41 | }
|
---|
42 | /*}}}*/
|
---|
43 | /*FUNCTION PentaVertexInput::~PentaVertexInput(){{{1*/
|
---|
44 | PentaVertexInput::~PentaVertexInput(){
|
---|
45 | return;
|
---|
46 | }
|
---|
47 | /*}}}*/
|
---|
48 |
|
---|
49 | /*Object virtual functions definitions:*/
|
---|
50 | /*FUNCTION PentaVertexInput::Echo {{{1*/
|
---|
51 | void PentaVertexInput::Echo(void){
|
---|
52 | this->DeepEcho();
|
---|
53 | }
|
---|
54 | /*}}}*/
|
---|
55 | /*FUNCTION PentaVertexInput::DeepEcho{{{1*/
|
---|
56 | void PentaVertexInput::DeepEcho(void){
|
---|
57 |
|
---|
58 | printf("PentaVertexInput:\n");
|
---|
59 | printf(" enum: %i (%s)\n",this->enum_type,EnumAsString(this->enum_type));
|
---|
60 | 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]);
|
---|
61 | }
|
---|
62 | /*}}}*/
|
---|
63 | /*FUNCTION PentaVertexInput::Id{{{1*/
|
---|
64 | int PentaVertexInput::Id(void){ return -1; }
|
---|
65 | /*}}}*/
|
---|
66 | /*FUNCTION PentaVertexInput::MyRank{{{1*/
|
---|
67 | int PentaVertexInput::MyRank(void){
|
---|
68 | extern int my_rank;
|
---|
69 | return my_rank;
|
---|
70 | }
|
---|
71 | /*}}}*/
|
---|
72 | /*FUNCTION PentaVertexInput::Marshall{{{1*/
|
---|
73 | void PentaVertexInput::Marshall(char** pmarshalled_dataset){
|
---|
74 |
|
---|
75 | char* marshalled_dataset=NULL;
|
---|
76 | int enum_value=0;
|
---|
77 |
|
---|
78 | /*recover marshalled_dataset: */
|
---|
79 | marshalled_dataset=*pmarshalled_dataset;
|
---|
80 |
|
---|
81 | /*get enum value of PentaVertexInput: */
|
---|
82 | enum_value=PentaVertexInputEnum;
|
---|
83 |
|
---|
84 | /*marshall enum: */
|
---|
85 | memcpy(marshalled_dataset,&enum_value,sizeof(enum_value));marshalled_dataset+=sizeof(enum_value);
|
---|
86 |
|
---|
87 | /*marshall PentaVertexInput data: */
|
---|
88 | memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
|
---|
89 | memcpy(marshalled_dataset,&values,sizeof(values));marshalled_dataset+=sizeof(values);
|
---|
90 |
|
---|
91 | *pmarshalled_dataset=marshalled_dataset;
|
---|
92 | }
|
---|
93 | /*}}}*/
|
---|
94 | /*FUNCTION PentaVertexInput::MarshallSize{{{1*/
|
---|
95 | int PentaVertexInput::MarshallSize(){
|
---|
96 |
|
---|
97 | return sizeof(values)+
|
---|
98 | +sizeof(enum_type)+
|
---|
99 | +sizeof(int); //sizeof(int) for enum value
|
---|
100 | }
|
---|
101 | /*}}}*/
|
---|
102 | /*FUNCTION PentaVertexInput::Demarshall{{{1*/
|
---|
103 | void PentaVertexInput::Demarshall(char** pmarshalled_dataset){
|
---|
104 |
|
---|
105 | char* marshalled_dataset=NULL;
|
---|
106 | int i;
|
---|
107 |
|
---|
108 | /*recover marshalled_dataset: */
|
---|
109 | marshalled_dataset=*pmarshalled_dataset;
|
---|
110 |
|
---|
111 | /*this time, no need to get enum type, the pointer directly points to the beginning of the
|
---|
112 | *object data (thanks to DataSet::Demarshall):*/
|
---|
113 | memcpy(&enum_type,marshalled_dataset,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
|
---|
114 | memcpy(&values,marshalled_dataset,sizeof(values));marshalled_dataset+=sizeof(values);
|
---|
115 |
|
---|
116 | /*return: */
|
---|
117 | *pmarshalled_dataset=marshalled_dataset;
|
---|
118 | return;
|
---|
119 | }
|
---|
120 | /*}}}*/
|
---|
121 | /*FUNCTION PentaVertexInput::Enum{{{1*/
|
---|
122 | int PentaVertexInput::Enum(void){
|
---|
123 |
|
---|
124 | return PentaVertexInputEnum;
|
---|
125 |
|
---|
126 | }
|
---|
127 | /*}}}*/
|
---|
128 |
|
---|
129 | /*PentaVertexInput management*/
|
---|
130 | /*FUNCTION PentaVertexInput::copy{{{1*/
|
---|
131 | Object* PentaVertexInput::copy() {
|
---|
132 |
|
---|
133 | return new PentaVertexInput(this->enum_type,this->values);
|
---|
134 |
|
---|
135 | }
|
---|
136 | /*}}}*/
|
---|
137 | /*FUNCTION PentaVertexInput::EnumType{{{1*/
|
---|
138 | int PentaVertexInput::EnumType(void){
|
---|
139 |
|
---|
140 | return this->enum_type;
|
---|
141 |
|
---|
142 | }
|
---|
143 | /*}}}*/
|
---|
144 | /*FUNCTION PentaVertexInput::SpawnSingInput{{{1*/
|
---|
145 | Input* PentaVertexInput::SpawnSingInput(int index){
|
---|
146 |
|
---|
147 | /*output*/
|
---|
148 | SingVertexInput* outinput=NULL;
|
---|
149 |
|
---|
150 | /*Create new Sing input (copy of current input)*/
|
---|
151 | ISSMASSERT(index<6 && index>=0);
|
---|
152 | outinput=new SingVertexInput(this->enum_type,this->values[index]);
|
---|
153 |
|
---|
154 | /*Assign output*/
|
---|
155 | return outinput;
|
---|
156 |
|
---|
157 | }
|
---|
158 | /*}}}*/
|
---|
159 | /*FUNCTION PentaVertexInput::SpawnBeamInput{{{1*/
|
---|
160 | Input* PentaVertexInput::SpawnBeamInput(int* indices){
|
---|
161 |
|
---|
162 | /*output*/
|
---|
163 | BeamVertexInput* outinput=NULL;
|
---|
164 | double newvalues[2];
|
---|
165 |
|
---|
166 | /*Loop over the new indices*/
|
---|
167 | for(int i=0;i<2;i++){
|
---|
168 |
|
---|
169 | /*Check index value*/
|
---|
170 | ISSMASSERT(indices[i]>=0 && indices[i]<6);
|
---|
171 |
|
---|
172 | /*Assign value to new input*/
|
---|
173 | newvalues[i]=this->values[indices[i]];
|
---|
174 | }
|
---|
175 |
|
---|
176 | /*Create new Beam input*/
|
---|
177 | outinput=new BeamVertexInput(this->enum_type,&newvalues[0]);
|
---|
178 |
|
---|
179 | /*Assign output*/
|
---|
180 | return outinput;
|
---|
181 |
|
---|
182 | }
|
---|
183 | /*}}}*/
|
---|
184 | /*FUNCTION PentaVertexInput::SpawnTriaInput{{{1*/
|
---|
185 | Input* PentaVertexInput::SpawnTriaInput(int* indices){
|
---|
186 |
|
---|
187 | /*output*/
|
---|
188 | TriaVertexInput* outinput=NULL;
|
---|
189 | double newvalues[3];
|
---|
190 |
|
---|
191 | /*Loop over the new indices*/
|
---|
192 | for(int i=0;i<3;i++){
|
---|
193 |
|
---|
194 | /*Check index value*/
|
---|
195 | ISSMASSERT(indices[i]>=0 && indices[i]<6);
|
---|
196 |
|
---|
197 | /*Assign value to new input*/
|
---|
198 | newvalues[i]=this->values[indices[i]];
|
---|
199 | }
|
---|
200 |
|
---|
201 | /*Create new Tria input*/
|
---|
202 | outinput=new TriaVertexInput(this->enum_type,&newvalues[0]);
|
---|
203 |
|
---|
204 | /*Assign output*/
|
---|
205 | return outinput;
|
---|
206 |
|
---|
207 | }
|
---|
208 | /*}}}*/
|
---|
209 | /*FUNCTION PentaVertexInput::SpawnResult{{{1*/
|
---|
210 | ElementResult* PentaVertexInput::SpawnResult(int step, double time){
|
---|
211 |
|
---|
212 | return new PentaVertexElementResult(this->enum_type,this->values,step,time);
|
---|
213 |
|
---|
214 | }
|
---|
215 | /*}}}*/
|
---|
216 |
|
---|
217 | /*Object functions*/
|
---|
218 | /*FUNCTION PentaVertexInput::GetParameterValue(bool* pvalue) {{{1*/
|
---|
219 | void PentaVertexInput::GetParameterValue(bool* pvalue){ISSMERROR(" not supported yet!");}
|
---|
220 | /*}}}*/
|
---|
221 | /*FUNCTION PentaVertexInput::GetParameterValue(int* pvalue){{{1*/
|
---|
222 | void PentaVertexInput::GetParameterValue(int* pvalue){ISSMERROR(" not supported yet!");}
|
---|
223 | /*}}}*/
|
---|
224 | /*FUNCTION PentaVertexInput::GetParameterValue(double* pvalue){{{1*/
|
---|
225 | void PentaVertexInput::GetParameterValue(double* pvalue){ISSMERROR(" not supported yet!");}
|
---|
226 | /*}}}*/
|
---|
227 | /*FUNCTION PentaVertexInput::GetParameterValue(double* pvalue,double* gauss){{{1*/
|
---|
228 | void PentaVertexInput::GetParameterValue(double* pvalue,double* gauss){
|
---|
229 | /*P1 interpolation on Gauss point*/
|
---|
230 |
|
---|
231 | /*intermediary*/
|
---|
232 | double l1l6[6];
|
---|
233 |
|
---|
234 | /*nodal functions: */
|
---|
235 | GetNodalFunctionsP1(&l1l6[0],gauss);
|
---|
236 |
|
---|
237 | /*Assign output pointers:*/
|
---|
238 | *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];
|
---|
239 |
|
---|
240 | }
|
---|
241 | /*}}}*/
|
---|
242 | /*FUNCTION PentaVertexInput::GetParameterValue(double* pvalue,double* gauss,double defaultvalue){{{1*/
|
---|
243 | void PentaVertexInput::GetParameterValue(double* pvalue,double* gauss,double defaultvalue){ISSMERROR(" not supported yet!");}
|
---|
244 | /*}}}*/
|
---|
245 | /*FUNCTION PentaVertexInput::GetParameterValues{{{1*/
|
---|
246 | void PentaVertexInput::GetParameterValues(double* values,double* gauss_pointers, int numgauss){
|
---|
247 | /*It is assumed that output values has been correctly allocated*/
|
---|
248 |
|
---|
249 | int i,j;
|
---|
250 | double gauss[4];
|
---|
251 |
|
---|
252 | for (i=0;i<numgauss;i++){
|
---|
253 |
|
---|
254 | /*Get current Gauss point coordinates*/
|
---|
255 | for (j=0;j<4;j++) gauss[j]=gauss_pointers[i*4+j];
|
---|
256 |
|
---|
257 | /*Assign parameter value*/
|
---|
258 | GetParameterValue(&values[i],&gauss[0]);
|
---|
259 | }
|
---|
260 | }
|
---|
261 | /*}}}*/
|
---|
262 | /*FUNCTION PentaVertexInput::GetParameterDerivativeValue{{{1*/
|
---|
263 | void PentaVertexInput::GetParameterDerivativeValue(double* p, double* xyz_list, double* gauss){
|
---|
264 | /*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:
|
---|
265 | * 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;
|
---|
266 | * 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;
|
---|
267 | * 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;
|
---|
268 | *
|
---|
269 | * p is a vector of size 3x1 already allocated.
|
---|
270 | */
|
---|
271 |
|
---|
272 | const int NDOF3=3;
|
---|
273 | const int numgrids=6;
|
---|
274 | double dh1dh6[NDOF3][numgrids];
|
---|
275 |
|
---|
276 | /*Get nodal funnctions derivatives in actual coordinate system: */
|
---|
277 | GetNodalFunctionsP1Derivatives(&dh1dh6[0][0],xyz_list, gauss);
|
---|
278 |
|
---|
279 | 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];
|
---|
280 | 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];
|
---|
281 | 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];
|
---|
282 |
|
---|
283 | }
|
---|
284 | /*}}}*/
|
---|
285 | /*FUNCTION PentaVertexInput::GetVxStrainRate3d{{{1*/
|
---|
286 | void PentaVertexInput::GetVxStrainRate3d(double* epsilonvx,double* xyz_list, double* gauss){
|
---|
287 | int i,j;
|
---|
288 |
|
---|
289 | const int numgrids=6;
|
---|
290 | const int DOFVELOCITY=3;
|
---|
291 | double B[8][27];
|
---|
292 | double B_reduced[6][DOFVELOCITY*numgrids];
|
---|
293 | double velocity[numgrids][DOFVELOCITY];
|
---|
294 |
|
---|
295 | /*Get B matrix: */
|
---|
296 | GetBStokes(&B[0][0], xyz_list, gauss);
|
---|
297 | /*Create a reduced matrix of B to get rid of pressure */
|
---|
298 | for (i=0;i<6;i++){
|
---|
299 | for (j=0;j<3;j++){
|
---|
300 | B_reduced[i][j]=B[i][j];
|
---|
301 | }
|
---|
302 | for (j=4;j<7;j++){
|
---|
303 | B_reduced[i][j-1]=B[i][j];
|
---|
304 | }
|
---|
305 | for (j=8;j<11;j++){
|
---|
306 | B_reduced[i][j-2]=B[i][j];
|
---|
307 | }
|
---|
308 | for (j=12;j<15;j++){
|
---|
309 | B_reduced[i][j-3]=B[i][j];
|
---|
310 | }
|
---|
311 | for (j=16;j<19;j++){
|
---|
312 | B_reduced[i][j-4]=B[i][j];
|
---|
313 | }
|
---|
314 | for (j=20;j<23;j++){
|
---|
315 | B_reduced[i][j-5]=B[i][j];
|
---|
316 | }
|
---|
317 | }
|
---|
318 |
|
---|
319 | /*Here, we are computing the strain rate of (vx,0,0)*/
|
---|
320 | for(i=0;i<numgrids;i++){
|
---|
321 | velocity[i][0]=this->values[i];
|
---|
322 | velocity[i][1]=0.0;
|
---|
323 | velocity[i][2]=0.0;
|
---|
324 | }
|
---|
325 | /*Multiply B by velocity, to get strain rate: */
|
---|
326 | MatrixMultiply(&B_reduced[0][0],6,DOFVELOCITY*numgrids,0,&velocity[0][0],DOFVELOCITY*numgrids,1,0,epsilonvx,0);
|
---|
327 |
|
---|
328 | }
|
---|
329 | /*}}}*/
|
---|
330 | /*FUNCTION PentaVertexInput::GetVyStrainRate3d{{{1*/
|
---|
331 | void PentaVertexInput::GetVyStrainRate3d(double* epsilonvy,double* xyz_list, double* gauss){
|
---|
332 | int i,j;
|
---|
333 |
|
---|
334 | const int numgrids=6;
|
---|
335 | const int DOFVELOCITY=3;
|
---|
336 | double B[8][27];
|
---|
337 | double B_reduced[6][DOFVELOCITY*numgrids];
|
---|
338 | double velocity[numgrids][DOFVELOCITY];
|
---|
339 |
|
---|
340 | /*Get B matrix: */
|
---|
341 | GetBStokes(&B[0][0], xyz_list, gauss);
|
---|
342 | /*Create a reduced matrix of B to get rid of pressure */
|
---|
343 | for (i=0;i<6;i++){
|
---|
344 | for (j=0;j<3;j++){
|
---|
345 | B_reduced[i][j]=B[i][j];
|
---|
346 | }
|
---|
347 | for (j=4;j<7;j++){
|
---|
348 | B_reduced[i][j-1]=B[i][j];
|
---|
349 | }
|
---|
350 | for (j=8;j<11;j++){
|
---|
351 | B_reduced[i][j-2]=B[i][j];
|
---|
352 | }
|
---|
353 | for (j=12;j<15;j++){
|
---|
354 | B_reduced[i][j-3]=B[i][j];
|
---|
355 | }
|
---|
356 | for (j=16;j<19;j++){
|
---|
357 | B_reduced[i][j-4]=B[i][j];
|
---|
358 | }
|
---|
359 | for (j=20;j<23;j++){
|
---|
360 | B_reduced[i][j-5]=B[i][j];
|
---|
361 | }
|
---|
362 | }
|
---|
363 |
|
---|
364 | /*Here, we are computing the strain rate of (0,vy,0)*/
|
---|
365 | for(i=0;i<numgrids;i++){
|
---|
366 | velocity[i][0]=0.0;
|
---|
367 | velocity[i][1]=this->values[i];
|
---|
368 | velocity[i][2]=0.0;
|
---|
369 | }
|
---|
370 | /*Multiply B by velocity, to get strain rate: */
|
---|
371 | MatrixMultiply(&B_reduced[0][0],6,DOFVELOCITY*numgrids,0,&velocity[0][0],DOFVELOCITY*numgrids,1,0,epsilonvy,0);
|
---|
372 |
|
---|
373 | }
|
---|
374 | /*}}}*/
|
---|
375 | /*FUNCTION PentaVertexInput::GetVzStrainRate3d{{{1*/
|
---|
376 | void PentaVertexInput::GetVzStrainRate3d(double* epsilonvz,double* xyz_list, double* gauss){
|
---|
377 | int i,j;
|
---|
378 |
|
---|
379 | const int numgrids=6;
|
---|
380 | const int DOFVELOCITY=3;
|
---|
381 | double B[8][27];
|
---|
382 | double B_reduced[6][DOFVELOCITY*numgrids];
|
---|
383 | double velocity[numgrids][DOFVELOCITY];
|
---|
384 |
|
---|
385 | /*Get B matrix: */
|
---|
386 | GetBStokes(&B[0][0], xyz_list, gauss);
|
---|
387 | /*Create a reduced matrix of B to get rid of pressure */
|
---|
388 | for (i=0;i<6;i++){
|
---|
389 | for (j=0;j<3;j++){
|
---|
390 | B_reduced[i][j]=B[i][j];
|
---|
391 | }
|
---|
392 | for (j=4;j<7;j++){
|
---|
393 | B_reduced[i][j-1]=B[i][j];
|
---|
394 | }
|
---|
395 | for (j=8;j<11;j++){
|
---|
396 | B_reduced[i][j-2]=B[i][j];
|
---|
397 | }
|
---|
398 | for (j=12;j<15;j++){
|
---|
399 | B_reduced[i][j-3]=B[i][j];
|
---|
400 | }
|
---|
401 | for (j=16;j<19;j++){
|
---|
402 | B_reduced[i][j-4]=B[i][j];
|
---|
403 | }
|
---|
404 | for (j=20;j<23;j++){
|
---|
405 | B_reduced[i][j-5]=B[i][j];
|
---|
406 | }
|
---|
407 | }
|
---|
408 |
|
---|
409 | /*Here, we are computing the strain rate of (0,0,vz)*/
|
---|
410 | for(i=0;i<numgrids;i++){
|
---|
411 | velocity[i][0]=0.0;
|
---|
412 | velocity[i][1]=0.0;
|
---|
413 | velocity[i][2]=this->values[i];
|
---|
414 | }
|
---|
415 |
|
---|
416 | /*Multiply B by velocity, to get strain rate: */
|
---|
417 | MatrixMultiply(&B_reduced[0][0],6,DOFVELOCITY*numgrids,0,&velocity[0][0],DOFVELOCITY*numgrids,1,0,epsilonvz,0);
|
---|
418 |
|
---|
419 | }
|
---|
420 | /*}}}*/
|
---|
421 | /*FUNCTION PentaVertexInput::GetVxStrainRate3dPattyn{{{1*/
|
---|
422 | void PentaVertexInput::GetVxStrainRate3dPattyn(double* epsilonvx,double* xyz_list, double* gauss){
|
---|
423 |
|
---|
424 | int i;
|
---|
425 | const int numgrids=6;
|
---|
426 | const int NDOF2=2;
|
---|
427 | double B[5][NDOF2*numgrids];
|
---|
428 | double velocity[numgrids][NDOF2];
|
---|
429 |
|
---|
430 | /*Get B matrix: */
|
---|
431 | GetBPattyn(&B[0][0], xyz_list, gauss);
|
---|
432 |
|
---|
433 | /*Here, we are computing the strain rate of (vx,0)*/
|
---|
434 | for(i=0;i<numgrids;i++){
|
---|
435 | velocity[i][0]=this->values[i];
|
---|
436 | velocity[i][1]=0.0;
|
---|
437 | }
|
---|
438 |
|
---|
439 | /*Multiply B by velocity, to get strain rate: */
|
---|
440 | MatrixMultiply( &B[0][0],5,NDOF2*numgrids,0,
|
---|
441 | &velocity[0][0],NDOF2*numgrids,1,0,
|
---|
442 | epsilonvx,0);
|
---|
443 |
|
---|
444 | }
|
---|
445 | /*}}}*/
|
---|
446 | /*FUNCTION PentaVertexInput::GetVyStrainRate3dPattyn{{{1*/
|
---|
447 | void PentaVertexInput::GetVyStrainRate3dPattyn(double* epsilonvy,double* xyz_list, double* gauss){
|
---|
448 |
|
---|
449 | int i;
|
---|
450 | const int numgrids=6;
|
---|
451 | const int NDOF2=2;
|
---|
452 | double B[5][NDOF2*numgrids];
|
---|
453 | double velocity[numgrids][NDOF2];
|
---|
454 |
|
---|
455 | /*Get B matrix: */
|
---|
456 | GetBPattyn(&B[0][0], xyz_list, gauss);
|
---|
457 |
|
---|
458 | /*Here, we are computing the strain rate of (0,vy)*/
|
---|
459 | for(i=0;i<numgrids;i++){
|
---|
460 | velocity[i][0]=0.0;
|
---|
461 | velocity[i][1]=this->values[i];
|
---|
462 | }
|
---|
463 |
|
---|
464 | /*Multiply B by velocity, to get strain rate: */
|
---|
465 | MatrixMultiply( &B[0][0],5,NDOF2*numgrids,0,
|
---|
466 | &velocity[0][0],NDOF2*numgrids,1,0,
|
---|
467 | epsilonvy,0);
|
---|
468 |
|
---|
469 | }
|
---|
470 | /*}}}*/
|
---|
471 | /*FUNCTION PentaVertexInput::ChangeEnum{{{1*/
|
---|
472 | void PentaVertexInput::ChangeEnum(int newenumtype){
|
---|
473 | this->enum_type=newenumtype;
|
---|
474 | }
|
---|
475 | /*}}}*/
|
---|
476 | /*FUNCTION PentaVertexInput::GetParameterAverage{{{1*/
|
---|
477 | void PentaVertexInput::GetParameterAverage(double* pvalue){
|
---|
478 | *pvalue=1./6.*(values[0]+values[1]+values[2]+values[3]+values[4]+values[5]);
|
---|
479 | }
|
---|
480 | /*}}}*/
|
---|
481 |
|
---|
482 | /*Intermediary*/
|
---|
483 | /*FUNCTION PentaVertexInput::SquareMin{{{1*/
|
---|
484 | void PentaVertexInput::SquareMin(double* psquaremin, bool process_units,Parameters* parameters){
|
---|
485 |
|
---|
486 | int i;
|
---|
487 | const int numnodes=6;
|
---|
488 | double valuescopy[numnodes];
|
---|
489 | double squaremin;
|
---|
490 |
|
---|
491 | /*First, copy values, to process units if requested: */
|
---|
492 | for(i=0;i<numnodes;i++)valuescopy[i]=this->values[i];
|
---|
493 |
|
---|
494 | /*Process units if requested: */
|
---|
495 | if(process_units)NodalValuesUnitConversion(&valuescopy[0],numnodes,enum_type,parameters);
|
---|
496 |
|
---|
497 | /*Now, figure out minimum of valuescopy: */
|
---|
498 | squaremin=pow(valuescopy[0],2);
|
---|
499 | for(i=1;i<numnodes;i++){
|
---|
500 | if(pow(valuescopy[i],2)<squaremin)squaremin=pow(valuescopy[i],2);
|
---|
501 | }
|
---|
502 | /*Assign output pointers:*/
|
---|
503 | *psquaremin=squaremin;
|
---|
504 | }
|
---|
505 | /*}}}*/
|
---|
506 | /*FUNCTION PentaVertexInput::Scale{{{1*/
|
---|
507 | void PentaVertexInput::Scale(double scale_factor){
|
---|
508 |
|
---|
509 | int i;
|
---|
510 | const int numgrids=6;
|
---|
511 |
|
---|
512 | for(i=0;i<numgrids;i++)values[i]=values[i]*scale_factor;
|
---|
513 | }
|
---|
514 | /*}}}*/
|
---|
515 | /*FUNCTION PentaVertexInput::AXPY{{{1*/
|
---|
516 | void PentaVertexInput::AXPY(Input* xinput,double scalar){
|
---|
517 |
|
---|
518 | int i;
|
---|
519 | const int numgrids=6;
|
---|
520 | PentaVertexInput* xpentavertexinput=NULL;
|
---|
521 |
|
---|
522 | /*xinput is of the same type, so cast it: */
|
---|
523 | xpentavertexinput=(PentaVertexInput*)xinput;
|
---|
524 |
|
---|
525 | /*Carry out the AXPY operation depending on type:*/
|
---|
526 | switch(xinput->Enum()){
|
---|
527 |
|
---|
528 | case PentaVertexInputEnum:
|
---|
529 | for(i=0;i<numgrids;i++)this->values[i]=this->values[i]+scalar*xpentavertexinput->values[i];
|
---|
530 | return;
|
---|
531 |
|
---|
532 | default:
|
---|
533 | ISSMERROR("not implemented yet");
|
---|
534 | }
|
---|
535 |
|
---|
536 | }
|
---|
537 | /*}}}*/
|
---|
538 | /*FUNCTION PentaVertexInput::Constrain{{{1*/
|
---|
539 | void PentaVertexInput::Constrain(double cm_min, double cm_max){
|
---|
540 |
|
---|
541 | int i;
|
---|
542 | const int numgrids=6;
|
---|
543 |
|
---|
544 | if(!isnan(cm_min)) for(i=0;i<numgrids;i++)if (this->values[i]<cm_min)this->values[i]=cm_min;
|
---|
545 | if(!isnan(cm_max)) for(i=0;i<numgrids;i++)if (this->values[i]>cm_max)this->values[i]=cm_max;
|
---|
546 |
|
---|
547 | }
|
---|
548 | /*}}}*/
|
---|
549 | /*FUNCTION PentaVertexInput::Extrude{{{1*/
|
---|
550 | void PentaVertexInput::Extrude(void){
|
---|
551 |
|
---|
552 | int i;
|
---|
553 |
|
---|
554 | /*First 3 values copied on 3 last values*/
|
---|
555 | for(i=0;i<3;i++) this->values[3+i]=this->values[i];
|
---|
556 |
|
---|
557 | }
|
---|
558 | /*}}}*/
|
---|
559 | /*FUNCTION PentaVertexInput::VerticallyIntegrate{{{1*/
|
---|
560 | void PentaVertexInput::VerticallyIntegrate(Input* thickness_input){
|
---|
561 |
|
---|
562 | /*Intermediaries*/
|
---|
563 | int i;
|
---|
564 | const int numgrids = 6;
|
---|
565 | int num_thickness_values;
|
---|
566 | double *thickness_values = NULL;
|
---|
567 |
|
---|
568 | /*Check that input provided is a thickness*/
|
---|
569 | if (thickness_input->EnumType()!=ThicknessEnum) ISSMERROR("Input provided is not a Thickness (enum_type is %s)",EnumAsString(thickness_input->EnumType()));
|
---|
570 |
|
---|
571 | /*Get Thickness value pointer*/
|
---|
572 | thickness_input->GetValuesPtr(&thickness_values,&num_thickness_values);
|
---|
573 |
|
---|
574 | /*vertically integrate depending on type:*/
|
---|
575 | switch(thickness_input->Enum()){
|
---|
576 |
|
---|
577 | case PentaVertexInputEnum:
|
---|
578 | for(i=0;i<3;i++){
|
---|
579 | this->values[i]=0.5*(this->values[i]+this->values[i+3]) * thickness_values[i];
|
---|
580 | this->values[i+3]=this->values[i];
|
---|
581 | }
|
---|
582 | return;
|
---|
583 |
|
---|
584 | default:
|
---|
585 | ISSMERROR("not implemented yet");
|
---|
586 | }
|
---|
587 | }
|
---|
588 | /*}}}*/
|
---|
589 | /*FUNCTION PentaVertexInput::PointwiseDivide{{{1*/
|
---|
590 | Input* PentaVertexInput::PointwiseDivide(Input* inputB){
|
---|
591 |
|
---|
592 | /*Ouput*/
|
---|
593 | PentaVertexInput* outinput=NULL;
|
---|
594 |
|
---|
595 | /*Intermediaries*/
|
---|
596 | int i;
|
---|
597 | PentaVertexInput *xinputB = NULL;
|
---|
598 | int B_numvalues;
|
---|
599 | double *B_values = NULL;
|
---|
600 | const int numgrids = 6;
|
---|
601 | double AdotBvalues[numgrids];
|
---|
602 |
|
---|
603 | /*Check that inputB is of the same type*/
|
---|
604 | if (inputB->Enum()!=PentaVertexInputEnum) ISSMERROR("Operation not permitted because inputB is of type %s",EnumAsString(inputB->Enum()));
|
---|
605 | xinputB=(PentaVertexInput*)inputB;
|
---|
606 |
|
---|
607 | /*Create point wise sum*/
|
---|
608 | for(i=0;i<numgrids;i++){
|
---|
609 | ISSMASSERT(xinputB->values[i]!=0);
|
---|
610 | AdotBvalues[i]=this->values[i]/xinputB->values[i];
|
---|
611 | }
|
---|
612 |
|
---|
613 | /*Create new Sing input (copy of current input)*/
|
---|
614 | outinput=new PentaVertexInput(this->enum_type,&AdotBvalues[0]);
|
---|
615 |
|
---|
616 | /*Return output pointer*/
|
---|
617 | return outinput;
|
---|
618 |
|
---|
619 | }
|
---|
620 | /*}}}*/
|
---|
621 | /*FUNCTION PentaVertexInput::GetVectorFromInputs{{{1*/
|
---|
622 | void PentaVertexInput::GetVectorFromInputs(Vec vector,int* doflist){
|
---|
623 |
|
---|
624 | const int numvertices=6;
|
---|
625 | VecSetValues(vector,numvertices,doflist,(const double*)this->values,INSERT_VALUES);
|
---|
626 |
|
---|
627 | } /*}}}*/
|
---|
628 | /*FUNCTION PentaVertexInput::GetValuesPtr{{{1*/
|
---|
629 | void PentaVertexInput::GetValuesPtr(double** pvalues,int* pnum_values){
|
---|
630 |
|
---|
631 | *pvalues=this->values;
|
---|
632 | *pnum_values=6;
|
---|
633 |
|
---|
634 | }
|
---|
635 | /*}}}*/
|
---|