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::SpawnBeamInput{{{1*/
|
---|
145 | Input* PentaVertexInput::SpawnBeamInput(int* indices){
|
---|
146 |
|
---|
147 | /*output*/
|
---|
148 | BeamVertexInput* outinput=NULL;
|
---|
149 | double newvalues[2];
|
---|
150 |
|
---|
151 | /*Loop over the new indices*/
|
---|
152 | for(int i=0;i<2;i++){
|
---|
153 |
|
---|
154 | /*Check index value*/
|
---|
155 | ISSMASSERT(indices[i]>=0 && indices[i]<6);
|
---|
156 |
|
---|
157 | /*Assign value to new input*/
|
---|
158 | newvalues[i]=this->values[indices[i]];
|
---|
159 | }
|
---|
160 |
|
---|
161 | /*Create new Beam input*/
|
---|
162 | outinput=new BeamVertexInput(this->enum_type,&newvalues[0]);
|
---|
163 |
|
---|
164 | /*Assign output*/
|
---|
165 | return outinput;
|
---|
166 |
|
---|
167 | }
|
---|
168 | /*}}}*/
|
---|
169 | /*FUNCTION PentaVertexInput::SpawnTriaInput{{{1*/
|
---|
170 | Input* PentaVertexInput::SpawnTriaInput(int* indices){
|
---|
171 |
|
---|
172 | /*output*/
|
---|
173 | TriaVertexInput* outinput=NULL;
|
---|
174 | double newvalues[3];
|
---|
175 |
|
---|
176 | /*Loop over the new indices*/
|
---|
177 | for(int i=0;i<3;i++){
|
---|
178 |
|
---|
179 | /*Check index value*/
|
---|
180 | ISSMASSERT(indices[i]>=0 && indices[i]<6);
|
---|
181 |
|
---|
182 | /*Assign value to new input*/
|
---|
183 | newvalues[i]=this->values[indices[i]];
|
---|
184 | }
|
---|
185 |
|
---|
186 | /*Create new Tria input*/
|
---|
187 | outinput=new TriaVertexInput(this->enum_type,&newvalues[0]);
|
---|
188 |
|
---|
189 | /*Assign output*/
|
---|
190 | return outinput;
|
---|
191 |
|
---|
192 | }
|
---|
193 | /*}}}*/
|
---|
194 | /*FUNCTION PentaVertexInput::SpawnResult{{{1*/
|
---|
195 | ElementResult* PentaVertexInput::SpawnResult(int step, double time){
|
---|
196 |
|
---|
197 | return new PentaVertexElementResult(this->enum_type,this->values,step,time);
|
---|
198 |
|
---|
199 | }
|
---|
200 | /*}}}*/
|
---|
201 |
|
---|
202 | /*Object functions*/
|
---|
203 | /*FUNCTION PentaVertexInput::GetParameterValue{{{1*/
|
---|
204 | void PentaVertexInput::GetParameterValue(double* pvalue,double* gauss){
|
---|
205 |
|
---|
206 | /*Call PentaRef function*/
|
---|
207 | PentaRef::GetParameterValue(pvalue,&values[0],gauss);
|
---|
208 |
|
---|
209 | }
|
---|
210 | /*}}}*/
|
---|
211 | /*FUNCTION PentaVertexInput::GetParameterValues{{{1*/
|
---|
212 | void PentaVertexInput::GetParameterValues(double* values,double* gauss_pointers, int numgauss){
|
---|
213 | /*It is assumed that output values has been correctly allocated*/
|
---|
214 |
|
---|
215 | int i,j;
|
---|
216 | double gauss[4];
|
---|
217 |
|
---|
218 | for (i=0;i<numgauss;i++){
|
---|
219 |
|
---|
220 | /*Get current Gauss point coordinates*/
|
---|
221 | for (j=0;j<4;j++) gauss[j]=gauss_pointers[i*4+j];
|
---|
222 |
|
---|
223 | /*Assign parameter value*/
|
---|
224 | GetParameterValue(&values[i],&gauss[0]);
|
---|
225 | }
|
---|
226 | }
|
---|
227 | /*}}}*/
|
---|
228 | /*FUNCTION PentaVertexInput::GetParameterDerivativeValue{{{1*/
|
---|
229 | void PentaVertexInput::GetParameterDerivativeValue(double* p, double* xyz_list, double* gauss){
|
---|
230 |
|
---|
231 | /*Call PentaRef function*/
|
---|
232 | PentaRef::GetParameterDerivativeValue(p,&values[0],xyz_list,gauss);
|
---|
233 | }
|
---|
234 | /*}}}*/
|
---|
235 | /*FUNCTION PentaVertexInput::GetVxStrainRate3d{{{1*/
|
---|
236 | void PentaVertexInput::GetVxStrainRate3d(double* epsilonvx,double* xyz_list, double* gauss){
|
---|
237 | int i,j;
|
---|
238 |
|
---|
239 | const int numgrids=6;
|
---|
240 | const int DOFVELOCITY=3;
|
---|
241 | double B[8][27];
|
---|
242 | double B_reduced[6][DOFVELOCITY*numgrids];
|
---|
243 | double velocity[numgrids][DOFVELOCITY];
|
---|
244 |
|
---|
245 | /*Get B matrix: */
|
---|
246 | GetBStokes(&B[0][0], xyz_list, gauss);
|
---|
247 | /*Create a reduced matrix of B to get rid of pressure */
|
---|
248 | for (i=0;i<6;i++){
|
---|
249 | for (j=0;j<3;j++){
|
---|
250 | B_reduced[i][j]=B[i][j];
|
---|
251 | }
|
---|
252 | for (j=4;j<7;j++){
|
---|
253 | B_reduced[i][j-1]=B[i][j];
|
---|
254 | }
|
---|
255 | for (j=8;j<11;j++){
|
---|
256 | B_reduced[i][j-2]=B[i][j];
|
---|
257 | }
|
---|
258 | for (j=12;j<15;j++){
|
---|
259 | B_reduced[i][j-3]=B[i][j];
|
---|
260 | }
|
---|
261 | for (j=16;j<19;j++){
|
---|
262 | B_reduced[i][j-4]=B[i][j];
|
---|
263 | }
|
---|
264 | for (j=20;j<23;j++){
|
---|
265 | B_reduced[i][j-5]=B[i][j];
|
---|
266 | }
|
---|
267 | }
|
---|
268 |
|
---|
269 | /*Here, we are computing the strain rate of (vx,0,0)*/
|
---|
270 | for(i=0;i<numgrids;i++){
|
---|
271 | velocity[i][0]=this->values[i];
|
---|
272 | velocity[i][1]=0.0;
|
---|
273 | velocity[i][2]=0.0;
|
---|
274 | }
|
---|
275 | /*Multiply B by velocity, to get strain rate: */
|
---|
276 | MatrixMultiply(&B_reduced[0][0],6,DOFVELOCITY*numgrids,0,&velocity[0][0],DOFVELOCITY*numgrids,1,0,epsilonvx,0);
|
---|
277 |
|
---|
278 | }
|
---|
279 | /*}}}*/
|
---|
280 | /*FUNCTION PentaVertexInput::GetVyStrainRate3d{{{1*/
|
---|
281 | void PentaVertexInput::GetVyStrainRate3d(double* epsilonvy,double* xyz_list, double* gauss){
|
---|
282 | int i,j;
|
---|
283 |
|
---|
284 | const int numgrids=6;
|
---|
285 | const int DOFVELOCITY=3;
|
---|
286 | double B[8][27];
|
---|
287 | double B_reduced[6][DOFVELOCITY*numgrids];
|
---|
288 | double velocity[numgrids][DOFVELOCITY];
|
---|
289 |
|
---|
290 | /*Get B matrix: */
|
---|
291 | GetBStokes(&B[0][0], xyz_list, gauss);
|
---|
292 | /*Create a reduced matrix of B to get rid of pressure */
|
---|
293 | for (i=0;i<6;i++){
|
---|
294 | for (j=0;j<3;j++){
|
---|
295 | B_reduced[i][j]=B[i][j];
|
---|
296 | }
|
---|
297 | for (j=4;j<7;j++){
|
---|
298 | B_reduced[i][j-1]=B[i][j];
|
---|
299 | }
|
---|
300 | for (j=8;j<11;j++){
|
---|
301 | B_reduced[i][j-2]=B[i][j];
|
---|
302 | }
|
---|
303 | for (j=12;j<15;j++){
|
---|
304 | B_reduced[i][j-3]=B[i][j];
|
---|
305 | }
|
---|
306 | for (j=16;j<19;j++){
|
---|
307 | B_reduced[i][j-4]=B[i][j];
|
---|
308 | }
|
---|
309 | for (j=20;j<23;j++){
|
---|
310 | B_reduced[i][j-5]=B[i][j];
|
---|
311 | }
|
---|
312 | }
|
---|
313 |
|
---|
314 | /*Here, we are computing the strain rate of (0,vy,0)*/
|
---|
315 | for(i=0;i<numgrids;i++){
|
---|
316 | velocity[i][0]=0.0;
|
---|
317 | velocity[i][1]=this->values[i];
|
---|
318 | velocity[i][2]=0.0;
|
---|
319 | }
|
---|
320 | /*Multiply B by velocity, to get strain rate: */
|
---|
321 | MatrixMultiply(&B_reduced[0][0],6,DOFVELOCITY*numgrids,0,&velocity[0][0],DOFVELOCITY*numgrids,1,0,epsilonvy,0);
|
---|
322 |
|
---|
323 | }
|
---|
324 | /*}}}*/
|
---|
325 | /*FUNCTION PentaVertexInput::GetVzStrainRate3d{{{1*/
|
---|
326 | void PentaVertexInput::GetVzStrainRate3d(double* epsilonvz,double* xyz_list, double* gauss){
|
---|
327 | int i,j;
|
---|
328 |
|
---|
329 | const int numgrids=6;
|
---|
330 | const int DOFVELOCITY=3;
|
---|
331 | double B[8][27];
|
---|
332 | double B_reduced[6][DOFVELOCITY*numgrids];
|
---|
333 | double velocity[numgrids][DOFVELOCITY];
|
---|
334 |
|
---|
335 | /*Get B matrix: */
|
---|
336 | GetBStokes(&B[0][0], xyz_list, gauss);
|
---|
337 | /*Create a reduced matrix of B to get rid of pressure */
|
---|
338 | for (i=0;i<6;i++){
|
---|
339 | for (j=0;j<3;j++){
|
---|
340 | B_reduced[i][j]=B[i][j];
|
---|
341 | }
|
---|
342 | for (j=4;j<7;j++){
|
---|
343 | B_reduced[i][j-1]=B[i][j];
|
---|
344 | }
|
---|
345 | for (j=8;j<11;j++){
|
---|
346 | B_reduced[i][j-2]=B[i][j];
|
---|
347 | }
|
---|
348 | for (j=12;j<15;j++){
|
---|
349 | B_reduced[i][j-3]=B[i][j];
|
---|
350 | }
|
---|
351 | for (j=16;j<19;j++){
|
---|
352 | B_reduced[i][j-4]=B[i][j];
|
---|
353 | }
|
---|
354 | for (j=20;j<23;j++){
|
---|
355 | B_reduced[i][j-5]=B[i][j];
|
---|
356 | }
|
---|
357 | }
|
---|
358 |
|
---|
359 | /*Here, we are computing the strain rate of (0,0,vz)*/
|
---|
360 | for(i=0;i<numgrids;i++){
|
---|
361 | velocity[i][0]=0.0;
|
---|
362 | velocity[i][1]=0.0;
|
---|
363 | velocity[i][2]=this->values[i];
|
---|
364 | }
|
---|
365 |
|
---|
366 | /*Multiply B by velocity, to get strain rate: */
|
---|
367 | MatrixMultiply(&B_reduced[0][0],6,DOFVELOCITY*numgrids,0,&velocity[0][0],DOFVELOCITY*numgrids,1,0,epsilonvz,0);
|
---|
368 |
|
---|
369 | }
|
---|
370 | /*}}}*/
|
---|
371 | /*FUNCTION PentaVertexInput::GetVxStrainRate3dPattyn{{{1*/
|
---|
372 | void PentaVertexInput::GetVxStrainRate3dPattyn(double* epsilonvx,double* xyz_list, double* gauss){
|
---|
373 |
|
---|
374 | int i;
|
---|
375 | const int numgrids=6;
|
---|
376 | const int NDOF2=2;
|
---|
377 | double B[5][NDOF2*numgrids];
|
---|
378 | double velocity[numgrids][NDOF2];
|
---|
379 |
|
---|
380 | /*Get B matrix: */
|
---|
381 | GetBPattyn(&B[0][0], xyz_list, gauss);
|
---|
382 |
|
---|
383 | /*Here, we are computing the strain rate of (vx,0)*/
|
---|
384 | for(i=0;i<numgrids;i++){
|
---|
385 | velocity[i][0]=this->values[i];
|
---|
386 | velocity[i][1]=0.0;
|
---|
387 | }
|
---|
388 |
|
---|
389 | /*Multiply B by velocity, to get strain rate: */
|
---|
390 | MatrixMultiply( &B[0][0],5,NDOF2*numgrids,0,
|
---|
391 | &velocity[0][0],NDOF2*numgrids,1,0,
|
---|
392 | epsilonvx,0);
|
---|
393 |
|
---|
394 | }
|
---|
395 | /*}}}*/
|
---|
396 | /*FUNCTION PentaVertexInput::GetVyStrainRate3dPattyn{{{1*/
|
---|
397 | void PentaVertexInput::GetVyStrainRate3dPattyn(double* epsilonvy,double* xyz_list, double* gauss){
|
---|
398 |
|
---|
399 | int i;
|
---|
400 | const int numgrids=6;
|
---|
401 | const int NDOF2=2;
|
---|
402 | double B[5][NDOF2*numgrids];
|
---|
403 | double velocity[numgrids][NDOF2];
|
---|
404 |
|
---|
405 | /*Get B matrix: */
|
---|
406 | GetBPattyn(&B[0][0], xyz_list, gauss);
|
---|
407 |
|
---|
408 | /*Here, we are computing the strain rate of (0,vy)*/
|
---|
409 | for(i=0;i<numgrids;i++){
|
---|
410 | velocity[i][0]=0.0;
|
---|
411 | velocity[i][1]=this->values[i];
|
---|
412 | }
|
---|
413 |
|
---|
414 | /*Multiply B by velocity, to get strain rate: */
|
---|
415 | MatrixMultiply( &B[0][0],5,NDOF2*numgrids,0,
|
---|
416 | &velocity[0][0],NDOF2*numgrids,1,0,
|
---|
417 | epsilonvy,0);
|
---|
418 |
|
---|
419 | }
|
---|
420 | /*}}}*/
|
---|
421 | /*FUNCTION PentaVertexInput::ChangeEnum{{{1*/
|
---|
422 | void PentaVertexInput::ChangeEnum(int newenumtype){
|
---|
423 | this->enum_type=newenumtype;
|
---|
424 | }
|
---|
425 | /*}}}*/
|
---|
426 | /*FUNCTION PentaVertexInput::GetParameterAverage{{{1*/
|
---|
427 | void PentaVertexInput::GetParameterAverage(double* pvalue){
|
---|
428 | *pvalue=1./6.*(values[0]+values[1]+values[2]+values[3]+values[4]+values[5]);
|
---|
429 | }
|
---|
430 | /*}}}*/
|
---|
431 |
|
---|
432 | /*Intermediary*/
|
---|
433 | /*FUNCTION PentaVertexInput::SquareMin{{{1*/
|
---|
434 | void PentaVertexInput::SquareMin(double* psquaremin, bool process_units,Parameters* parameters){
|
---|
435 |
|
---|
436 | int i;
|
---|
437 | const int numnodes=6;
|
---|
438 | double valuescopy[numnodes];
|
---|
439 | double squaremin;
|
---|
440 |
|
---|
441 | /*First, copy values, to process units if requested: */
|
---|
442 | for(i=0;i<numnodes;i++)valuescopy[i]=this->values[i];
|
---|
443 |
|
---|
444 | /*Process units if requested: */
|
---|
445 | if(process_units)NodalValuesUnitConversion(&valuescopy[0],numnodes,enum_type,parameters);
|
---|
446 |
|
---|
447 | /*Now, figure out minimum of valuescopy: */
|
---|
448 | squaremin=pow(valuescopy[0],2);
|
---|
449 | for(i=1;i<numnodes;i++){
|
---|
450 | if(pow(valuescopy[i],2)<squaremin)squaremin=pow(valuescopy[i],2);
|
---|
451 | }
|
---|
452 | /*Assign output pointers:*/
|
---|
453 | *psquaremin=squaremin;
|
---|
454 | }
|
---|
455 | /*}}}*/
|
---|
456 | /*FUNCTION PentaVertexInput::Scale{{{1*/
|
---|
457 | void PentaVertexInput::Scale(double scale_factor){
|
---|
458 |
|
---|
459 | int i;
|
---|
460 | const int numgrids=6;
|
---|
461 |
|
---|
462 | for(i=0;i<numgrids;i++)values[i]=values[i]*scale_factor;
|
---|
463 | }
|
---|
464 | /*}}}*/
|
---|
465 | /*FUNCTION PentaVertexInput::AXPY{{{1*/
|
---|
466 | void PentaVertexInput::AXPY(Input* xinput,double scalar){
|
---|
467 |
|
---|
468 | int i;
|
---|
469 | const int numgrids=6;
|
---|
470 | PentaVertexInput* xpentavertexinput=NULL;
|
---|
471 |
|
---|
472 | /*xinput is of the same type, so cast it: */
|
---|
473 | xpentavertexinput=(PentaVertexInput*)xinput;
|
---|
474 |
|
---|
475 | /*Carry out the AXPY operation depending on type:*/
|
---|
476 | switch(xinput->Enum()){
|
---|
477 |
|
---|
478 | case PentaVertexInputEnum:
|
---|
479 | for(i=0;i<numgrids;i++)this->values[i]=this->values[i]+scalar*xpentavertexinput->values[i];
|
---|
480 | return;
|
---|
481 |
|
---|
482 | default:
|
---|
483 | ISSMERROR("not implemented yet");
|
---|
484 | }
|
---|
485 |
|
---|
486 | }
|
---|
487 | /*}}}*/
|
---|
488 | /*FUNCTION PentaVertexInput::Constrain{{{1*/
|
---|
489 | void PentaVertexInput::Constrain(double cm_min, double cm_max){
|
---|
490 |
|
---|
491 | int i;
|
---|
492 | const int numgrids=6;
|
---|
493 |
|
---|
494 | if(!isnan(cm_min)) for(i=0;i<numgrids;i++)if (this->values[i]<cm_min)this->values[i]=cm_min;
|
---|
495 | if(!isnan(cm_max)) for(i=0;i<numgrids;i++)if (this->values[i]>cm_max)this->values[i]=cm_max;
|
---|
496 |
|
---|
497 | }
|
---|
498 | /*}}}*/
|
---|
499 | /*FUNCTION PentaVertexInput::Extrude{{{1*/
|
---|
500 | void PentaVertexInput::Extrude(void){
|
---|
501 |
|
---|
502 | int i;
|
---|
503 |
|
---|
504 | /*First 3 values copied on 3 last values*/
|
---|
505 | for(i=0;i<3;i++) this->values[3+i]=this->values[i];
|
---|
506 |
|
---|
507 | }
|
---|
508 | /*}}}*/
|
---|
509 | /*FUNCTION PentaVertexInput::VerticallyIntegrate{{{1*/
|
---|
510 | void PentaVertexInput::VerticallyIntegrate(Input* thickness_input){
|
---|
511 |
|
---|
512 | /*Intermediaries*/
|
---|
513 | int i;
|
---|
514 | const int numgrids = 6;
|
---|
515 | int num_thickness_values;
|
---|
516 | double *thickness_values = NULL;
|
---|
517 |
|
---|
518 | /*Check that input provided is a thickness*/
|
---|
519 | if (thickness_input->EnumType()!=ThicknessEnum) ISSMERROR("Input provided is not a Thickness (enum_type is %s)",EnumAsString(thickness_input->EnumType()));
|
---|
520 |
|
---|
521 | /*Get Thickness value pointer*/
|
---|
522 | thickness_input->GetValuesPtr(&thickness_values,&num_thickness_values);
|
---|
523 |
|
---|
524 | /*vertically integrate depending on type:*/
|
---|
525 | switch(thickness_input->Enum()){
|
---|
526 |
|
---|
527 | case PentaVertexInputEnum:
|
---|
528 | for(i=0;i<3;i++){
|
---|
529 | this->values[i]=0.5*(this->values[i]+this->values[i+3]) * thickness_values[i];
|
---|
530 | this->values[i+3]=this->values[i];
|
---|
531 | }
|
---|
532 | return;
|
---|
533 |
|
---|
534 | default:
|
---|
535 | ISSMERROR("not implemented yet");
|
---|
536 | }
|
---|
537 | }
|
---|
538 | /*}}}*/
|
---|
539 | /*FUNCTION PentaVertexInput::PointwiseDivide{{{1*/
|
---|
540 | Input* PentaVertexInput::PointwiseDivide(Input* inputB){
|
---|
541 |
|
---|
542 | /*Ouput*/
|
---|
543 | PentaVertexInput* outinput=NULL;
|
---|
544 |
|
---|
545 | /*Intermediaries*/
|
---|
546 | int i;
|
---|
547 | PentaVertexInput *xinputB = NULL;
|
---|
548 | int B_numvalues;
|
---|
549 | double *B_values = NULL;
|
---|
550 | const int numgrids = 6;
|
---|
551 | double AdotBvalues[numgrids];
|
---|
552 |
|
---|
553 | /*Check that inputB is of the same type*/
|
---|
554 | if (inputB->Enum()!=PentaVertexInputEnum) ISSMERROR("Operation not permitted because inputB is of type %s",EnumAsString(inputB->Enum()));
|
---|
555 | xinputB=(PentaVertexInput*)inputB;
|
---|
556 |
|
---|
557 | /*Create point wise sum*/
|
---|
558 | for(i=0;i<numgrids;i++){
|
---|
559 | ISSMASSERT(xinputB->values[i]!=0);
|
---|
560 | AdotBvalues[i]=this->values[i]/xinputB->values[i];
|
---|
561 | }
|
---|
562 |
|
---|
563 | /*Create new Penta vertex input (copy of current input)*/
|
---|
564 | outinput=new PentaVertexInput(this->enum_type,&AdotBvalues[0]);
|
---|
565 |
|
---|
566 | /*Return output pointer*/
|
---|
567 | return outinput;
|
---|
568 |
|
---|
569 | }
|
---|
570 | /*}}}*/
|
---|
571 | /*FUNCTION PentaVertexInput::GetVectorFromInputs{{{1*/
|
---|
572 | void PentaVertexInput::GetVectorFromInputs(Vec vector,int* doflist){
|
---|
573 |
|
---|
574 | const int numvertices=6;
|
---|
575 | VecSetValues(vector,numvertices,doflist,(const double*)this->values,INSERT_VALUES);
|
---|
576 |
|
---|
577 | } /*}}}*/
|
---|
578 | /*FUNCTION PentaVertexInput::GetValuesPtr{{{1*/
|
---|
579 | void PentaVertexInput::GetValuesPtr(double** pvalues,int* pnum_values){
|
---|
580 |
|
---|
581 | *pvalues=this->values;
|
---|
582 | *pnum_values=6;
|
---|
583 |
|
---|
584 | }
|
---|
585 | /*}}}*/
|
---|