Changeset 23481


Ignore:
Timestamp:
11/29/18 11:21:09 (6 years ago)
Author:
Mathieu Morlighem
Message:

NEW: splitting constraints into sub datasets to avoid InAnalysis calls

Location:
issm/trunk-jpl/src/c
Files:
5 edited

Legend:

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

    r23473 r23481  
    183183        if(nodes)delete nodes;
    184184        if(vertices)delete vertices;
    185         if(constraints)delete constraints;
     185        if(this->constraints_list && this->nummodels){
     186                for(int i=0;i<this->nummodels;i++) delete this->constraints_list[i];
     187                xDelete<Constraints*>(constraints_list);
     188        }
    186189        if(loads)delete loads;
    187190        if(materials)delete materials;
     
    202205
    203206/*Object management*/
     207int FemModel::AnalysisIndex(int analysis_enum){/*{{{*/
     208
     209        int found=-1;
     210        _assert_(this->analysis_type_list);
     211        for(int i=0;i<this->nummodels;i++){
     212                if(this->analysis_type_list[i]==analysis_enum){
     213                        found=i;
     214                        break;
     215                }
     216        }
     217        if(found!=-1) return found;
     218        else _error_("Could not find index of analysis " << EnumToStringx(analysis_enum) << " in list of FemModel analyses");
     219
     220
     221}/*}}}*/
    204222void FemModel::CheckPoint(void){/*{{{*/
    205223
     
    300318        xMemCpy<int>(output->analysis_type_list,this->analysis_type_list,this->nummodels);
    301319
     320        /*Analysis dependent arrays*/
     321        output->constraints_list=xNew<Constraints*>(this->nummodels);
     322
    302323        output->profiler=static_cast<Profiler*>(this->profiler->copy());
    303324
     
    305326        output->materials=static_cast<Materials*>(this->materials->Copy());
    306327        output->parameters=static_cast<Parameters*>(this->parameters->Copy());
    307         output->constraints=static_cast<Constraints*>(this->constraints->Copy());
    308328        output->results=static_cast<Results*>(this->results->Copy());
    309329
     
    319339        /*do the post-processing of the datasets to get an FemModel that can actually run analyses: */
    320340        for(i=0;i<nummodels;i++){
     341                output->constraints_list[i] = static_cast<Constraints*>(this->constraints_list[i]->Copy());
    321342                analysis_type=output->analysis_type_list[i];
    322343                output->SetCurrentConfiguration(analysis_type);
    323344                if(i==0) VerticesDofx(output->vertices,output->parameters); //only call once, we only have one set of vertices
    324                 SpcNodesx(output->nodes,output->constraints,output->parameters,analysis_type);
     345                SpcNodesx(output->nodes,output->constraints_list[i],output->parameters,analysis_type);
    325346                NodesDofx(output->nodes,output->parameters,analysis_type);
    326347                ConfigureObjectsx(output->elements,output->loads,output->nodes,output->vertices,output->materials,output->parameters);
     
    398419
    399420        /*create datasets for all analyses*/
    400         ModelProcessorx(&this->elements,&this->nodes,&this->vertices,&this->materials,&this->constraints,&this->loads,&this->parameters,iomodel,toolkitsoptionsfid,rootpath,this->solution_type,this->nummodels,this->analysis_type_list);
     421        ModelProcessorx(&this->elements,&this->nodes,&this->vertices,&this->materials,&this->constraints_list,&this->loads,&this->parameters,iomodel,toolkitsoptionsfid,rootpath,this->solution_type,this->nummodels,this->analysis_type_list);
    401422
    402423        /*do the post-processing of the datasets to get an FemModel that can actually run analyses: */
     
    418439
    419440                if(VerboseMProcessor()) _printf0_("      resolving node constraints\n");
    420                 SpcNodesx(nodes,constraints,parameters,analysis_type_list[i]);
     441                SpcNodesx(nodes,this->constraints,parameters,analysis_type_list[i]);
    421442
    422443                if(VerboseMProcessor()) _printf0_("      creating nodal degrees of freedom\n");
     
    436457                delete this->materials;
    437458                delete this->parameters;
    438                 delete this->constraints;
     459                if(this->constraints_list && this->nummodels){
     460                        for(i=0;i<this->nummodels;i++) delete this->constraints_list[i];
     461                        xDelete<Constraints*>(constraints_list);
     462                }
    439463                delete this->results;
    440464                delete this->nodes;
     
    446470                this->materials   = new Materials();
    447471                this->parameters  = new Parameters();
    448                 this->constraints = new Constraints();
    449472                this->results     = new Results();
    450473                this->nodes       = new Nodes();
     
    463486        this->materials->Marshall(pmarshalled_data,pmarshalled_data_size,marshall_direction);
    464487        this->parameters->Marshall(pmarshalled_data,pmarshalled_data_size,marshall_direction);
    465         this->constraints->Marshall(pmarshalled_data,pmarshalled_data_size,marshall_direction);
    466488        this->results->Marshall(pmarshalled_data,pmarshalled_data_size,marshall_direction);
    467489        this->nodes->Marshall(pmarshalled_data,pmarshalled_data_size,marshall_direction);
    468490        this->vertices->Marshall(pmarshalled_data,pmarshalled_data_size,marshall_direction);
    469491        this->elements->Marshall(pmarshalled_data,pmarshalled_data_size,marshall_direction);
     492
     493        if(marshall_direction==MARSHALLING_BACKWARD){
     494                this->constraints_list = xNew<Constraints*>(this->nummodels);
     495                for(i=0;i<nummodels;i++) this->constraints_list[i] = new Constraints();
     496        }
     497
     498        for(i=0;i<nummodels;i++){
     499                this->constraints_list[i]->Marshall(pmarshalled_data,pmarshalled_data_size,marshall_direction);
     500        }
    470501
    471502        if(marshall_direction==MARSHALLING_BACKWARD){
     
    480511                        SetCurrentConfiguration(analysis_type);
    481512                        if(i==0) VerticesDofx(this->vertices,this->parameters); //only call once, we only have one set of vertices
    482                         SpcNodesx(this->nodes,this->constraints,this->parameters,analysis_type);
     513                        SpcNodesx(this->nodes,this->constraints_list[i],this->parameters,analysis_type);
    483514                        NodesDofx(this->nodes,this->parameters,analysis_type);
    484515                        ConfigureObjectsx(this->elements,this->loads,this->nodes,this->vertices,this->materials,this->parameters);
     
    489520                SetCurrentConfiguration(analysis_type);
    490521        }
    491 
    492522}
    493523/*}}}*/
     
    559589                }
    560590        }
    561         if(found!=-1) analysis_counter=found;
     591        if(found!=-1) this->analysis_counter=found;
    562592        else _error_("Could not find alias for analysis_type " << EnumToStringx(configuration_type) << " in list of FemModel analyses");
    563593
     
    570600        this->elements->SetCurrentConfiguration(elements,loads, nodes,vertices, materials,parameters);
    571601        this->loads->SetCurrentConfiguration(elements, loads, nodes,vertices, materials,parameters);
     602        this->constraints = this->constraints_list[this->analysis_counter];
    572603
    573604        /*take care of toolkits options, that depend on this analysis type (present only after model processor)*/
     
    24882519        parameters->FindParam(&time,TimeEnum);
    24892520
     2521        int index=AnalysisIndex(analysis_type);
     2522
    24902523        /*start module: */
    24912524        if(VerboseModule()) _printf0_("   Updating constraints and active domain of analysis " << EnumToStringx(analysis_type)  << " for time: " << time << "\n");
     
    25962629        /*Creating nodes and constraints*/
    25972630        /*Just SSA (2D) and P1 in this version*/
    2598         Nodes* new_nodes                                        = new Nodes();
    2599         Constraints* new_constraints    = new Constraints();
     2631        Nodes* new_nodes = new Nodes();
     2632        Constraints** new_constraints_list = xNew<Constraints*>(this->nummodels);
    26002633
    26012634        int nodecounter         =0;
     
    26032636        for(int i=0;i<this->nummodels;i++){//create nodes for each analysis in analysis_type_list
    26042637
     2638                new_constraints_list[i] = new Constraints();
     2639
    26052640                int analysis_enum = this->analysis_type_list[i];
    26062641
     
    26092644
    26102645                this->CreateNodes(newnumberofvertices,my_vertices,nodecounter,analysis_enum,new_nodes);
    2611                 this->CreateConstraints(new_vertices,nodecounter,constraintcounter,analysis_enum,new_constraints);
    2612                 this->UpdateElements(newnumberofelements,newelementslist,my_elements,nodecounter,i,new_elements);
     2646                this->CreateConstraints(new_vertices,nodecounter,constraintcounter,analysis_enum,new_constraints_list[i]);
     2647                //this->UpdateElements(newnumberofelements,newelementslist,my_elements,nodecounter,i,new_elements);
    26132648
    26142649                if(new_nodes->Size()) nodecounter=new_nodes->MaximumId();
    2615                 constraintcounter = new_constraints->NumberOfConstraints();
     2650                constraintcounter = new_constraints_list[i]->NumberOfConstraints();
    26162651                /*Make sure nodecounter is at least 0 (if no node exists, maxid will be -1*/
    26172652                _assert_(nodecounter>=0);
     2653
     2654                new_constraints_list[i]->Presort();
    26182655        }
    26192656
     
    26232660        this->loads->Presort();
    26242661        new_materials->Presort();
    2625         new_constraints->Presort();
    26262662
    26272663        /*reset hooks for elements, loads and nodes: */
     
    26342670        for(int i=0;i<this->nummodels;i++){
    26352671                analysis_type=this->analysis_type_list[i];
    2636                 //SetCurrentConfiguration(analysis_type);
     2672                SetCurrentConfiguration(analysis_type);
    26372673
    26382674                this->analysis_counter=i;
     
    26562692                        VerticesDofx(new_vertices,this->parameters); //only call once, we only have one set of vertices
    26572693                }
    2658                 SpcNodesx(new_nodes,new_constraints,this->parameters,analysis_type);
     2694                SpcNodesx(new_nodes,new_constraints_list[i],this->parameters,analysis_type);
    26592695                NodesDofx(new_nodes,this->parameters,analysis_type);
    26602696        }
     
    26672703        delete this->elements;          this->elements          = new_elements;
    26682704        delete this->nodes;                     this->nodes                     = new_nodes;
    2669         delete this->constraints;       this->constraints       = new_constraints;
    26702705        delete this->materials;         this->materials = new_materials;
     2706
     2707        if(this->constraints_list && this->nummodels){
     2708                for(int i=0;i<this->nummodels;i++) delete this->constraints_list[i];
     2709                xDelete<Constraints*>(this->constraints_list);
     2710        }
     2711        this->constraints_list = new_constraints_list;
    26712712
    26722713        GetMaskOfIceVerticesLSMx0(this);
     
    33933434        /*OTHERS CONSTRAINTS MUST BE IMPLEMENTED*/
    33943435        if(analysis_enum!=StressbalanceAnalysisEnum) return;
     3436        int analysis_index = AnalysisIndex(analysis_enum);
    33953437
    33963438        int numberofnodes_analysistype= this->nodes->NumberOfNodes(analysis_enum);
     
    34263468
    34273469        /*Get spcvx and spcvy of old mesh*/
    3428         for(int i=0;i<this->constraints->Size();i++){
    3429 
    3430                 Constraint* constraint=(Constraint*)constraints->GetObjectByOffset(i);
     3470        for(int i=0;i<this->constraints_list[analysis_index]->Size();i++){
     3471
     3472                Constraint* constraint=(Constraint*)this->constraints_list[analysis_index]->GetObjectByOffset(i);
    34313473                if(!constraint->InAnalysis(analysis_enum)) _error_("AMR create constraints for "<<EnumToStringx(analysis_enum)<<" not supported yet!\n");
    34323474
  • issm/trunk-jpl/src/c/classes/FemModel.h

    r23254 r23481  
    4141                Profiler*    profiler;             //keep time, cpu and mem statistics while we are running.
    4242
    43                 Constraints *constraints;          //one set of constraints. each constraint knows which analysis_type it handles
    4443                Elements    *elements;             //elements (one set for all analyses)
    4544                Loads       *loads;                //one set of constraints. each constraint knows which analysis_type it handles
     
    5049                Vertices    *vertices;             //one set of vertices
    5150
     51                /*Analysis dependent datasets*/
     52                Constraints  *constraints;
     53                Constraints **constraints_list;
     54
    5255                //FIXME: do we want only one class and have virtual functions? or keep 2 classes, at least rename AdaptiveMeshRefinement -> AmrNeopz
    5356                #if defined(_HAVE_NEOPZ_) && !defined(_HAVE_AD_)
     
    6568
    6669                /*Methods:*/
     70                int  AnalysisIndex(int);
    6771                void CheckPoint(void);
    6872                void CleanUp(void);
  • issm/trunk-jpl/src/c/cores/ResetBoundaryConditions.cpp

    r16158 r23481  
    1313
    1414        if(VerboseSolution()) _printf0_("   updating boundary conditions...\n");
     15        _assert_(femmodel->analysis_type_list[femmodel->analysis_counter]==analysis_type);
    1516
    1617        /*set current analysis: */
    1718        femmodel->SetCurrentConfiguration(analysis_type);
     19        int index = femmodel->AnalysisIndex(analysis_type);
    1820
    1921        /*retrieve boundary conditions from element inputs :*/
  • issm/trunk-jpl/src/c/modules/ModelProcessorx/ModelProcessorx.cpp

    r23399 r23481  
    1313#include "./ModelProcessorx.h"
    1414
    15 void ModelProcessorx(Elements** pelements, Nodes** pnodes, Vertices** pvertices, Materials** pmaterials, Constraints** pconstraints, Loads** ploads, Parameters** pparameters,IoModel* iomodel,FILE* toolkitfile, char* rootpath,const int solution_enum,const int nummodels,const int* analysis_enum_list){
     15void ModelProcessorx(Elements** pelements, Nodes** pnodes, Vertices** pvertices, Materials** pmaterials, Constraints*** pconstraints, Loads** ploads, Parameters** pparameters,IoModel* iomodel,FILE* toolkitfile, char* rootpath,const int solution_enum,const int nummodels,const int* analysis_enum_list){
    1616
    1717        /*Set Verbosity once for all*/
     
    2828        Vertices    *vertices    = new Vertices();
    2929        Materials   *materials   = new Materials();
    30         Constraints *constraints = new Constraints();
    3130        Loads       *loads       = new Loads();
    3231        Parameters  *parameters  = new Parameters();
     32
     33        Constraints **constraints = xNew<Constraints*>(nummodels);
     34        for(int i=0;i<nummodels;i++) constraints[i] = new Constraints();
    3335
    3436
     
    5355                analysis->UpdateParameters(parameters,iomodel,solution_enum,analysis_enum);
    5456                analysis->CreateNodes(nodes,iomodel);
    55                 analysis->CreateConstraints(constraints,iomodel);
     57                analysis->CreateConstraints(constraints[i],iomodel);
    5658                analysis->CreateLoads(loads,iomodel);
    5759                analysis->UpdateElements(elements,iomodel,i,analysis_enum);
     
    6365                if(nodes->Size()) iomodel->nodecounter = nodes->MaximumId();
    6466                iomodel->loadcounter       = loads->NumberOfLoads();
    65                 iomodel->constraintcounter = constraints->NumberOfConstraints();
     67                iomodel->constraintcounter = constraints[i]->NumberOfConstraints();
    6668
    6769                /*Make sure nodecounter is at least 0 (if no node exists, maxid will be -1*/
    6870                _assert_(iomodel->nodecounter>=0);
     71
     72                /*Tell constraints that Ids are already sorted*/
     73                constraints[i]->Presort();
    6974        }
    7075
     
    9196        loads->Presort();
    9297        materials->Presort();
    93         constraints->Presort();
    9498
    9599        /*Assign output pointers:*/
  • issm/trunk-jpl/src/c/modules/ModelProcessorx/ModelProcessorx.h

    r23399 r23481  
    99#include "../../analyses/analyses.h"
    1010
    11 void ModelProcessorx(Elements** pelements, Nodes** pnodes, Vertices** pvertices, Materials** pmaterials, Constraints** pconstraints, Loads** ploads, Parameters** pparameters,IoModel* iomodel,FILE* toolkitfile, char* rootpath,const int solution_type,const int nummodels,const int* analysis_type_listh);
     11void ModelProcessorx(Elements** pelements, Nodes** pnodes, Vertices** pvertices, Materials** pmaterials, Constraints*** pconstraints, Loads** ploads, Parameters** pparameters,IoModel* iomodel,FILE* toolkitfile, char* rootpath,const int solution_type,const int nummodels,const int* analysis_type_listh);
    1212
    1313/*Creation of fem datasets: general drivers*/
Note: See TracChangeset for help on using the changeset viewer.