Changeset 21524


Ignore:
Timestamp:
02/06/17 10:39:11 (8 years ago)
Author:
tsantos
Message:

CHG: changes in AMR methods: added new method to get mesh by femmodel; changes in InterpolateInputs (NOTE: AMR not working yet).

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

Legend:

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

    r21523 r21524  
    31033103        output->materials->ResetHooks();
    31043104
    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__);
    31103105        /*do the post-processing of the datasets to get an FemModel that can actually run analyses: */
    31113106        int analysis_type;
     
    31223117        }
    31233118
     3119        /*Finally: interpolate all inputs*/
     3120        printf("-------------- file: FemModel.cpp line: %i\n",__LINE__);
     3121        this->InterpolateInputs(output);
     3122       
    31243123        /*Reset current configuration: */
    31253124        analysis_type=output->analysis_type_list[this->analysis_counter];
     
    32143213        printarray(P0inputsold,numelementsold,numP0inputs);
    32153214
    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       
    32173231        /*Old mesh coordinates*/
    32183232        IssmDouble *Xold     = NULL;
    32193233        IssmDouble *Yold     = NULL;
     3234        IssmDouble *Zold                = NULL;
    32203235        int        *Indexold = NULL;
     3236        int        *Indexnew = NULL;
    32213237        IssmDouble *Xnew     = NULL;
    32223238        IssmDouble *Ynew     = NULL;
    3223 
    3224 
     3239        IssmDouble *Znew                = NULL;
     3240       
     3241        /*Get the old mesh*/
    32253242        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*/
    32263251        InterpFromMeshToMesh2dx(&P0inputsnew,Indexold,Xold,Yold,numverticesold,numelementsold,
    32273252                                P0inputsold,numelementsold,numP0inputs,
    32283253                                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       
    32303266        _error_("STOP");
    32313267
    32323268        xDelete<IssmDouble>(P0inputsold);
    32333269        xDelete<IssmDouble>(P0inputsnew);
    3234 
     3270        xDelete<IssmDouble>(P1inputsold);
     3271        xDelete<IssmDouble>(P1inputsnew);
    32353272
    32363273        _error_("STOP");
     
    34113448
    34123449        int lid=0;
    3413 
     3450//itapopo use the GetMesh!!
    34143451        for(int j=0;j<newnumberofvertices;j++){
    34153452                if(my_vertices[j]){                             
     
    34553492}
    34563493/*}}}*/
     3494void 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/*}}}*/
    34573553void FemModel::CreateConstraints(int newnumberofvertices,int newnumberofelements,int* newelementslist,IssmDouble* newx,IssmDouble* newy,int* my_vertices,Constraints* constraints){/*{{{*/
    34583554
  • issm/trunk-jpl/src/c/classes/FemModel.h

    r21516 r21524  
    149149                void InitializeAdaptiveRefinement(void);
    150150                FemModel* ReMesh(void);
     151                void GetMesh(FemModel* femmodel,IssmDouble** px, IssmDouble** py, IssmDouble** pz, int** pelementslist);
    151152                void ExecuteRefinement(int &newnumberofvertices,int &newnumberofelements,IssmDouble** newx,IssmDouble** newy,IssmDouble** newz,int** newelementslist);
    152153                void GetMaskLevelSet(IssmDouble** pmasklevelset);
Note: See TracChangeset for help on using the changeset viewer.