Changeset 3430


Ignore:
Timestamp:
04/07/10 16:14:35 (15 years ago)
Author:
Eric.Larour
Message:

Progress in simplifying ModelProcessor

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

Legend:

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

    r3359 r3430  
    1616#include "../include/typedefs.h"
    1717#include "../include/macros.h"
    18 #include "./objects.h"
     18#include "./Icefront.h"
    1919
    2020               
     
    2525}
    2626/*}}}*/
    27 /*FUNCTION Icefront creation {{{1*/
     27/*FUNCTION Icefront constructor {{{1*/
    2828Icefront::Icefront(char icefront_type[ICEFRONTSTRING],int icefront_fill,int icefront_sid, int icefront_mparid, int icefront_eid, int icefront_element_type,
     29                int icefront_node_ids[MAX_ICEFRONT_GRIDS],double icefront_h[MAX_ICEFRONT_GRIDS],double  icefront_b[MAX_ICEFRONT_GRIDS]){
     30       
     31        this->Init(icefront_type,icefront_fill,icefront_sid, icefront_mparid, icefront_eid, icefront_element_type,
     32                icefront_node_ids,icefront_h,icefront_b);
     33
     34}
     35/*}}}*/
     36/*FUNCTION Init: used by  constructor {{{1*/
     37void Icefront::Init(char icefront_type[ICEFRONTSTRING],int icefront_fill,int icefront_sid, int icefront_mparid, int icefront_eid, int icefront_element_type,
    2938                int icefront_node_ids[MAX_ICEFRONT_GRIDS],double icefront_h[MAX_ICEFRONT_GRIDS],double  icefront_b[MAX_ICEFRONT_GRIDS]){
    3039
     
    5261        element=NULL;
    5362        element_offset=UNDEF;
    54 
    55         return;
    56 }
     63}
     64/*}}}*/
     65/*FUNCTION Icefront constructor from iomodel {{{1*/
     66Icefront::Icefront(int i, IoModel* iomodel){
     67
     68        int segment_width;
     69        int element_type;
     70        int i1,i2,i3,i4;
     71        int element;
     72
     73        /*icefront intermediary data: */
     74        char icefront_type[ICEFRONTSTRING];
     75        int  icefront_fill;
     76        int  icefront_element_type;
     77        int  icefront_sid;
     78        int  icefront_eid;
     79        int  icefront_mparid;
     80        int  icefront_node_ids[MAX_ICEFRONT_GRIDS];
     81        double icefront_h[MAX_ICEFRONT_GRIDS];
     82        double  icefront_b[MAX_ICEFRONT_GRIDS];
     83
     84        /*First, retrieve element index and element type: */
     85        if (strcmp(iomodel->meshtype,"2d")==0){
     86                segment_width=4;
     87                element_type=TriaEnum();
     88        }
     89        else{
     90                segment_width=6;
     91                element_type=PentaEnum();
     92        }
     93        element=(int)(*(iomodel->pressureload+segment_width*i+segment_width-2)-1); //element is in the penultimate column (grid1 grid2 ... elem fill)
     94
     95        icefront_mparid=iomodel->numberofelements+1; //matlab indexing
     96        icefront_mparid=iomodel->numberofelements+1; //matlab indexing
     97        icefront_sid=i+1; //matlab indexing
     98        icefront_fill=(int)*(iomodel->pressureload+segment_width*i+segment_width-1);
     99        icefront_eid=(int) *(iomodel->pressureload+segment_width*i+segment_width-2); //matlab indexing
     100        icefront_element_type=element_type;
     101
     102        i1=(int)*(iomodel->pressureload+segment_width*i+0);
     103        i2=(int)*(iomodel->pressureload+segment_width*i+1);
     104
     105        icefront_node_ids[0]=i1;
     106        icefront_node_ids[1]=i2;
     107
     108        icefront_h[0]=iomodel->thickness[i1-1];
     109        icefront_h[1]=iomodel->thickness[i2-1];
     110
     111        icefront_b[0]=iomodel->bed[i1-1];
     112        icefront_b[1]=iomodel->bed[i2-1];
     113
     114        if ((int)*(iomodel->elements_type+2*element+0)==MacAyealFormulationEnum()){ //this is a collapsed 3d element, icefront will be 2d
     115                strcpy(icefront_type,"segment");
     116        }
     117        else if ((int)*(iomodel->elements_type+2*element+0)==PattynFormulationEnum()){ //this is a real 3d element, icefront will be 3d.
     118                strcpy(icefront_type,"quad");
     119                i3=(int)*(iomodel->pressureload+segment_width*i+2);
     120                i4=(int)*(iomodel->pressureload+segment_width*i+3);
     121                icefront_node_ids[2]=i3;
     122                icefront_node_ids[3]=i4;
     123
     124                icefront_h[2]=iomodel->thickness[i3-1];
     125                icefront_h[3]=iomodel->thickness[i4-1];
     126
     127                icefront_b[2]=iomodel->bed[i3-1];
     128                icefront_b[3]=iomodel->bed[i4-1];
     129        }
     130        else{
     131                ISSMERROR(exprintf(" element type %i not supported yet",(int)*(iomodel->elements_type+2*element+0)));
     132        }
     133
     134        this->Init(icefront_type,icefront_fill,icefront_sid,icefront_mparid,icefront_eid,icefront_element_type,icefront_node_ids,icefront_h,icefront_b);
     135}
     136
     137
    57138/*}}}*/
    58139/*FUNCTION Icefront destructor {{{1*/
  • TabularUnified issm/trunk/src/c/objects/Icefront.h

    r3420 r3430  
    1616#include "./Element.h"
    1717#include "./Node.h"
     18#include "../ModelProcessorx/IoModel.h"
    1819
    1920#define MAX_ICEFRONT_GRIDS 4 //max number of grids for a certain load
     
    2324
    2425        private:
    25                 char    type[ICEFRONTSTRING];
     26                char  type[ICEFRONTSTRING];
    2627                int   fill;
    27                 int     sid;
     28                int       sid;
    2829       
    2930                /*material: */
     
    4950        public:
    5051
     52                /*constructors: {{{1*/
    5153                Icefront();
    5254                Icefront(char type[ICEFRONTSTRING],int fill,int sid, int mparid, int eid, int element_type, int node_ids[MAX_ICEFRONT_GRIDS],double h[MAX_ICEFRONT_GRIDS],double        b[MAX_ICEFRONT_GRIDS]);
     55                void Init(char type[ICEFRONTSTRING],int fill,int sid, int mparid, int eid, int element_type, int node_ids[MAX_ICEFRONT_GRIDS],double h[MAX_ICEFRONT_GRIDS],double       b[MAX_ICEFRONT_GRIDS]);
     56                Icefront(int i, IoModel* iomodel);
    5357                ~Icefront();
    54 
     58                /*}}}*/
     59                /*object management: {{{1*/
     60                void  Configure(void* elements,void* nodes,void* materials);
     61                Object* copy();
     62                void  DeepEcho();
     63                void  Demarshall(char** pmarshalled_dataset);
    5564                void  Echo();
    56                 void  DeepEcho();
     65                int   Enum();
     66                int   GetId();
     67                char* GetName();
    5768                void  Marshall(char** pmarshalled_dataset);
    5869                int   MarshallSize();
    59                 char* GetName();
    60                 void  Demarshall(char** pmarshalled_dataset);
    61                 int   Enum();
    62                 int   GetId();
    6370                int   MyRank();
     71                /*}}}*/
     72                /*numerics: {{{1*/
    6473                void  DistributeNumDofs(int* numdofspernode,int analysis_type,int sub_analysis_type);
    65                 void  Configure(void* elements,void* nodes,void* materials);
    6674                void  CreateKMatrix(Mat Kgg,void* inputs,int analysis_type,int sub_analysis_type);
    6775                void  UpdateFromInputs(void* inputs);
    68                
    6976                void  CreatePVector(Vec pg, void* inputs, int analysis_type,int sub_analysis_type);
    7077                void  CreatePVectorDiagnosticHoriz( Vec pg, void* inputs, int analysis_type,int sub_analysis_type);
     
    8087                void  PenaltyCreateKMatrix(Mat Kgg,void* inputs,double kmax,int analysis_type,int sub_analysis_type);
    8188                void  PenaltyCreatePVector(Vec pg,void* inputs,double kmax,int analysis_type,int sub_analysis_type);
    82                 Object* copy();
     89                /*}}}*/
    8390};
    8491
  • TabularUnified issm/trunk/src/c/objects/Node.cpp

    r3427 r3430  
    5252}
    5353/*}}}*/
    54 /*FUNCTION Node constructor from iomodel continuous Galerkin{{{2*/
     54/*FUNCTION Node constructor  from iomodel{{{2*/
    5555Node::Node(int i, IoModel* iomodel){ //i is the node index
    5656
     
    9898
    9999        /*set single point constraints.: */
    100         /*FROM DIAGNOSTICHORIZ*/
    101100        if (strcmp(iomodel->meshtype,"3d")==0){
    102101                /*We have a  3d mesh, we may have collapsed elements, hence dead grids. Freeze them out: */
     
    112111                }
    113112        }
    114         /*FROM DIAGNOSTICSTOKES*/
    115113        /*On a 3d mesh, in stokes formualtions, only stokes grids are free, the others are frozen: */
    116114        if (iomodel->borderstokes[i]){
    117115                //freeze everything except pressure
    118                 node->FreezeDof(1);
    119                 node->FreezeDof(2);
    120                 node->FreezeDof(3);
     116                this->FreezeDof(1);
     117                this->FreezeDof(2);
     118                this->FreezeDof(3);
    121119        }
    122120        else if (iomodel->gridonstokes[i]==0){
     
    125123                }
    126124        }
    127         /*FROM DIAGNOSTICHUTTER*/
    128         if (!iomodel->gridonhutter[i]){
    129                 for(k=1;k<=numdofs;k++){
    130                         node->FreezeDof(k);
    131                 }
    132         }
    133 }
    134 /*}}}*/
    135 /*FUNCTION Node constructor from iomodel discontinuous Galerkin{{{2*/
    136 Node::Node(int i,int j,IoModel* iomodel){
    137         /* i -> index of the vertex in C indexing
    138          * j -> index of the node in C indexing*/
    139 
    140         int numdofs;
    141         int partitionborder;
    142         int vertex_id;
    143         int upper_node_id;
    144 
    145         /*id: */
    146         this->id=j+1; //matlab indexing
    147 
    148         /*indexing:*/
    149         DistributeNumDofs(&numdofs,iomodel->analysis_type,iomodel->sub_analysis_type); //number of dofs per node
    150         if(iomodel->my_bordervertices[i])partitionborder=1; else partitionborder=0;//is this node on a partition border?
    151 
    152         this->indexing.Init(numdofs,partitionborder);
    153 
    154         /*properties (come from vertex number i): */
    155         this->properties.Init(
    156                                 (int)iomodel->gridonbed[i],
    157                                 (int)iomodel->gridonsurface[i],
    158                                 (int)iomodel->gridoniceshelf[i],
    159                                 (int)iomodel->gridonicesheet[i]);
    160 
    161         /*hooks: */
    162         vertex_id=i+1; //matlab indexing
    163 
    164         if (strcmp(iomodel->meshtype,"3d")==0){
    165                 if (isnan(iomodel->uppernodes[i])){
    166                         upper_node_id=this->id; //nodes on surface do not have upper nodes, only themselves.
    167                 }
    168                 else{
    169                         upper_node_id=(int)iomodel->uppernodes[i];
    170                 }
    171         }
    172         else{
    173                 /*If we are running 2d, upper_node does not mean much. Just point towards itself!:*/
    174                 upper_node_id=this->id;
    175         }
    176 
    177         this->hvertex.Init(&vertex_id,1);
    178         this->hupper_node.Init(&upper_node_id,1);
    179 
    180125}
    181126/*}}}*/
  • TabularUnified issm/trunk/src/c/objects/Node.h

    r3427 r3430  
    4444                Node(int id,DofIndexing* indexing, NodeProperties* properties, Hook* vertex, Hook* upper_node);
    4545                Node(int i, IoModel* iomodel);
    46                 Node(int i,int j,IoModel* iomodel);
    4746                ~Node();
    4847                /*}}}*/
  • TabularUnified issm/trunk/src/c/objects/Penpair.cpp

    r3332 r3430  
    216216/*FUNCTION Penpair::PenaltyCreateKMatrix {{{1*/
    217217void  Penpair::PenaltyCreateKMatrix(Mat Kgg,void* inputs,double kmax,int analysis_type,int sub_analysis_type){
    218                
     218       
     219        /*If you code this piece, don't forget that a penalty will be inactive if it is dealing with clone nodes*/
    219220        /*No loads applied, do nothing: */
    220221        return;
  • TabularUnified issm/trunk/src/c/objects/Riftfront.cpp

    r3332 r3430  
    2020               
    2121/*Object constructors and destructor*/
    22 /*FUNCTION Riftfront::constructor {{{1*/
     22/*FUNCTION Riftfront::default constructor {{{1*/
    2323Riftfront::Riftfront(){
    2424        /*in case :*/
     
    2727}
    2828/*}}}1*/
    29 /*FUNCTION Riftfront::creation {{{1*/
     29/*FUNCTION Riftfront::constructor {{{1*/
    3030Riftfront::Riftfront(char riftfront_type[RIFTFRONTSTRING],int riftfront_id, int riftfront_node_ids[MAX_RIFTFRONT_GRIDS], int riftfront_mparid, double riftfront_h[MAX_RIFTFRONT_GRIDS],double riftfront_b[MAX_RIFTFRONT_GRIDS],double riftfront_s[MAX_RIFTFRONT_GRIDS],double riftfront_normal[2],double riftfront_length,int riftfront_fill,double riftfront_friction, double riftfront_fraction,double riftfront_fractionincrement, double riftfront_penalty_offset, int riftfront_penalty_lock, bool riftfront_active,bool riftfront_frozen, int riftfront_counter,bool riftfront_prestable,bool riftfront_shelf){
     31
     32        this->Init(riftfront_type,riftfront_id, riftfront_node_ids[MAX_RIFTFRONT_GRIDS], riftfront_mparid, riftfront_h[MAX_RIFTFRONT_GRIDS],riftfront_b[MAX_RIFTFRONT_GRIDS],riftfront_s[MAX_RIFTFRONT_GRIDS],riftfront_normal[2],riftfront_length,riftfront_fill,riftfront_friction, riftfront_fraction,riftfront_fractionincrement, riftfront_penalty_offset, riftfront_penalty_lock, griftfront_active,griftfront_frozen, riftfront_counter,riftfront_prestable,riftfront_shelf);
     33
     34}
     35/*}}}1*/
     36/*FUNCTION Riftfront::constructor from iomodel{{{1*/
     37Riftfront::Riftfront(int i, IoModel* iomodel){
     38
     39        /*rifts: */
     40        char riftfront_type[RIFTFRONTSTRING];
     41        int  riftfront_id;
     42        int  riftfront_node_ids[2];
     43        int  riftfront_mparid;
     44        double riftfront_h[2];
     45        double riftfront_b[2];
     46        double riftfront_s[2];
     47        double riftfront_normal[2];
     48        double riftfront_length;
     49        int    riftfront_fill;
     50        double riftfront_friction;
     51        double riftfront_fraction;
     52        double riftfront_fractionincrement;
     53        bool   riftfront_shelf;
     54        double riftfront_penalty_offset;
     55        int riftfront_penalty_lock;
     56        bool riftfront_active;
     57        bool riftfront_frozen;
     58        int  riftfront_counter;
     59        bool riftfront_prestable;
     60        int el1,el2;
     61        int grid1,grid2;
     62        double normal[2];
     63        double length;
     64        int    fill;
     65        double friction;
     66        double fraction;
     67        double fractionincrement;
     68
     69        /*Ok, retrieve all the data needed to add a penalty between the two grids: */
     70        el1=(int)*(iomodel->riftinfo+RIFTINFOSIZE*i+2);
     71        el2=(int)*(iomodel->riftinfo+RIFTINFOSIZE*i+3);
     72
     73        grid1=(int)*(iomodel->riftinfo+RIFTINFOSIZE*i+0);
     74        grid2=(int)*(iomodel->riftinfo+RIFTINFOSIZE*i+1);
     75
     76        normal[0]=*(iomodel->riftinfo+RIFTINFOSIZE*i+4);
     77        normal[1]=*(iomodel->riftinfo+RIFTINFOSIZE*i+5);
     78        length=*(iomodel->riftinfo+RIFTINFOSIZE*i+6);
     79
     80        fill = (int)*(iomodel->riftinfo+RIFTINFOSIZE*i+7);
     81        friction=*(iomodel->riftinfo+RIFTINFOSIZE*i+8);
     82        fraction=*(iomodel->riftinfo+RIFTINFOSIZE*i+9);
     83        fractionincrement=*(iomodel->riftinfo+RIFTINFOSIZE*i+10);
     84
     85        strcpy(riftfront_type,"2d");
     86        riftfront_id=i+1; //matlab indexing
     87        riftfront_node_ids[0]=grid1;
     88        riftfront_node_ids[1]=grid2;
     89        riftfront_mparid=iomodel->numberofelements+1; //matlab indexing
     90
     91        riftfront_h[0]=iomodel->thickness[grid1-1];
     92        riftfront_h[1]=iomodel->thickness[grid2-1];
     93
     94        riftfront_b[0]=iomodel->bed[grid1-1];
     95        riftfront_b[1]=iomodel->bed[grid2-1];
     96
     97        riftfront_s[0]=iomodel->surface[grid1-1];
     98        riftfront_s[1]=iomodel->surface[grid2-1];
     99
     100        riftfront_normal[0]=normal[0];
     101        riftfront_normal[1]=normal[1];
     102        riftfront_length=length;
     103
     104        riftfront_fill=fill;
     105        riftfront_friction=friction;
     106        riftfront_fraction=fraction;
     107        riftfront_fractionincrement=fractionincrement;
     108        riftfront_shelf=(bool)iomodel->gridoniceshelf[grid1-1];
     109
     110        riftfront_penalty_offset=iomodel->penalty_offset;
     111        riftfront_penalty_lock=iomodel->penalty_lock;
     112
     113        riftfront_active=0;
     114        riftfront_frozen=0;
     115        riftfront_counter=0;
     116        riftfront_prestable=0;
     117                       
     118        this->Init(riftfront_type,riftfront_id, riftfront_node_ids[MAX_RIFTFRONT_GRIDS], riftfront_mparid, riftfront_h[MAX_RIFTFRONT_GRIDS],riftfront_b[MAX_RIFTFRONT_GRIDS],riftfront_s[MAX_RIFTFRONT_GRIDS],riftfront_normal[2],riftfront_length,riftfront_fill,riftfront_friction, riftfront_fraction,riftfront_fractionincrement, riftfront_penalty_offset, riftfront_penalty_lock, griftfront_active,griftfront_frozen, riftfront_counter,riftfront_prestable,riftfront_shelf);
     119
     120}
     121/*}}}1*/
     122/*FUNCTION Riftfront::Init, used by constructor {{{1*/
     123void Riftfront::Init(char riftfront_type[RIFTFRONTSTRING],int riftfront_id, int riftfront_node_ids[MAX_RIFTFRONT_GRIDS], int riftfront_mparid, double riftfront_h[MAX_RIFTFRONT_GRIDS],double riftfront_b[MAX_RIFTFRONT_GRIDS],double riftfront_s[MAX_RIFTFRONT_GRIDS],double riftfront_normal[2],double riftfront_length,int riftfront_fill,double riftfront_friction, double riftfront_fraction,double riftfront_fractionincrement, double riftfront_penalty_offset, int riftfront_penalty_lock, bool riftfront_active,bool riftfront_frozen, int riftfront_counter,bool riftfront_prestable,bool riftfront_shelf){
    31124
    32125        int i;
  • TabularUnified issm/trunk/src/c/objects/Riftfront.h

    r3201 r3430  
    5858        public:
    5959
     60                /*constructors,destructors: {{{1*/
    6061                Riftfront();
     62                void Init(char type[RIFTFRONTSTRING],int id, int node_ids[MAX_RIFTFRONT_GRIDS], int mparid, double h[MAX_RIFTFRONT_GRIDS],double b[MAX_RIFTFRONT_GRIDS],double s[MAX_RIFTFRONT_GRIDS],double normal[2],double length,int fill,double friction, double fraction, double fractionincrement, double penalty_offset, int penalty_lock,bool active,bool frozen, int counter,bool prestable,bool shelf);
    6163                Riftfront(char type[RIFTFRONTSTRING],int id, int node_ids[MAX_RIFTFRONT_GRIDS], int mparid, double h[MAX_RIFTFRONT_GRIDS],double b[MAX_RIFTFRONT_GRIDS],double s[MAX_RIFTFRONT_GRIDS],double normal[2],double length,int fill,double friction, double fraction, double fractionincrement, double penalty_offset, int penalty_lock,bool active,bool frozen, int counter,bool prestable,bool shelf);
    6264                ~Riftfront();
    63 
     65                /*}}}*/
     66                /*object management: {{{1*/
    6467                void  Echo();
    6568                void  DeepEcho();
     
    7275                int   MyRank();
    7376                void  Configure(void* elements,void* nodes,void* materials);
     77                Object* copy();
     78                /*}}}*/
     79                /*numerics: {{{1*/
    7480                void  UpdateFromInputs(void* inputs);
    7581                void  GetDofList(int* doflist,int* pnumberofdofs);
     
    8995                int   IsMaterialStable(void* inputs, int analysis_type);
    9096                void  OutputProperties(Vec riftproperties);
    91                 Object* copy();
     97                /*}}}*/
    9298};
    9399
Note: See TracChangeset for help on using the changeset viewer.