Changeset 3389 for issm/trunk


Ignore:
Timestamp:
04/05/10 09:55:42 (15 years ago)
Author:
Eric.Larour
Message:

Added copy constructor, and some debugging

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

Legend:

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

    r3388 r3389  
    385385        }
    386386
    387         ISSMERROR("create UpdateFromDakota routine, to call UpdateFromDakota in the elements, so it does not conflict
    388                         with UpdateFromInputs! in the elements");
     387        ISSMERROR("create UpdateFromDakota routine, to call UpdateFromDakota in the elements, so it does not conflict with UpdateFromInputs! in the elements");
    389388
    390389
  • issm/trunk/src/c/objects/Penta.cpp

    r3383 r3389  
    3838}
    3939/*}}}*/
     40/*FUNCTION Penta other constructor {{{1*/
     41Penta::Penta(int penta_id,Hook* penta_hnodes, Hook* penta_hmatice, Hook* penta_hmatpar, Hook* penta_hnumpar, ElementProperties* penta_properties):
     42        hnodes(penta_hnodes),
     43        hmatice(penta_hmatice),
     44        hmatpar(penta_hmatpar),
     45        hnumpar(penta_hnumpar),
     46        properties(penta_properties)
     47{
     48
     49        /*all the initialization has been done by the initializer, just fill in the id: */
     50        this->id=penta_id;
     51
     52        return;
     53}
     54/*}}}*/
    4055/*FUNCTION Penta destructor {{{1*/
    4156Penta::~Penta(){
     
    4459/*}}}*/
    4560
    46 /*Object marshall*/
     61/*Object management: */
     62/*FUNCTION Configure {{{1*/
     63void  Penta::Configure(void* ploadsin,void* pnodesin,void* pmaterialsin,void* pparametersin){
     64
     65        int i;
     66
     67        DataSet* loadsin=NULL;
     68        DataSet* nodesin=NULL;
     69        DataSet* materialsin=NULL;
     70        DataSet* parametersin=NULL;
     71
     72        /*Recover pointers :*/
     73        loadsin=(DataSet*)ploadsin;
     74        nodesin=(DataSet*)pnodesin;
     75        materialsin=(DataSet*)pmaterialsin;
     76        parametersin=(DataSet*)pparametersin;
     77
     78        /*Take care of hooking up all objects for this element, ie links the objects in the hooks to their respective
     79         * datasets, using internal ids and offsets hidden in hooks: */
     80        hnodes.configure(nodesin);
     81        hmatice.configure(materialsin);
     82        hmatpar.configure(materialsin);
     83        hnumpar.configure(parametersin);
     84
     85}
     86/*}}}*/
     87/*FUNCTION copy {{{1*/
     88Object* Penta::copy() {
     89        return new Penta(this->id,&this->hnodes,&this->hmatice,&this->hmatpar,&this->hnumpar,&this->properties);
     90}
     91/*}}}*/
     92/*FUNCTION Demarshall {{{1*/
     93void  Penta::Demarshall(char** pmarshalled_dataset){
     94
     95        char* marshalled_dataset=NULL;
     96        int   i;
     97
     98        /*recover marshalled_dataset: */
     99        marshalled_dataset=*pmarshalled_dataset;
     100
     101        /*this time, no need to get enum type, the pointer directly points to the beginning of the
     102         *object data (thanks to DataSet::Demarshall):*/
     103
     104        memcpy(&id,marshalled_dataset,sizeof(id));marshalled_dataset+=sizeof(id);
     105
     106        /*demarshall hooks: */
     107        hnodes.Demarshall(&marshalled_dataset);
     108        hmatice.Demarshall(&marshalled_dataset);
     109        hmatpar.Demarshall(&marshalled_dataset);
     110        hnumpar.Demarshall(&marshalled_dataset);
     111
     112        /*demarshall properties: */
     113        properties.Demarshall(&marshalled_dataset);
     114
     115        /*return: */
     116        *pmarshalled_dataset=marshalled_dataset;
     117        return;
     118}
     119/*}}}*/
     120/*FUNCTION DeepEcho{{{1*/
     121
     122void Penta::DeepEcho(void){
     123
     124        printf("Penta:\n");
     125        printf("   id: %i\n",id);
     126        hnodes.DeepEcho();
     127        hmatice.DeepEcho();
     128        hmatpar.DeepEcho();
     129        hnumpar.DeepEcho();
     130        properties.DeepEcho();
     131
     132        return;
     133}
     134/*}}}*/
     135/*FUNCTION Echo{{{1*/
     136
     137void Penta::Echo(void){
     138
     139        printf("Penta:\n");
     140        printf("   id: %i\n",id);
     141        hnodes.Echo();
     142        hmatice.Echo();
     143        hmatpar.Echo();
     144        hnumpar.Echo();
     145        properties.Echo();
     146
     147        return;
     148}
     149/*}}}*/
    47150/*FUNCTION Marshall {{{1*/
    48151void  Penta::Marshall(char** pmarshalled_dataset){
     
    88191}
    89192/*}}}*/
    90 /*FUNCTION Demarshall {{{1*/
    91 void  Penta::Demarshall(char** pmarshalled_dataset){
    92 
    93         char* marshalled_dataset=NULL;
    94         int   i;
    95 
    96         /*recover marshalled_dataset: */
    97         marshalled_dataset=*pmarshalled_dataset;
    98 
    99         /*this time, no need to get enum type, the pointer directly points to the beginning of the
    100          *object data (thanks to DataSet::Demarshall):*/
    101 
    102         memcpy(&id,marshalled_dataset,sizeof(id));marshalled_dataset+=sizeof(id);
    103 
    104         /*demarshall hooks: */
    105         hnodes.Demarshall(&marshalled_dataset);
    106         hmatice.Demarshall(&marshalled_dataset);
    107         hmatpar.Demarshall(&marshalled_dataset);
    108         hnumpar.Demarshall(&marshalled_dataset);
    109 
    110         /*demarshall properties: */
    111         properties.Demarshall(&marshalled_dataset);
    112 
    113         /*return: */
    114         *pmarshalled_dataset=marshalled_dataset;
    115         return;
    116 }
    117 /*}}}*/
    118 
    119 /*Object processing: */
    120 /*FUNCTION Echo{{{1*/
    121 
    122 void Penta::Echo(void){
    123 
    124         printf("Penta:\n");
    125         printf("   id: %i\n",id);
    126         hnodes.Echo();
    127         hmatice.Echo();
    128         hmatpar.Echo();
    129         hnumpar.Echo();
    130         properties.Echo();
    131 
    132         return;
    133 }
    134 /*}}}*/
    135 /*FUNCTION DeepEcho{{{1*/
    136 
    137 void Penta::DeepEcho(void){
    138 
    139         printf("Penta:\n");
    140         printf("   id: %i\n",id);
    141         hnodes.DeepEcho();
    142         hmatice.DeepEcho();
    143         hmatpar.DeepEcho();
    144         hnumpar.DeepEcho();
    145         properties.DeepEcho();
    146 
    147         return;
    148 }
    149 /*}}}*/
    150 /*FUNCTION Configure {{{1*/
    151 void  Penta::Configure(void* ploadsin,void* pnodesin,void* pmaterialsin,void* pparametersin){
    152 
    153         int i;
    154 
    155         DataSet* loadsin=NULL;
    156         DataSet* nodesin=NULL;
    157         DataSet* materialsin=NULL;
    158         DataSet* parametersin=NULL;
    159 
    160         /*Recover pointers :*/
    161         loadsin=(DataSet*)ploadsin;
    162         nodesin=(DataSet*)pnodesin;
    163         materialsin=(DataSet*)pmaterialsin;
    164         parametersin=(DataSet*)pparametersin;
    165 
    166         /*Take care of hooking up all objects for this element, ie links the objects in the hooks to their respective
    167          * datasets, using internal ids and offsets hidden in hooks: */
    168         hnodes.configure(nodesin);
    169         hmatice.configure(materialsin);
    170         hmatpar.configure(materialsin);
    171         hnumpar.configure(parametersin);
    172 
    173 }
    174 /*}}}*/
    175193/*FUNCTION SpawnTria {{{1*/
    176194void*  Penta::SpawnTria(int g0, int g1, int g2){
     
    206224}
    207225/*}}}*/
     226/*FUNCTION UpdateFromInputs {{{1*/
     227void  Penta::UpdateFromInputs(void* vinputs){
     228
     229        int     dofs[1]={0};
     230        double  temperature_list[6];
     231        double  temperature_average;
     232        double  B_list[6];
     233        double  B_average;
     234
     235        /*dynamic objects pointed to by hooks: */
     236        Node**  nodes=NULL;
     237        Matice* matice=NULL;
     238
     239        ParameterInputs* inputs=NULL;
     240
     241        /*If on water, skip: */
     242        if(this->properties.onwater)return;
     243
     244        /*recover objects from hooks: */
     245        nodes=(Node**)hnodes.deliverp();
     246        matice=(Matice*)hmatice.delivers();
     247
     248        /*recover pointers: */
     249        inputs=(ParameterInputs*)vinputs;
     250
     251        /*Update internal data if inputs holds new values: */
     252        inputs->Recover("thickness",&this->properties.h[0],1,dofs,6,(void**)nodes);
     253        inputs->Recover("surface",&this->properties.s[0],1,dofs,6,(void**)nodes);
     254        inputs->Recover("bed",&this->properties.b[0],1,dofs,6,(void**)nodes);
     255        inputs->Recover("drag",&this->properties.k[0],1,dofs,6,(void**)nodes);
     256        inputs->Recover("melting",&this->properties.melting[0],1,dofs,6,(void**)nodes);
     257        inputs->Recover("accumulation_param",&this->properties.accumulation[0],1,dofs,6,(void**)nodes);
     258
     259        //Update material if necessary
     260        if(inputs->Recover("temperature",&temperature_list[0],1,dofs,6,(void**)nodes)){
     261                if(matice && !this->properties.collapse){
     262                        //B_average=(Paterson(temperature_list[0])+Paterson(temperature_list[1])+Paterson(temperature_list[2])
     263                        //                      +Paterson(temperature_list[3])+Paterson(temperature_list[4])+Paterson(temperature_list[5]))/6.0;
     264                        temperature_average=(temperature_list[0]+temperature_list[1]+temperature_list[2]+temperature_list[3]+temperature_list[4]+temperature_list[5])/6.0;
     265                        B_average=Paterson(temperature_average);
     266                        matice->SetB(B_average);
     267                }
     268        }
     269
     270        if(inputs->Recover("temperature_average",&temperature_list[0],1,dofs,6,(void**)nodes)){
     271                if(matice && this->properties.collapse){
     272                        temperature_average=(temperature_list[0]+temperature_list[1]+temperature_list[2]+temperature_list[3]+temperature_list[4]+temperature_list[5])/6.0;
     273                        B_average=Paterson(temperature_average);
     274                        //B_average=(Paterson(temperature_list[0])+Paterson(temperature_list[1])+Paterson(temperature_list[2])
     275                        //                      +Paterson(temperature_list[3])+Paterson(temperature_list[4])+Paterson(temperature_list[5]))/6.0;
     276                        matice->SetB(B_average);
     277                }
     278        }
     279
     280        if(inputs->Recover("B",&B_list[0],1,dofs,6,(void**)nodes)){
     281                if(matice){
     282                        B_average=(B_list[0]+B_list[1]+B_list[2]+B_list[3]+B_list[4]+B_list[5])/6.0;
     283                        matice->SetB(B_average);
     284                }
     285        }
     286
     287}
     288/*}}}*/
     289/*FUNCTION UpdateFromDakota {{{1*/
     290void  Penta::UpdateFromDakota(void* vinputs){
     291
     292        ISSMERROR("not supported yet!");
     293
     294}
     295/*}}}*/
    208296
    209297/*Object functions*/
     
    248336        VecSetValues(pg,numgrids,doflist,(const double*)pressure,INSERT_VALUES);
    249337
    250 }
    251 /*}}}*/
    252 /*FUNCTION copy {{{1*/
    253 Object* Penta::copy() {
    254         return new Penta(*this);
    255338}
    256339/*}}}*/
     
    39764059}
    39774060/*}}}*/
    3978 /*FUNCTION UpdateFromInputs {{{1*/
    3979 void  Penta::UpdateFromInputs(void* vinputs){
    3980 
    3981         int     dofs[1]={0};
    3982         double  temperature_list[6];
    3983         double  temperature_average;
    3984         double  B_list[6];
    3985         double  B_average;
    3986 
    3987         /*dynamic objects pointed to by hooks: */
    3988         Node**  nodes=NULL;
    3989         Matice* matice=NULL;
    3990 
    3991         ParameterInputs* inputs=NULL;
    3992 
    3993         /*If on water, skip: */
    3994         if(this->properties.onwater)return;
    3995 
    3996         /*recover objects from hooks: */
    3997         nodes=(Node**)hnodes.deliverp();
    3998         matice=(Matice*)hmatice.delivers();
    3999 
    4000         /*recover pointers: */
    4001         inputs=(ParameterInputs*)vinputs;
    4002 
    4003         /*Update internal data if inputs holds new values: */
    4004         inputs->Recover("thickness",&this->properties.h[0],1,dofs,6,(void**)nodes);
    4005         inputs->Recover("surface",&this->properties.s[0],1,dofs,6,(void**)nodes);
    4006         inputs->Recover("bed",&this->properties.b[0],1,dofs,6,(void**)nodes);
    4007         inputs->Recover("drag",&this->properties.k[0],1,dofs,6,(void**)nodes);
    4008         inputs->Recover("melting",&this->properties.melting[0],1,dofs,6,(void**)nodes);
    4009         inputs->Recover("accumulation_param",&this->properties.accumulation[0],1,dofs,6,(void**)nodes);
    4010 
    4011         //Update material if necessary
    4012         if(inputs->Recover("temperature",&temperature_list[0],1,dofs,6,(void**)nodes)){
    4013                 if(matice && !this->properties.collapse){
    4014                         //B_average=(Paterson(temperature_list[0])+Paterson(temperature_list[1])+Paterson(temperature_list[2])
    4015                         //                      +Paterson(temperature_list[3])+Paterson(temperature_list[4])+Paterson(temperature_list[5]))/6.0;
    4016                         temperature_average=(temperature_list[0]+temperature_list[1]+temperature_list[2]+temperature_list[3]+temperature_list[4]+temperature_list[5])/6.0;
    4017                         B_average=Paterson(temperature_average);
    4018                         matice->SetB(B_average);
    4019                 }
    4020         }
    4021 
    4022         if(inputs->Recover("temperature_average",&temperature_list[0],1,dofs,6,(void**)nodes)){
    4023                 if(matice && this->properties.collapse){
    4024                         temperature_average=(temperature_list[0]+temperature_list[1]+temperature_list[2]+temperature_list[3]+temperature_list[4]+temperature_list[5])/6.0;
    4025                         B_average=Paterson(temperature_average);
    4026                         //B_average=(Paterson(temperature_list[0])+Paterson(temperature_list[1])+Paterson(temperature_list[2])
    4027                         //                      +Paterson(temperature_list[3])+Paterson(temperature_list[4])+Paterson(temperature_list[5]))/6.0;
    4028                         matice->SetB(B_average);
    4029                 }
    4030         }
    4031 
    4032         if(inputs->Recover("B",&B_list[0],1,dofs,6,(void**)nodes)){
    4033                 if(matice){
    4034                         B_average=(B_list[0]+B_list[1]+B_list[2]+B_list[3]+B_list[4]+B_list[5])/6.0;
    4035                         matice->SetB(B_average);
    4036                 }
    4037         }
    4038 
    4039 }
    4040 /*}}}*/
    40414061/*FUNCTION SurfaceArea {{{1*/
    40424062double Penta::SurfaceArea(void* inputs,int analysis_type,int sub_analysis_type){
  • issm/trunk/src/c/objects/Penta.h

    r3383 r3389  
    4040                Penta();
    4141                Penta(int penta_id,int* penta_node_ids, int penta_matice_id, int penta_matpar_id, int penta_numpar_id, ElementProperties* properties);
     42                Penta(int penta_id,Hook* penta_hnodes, Hook* penta_hmatice, Hook* penta_hmatpar, Hook* penta_hnumpar, ElementProperties* penta_properties);
    4243                ~Penta();
    4344                /*}}}*/
    4445                /*FUNCTION object management {{{1*/
     46                void  Configure(void* loads,void* nodes,void* materials,void* parameters);
     47                Object* copy();
     48                void  DeepEcho();
     49                void  Demarshall(char** pmarshalled_dataset);
    4550                void  Echo();
    46                 void  DeepEcho();
     51                int   Enum();
     52                int   GetId();
     53                char* GetName();
    4754                void  Marshall(char** pmarshalled_dataset);
    4855                int   MarshallSize();
    49                 char* GetName();
    50                 void  Demarshall(char** pmarshalled_dataset);
    51                 int   Enum();
    52                 int   GetId();
    5356                int   MyRank();
    54                 void  Configure(void* loads,void* nodes,void* materials,void* parameters);
     57                void*  SpawnTria(int g0, int g1, int g2);
     58                void  UpdateFromDakota(void* inputs);
     59                void  UpdateFromInputs(void* inputs);
    5560                /*}}}*/
    5661                /*FUNCTION element numerical routines {{{1*/
     
    5964                void  CreateKMatrixDiagnosticVert( Mat Kgg, void* inputs, int analysis_type,int sub_analysis_type);
    6065                void  CreatePVector(Vec pg, void* inputs, int analysis_type,int sub_analysis_type);
    61                 void  UpdateFromInputs(void* inputs);
    6266                void  GetDofList(int* doflist,int* pnumberofdofs);
    6367                void  GetDofList1(int* doflist);
     
    7680                void          GetThicknessList(double* thickness_list);
    7781                void          GetBedList(double* bed_list);
    78                 Object* copy();
    79                 void*  SpawnTria(int g0, int g1, int g2);
    8082
    8183                void  GetStrainRate(double* epsilon, double* velocity, double* xyz_list, double* gauss_coord);
  • issm/trunk/src/c/objects/Tria.cpp

    r3388 r3389  
    9696Object* Tria::copy() {
    9797
    98         return new Tria(this->id,this->hnodes,this->hmatice,this->hmatpar,this->hnumpar,this->properties);
     98        return new Tria(this->id,&this->hnodes,&this->hmatice,&this->hmatpar,&this->hnumpar,&this->properties);
    9999
    100100}
     
    299299
    300300        /*Update internal data if inputs holds new values: */
    301         inputs->Recover("thickness",&this->properties.h[0],1,dofs,3,(void**)nodes);
     301        /*inputs->Recover("thickness",&this->properties.h[0],1,dofs,3,(void**)nodes);
    302302        if(inputs->Recover("thickness",&new_h[0],1,dofs,3,(void**)nodes)){
    303303        //density, needed later:
     
    311311        this->h[i]=new_h[i];
    312312        }
    313         }
     313        }*/
    314314
    315315        ISSMERROR("not supported yet!");
Note: See TracChangeset for help on using the changeset viewer.