Changeset 23471


Ignore:
Timestamp:
11/20/18 08:19:42 (6 years ago)
Author:
tsantos
Message:

CHG: added write and read mesh in AMR with NeoPZ

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

Legend:

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

    r23469 r23471  
    5454/*}}}*/
    5555AdaptiveMeshRefinement::~AdaptiveMeshRefinement(){/*{{{*/
     56        int writemesh = 1;//itapopo keep 0
     57        if(writemesh) this->WriteMesh();
    5658        this->CleanUp();
    5759        gRefDBase.clear();
     
    856858}
    857859/*}}}*/
     860void AdaptiveMeshRefinement::ReadMesh(){/*{{{*/
     861
     862        std::string fathermeshfile              = "/home/santos/issm_fathermesh.txt";
     863        std::string previousmeshfile    = "/home/santos/issm_previousmesh.txt";
     864        std::string amrfile                             = "/home/santos/issm_amr.txt";
     865        std::ifstream amrifstream(amrfile.c_str());                             
     866        int size,value;
     867       
     868        TPZPersistenceManager::OpenRead(fathermeshfile);
     869        this->fathermesh = dynamic_cast<TPZGeoMesh *>(TPZPersistenceManager::ReadFromFile());
     870        TPZPersistenceManager::CloseRead();
     871       
     872        TPZPersistenceManager::OpenRead(previousmeshfile);
     873        this->previousmesh = dynamic_cast<TPZGeoMesh *>(TPZPersistenceManager::ReadFromFile());
     874   TPZPersistenceManager::CloseRead();
     875
     876        if(!amrifstream.is_open()) _error_("amr ifstream is not open!");
     877        amrifstream.seekg(0);
     878       
     879        this->sid2index.clear();
     880        this->index2sid.clear();
     881        this->specialelementsindex.clear();
     882       
     883        amrifstream>>size;
     884        for(int i=0;i<size;i++){
     885                amrifstream>>value;
     886                this->sid2index.push_back(value);
     887        }
     888       
     889        amrifstream>>size;
     890        for(int i=0;i<size;i++){
     891                amrifstream>>value;
     892                this->index2sid.push_back(value);
     893        }
     894       
     895        amrifstream>>size;
     896        for(int i=0;i<size;i++){
     897                amrifstream>>value;
     898                this->specialelementsindex.push_back(value);
     899        }
     900}
     901/*}}}*/
     902void AdaptiveMeshRefinement::WriteMesh(){/*{{{*/
     903
     904        std::string fathermeshfile              = "/home/santos/issm_fathermesh.txt";
     905        std::string previousmeshfile    = "/home/santos/issm_previousmesh.txt";
     906        std::string amrfile                             = "/home/santos/issm_amr.txt";
     907        std::ofstream amrofstream(amrfile.c_str());                             
     908
     909        if(this->fathermesh){
     910                TPZPersistenceManager::OpenWrite(fathermeshfile);
     911                TPZPersistenceManager::WriteToFile(this->fathermesh);
     912                TPZPersistenceManager::CloseWrite();
     913        }
     914
     915        if(this->previousmesh){
     916                TPZPersistenceManager::OpenWrite(previousmeshfile);
     917                TPZPersistenceManager::WriteToFile(this->previousmesh);
     918                TPZPersistenceManager::CloseWrite();
     919        }
     920
     921        if(this->sid2index.size()>0){
     922                amrofstream << this->sid2index.size() << std::endl;
     923                for(int i=0;i<this->sid2index.size();i++) {
     924                        amrofstream << this->sid2index[i] << std::endl;
     925                }
     926        }
     927       
     928        if(this->index2sid.size()>0){
     929                amrofstream << this->index2sid.size() << std::endl;
     930                for(int i=0;i<this->index2sid.size();i++) {
     931                        amrofstream << this->index2sid[i] << std::endl;
     932                }
     933        }
     934
     935        if(this->specialelementsindex.size()){
     936                amrofstream << this->specialelementsindex.size() << std::endl;
     937                for(int i=0;i<this->specialelementsindex.size();i++) {
     938                        amrofstream << this->specialelementsindex[i] << std::endl;
     939                }
     940        }
     941        amrofstream.flush();
     942        amrofstream.close();
     943}
     944/*}}}*/
  • issm/trunk-jpl/src/c/classes/AdaptiveMeshRefinement.h

    r23469 r23471  
    7070        void CreateInitialMesh(int &nvertices,int &nelements,double* x,double* y,int* elements);
    7171        void CheckMesh(int** pdata,double** pxy,int** pelements);
     72        void ReadMesh();
     73        void WriteMesh();
    7274        /*}}}*/
    7375private:
  • issm/trunk-jpl/src/c/classes/FemModel.cpp

    r23469 r23471  
    53295329        IssmDouble* z                                                                   = NULL;
    53305330        int* elements                                                                   = NULL;
     5331        int amr_restart;
    53315332
    53325333        /*Initialize field as NULL for now*/
     
    53565357        this->parameters->FindParam(&this->amr->deviatoricerror_maximum,AmrDeviatoricErrorMaximumEnum);
    53575358        if(my_rank==0){
    5358                 this->amr->CreateInitialMesh(numberofvertices,numberofelements,x,y,elements);
     5359                this->parameters->FindParam(&amr_restart,AmrRestartEnum);
     5360                if(amr_restart){//experimental
     5361                        this->amr->ReadMesh();
     5362                } else {//this is the default method
     5363                        this->amr->CreateInitialMesh(numberofvertices,numberofelements,x,y,elements);
     5364                }
    53595365        }
    53605366
Note: See TracChangeset for help on using the changeset viewer.