Changeset 4396


Ignore:
Timestamp:
07/04/10 12:39:52 (15 years ago)
Author:
Eric.Larour
Message:

Made Hooks in object a pointer. Makes for an easier Hook interface

Location:
issm/trunk/src/c/objects
Files:
23 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk/src/c/objects/Elements/Penta.cpp

    r4395 r4396  
    4141/*}}}*/
    4242/*FUNCTION Penta::Penta(int id, int index, IoModel* iomodel,int nummodels) {{{1*/
    43 Penta::Penta(int penta_id, int index, IoModel* iomodel,int nummodels){ //i is the element index
    44 
    45         IssmInt i;
    46         int penta_matice_id;
    47         int penta_matpar_id;
     43Penta::Penta(int penta_id, int index, IoModel* iomodel,int nummodels):
     44
     45        PentaHook(nummodels,index+1,iomodel->numberofelements+1) //index+1: matice id, iomodel->numberofelements+1: matpar id
     46                                                                      { //i is the element index
     47
     48        int i;
    4849        int penta_elements_ids[2];
    4950
     
    5152        this->id=penta_id;
    5253
    53         /*hooks: */
    54         penta_matice_id=index+1; //refers to the corresponding ice material object
    55         penta_matpar_id=iomodel->numberofelements+1; //refers to the constant material parameters object
    56 
     54        /*penta_elements_ids: */
    5755        if isnan(iomodel->upperelements[index]){
    5856                penta_elements_ids[1]=this->id; //upper penta is the same penta
     
    6866                penta_elements_ids[0]=(int)(iomodel->lowerelements[index]);
    6967        }
    70         this->InitHookNodes(nummodels);this->nodes=NULL;
    71         this->InitHookMatice(penta_matice_id);this->matice=NULL;
    72         this->InitHookMatpar(penta_matpar_id);this->matpar=NULL;
    73         this->InitHookNeighbors(penta_elements_ids);this->neighbors=NULL;
     68        this->InitHookNeighbors(penta_elements_ids);
    7469
    7570        //this->parameters: we still can't point to it, it may not even exist. Configure will handle this.
     
    7974        this->inputs=new Inputs();
    8075        this->results=new Results();
     76       
     77        /*initialize pointers:*/
     78        this->nodes=NULL;
     79        this->matice=NULL;
     80        this->matpar=NULL;
     81        this->neighbors=NULL;
    8182}
    8283/*}}}*/
     
    9293        penta=new Penta();
    9394
    94         /*copy fields: */
     95        //deal with PentaHook mother class
     96        penta->numanalyses=this->numanalyses;
     97        penta->hnodes=new Hook*[penta->numanalyses];
     98        for(i=0;i<penta->numanalyses;i++)penta->hnodes[i]=(Hook*)this->hnodes[i]->copy();
     99        penta->hmatice=(Hook*)this->hmatice->copy();
     100        penta->hmatpar=(Hook*)this->hmatpar->copy();
     101        penta->hneighbors=(Hook*)this->hneighbors->copy();
     102
     103        /*deal with Penta  copy fields: */
    95104        penta->id=this->id;
    96105        if(this->inputs){
     
    109118        penta->parameters=this->parameters;
    110119
    111         /*now deal with hooks and objects: */
    112         penta->InitHookNodes(this->numanalyses);
    113         for(i=0;i<this->numanalyses;i++)penta->hnodes[i].copy(&this->hnodes[i]);
    114         penta->hmatice.copy(&this->hmatice);
    115         penta->hmatpar.copy(&this->hmatpar);
    116         penta->hneighbors.copy(&this->hneighbors);
    117 
    118120        /*recover objects: */
    119121        penta->nodes=(Node**)xmalloc(6*sizeof(Node*)); //we cannot rely on an analysis_counter to tell us which analysis_type we are running, so we just copy the nodes.
    120122        for(i=0;i<6;i++)penta->nodes[i]=this->nodes[i];
    121         penta->matice=(Matice*)penta->hmatice.delivers();
    122         penta->matpar=(Matpar*)penta->hmatpar.delivers();
    123         penta->neighbors=(Penta**)penta->hneighbors.deliverp();
     123        penta->matice=(Matice*)penta->hmatice->delivers();
     124        penta->matpar=(Matpar*)penta->hmatpar->delivers();
     125        penta->neighbors=(Penta**)penta->hneighbors->deliverp();
    124126
    125127        return penta;
     
    167169
    168170        /*allocate dynamic memory: */
    169         InitHookNodes(numanalyses);
    170 
     171        this->hnodes=new Hook*[this->numanalyses];
    171172        /*demarshall hooks: */
    172         for(i=0;i<numanalyses;i++)hnodes[i].Demarshall(&marshalled_dataset);
    173         hmatice.Demarshall(&marshalled_dataset);
    174         hmatpar.Demarshall(&marshalled_dataset);
    175         hneighbors.Demarshall(&marshalled_dataset);
     173        for(i=0;i<numanalyses;i++){
     174                hnodes[i]=new Hook();
     175                hnodes[i]->Demarshall(&marshalled_dataset);
     176        }
     177        hmatice=new Hook(); hmatice->Demarshall(&marshalled_dataset);
     178        hmatpar=new Hook(); hmatpar->Demarshall(&marshalled_dataset);
     179        hneighbors=new Hook(); hneighbors->Demarshall(&marshalled_dataset);
    176180
    177181        /*pointers are garbage, until configuration is carried out: */
     
    236240
    237241        /*Marshall hooks: */
    238         for(i=0;i<numanalyses;i++)hnodes[i].Marshall(&marshalled_dataset);
    239         hmatice.Marshall(&marshalled_dataset);
    240         hmatpar.Marshall(&marshalled_dataset);
    241         hneighbors.Marshall(&marshalled_dataset);
     242        for(i=0;i<numanalyses;i++)hnodes[i]->Marshall(&marshalled_dataset);
     243        hmatice->Marshall(&marshalled_dataset);
     244        hmatpar->Marshall(&marshalled_dataset);
     245        hneighbors->Marshall(&marshalled_dataset);
    242246
    243247        /*Marshall inputs and results: */
     
    267271        int hnodes_size=0;;
    268272
    269         for(i=0;i<numanalyses;i++)hnodes_size+=hnodes[i].MarshallSize();
     273        for(i=0;i<numanalyses;i++)hnodes_size+=hnodes[i]->MarshallSize();
    270274
    271275        return sizeof(id)
    272276                +hnodes_size
    273277                +sizeof(numanalyses)
    274                 +hmatice.MarshallSize()
    275                 +hmatpar.MarshallSize()
    276                 +hneighbors.MarshallSize()
     278                +hmatice->MarshallSize()
     279                +hmatpar->MarshallSize()
     280                +hneighbors->MarshallSize()
    277281                +inputs->MarshallSize()
    278282                +results->MarshallSize()
     
    599603        /*Take care of hooking up all objects for this element, ie links the objects in the hooks to their respective
    600604         * datasets, using internal ids and offsets hidden in hooks: */
    601         this->hnodes[analysis_counter].configure(nodesin);
    602         this->hmatice.configure(materialsin);
    603         this->hmatpar.configure(materialsin);
    604         this->hneighbors.configure(elementsin);
     605        this->hnodes[analysis_counter]->configure(nodesin);
     606        this->hmatice->configure(materialsin);
     607        this->hmatpar->configure(materialsin);
     608        this->hneighbors->configure(elementsin);
    605609
    606610        /*Now, go pick up the objects inside the hooks: */
    607         this->nodes=(Node**)this->hnodes[analysis_counter].deliverp();
    608         this->matice=(Matice*)this->hmatice.delivers();
    609         this->matpar=(Matpar*)this->hmatpar.delivers();
    610         this->neighbors=(Penta**)this->hneighbors.deliverp();
     611        this->nodes=(Node**)this->hnodes[analysis_counter]->deliverp();
     612        this->matice=(Matice*)this->hmatice->delivers();
     613        this->matpar=(Matpar*)this->hmatpar->delivers();
     614        this->neighbors=(Penta**)this->hneighbors->deliverp();
    611615
    612616        /*point parameters to real dataset: */
     
    17791783/*Penta specific routines: */
    17801784/*FUNCTION Penta::SpawnTria {{{1*/
    1781 void*  Penta::SpawnTria(int g0, int g1, int g2){
     1785Tria*  Penta::SpawnTria(int g0, int g1, int g2){
    17821786
    17831787        int i;
     
    18111815
    18121816        /*recover nodes, matice and matpar: */
    1813         tria->nodes=(Node**)tria->hnodes[analysis_counter].deliverp();
    1814         tria->matice=(Matice*)tria->hmatice.delivers();
    1815         tria->matpar=(Matpar*)tria->hmatpar.delivers();
     1817        tria->nodes=(Node**)tria->hnodes[analysis_counter]->deliverp();
     1818        tria->matice=(Matice*)tria->hmatice->delivers();
     1819        tria->matpar=(Matpar*)tria->hmatpar->delivers();
    18161820       
    18171821        return tria;
  • issm/trunk/src/c/objects/Elements/Penta.h

    r4395 r4396  
    1717class Matice;
    1818class Matpar;
     19class Tria;
    1920
    2021#include "../../shared/Exceptions/exceptions.h"
     
    185186                void*     SpawnBeam(int g0, int g1);
    186187                void*     SpawnSing(int g0);
    187                 void*     SpawnTria(int g0, int g1, int g2);
     188                Tria*     SpawnTria(int g0, int g1, int g2);
    188189                void      SurfaceNormal(double* surface_normal, double xyz_list[3][3]);
    189190                void      UpdateFromDakota(void* inputs);
  • issm/trunk/src/c/objects/Elements/PentaHook.cpp

    r4378 r4396  
    2525        numanalyses=UNDEF;
    2626        this->hnodes=NULL;
     27        this->hmatice=NULL;
     28        this->hmatpar=NULL;
     29        this->hneighbors=NULL;
    2730}
    2831/*}}}*/
    2932/*FUNCTION PentaHook::~PentaHook(){{{1*/
    3033PentaHook::~PentaHook(){
     34
     35        int i;
     36
     37        for(i=0;i<this->numanalyses;i++){
     38                delete this->hnodes[i];
     39        }
    3140        delete [] this->hnodes;
     41        delete hmatice;
     42        delete hmatpar;
     43        delete hneighbors;
    3244}
    3345/*}}}*/
    34 /*FUNCTION PentaHook::InitHookNodes(int numanalyses){{{1*/
    35 void PentaHook::InitHookNodes(int in_numanalyses){
    36 
     46/*FUNCTION PentaHook::PentaHook(int in_numanalyses,int matice_id, int matpar_id){{{1*/
     47PentaHook::PentaHook(int in_numanalyses,int matice_id, int matpar_id){
     48       
    3749        this->numanalyses=in_numanalyses;
    38         this->hnodes=new Hook[in_numanalyses];
     50        this->hnodes=new Hook*[in_numanalyses];
     51        this->hmatice=new Hook(&matice_id,1);
     52        this->hmatpar=new Hook(&matpar_id,1);
     53        this->hneighbors=NULL;
    3954
    4055}
     
    4257/*FUNCTION PentaHook::SetHookNodes(int* node_ids,int analysis_counter){{{1*/
    4358void PentaHook::SetHookNodes(int* node_ids,int analysis_counter){
    44         this->hnodes[analysis_counter].Init(node_ids,6);
     59        this->hnodes[analysis_counter]= new Hook(node_ids,6);
    4560
    4661}
    4762/*}}}*/
    48 /*FUNCTION PentaHook::InitHookMatice(int matice_id){{{1*/
    49 void PentaHook::InitHookMatice(int matice_id){
    50         this->hmatice.Init(&matice_id,1);
    51 }
    52 
    53 /*FUNCTION PentaHook::InitHookMatpar(int matpar_id){{{1*/
    54 void PentaHook::InitHookMatpar(int matpar_id){
    55         this->hmatpar.Init(&matpar_id,1);
    56 }
    57 
    5863/*FUNCTION PentaHook::InitHookNeighbors(int* element_ids){{{1*/
    5964void PentaHook::InitHookNeighbors(int* element_ids){
    60         this->hneighbors.Init(element_ids,2);
     65        this->hneighbors=new Hook(element_ids,2);
    6166
    6267}
     
    6974
    7075        triahook->numanalyses=this->numanalyses;
    71         triahook->hnodes=new Hook[this->numanalyses];
     76        triahook->hnodes=new Hook*[this->numanalyses];
    7277
    7378        for(i=0;i<this->numanalyses;i++){
    7479                /*Do not do anything if Hook is empty*/
    75                 if (this->hnodes[i].GetNum()==0) continue;
     80                if (this->hnodes[i]->GetNum()==0) continue;
    7681                /*Else, spawn Hook*/
    77                 this->hnodes[i].Spawn(&triahook->hnodes[i],indices,3);
     82                triahook->hnodes[i]=this->hnodes[i]->Spawn(indices,3);
    7883        }
    79         triahook->hmatice.copy(&this->hmatice);
    80         triahook->hmatpar.copy(&this->hmatpar);
     84        triahook->hmatice=(Hook*)this->hmatice->copy();
     85        triahook->hmatpar=(Hook*)this->hmatpar->copy();
    8186}
    8287/*}}}*/
  • issm/trunk/src/c/objects/Elements/PentaHook.h

    r4369 r4396  
    1313        public:
    1414                int   numanalyses; //number of analysis types
    15                 Hook* hnodes; // 6 nodes for each analysis type
    16                 Hook hmatice; // 1 ice material
    17                 Hook hmatpar; // 1 material parameter
    18                 Hook hneighbors; // 2 elements, first down, second up
     15                Hook** hnodes; // 6 nodes for each analysis type
     16                Hook* hmatice; // 1 ice material
     17                Hook* hmatpar; // 1 material parameter
     18                Hook* hneighbors; // 2 elements, first down, second up
    1919
    2020                /*FUNCTION constructors, destructors {{{1*/
    2121                PentaHook();
     22                PentaHook(int in_numanalyses,int matice_id, int matpar_id);
    2223                ~PentaHook();
    23                 void InitHookNodes(int numanalyses);
    2424                void SetHookNodes(int* node_ids,int analysis_counter);
    25                 void InitHookMatice(int matice_id);
    26                 void InitHookMatpar(int matpar_id);
     25                void SpawnTriaHook(TriaHook* triahook,int* indices);
    2726                void InitHookNeighbors(int* element_ids);
    28                 void SpawnTriaHook(TriaHook* triahook,int* indices);
    2927                /*}}}*/
    3028};
  • issm/trunk/src/c/objects/Elements/Tria.cpp

    r4394 r4396  
    2323/*FUNCTION Tria::Tria(){{{1*/
    2424Tria::Tria(){
     25
    2526        this->nodes=NULL;
    2627        this->matice=NULL;
     
    3940/*}}}*/
    4041/*FUNCTION Tria::Tria(int id, int index, IoModel* iomodel,int nummodels){{{1*/
    41 Tria::Tria(int tria_id, int index, IoModel* iomodel,int nummodels){ //i is the element index
    42 
    43         int    i;
    44         int    tria_matice_id;
    45         int    tria_matpar_id;
    46 
     42Tria::Tria(int tria_id, int index, IoModel* iomodel,int nummodels)
     43
     44        :TriaRef(P1Enum) //P1Enum: interpolation type
     45        ,TriaHook(nummodels,index+1,iomodel->numberofelements+1) //index+1: matice id, iomodel->numberofelements+1: matpar id
     46                                                                  { //i is the element index
    4747        /*id: */
    4848        this->id=tria_id;
    49 
    50         /*interpolation type: */
    51         this->InitInterpolationType(P1Enum);
    52        
    53         /*hooks: */
    54         tria_matice_id=index+1; //refers to the corresponding ice material object
    55         tria_matpar_id=iomodel->numberofelements+1; //refers to the constant material parameters object
    56 
    57         this->InitHookNodes(nummodels);      this->nodes=NULL;
    58         this->InitHookMatice(tria_matice_id);this->matice=NULL;
    59         this->InitHookMatpar(tria_matpar_id);this->matpar=NULL;
    6049
    6150        //this->parameters: we still can't point to it, it may not even exist. Configure will handle this.
     
    6655        this->results=new Results();
    6756
     57        /*initialize pointers:*/
     58        this->nodes=NULL;
     59        this->matice=NULL;
     60        this->matpar=NULL;
     61
    6862}
    6963/*}}}*/
     
    7872        tria=new Tria();
    7973
    80         /*copy fields: */
     74        //deal with TriaRef mother class
     75        tria->interpolation_type=this->interpolation_type;
     76
     77        //deal with TriaHook mother class
     78        tria->numanalyses=this->numanalyses;
     79        tria->hnodes=new Hook*[tria->numanalyses];
     80        for(i=0;i<tria->numanalyses;i++)tria->hnodes[i]=(Hook*)this->hnodes[i]->copy();
     81        tria->hmatice=(Hook*)this->hmatice->copy();
     82        tria->hmatpar=(Hook*)this->hmatpar->copy();
     83
     84        /*deal with Tria fields: */
    8185        tria->id=this->id;
    82         tria->interpolation_type=this->interpolation_type;
    8386        if(this->inputs){
    8487                tria->inputs=(Inputs*)this->inputs->Copy();
     
    9598        /*point parameters: */
    9699        tria->parameters=this->parameters;
    97 
    98         /*now deal with hooks and objects: */
    99         tria->InitHookNodes(this->numanalyses);
    100         for(i=0;i<this->numanalyses;i++)tria->hnodes[i].copy(&this->hnodes[i]);
    101         tria->hmatice.copy(&this->hmatice);
    102         tria->hmatpar.copy(&this->hmatpar);
    103 
     100       
    104101        /*recover objects: */
    105102        tria->nodes=(Node**)xmalloc(3*sizeof(Node*)); //we cannot rely on an analysis_counter to tell us which analysis_type we are running, so we just copy the nodes.
    106103        for(i=0;i<3;i++)tria->nodes[i]=this->nodes[i];
    107         tria->matice=(Matice*)tria->hmatice.delivers();
    108         tria->matpar=(Matpar*)tria->hmatpar.delivers();
     104        tria->matice=(Matice*)tria->hmatice->delivers();
     105        tria->matpar=(Matpar*)tria->hmatpar->delivers();
    109106
    110107        return tria;
     
    159156
    160157        /*allocate dynamic memory: */
    161         InitHookNodes(numanalyses);
    162 
     158        this->hnodes=new Hook*[this->numanalyses];
    163159        /*demarshall hooks: */
    164         for(i=0;i<numanalyses;i++)hnodes[i].Demarshall(&marshalled_dataset);
    165         hmatice.Demarshall(&marshalled_dataset);
    166         hmatpar.Demarshall(&marshalled_dataset);
     160        for(i=0;i<numanalyses;i++){
     161                hnodes[i]=new Hook();
     162                hnodes[i]->Demarshall(&marshalled_dataset);
     163        }
     164        hmatice=new Hook(); hmatice->Demarshall(&marshalled_dataset);
     165        hmatpar=new Hook(); hmatpar->Demarshall(&marshalled_dataset);
    167166
    168167        /*pointers are garbabe, until configuration is carried out: */
     
    248247
    249248        /*Marshall hooks: */
    250         for(i=0;i<numanalyses;i++)hnodes[i].Marshall(&marshalled_dataset);
    251         hmatice.Marshall(&marshalled_dataset);
    252         hmatpar.Marshall(&marshalled_dataset);
     249        for(i=0;i<numanalyses;i++)hnodes[i]->Marshall(&marshalled_dataset);
     250        hmatice->Marshall(&marshalled_dataset);
     251        hmatpar->Marshall(&marshalled_dataset);
    253252
    254253        /*Marshall inputs: */
     
    279278        int hnodes_size=0;;
    280279
    281         for(i=0;i<numanalyses;i++)hnodes_size+=hnodes[i].MarshallSize();
     280        for(i=0;i<numanalyses;i++)hnodes_size+=hnodes[i]->MarshallSize();
    282281
    283282        return sizeof(id)
     
    285284                +sizeof(interpolation_type)
    286285                +sizeof(numanalyses)
    287                 +hmatice.MarshallSize()
    288                 +hmatpar.MarshallSize()
     286                +hmatice->MarshallSize()
     287                +hmatpar->MarshallSize()
    289288                +inputs->MarshallSize()
    290289                +results->MarshallSize()
     
    488487        /*Take care of hooking up all objects for this element, ie links the objects in the hooks to their respective
    489488         * datasets, using internal ids and offsets hidden in hooks: */
    490         this->hnodes[analysis_counter].configure(nodesin);
    491         this->hmatice.configure(materialsin);
    492         this->hmatpar.configure(materialsin);
     489        this->hnodes[analysis_counter]->configure(nodesin);
     490        this->hmatice->configure(materialsin);
     491        this->hmatpar->configure(materialsin);
    493492
    494493        /*Now, go pick up the objects inside the hooks: */
    495         this->nodes=(Node**)this->hnodes[analysis_counter].deliverp();
    496         this->matice=(Matice*)this->hmatice.delivers();
    497         this->matpar=(Matpar*)this->hmatpar.delivers();
     494        this->nodes=(Node**)this->hnodes[analysis_counter]->deliverp();
     495        this->matice=(Matice*)this->hmatice->delivers();
     496        this->matpar=(Matpar*)this->hmatpar->delivers();
    498497
    499498        /*point parameters to real dataset: */
  • issm/trunk/src/c/objects/Elements/TriaHook.cpp

    r4236 r4396  
    2525        numanalyses=UNDEF;
    2626        this->hnodes=NULL;
     27        this->hmatice=NULL;
     28        this->hmatpar=NULL;
    2729}
    2830/*}}}*/
    2931/*FUNCTION TriaHook::~TriaHook(){{{1*/
    3032TriaHook::~TriaHook(){
     33        int i;
     34
     35        for(i=0;i<this->numanalyses;i++){
     36                delete this->hnodes[i];
     37        }
    3138        delete [] this->hnodes;
     39        delete hmatice;
     40        delete hmatpar;
     41
    3242}
    3343/*}}}*/
    34 /*FUNCTION TriaHook::InitHookNodes(int numanalyses){{{1*/
    35 void TriaHook::InitHookNodes(int in_numanalyses){
    36 
     44/*FUNCTION TriaHook::TriaHook(int in_numanalyses,int matice_id, int matpar_id){{{1*/
     45TriaHook::TriaHook(int in_numanalyses,int matice_id, int matpar_id){
     46       
    3747        this->numanalyses=in_numanalyses;
    38         this->hnodes=new Hook[in_numanalyses];
     48        this->hnodes=new Hook*[in_numanalyses];
     49        this->hmatice=new Hook(&matice_id,1);
     50        this->hmatpar=new Hook(&matpar_id,1);
    3951
    4052}
     
    4254/*FUNCTION TriaHook::SetHookNodes(int* node_ids,int analysis_counter){{{1*/
    4355void TriaHook::SetHookNodes(int* node_ids,int analysis_counter){
    44         this->hnodes[analysis_counter].Init(node_ids,3);
    45 
     56        this->hnodes[analysis_counter]=new Hook(node_ids,3);
    4657}
    4758/*}}}*/
    48 /*FUNCTION TriaHook::InitHookMatice(int matice_id){{{1*/
    49 void TriaHook::InitHookMatice(int matice_id){
    50         this->hmatice.Init(&matice_id,1);
    51 }
    52 
    53 /*FUNCTION TriaHook::InitHookMatpar(int matpar_id){{{1*/
    54 void TriaHook::InitHookMatpar(int matpar_id){
    55         this->hmatpar.Init(&matpar_id,1);
    56 }
    57 
  • issm/trunk/src/c/objects/Elements/TriaHook.h

    r3984 r4396  
    1111
    1212        public:
    13                 int   numanalyses; //number of analysis types
    14                 Hook* hnodes; // 3 nodes for each analysis type
    15                 Hook hmatice; // 1 ice material
    16                 Hook hmatpar; // 1 material parameter
     13                int    numanalyses; //number of analysis types
     14                Hook** hnodes; // 3 nodes for each analysis type
     15                Hook* hmatice; // 1 ice material
     16                Hook* hmatpar; // 1 material parameter
    1717
    1818
    1919                /*FUNCTION constructors, destructors {{{1*/
    2020                TriaHook();
     21                TriaHook(int in_numanalyses,int matice_id, int matpar_id);
    2122                ~TriaHook();
    22                 void InitHookNodes(int numanalyses);
    2323                void SetHookNodes(int* node_ids,int analysis_counter);
    24                 void InitHookMatice(int matice_id);
    25                 void InitHookMatpar(int matpar_id);
    26                 void InitHookNeighbors(int* element_ids);
    27 
    2824                /*}}}*/
    2925
  • issm/trunk/src/c/objects/Elements/TriaRef.cpp

    r4236 r4396  
    2525}
    2626/*}}}*/
     27/*FUNCTION TriaRef::TriaRef(int type){{{1*/
     28TriaRef::TriaRef(int type){
     29        this->interpolation_type=type;
     30}
     31/*}}}*/
    2732/*FUNCTION TriaRef::~TriaRef(){{{1*/
    2833TriaRef::~TriaRef(){
    2934}
    3035/*}}}*/
    31 /*FUNCTION TriaRef::InitInterpolationType(int type){{{1*/
    32 void TriaRef::InitInterpolationType(int type){
    33         this->interpolation_type=type;
    34 }
    35 /*}}}*/
  • issm/trunk/src/c/objects/Elements/TriaRef.h

    r3828 r4396  
    1616                /*FUNCTION constructors, destructors {{{1*/
    1717                TriaRef();
     18                TriaRef(int type);
    1819                ~TriaRef();
    19                 void InitInterpolationType(int type);
    2020                /*}}}*/
    2121                /*FUNCTION numerics {{{1*/
  • issm/trunk/src/c/objects/Hook.cpp

    r4378 r4396  
    3131/*FUNCTION Hook::Hook(int* ids, int num){{{1*/
    3232Hook::Hook(int* in_ids, int in_num){
    33         this->Init(in_ids,in_num);
    34 }
    35 /*}}}*/
    36 /*FUNCTION Hook::Init(int* ids, int num){{{1*/
    37 void Hook::Init(int* in_ids, int in_num){
    3833
    3934        /*Intermediaries*/
     
    6257                        this->offsets[i]=0;
    6358                }
    64         }
    65 }
    66 /*}}}*/
    67 /*FUNCTION Hook::Hook(Object** hook_objects, int* hook_ids, int* hook_offsets,int hook_num){{{1*/
    68 Hook::Hook(Object** hook_objects, int* hook_ids, int* hook_offsets,int hook_num){
    69 
    70         /*just plug in: */
    71         this->num=hook_num;
    72         this->objects=hook_objects;
    73         this->offsets=hook_offsets;
    74         this->ids=hook_ids;
    75 
    76 }
    77 /*}}}*/
    78 /*FUNCTION Hook::Hook(Hook* input) {{{1*/
    79 Hook::Hook(Hook* input){
    80 
    81         int i;
    82         Object** input_objects=NULL;
    83         int*     input_ids=NULL;
    84         int*     input_offsets=NULL;
    85 
    86         /*get internals of input: */
    87         this->num=input->GetNum();
    88         input_objects=input->GetObjects();
    89         input_ids=input->Ids();
    90         input_offsets=input->GetOffsets();
    91 
    92         if(this->num){
    93                 this->objects=(Object**)xmalloc(this->num*sizeof(Object*));
    94                 this->ids=(int*)xmalloc(this->num*sizeof(int));
    95                 this->offsets=(int*)xmalloc(this->num*sizeof(int));
    96         }
    97        
    98 
    99         for(i=0;i<this->num;i++){
    100                 this->objects[i]=input_objects[i];
    101                 this->offsets[i]=input_offsets[i];
    102                 this->ids[i]=input_ids[i];
    10359        }
    10460}
     
    252208}
    253209/*}}}*/
    254 /*FUNCTION Hook::copy(Hook* input) {{{1*/
    255 void Hook::copy(Hook* input){
    256 
    257         int i;
    258         Object** input_objects=NULL;
    259         int*     input_ids=NULL;
    260         int*     input_offsets=NULL;
    261 
    262         /*get internals of input: */
    263         this->num=input->GetNum();
    264         input_objects=input->GetObjects();
    265         input_ids=input->Ids();
    266         input_offsets=input->GetOffsets();
    267 
    268         if(this->num){
    269                 this->objects=(Object**)xmalloc(this->num*sizeof(Object*));
    270                 this->ids=(int*)xmalloc(this->num*sizeof(int));
    271                 this->offsets=(int*)xmalloc(this->num*sizeof(int));
    272         }
    273        
    274 
    275         for(i=0;i<this->num;i++){
    276                 this->objects[i]=input_objects[i];
    277                 this->offsets[i]=input_offsets[i];
    278                 this->ids[i]=input_ids[i];
     210/*FUNCTION Hook::copy(void) {{{1*/
     211Object* Hook::copy(void){
     212
     213        int i;
     214
     215        /*output: */
     216        Hook* output=NULL;
     217
     218        /*initalize output: */
     219        output=new Hook();
     220
     221        /*copy in the fields: */
     222        output->num=this->num;
     223        if(output->num){
     224                output->objects=(Object**)xmalloc(output->num*sizeof(Object*));
     225                output->ids=(int*)xmalloc(output->num*sizeof(int));
     226                output->offsets=(int*)xmalloc(output->num*sizeof(int));
     227        }
     228       
     229        for(i=0;i<output->num;i++){
     230                output->objects[i]=this->objects[i];
     231                output->offsets[i]=this->offsets[i];
     232                output->ids[i]=this->ids[i];
    279233        }
    280234}
     
    363317/*}}}*/
    364318/*FUNCTION Hook::Spawn{{{1*/
    365 void Hook::Spawn(Hook* spawnedhook, int* indices, int numindices){
    366 
    367         int i;
     319Hook* Hook::Spawn(int* indices, int numindices){
     320
     321        int i;
     322
     323        /*output: */
     324        Hook* output=NULL;
     325
     326        /*allocate: */
     327        output=new Hook();
    368328
    369329        /*If this Hook is empty, simply return*/
    370330        if(this->num==0){
    371                 spawnedhook->num=0;
    372                 return;
     331                output->num=0;
     332                return output;
    373333        }
    374334
     
    377337
    378338        /*go pickup the correct objects, ids and offsets :*/
    379         spawnedhook->num=numindices;
    380         if(spawnedhook->num<1) ISSMERROR("Trying to spawn an empty ElementProperties!");
    381 
    382         spawnedhook->objects=(Object**)xmalloc(spawnedhook->num*sizeof(Object*));
    383         spawnedhook->ids=(int*)xmalloc(spawnedhook->num*sizeof(int));
    384         spawnedhook->offsets=(int*)xmalloc(spawnedhook->num*sizeof(int));
    385 
    386         for(i=0;i<spawnedhook->num;i++){
    387                 spawnedhook->objects[i]=this->objects[indices[i]];
    388                 spawnedhook->ids[i]=this->ids[indices[i]];
    389                 spawnedhook->offsets[i]=this->offsets[indices[i]];
    390         }
    391 }
    392 /*}}}*/
     339        output->num=numindices;
     340        if(output->num<1) ISSMERROR("Trying to spawn an empty ElementProperties!");
     341
     342        output->objects=(Object**)xmalloc(output->num*sizeof(Object*));
     343        output->ids=(int*)xmalloc(output->num*sizeof(int));
     344        output->offsets=(int*)xmalloc(output->num*sizeof(int));
     345
     346        for(i=0;i<output->num;i++){
     347                output->objects[i]=this->objects[indices[i]];
     348                output->ids[i]=this->ids[indices[i]];
     349                output->offsets[i]=this->offsets[indices[i]];
     350        }
     351
     352        return output;
     353}
     354/*}}}*/
  • issm/trunk/src/c/objects/Hook.h

    r4369 r4396  
    2929                Hook();
    3030                Hook(int* ids, int num);
    31                 void Init(int* ids, int num);
    32                 Hook(Object** objects, int* ids, int* offsets,int num);
    33                 Hook(Hook* hook);
    3431                ~Hook();
    3532                /*}}}*/
     
    4037                int        MarshallSize();
    4138                void       Demarshall(char** pmarshalled_dataset);
    42                 void       copy(Hook* hook);
     39                Object*    copy(void);
    4340                /*}}}*/
    4441                /*Hook management: {{{1*/
     
    4643                Object**   deliverp(void); //deliver all objects
    4744                void       configure(DataSet* dataset);
    48                 void       Spawn(Hook* spawnedhook, int* indices, int numindices);
     45                Hook*      Spawn(int* indices, int numindices);
    4946                Object**   GetObjects(void);
    5047                int*       Ids(void);
  • issm/trunk/src/c/objects/Loads/Icefront.cpp

    r4248 r4396  
    2424        this->inputs=NULL;
    2525        this->parameters=NULL;
     26        this->hnodes=NULL;
     27        this->helement=NULL;
     28        this->hmatpar=NULL;
    2629}
    2730/*}}}*/
     
    8487
    8588        /*Hooks: */
    86         this->hnodes.Init(icefront_node_ids,num_nodes);
    87         this->helement.Init(&icefront_eid,1);
    88         this->hmatpar.Init(&icefront_mparid,1);
     89        this->hnodes=new Hook(icefront_node_ids,num_nodes);
     90        this->helement=new Hook(&icefront_eid,1);
     91        this->hmatpar=new Hook(&icefront_mparid,1);
    8992
    9093        //intialize  and add as many inputs per element as requested:
     
    103106        delete inputs;
    104107        this->parameters=NULL;
     108        delete hnodes;
     109        delete helement;
     110        delete hmatpar;
    105111}
    106112/*}}}*/
     
    112118        printf("   id: %i\n",id);
    113119        printf("   analysis_type: %s\n",EnumAsString(analysis_type));
    114         hnodes.Echo();
    115         helement.Echo();
    116         hmatpar.Echo();
     120        hnodes->Echo();
     121        helement->Echo();
     122        hmatpar->Echo();
    117123        printf("   parameters\n");
    118124        parameters->Echo();
     
    127133        printf("   id: %i\n",id);
    128134        printf("   analysis_type: %s\n",EnumAsString(analysis_type));
    129         hnodes.DeepEcho();
    130         helement.DeepEcho();
    131         hmatpar.DeepEcho();
     135        hnodes->DeepEcho();
     136        helement->DeepEcho();
     137        hmatpar->DeepEcho();
    132138        printf("   parameters\n");
    133139        parameters->DeepEcho();
     
    167173
    168174        /*Marshall hooks: */
    169         hnodes.Marshall(&marshalled_dataset);
    170         helement.Marshall(&marshalled_dataset);
    171         hmatpar.Marshall(&marshalled_dataset);
     175        hnodes->Marshall(&marshalled_dataset);
     176        helement->Marshall(&marshalled_dataset);
     177        hmatpar->Marshall(&marshalled_dataset);
    172178
    173179        /*Marshall inputs: */
     
    189195        return sizeof(id)
    190196                +sizeof(analysis_type)
    191                 +hnodes.MarshallSize()
    192                 +helement.MarshallSize()
    193                 +hmatpar.MarshallSize()
     197                +hnodes->MarshallSize()
     198                +helement->MarshallSize()
     199                +hmatpar->MarshallSize()
    194200                +inputs->MarshallSize()
    195201                +sizeof(int); //sizeof(int) for enum type
     
    211217
    212218        /*demarshall hooks: */
    213         hnodes.Demarshall(&marshalled_dataset);
    214         helement.Demarshall(&marshalled_dataset);
    215         hmatpar.Demarshall(&marshalled_dataset);
     219        hnodes=new Hook(); hnodes->Demarshall(&marshalled_dataset);
     220        helement=new Hook(); helement->Demarshall(&marshalled_dataset);
     221        hmatpar=new Hook(); hmatpar->Demarshall(&marshalled_dataset);
    216222       
    217223        /*demarshall inputs: */
     
    253259
    254260        /*now deal with hooks and objects: */
    255         icefront->hnodes.copy(&this->hnodes);
    256         icefront->helement.copy(&this->helement);
    257         icefront->hmatpar.copy(&this->hmatpar);
     261        icefront->hnodes=(Hook*)this->hnodes->copy();
     262        icefront->helement=(Hook*)this->helement->copy();
     263        icefront->hmatpar=(Hook*)this->hmatpar->copy();
    258264
    259265        return icefront;
     
    268274        /*Take care of hooking up all objects for this element, ie links the objects in the hooks to their respective
    269275         * datasets, using internal ids and offsets hidden in hooks: */
    270         hnodes.configure(nodesin);
    271         helement.configure(elementsin);
    272         hmatpar.configure(materialsin);
     276        hnodes->configure(nodesin);
     277        helement->configure(elementsin);
     278        hmatpar->configure(materialsin);
    273279
    274280        /*point parameters to real dataset: */
     
    411417
    412418        /*Recover hook objects: */
    413         matpar=(Matpar*)hmatpar.delivers();
    414         element=(Element*)helement.delivers();
    415         nodes=(Node**)hnodes.deliverp();
     419        matpar=(Matpar*)hmatpar->delivers();
     420        element=(Element*)helement->delivers();
     421        nodes=(Node**)hnodes->deliverp();
    416422
    417423        element_type=element->Enum();
     
    514520
    515521        /*Recover hook objects: */
    516         matpar=(Matpar*)hmatpar.delivers();
    517         element=(Element*)helement.delivers();
    518         nodes=(Node**)hnodes.deliverp();
     522        matpar=(Matpar*)hmatpar->delivers();
     523        element=(Element*)helement->delivers();
     524        nodes=(Node**)hnodes->deliverp();
    519525
    520526        element_type=element->Enum();
     
    653659
    654660        /*Recover hook objects: */
    655         matpar=(Matpar*)hmatpar.delivers();
    656         element=(Element*)helement.delivers();
    657         nodes=(Node**)hnodes.deliverp();
     661        matpar=(Matpar*)hmatpar->delivers();
     662        element=(Element*)helement->delivers();
     663        nodes=(Node**)hnodes->deliverp();
    658664       
    659665        /*check icefront is associated to a pentaelem: */
     
    756762
    757763        Node**   nodes=NULL;
    758         nodes=(Node**)hnodes.deliverp();
     764        nodes=(Node**)hnodes->deliverp();
    759765        inputs->GetParameterValue(&type,TypeEnum);
    760766       
  • issm/trunk/src/c/objects/Loads/Icefront.h

    r4248 r4396  
    2525
    2626                /*hooks: */
    27                 Hook hnodes;
    28                 Hook helement;
    29                 Hook hmatpar;
     27                Hook* hnodes;
     28                Hook* helement;
     29                Hook* hmatpar;
    3030
    3131                /*inputs and parameters: */
  • issm/trunk/src/c/objects/Loads/Numericalflux.cpp

    r4248 r4396  
    2323        this->inputs=NULL;
    2424        this->parameters=NULL;
     25        this->helements=NULL;
     26        this->hnodes=NULL;
    2527}
    2628/*}}}*/
     
    109111
    110112        /*Hooks: */
    111         this->hnodes.Init(numericalflux_node_ids,num_nodes);
    112         this->helements.Init(numericalflux_elem_ids,num_elems);
     113        this->hnodes=new Hook(numericalflux_node_ids,num_nodes);
     114        this->helements=new Hook(numericalflux_elem_ids,num_elems);
    113115
    114116        //intialize  and add as many inputs per element as requested:
     
    124126        delete inputs;
    125127        this->parameters=NULL;
     128        delete helements;
     129        delete hnodes;
    126130}
    127131/*}}}*/
     
    139143        printf("   id: %i\n",id);
    140144        printf("   analysis_type: %s\n",EnumAsString(analysis_type));
    141         hnodes.DeepEcho();
    142         helements.DeepEcho();
     145        hnodes->DeepEcho();
     146        helements->DeepEcho();
    143147        printf("   parameters\n");
    144148        parameters->DeepEcho();
     
    181185
    182186        /*Marshall hooks: */
    183         hnodes.Marshall(&marshalled_dataset);
    184         helements.Marshall(&marshalled_dataset);
     187        hnodes->Marshall(&marshalled_dataset);
     188        helements->Marshall(&marshalled_dataset);
    185189
    186190        /*Marshall inputs: */
     
    203207        return sizeof(id)
    204208                +sizeof(analysis_type)
    205                 +hnodes.MarshallSize()
    206                 +helements.MarshallSize()
     209                +hnodes->MarshallSize()
     210                +helements->MarshallSize()
    207211                +inputs->MarshallSize()
    208212                +sizeof(int); //sizeof(int) for enum type
     
    224228
    225229        /*demarshall hooks: */
    226         hnodes.Demarshall(&marshalled_dataset);
    227         helements.Demarshall(&marshalled_dataset);
     230        hnodes=new Hook(); hnodes->Demarshall(&marshalled_dataset);
     231        helements=new Hook(); helements->Demarshall(&marshalled_dataset);
    228232       
    229233        /*demarshall inputs: */
     
    265269
    266270        /*now deal with hooks and objects: */
    267         numericalflux->hnodes.copy(&this->hnodes);
    268         numericalflux->helements.copy(&this->helements);
     271        numericalflux->hnodes=(Hook*)this->hnodes->copy();
     272        numericalflux->helements=(Hook*)this->helements->copy();
    269273
    270274        return numericalflux;
     
    279283        /*Take care of hooking up all objects for this element, ie links the objects in the hooks to their respective
    280284         * datasets, using internal ids and offsets hidden in hooks: */
    281         hnodes.configure(nodesin);
    282         helements.configure(elementsin);
     285        hnodes->configure(nodesin);
     286        helements->configure(elementsin);
    283287
    284288        /*point parameters to real dataset: */
     
    394398
    395399        /*recover objects from hooks: */
    396         nodes=(Node**)hnodes.deliverp();
    397         trias=(Tria**)helements.deliverp();
     400        nodes=(Node**)hnodes->deliverp();
     401        trias=(Tria**)helements->deliverp();
    398402
    399403        /*recover parameters: */
     
    514518
    515519        /*recover objects from hooks: */
    516         nodes=(Node**)hnodes.deliverp();
    517         trias=(Tria**)helements.deliverp();
     520        nodes=(Node**)hnodes->deliverp();
     521        trias=(Tria**)helements->deliverp();
    518522
    519523        /*recover parameters: */
     
    640644
    641645        /*recover objects from hooks: */
    642         nodes=(Node**)hnodes.deliverp();
    643         trias=(Tria**)helements.deliverp();
     646        nodes=(Node**)hnodes->deliverp();
     647        trias=(Tria**)helements->deliverp();
    644648
    645649        /*Retrieve parameters: */
     
    742746
    743747        /*recover objects from hooks: */
    744         nodes=(Node**)hnodes.deliverp();
     748        nodes=(Node**)hnodes->deliverp();
    745749       
    746750        /*recover type: */
  • issm/trunk/src/c/objects/Loads/Numericalflux.h

    r4248 r4396  
    2222                int analysis_type;
    2323
    24                 Hook        helements;
    25                 Hook        hnodes;
     24                Hook*       helements;
     25                Hook*       hnodes;
    2626                Parameters *parameters;
    2727                Inputs     *inputs;
  • issm/trunk/src/c/objects/Loads/Pengrid.cpp

    r4248 r4396  
    2323        this->inputs=NULL;
    2424        this->parameters=NULL;
     25        this->hnode=NULL;
     26        this->helement=NULL;
     27        this->hmatpar=NULL;
    2528       
    2629        /*not active, not zigzagging: */
     
    5154        pengrid_matpar_id=iomodel->numberofelements+1; //refers to the constant material parameters object
    5255
    53         this->hnode.Init(&pengrid_node_id,1);
    54         this->helement.Init(&pengrid_element_id,1);
    55         this->hmatpar.Init(&pengrid_matpar_id,1);
     56        this->hnode=new Hook(&pengrid_node_id,1);
     57        this->helement=new Hook(&pengrid_element_id,1);
     58        this->hmatpar=new Hook(&pengrid_matpar_id,1);
    5659
    5760        //initialize inputs: none needed
     
    6972/*FUNCTION Pengrid::destructor {{{1*/
    7073Pengrid::~Pengrid(){
     74        delete hnode;
     75        delete helement;
     76        delete hmatpar;
    7177        return;
    7278}
     
    8591        printf("   id: %i\n",id);
    8692        printf("   analysis_type: %s\n",EnumAsString(analysis_type));
    87         hnode.DeepEcho();
    88         helement.DeepEcho();
    89         hmatpar.DeepEcho();
     93        hnode->DeepEcho();
     94        helement->DeepEcho();
     95        hmatpar->DeepEcho();
    9096        printf("   active %i\n",this->active);
    9197        printf("   zigzag_counter %i\n",this->zigzag_counter);
     
    129135
    130136        /*Marshall hooks: */
    131         hnode.Marshall(&marshalled_dataset);
    132         helement.Marshall(&marshalled_dataset);
    133         hmatpar.Marshall(&marshalled_dataset);
     137        hnode->Marshall(&marshalled_dataset);
     138        helement->Marshall(&marshalled_dataset);
     139        hmatpar->Marshall(&marshalled_dataset);
    134140
    135141        /*Marshall inputs: */
     
    154160                +sizeof(active)
    155161                +sizeof(zigzag_counter)
    156                 +hnode.MarshallSize()
    157                 +helement.MarshallSize()
    158                 +hmatpar.MarshallSize()
     162                +hnode->MarshallSize()
     163                +helement->MarshallSize()
     164                +hmatpar->MarshallSize()
    159165                +inputs->MarshallSize()
    160166                +sizeof(int); //sizeof(int) for enum type
     
    179185
    180186        /*demarshall hooks: */
    181         hnode.Demarshall(&marshalled_dataset);
    182         helement.Demarshall(&marshalled_dataset);
    183         hmatpar.Demarshall(&marshalled_dataset);
     187        hnode=new Hook(); hnode->Demarshall(&marshalled_dataset);
     188        helement=new Hook(); helement->Demarshall(&marshalled_dataset);
     189        hmatpar=new Hook(); hmatpar->Demarshall(&marshalled_dataset);
    184190       
    185191        /*demarshall inputs: */
     
    220226
    221227        /*now deal with hooks and objects: */
    222         pengrid->hnode.copy(&this->hnode);
    223         pengrid->helement.copy(&this->helement);
    224         pengrid->hmatpar.copy(&this->hmatpar);
     228        pengrid->hnode=(Hook*)this->hnode->copy();
     229        pengrid->hmatpar=(Hook*)this->hmatpar->copy();
     230        pengrid->helement=(Hook*)this->helement->copy();
    225231
    226232        //let's not forget internals
     
    239245        /*Take care of hooking up all objects for this load, ie links the objects in the hooks to their respective
    240246         * datasets, using internal ids and offsets hidden in hooks: */
    241         hnode.configure(nodesin);
    242         helement.configure(elementsin);
    243         hmatpar.configure(materialsin);
     247        hnode->configure(nodesin);
     248        helement->configure(elementsin);
     249        hmatpar->configure(materialsin);
    244250
    245251        /*point parameters to real dataset: */
     
    381387
    382388        /*recover objects from hooks: */
    383         node=(Node*)hnode.delivers();
     389        node=(Node*)hnode->delivers();
    384390       
    385391        node->GetDofList(&doflist_per_node[0],&numberofdofspernode);
     
    448454
    449455        /*recover pointers: */
    450         node=(Node*)hnode.delivers();
    451         penta=(Penta*)helement.delivers();
    452         matpar=(Matpar*)hmatpar.delivers();
     456        node=(Node*)hnode->delivers();
     457        penta=(Penta*)helement->delivers();
     458        matpar=(Matpar*)hmatpar->delivers();
    453459       
    454460        /*check that pengrid is not a clone (penalty to be added only once)*/
     
    533539
    534540        /*recover pointers: */
    535         node=(Node*)hnode.delivers();
    536         penta=(Penta*)helement.delivers();
     541        node=(Node*)hnode->delivers();
     542        penta=(Penta*)helement->delivers();
    537543
    538544        //recover slope: */
     
    577583
    578584        /*recover pointers: */
    579         node=(Node*)hnode.delivers();
    580         penta=(Penta*)helement.delivers();
    581         matpar=(Matpar*)hmatpar.delivers();
     585        node=(Node*)hnode->delivers();
     586        penta=(Penta*)helement->delivers();
     587        matpar=(Matpar*)hmatpar->delivers();
    582588
    583589        /*check that pengrid is not a clone (penalty to be added only once)*/
     
    665671
    666672        /*recover pointers: */
    667         node=(Node*)hnode.delivers();
    668         penta=(Penta*)helement.delivers();
    669         matpar=(Matpar*)hmatpar.delivers();
     673        node=(Node*)hnode->delivers();
     674        penta=(Penta*)helement->delivers();
     675        matpar=(Matpar*)hmatpar->delivers();
    670676
    671677        /*check that pengrid is not a clone (penalty to be added only once)*/
     
    738744
    739745        /*recover pointers: */
    740         node=(Node*)hnode.delivers();
    741         penta=(Penta*)helement.delivers();
    742         matpar=(Matpar*)hmatpar.delivers();
     746        node=(Node*)hnode->delivers();
     747        penta=(Penta*)helement->delivers();
     748        matpar=(Matpar*)hmatpar->delivers();
    743749
    744750        if(!this->active)return;
  • issm/trunk/src/c/objects/Loads/Pengrid.h

    r4248 r4396  
    2121                int analysis_type;
    2222               
    23                 Hook hnode;  //hook to 1 node
    24                 Hook helement;  //hook to 1 element
    25                 Hook hmatpar; //hook to 1 matpar
     23                Hook* hnode;  //hook to 1 node
     24                Hook* helement;  //hook to 1 element
     25                Hook* hmatpar; //hook to 1 matpar
    2626
    2727                Parameters* parameters; //pointer to solution parameters
  • issm/trunk/src/c/objects/Loads/Penpair.cpp

    r4248 r4396  
    2020/*FUNCTION Penpair::constructor {{{1*/
    2121Penpair::Penpair(){
     22
     23        this->hnodes=NULL;
    2224        return;
    2325}
    2426/*}}}1*/
    2527/*FUNCTION Penpair::creation {{{1*/
    26 Penpair::Penpair(int penpair_id, int* penpair_node_ids,int in_analysis_type):
    27         hnodes(penpair_node_ids,2)
    28 {
     28Penpair::Penpair(int penpair_id, int* penpair_node_ids,int in_analysis_type){
     29
     30       
     31        this->id=penpair_id;
     32        this->analysis_type=in_analysis_type;
     33        this->hnodes=new Hook(penpair_node_ids,2);
     34       
     35        return;
     36}
     37/*}}}1*/
     38/*FUNCTION Penpair::creation {{{1*/
     39Penpair::Penpair(int penpair_id, Hook* penpair_hnodes,int in_analysis_type){
    2940
    3041        /*all the initialization has been done by the initializer, just fill in the id: */
    3142        this->id=penpair_id;
    3243        this->analysis_type=in_analysis_type;
    33        
    34         return;
    35 }
    36 /*}}}1*/
    37 /*FUNCTION Penpair::creation {{{1*/
    38 Penpair::Penpair(int penpair_id, Hook* penpair_hnodes,int in_analysis_type):
    39         hnodes(penpair_hnodes)
    40 {
    41 
    42         /*all the initialization has been done by the initializer, just fill in the id: */
    43         this->id=penpair_id;
    44         this->analysis_type=in_analysis_type;
     44        this->hnodes=penpair_hnodes;
    4545       
    4646        return;
     
    4949/*FUNCTION Penpair::destructor {{{1*/
    5050Penpair::~Penpair(){
     51        delete hnodes;
    5152        return;
    5253}
     
    6263        printf("   id: %i\n",id);
    6364        printf("   analysis_type: %s\n",EnumAsString(analysis_type));
    64         hnodes.Echo();
     65        hnodes->Echo();
    6566       
    6667        return;
     
    7374        printf("   id: %i\n",id);
    7475        printf("   analysis_type: %s\n",EnumAsString(analysis_type));
    75         hnodes.DeepEcho();
     76        hnodes->DeepEcho();
    7677
    7778        return;
     
    107108
    108109        /*Marshall hooks*/
    109         hnodes.Marshall(&marshalled_dataset);
     110        hnodes->Marshall(&marshalled_dataset);
    110111
    111112        *pmarshalled_dataset=marshalled_dataset;
     
    118119        return sizeof(id)+
    119120                +sizeof(analysis_type)
    120                 +hnodes.MarshallSize()
     121                +hnodes->MarshallSize()
    121122                +sizeof(int); //sizeof(int) for enum type
    122123}
     
    137138
    138139        /*demarshall hooks: */
    139         hnodes.Demarshall(&marshalled_dataset);
     140        hnodes=new Hook(); hnodes->Demarshall(&marshalled_dataset);
    140141
    141142        /*return: */
     
    162163
    163164        /*now deal with hooks and objects: */
    164         penpair->hnodes.copy(&this->hnodes);
     165        penpair->hnodes=(Hook*)this->hnodes->copy();
    165166
    166167        return penpair;
     
    175176        /*Take care of hooking up all objects for this element, ie links the objects in the hooks to their respective
    176177         * datasets, using internal ids and offsets hidden in hooks: */
    177         hnodes.configure(nodesin);
     178        hnodes->configure(nodesin);
    178179
    179180}
  • issm/trunk/src/c/objects/Loads/Penpair.h

    r4248 r4396  
    2020                int analysis_type;
    2121               
    22                 Hook hnodes;  //hook to 2 nodes
     22                Hook* hnodes;  //hook to 2 nodes
    2323
    2424        public:
  • issm/trunk/src/c/objects/Loads/Riftfront.cpp

    r4248 r4396  
    2525        this->inputs=NULL;
    2626        this->parameters=NULL;
     27        this->hnodes=NULL;
     28        this->helements=NULL;
     29        this->hmatpar=NULL;
    2730}
    2831/*}}}*/
     
    5962        riftfront_matpar_id=iomodel->numberofelements+1; //matlab indexing
    6063
    61         this->hnodes.Init(riftfront_node_ids,2);
    62         this->hmatpar.Init(&riftfront_matpar_id,1);
     64        this->hnodes=new Hook(riftfront_node_ids,2);
     65        this->hmatpar=new Hook(&riftfront_matpar_id,1);
    6366
    6467        /*computational parameters: */
     
    98101        delete inputs;
    99102        this->parameters=NULL;
     103        delete hnodes;
     104        delete hmatpar;
     105        delete helements;
    100106}
    101107/*}}}*/
     
    113119        printf("   id: %i\n",id);
    114120        printf("   analysis_type: %s\n",EnumAsString(analysis_type));
    115         hnodes.DeepEcho();
    116         hmatpar.DeepEcho();
     121        hnodes->DeepEcho();
     122        hmatpar->DeepEcho();
    117123        printf("   parameters\n");
    118124        parameters->DeepEcho();
     
    161167
    162168        /*Marshall hooks: */
    163         hnodes.Marshall(&marshalled_dataset);
    164         hmatpar.Marshall(&marshalled_dataset);
     169        hnodes->Marshall(&marshalled_dataset);
     170        hmatpar->Marshall(&marshalled_dataset);
    165171
    166172        /*Marshall inputs: */
     
    192198                +sizeof(prestable)
    193199                +sizeof(penalty_lock)
    194                 +hnodes.MarshallSize()
    195                 +hmatpar.MarshallSize()
     200                +hnodes->MarshallSize()
     201                +hmatpar->MarshallSize()
    196202                +inputs->MarshallSize()
    197203                +sizeof(int); //sizeof(int) for enum type
     
    224230
    225231        /*demarshall hooks: */
    226         hnodes.Demarshall(&marshalled_dataset);
    227         hmatpar.Demarshall(&marshalled_dataset);
     232        hnodes=new Hook(); hnodes->Demarshall(&marshalled_dataset);
     233        hmatpar=new Hook(); hmatpar->Demarshall(&marshalled_dataset);
    228234       
    229235        /*demarshall inputs: */
     
    264270
    265271        /*now deal with hooks and objects: */
    266         riftfront->hnodes.copy(&this->hnodes);
    267         riftfront->helements.copy(&this->helements);
    268         riftfront->hmatpar.copy(&this->hmatpar);
     272        riftfront->hnodes=(Hook*)this->hnodes->copy();
     273        riftfront->hmatpar=(Hook*)this->hmatpar->copy();
    269274
    270275        return riftfront;
     
    279284        /*Take care of hooking up all objects for this element, ie links the objects in the hooks to their respective
    280285         * datasets, using internal ids and offsets hidden in hooks: */
    281         hnodes.configure(nodesin);
    282         hmatpar.configure(materialsin);
     286        hnodes->configure(nodesin);
     287        hmatpar->configure(materialsin);
    283288
    284289        /*point parameters to real dataset: */
     
    320325
    321326        /*Recover hook objects: */
    322         elements=(Element**)helements.deliverp();
    323         nodes=(Node**)hnodes.deliverp();
     327        elements=(Element**)helements->deliverp();
     328        nodes=(Node**)hnodes->deliverp();
    324329
    325330        /*enum of element? */
     
    444449       
    445450        /*Recover hook objects: */
    446         elements=(Element**)helements.deliverp();
    447         nodes=(Node**)hnodes.deliverp();
    448         matpar=(Matpar*)hmatpar.delivers();
     451        elements=(Element**)helements->deliverp();
     452        nodes=(Node**)hnodes->deliverp();
     453        matpar=(Matpar*)hmatpar->delivers();
    449454
    450455        /*enum of element? */
     
    569574
    570575        /*Recover hook objects: */
    571         elements=(Element**)helements.deliverp();
    572         nodes=(Node**)hnodes.deliverp();
     576        elements=(Element**)helements->deliverp();
     577        nodes=(Node**)hnodes->deliverp();
    573578
    574579        /*enum of element? */
     
    647652        Node      **nodes           = NULL;
    648653       
    649         nodes=(Node**)hnodes.deliverp();
     654        nodes=(Node**)hnodes->deliverp();
    650655
    651656        for(i=0;i<MAX_RIFTFRONT_GRIDS;i++){
     
    705710
    706711        /*Recover hook objects: */
    707         elements=(Element**)helements.deliverp();
    708         nodes=(Node**)hnodes.deliverp();
     712        elements=(Element**)helements->deliverp();
     713        nodes=(Node**)hnodes->deliverp();
    709714
    710715        /*enum of element? */
     
    770775
    771776        /*Recover hook objects: */
    772         elements=(Element**)helements.deliverp();
    773         nodes=(Node**)hnodes.deliverp();
     777        elements=(Element**)helements->deliverp();
     778        nodes=(Node**)hnodes->deliverp();
    774779
    775780        /*enum of element? */
     
    820825
    821826        /*Recover hook objects: */
    822         elements=(Element**)helements.deliverp();
    823         nodes=(Node**)hnodes.deliverp();
     827        elements=(Element**)helements->deliverp();
     828        nodes=(Node**)hnodes->deliverp();
    824829
    825830        /*enum of element? */
     
    876881
    877882        /*Recover hook objects: */
    878         elements=(Element**)helements.deliverp();
    879         nodes=(Node**)hnodes.deliverp();
     883        elements=(Element**)helements->deliverp();
     884        nodes=(Node**)hnodes->deliverp();
    880885
    881886        /*enum of element? */
  • issm/trunk/src/c/objects/Loads/Riftfront.h

    r4248 r4396  
    2424                int     analysis_type;
    2525
    26                 Hook hnodes; //2 nodes
    27                 Hook helements; //2 elements
    28                 Hook hmatpar;
     26                Hook* hnodes; //2 nodes
     27                Hook* helements; //2 elements
     28                Hook* hmatpar;
    2929               
    3030                /*computational: */
  • issm/trunk/src/c/objects/Node.cpp

    r4390 r4396  
    2222Node::Node(){
    2323        this->inputs=NULL;
     24        this->hvertex=NULL;
     25        this->hupper_node=NULL;
    2426        return;
    2527}
     
    2729/*FUNCTION Node::Node(int id, int vertex_id, int uppernode_id, int numdofs, NodeProperties*) {{{2*/
    2830Node::Node(int node_id,int node_sid, int node_vertex_id, int node_upper_node_id, int node_numdofs):
    29         indexing(node_numdofs),
    30     hvertex(&node_vertex_id,1),
    31     hupper_node(&node_upper_node_id,1){
     31        indexing(node_numdofs){
    3232
    3333        this->id=node_id;
    3434        this->sid=node_sid;
    3535        this->inputs=new Inputs();
     36       
     37        this->hvertex=new Hook(&node_vertex_id,1);
     38    this->hupper_node=new Hook(&node_upper_node_id,1);
     39
    3640}
    3741/*}}}*/
     
    8690        }
    8791
    88         this->hvertex.Init(&vertex_id,1); //node id is the same as the vertex id, continuous galerkin!
    89         this->hupper_node.Init(&upper_node_id,1);
     92        this->hvertex=new Hook(&vertex_id,1); //node id is the same as the vertex id, continuous galerkin!
     93        this->hupper_node=new Hook(&upper_node_id,1);
    9094
    9195        //intialize inputs, and add as many inputs per element as requested:
     
    201205        indexing.DeepEcho();
    202206        printf("Vertex:\n");
    203         hvertex.DeepEcho();
     207        hvertex->DeepEcho();
    204208        printf("Upper node:\n");
    205209        //Do not Deepecho the upper_node otherwise DeepEcho will go crazy!
    206         hupper_node.Echo();
     210        hupper_node->Echo();
    207211        printf("   inputs\n");
    208212        inputs->DeepEcho();
     
    244248        /*marshall objects: */
    245249        indexing.Marshall(&marshalled_dataset);
    246         hvertex.Marshall(&marshalled_dataset);
    247         hupper_node.Marshall(&marshalled_dataset);
     250        hvertex->Marshall(&marshalled_dataset);
     251        hupper_node->Marshall(&marshalled_dataset);
    248252
    249253        /*Marshall inputs: */
     
    266270                sizeof(sid)+
    267271                indexing.MarshallSize()+
    268                 hvertex.MarshallSize()+
    269                 hupper_node.MarshallSize()+
     272                hvertex->MarshallSize()+
     273                hupper_node->MarshallSize()+
    270274                inputs->MarshallSize()+
    271275                sizeof(analysis_type)+
     
    290294        /*demarshall objects: */
    291295        indexing.Demarshall(&marshalled_dataset);
    292         hvertex.Demarshall(&marshalled_dataset);
    293         hupper_node.Demarshall(&marshalled_dataset);
     296        hvertex=new Hook(); hvertex->Demarshall(&marshalled_dataset);
     297        hupper_node=new Hook(); hupper_node->Demarshall(&marshalled_dataset);
    294298
    295299        /*demarshall inputs: */
     
    311315Object* Node::copy() {
    312316               
    313         return new Node(this->id,this->sid,&this->indexing, &this->hvertex,&this->hupper_node,this->inputs,this->analysis_type);
     317        return new Node(this->id,this->sid,&this->indexing, this->hvertex,this->hupper_node,this->inputs,this->analysis_type);
    314318
    315319}
     
    325329        /*Take care of hooking up all objects for this element, ie links the objects in the hooks to their respective
    326330         * datasets, using internal ids and offsets hidden in hooks: */
    327         hvertex.configure(verticesin);
    328         hupper_node.configure(nodesin);
     331        hvertex->configure(verticesin);
     332        hupper_node->configure(nodesin);
    329333
    330334}
     
    341345        Vertex* vertex=NULL;
    342346
    343         vertex=(Vertex*)this->hvertex.delivers();
     347        vertex=(Vertex*)this->hvertex->delivers();
    344348
    345349        return vertex->dof;
     
    365369        Vertex*  vertex=NULL;
    366370
    367         vertex=(Vertex*)hvertex.delivers();
     371        vertex=(Vertex*)hvertex->delivers();
    368372        return vertex->id;
    369373}
     
    374378        Vertex*  vertex=NULL;
    375379
    376         vertex=(Vertex*)hvertex.delivers();
     380        vertex=(Vertex*)hvertex->delivers();
    377381        return vertex->dof;
    378382}
     
    383387        Vertex*  vertex=NULL;
    384388
    385         vertex=(Vertex*)hvertex.delivers();
     389        vertex=(Vertex*)hvertex->delivers();
    386390        vertex->dof=in_dof;
    387391
     
    706710        Vertex* vertex=NULL;
    707711
    708         vertex=(Vertex*)hvertex.delivers();
     712        vertex=(Vertex*)hvertex->delivers();
    709713        return vertex->sigma;
    710714}
     
    713717Node* Node::GetUpperNode(){
    714718        Node* upper_node=NULL;
    715         upper_node=(Node*)hupper_node.delivers();
     719        upper_node=(Node*)hupper_node->delivers();
    716720        return upper_node;
    717721}
     
    721725        Vertex* vertex=NULL;
    722726
    723         vertex=(Vertex*)hvertex.delivers();
     727        vertex=(Vertex*)hvertex->delivers();
    724728        return vertex->x;
    725729}
     
    729733        Vertex* vertex=NULL;
    730734
    731         vertex=(Vertex*)hvertex.delivers();
     735        vertex=(Vertex*)hvertex->delivers();
    732736        return vertex->y;
    733737}
     
    737741        Vertex* vertex=NULL;
    738742
    739         vertex=(Vertex*)hvertex.delivers();
     743        vertex=(Vertex*)hvertex->delivers();
    740744        return vertex->z;
    741745}
  • issm/trunk/src/c/objects/Node.h

    r4248 r4396  
    2727                               
    2828                DofIndexing    indexing;
    29                 Hook           hvertex;
    30                 Hook           hupper_node;
     29                Hook*          hvertex;
     30                Hook*          hupper_node;
    3131                Inputs*        inputs; //properties of this node
    3232                int            analysis_type;
Note: See TracChangeset for help on using the changeset viewer.