Changeset 18237 for issm/trunk-jpl/src


Ignore:
Timestamp:
07/11/14 11:33:15 (11 years ago)
Author:
schlegel
Message:

CHG: create femmodel copy for dakota runs

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

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/c/analyses/DamageEvolutionAnalysis.cpp

    r18136 r18237  
    6969        iomodel->FetchDataToInput(elements,PressureEnum);
    7070
    71         bool dakota_analysis;
    72         iomodel->Constant(&dakota_analysis,QmuIsdakotaEnum);
    73         if(dakota_analysis){
    74                 elements->InputDuplicate(DamageDEnum, QmuDamageDEnum);
    75         }
    7671}/*}}}*/
    7772void DamageEvolutionAnalysis::CreateNodes(Nodes* nodes,IoModel* iomodel){/*{{{*/
  • issm/trunk-jpl/src/c/analyses/EnthalpyAnalysis.cpp

    r18068 r18237  
    7878        InputUpdateFromConstantx(elements,0.,VyMeshEnum);
    7979        InputUpdateFromConstantx(elements,0.,VzMeshEnum);
    80         if(dakota_analysis){
    81                 elements->InputDuplicate(TemperatureEnum,QmuTemperatureEnum);
    82                 elements->InputDuplicate(BasalforcingsGroundediceMeltingRateEnum,QmuMeltingEnum);
    83                 elements->InputDuplicate(VxMeshEnum,QmuVxMeshEnum);
    84                 elements->InputDuplicate(VxMeshEnum,QmuVyMeshEnum);
    85                 elements->InputDuplicate(VxMeshEnum,QmuVzMeshEnum);
    86         }
    8780        if(islevelset){
    8881                iomodel->FetchDataToInput(elements,IceMaskNodeActivationEnum);
  • issm/trunk-jpl/src/c/analyses/MasstransportAnalysis.cpp

    r18074 r18237  
    7171        if(stabilization==3){
    7272                iomodel->FetchDataToInput(elements,MasstransportSpcthicknessEnum); //for DG, we need the spc in the element
    73         }
    74 
    75         if(dakota_analysis){
    76                 elements->InputDuplicate(BaseEnum,QmuBaseEnum);
    77                 elements->InputDuplicate(ThicknessEnum,QmuThicknessEnum);
    78                 elements->InputDuplicate(SurfaceEnum,QmuSurfaceEnum);
    79                 elements->InputDuplicate(MaskIceLevelsetEnum,QmuMaskIceLevelsetEnum);
    80                 if(isgroundingline) elements->InputDuplicate(MaskGroundediceLevelsetEnum,QmuMaskGroundediceLevelsetEnum);
    8173        }
    8274
  • issm/trunk-jpl/src/c/analyses/StressbalanceAnalysis.cpp

    r18235 r18237  
    213213        iomodel->FetchDataToInput(elements,MaterialsRheologyNEnum);
    214214        iomodel->FetchDataToInput(elements,VxEnum,0.);
    215         if(dakota_analysis)elements->InputDuplicate(VxEnum,QmuVxEnum);
    216215        iomodel->FetchDataToInput(elements,VyEnum,0.);
    217         if(dakota_analysis)elements->InputDuplicate(VyEnum,QmuVyEnum);
    218216        iomodel->FetchDataToInput(elements,LoadingforceXEnum);
    219217        iomodel->FetchDataToInput(elements,LoadingforceYEnum);
     
    228226                iomodel->FetchDataToInput(elements,LoadingforceZEnum);
    229227                iomodel->FetchDataToInput(elements,VzEnum,0.);
    230                 if(dakota_analysis)elements->InputDuplicate(VzEnum,QmuVzEnum);
    231228        }
    232229        if(isFS){
    233230                iomodel->FetchDataToInput(elements,PressureEnum,0.);
    234231                iomodel->FetchDataToInput(elements,BasalforcingsFloatingiceMeltingRateEnum,0.);
    235                 if(dakota_analysis)elements->InputDuplicate(PressureEnum,QmuPressureEnum);
    236232        }
    237233        if(islevelset){
  • issm/trunk-jpl/src/c/analyses/ThermalAnalysis.cpp

    r18068 r18237  
    7575        InputUpdateFromConstantx(elements,0.,VyMeshEnum);
    7676        InputUpdateFromConstantx(elements,0.,VzMeshEnum);
    77         if(dakota_analysis){
    78                 elements->InputDuplicate(TemperatureEnum,QmuTemperatureEnum);
    79                 elements->InputDuplicate(BasalforcingsGroundediceMeltingRateEnum,QmuMeltingEnum);
    80                 elements->InputDuplicate(VxMeshEnum,QmuVxMeshEnum);
    81                 elements->InputDuplicate(VxMeshEnum,QmuVyMeshEnum);
    82                 elements->InputDuplicate(VxMeshEnum,QmuVzMeshEnum);
    83         }
    8477        if(islevelset){
    8578                iomodel->FetchDataToInput(elements,IceMaskNodeActivationEnum);
  • issm/trunk-jpl/src/c/classes/Constraints/SpcDynamic.cpp

    r18064 r18237  
    5454}               
    5555/*}}}*/
    56 int    SpcDynamic::Id(void){ return sid; }/*{{{*/
     56int SpcDynamic::Id(void){ return sid; }/*{{{*/
    5757/*}}}*/
    5858int SpcDynamic::ObjectEnum(void){/*{{{*/
     
    6363/*}}}*/
    6464Object* SpcDynamic::copy() {/*{{{*/
    65         return new SpcDynamic(*this);
     65
     66        SpcDynamic* spcdyn = new SpcDynamic(*this);
     67
     68        spcdyn->sid=this->sid;
     69        spcdyn->nodeid=this->nodeid;
     70        spcdyn->dof=this->dof;
     71        spcdyn->value=this->value;
     72        spcdyn->analysis_type=this->analysis_type;
     73        spcdyn->isset=this->isset;
     74
     75        return (Object*) spcdyn;
    6676}
    6777/*}}}*/
  • issm/trunk-jpl/src/c/classes/Constraints/SpcStatic.cpp

    r18064 r18237  
    5757}               
    5858/*}}}*/
    59 int    SpcStatic::Id(void){ return sid; }/*{{{*/
     59int SpcStatic::Id(void){ return sid; }/*{{{*/
    6060/*}}}*/
    6161int SpcStatic::ObjectEnum(void){/*{{{*/
     
    6666/*}}}*/
    6767Object* SpcStatic::copy() {/*{{{*/
    68         return new SpcStatic(*this);
     68       
     69        SpcStatic* spcstat = new SpcStatic(*this);
     70
     71        spcstat->sid=this->sid;
     72        spcstat->nodeid=this->nodeid;
     73        spcstat->dof=this->dof;
     74        spcstat->value=this->value;
     75        spcstat->analysis_type=this->analysis_type;
     76
     77        return (Object*) spcstat;
    6978}
    7079/*}}}*/
  • issm/trunk-jpl/src/c/classes/Contour.h

    r18064 r18237  
    7777                /*}}}*/
    7878                Object* copy() {/*{{{*/
    79                         return new Contour(*this);
     79
     80                        Contour* contour = new Contour(this->id,this->nods,this->x,this->y,this->closed);
     81
     82                        return (Object*) contour;
    8083                }
    8184                /*}}}*/
  • issm/trunk-jpl/src/c/classes/DofIndexing.cpp

    r18064 r18237  
    5555                this->s_set=xNew<bool>(this->gsize);
    5656                this->svalues=xNew<IssmDouble>(this->gsize);
    57                 if(in->doftype)this->doftype=xNew<int>(this->gsize);
     57                if(in->doftype){
     58                        this->doftype=xNew<int>(this->gsize);
     59                }
     60                else{
     61                        this->doftype=NULL;
     62                }
    5863                this->gdoflist=xNew<int>(this->gsize);
    5964        }
     
    6570                this->gdoflist = NULL;
    6671        }
    67         if(this->fsize>0 && this->fsize!=UNDEF)this->fdoflist=xNew<int>(this->fsize); else this->fdoflist=NULL;
    68         if(this->ssize>0 && this->ssize!=UNDEF)this->sdoflist=xNew<int>(this->ssize); else this->sdoflist=NULL;
     72        if(this->fsize>0)this->fdoflist=xNew<int>(this->fsize); else this->fdoflist=NULL;
     73        if(this->ssize>0)this->sdoflist=xNew<int>(this->ssize); else this->sdoflist=NULL;
    6974
    7075        if(this->gsize>0){
     
    7580                memcpy(this->gdoflist,in->gdoflist,this->gsize*sizeof(int));
    7681        }
    77         if(this->fsize>0 && this->fsize!=UNDEF)memcpy(this->fdoflist,in->fdoflist,this->fsize*sizeof(int));
    78         if(this->ssize>0 && this->ssize!=UNDEF)memcpy(this->sdoflist,in->sdoflist,this->ssize*sizeof(int));
     82        if(this->fsize>0)memcpy(this->fdoflist,in->fdoflist,this->fsize*sizeof(int));
     83        if(this->ssize>0)memcpy(this->sdoflist,in->sdoflist,this->ssize*sizeof(int));
    7984
    8085}
     
    8287DofIndexing::~DofIndexing(){ //destructor/*{{{*/
    8388
    84         xDelete<bool>(f_set);
    85         xDelete<bool>(s_set);
    86         xDelete<IssmDouble>(svalues);
    87         xDelete<int>(doftype);
    88         xDelete<int>(gdoflist);
    89         xDelete<int>(fdoflist);
    90         xDelete<int>(sdoflist);
    91 
     89        if(this->f_set) xDelete<bool>(f_set);
     90        if(this->s_set) xDelete<bool>(s_set);
     91        if(this->svalues) xDelete<IssmDouble>(svalues);
     92        if(this->doftype) xDelete<int>(doftype);
     93        if(this->gdoflist) xDelete<int>(gdoflist);
     94        if(this->fdoflist) xDelete<int>(fdoflist);
     95        if(this->sdoflist) xDelete<int>(sdoflist);
     96
     97}
     98/*}}}*/
     99DofIndexing DofIndexing::operator=( const DofIndexing& in ){/*{{{*/
     100
     101        this->copy(in);
     102
     103        return this;
     104}
     105/*}}}*/
     106void DofIndexing::copy(const DofIndexing& in ){/*{{{*/
     107
     108        this->gsize  = in.gsize;
     109        this->fsize  = in.fsize;
     110        this->ssize  = in.ssize;
     111        this->clone  = in.clone;
     112        this->active = in.active;
     113
     114        if(this->gsize>0){
     115                this->f_set=xNew<bool>(this->gsize);
     116                this->s_set=xNew<bool>(this->gsize);
     117                this->svalues=xNew<IssmDouble>(this->gsize);
     118                if(in.doftype){
     119                        this->doftype=xNew<int>(this->gsize);
     120                }
     121                else{
     122                        this->doftype=NULL;
     123                }
     124                this->gdoflist=xNew<int>(this->gsize);
     125        }
     126        else{
     127                this->f_set    = NULL;
     128                this->s_set    = NULL;
     129                this->svalues  = NULL;
     130                this->doftype  = NULL;
     131                this->gdoflist = NULL;
     132        }
     133        if(this->fsize>0)this->fdoflist=xNew<int>(this->fsize); else this->fdoflist=NULL;
     134        if(this->ssize>0)this->sdoflist=xNew<int>(this->ssize); else this->sdoflist=NULL;
     135
     136        if(this->gsize>0){
     137                memcpy(this->f_set,in.f_set,this->gsize*sizeof(bool));
     138                memcpy(this->s_set,in.s_set,this->gsize*sizeof(bool));
     139                xMemCpy<IssmDouble>(this->svalues,in.svalues,this->gsize);
     140                if(this->doftype)memcpy(this->doftype,in.doftype,this->gsize*sizeof(int));
     141                memcpy(this->gdoflist,in.gdoflist,this->gsize*sizeof(int));
     142        }
     143        if(this->fsize>0)memcpy(this->fdoflist,in.fdoflist,this->fsize*sizeof(int));
     144        if(this->ssize>0)memcpy(this->sdoflist,in.sdoflist,this->ssize*sizeof(int));
     145
     146        return;
    92147}
    93148/*}}}*/
     
    101156        /*memory allocation */
    102157        if(this->gsize>0){
    103                 this->f_set    = xNew<bool>(this->gsize);
    104                 this->s_set    = xNew<bool>(this->gsize);
    105                 this->svalues  = xNew<IssmDouble>(this->gsize);
    106                 this->gdoflist = xNew<int>(this->gsize);
    107 
    108                 if(in_doftype)
    109                  this->doftype = xNew<int>(this->gsize);
     158                this->f_set    = xNew<bool>((unsigned int)in_gsize);
     159                this->s_set    = xNew<bool>((unsigned int)in_gsize);
     160                this->svalues  = xNew<IssmDouble>((unsigned int)in_gsize);
     161                this->gdoflist = xNew<int>((unsigned int)in_gsize);
     162
     163                if(in_doftype) this->doftype = xNew<int>((unsigned int)in_gsize);
     164                else this->doftype = NULL;
    110165        }
    111166
     
    117172                this->gdoflist[i] = UNDEF;
    118173
    119                 if(this->doftype)
    120                  this->doftype[i]=in_doftype[i];
     174                if(this->doftype) this->doftype[i]=in_doftype[i];
    121175        }
    122176}
  • issm/trunk-jpl/src/c/classes/DofIndexing.h

    r15223 r18237  
    4141                DofIndexing(DofIndexing* properties);
    4242                ~DofIndexing();
     43                DofIndexing operator=(const DofIndexing& in);
    4344                /*}}}*/
    4445                /*Object like functionality: {{{*/
    4546                void  Echo(void);
    4647                void  DeepEcho(void);
    47                 void  copy(DofIndexing* properties);
     48                void  copy(const DofIndexing& in);
    4849                /*}}}*/
    4950                /*DofIndexing management: {{{*/
  • issm/trunk-jpl/src/c/classes/Elements/Element.cpp

    r18194 r18237  
    289289        if(nodes){
    290290                int numnodes = this->GetNumberOfNodes();
    291                 for(int i=0;i<numnodes;i++) nodes[i]->Echo();
     291                for(int i=0;i<numnodes;i++) {
     292                        _printf_("nodes[" << i << "] = " << nodes[i]); 
     293                        nodes[i]->Echo();
     294                }
    292295        }
    293296        else _printf_("nodes = NULL\n");
  • issm/trunk-jpl/src/c/classes/Elements/Element.h

    r18194 r18237  
    165165                virtual void       Configure(Elements* elements,Loads* loads,Nodes* nodes,Vertices* vertices,Materials* materials,Parameters* parameters)=0;
    166166                virtual void       SetCurrentConfiguration(Elements* elements,Loads* loads,Nodes* nodes,Materials* materials,Parameters* parameters)=0;
     167                virtual void       ResetHooks()=0;
    167168                virtual void   ElementSizes(IssmDouble* phx,IssmDouble* phy,IssmDouble* phz)=0;
    168169
  • issm/trunk-jpl/src/c/classes/Elements/ElementHook.cpp

    r17962 r18237  
    2929        int i;
    3030
    31         for(i=0;i<this->numanalyses;i++){
    32                 if (this->hnodes[i]) delete this->hnodes[i];
    33         }
    34         delete [] this->hnodes;
     31        if (this->hnodes) delete [] this->hnodes;
    3532        delete hvertices;
    3633        delete hmaterial;
     
    7673
    7774void ElementHook::SetHookNodes(int* node_ids,int numnodes,int analysis_counter){/*{{{*/
    78         this->hnodes[analysis_counter]= new Hook(node_ids,numnodes);
     75        if(this->hnodes) this->hnodes[analysis_counter]= new Hook(node_ids,numnodes);
    7976}
    8077/*}}}*/
  • issm/trunk-jpl/src/c/classes/Elements/Elements.cpp

    r17962 r18237  
    6262}
    6363/*}}}*/
     64void Elements::ResetHooks(){/*{{{*/
     65
     66        vector<Object*>::iterator object;
     67        Element* element=NULL;
     68
     69        for ( object=objects.begin() ; object < objects.end(); object++ ){
     70
     71                element=dynamic_cast<Element*>((*object));
     72                element->ResetHooks();
     73
     74        }
     75
     76}
     77/*}}}*/
    6478int  Elements::MaxNumNodes(void){/*{{{*/
    6579
  • issm/trunk-jpl/src/c/classes/Elements/Elements.h

    r16486 r18237  
    2727                int    MaxNumNodes(void);
    2828                void   SetCurrentConfiguration(Elements* elements,Loads* loads, Nodes* nodes, Vertices* vertices, Materials* materials,Parameters* parameters);
     29                void   ResetHooks();
    2930                int    NumberOfElements(void);
    3031                void   InputDuplicate(int input_enum,int output_enum);
  • issm/trunk-jpl/src/c/classes/Elements/Penta.cpp

    r18212 r18237  
    6464
    6565        int i;
    66 
    6766        Penta* penta=NULL;
    6867
     
    7069
    7170        //deal with PentaRef mother class
    72         penta->element_type_list=xNew<int>(this->numanalyses);
    73         for(i=0;i<this->numanalyses;i++) penta->element_type_list[i]=this->element_type_list[i];
    74 
    75         //deal with ElementHook
    76         penta->numanalyses=this->numanalyses;
    77         penta->hnodes=new Hook*[penta->numanalyses];
    78         for(i=0;i<penta->numanalyses;i++)penta->hnodes[i]=(Hook*)this->hnodes[i]->copy();
    79         penta->hvertices=(Hook*)this->hvertices->copy();
    80         penta->hmaterial=(Hook*)this->hmaterial->copy();
    81         penta->hmatpar=(Hook*)this->hmatpar->copy();
    82         penta->hneighbors=(Hook*)this->hneighbors->copy();
    83 
    84         /*deal with Penta  copy fields: */
    85         penta->id=this->id;
    86         penta->sid=this->sid;
    87         if(this->inputs){
    88                 penta->inputs=(Inputs*)this->inputs->Copy();
    89         }
    90         else{
    91                 penta->inputs=new Inputs();
    92         }
     71        int nanalyses = this->numanalyses;
     72        if(nanalyses > 0){
     73                penta->element_type_list=xNew<int>(nanalyses);
     74                for(i=0;i<nanalyses;i++) {
     75                        if (this->element_type_list[i]) penta->element_type_list[i]=this->element_type_list[i];
     76                        else penta->element_type_list[i] = NULL;
     77                }
     78        }
     79        else penta->element_type_list = NULL;
     80        penta->element_type=this->element_type;
     81        penta->numanalyses=nanalyses;
     82
     83        //deal with ElementHook mother class
     84        if (this->hnodes){
     85                penta->hnodes=xNew<Hook*>(penta->numanalyses);
     86                for(i=0;i<penta->numanalyses;i++){
     87                        if (this->hnodes[i]) penta->hnodes[i] = (Hook*)(this->hnodes[i]->copy());
     88                        else penta->hnodes[i] = NULL;
     89                }
     90        }
     91        else penta->hnodes = NULL;
     92
     93        penta->hvertices = (Hook*)this->hvertices->copy();
     94        penta->hmaterial = (Hook*)this->hmaterial->copy();
     95        penta->hmatpar   = (Hook*)this->hmatpar->copy();
     96        if (this->hneighbors) penta->hneighbors = (Hook*)(this->hneighbors->copy());
     97        else penta->hneighbors = NULL;
     98
     99        /*deal with Tria fields: */
     100        penta->id  = this->id;
     101        penta->sid = this->sid;
     102        if(this->inputs) penta->inputs = (Inputs*)(this->inputs->Copy());
     103        else penta->inputs=new Inputs();
     104
    93105        /*point parameters: */
    94106        penta->parameters=this->parameters;
    95107
    96108        /*recover objects: */
    97         penta->nodes=xNew<Node*>(6); //we cannot rely on an analysis_counter to tell us which analysis_type we are running, so we just copy the nodes.
    98         for(i=0;i<6;i++)penta->nodes[i]=this->nodes[i];
    99         penta->vertices=(Vertex**)penta->hvertices->deliverp();
    100         penta->material=(Material*)penta->hmaterial->delivers();
    101         penta->matpar=(Matpar*)penta->hmatpar->delivers();
    102         penta->verticalneighbors=(Penta**)penta->hneighbors->deliverp();
     109        if (this->nodes) {
     110                unsigned int num_nodes = 6;
     111                penta->nodes = xNew<Node*>(num_nodes); //we cannot rely on an analysis_counter to tell us which analysis_type we are running, so we just copy the nodes.
     112                for(i=0;i<num_nodes;i++) if(this->nodes[i]) penta->nodes[i]=this->nodes[i]; else penta->nodes[i] = NULL;
     113        }
     114        else penta->nodes = NULL;
     115
     116        penta->vertices = (Vertex**)this->hvertices->deliverp();
     117        penta->material = (Material*)this->hmaterial->delivers();
     118        penta->matpar   = (Matpar*)this->hmatpar->delivers();
     119        penta->verticalneighbors = (Penta**)this->hneighbors->deliverp();
    103120
    104121        return penta;
     122
    105123}
    106124/*}}}*/
     
    18971915        if(this->hnodes[analysis_counter]) this->nodes=(Node**)this->hnodes[analysis_counter]->deliverp();
    18981916        else this->nodes=NULL;
     1917
     1918}
     1919/*}}}*/
     1920void       Penta::ResetHooks(){/*{{{*/
     1921
     1922        this->nodes=NULL;
     1923        this->vertices=NULL;
     1924        this->material=NULL;
     1925        this->matpar=NULL;
     1926        this->verticalneighbors=NULL;
     1927        this->parameters=NULL;
     1928
     1929        //deal with ElementHook mother class
     1930        for(int i=0;i<this->numanalyses;i++) if(this->hnodes[i]) this->hnodes[i]->reset();
     1931        this->hvertices->reset();
     1932        this->hmaterial->reset();
     1933        this->hmatpar->reset();
     1934        if(this->hneighbors) this->hneighbors->reset();
    18991935
    19001936}
  • issm/trunk-jpl/src/c/classes/Elements/Penta.h

    r18192 r18237  
    6262                void   FSContactMigration(Vector<IssmDouble>* vertexgrounded,Vector<IssmDouble>* vertexfloating);
    6363                void   SetCurrentConfiguration(Elements* elements,Loads* loads,Nodes* nodes,Materials* materials,Parameters* parameters);
     64                void   ResetHooks();
    6465                void   Delta18oParameterization(void);
    6566                Penta* GetUpperPenta(void);
  • issm/trunk-jpl/src/c/classes/Elements/Seg.h

    r18192 r18237  
    5959                void        Configure(Elements* elements,Loads* loads,Nodes* nodesin,Vertices* verticesin,Materials* materials,Parameters* parameters){_error_("not implemented yet");};
    6060                void        SetCurrentConfiguration(Elements* elements,Loads* loads,Nodes* nodes,Materials* materials,Parameters* parameters){_error_("not implemented yet");};
     61                void        ResetHooks(){_error_("not implemented yet");};
    6162                void        Delta18oParameterization(void){_error_("not implemented yet");};
    6263                void        ElementSizes(IssmDouble* hx,IssmDouble* hy,IssmDouble* hz){_error_("not implemented yet");};
  • issm/trunk-jpl/src/c/classes/Elements/Tetra.cpp

    r18179 r18237  
    4848/*}}}*/
    4949Object* Tetra::copy() {/*{{{*/
    50         _error_("not implemented yet");
     50
     51        int i;
     52        Tetra* tetra=NULL;
     53
     54        tetra=new Tetra();
     55
     56        //deal with TetraRef mother class
     57        int nanalyses = this->numanalyses;
     58        if(nanalyses > 0){
     59                tetra->element_type_list=xNew<int>(nanalyses);
     60                for(i=0;i<nanalyses;i++){
     61                        if (this->element_type_list[i]) tetra->element_type_list[i]=this->element_type_list[i];
     62                        else tetra->element_type_list[i] = NULL;
     63                }
     64        }
     65        else tetra->element_type_list = NULL;
     66        tetra->element_type=this->element_type;
     67        tetra->numanalyses=nanalyses;
     68
     69        //deal with ElementHook mother class
     70        if (this->hnodes){
     71                tetra->hnodes=xNew<Hook*>(tetra->numanalyses);
     72                for(i=0;i<tetra->numanalyses;i++){
     73                        if (this->hnodes[i]) tetra->hnodes[i] = (Hook*)(this->hnodes[i]->copy());
     74                        else tetra->hnodes[i] = NULL;
     75                }
     76        }
     77        else tetra->hnodes = NULL;
     78
     79        tetra->hvertices = (Hook*)this->hvertices->copy();
     80        tetra->hmaterial = (Hook*)this->hmaterial->copy();
     81        tetra->hmatpar   = (Hook*)this->hmatpar->copy();
     82        tetra->hneighbors = NULL;
     83
     84        /*deal with Tria fields: */
     85        tetra->id  = this->id;
     86        tetra->sid = this->sid;
     87        if(this->inputs) tetra->inputs = (Inputs*)(this->inputs->Copy());
     88        else tetra->inputs=new Inputs();
     89
     90        /*point parameters: */
     91        tetra->parameters=this->parameters;
     92
     93        /*recover objects: */
     94        unsigned int num_nodes = 3;
     95        tetra->nodes = xNew<Node*>(num_nodes); //we cannot rely on an analysis_counter to tell us which analysis_type we are running, so we just copy the nodes.
     96        for(i=0;i<num_nodes;i++) if(this->nodes[i]) tetra->nodes[i]=this->nodes[i]; else tetra->nodes[i] = NULL;
     97
     98        tetra->vertices = (Vertex**)this->hvertices->deliverp();
     99        tetra->material = (Material*)this->hmaterial->delivers();
     100        tetra->matpar   = (Matpar*)this->hmatpar->delivers();
     101
     102        return tetra;
    51103}
    52104/*}}}*/
     
    727779}
    728780/*}}}*/
     781void     Tetra::ResetHooks(){/*{{{*/
     782
     783        this->nodes=NULL;
     784        this->vertices=NULL;
     785        this->material=NULL;
     786        this->matpar=NULL;
     787        this->parameters=NULL;
     788
     789        //deal with ElementHook mother class
     790        for(int i=0;i<this->numanalyses;i++) if(this->hnodes[i]) this->hnodes[i]->reset();
     791        this->hvertices->reset();
     792        this->hmaterial->reset();
     793        this->hmatpar->reset();
     794        if(this->hneighbors) this->hneighbors->reset();
     795}
     796/*}}}*/
    729797Element* Tetra::SpawnBasalElement(void){/*{{{*/
    730798
  • issm/trunk-jpl/src/c/classes/Elements/Tetra.h

    r18192 r18237  
    5959                void        Configure(Elements* elements,Loads* loads,Nodes* nodesin,Vertices* verticesin,Materials* materials,Parameters* parameters);
    6060                void        SetCurrentConfiguration(Elements* elements,Loads* loads,Nodes* nodes,Materials* materials,Parameters* parameters);
     61                void        ResetHooks();
    6162                void        Delta18oParameterization(void){_error_("not implemented yet");};
    6263                void        ElementSizes(IssmDouble* hx,IssmDouble* hy,IssmDouble* hz);
  • issm/trunk-jpl/src/c/classes/Elements/Tria.cpp

    r18192 r18237  
    4242                this->material = NULL;
    4343                this->matpar   = NULL;
    44                 this->element_type_list=xNew<int>(nummodels);
     44                if(nummodels>0){
     45                        this->element_type_list=xNew<int>(nummodels);
     46                        for(int i=0;i<nummodels;i++) this->element_type_list[i] = NULL;
     47                }
     48                else this->element_type_list = NULL;
     49
    4550}
    4651/*}}}*/
     
    5762
    5863        //deal with TriaRef mother class
    59         tria->element_type_list=xNew<int>(this->numanalyses);
    60         for(i=0;i<this->numanalyses;i++) tria->element_type_list[i]=this->element_type_list[i];
     64        int nanalyses = this->numanalyses;
     65        if(nanalyses > 0){
     66                tria->element_type_list=xNew<int>(nanalyses);
     67                for(i=0;i<nanalyses;i++){
     68                        if (this->element_type_list[i]) tria->element_type_list[i]=this->element_type_list[i];
     69                        else tria->element_type_list[i] = NULL;
     70                }
     71        }
     72        else tria->element_type_list = NULL;
     73        tria->element_type=this->element_type;
     74        tria->numanalyses=nanalyses;
    6175
    6276        //deal with ElementHook mother class
    63         tria->numanalyses=this->numanalyses;
    64         tria->hnodes=new Hook*[tria->numanalyses];
    65         for(i=0;i<tria->numanalyses;i++)tria->hnodes[i]=(Hook*)this->hnodes[i]->copy();
     77        if (this->hnodes){
     78                tria->hnodes=xNew<Hook*>(tria->numanalyses);
     79                for(i=0;i<tria->numanalyses;i++){
     80                        if (this->hnodes[i]) tria->hnodes[i] = (Hook*)(this->hnodes[i]->copy());
     81                        else tria->hnodes[i] = NULL;
     82                }
     83        }
     84        else tria->hnodes = NULL;
     85
    6686        tria->hvertices = (Hook*)this->hvertices->copy();
    6787        tria->hmaterial = (Hook*)this->hmaterial->copy();
    6888        tria->hmatpar   = (Hook*)this->hmatpar->copy();
     89        tria->hneighbors = NULL;
    6990
    7091        /*deal with Tria fields: */
    7192        tria->id  = this->id;
    7293        tria->sid = this->sid;
    73         if(this->inputs){
    74                 tria->inputs=(Inputs*)this->inputs->Copy();
    75         }
    76         else{
    77                 tria->inputs=new Inputs();
    78         }
     94        if(this->inputs) tria->inputs = (Inputs*)(this->inputs->Copy());
     95        else tria->inputs=new Inputs();
     96
    7997        /*point parameters: */
    8098        tria->parameters=this->parameters;
    8199
    82100        /*recover objects: */
    83         tria->nodes = xNew<Node*>(3); //we cannot rely on an analysis_counter to tell us which analysis_type we are running, so we just copy the nodes.
    84         for(i=0;i<3;i++)tria->nodes[i]=this->nodes[i];
    85 
    86         tria->vertices = (Vertex**)tria->hvertices->deliverp();
    87         tria->material = (Material*)tria->hmaterial->delivers();
    88         tria->matpar   = (Matpar*)tria->hmatpar->delivers();
     101        if (this->nodes){
     102                unsigned int num_nodes = 3;
     103                tria->nodes = xNew<Node*>(num_nodes); //we cannot rely on an analysis_counter to tell us which analysis_type we are running, so we just copy the nodes.
     104                for(i=0;i<num_nodes;i++) if(this->nodes[i]) tria->nodes[i]=this->nodes[i]; else tria->nodes[i] = NULL;
     105        }
     106        else tria->nodes = NULL;
     107       
     108
     109        tria->vertices = (Vertex**)this->hvertices->deliverp();
     110        tria->material = (Material*)this->hmaterial->delivers();
     111        tria->matpar   = (Matpar*)this->hmatpar->delivers();
    89112
    90113        return tria;
     
    307330
    308331        /*Get Element type*/
    309         this->element_type=this->element_type_list[analysis_counter];
     332        if (this->element_type_list) this->element_type=this->element_type_list[analysis_counter];
    310333
    311334        /*Take care of hooking up all objects for this element, ie links the objects in the hooks to their respective
    312335         * datasets, using internal ids and offsets hidden in hooks: */
    313         if(this->hnodes[analysis_counter]) this->hnodes[analysis_counter]->configure(nodesin);
     336        if(this->hnodes){
     337                if (this->hnodes[analysis_counter]) this->hnodes[analysis_counter]->configure(nodesin);
     338                else this->hnodes[analysis_counter] = NULL;
     339        }
     340        else this->hnodes = NULL;
    314341        this->hvertices->configure(verticesin);
    315342        this->hmaterial->configure(materialsin);
     
    317344
    318345        /*Now, go pick up the objects inside the hooks: */
    319         if(this->hnodes[analysis_counter]) this->nodes=(Node**)this->hnodes[analysis_counter]->deliverp();
     346        if(this->hnodes && this->hnodes[analysis_counter]) this->nodes=(Node**)this->hnodes[analysis_counter]->deliverp();
    320347        else this->nodes=NULL;
    321348        this->vertices = (Vertex**)this->hvertices->deliverp();
     
    327354
    328355        /*get inputs configured too: */
    329         this->inputs->Configure(parameters);
     356        this->inputs->Configure(this->parameters);
    330357
    331358}
     
    856883/*}}}*/
    857884int        Tria::GetNumberOfNodes(void){/*{{{*/
    858         return this->NumberofNodes(this->element_type);
     885        if (this->nodes) return this->NumberofNodes(this->element_type);
     886        else return 0;
    859887}
    860888/*}}}*/
     
    16841712}
    16851713/*}}}*/
     1714void       Tria::ResetHooks(){/*{{{*/
     1715
     1716        this->nodes=NULL;
     1717        this->vertices=NULL;
     1718        this->material=NULL;
     1719        this->matpar=NULL;
     1720        this->parameters=NULL;
     1721
     1722        //deal with ElementHook mother class
     1723        for(int i=0;i<this->numanalyses;i++) if(this->hnodes[i]) this->hnodes[i]->reset();
     1724        this->hvertices->reset();
     1725        this->hmaterial->reset();
     1726        this->hmatpar->reset();
     1727        if(this->hneighbors) this->hneighbors->reset();
     1728
     1729}
     1730/*}}}*/
    16861731void       Tria::SetClone(int* minranks){/*{{{*/
    16871732
     
    17591804
    17601805        /*Get Element type*/
    1761         this->element_type=this->element_type_list[analysis_counter];
     1806        if(this->element_type_list) this->element_type=this->element_type_list[analysis_counter];
    17621807
    17631808        /*Pick up nodes*/
    1764         if(this->hnodes[analysis_counter]) this->nodes=(Node**)this->hnodes[analysis_counter]->deliverp();
    1765         else this->nodes=NULL;
     1809        if(this->hnodes && this->hnodes[analysis_counter]){
     1810                this->nodes=(Node**)this->hnodes[analysis_counter]->deliverp();
     1811        }
    17661812
    17671813}
  • issm/trunk-jpl/src/c/classes/Elements/Tria.h

    r18192 r18237  
    5858                void        Configure(Elements* elements,Loads* loads,Nodes* nodesin,Vertices* verticesin,Materials* materials,Parameters* parameters);
    5959                void        SetCurrentConfiguration(Elements* elements,Loads* loads,Nodes* nodes,Materials* materials,Parameters* parameters);
     60                void        ResetHooks();
    6061                void        Delta18oParameterization(void);
    6162                void        ElementSizes(IssmDouble* hx,IssmDouble* hy,IssmDouble* hz);
  • issm/trunk-jpl/src/c/classes/FemModel.cpp

    r18222 r18237  
    106106        char *outbinfilename = NULL;
    107107        char *lockfilename   = NULL;
    108         bool  waitonlock     = false;
    109 
    110         /*Close output file: */
    111         this->parameters->FindParam(&output_fid,OutputFilePointerEnum);
    112         this->parameters->FindParam(&outbinfilename,OutputFileNameEnum);
    113         pfclose(output_fid,outbinfilename);
    114 
    115         /*Write lock file if requested: */
    116         this->parameters->FindParam(&waitonlock,SettingsWaitonlockEnum);
     108
     109        this->parameters->FindParam(&outbinfilename,OutputFileNameEnum);
    117110        this->parameters->FindParam(&lockfilename,LockFileNameEnum);
    118         if(waitonlock){
    119                 _printf0_("write lock file:\n");
    120                 WriteLockFile(lockfilename);
    121         }
    122111
    123112        /*Delete all the datasets: */
     
    134123        delete results;
    135124
     125        /*Now delete: */
     126        delete profiler;
     127
     128}
     129/*}}}*/
     130
     131/*Object management*/
     132void FemModel::Echo(void){/*{{{*/
     133
     134        _printf_("FemModel echo: \n");
     135        _printf_("   number of fem models: " << nummodels << "\n");
     136        _printf_("   analysis_type_list: \n");
     137        for(int i=0;i<nummodels;i++)_printf_("     " << i << ": " << EnumToStringx(analysis_type_list[i]) << "\n");
     138        _printf_("   current analysis_type: \n");
     139        _printf_("     " << analysis_counter << ": " << EnumToStringx(analysis_type_list[analysis_counter]) << "\n");
     140
     141}
     142/*}}}*/
     143void FemModel::InitFromFiles(char* rootpath, char* inputfilename, char* outputfilename, char* toolkitsfilename, char* lockfilename, const int in_solution_type,const int* analyses,const int nummodels){/*{{{*/
     144
     145        /*intermediary*/
     146        int         i;
     147        int         analysis_type;
     148        FILE       *IOMODEL = NULL;
     149        FILE       *toolkitsoptionsfid = NULL;
     150        FILE       *output_fid = NULL;
     151        int         my_rank;
     152
     153        /*recover my_rank:*/
     154        my_rank=IssmComm::GetRank();
     155
     156        /*Open input file on cpu 0: */
     157        if(my_rank==0) IOMODEL = pfopen0(inputfilename ,"rb");
     158
     159        /*Open toolkits file: */
     160        toolkitsoptionsfid=pfopen(toolkitsfilename,"r");
     161
     162        /*Initialize internal data: */
     163        this->nummodels        = nummodels;
     164        this->solution_type    = in_solution_type;
     165        this->analysis_counter = nummodels-1;   //point to last analysis_type carried out.
     166        this->results          = new Results(); //not initialized by CreateDataSets
     167
     168        /*Dynamically allocate whatever is a list of length nummodels: */
     169        analysis_type_list=xNew<int>(nummodels);
     170
     171        /*Initialize: */
     172        for(i=0;i<nummodels;i++)analysis_type_list[i]=analyses[i];
     173
     174        /*create datasets for all analyses*/
     175        ModelProcessorx(&this->elements,&this->nodes,&this->vertices,&this->materials,&this->constraints,&this->loads,&this->parameters,IOMODEL,toolkitsoptionsfid,rootpath,this->solution_type,nummodels,analyses);
     176
     177        /*do the post-processing of the datasets to get an FemModel that can actually run analyses: */
     178        for(i=0;i<nummodels;i++){
     179
     180                if(VerboseMProcessor()) _printf0_("   Processing finite element model of analysis " << EnumToStringx(analysis_type_list[i]) << ":\n");
     181                analysis_type=analysis_type_list[i];
     182                this->SetCurrentConfiguration(analysis_type);
     183
     184                if(i==0){
     185                        if(VerboseMProcessor()) _printf0_("      creating vertex PIDs\n");
     186                        VerticesDofx(vertices,parameters); //only call once, we only have one set of vertices
     187                }
     188
     189                if(VerboseMProcessor()) _printf0_("      resolving node constraints\n");
     190                SpcNodesx(nodes,constraints,parameters,analysis_type);
     191
     192                if(VerboseMProcessor()) _printf0_("      creating nodal degrees of freedom\n");
     193                NodesDofx(nodes,parameters,analysis_type);
     194
     195                if(VerboseMProcessor()) _printf0_("      configuring element and loads\n");
     196                ConfigureObjectsx(elements, loads, nodes, vertices, materials,parameters);
     197        }
     198
     199        /*Close input file and toolkits file descriptors: */
     200        if(my_rank==0) pfclose(IOMODEL,inputfilename);
     201        pfclose(toolkitsoptionsfid,toolkitsfilename);
     202
     203        /*Open output file once for all and add output file name and file descriptor to parameters*/
     204        output_fid=pfopen(outputfilename,"wb");
     205        this->parameters->AddObject(new StringParam(OutputFileNameEnum,outputfilename));
     206        this->parameters->SetParam(output_fid,OutputFilePointerEnum);
     207
     208        /*Save lock file name for later: */
     209        this->parameters->AddObject(new StringParam(LockFileNameEnum,lockfilename));
     210
     211        }
     212/*}}}*/
     213void FemModel::CleanUp(void){/*{{{*/
     214
     215        /*Intermediary*/
     216        FILE *output_fid;
     217        char *outbinfilename = NULL;
     218        char *lockfilename   = NULL;
     219        bool  waitonlock     = false;
     220
     221        /*Close output file: */
     222        this->parameters->FindParam(&output_fid,OutputFilePointerEnum);
     223        this->parameters->FindParam(&outbinfilename,OutputFileNameEnum);
     224        pfclose(output_fid,outbinfilename);
     225
     226        /*Write lock file if requested: */
     227        this->parameters->FindParam(&waitonlock,SettingsWaitonlockEnum);
     228        this->parameters->FindParam(&lockfilename,LockFileNameEnum);
     229        if(waitonlock){
     230                _printf0_("write lock file:\n");
     231                WriteLockFile(lockfilename);
     232        }
     233
    136234        /*Before we delete the profiler, report statistics for this run: */
    137235        profiler->Tag(Finish);  //final tagging
     
    141239        _printf0_("\n");
    142240        _printf0_("   Total elapsed time:"
    143                         <<profiler->DeltaTimeModHour(Start,Finish)<<" hrs "
    144                         <<profiler->DeltaTimeModMin(Start,Finish)<<" min "
    145                         <<profiler->DeltaTimeModSec(Start,Finish)<<" sec"
    146                         );
     241                                <<profiler->DeltaTimeModHour(Start,Finish)<<" hrs "
     242                                <<profiler->DeltaTimeModMin(Start,Finish)<<" min "
     243                                <<profiler->DeltaTimeModSec(Start,Finish)<<" sec"
     244                                );
    147245        _printf0_("\n");
    148 
    149         /*Now delete: */
    150         delete profiler;
    151246
    152247        /*Finalize PETSC for this model: */
    153248        #ifdef _HAVE_PETSC_
    154249        _printf0_("closing PETSc\n");
    155         PetscFinalize(); 
     250        PetscFinalize();
    156251        #endif
    157252
    158253}
    159 /*}}}*/
    160 
    161 /*Object management*/
    162 void FemModel::Echo(void){/*{{{*/
    163 
    164         _printf_("FemModel echo: \n");
    165         _printf_("   number of fem models: " << nummodels << "\n");
    166         _printf_("   analysis_type_list: \n");
    167         for(int i=0;i<nummodels;i++)_printf_("     " << i << ": " << EnumToStringx(analysis_type_list[i]) << "\n");
    168         _printf_("   current analysis_type: \n");
    169         _printf_("     " << analysis_counter << ": " << EnumToStringx(analysis_type_list[analysis_counter]) << "\n");
    170 
    171 }
    172 /*}}}*/
    173 void FemModel::InitFromFiles(char* rootpath, char* inputfilename, char* outputfilename, char* toolkitsfilename, char* lockfilename, const int in_solution_type,const int* analyses,const int nummodels){/*{{{*/
    174 
    175         /*intermediary*/
    176         int         i;
    177         int         analysis_type;
    178         FILE       *IOMODEL = NULL;
    179         FILE       *toolkitsoptionsfid = NULL;
    180         FILE       *output_fid = NULL;
    181         int         my_rank;
    182 
    183         /*recover my_rank:*/
    184         my_rank=IssmComm::GetRank();
    185 
    186         /*Open input file on cpu 0: */
    187         if(my_rank==0) IOMODEL = pfopen0(inputfilename ,"rb");
    188 
    189         /*Open toolkits file: */
    190         toolkitsoptionsfid=pfopen(toolkitsfilename,"r");
    191 
    192         /*Initialize internal data: */
    193         this->nummodels        = nummodels;
    194         this->solution_type    = in_solution_type;
    195         this->analysis_counter = nummodels-1;   //point to last analysis_type carried out.
    196         this->results          = new Results(); //not initialized by CreateDataSets
    197 
    198         /*Dynamically allocate whatever is a list of length nummodels: */
    199         analysis_type_list=xNew<int>(nummodels);
    200 
    201         /*Initialize: */
    202         for(i=0;i<nummodels;i++)analysis_type_list[i]=analyses[i];
    203 
    204         /*create datasets for all analyses*/
    205         ModelProcessorx(&this->elements,&this->nodes,&this->vertices,&this->materials,&this->constraints,&this->loads,&this->parameters,IOMODEL,toolkitsoptionsfid,rootpath,this->solution_type,nummodels,analyses);
    206 
    207         /*do the post-processing of the datasets to get an FemModel that can actually run analyses: */
    208         for(i=0;i<nummodels;i++){
    209 
    210                 if(VerboseMProcessor()) _printf0_("   Processing finite element model of analysis " << EnumToStringx(analysis_type_list[i]) << ":\n");
    211                 analysis_type=analysis_type_list[i];
    212                 this->SetCurrentConfiguration(analysis_type);
    213 
    214                 if(i==0){
    215                         if(VerboseMProcessor()) _printf0_("      creating vertex PIDs\n");
    216                         VerticesDofx(vertices,parameters); //only call once, we only have one set of vertices
    217                 }
    218 
    219                 if(VerboseMProcessor()) _printf0_("      resolving node constraints\n");
    220                 SpcNodesx(nodes,constraints,parameters,analysis_type);
    221 
    222                 if(VerboseMProcessor()) _printf0_("      creating nodal degrees of freedom\n");
    223                 NodesDofx(nodes,parameters,analysis_type);
    224 
    225                 if(VerboseMProcessor()) _printf0_("      configuring element and loads\n");
    226                 ConfigureObjectsx(elements, loads, nodes, vertices, materials,parameters);
    227         }
    228 
    229         /*Close input file and toolkits file descriptors: */
    230         if(my_rank==0) pfclose(IOMODEL,inputfilename);
    231         pfclose(toolkitsoptionsfid,toolkitsfilename);
    232 
    233         /*Open output file once for all and add output file name and file descriptor to parameters*/
    234         output_fid=pfopen(outputfilename,"wb");
    235         this->parameters->AddObject(new StringParam(OutputFileNameEnum,outputfilename));
    236         this->parameters->SetParam(output_fid,OutputFilePointerEnum);
    237 
    238         /*Save lock file name for later: */
    239         this->parameters->AddObject(new StringParam(LockFileNameEnum,lockfilename));
    240 
    241         }
    242254/*}}}*/
    243255void FemModel::SetStaticComm(void){/*{{{*/
     
    348360}
    349361/*}}}*/
     362FemModel* FemModel::copy(void){/*{{{*/
     363
     364        FemModel* output=NULL;
     365        int       i;
     366        int       analysis_type;
     367
     368        output=new FemModel(*this); //Use default copy constructor.
     369
     370        output->comm = this->comm;
     371        output->nummodels = this->nummodels;
     372        output->solution_type = this->solution_type;
     373        output->analysis_counter = this->analysis_counter;
     374
     375        /*Now, deep copy arrays: */
     376        output->analysis_type_list=xNew<int>(nummodels);
     377        xMemCpy<int>(output->analysis_type_list,this->analysis_type_list,this->nummodels);
     378
     379        output->profiler=static_cast<Profiler*>(this->profiler->copy());
     380
     381        output->loads=static_cast<Loads*>(this->loads->Copy());
     382        output->materials=static_cast<Materials*>(this->materials->Copy());
     383        output->parameters=static_cast<Parameters*>(this->parameters->Copy());
     384        output->constraints=static_cast<Constraints*>(this->constraints->Copy());
     385        output->results=static_cast<Results*>(this->results->Copy());
     386
     387        output->nodes=static_cast<Nodes*>(this->nodes->Copy());
     388        output->vertices=static_cast<Vertices*>(this->vertices->Copy());
     389        output->elements=static_cast<Elements*>(this->elements->Copy());
     390
     391        /*reset hooks for elements, loads and nodes: */
     392        output->elements->ResetHooks();
     393        output->loads->ResetHooks();
     394        output->materials->ResetHooks();
     395
     396        /*do the post-processing of the datasets to get an FemModel that can actually run analyses: */
     397        for(i=0;i<nummodels;i++){
     398                analysis_type=output->analysis_type_list[i];
     399                output->SetCurrentConfiguration(analysis_type);
     400                if(i==0) VerticesDofx(output->vertices,output->parameters); //only call once, we only have one set of vertices
     401                SpcNodesx(output->nodes,output->constraints,output->parameters,analysis_type);
     402                NodesDofx(output->nodes,output->parameters,analysis_type);
     403                ConfigureObjectsx(output->elements,output->loads,output->nodes,output->vertices,output->materials,output->parameters);
     404        }
     405
     406        return output;
     407}
     408/*}}}*/
     409
    350410/*Modules:*/
    351411int  FemModel::UpdateVertexPositionsx(void){ /*{{{*/
  • issm/trunk-jpl/src/c/classes/FemModel.h

    r18003 r18237  
    5252                /*Methods:*/
    5353                void Echo();
     54                FemModel* copy();
    5455                void InitFromFiles(char* rootpath, char* inputfilename, char* outputfilename, char* petscfilename, char* lockfilename, const int solution_type,const int* analyses,const int nummodels);
     56                void CleanUp(void);
    5557                void Solve(void);
    5658                void SetStaticComm();
  • issm/trunk-jpl/src/c/classes/Hook.cpp

    r18064 r18237  
    2929
    3030        /*Get out if num=0*/
    31         if (num==0){
     31        if (this->num<=0){
    3232                /*Empty hook*/
    3333                this->ids     = NULL;
    3434                this->objects = NULL;
    3535                this->offsets = NULL;
     36                this->num = 0;
    3637        }
    3738        else{
    3839                /*Allocate: */
    39                 this->objects=xNew<Object*>(this->num);
    40                 this->ids=xNew<int>(this->num);
    41                 this->offsets=xNew<int>(this->num);
     40                this->objects=xNew<Object*>(in_num);
     41                this->ids=xNew<int>(in_num);
     42                this->offsets=xNew<int>(in_num);
    4243
    4344                /*Copy ids: */
     
    109110
    110111        /*initalize output: */
    111         output=new Hook();
    112 
    113         /*copy in the fields: */
    114         output->num=this->num;
    115         if(output->num){
    116                 output->objects = xNew<Object*>(output->num);
    117                 output->ids     = xNew<int>(output->num);
    118                 output->offsets = xNew<int>(output->num);
    119         }
     112        output=new Hook(this->ids,this->num);
    120113
    121114        for(int i=0;i<output->num;i++){
    122115                output->objects[i] = this->objects[i];
    123116                output->offsets[i] = this->offsets[i];
    124                 output->ids[i]     = this->ids[i];
    125117        }
    126118
     
    130122
    131123/*Hook management: */
     124void Hook::reset(){/*{{{*/
     125
     126        /*intermediary: */
     127        Object* object=NULL;
     128        int i;
     129
     130        for(i=0;i<this->num;i++){
     131                        this->objects[i]=NULL; //reset this node.
     132        }
     133}
     134/*}}}*/
    132135void Hook::configure(DataSet* dataset){/*{{{*/
    133136
     
    161164                        else this->offsets[i]=UNDEF; //object offset was wrong, reset it.
    162165                }
     166                else this->offsets[i]=UNDEF;
    163167
    164168                /*Now, for this->objects that did not get resolved, and for which we have no offset, chase them in the dataset, by id: */
     
    174178
    175179        /*first, check that we only have one T object in our object list: */
    176         if (this->num!=1) _error_("trying to delivery a single hook object when hook holds " << this->num << " objects" << "\n");
     180        if (this->num!=1) _error_("trying to deliver a single hook object when hook holds " << this->num << " objects" << "\n");
    177181
    178182        /*check NULL: */
  • issm/trunk-jpl/src/c/classes/Hook.h

    r16233 r18237  
    3939                Object**   deliverp(void); //deliver all objects
    4040                void       configure(DataSet* dataset);
     41                void       reset(void);
    4142                Hook*      Spawn(int* indices, int numindices);
    4243                int*       Ids(void);
  • issm/trunk-jpl/src/c/classes/Inputs/DatasetInput.cpp

    r18064 r18237  
    6565        output = new DatasetInput();
    6666        output->enum_type=this->enum_type;
    67         output->inputs=(Inputs*)this->inputs->Copy();
     67        output->numids=this->numids;
     68        output->ids=xNew<int>(output->numids);
     69        xMemCpy(output->ids,this->ids,output->numids);
     70        output->inputs=static_cast<Inputs*>(this->inputs->Copy());
    6871
    69         return output;
     72        return (Object*)output;
    7073}
    7174/*}}}*/
     
    152155        /*Get requested input within dataset*/
    153156        for(int i=0;i<this->numids;i++) if(this->ids[i]==id) offset=i;
    154         if(offset<0) _error_("Could not find input of id "<<id);
     157        if(offset<0) _error_("Could not find input of id "<<id );
    155158
    156159        Input* input=dynamic_cast<Input*>(this->inputs->GetObjectByOffset(offset));
  • issm/trunk-jpl/src/c/classes/Inputs/PentaInput.cpp

    r18078 r18237  
    2020
    2121        /*Set Enum*/
    22         enum_type=in_enum_type;
     22        this->enum_type=in_enum_type;
    2323        this->interpolation_type=interpolation_type_in;
    2424
     25        int numnodes = this->NumberofNodes(this->interpolation_type);
     26
    2527        /*Set values*/
    26         this->values=xNew<IssmDouble>(this->NumberofNodes(this->interpolation_type));
    27         for(int i=0;i<this->NumberofNodes(this->interpolation_type);i++) values[i]=in_values[i];
     28        if (numnodes > 0){
     29                this->values=xNew<IssmDouble>((unsigned int)numnodes);
     30                for(int i=0;i<this->NumberofNodes(this->interpolation_type);i++) values[i]=in_values[i];
     31        }
     32        else{
     33                this->values = NULL;
     34        }
     35
    2836}
    2937/*}}}*/
  • issm/trunk-jpl/src/c/classes/Inputs/TetraInput.cpp

    r18078 r18237  
    2020
    2121        /*Set Enum*/
    22         enum_type=in_enum_type;
     22        this->enum_type=in_enum_type;
    2323        this->interpolation_type=interpolation_type_in;
    2424
     25        int numnodes = this->NumberofNodes(this->interpolation_type);
     26
    2527        /*Set values*/
    26         this->values=xNew<IssmDouble>(this->NumberofNodes(this->interpolation_type));
    27         for(int i=0;i<this->NumberofNodes(this->interpolation_type);i++) values[i]=in_values[i];
     28        if (numnodes > 0){
     29                this->values=xNew<IssmDouble>((unsigned int)numnodes);
     30                for(int i=0;i<this->NumberofNodes(this->interpolation_type);i++) values[i]=in_values[i];
     31        }
     32        else{
     33                this->values = NULL;
     34        }
     35
    2836}
    2937/*}}}*/
  • issm/trunk-jpl/src/c/classes/Inputs/TransientInput.cpp

    r18064 r18237  
    8080}
    8181/*}}}*/
    82 int    TransientInput::Id(void){ return -1; }/*{{{*/
    83 /*}}}*/
    84 int TransientInput::ObjectEnum(void){/*{{{*/
     82int  TransientInput::Id(void){ return -1; }/*{{{*/
     83/*}}}*/
     84int  TransientInput::ObjectEnum(void){/*{{{*/
    8585
    8686        return TransientInputEnum;
     
    9696        output->numtimesteps=this->numtimesteps;
    9797        output->timesteps=xNew<IssmDouble>(this->numtimesteps);
    98         xMemCpy(output->timesteps,this->timesteps,this->numtimesteps);
    99         output->inputs=(Inputs*)this->inputs->Copy();
     98        xMemCpy(output->timesteps,this->timesteps,this->numtimesteps);
     99        output->inputs=static_cast<Inputs*>(this->inputs->Copy());
    100100        output->parameters=this->parameters;
    101101
    102         return output;
     102        return (Object*)output;
    103103
    104104}
     
    315315}
    316316/*}}}*/
    317 int TransientInput::GetResultInterpolation(void){/*{{{*/
     317int  TransientInput::GetResultInterpolation(void){/*{{{*/
    318318
    319319        IssmDouble time;
     
    330330}
    331331/*}}}*/
    332 int TransientInput::GetResultNumberOfNodes(void){/*{{{*/
     332int  TransientInput::GetResultNumberOfNodes(void){/*{{{*/
    333333
    334334        IssmDouble time;
  • issm/trunk-jpl/src/c/classes/Inputs/TriaInput.cpp

    r18078 r18237  
    2020
    2121        /*Set Enum*/
    22         enum_type=in_enum_type;
     22        this->enum_type=in_enum_type;
    2323        this->interpolation_type=interpolation_type_in;
    2424
     25        int numnodes = this->NumberofNodes(this->interpolation_type);
     26
    2527        /*Set values*/
    26         this->values=xNew<IssmDouble>(this->NumberofNodes(this->interpolation_type));
    27         for(int i=0;i<this->NumberofNodes(this->interpolation_type);i++) values[i]=in_values[i];
     28        if (numnodes > 0){
     29                this->values=xNew<IssmDouble>((unsigned int)numnodes);
     30                for(int i=0;i<this->NumberofNodes(this->interpolation_type);i++) values[i]=in_values[i];
     31        }
     32        else{
     33                this->values = NULL;
     34        }
    2835}
    2936/*}}}*/
     
    4552}
    4653/*}}}*/
    47 int    TriaInput::Id(void){ return -1; }/*{{{*/
    48 /*}}}*/
    49 int TriaInput::ObjectEnum(void){/*{{{*/
     54int  TriaInput::Id(void){ return -1; }/*{{{*/
     55/*}}}*/
     56int  TriaInput::ObjectEnum(void){/*{{{*/
    5057
    5158        return TriaInputEnum;
  • issm/trunk-jpl/src/c/classes/Loads/Load.h

    r17266 r18237  
    2626                virtual       ~Load(){};
    2727                virtual void  Configure(Elements* elements,Loads* loads,Nodes* nodes,Vertices* vertices,Materials* materials,Parameters* parameters)=0;
     28                virtual void  ResetHooks()=0;
    2829                virtual bool  IsPenalty(void)=0;
    2930                virtual int   GetNumberOfNodes(void)=0;
  • issm/trunk-jpl/src/c/classes/Loads/Loads.cpp

    r18064 r18237  
    4343                load=dynamic_cast<Load*>(*object);
    4444                load->Configure(elements,loads,nodes,vertices,materials,parameters);
     45
     46        }
     47
     48}
     49/*}}}*/
     50void Loads::ResetHooks(){/*{{{*/
     51
     52        vector<Object*>::iterator object;
     53        Load* load=NULL;
     54
     55        for ( object=objects.begin() ; object < objects.end(); object++ ){
     56
     57                load=dynamic_cast<Load*>((*object));
     58                load->ResetHooks();
    4559
    4660        }
  • issm/trunk-jpl/src/c/classes/Loads/Loads.h

    r15067 r18237  
    2424                /*numerics*/
    2525                void  Configure(Elements* elements,Loads* loads, Nodes* nodes, Vertices* vertices, Materials* materials,Parameters* parameters);
     26                void  ResetHooks();
    2627                bool  IsPenalty(int analysis);
    2728                int   MaxNumNodes(int analysis);
  • issm/trunk-jpl/src/c/classes/Loads/Numericalflux.cpp

    r18078 r18237  
    158158}               
    159159/*}}}*/
    160 int    Numericalflux::Id(void){/*{{{*/
     160int Numericalflux::Id(void){/*{{{*/
    161161        return id;
    162162}
     
    215215/*}}}*/
    216216void  Numericalflux::SetCurrentConfiguration(Elements* elementsin,Loads* loadsin,Nodes* nodesin,Vertices* verticesin,Materials* materialsin,Parameters* parametersin){/*{{{*/
     217
     218}
     219/*}}}*/
     220void  Numericalflux::ResetHooks(){/*{{{*/
     221
     222        this->nodes=NULL;
     223        this->vertices=NULL;
     224        this->element=NULL;
     225        this->parameters=NULL;
     226
     227        /*Get Element type*/
     228        this->hnodes->reset();
     229        this->hvertices->reset();
     230        this->helement->reset();
    217231
    218232}
     
    277291}
    278292/*}}}*/
    279 void Numericalflux::GetNodesSidList(int* sidlist){/*{{{*/
     293void  Numericalflux::GetNodesSidList(int* sidlist){/*{{{*/
    280294
    281295        _assert_(sidlist);
     
    294308}
    295309/*}}}*/
    296 void Numericalflux::GetNodesLidList(int* lidlist){/*{{{*/
     310void  Numericalflux::GetNodesLidList(int* lidlist){/*{{{*/
    297311
    298312        _assert_(lidlist);
     
    311325}
    312326/*}}}*/
    313 int Numericalflux::GetNumberOfNodes(void){/*{{{*/
     327int   Numericalflux::GetNumberOfNodes(void){/*{{{*/
    314328
    315329        switch(this->flux_type){
     
    324338}
    325339/*}}}*/
    326 bool Numericalflux::IsPenalty(void){/*{{{*/
     340bool  Numericalflux::IsPenalty(void){/*{{{*/
    327341        return false;
    328342}
     
    342356}
    343357/*}}}*/
    344 bool Numericalflux::InAnalysis(int in_analysis_type){/*{{{*/
     358bool  Numericalflux::InAnalysis(int in_analysis_type){/*{{{*/
    345359        if (in_analysis_type==this->analysis_type) return true;
    346360        else return false;
    347361}
    348362/*}}}*/
    349 void Numericalflux::SetwiseNodeConnectivity(int* pd_nz,int* po_nz,Node* node,bool* flags,int* flagsindices,int set1_enum,int set2_enum){/*{{{*/
     363void  Numericalflux::SetwiseNodeConnectivity(int* pd_nz,int* po_nz,Node* node,bool* flags,int* flagsindices,int set1_enum,int set2_enum){/*{{{*/
    350364
    351365        /*Output */
  • issm/trunk-jpl/src/c/classes/Loads/Numericalflux.h

    r17269 r18237  
    5858                void Configure(Elements* elements,Loads* loads,Nodes* nodes,Vertices* vertices,Materials* materials,Parameters* parameters);
    5959                void SetCurrentConfiguration(Elements* elements,Loads* loads,Nodes* nodes,Vertices* vertices,Materials* materials,Parameters* parameters);
     60                void ResetHooks();
    6061                void CreateKMatrix(Matrix<IssmDouble>* Kff, Matrix<IssmDouble>* Kfs);
    6162                void CreatePVector(Vector<IssmDouble>* pf);
  • issm/trunk-jpl/src/c/classes/Loads/Pengrid.cpp

    r18064 r18237  
    160160}
    161161/*}}}*/
     162void  Pengrid::ResetHooks(){/*{{{*/
     163
     164        this->node=NULL;
     165        this->element=NULL;
     166        this->matpar=NULL;
     167        this->parameters=NULL;
     168
     169        /*Get Element type*/
     170        this->hnode->reset();
     171        this->helement->reset();
     172        this->hmatpar->reset();
     173
     174}
     175/*}}}*/
    162176void  Pengrid::CreateKMatrix(Matrix<IssmDouble>* Kff, Matrix<IssmDouble>* Kfs){/*{{{*/
    163177
     
    189203}
    190204/*}}}*/
    191 void Pengrid::GetNodesSidList(int* sidlist){/*{{{*/
     205void  Pengrid::GetNodesSidList(int* sidlist){/*{{{*/
    192206
    193207        _assert_(sidlist);
     
    197211}
    198212/*}}}*/
    199 void Pengrid::GetNodesLidList(int* lidlist){/*{{{*/
     213void  Pengrid::GetNodesLidList(int* lidlist){/*{{{*/
    200214
    201215        _assert_(lidlist);
     
    205219}
    206220/*}}}*/
    207 int Pengrid::GetNumberOfNodes(void){/*{{{*/
     221int   Pengrid::GetNumberOfNodes(void){/*{{{*/
    208222
    209223        return NUMVERTICES;
     
    268282}
    269283/*}}}*/
    270 bool Pengrid::InAnalysis(int in_analysis_type){/*{{{*/
     284bool  Pengrid::InAnalysis(int in_analysis_type){/*{{{*/
    271285        if (in_analysis_type==this->analysis_type)return true;
    272286        else return false;
    273287}
    274288/*}}}*/
    275 bool Pengrid::IsPenalty(void){/*{{{*/
     289bool  Pengrid::IsPenalty(void){/*{{{*/
    276290        return true;
    277291}
    278292/*}}}*/
    279 void Pengrid::SetwiseNodeConnectivity(int* pd_nz,int* po_nz,Node* node,bool* flags,int* flagsindices,int set1_enum,int set2_enum){/*{{{*/
     293void  Pengrid::SetwiseNodeConnectivity(int* pd_nz,int* po_nz,Node* node,bool* flags,int* flagsindices,int set1_enum,int set2_enum){/*{{{*/
    280294
    281295        /*Output */
  • issm/trunk-jpl/src/c/classes/Loads/Pengrid.h

    r17516 r18237  
    6868                void  Configure(Elements* elements,Loads* loads,Nodes* nodes,Vertices* vertices,Materials* materials,Parameters* parameters);
    6969                void  SetCurrentConfiguration(Elements* elements,Loads* loads,Nodes* nodes,Vertices* vertices,Materials* materials,Parameters* parameters);
     70                void  ResetHooks();
    7071                void  CreateKMatrix(Matrix<IssmDouble>* Kff, Matrix<IssmDouble>* Kfs);
    7172                void  CreatePVector(Vector<IssmDouble>* pf);
  • issm/trunk-jpl/src/c/classes/Loads/Penpair.cpp

    r18064 r18237  
    6565}               
    6666/*}}}*/
    67 int    Penpair::Id(void){ return id; }/*{{{*/
    68 /*}}}*/
    69 int Penpair::ObjectEnum(void){/*{{{*/
     67int  Penpair::Id(void){ return id; }/*{{{*/
     68/*}}}*/
     69int  Penpair::ObjectEnum(void){/*{{{*/
    7070
    7171        return PenpairEnum;
     
    113113}
    114114/*}}}*/
     115void  Penpair::ResetHooks(){/*{{{*/
     116
     117        this->nodes=NULL;
     118        this->parameters=NULL;
     119
     120        /*Get Element type*/
     121        this->hnodes->reset();
     122
     123}
     124/*}}}*/
    115125void  Penpair::CreateKMatrix(Matrix<IssmDouble>* Kff, Matrix<IssmDouble>* Kfs){/*{{{*/
    116126        /*If you code this piece, don't forget that a penalty will be inactive if it is dealing with clone nodes*/
     
    131141}
    132142/*}}}*/
    133 void Penpair::GetNodesSidList(int* sidlist){/*{{{*/
     143void  Penpair::GetNodesSidList(int* sidlist){/*{{{*/
    134144
    135145        _assert_(sidlist);
     
    139149}
    140150/*}}}*/
    141 void Penpair::GetNodesLidList(int* lidlist){/*{{{*/
     151void  Penpair::GetNodesLidList(int* lidlist){/*{{{*/
    142152
    143153        _assert_(lidlist);
     
    147157}
    148158/*}}}*/
    149 int Penpair::GetNumberOfNodes(void){/*{{{*/
     159int   Penpair::GetNumberOfNodes(void){/*{{{*/
    150160
    151161        return NUMVERTICES;
    152162}
    153163/*}}}*/
    154 bool Penpair::IsPenalty(void){/*{{{*/
     164bool  Penpair::IsPenalty(void){/*{{{*/
    155165        return true;
    156166}
     
    190200}
    191201/*}}}*/
    192 bool Penpair::InAnalysis(int in_analysis_type){/*{{{*/
     202bool  Penpair::InAnalysis(int in_analysis_type){/*{{{*/
    193203        if (in_analysis_type==this->analysis_type)return true;
    194204        else return false;
    195205}
    196206/*}}}*/
    197 void Penpair::SetwiseNodeConnectivity(int* pd_nz,int* po_nz,Node* node,bool* flags,int* flagsindices,int set1_enum,int set2_enum){/*{{{*/
     207void  Penpair::SetwiseNodeConnectivity(int* pd_nz,int* po_nz,Node* node,bool* flags,int* flagsindices,int set1_enum,int set2_enum){/*{{{*/
    198208
    199209        /*Output */
  • issm/trunk-jpl/src/c/classes/Loads/Penpair.h

    r16783 r18237  
    4848                        /*Load virtual functions definitions: {{{*/
    4949                void  Configure(Elements* elements,Loads* loads,Nodes* nodes,Vertices* vertices,Materials* materials,Parameters* parameters);
     50                void  ResetHooks();
    5051                void  SetCurrentConfiguration(Elements* elements,Loads* loads,Nodes* nodes,Vertices* vertices,Materials* materials,Parameters* parameters);
    5152                void  CreateKMatrix(Matrix<IssmDouble>* Kff, Matrix<IssmDouble>* Kfs);
  • issm/trunk-jpl/src/c/classes/Loads/Riftfront.cpp

    r18064 r18237  
    208208}
    209209/*}}}*/
    210 void    Riftfront::InputUpdateFromVector(IssmDouble* vector, int name, int type){/*{{{*/
     210void  Riftfront::InputUpdateFromVector(IssmDouble* vector, int name, int type){/*{{{*/
    211211
    212212        _error_("not implemented yet");
     
    216216
    217217/*Load virtual functions definitions:*/
    218 void  Riftfront::Configure(Elements* elementsin,Loads* loadsin,Nodes* nodesin,Vertices* verticesin,Materials* materialsin,Parameters* parametersin){/*{{{*/
     218void  Riftfront::Configure(Elements* elementsin,Loads* loadsin,Nodes* nodesin,Vertices* verticesin,Materials* materialsin,Parameters* parametersin){/*{{{*/     
    219219
    220220        /*Take care of hooking up all objects for this element, ie links the objects in the hooks to their respective
     
    234234}
    235235/*}}}*/
    236 bool Riftfront::IsPenalty(void){/*{{{*/
     236void  Riftfront::ResetHooks(){/*{{{*/
     237
     238        this->nodes=NULL;
     239        this->elements=NULL;
     240        this->matpar=NULL;
     241        this->parameters=NULL;
     242
     243        /*Get Element type*/
     244        this->hnodes->reset();
     245        this->helements->reset();
     246        this->hmatpar->reset();
     247
     248}
     249/*}}}*/
     250bool  Riftfront::IsPenalty(void){/*{{{*/
    237251        return true;
    238252}
     
    302316}
    303317/*}}}*/
    304 void Riftfront::GetNodesSidList(int* sidlist){/*{{{*/
     318void  Riftfront::GetNodesSidList(int* sidlist){/*{{{*/
    305319
    306320        _assert_(sidlist);
     
    310324}
    311325/*}}}*/
    312 void Riftfront::GetNodesLidList(int* lidlist){/*{{{*/
     326void  Riftfront::GetNodesLidList(int* lidlist){/*{{{*/
    313327
    314328        _assert_(lidlist);
     
    318332}
    319333/*}}}*/
    320 int Riftfront::GetNumberOfNodes(void){/*{{{*/
     334int   Riftfront::GetNumberOfNodes(void){/*{{{*/
    321335
    322336        return NUMVERTICES;
    323337}
    324338/*}}}*/
    325 bool Riftfront::InAnalysis(int in_analysis_type){/*{{{*/
     339bool  Riftfront::InAnalysis(int in_analysis_type){/*{{{*/
    326340        if (in_analysis_type==this->analysis_type) return true;
    327341        else return false;
    328342}
    329343/*}}}*/
    330 void Riftfront::SetwiseNodeConnectivity(int* pd_nz,int* po_nz,Node* node,bool* flags,int* flagsindices,int set1_enum,int set2_enum){/*{{{*/
     344void  Riftfront::SetwiseNodeConnectivity(int* pd_nz,int* po_nz,Node* node,bool* flags,int* flagsindices,int set1_enum,int set2_enum){/*{{{*/
    331345
    332346        /*Output */
     
    556570/*}}}*/
    557571#define _ZIGZAGCOUNTER_
    558 int Riftfront::Constrain(int* punstable){/*{{{*/
     572int    Riftfront::Constrain(int* punstable){/*{{{*/
    559573
    560574        IssmDouble  penetration;
  • issm/trunk-jpl/src/c/classes/Loads/Riftfront.h

    r17269 r18237  
    7474                /*Load virtual functions definitions: {{{*/
    7575                void  Configure(Elements* elements,Loads* loads,Nodes* nodes,Vertices* vertices,Materials* materials,Parameters* parameters);
     76                void  ResetHooks();
    7677                void  SetCurrentConfiguration(Elements* elements,Loads* loads,Nodes* nodes,Vertices* vertices,Materials* materials,Parameters* parameters);
    7778                void  CreateKMatrix(Matrix<IssmDouble>* Kff, Matrix<IssmDouble>* Kfs);
  • issm/trunk-jpl/src/c/classes/Materials/Material.h

    r18060 r18237  
    4141                virtual IssmDouble GetDbar()=0;
    4242                virtual bool       IsDamage()=0;
     43                virtual void       ResetHooks()=0;
    4344
    4445};
  • issm/trunk-jpl/src/c/classes/Materials/Materials.cpp

    r18064 r18237  
    4444}
    4545/*}}}*/
     46void Materials::ResetHooks(){/*{{{*/
     47
     48        vector<Object*>::iterator object;
     49        Material* material=NULL;
     50
     51        for ( object=objects.begin() ; object < objects.end(); object++ ){
     52
     53                material=dynamic_cast<Material*>((*object));
     54                material->ResetHooks();
     55
     56        }
     57
     58}
     59/*}}}*/
  • issm/trunk-jpl/src/c/classes/Materials/Materials.h

    r17275 r18237  
    2424                /*numerics*/
    2525                void  Configure(Elements* elements,Loads* loads, Nodes* nodes, Vertices* vertices, Materials* materials,Parameters* parameters);
     26                void  ResetHooks();
    2627
    2728};
  • issm/trunk-jpl/src/c/classes/Materials/Matice.cpp

    r18064 r18237  
    567567}
    568568/*}}}*/
     569void  Matice::ResetHooks(){/*{{{*/
     570
     571        this->element=NULL;
     572
     573        /*Get Element type*/
     574        this->helement->reset();
     575
     576}
     577/*}}}*/
  • issm/trunk-jpl/src/c/classes/Materials/Matice.h

    r18060 r18237  
    4141                Object* copy();
    4242                /*}}}*/
    43                 /*Update virtual functions definitions: {{{*/
     43                /*Update virtual funictions definitions: {{{*/
    4444                void  InputUpdateFromVector(IssmDouble* vector, int name, int type);
    4545                void  InputUpdateFromMatrixDakota(IssmDouble* matrix, int nrow, int ncols, int name, int type);
     
    7070                IssmDouble GetN();
    7171                bool       IsDamage();
     72                void       ResetHooks();
    7273                /*}}}*/
    7374};
  • issm/trunk-jpl/src/c/classes/Materials/Matpar.cpp

    r18064 r18237  
    135135/*}}}*/
    136136Object* Matpar::copy() {/*{{{*/
    137         return new Matpar(*this);
     137
     138        /*Output*/
     139        Matpar* matpar;
     140
     141        /*Initialize output*/
     142        matpar=new Matpar(*this);
     143
     144        /*copy fields: */
     145        matpar->mid=this->mid;
     146        matpar->rho_ice=this->rho_ice;
     147        matpar->rho_water=this->rho_water;
     148        matpar->rho_freshwater=this->rho_freshwater;
     149        matpar->mu_water=this->mu_water;
     150        matpar->heatcapacity=this->heatcapacity;
     151        matpar->thermalconductivity=this->thermalconductivity;
     152        matpar->temperateiceconductivity=this->temperateiceconductivity;
     153        matpar->latentheat=this->latentheat;
     154        matpar->beta=this->beta;
     155        matpar->meltingpoint=this->meltingpoint;
     156        matpar->referencetemperature=this->referencetemperature;
     157        matpar->mixed_layer_capacity=this->mixed_layer_capacity;
     158        matpar->thermal_exchange_velocity=this->thermal_exchange_velocity;
     159        matpar->g=this->g;
     160        matpar->desfac=this->desfac;
     161        matpar->s0p=this->s0p;
     162
     163        matpar->sediment_compressibility=this->sediment_compressibility;
     164        matpar->sediment_porosity=this->sediment_porosity;
     165        matpar->sediment_thickness=this->sediment_thickness;
     166        matpar->water_compressibility=this->water_compressibility;
     167
     168        matpar->epl_compressibility=this->epl_compressibility;
     169        matpar->epl_porosity=this->epl_porosity;
     170        matpar->epl_init_thickness=this->epl_init_thickness;
     171        matpar->epl_max_thickness=this->epl_max_thickness;
     172        matpar->epl_conductivity=this->epl_conductivity;
     173
     174        matpar->lithosphere_shear_modulus=this->lithosphere_shear_modulus;
     175        matpar->lithosphere_density=this->lithosphere_density;
     176        matpar->mantle_shear_modulus=this->mantle_shear_modulus;
     177        matpar->mantle_density=this->mantle_density;
     178
     179        return matpar;
    138180}
    139181/*}}}*/
     
    401443}               
    402444/*}}}*/
     445void  Matpar::ResetHooks(){/*{{{*/
     446
     447        //Nothing to be done
     448        return;
     449}
     450/*}}}*/
  • issm/trunk-jpl/src/c/classes/Materials/Matpar.h

    r18060 r18237  
    9191                IssmDouble GetDbar(){_error_("not supported");};
    9292                bool       IsDamage(){_error_("not supported");};
     93                void       ResetHooks();
    9394                /*}}}*/
    9495                /*Numerics: {{{*/
  • issm/trunk-jpl/src/c/classes/Misfit.h

    r18064 r18237  
    8888                /*}}}*/
    8989                Object* copy() {/*{{{*/
    90                         return new Misfit(this->name,this->model_enum,this->observation_enum,this->timeinterpolation,this->weights_enum);
     90                        Misfit* mf = new Misfit(this->name,this->model_enum,this->observation_enum,this->timeinterpolation,this->weights_enum);
     91                        mf->misfit=this->misfit;
     92                        mf->lock=this->lock;
     93                        return (Object*) mf;
    9194                }
    9295                /*}}}*/
  • issm/trunk-jpl/src/c/classes/Node.cpp

    r18064 r18237  
    125125}
    126126/*}}}*/
     127Object* Node::copy(void){/*{{{*/
     128
     129        int k,l;
     130
     131        /*output: */
     132        Node* output=NULL;
     133
     134        /*initalize output: */
     135        output=new Node();
     136
     137        /*id: */
     138        output->id  = this->id;
     139        output->sid = this->sid;
     140        output->lid = this->lid;
     141        output->analysis_enum = this->analysis_enum;
     142        output->approximation = this->approximation;
     143
     144        /*Initialize coord_system: */
     145        for(k=0;k<3;k++) for(l=0;l<3;l++) output->coord_system[k][l]=this->coord_system[k][l];
     146
     147        /*indexing:*/
     148        output->indexingupdate = this->indexingupdate;
     149        output->indexing.copy(this->indexing);
     150
     151        return (Object*)output;
     152}
     153/*}}}*/
    127154
    128155/*Object virtual functions definitions:*/
     
    514541                else if (setenum==SsetEnum){
    515542                        if(this->indexing.doftype){
    516                                 numdofs=0;
     543                        numdofs=0;
    517544                                for(i=0;i<this->indexing.gsize;i++){
    518545                                        if((this->indexing.doftype[i]==approximation_enum) && (this->indexing.s_set[i])) numdofs++;
  • issm/trunk-jpl/src/c/classes/Node.h

    r17255 r18237  
    4949                int     Id();
    5050                int     ObjectEnum();
    51                 Object *copy(){_error_("Not implemented yet (similar to Elements)"); };
     51                Object *copy();
    5252
    5353                /*Node numerical routines*/
  • issm/trunk-jpl/src/c/classes/Params/DoubleParam.cpp

    r18064 r18237  
    3838}
    3939/*}}}*/
    40 int    DoubleParam::Id(void){ return -1; }/*{{{*/
     40int  DoubleParam::Id(void){ return -1; }/*{{{*/
    4141/*}}}*/
    42 int DoubleParam::ObjectEnum(void){/*{{{*/
     42int  DoubleParam::ObjectEnum(void){/*{{{*/
    4343
    4444        return DoubleParamEnum;
  • issm/trunk-jpl/src/c/classes/Params/Parameters.cpp

    r18064 r18237  
    108108                }
    109109        }
    110         _error_("could not find parameter " << EnumToStringx(enum_type));
     110        _error_("could not find parameter " <<  EnumToStringx(enum_type));
    111111}
    112112/*}}}*/
  • issm/trunk-jpl/src/c/classes/Profiler.cpp

    r18063 r18237  
    2929}
    3030/*}}}*/
     31Object* Profiler::copy(){/*{{{*/
     32        /*First do simple copy: */
     33        Profiler* output=new Profiler();
     34        delete output->time;
     35        delete output->flops;
     36        delete output->memory;
     37
     38        /*Now for deep copy: */
     39        output->time=(Parameters*)this->time->Copy();
     40        output->flops=(Parameters*)this->flops->Copy();
     41        output->memory=(Parameters*)this->memory->Copy();
     42
     43        return (Object*)output;
     44}
     45/*}}}*/
    3146
    3247/*Object virtual functions definitions:*/
     
    4762}
    4863/*}}}*/
    49 int    Profiler::Id(void){ return -1; }/*{{{*/
     64int  Profiler::Id(void){ return -1; }/*{{{*/
    5065/*}}}*/
    51 int Profiler::ObjectEnum(void){/*{{{*/
     66int  Profiler::ObjectEnum(void){/*{{{*/
    5267
    5368        return ProfilerEnum;
  • issm/trunk-jpl/src/c/classes/Profiler.h

    r15067 r18237  
    4242                int     Id();
    4343                int     ObjectEnum();
    44                 Object *copy()        {_error_("Not implemented yet"); };
     44                Object *copy();
    4545                /*}}}*/
    4646                /*Profiler routines {{{*/
  • issm/trunk-jpl/src/c/classes/kriging/ExponentialVariogram.cpp

    r18064 r18237  
    4949}
    5050/*}}}*/
     51Object* ExponentialVariogram::copy(void){/*{{{*/
     52           return new ExponentialVariogram(*this);
     53}
     54/*}}}*/
    5155
    5256/*Variogram function*/
  • issm/trunk-jpl/src/c/classes/kriging/ExponentialVariogram.h

    r13414 r18237  
    2626                int   Id(){_error_("Not implemented yet");};
    2727                int   ObjectEnum(){_error_("Not implemented yet");};
    28                 Object* copy(){_error_("Not implemented yet");};
     28                Object* copy();
    2929
    3030                /*Variogram functions*/
  • issm/trunk-jpl/src/c/classes/kriging/GaussianVariogram.cpp

    r18064 r18237  
    4949}
    5050/*}}}*/
     51Object* GaussianVariogram::copy(void){/*{{{*/
     52           return new GaussianVariogram(*this);
     53}
     54/*}}}*/
    5155
    5256/*Variogram function*/
  • issm/trunk-jpl/src/c/classes/kriging/GaussianVariogram.h

    r13414 r18237  
    2727                int   Id(){_error_("Not implemented yet");};
    2828                int   ObjectEnum(){_error_("Not implemented yet");};
    29                 Object* copy(){_error_("Not implemented yet");};
     29                Object* copy();
    3030
    3131                /*Variogram functions*/
  • issm/trunk-jpl/src/c/classes/kriging/Observation.cpp

    r18064 r18237  
    4141}
    4242/*}}}*/
     43Object* Observation::copy(void){/*{{{*/
     44
     45        Observation* observation = new Observation(this->x,this->y,this->xi,this->yi,this->index,this->value);
     46
     47        observation->weight = this->weight;
     48
     49        return (Object*) observation;
     50
     51}
     52/*}}}*/
    4353
    4454/*Observations functions*/
  • issm/trunk-jpl/src/c/classes/kriging/Observation.h

    r15067 r18237  
    2727                int     Id()        {_error_("Not implemented yet"); };
    2828                int     ObjectEnum(){_error_("Not implemented yet"); };
    29                 Object *copy()      {_error_("Not implemented yet"); };
     29                Object *copy();
    3030
    3131                /*Management*/
  • issm/trunk-jpl/src/c/classes/kriging/PowerVariogram.cpp

    r18064 r18237  
    5050}
    5151/*}}}*/
     52Object* PowerVariogram::copy(void){/*{{{*/
     53           return new PowerVariogram(*this);
     54}
     55/*}}}*/
    5256
    5357/*Variogram function*/
  • issm/trunk-jpl/src/c/classes/kriging/PowerVariogram.h

    r13414 r18237  
    2626                int   Id(){_error_("Not implemented yet");};
    2727                int   ObjectEnum(){_error_("Not implemented yet");};
    28                 Object* copy(){_error_("Not implemented yet");};
     28                Object* copy();
    2929
    3030                /*Variogram functions*/
  • issm/trunk-jpl/src/c/classes/kriging/Quadtree.cpp

    r18064 r18237  
    498498
    499499}/*}}}*/
     500Object* Quadtree::QuadtreeBox::copy(void){/*{{{*/
     501
     502           QuadtreeBox* qtreebox = new QuadtreeBox(*this);
     503
     504                if (this->box){
     505                        for (int i=0; i<4; ++i){
     506                                if(this->box[i]) qtreebox->box[i] = reinterpret_cast<QuadtreeBox*>(this->box[i]->copy());
     507                                else qtreebox->box[i] = NULL;
     508                        }
     509                }
     510                if (this->obs){
     511                        for (int i=0; i<4; ++i){
     512                                if(this->obs[i]) qtreebox->obs[i] = reinterpret_cast<Observation*>(this->obs[i]->copy());
     513                                else qtreebox->obs[i] = NULL;
     514                        }
     515                }
     516
     517                return (Object*) qtreebox;
     518}
     519/*}}}*/
    500520int Quadtree::QuadtreeBox::IsWithinRange(double x,double y,double range){/*{{{*/
    501521
  • issm/trunk-jpl/src/c/classes/kriging/Quadtree.h

    r13414 r18237  
    3030                                int     Id()        {_error_("not implemented yet"); };
    3131                                int     ObjectEnum(){_error_("not implemented yet"); };
    32                                 Object *copy()      {_error_("not implemented yet"); };
     32                                Object *copy();
    3333
    3434                                /*Methods*/
  • issm/trunk-jpl/src/c/classes/kriging/SphericalVariogram.cpp

    r18064 r18237  
    4949}
    5050/*}}}*/
     51Object* SphericalVariogram::copy(void){/*{{{*/
     52        return new SphericalVariogram(*this);
     53}
     54/*}}}*/
    5155
    5256/*Variogram function*/
  • issm/trunk-jpl/src/c/classes/kriging/SphericalVariogram.h

    r13414 r18237  
    2626                int   Id(){_error_("Not implemented yet");};
    2727                int   ObjectEnum(){_error_("Not implemented yet");};
    28                 Object* copy(){_error_("Not implemented yet");};
     28                Object* copy();
    2929
    3030                /*Variogram functions*/
  • issm/trunk-jpl/src/c/cores/DakotaSpawnCore.cpp

    r16518 r18237  
    5151        if(counter==-1)return 0;
    5252
    53         /*cast void_femmodel to FemModel: */
    54         femmodel=reinterpret_cast<FemModel*>(void_femmodel);
     53        /*cast void_femmodel to FemModel, and at the same time, make a copy, so we start this new core run for this specific sample
     54         *with a brand new copy of the model, which has not been tempered with by previous dakota runs: */
     55        femmodel=(reinterpret_cast<FemModel*>(void_femmodel))->copy();
    5556
    5657        /*retrieve parameters: */
     
    8081        /*Free ressources:*/
    8182        DakotaFree(&d_variables,&d_variables_descriptors,&responses_descriptors, d_numvariables, numresponsedescriptors);
     83
     84        /*Avoid leaks here: */
     85        delete femmodel;
    8286
    8387        return 1; //this is critical! do not return 0, otherwise, dakota_core will stop running!
  • issm/trunk-jpl/src/c/cores/damage_core.cpp

    r17391 r18237  
    2222        //first recover parameters common to all solutions
    2323        femmodel->parameters->FindParam(&save_results,SaveResultsEnum);
    24         femmodel->parameters->FindParam(&dakota_analysis,QmuIsdakotaEnum);
    2524        femmodel->parameters->FindParam(&solution_type,SolutionTypeEnum);
    2625        femmodel->parameters->FindParam(&numoutputs,DamageEvolutionNumRequestedOutputsEnum);
    2726        if(numoutputs) femmodel->parameters->FindParam(&requested_outputs,&numoutputs,DamageEvolutionRequestedOutputsEnum);
    28 
    29         if(dakota_analysis && solution_type!=TransientSolutionEnum){
    30                 femmodel->SetCurrentConfiguration(DamageEvolutionAnalysisEnum);
    31                 ResetConstraintsx(femmodel);
    32         }
    3327
    3428        if(VerboseSolution()) _printf0_("   computing damage\n");
  • issm/trunk-jpl/src/c/cores/masstransport_core.cpp

    r17924 r18237  
    2626        femmodel->parameters->FindParam(&isFS,FlowequationIsFSEnum);
    2727        femmodel->parameters->FindParam(&isfreesurface,MasstransportIsfreesurfaceEnum);
    28         femmodel->parameters->FindParam(&dakota_analysis,QmuIsdakotaEnum);
    2928        femmodel->parameters->FindParam(&solution_type,SolutionTypeEnum);
    3029        femmodel->parameters->FindParam(&domaintype,DomainTypeEnum);
    3130        femmodel->parameters->FindParam(&numoutputs,MasstransportNumRequestedOutputsEnum);
    3231        if(numoutputs) femmodel->parameters->FindParam(&requested_outputs,&numoutputs,MasstransportRequestedOutputsEnum);
    33 
    34         /*for qmu analysis, reinitialize velocity so that fake sensitivities do not show up as a result of a different restart of the convergence at each trial.*/
    35         if(dakota_analysis && solution_type==MasstransportSolutionEnum){
    36                 InputDuplicatex(femmodel,QmuSurfaceEnum,SurfaceEnum);
    37                 InputDuplicatex(femmodel,QmuThicknessEnum,ThicknessEnum);
    38                 InputDuplicatex(femmodel,QmuBaseEnum,BaseEnum);
    39         }
    4032
    4133        /*Calculate new Surface Mass Balance (SMB)*/
  • issm/trunk-jpl/src/c/cores/stressbalance_core.cpp

    r17700 r18237  
    3030        femmodel->parameters->FindParam(&isHO,FlowequationIsHOEnum);
    3131        femmodel->parameters->FindParam(&isFS,FlowequationIsFSEnum);
    32         femmodel->parameters->FindParam(&dakota_analysis,QmuIsdakotaEnum);
    3332        femmodel->parameters->FindParam(&save_results,SaveResultsEnum);
    3433        femmodel->parameters->FindParam(&solution_type,SolutionTypeEnum);
    3534        femmodel->parameters->FindParam(&numoutputs,StressbalanceNumRequestedOutputsEnum);
    3635        if(numoutputs) femmodel->parameters->FindParam(&requested_outputs,&numoutputs,StressbalanceRequestedOutputsEnum);
    37 
    38         /*for qmu analysis, reinitialize velocity so that fake sensitivities do not show up as a result of a different restart of the convergence at each trial.*/
    39         if(dakota_analysis && solution_type==StressbalanceSolutionEnum){
    40                 InputDuplicatex(femmodel,QmuVxEnum,VxEnum);
    41                 InputDuplicatex(femmodel,QmuVyEnum,VyEnum);
    42                 if(domaintype==Domain3DEnum) InputDuplicatex(femmodel,QmuVzEnum,VzEnum);
    43                 if(isFS) InputDuplicatex(femmodel,QmuPressureEnum,PressureEnum);
    44         }
    4536
    4637        /*Compute slopes if necessary */
  • issm/trunk-jpl/src/c/cores/thermal_core.cpp

    r18068 r18237  
    2222        /*first recover parameters common to all solutions*/
    2323        femmodel->parameters->FindParam(&save_results,SaveResultsEnum);
    24         femmodel->parameters->FindParam(&dakota_analysis,QmuIsdakotaEnum);
    2524        femmodel->parameters->FindParam(&solution_type,SolutionTypeEnum);
    2625        femmodel->parameters->FindParam(&isenthalpy,ThermalIsenthalpyEnum);
    2726        femmodel->parameters->FindParam(&numoutputs,ThermalNumRequestedOutputsEnum);
    2827        if(numoutputs) femmodel->parameters->FindParam(&requested_outputs,&numoutputs,ThermalRequestedOutputsEnum);
    29 
    30         if(dakota_analysis && solution_type!=TransientSolutionEnum){
    31                 InputDuplicatex(femmodel,QmuVxMeshEnum,VxMeshEnum);
    32                 InputDuplicatex(femmodel,QmuVyMeshEnum,VyMeshEnum);
    33                 InputDuplicatex(femmodel,QmuVzMeshEnum,VzMeshEnum);
    34                 InputDuplicatex(femmodel,QmuTemperatureEnum,TemperatureEnum);
    35                 InputDuplicatex(femmodel,QmuMeltingEnum,BasalforcingsGroundediceMeltingRateEnum);
    36                 InputDuplicatex(femmodel,QmuMaterialsRheologyBEnum,MaterialsRheologyBEnum);
    37                 femmodel->SetCurrentConfiguration(ThermalAnalysisEnum);
    38                 ResetConstraintsx(femmodel);
    39         }
    4028
    4129        if(isenthalpy){
  • issm/trunk-jpl/src/c/cores/transient_core.cpp

    r18094 r18237  
    6060        step=0;
    6161        time=starttime;
    62 
    63         /*for qmu analysis, reinitialize velocity so that fake sensitivities do not show up as a result of a different restart of the convergence at each trial.*/
    64         if(dakota_analysis){
    65                 if(isstressbalance){
    66                         InputDuplicatex(femmodel,QmuVxEnum,VxEnum);
    67                         InputDuplicatex(femmodel,QmuVyEnum,VyEnum);
    68                         if(domaintype==Domain3DEnum){
    69                                 InputDuplicatex(femmodel,QmuVzEnum,VzEnum);
    70                                 if(isFS)InputDuplicatex(femmodel,QmuPressureEnum,PressureEnum);
    71                         }
    72                 }
    73                 if(ismasstransport || isgroundingline){
    74                         InputDuplicatex(femmodel,QmuThicknessEnum,ThicknessEnum);
    75                         InputDuplicatex(femmodel,QmuSurfaceEnum,SurfaceEnum);
    76                         InputDuplicatex(femmodel,QmuBaseEnum,BaseEnum);
    77                         InputDuplicatex(femmodel,QmuMaskIceLevelsetEnum,MaskIceLevelsetEnum);
    78                 }
    79                 if(isgroundingline) InputDuplicatex(femmodel,QmuMaskGroundediceLevelsetEnum,MaskGroundediceLevelsetEnum);
    80                 if(isthermal && domaintype==Domain3DEnum){
    81                         //Update Vertex Position after updating Thickness and Bed
    82                         femmodel->SetCurrentConfiguration(MasstransportAnalysisEnum);
    83                         femmodel->UpdateVertexPositionsx();
    84                         InputDuplicatex(femmodel,QmuVxMeshEnum,VxMeshEnum);
    85                         InputDuplicatex(femmodel,QmuVyMeshEnum,VyMeshEnum);
    86                         InputDuplicatex(femmodel,QmuVzMeshEnum,VzMeshEnum);
    87                         InputDuplicatex(femmodel,QmuTemperatureEnum,TemperatureEnum);
    88                         InputDuplicatex(femmodel,QmuMeltingEnum,BasalforcingsGroundediceMeltingRateEnum);
    89                         InputDuplicatex(femmodel,QmuMaterialsRheologyBEnum,MaterialsRheologyBEnum);
    90                         //Reset Thermal Constraints
    91                         femmodel->SetCurrentConfiguration(ThermalAnalysisEnum);
    92                         ResetConstraintsx(femmodel);
    93                 }
    94         }
    9562
    9663        while(time < finaltime - (yts*DBL_EPSILON)){ //make sure we run up to finaltime.
  • issm/trunk-jpl/src/c/datastructures/DataSet.cpp

    r18063 r18237  
    2727
    2828        sorted=0;
     29        numsorted=0;
    2930        sorted_ids=NULL;
    3031        id_offsets=NULL;
     
    4142}
    4243/*}}}*/
    43 DataSet*   DataSet::Copy(void){/*{{{*/
    44 
    45         vector<Object*>::iterator object;
     44DataSet* DataSet::Copy(void){/*{{{*/
     45
     46        vector<Object*>::iterator obj;
    4647        Object* object_copy=NULL;
    4748
    48         DataSet* copy=new DataSet(enum_type);
    49 
    50         copy->sorted=sorted;
    51         copy->presorted=presorted;
    52         if(sorted_ids){
    53                 copy->sorted_ids=xNew<int>(objects.size());
    54                 xMemCpy<int>(copy->sorted_ids,sorted_ids,objects.size());
    55         }
    56         if(id_offsets){
    57                 copy->id_offsets=xNew<int>(objects.size());
    58                 xMemCpy<int>(copy->id_offsets,id_offsets,objects.size());
    59         }
     49        DataSet* copy=new DataSet(this->enum_type);
     50
     51        copy->sorted=this->sorted;
     52        copy->numsorted=this->numsorted;
     53        copy->presorted=this->presorted;
    6054
    6155        /*Now we need to deep copy the objects: */
    62         for ( object=objects.begin() ; object < objects.end(); object++ ){
    63 
    64                 /*Call echo on object: */
    65                 object_copy = (*object)->copy();
     56        for ( obj=this->objects.begin() ; obj < this->objects.end(); obj++ ){
     57                /*Call copy on object: */
     58                object_copy = (*obj)->copy();
    6659                copy->AddObject(object_copy);
    6760        }
     61
     62        /*Build id_offsets and sorted_ids*/
     63        int objsize = this->numsorted;
     64        if(this->sorted && objsize>0 && this->id_offsets){     
     65                /*Allocate new ids*/
     66                copy->id_offsets=xNew<int>(objsize);
     67                xMemCpy<int>(copy->id_offsets,this->id_offsets,objsize);
     68        }
     69        else copy->id_offsets=NULL;
     70        if(this->sorted && objsize>0 && this->sorted_ids){
     71                /*Allocate new ids*/
     72                copy->sorted_ids=xNew<int>(objsize);
     73                xMemCpy<int>(copy->sorted_ids,this->sorted_ids,objsize);
     74        }
     75        else copy->sorted_ids=NULL;
     76
    6877        return copy;
    6978}
     
    7786
    7887/*Specific methods*/
    79 int  DataSet::AddObject(Object* object){/*{{{*/
     88int   DataSet::AddObject(Object* object){/*{{{*/
    8089
    8190        _assert_(this);
     
    102111}
    103112/*}}}*/
    104 int  DataSet::DeleteObject(Object* object){/*{{{*/
     113int   DataSet::DeleteObject(Object* object){/*{{{*/
    105114
    106115        vector<Object*>::iterator iterator;
     
    116125}
    117126/*}}}*/
    118 void DataSet::DeepEcho(){/*{{{*/
     127void  DataSet::DeepEcho(){/*{{{*/
    119128
    120129        vector<Object*>::iterator object;
     
    132141}
    133142/*}}}*/
    134 void DataSet::Echo(){/*{{{*/
     143void  DataSet::Echo(){/*{{{*/
    135144
    136145        vector<Object*>::iterator object;
     
    149158}
    150159/*}}}*/
    151 int  DataSet::GetEnum(){/*{{{*/
     160int   DataSet::GetEnum(){/*{{{*/
    152161        return enum_type;
    153162}
     
    176185
    177186        _assert_(this);
    178         if(!sorted)_error_("trying to binary search on a non-sorted dataset!");
     187        if(!sorted || objects.size()>numsorted)_error_("trying to binary search on a non-sorted dataset!");
    179188
    180189        /*Carry out a binary search on the sorted_ids: */
     
    193202}
    194203/*}}}*/
    195 void DataSet::Presort(){/*{{{*/
     204void  DataSet::Presort(){/*{{{*/
    196205
    197206        /*vector of objects is already sorted, just allocate the sorted ids and their
     
    200209
    201210                /*Delete existing ids*/
    202                 xDelete<int>(sorted_ids);
    203                 xDelete<int>(id_offsets);
     211                if(sorted_ids) xDelete<int>(sorted_ids);
     212                if(id_offsets) xDelete<int>(id_offsets);
    204213
    205214                /*Allocate new ids*/
     
    215224
    216225        /*set sorted flag: */
     226        numsorted=objects.size();
    217227        sorted=1;
    218228}
    219229/*}}}*/
    220 int  DataSet::Size(void){/*{{{*/
     230int   DataSet::Size(void){/*{{{*/
    221231        _assert_(this!=NULL);
    222232
     
    224234}
    225235/*}}}*/
    226 void DataSet::Sort(){/*{{{*/
     236void  DataSet::Sort(){/*{{{*/
    227237
    228238        /*Only sort if we are not already sorted: */
  • issm/trunk-jpl/src/c/datastructures/DataSet.h

    r15067 r18237  
    2525                int             sorted;
    2626                int             presorted;
     27                int             numsorted;
    2728                int*            sorted_ids;
    2829                int*            id_offsets;
  • issm/trunk-jpl/src/c/main/issm.cpp

    r16591 r18237  
    2323
    2424        /*Wrap up: */
     25        femmodel->CleanUp();
     26
     27        /*Delete Model: */
    2528        delete femmodel;
    2629
  • issm/trunk-jpl/src/c/modules/ModelProcessorx/CreateElementsVerticesAndMaterials.cpp

    r17757 r18237  
    5656                                case 2:
    5757                                        elements->InputDuplicate(MaterialsRheologyBEnum,MaterialsRheologyBbarEnum);
    58                                         if(dakota_analysis) elements->InputDuplicate(MaterialsRheologyBbarEnum,QmuMaterialsRheologyBEnum);
    5958                                        break;
    6059                                case 3:
    61                                         if(dakota_analysis) elements->InputDuplicate(MaterialsRheologyBEnum,QmuMaterialsRheologyBEnum);
    6260                                        break;
    6361                                default:
     
    7472                                        elements->InputDuplicate(MaterialsRheologyBEnum,MaterialsRheologyBbarEnum);
    7573                                        elements->InputDuplicate(DamageDEnum,DamageDbarEnum);
    76                                         if(dakota_analysis) elements->InputDuplicate(MaterialsRheologyBbarEnum,QmuMaterialsRheologyBEnum);
    7774                                        break;
    7875                                case 3:
    79                                         if(dakota_analysis) elements->InputDuplicate(MaterialsRheologyBEnum,QmuMaterialsRheologyBEnum);
    8076                                        break;
    8177                                default:
  • issm/trunk-jpl/src/c/toolkits/issm/Bucket.h

    r16158 r18237  
    125125                } /*}}}*/
    126126                Object *copy()        {/*{{{*/
    127                         _error_("Not implemented yet (similar to Elements)"); };
     127                        if (this->type==MATRIX_BUCKET) return new Bucket(this->m,this->idxm,this->n,this->idxn,this->values,this->mode);
     128                        else if (this->type==VECTOR_BUCKET) return new Bucket(this->m,this->idxm,this->values,this->mode);
     129                        else _error_("No Copy of Bucket because its type is invalid."); };
    128130                /*}}}*/
    129131
Note: See TracChangeset for help on using the changeset viewer.