Changeset 3390


Ignore:
Timestamp:
04/05/10 10:32:18 (15 years ago)
Author:
Eric.Larour
Message:

First rough draft of vertex functionality.

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

Legend:

Unmodified
Added
Removed
  • issm/trunk/src/c/objects/ElementProperties.h

    r3383 r3390  
    1111
    1212                /*nodal property values: */
    13                 int     numnodes;
     13                int      numnodes;
    1414                double*  h;
    1515                double*  s;
  • issm/trunk/src/c/objects/Node.cpp

    r3378 r3390  
    6464/*}}}*/
    6565
    66 /*Object marshall*/
     66/*Object management*/
    6767/*FUNCTION Node Marshall{{{1*/
    6868void  Node::Marshall(char** pmarshalled_dataset){
     
    169169}
    170170/*}}}*/
     171/*FUNCTION Node GetId{{{1*/
     172int    Node::GetId(void){ return id; }
     173/*}}}*/
     174/*FUNCTION Node GetName{{{1*/
     175char* Node::GetName(void){
     176        return "node";
     177}
     178/*}}}*/
    171179               
    172180/*Object functions*/
     
    677685}
    678686/*}}}*/
    679 /*FUNCTION Node GetId{{{1*/
    680 int    Node::GetId(void){ return id; }
    681 /*}}}*/
    682 /*FUNCTION Node GetName{{{1*/
    683 char* Node::GetName(void){
    684         return "node";
    685 }
    686 /*}}}*/
    687687/*FUNCTION Node GetNumberOfDofs{{{1*/
    688688int   Node::GetNumberOfDofs(){
  • issm/trunk/src/c/objects/Node.h

    r3372 r3390  
    2222                double  x[3]; /*! coordinates*/
    2323                double  sigma; /*! sigma = (z-bed)/thickness*/
     24               
    2425                int         onbed; /*! for 3d, on bedrock*/
    2526                int         onsurface; /*! for 3d, on surface*/
  • issm/trunk/src/c/objects/Vertex.cpp

    r3388 r3390  
    99#endif
    1010
     11#include <string.h>
    1112#include "./Vertex.h"
    1213#include "../EnumDefinitions/EnumDefinitions.h"
     14#include "../include/macros.h"
     15#include "../shared/shared.h"
     16#include "../include/typedefs.h"
    1317#include "../include/macros.h"
    1418
     
    4852
    4953void Vertex::DeepEcho(void){
    50 
    51         printf("Vertex:\n");
    52         printf("   id: %i\n",id);
    53         hnodes.DeepEcho();
    54         hmatice.DeepEcho();
    55         hmatpar.DeepEcho();
    56         hnumpar.DeepEcho();
    57         properties.DeepEcho();
    58 
    59         return;
     54        this->Echo();
    6055}
    6156/*}}}*/
     
    7368
    7469        memcpy(&id,marshalled_dataset,sizeof(id));marshalled_dataset+=sizeof(id);
    75 
    76         /*demarshall hooks: */
    77         hnodes.Demarshall(&marshalled_dataset);
    78         hmatice.Demarshall(&marshalled_dataset);
    79         hmatpar.Demarshall(&marshalled_dataset);
    80         hnumpar.Demarshall(&marshalled_dataset);
    81 
    82         /*demarshall properties: */
    83         properties.Demarshall(&marshalled_dataset);
     70        memcpy(&x,marshalled_dataset,sizeof(x));marshalled_dataset+=sizeof(x);
     71        memcpy(&y,marshalled_dataset,sizeof(y));marshalled_dataset+=sizeof(y);
     72        memcpy(&z,marshalled_dataset,sizeof(z));marshalled_dataset+=sizeof(z);
    8473
    8574        /*return: */
     
    9483        printf("Vertex:\n");
    9584        printf("   id: %i\n",id);
    96         hnodes.Echo();
    97         hmatice.Echo();
    98         hmatpar.Echo();
    99         hnumpar.Echo();
    100         properties.Echo();
     85        printf("   x: %g\n",x);
     86        printf("   y: %g\n",y);
     87        printf("   z: %g\n",z);
    10188
    10289        return;
     
    10895        return VertexEnum();
    10996
     97}
     98/*}}}*/
     99/*FUNCTION GetId{{{1*/
     100int    Vertex::GetId(void){ return id; }
     101/*}}}*/
     102/*FUNCTION GetName{{{1*/
     103char* Vertex::GetName(void){
     104        return "node";
    110105}
    111106/*}}}*/
     
    127122        /*marshall Vertex data: */
    128123        memcpy(marshalled_dataset,&id,sizeof(id));marshalled_dataset+=sizeof(id);
    129 
    130         /*Marshall hooks: */
    131         hnodes.Marshall(&marshalled_dataset);
    132         hmatice.Marshall(&marshalled_dataset);
    133         hmatpar.Marshall(&marshalled_dataset);
    134         hnumpar.Marshall(&marshalled_dataset);
    135 
    136         /*Marshall properties: */
    137         properties.Marshall(&marshalled_dataset);
     124        memcpy(marshalled_dataset,&x,sizeof(x));marshalled_dataset+=sizeof(x);
     125        memcpy(marshalled_dataset,&y,sizeof(y));marshalled_dataset+=sizeof(y);
     126        memcpy(marshalled_dataset,&z,sizeof(z));marshalled_dataset+=sizeof(z);
    138127
    139128        *pmarshalled_dataset=marshalled_dataset;
     
    144133int   Vertex::MarshallSize(){
    145134       
    146         return sizeof(id)
    147                 +hnodes.MarshallSize()
    148                 +hmatice.MarshallSize()
    149                 +hmatpar.MarshallSize()
    150                 +hnumpar.MarshallSize()
    151                 +properties.MarshallSize()
     135        return sizeof(id)+
     136                sizeof(x)+
     137                sizeof(y)+
     138                sizeof(z)+
    152139                +sizeof(int); //sizeof(int) for enum type
    153140}
     
    162149void  Vertex::UpdateFromDakota(void* vinputs){
    163150
    164         int     i;
    165         int     dofs[1]={0};
    166         double  temperature_list[3];
    167         double  temperature_average;
    168         double  B_list[3];
    169         double  B_average;
    170         double  new_h[3];
    171 
    172         /*dynamic objects pointed to by hooks: */
    173         Node**  nodes=NULL;
    174         Matpar* matpar=NULL;
    175         Matice* matice=NULL;
    176         Numpar* numpar=NULL;
    177 
    178         ParameterInputs* inputs=NULL;
    179 
    180         /*recover pointers: */
    181         inputs=(ParameterInputs*)vinputs;
    182 
    183         /*recover objects from hooks: */
    184         nodes=(Node**)hnodes.deliverp();
    185         matpar=(Matpar*)hmatpar.delivers();
    186         matice=(Matice*)hmatice.delivers();
    187         numpar=(Numpar*)hnumpar.delivers();
    188 
    189         /*Update internal data if inputs holds new values: */
    190         inputs->Recover("thickness",&this->properties.h[0],1,dofs,3,(void**)nodes);
    191                
    192         if(inputs->Recover("thickness",&new_h[0],1,dofs,3,(void**)nodes)){
    193         //density, needed later:
    194         double di=(this->matpar->GetRhoIce()/this->matpar->GetRhoWater());
    195         //Go through grids:
    196         for (i=0;i<3;i++){
    197         if(nodes[i]->IsOnShelf()){
    198         this->b[i]=this->b[i]-di*(new_h[i]-h[i]); //hydrostatic equilibrium;
    199         }
    200         this->s[i]=this->b[i]+new_h[i];
    201         this->h[i]=new_h[i];
    202         }
    203         }
     151        ISSMERROR("not supported yet!");
    204152       
    205153}
     
    208156void  Vertex::UpdateFromInputs(void* vinputs){
    209157
    210         int     i;
    211         int     dofs[1]={0};
    212         double  temperature_list[3];
    213         double  temperature_average;
    214         double  B_list[3];
    215         double  B_average;
    216         double  new_h[3];
    217 
    218         /*dynamic objects pointed to by hooks: */
    219         Node**  nodes=NULL;
    220         Matpar* matpar=NULL;
    221         Matice* matice=NULL;
    222         Numpar* numpar=NULL;
    223 
    224         ParameterInputs* inputs=NULL;
    225 
    226         /*recover pointers: */
    227         inputs=(ParameterInputs*)vinputs;
    228 
    229         /*recover objects from hooks: */
    230         nodes=(Node**)hnodes.deliverp();
    231         matpar=(Matpar*)hmatpar.delivers();
    232         matice=(Matice*)hmatice.delivers();
    233         numpar=(Numpar*)hnumpar.delivers();
    234 
    235         /*Update internal data if inputs holds new values: */
    236         //if (id==1) printf("WARNING if QMU: no hydrostatic equilibrium is applied here (conflict with prognostic, which does not have matpar)\n");
    237         //For now
    238         inputs->Recover("thickness",&this->properties.h[0],1,dofs,3,(void**)nodes);
    239         //Later
    240         /*
    241                 if(inputs->Recover("thickness",&new_h[0],1,dofs,3,(void**)nodes)){
    242         //density, needed later:
    243         double di=(this->matpar->GetRhoIce()/this->matpar->GetRhoWater());
    244         //Go through grids:
    245         for (i=0;i<3;i++){
    246         if(nodes[i]->IsOnShelf()){
    247         this->b[i]=this->b[i]-di*(new_h[i]-h[i]); //hydrostatic equilibrium;
    248         }
    249         this->s[i]=this->b[i]+new_h[i];
    250         this->h[i]=new_h[i];
    251         }
    252         }
    253         */
    254         inputs->Recover("surface",&this->properties.s[0],1,dofs,3,(void**)nodes);
    255         inputs->Recover("bed",&this->properties.b[0],1,dofs,3,(void**)nodes);
    256         inputs->Recover("drag",&this->properties.k[0],1,dofs,3,(void**)nodes);
    257         inputs->Recover("melting",&this->properties.melting[0],1,dofs,3,(void**)nodes);
    258         inputs->Recover("accumulation",&this->properties.accumulation[0],1,dofs,3,(void**)nodes);
    259         inputs->Recover("geothermalflux",&this->properties.geothermalflux[0],1,dofs,3,(void**)nodes);
     158        ISSMERROR("not supported yet!");
    260159       
    261         //Update material if necessary
    262         if(inputs->Recover("temperature_average",&temperature_list[0],1,dofs,3,(void**)nodes)){
    263                 temperature_average=(temperature_list[0]+temperature_list[1]+temperature_list[2])/3.0;
    264                 B_average=Paterson(temperature_average);
    265                 matice->SetB(B_average);
    266         }
    267        
    268         if(inputs->Recover("B",&B_list[0],1,dofs,3,(void**)nodes)){
    269                 B_average=(B_list[0]+B_list[1]+B_list[2])/3.0;
    270                 matice->SetB(B_average);
    271         }
    272 
    273160}
    274161/*}}}*/
  • issm/trunk/src/c/objects/Vertex.h

    r3388 r3390  
    66#define _VERTEX_H_
    77
     8#include "./Object.h"
    89
    9 class Vertex{
     10class Vertex: public Object{
    1011
    1112        private:
     
    2930                void  Echo();
    3031                int   Enum();
    31                 int   Id();
     32                int   GetId(void);
     33                char* GetName();
    3234                void  Marshall(char** pmarshalled_dataset);
    3335                int   MarshallSize();
Note: See TracChangeset for help on using the changeset viewer.