Changeset 24340
- Timestamp:
- 11/16/19 22:35:47 (5 years ago)
- Location:
- issm/trunk-jpl
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/c/classes/Elements/Element.cpp
r24335 r24340 1318 1318 if(!input) _error_("Input " << EnumToStringx(inputenum) << " not found in element"); 1319 1319 input->GetInputValue(pvalue,gauss); 1320 1321 }/*}}}*/1322 void Element::GetInputsInterpolations(Vector<IssmDouble>* interpolations){/*{{{*/1323 1324 int interpolation;1325 1326 /*Go through all inputs and assign interpolation in vector*/1327 _assert_(this->inputs);1328 for(int i=0;i<this->inputs->Size();i++){1329 Input* input=xDynamicCast<Input*>(this->inputs->GetObjectByOffset(i));1330 switch(input->ObjectEnum()){1331 case BoolInputEnum:1332 case DoubleInputEnum:1333 case IntInputEnum:1334 interpolations->SetValue(input->InstanceEnum(),reCast<IssmDouble>(input->ObjectEnum()),INS_VAL);1335 break;1336 case TriaInputEnum:1337 interpolation = input->GetResultInterpolation();1338 interpolations->SetValue(input->InstanceEnum(),interpolation,INS_VAL);1339 break;1340 default:1341 _error_("Input "<<EnumToStringx(input->ObjectEnum())<<" not supported yet");1342 }1343 }1344 1320 1345 1321 }/*}}}*/ -
issm/trunk-jpl/src/c/classes/FemModel.cpp
r24335 r24340 18 18 #include "../analyses/analyses.h" 19 19 #include "./Inputs2/DatasetInput2.h" 20 #include "./Inputs2/ElementInput2.h" 20 21 21 22 #if _HAVE_CODIPACK_ … … 3071 3072 } 3072 3073 3074 /*Creating inputs*/ 3075 Inputs2* new_inputs2=new Inputs2(newnumberofelements,newnumberofvertices); 3076 3073 3077 /*Creating materials*/ 3074 3078 Materials* new_materials=new Materials(); … … 3134 3138 } 3135 3139 3136 ConfigureObjectsx(new_elements,this->loads,new_nodes_list[i],new_vertices,new_materials,this->parameters, this->inputs2);3140 ConfigureObjectsx(new_elements,this->loads,new_nodes_list[i],new_vertices,new_materials,this->parameters,new_inputs2); 3137 3141 SpcNodesx(new_nodes_list[i],new_constraints_list[i],this->parameters); 3138 3142 NodesDofx(new_nodes_list[i],this->parameters); 3139 3143 } 3140 3144 3141 /* Finally: interpolate all inputs and insert them into the new elements.*/3142 this->InterpolateInputs(new_vertices,new_elements );3145 /*Interpolate all inputs and insert them into the new elements.*/ 3146 this->InterpolateInputs(new_vertices,new_elements,new_inputs2); 3143 3147 3144 3148 /*Delete old structure and set new pointers*/ 3145 delete this->vertices; this->vertices = new_vertices; 3146 delete this->elements; this->elements = new_elements; 3147 delete this->materials; this->materials = new_materials; 3149 delete this->inputs2; this->inputs2 = new_inputs2; 3150 delete this->vertices; this->vertices = new_vertices; 3151 delete this->elements; this->elements = new_elements; 3152 delete this->materials; this->materials = new_materials; 3148 3153 if(this->constraints_list && this->nummodels){ 3149 3154 for(int i=0;i<this->nummodels;i++) delete this->constraints_list[i]; … … 3157 3162 this->nodes_list = new_nodes_list; 3158 3163 3164 /*Reset mask*/ 3159 3165 GetMaskOfIceVerticesLSMx0(this); 3160 3166 … … 3268 3274 void FemModel::GetInputs(int* pnumP0inputs,IssmDouble** pP0inputs,int** pP0input_enums,int** pP0input_interp,int* pnumP1inputs,IssmDouble** pP1inputs,int** pP1input_enums,int** pP1input_interp){/*{{{*/ 3269 3275 3270 int maxinputs = MaximumNumberOfDefinitionsEnum; 3271 int numberofvertices = this->vertices->NumberOfVertices(); 3272 int numberofelements = this->elements->NumberOfElements(); 3273 int elementswidth = this->GetElementsWidth(); 3274 int numP0inputs = -1; 3276 int numberofvertices = this->vertices->NumberOfVertices(); 3277 int numberofelements = this->elements->NumberOfElements(); 3278 int elementswidth = this->GetElementsWidth(); 3279 int numinputs,numP0inputs,numP1inputs; 3275 3280 IssmDouble* P0inputs = NULL; 3276 3281 Vector<IssmDouble>* vP0inputs = NULL; 3277 3282 int* P0input_enums = NULL; 3278 3283 int* P0input_interp = NULL; 3279 int numP1inputs = -1;3280 3284 IssmDouble* P1inputs = NULL; 3281 3285 Vector<IssmDouble>* vP1inputs = NULL; 3282 3286 int* P1input_enums = NULL; 3283 3287 int* P1input_interp = NULL; 3284 Vector<IssmDouble>* input_interpolations= NULL;3285 IssmDouble* input_interpolations_serial= NULL;3288 int* input_interpolations = NULL; 3289 int* input_enums = NULL; 3286 3290 int* pos = NULL; 3287 3291 IssmDouble value = 0; 3288 3292 3289 3293 /*Figure out how many inputs we have and their respective interpolation*/ 3290 input_interpolations=new Vector<IssmDouble>(maxinputs); 3291 if(this->elements->Size()){ 3292 Element* element=xDynamicCast<Element*>(this->elements->GetObjectByOffset(0)); 3293 element->GetInputsInterpolations(input_interpolations); 3294 } 3295 3296 /*Assemble and serialize*/ 3297 input_interpolations->Assemble(); 3298 input_interpolations_serial = input_interpolations->ToMPISerial(); 3294 this->inputs2->GetInputsInterpolations(&numinputs,&input_interpolations,&input_enums); 3299 3295 3300 3296 /*Count and get enums of all inputs in old mesh*/ … … 3308 3304 numP0inputs = 0; 3309 3305 numP1inputs = 0; 3310 for(int i=0;i< maxinputs;i++){3311 int inputinterp = reCast<int>(input_interpolations_serial[i]);3306 for(int i=0;i<numinputs;i++){ 3307 int inputinterp = input_interpolations[i]; 3312 3308 switch(inputinterp){ 3313 3309 case 0: … … 3316 3312 case P1Enum: 3317 3313 if(step){ 3318 P1input_enums[numP1inputs] = i ;3314 P1input_enums[numP1inputs] = input_enums[i]; 3319 3315 P1input_interp[numP1inputs] = inputinterp; 3320 3316 } … … 3322 3318 break; 3323 3319 case P0Enum: 3324 case DoubleInputEnum: 3325 case IntInputEnum: 3326 case BoolInputEnum: 3320 case IntInput2Enum: 3321 case BoolInput2Enum: 3327 3322 if(step){ 3328 P0input_enums[numP0inputs] = i ;3323 P0input_enums[numP0inputs] = input_enums[i]; 3329 3324 P0input_interp[numP0inputs] = inputinterp; 3330 3325 } … … 3332 3327 break; 3333 3328 default: 3334 _error_(EnumToStringx(inputinterp)<<" Not supported yet");3329 _error_(EnumToStringx(inputinterp)<<" ("<<inputinterp<<") Not supported yet"); 3335 3330 } 3336 3331 } … … 3346 3341 /*Get P0 inputs*/ 3347 3342 for(int j=0;j<numP0inputs;j++){ 3348 TriaInput* input=xDynamicCast<TriaInput*>(element->GetInput(P0input_enums[j])); 3349 input->GetInputAverage(&value); 3343 switch(P0input_interp[j]){ 3344 case P0Enum:{ 3345 Input2* input=element->GetInput2(P0input_enums[j]); 3346 input->GetInputAverage(&value); 3347 } 3348 break; 3349 case IntInput2Enum:{ 3350 int valueint; 3351 element->GetInput2Value(&valueint,P0input_enums[j]); 3352 value = reCast<IssmDouble>(valueint); 3353 } 3354 break; 3355 case BoolInput2Enum:{ 3356 bool valuebool; 3357 element->GetInput2Value(&valuebool,P0input_enums[j]); 3358 value = reCast<IssmDouble>(valuebool); 3359 } 3360 break; 3361 default: 3362 _error_(EnumToStringx(P0input_interp[j])<<" ("<<P0input_interp[j]<<") Not supported yet"); 3363 } 3350 3364 pos[0]=element->Sid()*numP0inputs+j; 3351 3365 /*Insert input in the vector*/ … … 3355 3369 /*Get P1 inputs*/ 3356 3370 for(int j=0;j<numP1inputs;j++){ 3357 TriaInput* input=xDynamicCast<TriaInput*>(element->GetInput(P1input_enums[j])); 3371 Input2* temp = element->GetInput2(P1input_enums[j]); _assert_(temp); 3372 ElementInput2* input=xDynamicCast<ElementInput2*>(temp); 3358 3373 pos[0]=element->vertices[0]->Sid()*numP1inputs+j; 3359 3374 pos[1]=element->vertices[1]->Sid()*numP1inputs+j; 3360 3375 pos[2]=element->vertices[2]->Sid()*numP1inputs+j; 3361 3376 /*Insert input in the vector*/ 3362 vP1inputs->SetValues(elementswidth,pos,input-> values,INS_VAL);3377 vP1inputs->SetValues(elementswidth,pos,input->element_values,INS_VAL); 3363 3378 } 3364 3379 } … … 3381 3396 3382 3397 /*Cleanup*/ 3383 delete input_interpolations;3384 3398 delete vP0inputs; 3385 3399 delete vP1inputs; 3386 xDelete< IssmDouble>(input_interpolations_serial);3400 xDelete<int>(input_interpolations); 3387 3401 xDelete<int>(pos); 3388 3402 } 3389 3403 /*}}}*/ 3390 void FemModel::InterpolateInputs(Vertices* newfemmodel_vertices,Elements* newfemmodel_elements ){/*{{{*/3404 void FemModel::InterpolateInputs(Vertices* newfemmodel_vertices,Elements* newfemmodel_elements,Inputs2* newinputs2){/*{{{*/ 3391 3405 3392 3406 int numberofelements = -1; //global, entire old mesh … … 3449 3463 3450 3464 /*Insert P0 and P1 inputs into the new elements (just on the new partition)*/ 3465 int vertexlids[3]; 3451 3466 values=xNew<IssmDouble>(elementswidth); 3452 3467 for(int i=0;i<newfemmodel_elements->Size();i++){//just on the new partition 3453 3468 Element* element=xDynamicCast<Element*>(newfemmodel_elements->GetObjectByOffset(i)); 3454 _error_("not supported");3455 3469 /*newP0inputs is just on the new partition*/ 3456 3470 for(int j=0;j<numP0inputs;j++){ 3457 3471 switch(P0input_interp[j]){ 3458 3472 case P0Enum: 3459 case DoubleInputEnum: 3460 element->AddInput(new DoubleInput(P0input_enums[j],newP0inputs[i*numP0inputs+j])); 3473 element->SetElementInput(newinputs2,P0input_enums[j],newP0inputs[i*numP0inputs+j]); 3461 3474 break; 3462 case IntInputEnum: 3463 element->SetIntInput(this->inputs2,P0input_enums[j],reCast<int>(newP0inputs[i*numP0inputs+j])); 3464 element->AddInput(new IntInput(P0input_enums[j],reCast<int>(newP0inputs[i*numP0inputs+j]))); 3475 case IntInput2Enum: 3476 element->SetIntInput(newinputs2,P0input_enums[j],reCast<int>(newP0inputs[i*numP0inputs+j])); 3465 3477 break; 3466 case BoolInputEnum: 3467 element->SetBoolInput(this->inputs2,P0input_enums[j],reCast<bool>(newP0inputs[i*numP0inputs+j])); 3468 element->AddInput(new BoolInput(P0input_enums[j],reCast<bool>(newP0inputs[i*numP0inputs+j]))); 3478 case BoolInput2Enum: 3479 element->SetBoolInput(newinputs2,P0input_enums[j],reCast<bool>(newP0inputs[i*numP0inputs+j])); 3469 3480 break; 3470 3481 default: 3471 _error_(EnumToStringx(P0input_ enums[j])<<" Not supported yet");3482 _error_(EnumToStringx(P0input_interp[j])<<" Not supported yet"); 3472 3483 } 3473 3484 } 3474 3485 /*newP1inputs is just on the new partition*/ 3486 for(int i=0;i<3;i++) vertexlids[i]=element->vertices[i]->lid; 3475 3487 for(int j=0;j<numP1inputs;j++){ 3476 3488 values[0]=newP1inputs[sidtoindex[element->vertices[0]->Sid()]*numP1inputs+j]; 3477 3489 values[1]=newP1inputs[sidtoindex[element->vertices[1]->Sid()]*numP1inputs+j]; 3478 3490 values[2]=newP1inputs[sidtoindex[element->vertices[2]->Sid()]*numP1inputs+j]; 3479 element->inputs->AddInput(new TriaInput(P1input_enums[j],values,P1Enum)); 3480 } 3481 } 3491 newinputs2->SetTriaInput(P1input_enums[j],P1Enum,3,vertexlids,values); 3492 } 3493 } 3494 3482 3495 3483 3496 /*Cleanup*/ … … 3599 3612 3600 3613 /*newlementslist is in Matlab indexing*/ 3601 3614 int lid=0; 3602 3615 for(int i=0;i<newnumberofelements;i++){ 3603 3616 if(my_elements[i]){ … … 3606 3619 newtria->id=i+1; 3607 3620 newtria->sid=i; 3621 newtria->lid=lid++; 3622 newtria->iscollapsed=0; 3623 newtria->isonsurface = true; 3624 newtria->isonbase = true; 3608 3625 newtria->parameters=NULL; 3609 3626 newtria->inputs=new Inputs(); -
issm/trunk-jpl/src/c/classes/FemModel.h
r24335 r24340 199 199 void CreateConstraints(Vertices* newfemmodel_vertices,int analysis_enum,Constraints* newfemmodel_constraints); 200 200 void GetInputs(int* pnumP0inputs,IssmDouble** pP0inputs,int** pP0input_enums,int** pP0input_interp,int* pnumP1inputs,IssmDouble** pP1inputs,int** pP1input_enums,int** pP1input_interp); 201 void InterpolateInputs(Vertices* newfemmodel_vertices,Elements* newfemmodel_elements );201 void InterpolateInputs(Vertices* newfemmodel_vertices,Elements* newfemmodel_elements,Inputs2* new_inputs); 202 202 void UpdateElements(int newnumberofelements,int* newelementslist,bool* my_elements,int analysis_counter,Elements* newelements); 203 203 void WriteMeshInResults(void); -
issm/trunk-jpl/src/c/classes/Inputs2/Inputs2.cpp
r24335 r24340 246 246 } 247 247 /*}}}*/ 248 void Inputs2::GetInputsInterpolations(int* pnuminputs,int** pinterpolations,int** pinputenums){/*{{{*/ 249 250 /*First count number of inputs*/ 251 int count = 0; 252 for(int i=0;i<NUMINPUTS;i++){ 253 if(this->inputs[i]) count++; 254 } 255 int numinputs = count; 256 257 /*Allocate output*/ 258 int* interpolations = xNew<int>(count); 259 int* enumlist = xNew<int>(count); 260 261 /*Go through all inputs and assign interpolation in vector*/ 262 count = 0; 263 for(int i=0;i<NUMINPUTS;i++){ 264 265 Input2* input=this->inputs[i]; 266 if(!input) continue; 267 268 enumlist[count] = i+InputsSTARTEnum+1; 269 switch(input->ObjectEnum()){ 270 case BoolInput2Enum: 271 case IntInput2Enum: 272 interpolations[count] = input->ObjectEnum(); 273 break; 274 case TriaInput2Enum: 275 interpolations[count] = input->GetResultInterpolation(); 276 break; 277 default: 278 _error_("Input "<<EnumToStringx(input->ObjectEnum())<<" not supported yet"); 279 } 280 count++; 281 } 282 _assert_(count == numinputs); 283 284 /*Return pointer*/ 285 *pnuminputs = numinputs; 286 *pinterpolations = interpolations; 287 *pinputenums = enumlist; 288 289 }/*}}}*/ 248 290 SegInput2* Inputs2::GetSegInput(int enum_in){/*{{{*/ 249 291 -
issm/trunk-jpl/src/c/classes/Inputs2/Inputs2.h
r24335 r24340 49 49 void Echo(void); 50 50 bool Exist(int enum_type); 51 void GetInputsInterpolations(int* pnuminputs,int** pinterpolations,int** penum); 51 52 SegInput2* GetSegInput(int enum_type); 52 53 TriaInput2* GetTriaInput(int enum_type);
Note:
See TracChangeset
for help on using the changeset viewer.