Changeset 21524
- Timestamp:
- 02/06/17 10:39:11 (8 years ago)
- Location:
- issm/trunk-jpl/src/c/classes
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/c/classes/FemModel.cpp
r21523 r21524 3103 3103 output->materials->ResetHooks(); 3104 3104 3105 printf("-------------- file: FemModel.cpp line: %i\n",__LINE__);3106 /*Finally: interpolate all inputs*/3107 this->InterpolateInputs(output);3108 3109 printf("-------------- file: FemModel.cpp line: %i\n",__LINE__);3110 3105 /*do the post-processing of the datasets to get an FemModel that can actually run analyses: */ 3111 3106 int analysis_type; … … 3122 3117 } 3123 3118 3119 /*Finally: interpolate all inputs*/ 3120 printf("-------------- file: FemModel.cpp line: %i\n",__LINE__); 3121 this->InterpolateInputs(output); 3122 3124 3123 /*Reset current configuration: */ 3125 3124 analysis_type=output->analysis_type_list[this->analysis_counter]; … … 3214 3213 printarray(P0inputsold,numelementsold,numP0inputs); 3215 3214 3216 _error_("stop"); 3215 /*========== Deal with P1 inputs ==========*/ 3216 IssmDouble* P1inputsold = xNew<IssmDouble>(numverticesold*numP1inputs); 3217 IssmDouble* P1inputsnew = NULL; 3218 vector = NULL; 3219 3220 for(int i=0;i<numP1inputs;i++){ 3221 printf("Dealing with %s (type: %s)\n",EnumToStringx(P1input_enums[i]),EnumToStringx(P1input_interp[i])); 3222 GetVectorFromInputsx(&vector,this,P1input_enums[i],VertexSIdEnum); 3223 3224 /*Copy vector in matrix*/ 3225 for(int j=0;j<numverticesold;j++) P1inputsold[j*numP1inputs+i] = vector[j]; 3226 xDelete<IssmDouble>(vector); 3227 } 3228 printf("Printing array to make sure it looks alright\n"); 3229 printarray(P1inputsold,numverticesold,numP1inputs); 3230 3217 3231 /*Old mesh coordinates*/ 3218 3232 IssmDouble *Xold = NULL; 3219 3233 IssmDouble *Yold = NULL; 3234 IssmDouble *Zold = NULL; 3220 3235 int *Indexold = NULL; 3236 int *Indexnew = NULL; 3221 3237 IssmDouble *Xnew = NULL; 3222 3238 IssmDouble *Ynew = NULL; 3223 3224 3239 IssmDouble *Znew = NULL; 3240 3241 /*Get the old mesh*/ 3225 3242 printf("-------------- file: FemModel.cpp line: %i\n",__LINE__); 3243 this->GetMesh(this,&Xold,&Yold,&Zold,&Indexold); 3244 3245 /*Get the new mesh*/ 3246 printf("-------------- file: FemModel.cpp line: %i\n",__LINE__); 3247 this->GetMesh(newfemmodel,&Xnew,&Ynew,&Znew,&Indexnew); 3248 3249 printf("-------------- file: FemModel.cpp line: %i\n",__LINE__); 3250 /*Interplate P0 inputs in the new mesh*/ 3226 3251 InterpFromMeshToMesh2dx(&P0inputsnew,Indexold,Xold,Yold,numverticesold,numelementsold, 3227 3252 P0inputsold,numelementsold,numP0inputs, 3228 3253 Xnew,Ynew,numelementsnew,NULL); 3229 3254 3255 printf("Printing array AFTER INTERP - P0 INPUTS - to make sure it looks alright\n"); 3256 printarray(P0inputsnew,numelementsnew,numP0inputs); 3257 3258 /*Interpolate P1 inputs in the new mesh*/ 3259 InterpFromMeshToMesh2dx(&P1inputsnew,Indexold,Xold,Yold,numverticesold,numelementsold, 3260 P1inputsold,numverticesold,numP1inputs, 3261 Xnew,Ynew,numverticesnew,NULL); 3262 3263 printf("Printing array AFTER INTERP - P1 INPUTS - to make sure it looks alright\n"); 3264 printarray(P1inputsnew,numverticesnew,numP1inputs); 3265 3230 3266 _error_("STOP"); 3231 3267 3232 3268 xDelete<IssmDouble>(P0inputsold); 3233 3269 xDelete<IssmDouble>(P0inputsnew); 3234 3270 xDelete<IssmDouble>(P1inputsold); 3271 xDelete<IssmDouble>(P1inputsnew); 3235 3272 3236 3273 _error_("STOP"); … … 3411 3448 3412 3449 int lid=0; 3413 3450 //itapopo use the GetMesh!! 3414 3451 for(int j=0;j<newnumberofvertices;j++){ 3415 3452 if(my_vertices[j]){ … … 3455 3492 } 3456 3493 /*}}}*/ 3494 void FemModel::GetMesh(FemModel* femmodel,IssmDouble** px, IssmDouble** py, IssmDouble** pz, int** pelementslist){/*{{{*/ 3495 3496 if(!femmodel) _error_("GetMesh: NULL femmodel."); 3497 3498 int numberofvertices, numberofelements; 3499 int elementswidth = 3; //itapopo just 2D mesh in this version (just tria elements) 3500 IssmDouble *x = NULL; 3501 IssmDouble *y = NULL; 3502 IssmDouble *z = NULL; 3503 int* elementslist = NULL; 3504 3505 /*Get vertices coordinates*/ 3506 VertexCoordinatesx(&x, &y, &z, femmodel->vertices,false) ; 3507 3508 numberofvertices = femmodel->vertices->NumberOfVertices(); 3509 numberofelements = femmodel->elements->NumberOfElements(); 3510 3511 /*Get element vertices*/ 3512 int* elem_vertices=xNew<int>(elementswidth); 3513 Vector<IssmDouble>* vid1= new Vector<IssmDouble>(numberofelements); 3514 Vector<IssmDouble>* vid2= new Vector<IssmDouble>(numberofelements); 3515 Vector<IssmDouble>* vid3= new Vector<IssmDouble>(numberofelements); 3516 3517 /*Go through elements, and for each element, get vertices*/ 3518 for(int i=0;i<femmodel->elements->Size();i++){ 3519 Element* element=xDynamicCast<Element*>(femmodel->elements->GetObjectByOffset(i)); 3520 element->GetVerticesSidList(elem_vertices); 3521 vid1->SetValue(element->sid,elem_vertices[0],INS_VAL); 3522 vid2->SetValue(element->sid,elem_vertices[1],INS_VAL); 3523 vid3->SetValue(element->sid,elem_vertices[2],INS_VAL); 3524 } 3525 3526 /*Assemble*/ 3527 vid1->Assemble(); 3528 vid2->Assemble(); 3529 vid3->Assemble(); 3530 3531 /*Serialize*/ 3532 IssmDouble *id1 = vid1->ToMPISerial(); 3533 IssmDouble *id2 = vid2->ToMPISerial(); 3534 IssmDouble *id3 = vid3->ToMPISerial(); 3535 3536 /*Construct elements list*/ 3537 elementslist=xNew<int>(numberofelements*elementswidth); 3538 if(numberofelements*elementswidth<0) _error_("numberofelements negative."); 3539 for(int i=0;i<numberofelements;i++){ 3540 std::cout << (int)id1[i]+1 << " " << (int)id2[i]+1 <<" " << (int)id3[i]+1 << std::endl; 3541 elementslist[elementswidth*i+0] = (int)id1[i]+1; //InterpMesh wants Matlab indexing 3542 elementslist[elementswidth*i+1] = (int)id2[i]+1; //InterpMesh wants Matlab indexing 3543 elementslist[elementswidth*i+2] = (int)id3[i]+1; //InterpMesh wants Matlab indexinf 3544 } 3545 3546 /*Assign pointers*/ 3547 *px = x; 3548 *py = y; 3549 *pz = z; 3550 *pelementslist = elementslist; 3551 } 3552 /*}}}*/ 3457 3553 void FemModel::CreateConstraints(int newnumberofvertices,int newnumberofelements,int* newelementslist,IssmDouble* newx,IssmDouble* newy,int* my_vertices,Constraints* constraints){/*{{{*/ 3458 3554 -
issm/trunk-jpl/src/c/classes/FemModel.h
r21516 r21524 149 149 void InitializeAdaptiveRefinement(void); 150 150 FemModel* ReMesh(void); 151 void GetMesh(FemModel* femmodel,IssmDouble** px, IssmDouble** py, IssmDouble** pz, int** pelementslist); 151 152 void ExecuteRefinement(int &newnumberofvertices,int &newnumberofelements,IssmDouble** newx,IssmDouble** newy,IssmDouble** newz,int** newelementslist); 152 153 void GetMaskLevelSet(IssmDouble** pmasklevelset);
Note:
See TracChangeset
for help on using the changeset viewer.