Changeset 24340


Ignore:
Timestamp:
11/16/19 22:35:47 (5 years ago)
Author:
Mathieu Morlighem
Message:

CHG: fixing AMR

Location:
issm/trunk-jpl
Files:
6 edited

Legend:

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

    r24335 r24340  
    13181318        if(!input) _error_("Input " << EnumToStringx(inputenum) << " not found in element");
    13191319        input->GetInputValue(pvalue,gauss);
    1320 
    1321 }/*}}}*/
    1322 void       Element::GetInputsInterpolations(Vector<IssmDouble>* interpolations){/*{{{*/
    1323 
    1324         int interpolation;
    1325 
    1326         /*Go through all inputs and assign interpolation in vector*/
    1327         _assert_(this->inputs);
    1328         for(int i=0;i<this->inputs->Size();i++){
    1329                 Input* input=xDynamicCast<Input*>(this->inputs->GetObjectByOffset(i));
    1330                 switch(input->ObjectEnum()){
    1331                         case BoolInputEnum:
    1332                         case DoubleInputEnum:
    1333                         case IntInputEnum:
    1334                                 interpolations->SetValue(input->InstanceEnum(),reCast<IssmDouble>(input->ObjectEnum()),INS_VAL);
    1335                                 break;
    1336                         case TriaInputEnum:
    1337                                 interpolation = input->GetResultInterpolation();
    1338                                 interpolations->SetValue(input->InstanceEnum(),interpolation,INS_VAL);
    1339                                 break;
    1340                         default:
    1341                                 _error_("Input "<<EnumToStringx(input->ObjectEnum())<<" not supported yet");
    1342                 }
    1343         }
    13441320
    13451321}/*}}}*/
  • issm/trunk-jpl/src/c/classes/FemModel.cpp

    r24335 r24340  
    1818#include "../analyses/analyses.h"
    1919#include "./Inputs2/DatasetInput2.h"
     20#include "./Inputs2/ElementInput2.h"
    2021
    2122#if _HAVE_CODIPACK_
     
    30713072        }
    30723073
     3074        /*Creating inputs*/
     3075        Inputs2* new_inputs2=new Inputs2(newnumberofelements,newnumberofvertices);
     3076
    30733077        /*Creating materials*/
    30743078        Materials* new_materials=new Materials();
     
    31343138                }
    31353139
    3136                 ConfigureObjectsx(new_elements,this->loads,new_nodes_list[i],new_vertices,new_materials,this->parameters,this->inputs2);
     3140                ConfigureObjectsx(new_elements,this->loads,new_nodes_list[i],new_vertices,new_materials,this->parameters,new_inputs2);
    31373141                SpcNodesx(new_nodes_list[i],new_constraints_list[i],this->parameters);
    31383142                NodesDofx(new_nodes_list[i],this->parameters);
    31393143        }
    31403144
    3141         /*Finally: interpolate all inputs and insert them into the new elements.*/
    3142         this->InterpolateInputs(new_vertices,new_elements);
     3145        /*Interpolate all inputs and insert them into the new elements.*/
     3146        this->InterpolateInputs(new_vertices,new_elements,new_inputs2);
    31433147
    31443148        /*Delete old structure and set new pointers*/
    3145         delete this->vertices;          this->vertices          = new_vertices;
    3146         delete this->elements;          this->elements          = new_elements;
    3147         delete this->materials;         this->materials = new_materials;
     3149        delete this->inputs2;   this->inputs2 = new_inputs2;
     3150        delete this->vertices;  this->vertices = new_vertices;
     3151        delete this->elements;  this->elements = new_elements;
     3152        delete this->materials; this->materials = new_materials;
    31483153        if(this->constraints_list && this->nummodels){
    31493154                for(int i=0;i<this->nummodels;i++) delete this->constraints_list[i];
     
    31573162        this->nodes_list = new_nodes_list;
    31583163
     3164        /*Reset mask*/
    31593165        GetMaskOfIceVerticesLSMx0(this);
    31603166
     
    32683274void FemModel::GetInputs(int* pnumP0inputs,IssmDouble** pP0inputs,int** pP0input_enums,int** pP0input_interp,int* pnumP1inputs,IssmDouble** pP1inputs,int** pP1input_enums,int** pP1input_interp){/*{{{*/
    32693275
    3270         int maxinputs                                                                           = MaximumNumberOfDefinitionsEnum;
    3271         int numberofvertices                                                            = this->vertices->NumberOfVertices();
    3272         int numberofelements                                                            = this->elements->NumberOfElements();
    3273         int elementswidth                                                                       = this->GetElementsWidth();
    3274         int numP0inputs                                                                 = -1;
     3276        int numberofvertices = this->vertices->NumberOfVertices();
     3277        int numberofelements = this->elements->NumberOfElements();
     3278        int elementswidth    = this->GetElementsWidth();
     3279        int numinputs,numP0inputs,numP1inputs;
    32753280        IssmDouble* P0inputs                                                            = NULL;
    32763281        Vector<IssmDouble>* vP0inputs                                   = NULL;
    32773282        int* P0input_enums                                                              = NULL;
    32783283        int* P0input_interp                                                             = NULL;
    3279         int numP1inputs                                                                 = -1;
    32803284        IssmDouble* P1inputs                                                            = NULL;
    32813285        Vector<IssmDouble>* vP1inputs                                   = NULL;
    32823286        int* P1input_enums                                                              = NULL;
    32833287        int* P1input_interp                                                             = NULL;
    3284         Vector<IssmDouble>* input_interpolations        = NULL;
    3285         IssmDouble* input_interpolations_serial = NULL;
     3288        int* input_interpolations                 = NULL;
     3289        int* input_enums                          = NULL;
    32863290   int* pos                                                                                             = NULL;
    32873291        IssmDouble value                                                                        = 0;
    32883292
    32893293        /*Figure out how many inputs we have and their respective interpolation*/
    3290         input_interpolations=new Vector<IssmDouble>(maxinputs);
    3291         if(this->elements->Size()){
    3292                 Element* element=xDynamicCast<Element*>(this->elements->GetObjectByOffset(0));
    3293                 element->GetInputsInterpolations(input_interpolations);
    3294         }
    3295 
    3296         /*Assemble and serialize*/
    3297         input_interpolations->Assemble();
    3298         input_interpolations_serial = input_interpolations->ToMPISerial();
     3294        this->inputs2->GetInputsInterpolations(&numinputs,&input_interpolations,&input_enums);
    32993295
    33003296        /*Count and get enums of all inputs in old mesh*/
     
    33083304                numP0inputs = 0;
    33093305                numP1inputs = 0;
    3310                 for(int i=0;i<maxinputs;i++){
    3311                         int inputinterp = reCast<int>(input_interpolations_serial[i]);
     3306                for(int i=0;i<numinputs;i++){
     3307                        int inputinterp = input_interpolations[i];
    33123308                        switch(inputinterp){
    33133309                                case 0:
     
    33163312                                case P1Enum:
    33173313                                        if(step){
    3318                                                 P1input_enums[numP1inputs]  = i;
     3314                                                P1input_enums[numP1inputs]  = input_enums[i];
    33193315                                                P1input_interp[numP1inputs] = inputinterp;
    33203316                                        }
     
    33223318                                        break;
    33233319                                case P0Enum:
    3324                                 case DoubleInputEnum:
    3325                                 case IntInputEnum:
    3326                                 case BoolInputEnum:
     3320                                case IntInput2Enum:
     3321                                case BoolInput2Enum:
    33273322                                        if(step){
    3328                                                 P0input_enums[numP0inputs]  = i;
     3323                                                P0input_enums[numP0inputs]  = input_enums[i];
    33293324                                                P0input_interp[numP0inputs] = inputinterp;
    33303325                                        }
     
    33323327                                        break;
    33333328                                default:
    3334                                         _error_(EnumToStringx(inputinterp)<<" Not supported yet");
     3329                                        _error_(EnumToStringx(inputinterp)<<" ("<<inputinterp<<") Not supported yet");
    33353330                        }
    33363331                }
     
    33463341                /*Get P0 inputs*/
    33473342                for(int j=0;j<numP0inputs;j++){
    3348                         TriaInput* input=xDynamicCast<TriaInput*>(element->GetInput(P0input_enums[j]));
    3349                         input->GetInputAverage(&value);
     3343                        switch(P0input_interp[j]){
     3344                                case P0Enum:{
     3345                                        Input2* input=element->GetInput2(P0input_enums[j]);
     3346                                        input->GetInputAverage(&value);
     3347                                }
     3348                                                         break;
     3349                                case IntInput2Enum:{
     3350                                        int valueint;
     3351                                        element->GetInput2Value(&valueint,P0input_enums[j]);
     3352                                        value = reCast<IssmDouble>(valueint);
     3353                                }
     3354                                                                         break;
     3355                                case BoolInput2Enum:{
     3356                                        bool valuebool;
     3357                                        element->GetInput2Value(&valuebool,P0input_enums[j]);
     3358                                        value = reCast<IssmDouble>(valuebool);
     3359                                }
     3360                                        break;
     3361                                default:
     3362                                        _error_(EnumToStringx(P0input_interp[j])<<" ("<<P0input_interp[j]<<") Not supported yet");
     3363                        }
    33503364                        pos[0]=element->Sid()*numP0inputs+j;
    33513365                        /*Insert input in the vector*/
     
    33553369                /*Get P1 inputs*/
    33563370                for(int j=0;j<numP1inputs;j++){
    3357                         TriaInput* input=xDynamicCast<TriaInput*>(element->GetInput(P1input_enums[j]));
     3371                        Input2* temp = element->GetInput2(P1input_enums[j]); _assert_(temp);
     3372                        ElementInput2* input=xDynamicCast<ElementInput2*>(temp);
    33583373                        pos[0]=element->vertices[0]->Sid()*numP1inputs+j;
    33593374                        pos[1]=element->vertices[1]->Sid()*numP1inputs+j;
    33603375                        pos[2]=element->vertices[2]->Sid()*numP1inputs+j;
    33613376                        /*Insert input in the vector*/
    3362                         vP1inputs->SetValues(elementswidth,pos,input->values,INS_VAL);
     3377                        vP1inputs->SetValues(elementswidth,pos,input->element_values,INS_VAL);
    33633378                }
    33643379        }
     
    33813396
    33823397        /*Cleanup*/
    3383         delete input_interpolations;
    33843398        delete vP0inputs;
    33853399        delete vP1inputs;
    3386         xDelete<IssmDouble>(input_interpolations_serial);
     3400        xDelete<int>(input_interpolations);
    33873401        xDelete<int>(pos);
    33883402}
    33893403/*}}}*/
    3390 void FemModel::InterpolateInputs(Vertices* newfemmodel_vertices,Elements* newfemmodel_elements){/*{{{*/
     3404void FemModel::InterpolateInputs(Vertices* newfemmodel_vertices,Elements* newfemmodel_elements,Inputs2* newinputs2){/*{{{*/
    33913405
    33923406        int numberofelements                    = -1;                                                                                           //global, entire old mesh
     
    34493463
    34503464        /*Insert P0 and P1 inputs into the new elements (just on the new partition)*/
     3465        int vertexlids[3];
    34513466        values=xNew<IssmDouble>(elementswidth);
    34523467        for(int i=0;i<newfemmodel_elements->Size();i++){//just on the new partition
    34533468                Element* element=xDynamicCast<Element*>(newfemmodel_elements->GetObjectByOffset(i));
    3454                 _error_("not supported");
    34553469                /*newP0inputs is just on the new partition*/
    34563470                for(int j=0;j<numP0inputs;j++){
    34573471                        switch(P0input_interp[j]){
    34583472                                case P0Enum:
    3459                                 case DoubleInputEnum:
    3460                                         element->AddInput(new DoubleInput(P0input_enums[j],newP0inputs[i*numP0inputs+j]));
     3473                                        element->SetElementInput(newinputs2,P0input_enums[j],newP0inputs[i*numP0inputs+j]);
    34613474                                        break;
    3462                                 case IntInputEnum:
    3463                                         element->SetIntInput(this->inputs2,P0input_enums[j],reCast<int>(newP0inputs[i*numP0inputs+j]));
    3464                                         element->AddInput(new IntInput(P0input_enums[j],reCast<int>(newP0inputs[i*numP0inputs+j])));
     3475                                case IntInput2Enum:
     3476                                        element->SetIntInput(newinputs2,P0input_enums[j],reCast<int>(newP0inputs[i*numP0inputs+j]));
    34653477                                        break;
    3466                                 case BoolInputEnum:
    3467                                         element->SetBoolInput(this->inputs2,P0input_enums[j],reCast<bool>(newP0inputs[i*numP0inputs+j]));
    3468                                         element->AddInput(new BoolInput(P0input_enums[j],reCast<bool>(newP0inputs[i*numP0inputs+j])));
     3478                                case BoolInput2Enum:
     3479                                        element->SetBoolInput(newinputs2,P0input_enums[j],reCast<bool>(newP0inputs[i*numP0inputs+j]));
    34693480                                        break;
    34703481                                default:
    3471                                         _error_(EnumToStringx(P0input_enums[j])<<" Not supported yet");
     3482                                        _error_(EnumToStringx(P0input_interp[j])<<" Not supported yet");
    34723483                        }
    34733484                }
    34743485                /*newP1inputs is just on the new partition*/
     3486                for(int i=0;i<3;i++) vertexlids[i]=element->vertices[i]->lid;
    34753487                for(int j=0;j<numP1inputs;j++){
    34763488                        values[0]=newP1inputs[sidtoindex[element->vertices[0]->Sid()]*numP1inputs+j];
    34773489                        values[1]=newP1inputs[sidtoindex[element->vertices[1]->Sid()]*numP1inputs+j];
    34783490                        values[2]=newP1inputs[sidtoindex[element->vertices[2]->Sid()]*numP1inputs+j];
    3479                         element->inputs->AddInput(new TriaInput(P1input_enums[j],values,P1Enum));
    3480                 }
    3481         }
     3491                        newinputs2->SetTriaInput(P1input_enums[j],P1Enum,3,vertexlids,values);
     3492                }
     3493        }
     3494
    34823495
    34833496        /*Cleanup*/
     
    35993612
    36003613        /*newlementslist is in Matlab indexing*/
    3601 
     3614        int lid=0;
    36023615        for(int i=0;i<newnumberofelements;i++){
    36033616                if(my_elements[i]){
     
    36063619                        newtria->id=i+1;
    36073620                        newtria->sid=i;
     3621                        newtria->lid=lid++;
     3622                        newtria->iscollapsed=0;
     3623                        newtria->isonsurface = true;
     3624                        newtria->isonbase = true;
    36083625                        newtria->parameters=NULL;
    36093626                        newtria->inputs=new Inputs();
  • issm/trunk-jpl/src/c/classes/FemModel.h

    r24335 r24340  
    199199                void CreateConstraints(Vertices* newfemmodel_vertices,int analysis_enum,Constraints* newfemmodel_constraints);
    200200                void GetInputs(int* pnumP0inputs,IssmDouble** pP0inputs,int** pP0input_enums,int** pP0input_interp,int* pnumP1inputs,IssmDouble** pP1inputs,int** pP1input_enums,int** pP1input_interp);
    201                 void InterpolateInputs(Vertices* newfemmodel_vertices,Elements* newfemmodel_elements);
     201                void InterpolateInputs(Vertices* newfemmodel_vertices,Elements* newfemmodel_elements,Inputs2* new_inputs);
    202202                void UpdateElements(int newnumberofelements,int* newelementslist,bool* my_elements,int analysis_counter,Elements* newelements);
    203203                void WriteMeshInResults(void);
  • issm/trunk-jpl/src/c/classes/Inputs2/Inputs2.cpp

    r24335 r24340  
    246246}
    247247/*}}}*/
     248void Inputs2::GetInputsInterpolations(int* pnuminputs,int** pinterpolations,int** pinputenums){/*{{{*/
     249
     250        /*First count number of inputs*/
     251        int count = 0;
     252        for(int i=0;i<NUMINPUTS;i++){
     253                if(this->inputs[i]) count++;
     254        }
     255        int numinputs = count;
     256
     257        /*Allocate output*/
     258        int* interpolations = xNew<int>(count);
     259        int* enumlist       = xNew<int>(count);
     260
     261        /*Go through all inputs and assign interpolation in vector*/
     262        count = 0;
     263        for(int i=0;i<NUMINPUTS;i++){
     264
     265                Input2* input=this->inputs[i];
     266                if(!input) continue;
     267
     268                enumlist[count] = i+InputsSTARTEnum+1;
     269                switch(input->ObjectEnum()){
     270                        case BoolInput2Enum:
     271                        case IntInput2Enum:
     272                                interpolations[count] = input->ObjectEnum();
     273                                break;
     274                        case TriaInput2Enum:
     275                                interpolations[count] = input->GetResultInterpolation();
     276                                break;
     277                        default:
     278                                _error_("Input "<<EnumToStringx(input->ObjectEnum())<<" not supported yet");
     279                }
     280                count++;
     281        }
     282        _assert_(count == numinputs);
     283
     284        /*Return pointer*/
     285        *pnuminputs = numinputs;
     286        *pinterpolations = interpolations;
     287        *pinputenums = enumlist;
     288
     289}/*}}}*/
    248290SegInput2* Inputs2::GetSegInput(int enum_in){/*{{{*/
    249291
  • issm/trunk-jpl/src/c/classes/Inputs2/Inputs2.h

    r24335 r24340  
    4949                void     Echo(void);
    5050                bool     Exist(int enum_type);
     51                void     GetInputsInterpolations(int* pnuminputs,int** pinterpolations,int** penum);
    5152                SegInput2*       GetSegInput(int enum_type);
    5253                TriaInput2*      GetTriaInput(int enum_type);
Note: See TracChangeset for help on using the changeset viewer.