Changeset 23501
- Timestamp:
- 12/02/18 15:34:43 (6 years ago)
- Location:
- issm/trunk-jpl/src/c
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/c/classes/AdaptiveMeshRefinement.cpp
r23471 r23501 15 15 /*Constructor, copy, clean up and destructor*/ 16 16 AdaptiveMeshRefinement::AdaptiveMeshRefinement(){/*{{{*/ 17 this->Initialize(); 17 18 /*Set pointers to NULL*/ 19 this->fathermesh = NULL; 20 this->previousmesh = NULL; 21 this->refinement_type = -1; 22 this->level_max = -1; 23 this->gradation = -1; 24 this->lag = -1; 25 this->groundingline_distance = -1; 26 this->icefront_distance = -1; 27 this->thicknesserror_threshold = -1; 28 this->deviatoricerror_threshold = -1; 29 this->deviatoricerror_maximum = -1; 30 this->thicknesserror_maximum = -1; 31 this->sid2index.clear(); 32 this->index2sid.clear(); 33 this->specialelementsindex.clear(); 34 this->x = NULL; 35 this->y = NULL; 36 this->elementslist = NULL; 37 this->numberofvertices = -1; 38 this->numberofelements = -1; 18 39 } 19 40 /*}}}*/ … … 54 75 /*}}}*/ 55 76 AdaptiveMeshRefinement::~AdaptiveMeshRefinement(){/*{{{*/ 56 int writemesh = 1;//itapopo keep 077 int writemesh = 0;//only to restart 57 78 if(writemesh) this->WriteMesh(); 58 79 this->CleanUp(); … … 65 86 if(this->fathermesh) delete this->fathermesh; 66 87 if(this->previousmesh) delete this->previousmesh; 88 if(this->x) delete this->x; 89 if(this->y) delete this->y; 90 if(this->elementslist) delete this->elementslist; 67 91 this->refinement_type = -1; 68 92 this->level_max = -1; … … 75 99 this->deviatoricerror_maximum = -1; 76 100 this->thicknesserror_maximum = -1; 101 this->numberofvertices = -1; 102 this->numberofelements = -1; 77 103 this->sid2index.clear(); 78 104 this->index2sid.clear(); … … 80 106 } 81 107 /*}}}*/ 82 void AdaptiveMeshRefinement::Initialize(){/*{{{*/83 84 /*Set pointers to NULL*/85 this->fathermesh = NULL;86 this->previousmesh = NULL;87 this->refinement_type = -1;88 this->level_max = -1;89 this->gradation = -1;90 this->lag = -1;91 this->groundingline_distance = -1;92 this->icefront_distance = -1;93 this->thicknesserror_threshold = -1;94 this->deviatoricerror_threshold = -1;95 this->deviatoricerror_maximum = -1;96 this->thicknesserror_maximum = -1;97 this->sid2index.clear();98 this->index2sid.clear();99 this->specialelementsindex.clear();100 }101 /*}}}*/102 108 103 109 /*Mesh refinement methods*/ 110 void AdaptiveMeshRefinement::SetMesh(int** elementslist_in,IssmDouble** x_in,IssmDouble** y_in,int* numberofvertices_in,int* numberofelements_in){/*{{{*/ 111 112 /*Delete previous mesh and keep the entire mesh*/ 113 if(this->elementslist) xDelete<int>(this->elementslist); 114 if(this->x) xDelete<IssmDouble>(this->x); 115 if(this->y) xDelete<IssmDouble>(this->y); 116 117 this->elementslist = *elementslist_in; 118 this->x = *x_in; 119 this->y = *y_in; 120 this->numberofvertices = *numberofvertices_in; 121 this->numberofelements = *numberofelements_in; 122 }/*}}}*/ 123 void AdaptiveMeshRefinement::GetMesh(int** elementslist_out,IssmDouble** x_out,IssmDouble** y_out,int* numberofvertices_out,int* numberofelements_out){/*{{{*/ 124 125 /*Get the entire mesh*/ 126 *elementslist_out = this->elementslist; 127 *x_out = this->x; 128 *y_out = this->y; 129 *numberofvertices_out= this->numberofvertices; 130 *numberofelements_out= this->numberofelements; 131 }/*}}}*/ 104 132 void AdaptiveMeshRefinement::ExecuteRefinement(double* gl_distance,double* if_distance,double* deviatoricerror,double* thicknesserror,int** pdatalist,double** pxylist,int** pelementslist){/*{{{*/ 105 133 … … 555 583 } 556 584 /*}}}*/ 557 void AdaptiveMeshRefinement:: CreateInitialMesh(int &nvertices,int &nelements,double* x,double* y,int* elements){/*{{{*/585 void AdaptiveMeshRefinement::Initialize(){/*{{{*/ 558 586 559 587 /* IMPORTANT! elements come in Matlab indexing 560 588 NEOPZ works only in C indexing*/ 561 589 562 if( nvertices<=0) _error_("Impossible to create initial mesh: nvertices is <= 0!\n");563 if( nelements<=0) _error_("Impossible to create initial mesh: nelements is <= 0!\n");590 if(this->numberofvertices<=0) _error_("Impossible to create initial mesh: nvertices is <= 0!\n"); 591 if(this->numberofelements<=0) _error_("Impossible to create initial mesh: nelements is <= 0!\n"); 564 592 if(this->refinement_type!=0 && this->refinement_type!=1) _error_("Impossible to create initial mesh: refinement type is not defined!\n"); 565 593 566 594 /*Verify and creating initial mesh*/ 567 if(this->fathermesh || this->previousmesh) _error_("Initial mesh already exists!"); 595 if(!this->x || !this->y || !this->elementslist) _error_("Mesh data structure is NULL!\n"); 596 if(this->fathermesh || this->previousmesh) _error_("Initial mesh already exists!\n"); 568 597 569 598 this->fathermesh = new TPZGeoMesh(); 570 this->fathermesh->NodeVec().Resize( nvertices);599 this->fathermesh->NodeVec().Resize(this->numberofvertices); 571 600 572 601 /*Set the vertices (geometric nodes in NeoPZ context)*/ 573 for(int i=0;i< nvertices;i++){602 for(int i=0;i<this->numberofvertices;i++){ 574 603 /*x,y,z coords*/ 575 604 TPZManVector<REAL,3> coord(3,0.); 576 coord[0]= x[i];577 coord[1]= y[i];605 coord[0]= this->x[i]; 606 coord[1]= this->y[i]; 578 607 coord[2]= 0.; 579 608 /*Insert in the mesh*/ … … 586 615 const int mat = this->GetElemMaterialID(); 587 616 TPZManVector<long> elem(this->GetNumberOfNodes(),0); 588 this->index2sid.clear(); this->index2sid.resize( nelements);617 this->index2sid.clear(); this->index2sid.resize(this->numberofelements); 589 618 this->sid2index.clear(); 590 619 591 for(int i=0;i< nelements;i++){592 for(int j=0;j<this->GetNumberOfNodes();j++) elem[j]= elements[i*this->GetNumberOfNodes()+j]-1;//Convert Matlab to C indexing620 for(int i=0;i<this->numberofelements;i++){ 621 for(int j=0;j<this->GetNumberOfNodes();j++) elem[j]=this->elementslist[i*this->GetNumberOfNodes()+j]-1;//Convert Matlab to C indexing 593 622 switch(this->GetNumberOfNodes()){ 594 623 case 3: this->fathermesh->CreateGeoElement(ETriangle,elem,mat,index,this->refinement_type); break; … … 865 894 std::ifstream amrifstream(amrfile.c_str()); 866 895 int size,value; 867 896 868 897 TPZPersistenceManager::OpenRead(fathermeshfile); 869 898 this->fathermesh = dynamic_cast<TPZGeoMesh *>(TPZPersistenceManager::ReadFromFile()); -
issm/trunk-jpl/src/c/classes/AdaptiveMeshRefinement.h
r23471 r23501 68 68 void Initialize(); 69 69 void ExecuteRefinement(double* gl_distance,double* if_distance,double* deviatoricerror,double* thicknesserror,int** pdatalist,double** pxy,int** pelementslist); 70 void CreateInitialMesh(int &nvertices,int &nelements,double* x,double* y,int* elements); 70 void SetMesh(int** elementslist_in,IssmDouble** x_in,IssmDouble** y_in,int* numberofvertices,int* numberofelements); 71 void GetMesh(int** elementslist_out,IssmDouble** x_out,IssmDouble** y_out,int* numberofvertices,int* numberofelements); 71 72 void CheckMesh(int** pdata,double** pxy,int** pelements); 72 73 void ReadMesh(); … … 80 81 TPZGeoMesh *fathermesh; // Entire mesh without refinement if refinement_type==1; refined with hanging nodes if efinement_type==0 81 82 TPZGeoMesh *previousmesh; // Refined mesh without hanging nodes (it is always refpattern type), used to generate ISSM mesh 83 IssmDouble* x; // Entire mesh 84 IssmDouble* y; 85 int* elementslist; 86 int numberofvertices; 87 int numberofelements; 82 88 /*}}}*/ 83 89 /*Private methods{{{*/ -
issm/trunk-jpl/src/c/classes/AmrBamg.cpp
r23066 r23501 39 39 this->fathermesh = NULL; 40 40 this->previousmesh = NULL; 41 this->elementslist = NULL; 42 this->x = NULL; 43 this->y = NULL; 44 this->numberofvertices = -1; 45 this->numberofelements = -1; 41 46 42 47 /*Only initialize options for now (same as bamg.m)*/ … … 73 78 if(this->previousmesh) delete this->previousmesh; 74 79 if(this->options) delete this->options; 75 80 if(this->x) xDelete<IssmDouble>(this->x); 81 if(this->y) xDelete<IssmDouble>(this->y); 82 if(this->elementslist) xDelete<int>(this->elementslist); 76 83 } 77 84 /*}}}*/ 78 85 79 86 /*Methods*/ 80 void AmrBamg::Initialize(int* elements,IssmDouble* x,IssmDouble* y,int numberofvertices,int numberofelements){/*{{{*/ 87 void AmrBamg::SetMesh(int** elementslist_in,IssmDouble** x_in,IssmDouble** y_in,int* numberofvertices_in,int* numberofelements_in){/*{{{*/ 88 89 /*Delete previous mesh and keep the entire mesh*/ 90 if(this->elementslist) xDelete<int>(this->elementslist); 91 if(this->x) xDelete<IssmDouble>(this->x); 92 if(this->y) xDelete<IssmDouble>(this->y); 93 94 this->elementslist = *elementslist_in; 95 this->x = *x_in; 96 this->y = *y_in; 97 this->numberofvertices = *numberofvertices_in; 98 this->numberofelements = *numberofelements_in; 99 }/*}}}*/ 100 void AmrBamg::GetMesh(int** elementslist_out,IssmDouble** x_out,IssmDouble** y_out,int* numberofvertices_out,int* numberofelements_out){/*{{{*/ 101 102 /*Get the entire mesh*/ 103 *elementslist_out = this->elementslist; 104 *x_out = this->x; 105 *y_out = this->y; 106 *numberofvertices_out= this->numberofvertices; 107 *numberofelements_out= this->numberofelements; 108 }/*}}}*/ 109 void AmrBamg::Initialize(){/*{{{*/ 81 110 82 111 /*Check options*/ … … 85 114 86 115 /*Read father mesh and create geometry*/ 87 Mesh* Th=new Mesh( elements,x,y,numberofvertices,numberofelements,this->options);116 Mesh* Th=new Mesh(this->elementslist,this->x,this->y,this->numberofvertices,this->numberofelements,this->options); 88 117 89 118 /*Write geometry*/ … … 99 128 }/*}}}*/ 100 129 void AmrBamg::ExecuteRefinementBamg(IssmDouble* field,IssmDouble* hmaxVertices,int** pdatalist,IssmDouble** pxylist,int** pelementslist){/*{{{*/ 101 130 102 131 /*Intermediaries*/ 103 132 BamgGeom* geomout=new BamgGeom(); … … 113 142 this->options->field = field; 114 143 this->options->hmaxVertices = hmaxVertices; 115 144 116 145 /*remesh*/ 117 146 if(this->previousmesh){ -
issm/trunk-jpl/src/c/classes/AmrBamg.h
r23469 r23501 28 28 IssmDouble deviatoricerror_maximum; 29 29 30 30 31 /* Constructor, destructor etc*/ 31 32 AmrBamg(); … … 34 35 35 36 /*General methods*/ 36 void Initialize(int* elements,IssmDouble* x,IssmDouble* y,int numberofvertices,int numberofelements); 37 void Initialize(); 38 void SetMesh(int** elementslist_in,IssmDouble** x_in,IssmDouble** y_in,int* numberofvertices,int* numberofelements); 39 void GetMesh(int** elementslist_out,IssmDouble** x_out,IssmDouble** y_out,int* numberofvertices,int* numberofelements); 37 40 void ExecuteRefinementBamg(IssmDouble* field,IssmDouble* hmaxVertices,int** pdatalist,IssmDouble** pxylist,int** pelementslist); 38 41 void SetBamgOpts(IssmDouble hmin_in,IssmDouble hmax_in,IssmDouble err_in,IssmDouble gradation_in); … … 46 49 BamgMesh* previousmesh; 47 50 BamgOpts* options; 51 /*entire mesh*/ 52 IssmDouble* x; 53 IssmDouble* y; 54 int* elementslist; 55 int numberofvertices; 56 int numberofelements; 48 57 }; 49 58 -
issm/trunk-jpl/src/c/classes/FemModel.cpp
r23500 r23501 2719 2719 /*Finally: interpolate all inputs and insert them into the new elements.*/ 2720 2720 this->InterpolateInputs(new_vertices,new_elements); 2721 2721 2722 2722 /*Delete old structure and set new pointers*/ 2723 2723 delete this->vertices; this->vertices = new_vertices; … … 2749 2749 SetCurrentConfiguration(analysis_type); 2750 2750 2751 /*Set the new mesh*/ 2752 this->SetMesh(&newelementslist,&newx,&newy,&newnumberofvertices,&newnumberofelements); 2753 2751 2754 /*Cleanup*/ 2752 xDelete<IssmDouble>(newx);2753 xDelete<IssmDouble>(newy);2754 2755 xDelete<IssmDouble>(newz); 2755 xDelete<int>(newelementslist);2756 2756 xDelete<int>(my_vertices); 2757 2757 xDelete<bool>(my_elements); … … 2967 2967 void FemModel::InterpolateInputs(Vertices* newfemmodel_vertices,Elements* newfemmodel_elements){/*{{{*/ 2968 2968 2969 int numberofelements = this->elements->NumberOfElements();//global, entire old mesh2969 int numberofelements = -1; //global, entire old mesh 2970 2970 int newnumberofelements = newfemmodel_elements->Size(); //just on the new partition 2971 int numberofvertices = this->vertices->NumberOfVertices();//global, entire old mesh2971 int numberofvertices = -1; //global, entire old mesh 2972 2972 int newnumberofvertices = newfemmodel_vertices->Size(); //just on the new partition 2973 2973 int elementswidth = this->GetElementsWidth(); //just tria in this version … … 2986 2986 IssmDouble* x = NULL;//global, entire old mesh 2987 2987 IssmDouble* y = NULL;//global, entire old mesh 2988 IssmDouble* z = NULL;//global, entire old mesh2989 2988 int* elementslist = NULL;//global, entire old mesh 2990 2989 IssmDouble* newx = NULL;//just on the new partition … … 3000 2999 3001 3000 /*Get the old mesh (global, entire mesh)*/ 3002 this->GetMesh( this->vertices,this->elements,&x,&y,&z,&elementslist);3001 this->GetMesh(&elementslist,&x,&y,&numberofvertices,&numberofelements); 3003 3002 3004 3003 /*Get the new mesh (just on the new partition)*/ … … 3065 3064 xDelete<int>(P1input_enums); 3066 3065 xDelete<int>(P1input_interp); 3067 xDelete<IssmDouble>(x);3068 xDelete<IssmDouble>(y);3069 xDelete<IssmDouble>(z);3070 xDelete<int>(elementslist);3071 3066 xDelete<IssmDouble>(newx); 3072 3067 xDelete<IssmDouble>(newy); … … 3090 3085 IssmDouble* x = NULL; 3091 3086 IssmDouble* y = NULL; 3092 IssmDouble* z = NULL;3093 3087 int* elementslist = NULL; 3094 3088 … … 3097 3091 parameters->FindParam(&step,StepEnum); 3098 3092 parameters->FindParam(&time,TimeEnum); 3099 numberofelements=this->elements->NumberOfElements();3100 numberofvertices=this->vertices->NumberOfVertices();3101 3093 3102 3094 /*Get mesh. Elementslist comes in Matlab indexing*/ 3103 this->GetMesh( this->vertices,this->elements,&x,&y,&z,&elementslist);3095 this->GetMesh(&elementslist,&x,&y,&numberofvertices,&numberofelements); 3104 3096 3105 3097 /*Write mesh in Results*/ … … 3112 3104 this->results->AddResult(new GenericExternalResult<IssmDouble*>(this->results->Size()+1,MeshYEnum, 3113 3105 y,numberofvertices,1,step,time)); 3114 3115 /*Cleanup*/3116 xDelete<IssmDouble>(x);3117 xDelete<IssmDouble>(y);3118 xDelete<IssmDouble>(z);3119 xDelete<int>(elementslist);3120 3106 } 3121 3107 /*}}}*/ … … 3326 3312 } 3327 3313 /*}}}*/ 3328 void FemModel::GetMesh(Vertices* femmodel_vertices, Elements* femmodel_elements,IssmDouble** px, IssmDouble** py, IssmDouble** pz,int** pelementslist){/*{{{*/3314 void FemModel::GetMesh(Vertices* femmodel_vertices, Elements* femmodel_elements,IssmDouble** px, IssmDouble** py, int** pelementslist){/*{{{*/ 3329 3315 3330 3316 if(!femmodel_vertices) _error_("GetMesh: vertices are NULL."); … … 3383 3369 *px = x; 3384 3370 *py = y; 3385 *pz = z;3386 3371 *pelementslist = elementslist; //Matlab indexing. InterMesh uses this type. 3387 3372 … … 3391 3376 xDelete<IssmDouble>(id2); 3392 3377 xDelete<IssmDouble>(id3); 3378 xDelete<IssmDouble>(z); 3393 3379 delete vid1; 3394 3380 delete vid2; … … 3396 3382 } 3397 3383 /*}}}*/ 3384 void FemModel::GetMesh(int** elementslist, IssmDouble** x, IssmDouble** y, int* numberofvertices, int* numberofelements){/*{{{*/ 3385 3386 int amrtype; 3387 this->parameters->FindParam(&amrtype,AmrTypeEnum); 3388 3389 switch(amrtype){ 3390 3391 #if defined(_HAVE_NEOPZ_) 3392 case AmrNeopzEnum: this->amr->GetMesh(elementslist,x,y,numberofvertices,numberofelements); break; 3393 #endif 3394 3395 #if defined(_HAVE_BAMG_) 3396 case AmrBamgEnum: this->amrbamg->GetMesh(elementslist,x,y,numberofvertices,numberofelements); break; 3397 #endif 3398 3399 default: _error_("not implemented yet"); 3400 } 3401 }/*}}}*/ 3402 void FemModel::SetMesh(int** elementslist, IssmDouble** x, IssmDouble** y, int* numberofvertices, int* numberofelements){/*{{{*/ 3403 3404 int amrtype; 3405 this->parameters->FindParam(&amrtype,AmrTypeEnum); 3406 3407 switch(amrtype){ 3408 3409 #if defined(_HAVE_NEOPZ_) 3410 case AmrNeopzEnum: this->amr->SetMesh(elementslist,x,y,numberofvertices,numberofelements); break; 3411 #endif 3412 3413 #if defined(_HAVE_BAMG_) 3414 case AmrBamgEnum: this->amrbamg->SetMesh(elementslist,x,y,numberofvertices,numberofelements); break; 3415 #endif 3416 3417 default: _error_("not implemented yet"); 3418 } 3419 }/*}}}*/ 3398 3420 void FemModel::GetMeshOnPartition(Vertices* femmodel_vertices,Elements* femmodel_elements,IssmDouble** px,IssmDouble** py,IssmDouble** pz,int** pelementslist,int** psidtoindex){/*{{{*/ 3399 3421 … … 3460 3482 int analysis_index = AnalysisIndex(analysis_enum); 3461 3483 3462 int numberofnodes_analysistype= 3484 int numberofnodes_analysistype= this->nodes_list[analysis_index]->NumberOfNodes(); 3463 3485 int dofpernode = 2; //vx and vy 3464 3486 int numberofcols = dofpernode*2; //to keep dofs and flags in the vspc vector 3465 int numberofvertices = this->vertices->NumberOfVertices();//global, entire old mesh3466 int numberofelements = this->elements->NumberOfElements();//global, entire old mesh3487 int numberofvertices = -1; //global, entire old mesh 3488 int numberofelements = -1; //global, entire old mesh 3467 3489 int newnumberofvertices = newfemmodel_vertices->Size(); //local, just the new partition 3468 3490 int count = 0; 3469 3491 IssmDouble* x = NULL; //global, entire old mesh 3470 3492 IssmDouble* y = NULL; //global, entire old mesh 3471 IssmDouble* z = NULL; //global, entire old mesh3472 3493 int* elementslist = NULL; //global, entire old mesh 3473 3494 IssmDouble* spc = NULL; //global, entire old mesh … … 3479 3500 3480 3501 /*Get old mesh (global, entire mesh). Elementslist comes in Matlab indexing*/ 3481 this->GetMesh( this->vertices,this->elements,&x,&y,&z,&elementslist);3502 this->GetMesh(&elementslist,&x,&y,&numberofvertices,&numberofelements); 3482 3503 3483 3504 /*Get vertices coordinates of the new partition*/ … … 3545 3566 } 3546 3567 } 3547 3568 3548 3569 /*Cleanup*/ 3549 xDelete<IssmDouble>(x);3550 xDelete<IssmDouble>(y);3551 xDelete<IssmDouble>(z);3552 xDelete<int>(elementslist);3553 3570 xDelete<IssmDouble>(spc); 3554 3571 xDelete<IssmDouble>(newspc); … … 5077 5094 IssmDouble* x = NULL; 5078 5095 IssmDouble* y = NULL; 5079 IssmDouble* z = NULL;5080 5096 int* elements = NULL; 5081 5097 IssmDouble hmin,hmax,err,gradation; … … 5088 5104 5089 5105 /*Get vertices coordinates of the coarse mesh (father mesh)*/ 5090 this->GetMesh(this->vertices,this->elements,&x,&y,& z,&elements);5106 this->GetMesh(this->vertices,this->elements,&x,&y,&elements); 5091 5107 5092 5108 /*Create bamg data structures for bamg*/ … … 5116 5132 5117 5133 /*Re-create original mesh and put it in bamg structure (only cpu 0)*/ 5134 this->amrbamg->SetMesh(&elements,&x,&y,&numberofvertices,&numberofelements); 5118 5135 if(my_rank==0){ 5119 this->amrbamg->Initialize(elements,x,y,numberofvertices,numberofelements); 5120 } 5121 5122 /*Free the vectors*/ 5123 xDelete<IssmDouble>(x); 5124 xDelete<IssmDouble>(y); 5125 xDelete<IssmDouble>(z); 5126 xDelete<int>(elements); 5136 this->amrbamg->Initialize(); 5137 } 5127 5138 } 5128 5139 /*}}}*/ … … 5132 5143 5133 5144 /*Intermediaries*/ 5134 int numberofvertices = this->vertices->NumberOfVertices(); 5135 IssmDouble* verticedistance = NULL; 5145 int numberofvertices = this->vertices->NumberOfVertices(); 5146 Vector<IssmDouble>* vminvertexdistance = new Vector<IssmDouble>(numberofvertices); 5147 IssmDouble* pminvertexdistance = NULL; 5148 IssmDouble* levelset_points = NULL; 5149 IssmDouble x,y; 5136 5150 IssmDouble threshold,resolution; 5151 IssmDouble minvertexdistance,distance; 5152 int sid,numberofpoints; 5137 5153 5138 5154 switch(levelset_type){ … … 5148 5164 } 5149 5165 5150 /*Get vertice distance to zero level set points*/ 5151 this->GetVerticeDistanceToZeroLevelSet(&verticedistance,levelset_type); 5152 if(!verticedistance) _error_("verticedistance is NULL!\n"); 5166 /*Get points which level set is zero (center of elements with zero level set)*/ 5167 this->GetZeroLevelSetPoints(&levelset_points,numberofpoints,levelset_type);//levelset_points is serial (global) 5168 5169 for(int i=0;i<this->vertices->Size();i++){//only on this partition 5170 Vertex* vertex=(Vertex*)this->vertices->GetObjectByOffset(i); 5171 /*Attention: no spherical coordinates*/ 5172 x = vertex->GetX(); 5173 y = vertex->GetY(); 5174 sid= vertex->Sid(); 5175 minvertexdistance=INFINITY; 5176 5177 /*Find the minimum vertex distance*/ 5178 for(int j=0;j<numberofpoints;j++){ 5179 distance=sqrt((x-levelset_points[2*j])*(x-levelset_points[2*j])+(y-levelset_points[2*j+1])*(y-levelset_points[2*j+1])); 5180 minvertexdistance=min(distance,minvertexdistance); 5181 } 5182 /*Now, insert in the vector*/ 5183 vminvertexdistance->SetValue(sid,minvertexdistance,INS_VAL); 5184 } 5185 /*Assemble*/ 5186 vminvertexdistance->Assemble(); 5187 5188 /*Assign the pointer*/ 5189 pminvertexdistance=vminvertexdistance->ToMPISerial(); 5153 5190 5154 5191 /*Fill hmaxVertices*/ 5155 5192 for(int i=0;i<numberofvertices;i++){ 5156 if( verticedistance[i]<threshold){5193 if(pminvertexdistance[i]<threshold){ //hmaxvertices is serial (global) 5157 5194 if(xIsNan<IssmDouble>(hmaxvertices[i])) hmaxvertices[i]=resolution; 5158 5195 else hmaxvertices[i]=min(resolution,hmaxvertices[i]); … … 5161 5198 5162 5199 /*Cleanup*/ 5163 xDelete<IssmDouble>(verticedistance); 5200 xDelete<IssmDouble>(pminvertexdistance); 5201 xDelete<IssmDouble>(levelset_points); 5202 delete vminvertexdistance; 5164 5203 } 5165 5204 /*}}}*/ … … 5170 5209 /*Intermediaries*/ 5171 5210 int elementswidth = this->GetElementsWidth(); 5172 int numberofelements = this->elements->NumberOfElements();5173 int numberofvertices = this->vertices->NumberOfVertices();5211 int numberofelements = -1; 5212 int numberofvertices = -1; 5174 5213 IssmDouble hmax = this->amrbamg->GetBamgOpts()->hmax; 5175 IssmDouble* maxlength = xNew<IssmDouble>(numberofelements);5176 IssmDouble* error_vertices = xNewZeroInit<IssmDouble>(numberofvertices);5214 IssmDouble* maxlength = NULL; 5215 IssmDouble* error_vertices = NULL; 5177 5216 IssmDouble* error_elements = NULL; 5178 5217 IssmDouble* x = NULL; 5179 5218 IssmDouble* y = NULL; 5180 IssmDouble* z = NULL;5181 5219 int* index = NULL; 5182 5220 IssmDouble maxerror,threshold,groupthreshold,resolution,length; … … 5216 5254 5217 5255 /*Get mesh*/ 5218 this->GetMesh(this->vertices,this->elements,&x,&y,&z,&index); 5256 this->GetMesh(&index,&x,&y,&numberofvertices,&numberofelements); 5257 maxlength = xNew<IssmDouble>(numberofelements); 5258 error_vertices = xNewZeroInit<IssmDouble>(numberofvertices); 5219 5259 5220 5260 /*Fill error_vertices (this is the sum of all elements connected to the vertex)*/ … … 5260 5300 5261 5301 /*Cleanup*/ 5262 xDelete<IssmDouble>(x);5263 xDelete<IssmDouble>(y);5264 xDelete<IssmDouble>(z);5265 xDelete<int>(index);5266 5302 xDelete<IssmDouble>(error_elements); 5267 5303 xDelete<IssmDouble>(error_vertices); … … 5270 5306 /*}}}*/ 5271 5307 void FemModel::GetVerticeDistanceToZeroLevelSet(IssmDouble** pverticedistance,int levelset_type){/*{{{*/ 5308 5309 //itapopo esse metodo pode ser deletado 5310 5272 5311 5273 5312 /*Here, "zero level set" means grounding line or ice front, depending on the level set type*/ … … 5281 5320 5282 5321 /*Intermediaries*/ 5283 int numberofvertices = this->vertices->NumberOfVertices(); 5322 int numberofvertices = -1; 5323 int numberofelements = -1; 5284 5324 IssmDouble* levelset_points= NULL; 5285 5325 IssmDouble* x = NULL; 5286 5326 IssmDouble* y = NULL; 5287 IssmDouble* z = NULL; 5327 int* elementslist = NULL; 5288 5328 int numberofpoints; 5289 5329 IssmDouble distance; 5290 5330 5291 5331 /*Get vertices coordinates*/ 5292 VertexCoordinatesx(&x,&y,&z,this->vertices,false) ; 5332 this->GetMesh(&elementslist,&x,&y,&numberofvertices,&numberofelements); 5333 //this->GetMeshOnPartition(this->vertices,this->elements,&x,&y,&z,&elementslist,&sidtoindex); 5293 5334 5294 5335 /*Get points which level set is zero (center of elements with zero level set)*/ … … 5310 5351 /*Cleanup*/ 5311 5352 xDelete<IssmDouble>(levelset_points); 5312 xDelete<IssmDouble>(x);5313 xDelete<IssmDouble>(y);5314 xDelete<IssmDouble>(z);5315 5353 } 5316 5354 /*}}}*/ … … 5393 5431 IssmDouble* x = NULL; 5394 5432 IssmDouble* y = NULL; 5395 IssmDouble* z = NULL;5396 5433 int* elements = NULL; 5397 5434 int amr_restart; … … 5402 5439 /*Get vertices coordinates of the coarse mesh (father mesh)*/ 5403 5440 /*elements comes in Matlab indexing*/ 5404 this->GetMesh(this->vertices,this->elements,&x,&y,& z,&elements);5441 this->GetMesh(this->vertices,this->elements,&x,&y,&elements); 5405 5442 5406 5443 /*Create initial mesh (coarse mesh) in neopz data structure*/ … … 5422 5459 this->parameters->FindParam(&this->amr->deviatoricerror_groupthreshold,AmrDeviatoricErrorGroupThresholdEnum); 5423 5460 this->parameters->FindParam(&this->amr->deviatoricerror_maximum,AmrDeviatoricErrorMaximumEnum); 5461 5462 /*Initialize NeoPZ data structure*/ 5463 this->amr->SetMesh(&elements,&x,&y,&numberofvertices,&numberofelements); 5424 5464 if(my_rank==0){ 5425 5465 this->parameters->FindParam(&amr_restart,AmrRestartEnum); … … 5427 5467 this->amr->ReadMesh(); 5428 5468 } else {//this is the default method 5429 this->amr->CreateInitialMesh(numberofvertices,numberofelements,x,y,elements); 5430 } 5431 } 5432 5433 /*Free the vectors*/ 5434 xDelete<IssmDouble>(x); 5435 xDelete<IssmDouble>(y); 5436 xDelete<IssmDouble>(z); 5437 xDelete<int>(elements); 5469 this->amr->Initialize(); 5470 } 5471 } 5438 5472 } 5439 5473 /*}}}*/ -
issm/trunk-jpl/src/c/classes/FemModel.h
r23493 r23501 174 174 void BedrockFromMismipPlus(void); 175 175 void AdjustBaseThicknessAndMask(void); 176 void GetMesh(Vertices* femmodel_vertices,Elements* femmodel_elements,IssmDouble** px, IssmDouble** py, IssmDouble** pz, int** pelementslist); 176 void GetMesh(Vertices* femmodel_vertices,Elements* femmodel_elements,IssmDouble** px, IssmDouble** py, int** pelementslist); 177 void GetMesh(int** elementslist, IssmDouble** x, IssmDouble** y, int* numberofvertices, int* numberofelements); 178 void SetMesh(int** elementslist, IssmDouble** x, IssmDouble** y, int* numberofvertices, int* numberofelements); 177 179 void GetMeshOnPartition(Vertices* femmodel_vertices,Elements* femmodel_elements,IssmDouble** px, IssmDouble** py, IssmDouble** pz, int** pelementslist,int** psidtoindex); 178 180 void GetGroundediceLevelSet(IssmDouble** pmasklevelset); -
issm/trunk-jpl/src/c/cores/transient_core.cpp
r23485 r23501 101 101 IssmDouble* lat_ice = NULL; 102 102 IssmDouble* lon_ice = NULL; 103 IssmDouble* z_ice = NULL;104 103 IssmDouble* icebase = NULL; 105 104 IssmDouble* icemask = NULL; … … 143 142 144 143 /*Interpolate ice base and mask onto ocean grid*/ 145 femmodel->GetMesh(femmodel->vertices,femmodel->elements,&x_ice,&y_ice,& z_ice,&index_ice);144 femmodel->GetMesh(femmodel->vertices,femmodel->elements,&x_ice,&y_ice,&index_ice); 146 145 BamgTriangulatex(&index_ocean,&nels_ocean,oceangridx,oceangridy,ngrids_ocean); 147 146 femmodel->vertices->LatLonList(&lat_ice,&lon_ice); … … 194 193 xDelete<IssmDouble>(x_ice); 195 194 xDelete<IssmDouble>(y_ice); 196 xDelete<IssmDouble>(z_ice);197 195 xDelete<IssmDouble>(icebase_oceangrid); 198 196 xDelete<IssmDouble>(oceangridx); … … 271 269 IssmDouble *lat_ice = NULL; 272 270 IssmDouble *lon_ice = NULL; 273 IssmDouble *z_ice = NULL;274 271 IssmDouble *icebase = NULL; 275 272 IssmDouble *icemask = NULL; … … 282 279 /*Recover mesh and inputs needed*/ 283 280 femmodel->parameters->FindParam(&rho_ice,MaterialsRhoIceEnum); 284 femmodel->GetMesh(femmodel->vertices,femmodel->elements,&x_ice,&y_ice,& z_ice,&index_ice);281 femmodel->GetMesh(femmodel->vertices,femmodel->elements,&x_ice,&y_ice,&index_ice); 285 282 femmodel->parameters->FindParam(&oceangridx,&ngrids_ocean,OceanGridXEnum); 286 283 femmodel->parameters->FindParam(&oceangridy,&ngrids_ocean,OceanGridYEnum); … … 354 351 xDelete<IssmDouble>(x_ice); 355 352 xDelete<IssmDouble>(y_ice); 356 xDelete<IssmDouble>(z_ice);357 353 xDelete<IssmDouble>(melt_mesh); 358 354 xDelete<IssmDouble>(oceangridx);
Note:
See TracChangeset
for help on using the changeset viewer.