Changeset 23469


Ignore:
Timestamp:
11/17/18 11:53:24 (6 years ago)
Author:
tsantos
Message:

CHG: improving AMR (bamg) with error estimators, and optimizing AMR (neopz)

Location:
issm/trunk-jpl/src/c/classes
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/c/classes/AdaptiveMeshRefinement.cpp

    r23066 r23469  
    264264        if(verbose) _printf_(""<<count<<"\n");
    265265        /*Adjust the connectivities before continue*/
    266         gmesh->BuildConnectivity();
     266        //gmesh->BuildConnectivity(); this is not necessary
    267267        /*}}}*/
    268268
     
    301301        if(verbose) _printf_(""<<count<<"\n");
    302302        /*Adjust the connectivities before continue*/
    303         gmesh->BuildConnectivity();
     303        //gmesh->BuildConnectivity();//this is not necessary
    304304        /*}}}*/
    305305
     
    312312}
    313313/*}}}*/
    314 int AdaptiveMeshRefinement::VerifyRefinementType(TPZGeoEl* geoel){/*{{{*/
     314int AdaptiveMeshRefinement::VerifyRefinementType(TPZGeoEl* geoel,TPZGeoMesh* gmesh){/*{{{*/
    315315
    316316        /*
     
    323323        /*Output*/
    324324        int type=0;
    325         int count=0;
    326325
    327326        /*Intermediaries*/
     
    330329        /*Loop over neighboors (sides 3, 4 and 5)*/
    331330        for(int j=3;j<6;j++){
     331                if(!gmesh->Element(geoel->NeighbourIndex(j))->HasSubElement()) continue;
    332332                sons.clear();
    333                 geoel->Neighbour(j).Element()->GetHigherSubElements(sons);
    334                 if(sons.size()) count++; //if neighbour was refined
    335                 if(sons.size()>4) count++; //if neighbour's level is > element level+1
    336         }
    337 
     333                gmesh->Element(geoel->NeighbourIndex(j))->GetHigherSubElements(sons);
     334                if(sons.size()) type++; //if neighbour was refined
     335                if(sons.size()>4) type++; //if neighbour's level is > element level+1
     336                if(type>1) break;
     337        }
     338       
    338339        /*Verify and return*/
    339         if(count>1) type=2;
    340         else type=count;
     340        if(type>1) type=2;
    341341
    342342        return type;
     
    358358
    359359        count=1;
     360       
    360361        while(count>0){
    361362                count=0;
     
    367368                        if(gmesh->Element(i)->Level()==this->level_max) continue;
    368369                        /*loop over neighboors (sides 3, 4 and 5). Important: neighbours has the same dimension of the element*/
    369                         type=this->VerifyRefinementType(gmesh->Element(i));
     370                        type=this->VerifyRefinementType(gmesh->Element(i),gmesh);
    370371                        if(type<2){
    371372                                typecount=0;
    372373                                for(int j=3;j<6;j++){
    373                                         if(gmesh->Element(i)->Neighbour(j).Element()->HasSubElement()) continue;
    374                                         if(gmesh->Element(i)->Neighbour(j).Element()->Index()==i) typecount++;//neighbour==this element, element at the border
    375                                         if(this->VerifyRefinementType(gmesh->Element(i)->Neighbour(j).Element())==1) typecount++;
     374                                        if(gmesh->Element(gmesh->Element(i)->NeighbourIndex(j))->HasSubElement()) continue;
     375                                        if(gmesh->Element(i)->NeighbourIndex(j)==i) typecount++;//neighbour==this element, element at the border
     376                                        if(this->VerifyRefinementType(gmesh->Element(gmesh->Element(i)->NeighbourIndex(j)),gmesh)==1) typecount++;
     377                                        if(typecount>1 && type==1) type=2;
     378                                        else if(typecount>2 && type==0) type=2;
     379                                        if(type==2) break;
    376380                                }
    377                                 if(typecount>1 && type==1) type=2;
    378                                 else if(typecount>2 && type==0) type=2;
    379381                        }
     382                       
    380383                        /*refine the element if requested*/
    381384                        if(type==2){gmesh->Element(i)->Divide(sons);    count++;}
     
    386389                }
    387390                /*Adjust the connectivities before continue*/
    388                 gmesh->BuildConnectivity();
     391                //gmesh->BuildConnectivity();//this is not necessary
    389392        }
    390393}
     
    424427                        else _printf_(""<<count<<", ");
    425428                }
    426                 gmesh->BuildConnectivity();
     429                //gmesh->BuildConnectivity();//this is not necessary
    427430        }
    428431}
     
    446449        this->specialelementsindex.clear();
    447450        /*Adjust connectivities*/
    448         gmesh->BuildConnectivity();
     451        //gmesh->BuildConnectivity();//this is not necessary
    449452}
    450453/*}}}*/
  • issm/trunk-jpl/src/c/classes/AdaptiveMeshRefinement.h

    r23065 r23469  
    9090        void PrintGMeshVTK(TPZGeoMesh *gmesh,std::ofstream &file,bool matColor=true);
    9191        int GetVTK_ElType(TPZGeoEl* gel);
    92         int VerifyRefinementType(TPZGeoEl* geoel);
     92        int VerifyRefinementType(TPZGeoEl* geoel,TPZGeoMesh* gmesh);
    9393        /*}}}*/
    9494};
  • issm/trunk-jpl/src/c/classes/AmrBamg.h

    r23065 r23469  
    3737                void ExecuteRefinementBamg(IssmDouble* field,IssmDouble* hmaxVertices,int** pdatalist,IssmDouble** pxylist,int** pelementslist);
    3838                void SetBamgOpts(IssmDouble hmin_in,IssmDouble hmax_in,IssmDouble err_in,IssmDouble gradation_in);
    39 
     39               
     40                /*Access Method*/
     41                BamgOpts* GetBamgOpts(){return this->options;}
     42               
    4043        private:
    4144                BamgGeom* geometry;
  • issm/trunk-jpl/src/c/classes/FemModel.cpp

    r23254 r23469  
    51065106        int numberofelements                                            = this->elements->NumberOfElements();
    51075107        int numberofvertices                                            = this->vertices->NumberOfVertices();
     5108        IssmDouble      hmax                                                    = this->amrbamg->GetBamgOpts()->hmax;
    51085109        IssmDouble* maxlength                                   = xNew<IssmDouble>(numberofelements);
    51095110        IssmDouble* error_vertices                              = xNewZeroInit<IssmDouble>(numberofvertices);
     
    51685169        /*Fill hmaxvertices with the criteria*/
    51695170        for(int i=0;i<numberofelements;i++){
    5170                 refine=false;
    51715171                /*Refine any element if its error > phi*maxerror*/
    5172                 if(error_elements[i]>threshold*maxerror) refine=true;
    5173                 /*If the element size is closer to the resolution, verify the sum of error in the vertices*/
    5174                 if(resolution/maxlength[i]>0.85){
     5172                if(error_elements[i]>threshold*maxerror){
     5173                        /*Now, fill the hmaxvertices if requested*/
    51755174                        for(int j=0;j<elementswidth;j++){
    51765175                                vid=index[i*elementswidth+j]-1;//Matlab to C indexing
    5177                                 if(error_vertices[vid]>groupthreshold*maxerror) refine=true;
    5178                         }
    5179                 }
    5180                 /*Now, fill the hmaxvertices if requested*/
    5181                 if(refine){
    5182                         for(int j=0;j<elementswidth;j++){
    5183                                 vid=index[i*elementswidth+j]-1;//Matlab to C indexing
    5184                                 if(xIsNan<IssmDouble>(hmaxvertices[vid])) hmaxvertices[vid]=resolution;
    5185                                 else hmaxvertices[vid]=min(resolution,hmaxvertices[vid]);
    5186                         }
     5176                                if(xIsNan<IssmDouble>(hmaxvertices[vid])) hmaxvertices[vid]=max(maxlength[i]/2.,resolution);//Try first dividing the element
     5177                                else hmaxvertices[vid]=min(max(maxlength[i]/2.,resolution),hmaxvertices[vid]);//Try first dividing the element
     5178                        }
     5179                }
     5180                else {
     5181                        /*Try unrefine the element*/
     5182                        if(maxlength[i] < 1.1*hmax/2.){
     5183                                for(int j=0;j<elementswidth;j++){
     5184                                        vid=index[i*elementswidth+j]-1;//Matlab to C indexing
     5185                                        if(error_vertices[vid]>groupthreshold*maxerror) hmaxvertices[vid]=maxlength[i]; //keep the current resolution
     5186                                        else{
     5187                                                if(xIsNan<IssmDouble>(hmaxvertices[vid])) hmaxvertices[vid]=min(maxlength[i]*2.,hmax);
     5188                                                else hmaxvertices[vid]=min(min(maxlength[i]*2.,hmax),hmaxvertices[vid]);//Try first to duplicate the element
     5189                                        }
     5190                                }
     5191                        }
    51875192                }
    51885193        }
Note: See TracChangeset for help on using the changeset viewer.