source: issm/trunk-jpl/src/c/objects/Inputs/PentaP1Input.cpp@ 11291

Last change on this file since 11291 was 11291, checked in by Mathieu Morlighem, 13 years ago

moved TriaVertexInput to TriaP1Input and same for Penta

File size: 17.1 KB
RevLine 
[11291]1/*!\file PentaP1Input.c
2 * \brief: implementation of the PentaP1Input object
[3683]3 */
4
5#ifdef HAVE_CONFIG_H
[9320]6 #include <config.h>
[3683]7#else
8#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
9#endif
10
[9320]11#include <stdio.h>
[3683]12#include <string.h>
13#include "../objects.h"
14#include "../../EnumDefinitions/EnumDefinitions.h"
15#include "../../shared/shared.h"
[4236]16#include "../../Container/Container.h"
[3775]17#include "../../include/include.h"
[3683]18
[11291]19/*PentaP1Input constructors and destructor*/
20/*FUNCTION PentaP1Input::PentaP1Input(){{{1*/
21PentaP1Input::PentaP1Input(){
[3683]22 return;
23}
24/*}}}*/
[11291]25/*FUNCTION PentaP1Input::PentaP1Input(int in_enum_type,double* values){{{1*/
26PentaP1Input::PentaP1Input(int in_enum_type,double* in_values)
[4882]27 :PentaRef(1)
28{
[3683]29
[4882]30 /*Set PentaRef*/
31 this->SetElementType(P1Enum,0);
32 this->element_type=P1Enum;
33
[3683]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/*}}}*/
[11291]43/*FUNCTION PentaP1Input::~PentaP1Input(){{{1*/
44PentaP1Input::~PentaP1Input(){
[3683]45 return;
46}
47/*}}}*/
48
[4248]49/*Object virtual functions definitions:*/
[11291]50/*FUNCTION PentaP1Input::Echo {{{1*/
51void PentaP1Input::Echo(void){
[4248]52 this->DeepEcho();
[3683]53}
54/*}}}*/
[11291]55/*FUNCTION PentaP1Input::DeepEcho{{{1*/
56void PentaP1Input::DeepEcho(void){
[3683]57
[11291]58 printf("PentaP1Input:\n");
[8224]59 printf(" enum: %i (%s)\n",this->enum_type,EnumToStringx(this->enum_type));
[3847]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]);
[3683]61}
62/*}}}*/
[11291]63/*FUNCTION PentaP1Input::Id{{{1*/
64int PentaP1Input::Id(void){ return -1; }
[3683]65/*}}}*/
[11291]66/*FUNCTION PentaP1Input::MyRank{{{1*/
67int PentaP1Input::MyRank(void){
[4248]68 extern int my_rank;
69 return my_rank;
[3683]70}
71/*}}}*/
[9777]72#ifdef _SERIAL_
[11291]73/*FUNCTION PentaP1Input::Marshall{{{1*/
74void PentaP1Input::Marshall(char** pmarshalled_dataset){
[3683]75
76 char* marshalled_dataset=NULL;
77 int enum_value=0;
78
79 /*recover marshalled_dataset: */
80 marshalled_dataset=*pmarshalled_dataset;
81
[11291]82 /*get enum value of PentaP1Input: */
83 enum_value=PentaP1InputEnum;
[3683]84
85 /*marshall enum: */
86 memcpy(marshalled_dataset,&enum_value,sizeof(enum_value));marshalled_dataset+=sizeof(enum_value);
87
[11291]88 /*marshall PentaP1Input data: */
[3683]89 memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
90 memcpy(marshalled_dataset,&values,sizeof(values));marshalled_dataset+=sizeof(values);
91
92 *pmarshalled_dataset=marshalled_dataset;
93}
94/*}}}*/
[11291]95/*FUNCTION PentaP1Input::MarshallSize{{{1*/
96int PentaP1Input::MarshallSize(){
[3683]97
98 return sizeof(values)+
99 +sizeof(enum_type)+
100 +sizeof(int); //sizeof(int) for enum value
101}
102/*}}}*/
[11291]103/*FUNCTION PentaP1Input::Demarshall{{{1*/
104void PentaP1Input::Demarshall(char** pmarshalled_dataset){
[4248]105
106 char* marshalled_dataset=NULL;
107 int i;
108
109 /*recover marshalled_dataset: */
110 marshalled_dataset=*pmarshalled_dataset;
111
112 /*this time, no need to get enum type, the pointer directly points to the beginning of the
113 *object data (thanks to DataSet::Demarshall):*/
114 memcpy(&enum_type,marshalled_dataset,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
115 memcpy(&values,marshalled_dataset,sizeof(values));marshalled_dataset+=sizeof(values);
116
117 /*return: */
118 *pmarshalled_dataset=marshalled_dataset;
119 return;
[3683]120}
121/*}}}*/
[9777]122#endif
[11291]123/*FUNCTION PentaP1Input::ObjectEnum{{{1*/
124int PentaP1Input::ObjectEnum(void){
[4248]125
[11291]126 return PentaP1InputEnum;
[4248]127
128}
129/*}}}*/
130
[11291]131/*PentaP1Input management*/
132/*FUNCTION PentaP1Input::copy{{{1*/
133Object* PentaP1Input::copy() {
[4248]134
[11291]135 return new PentaP1Input(this->enum_type,this->values);
[4248]136
137}
138/*}}}*/
[11291]139/*FUNCTION PentaP1Input::InstanceEnum{{{1*/
140int PentaP1Input::InstanceEnum(void){
[4248]141
142 return this->enum_type;
143
144}
145/*}}}*/
[11291]146/*FUNCTION PentaP1Input::SpawnTriaInput{{{1*/
147Input* PentaP1Input::SpawnTriaInput(int* indices){
[3683]148
[3847]149 /*output*/
[11291]150 TriaP1Input* outinput=NULL;
[3847]151 double newvalues[3];
152
153 /*Loop over the new indices*/
154 for(int i=0;i<3;i++){
155
156 /*Check index value*/
[6412]157 _assert_(indices[i]>=0 && indices[i]<6);
[3847]158
159 /*Assign value to new input*/
160 newvalues[i]=this->values[indices[i]];
161 }
162
163 /*Create new Tria input*/
[11291]164 outinput=new TriaP1Input(this->enum_type,&newvalues[0]);
[3847]165
166 /*Assign output*/
167 return outinput;
168
169}
170/*}}}*/
[11291]171/*FUNCTION PentaP1Input::SpawnResult{{{1*/
172ElementResult* PentaP1Input::SpawnResult(int step, double time){
[3847]173
[4050]174 return new PentaVertexElementResult(this->enum_type,this->values,step,time);
[4037]175
176}
177/*}}}*/
178
[3683]179/*Object functions*/
[11291]180/*FUNCTION PentaP1Input::GetInputValue(double* pvalue,GaussPenta* gauss){{{1*/
181void PentaP1Input::GetInputValue(double* pvalue,GaussPenta* gauss){
[5629]182
183 /*Call PentaRef function*/
[10135]184 PentaRef::GetInputValue(pvalue,&values[0],gauss);
[5629]185
186}
187/*}}}*/
[11291]188/*FUNCTION PentaP1Input::GetInputDerivativeValue(double* p, double* xyz_list, GaussPenta* gauss){{{1*/
189void PentaP1Input::GetInputDerivativeValue(double* p, double* xyz_list, GaussPenta* gauss){
[5629]190
191 /*Call PentaRef function*/
[10135]192 PentaRef::GetInputDerivativeValue(p,&values[0],xyz_list,gauss);
[5629]193}
194/*}}}*/
[11291]195/*FUNCTION PentaP1Input::GetVxStrainRate3d{{{1*/
196void PentaP1Input::GetVxStrainRate3d(double* epsilonvx,double* xyz_list, GaussPenta* gauss){
[5647]197 int i,j;
198
[8303]199 const int numnodes=6;
[5647]200 const int DOFVELOCITY=3;
201 double B[8][27];
[8303]202 double B_reduced[6][DOFVELOCITY*numnodes];
203 double velocity[numnodes][DOFVELOCITY];
[5647]204
205 /*Get B matrix: */
206 GetBStokes(&B[0][0], xyz_list, gauss);
207 /*Create a reduced matrix of B to get rid of pressure */
208 for (i=0;i<6;i++){
209 for (j=0;j<3;j++){
210 B_reduced[i][j]=B[i][j];
211 }
212 for (j=4;j<7;j++){
213 B_reduced[i][j-1]=B[i][j];
214 }
215 for (j=8;j<11;j++){
216 B_reduced[i][j-2]=B[i][j];
217 }
218 for (j=12;j<15;j++){
219 B_reduced[i][j-3]=B[i][j];
220 }
221 for (j=16;j<19;j++){
222 B_reduced[i][j-4]=B[i][j];
223 }
224 for (j=20;j<23;j++){
225 B_reduced[i][j-5]=B[i][j];
226 }
227 }
228
229 /*Here, we are computing the strain rate of (vx,0,0)*/
[8303]230 for(i=0;i<numnodes;i++){
[5647]231 velocity[i][0]=this->values[i];
232 velocity[i][1]=0.0;
233 velocity[i][2]=0.0;
234 }
235 /*Multiply B by velocity, to get strain rate: */
[8303]236 MatrixMultiply(&B_reduced[0][0],6,DOFVELOCITY*numnodes,0,&velocity[0][0],DOFVELOCITY*numnodes,1,0,epsilonvx,0);
[5647]237
238}
239/*}}}*/
[11291]240/*FUNCTION PentaP1Input::GetVyStrainRate3d{{{1*/
241void PentaP1Input::GetVyStrainRate3d(double* epsilonvy,double* xyz_list, GaussPenta* gauss){
[5647]242 int i,j;
243
[8303]244 const int numnodes=6;
[5647]245 const int DOFVELOCITY=3;
246 double B[8][27];
[8303]247 double B_reduced[6][DOFVELOCITY*numnodes];
248 double velocity[numnodes][DOFVELOCITY];
[5647]249
250 /*Get B matrix: */
251 GetBStokes(&B[0][0], xyz_list, gauss);
252 /*Create a reduced matrix of B to get rid of pressure */
253 for (i=0;i<6;i++){
254 for (j=0;j<3;j++){
255 B_reduced[i][j]=B[i][j];
256 }
257 for (j=4;j<7;j++){
258 B_reduced[i][j-1]=B[i][j];
259 }
260 for (j=8;j<11;j++){
261 B_reduced[i][j-2]=B[i][j];
262 }
263 for (j=12;j<15;j++){
264 B_reduced[i][j-3]=B[i][j];
265 }
266 for (j=16;j<19;j++){
267 B_reduced[i][j-4]=B[i][j];
268 }
269 for (j=20;j<23;j++){
270 B_reduced[i][j-5]=B[i][j];
271 }
272 }
273
274 /*Here, we are computing the strain rate of (0,vy,0)*/
[8303]275 for(i=0;i<numnodes;i++){
[5647]276 velocity[i][0]=0.0;
277 velocity[i][1]=this->values[i];
278 velocity[i][2]=0.0;
279 }
280 /*Multiply B by velocity, to get strain rate: */
[8303]281 MatrixMultiply(&B_reduced[0][0],6,DOFVELOCITY*numnodes,0,&velocity[0][0],DOFVELOCITY*numnodes,1,0,epsilonvy,0);
[5647]282
283}
284/*}}}*/
[11291]285/*FUNCTION PentaP1Input::GetVzStrainRate3d{{{1*/
286void PentaP1Input::GetVzStrainRate3d(double* epsilonvz,double* xyz_list, GaussPenta* gauss){
[5647]287 int i,j;
288
[8303]289 const int numnodes=6;
[5647]290 const int DOFVELOCITY=3;
291 double B[8][27];
[8303]292 double B_reduced[6][DOFVELOCITY*numnodes];
293 double velocity[numnodes][DOFVELOCITY];
[5647]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 (0,0,vz)*/
[8303]320 for(i=0;i<numnodes;i++){
[5647]321 velocity[i][0]=0.0;
322 velocity[i][1]=0.0;
323 velocity[i][2]=this->values[i];
324 }
325
326 /*Multiply B by velocity, to get strain rate: */
[8303]327 MatrixMultiply(&B_reduced[0][0],6,DOFVELOCITY*numnodes,0,&velocity[0][0],DOFVELOCITY*numnodes,1,0,epsilonvz,0);
[5647]328
329}
330/*}}}*/
[11291]331/*FUNCTION PentaP1Input::GetVxStrainRate3dPattyn{{{1*/
332void PentaP1Input::GetVxStrainRate3dPattyn(double* epsilonvx,double* xyz_list, GaussPenta* gauss){
[5647]333
334 int i;
[8303]335 const int numnodes=6;
336 double B[5][NDOF2*numnodes];
337 double velocity[numnodes][NDOF2];
[5647]338
339 /*Get B matrix: */
340 GetBPattyn(&B[0][0], xyz_list, gauss);
341
342 /*Here, we are computing the strain rate of (vx,0)*/
[8303]343 for(i=0;i<numnodes;i++){
[5647]344 velocity[i][0]=this->values[i];
345 velocity[i][1]=0.0;
346 }
347
348 /*Multiply B by velocity, to get strain rate: */
[8303]349 MatrixMultiply( &B[0][0],5,NDOF2*numnodes,0,
350 &velocity[0][0],NDOF2*numnodes,1,0,
[5647]351 epsilonvx,0);
352
353}
354/*}}}*/
[11291]355/*FUNCTION PentaP1Input::GetVyStrainRate3dPattyn{{{1*/
356void PentaP1Input::GetVyStrainRate3dPattyn(double* epsilonvy,double* xyz_list, GaussPenta* gauss){
[5647]357
358 int i;
[8303]359 const int numnodes=6;
360 double B[5][NDOF2*numnodes];
361 double velocity[numnodes][NDOF2];
[5647]362
363 /*Get B matrix: */
364 GetBPattyn(&B[0][0], xyz_list, gauss);
365
366 /*Here, we are computing the strain rate of (0,vy)*/
[8303]367 for(i=0;i<numnodes;i++){
[5647]368 velocity[i][0]=0.0;
369 velocity[i][1]=this->values[i];
370 }
371
372 /*Multiply B by velocity, to get strain rate: */
[8303]373 MatrixMultiply( &B[0][0],5,NDOF2*numnodes,0,
374 &velocity[0][0],NDOF2*numnodes,1,0,
[5647]375 epsilonvy,0);
376
377}
378/*}}}*/
[11291]379/*FUNCTION PentaP1Input::ChangeEnum{{{1*/
380void PentaP1Input::ChangeEnum(int newenumtype){
[3732]381 this->enum_type=newenumtype;
382}
383/*}}}*/
[11291]384/*FUNCTION PentaP1Input::GetInputAverage{{{1*/
385void PentaP1Input::GetInputAverage(double* pvalue){
[3830]386 *pvalue=1./6.*(values[0]+values[1]+values[2]+values[3]+values[4]+values[5]);
387}
388/*}}}*/
[3840]389
390/*Intermediary*/
[11291]391/*FUNCTION PentaP1Input::SquareMin{{{1*/
392void PentaP1Input::SquareMin(double* psquaremin, bool process_units,Parameters* parameters){
[4042]393
394 int i;
395 const int numnodes=6;
396 double valuescopy[numnodes];
397 double squaremin;
398
399 /*First, copy values, to process units if requested: */
400 for(i=0;i<numnodes;i++)valuescopy[i]=this->values[i];
401
402 /*Process units if requested: */
[8967]403 if(process_units)UnitConversion(&valuescopy[0],numnodes,IuToExtEnum,enum_type);
[4042]404
405 /*Now, figure out minimum of valuescopy: */
406 squaremin=pow(valuescopy[0],2);
407 for(i=1;i<numnodes;i++){
408 if(pow(valuescopy[i],2)<squaremin)squaremin=pow(valuescopy[i],2);
409 }
410 /*Assign output pointers:*/
411 *psquaremin=squaremin;
412}
413/*}}}*/
[11291]414/*FUNCTION PentaP1Input::ConstrainMin{{{1*/
415void PentaP1Input::ConstrainMin(double minimum){
[5017]416
417 int i;
[8303]418 const int numnodes=6;
[5017]419
[8303]420 for(i=0;i<numnodes;i++) if (values[i]<minimum) values[i]=minimum;
[5017]421}
422/*}}}*/
[11291]423/*FUNCTION PentaP1Input::InfinityNorm{{{1*/
424double PentaP1Input::InfinityNorm(void){
[5513]425
426 /*Output*/
[8303]427 const int numnodes=6;
[5513]428 double norm=0;
429
[8303]430 for(int i=0;i<numnodes;i++) if(fabs(values[i])>norm) norm=fabs(values[i]);
[5513]431 return norm;
432}
433/*}}}*/
[11291]434/*FUNCTION PentaP1Input::Max{{{1*/
435double PentaP1Input::Max(void){
[5659]436
[8303]437 const int numnodes=6;
[5659]438 double max=values[0];
439
[8303]440 for(int i=1;i<numnodes;i++){
[5659]441 if(values[i]>max) max=values[i];
442 }
443 return max;
444}
445/*}}}*/
[11291]446/*FUNCTION PentaP1Input::MaxAbs{{{1*/
447double PentaP1Input::MaxAbs(void){
[5659]448
[8303]449 const int numnodes=6;
[5659]450 double max=fabs(values[0]);
451
[8303]452 for(int i=1;i<numnodes;i++){
[5659]453 if(fabs(values[i])>max) max=fabs(values[i]);
454 }
455 return max;
456}
457/*}}}*/
[11291]458/*FUNCTION PentaP1Input::Min{{{1*/
459double PentaP1Input::Min(void){
[5659]460
[8303]461 const int numnodes=6;
[5659]462 double min=values[0];
463
[8303]464 for(int i=1;i<numnodes;i++){
[5659]465 if(values[i]<min) min=values[i];
466 }
467 return min;
468}
469/*}}}*/
[11291]470/*FUNCTION PentaP1Input::MinAbs{{{1*/
471double PentaP1Input::MinAbs(void){
[5659]472
[8303]473 const int numnodes=6;
[5659]474 double min=fabs(values[0]);
475
[8303]476 for(int i=1;i<numnodes;i++){
[5659]477 if(fabs(values[i])<min) min=fabs(values[i]);
478 }
479 return min;
480}
481/*}}}*/
[11291]482/*FUNCTION PentaP1Input::Scale{{{1*/
483void PentaP1Input::Scale(double scale_factor){
[4047]484
485 int i;
[8303]486 const int numnodes=6;
[4047]487
[8303]488 for(i=0;i<numnodes;i++)values[i]=values[i]*scale_factor;
[4047]489}
490/*}}}*/
[11291]491/*FUNCTION PentaP1Input::AXPY{{{1*/
492void PentaP1Input::AXPY(Input* xinput,double scalar){
[4048]493
494 int i;
[8303]495 const int numnodes=6;
[4048]496
497 /*xinput is of the same type, so cast it: */
498
[4174]499 /*Carry out the AXPY operation depending on type:*/
[9883]500 switch(xinput->ObjectEnum()){
[4048]501
[11291]502 case PentaP1InputEnum:{
503 PentaP1Input* cast_input=(PentaP1Input*)xinput;
[8303]504 for(i=0;i<numnodes;i++)this->values[i]=this->values[i]+scalar*(cast_input->values[i]);}
[4174]505 return;
[6200]506 case ControlInputEnum:{
507 ControlInput* cont_input=(ControlInput*)xinput;
[11291]508 if(cont_input->values->ObjectEnum()!=PentaP1InputEnum) _error_("not supported yet");
509 PentaP1Input* cast_input=(PentaP1Input*)cont_input->values;
[8303]510 for(i=0;i<numnodes;i++)this->values[i]=this->values[i]+scalar*(cast_input->values[i]);}
[6200]511 return;
[4174]512 default:
[6412]513 _error_("not implemented yet");
[4174]514 }
515
[4048]516}
517/*}}}*/
[11291]518/*FUNCTION PentaP1Input::Constrain{{{1*/
519void PentaP1Input::Constrain(double cm_min, double cm_max){
[4048]520
521 int i;
[8303]522 const int numnodes=6;
[4048]523
[8303]524 if(!isnan(cm_min)) for(i=0;i<numnodes;i++)if (this->values[i]<cm_min)this->values[i]=cm_min;
525 if(!isnan(cm_max)) for(i=0;i<numnodes;i++)if (this->values[i]>cm_max)this->values[i]=cm_max;
[4048]526
527}
528/*}}}*/
[11291]529/*FUNCTION PentaP1Input::Extrude{{{1*/
530void PentaP1Input::Extrude(void){
[4274]531
532 int i;
533
534 /*First 3 values copied on 3 last values*/
535 for(i=0;i<3;i++) this->values[3+i]=this->values[i];
536}
537/*}}}*/
[11291]538/*FUNCTION PentaP1Input::VerticallyIntegrate{{{1*/
539void PentaP1Input::VerticallyIntegrate(Input* thickness_input){
[4471]540
541 /*Intermediaries*/
542 int i;
[8303]543 const int numnodes = 6;
[4471]544 int num_thickness_values;
545 double *thickness_values = NULL;
546
547 /*Check that input provided is a thickness*/
[9883]548 if (thickness_input->InstanceEnum()!=ThicknessEnum) _error_("Input provided is not a Thickness (enum_type is %s)",EnumToStringx(thickness_input->InstanceEnum()));
[4471]549
550 /*Get Thickness value pointer*/
551 thickness_input->GetValuesPtr(&thickness_values,&num_thickness_values);
552
553 /*vertically integrate depending on type:*/
[9883]554 switch(thickness_input->ObjectEnum()){
[4471]555
[11291]556 case PentaP1InputEnum:
[4471]557 for(i=0;i<3;i++){
558 this->values[i]=0.5*(this->values[i]+this->values[i+3]) * thickness_values[i];
559 this->values[i+3]=this->values[i];
560 }
561 return;
562
563 default:
[6412]564 _error_("not implemented yet");
[4471]565 }
566}
567/*}}}*/
[11291]568/*FUNCTION PentaP1Input::PointwiseDivide{{{1*/
569Input* PentaP1Input::PointwiseDivide(Input* inputB){
[4471]570
571 /*Ouput*/
[11291]572 PentaP1Input* outinput=NULL;
[4471]573
574 /*Intermediaries*/
575 int i;
[11291]576 PentaP1Input *xinputB = NULL;
[4471]577 int B_numvalues;
[8303]578 const int numnodes = 6;
579 double AdotBvalues[numnodes];
[4471]580
581 /*Check that inputB is of the same type*/
[11291]582 if (inputB->ObjectEnum()!=PentaP1InputEnum) _error_("Operation not permitted because inputB is of type %s",EnumToStringx(inputB->ObjectEnum()));
583 xinputB=(PentaP1Input*)inputB;
[4471]584
585 /*Create point wise sum*/
[8303]586 for(i=0;i<numnodes;i++){
[6412]587 _assert_(xinputB->values[i]!=0);
[4471]588 AdotBvalues[i]=this->values[i]/xinputB->values[i];
589 }
590
[4899]591 /*Create new Penta vertex input (copy of current input)*/
[11291]592 outinput=new PentaP1Input(this->enum_type,&AdotBvalues[0]);
[4471]593
594 /*Return output pointer*/
595 return outinput;
596
597}
598/*}}}*/
[11291]599/*FUNCTION PentaP1Input::PointwiseMin{{{1*/
600Input* PentaP1Input::PointwiseMin(Input* inputB){
[8129]601
602 /*Ouput*/
[11291]603 PentaP1Input* outinput=NULL;
[8129]604
605 /*Intermediaries*/
606 int i;
[11291]607 PentaP1Input *xinputB = NULL;
[8129]608 int B_numvalues;
[8303]609 const int numnodes = 6;
610 double minvalues[numnodes];
[8129]611
612 /*Check that inputB is of the same type*/
[11291]613 if (inputB->ObjectEnum()!=PentaP1InputEnum) _error_("Operation not permitted because inputB is of type %s",EnumToStringx(inputB->ObjectEnum()));
614 xinputB=(PentaP1Input*)inputB;
[8129]615
616 /*Create point wise min*/
[8303]617 for(i=0;i<numnodes;i++){
[8129]618 if(this->values[i] > xinputB->values[i]) minvalues[i]=xinputB->values[i];
619 else minvalues[i]=this->values[i];
620 }
621
622 /*Create new Penta vertex input (copy of current input)*/
[11291]623 outinput=new PentaP1Input(this->enum_type,&minvalues[0]);
[8129]624
625 /*Return output pointer*/
626 return outinput;
627
628}
629/*}}}*/
[11291]630/*FUNCTION PentaP1Input::PointwiseMax{{{1*/
631Input* PentaP1Input::PointwiseMax(Input* inputB){
[8129]632
633 /*Ouput*/
[11291]634 PentaP1Input* outinput=NULL;
[8129]635
636 /*Intermediaries*/
637 int i;
[11291]638 PentaP1Input *xinputB = NULL;
[8129]639 int B_numvalues;
[8303]640 const int numnodes = 6;
641 double maxvalues[numnodes];
[8129]642
643 /*Check that inputB is of the same type*/
[11291]644 if (inputB->ObjectEnum()!=PentaP1InputEnum) _error_("Operation not permitted because inputB is of type %s",EnumToStringx(inputB->ObjectEnum()));
645 xinputB=(PentaP1Input*)inputB;
[8129]646
647 /*Create point wise max*/
[8303]648 for(i=0;i<numnodes;i++){
[8129]649 if(this->values[i] < xinputB->values[i]) maxvalues[i]=xinputB->values[i];
650 else maxvalues[i]=this->values[i];
651 }
652
653 /*Create new Penta vertex input (copy of current input)*/
[11291]654 outinput=new PentaP1Input(this->enum_type,&maxvalues[0]);
[8129]655
656 /*Return output pointer*/
657 return outinput;
658
659}
660/*}}}*/
[11291]661/*FUNCTION PentaP1Input::GetVectorFromInputs{{{1*/
662void PentaP1Input::GetVectorFromInputs(Vec vector,int* doflist){
[4048]663
664 const int numvertices=6;
[4502]665 VecSetValues(vector,numvertices,doflist,(const double*)this->values,INSERT_VALUES);
[4048]666
[4502]667} /*}}}*/
[11291]668/*FUNCTION PentaP1Input::GetValuesPtr{{{1*/
669void PentaP1Input::GetValuesPtr(double** pvalues,int* pnum_values){
[4055]670
671 *pvalues=this->values;
672 *pnum_values=6;
673
674}
675/*}}}*/
[11291]676/*FUNCTION PentaP1Input::Configure{{{1*/
677void PentaP1Input::Configure(Parameters* parameters){
[8363]678 /*do nothing: */
679}
680/*}}}*/
Note: See TracBrowser for help on using the repository browser.