Changeset 3645


Ignore:
Timestamp:
04/30/10 12:30:18 (15 years ago)
Author:
Mathieu Morlighem
Message:

Adde constructor from iomodel

File:
1 edited

Legend:

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

    r3642 r3645  
    5353        /*point parameters: */
    5454        this->parameters=numericalflux_parameters;
     55}
     56/*}}}*/
     57/*FUNCTION Numericalflux::Numericalflux(int id, int i, IoModel* iomodel) {{{1*/
     58Numericalflux::Numericalflux(int numericalflux_id,int i, IoModel* iomodel){
     59
     60        /* Intermediary */
     61        int  e1,e2;
     62        int  i1,i2;
     63        int  pos1,pos2;
     64        int  num_nodes;
     65        int  num_elems;
     66
     67        /*numericalflux constructor data: */
     68        int   numericalflux_elem_ids[2];
     69        int   numericalflux_mparid;
     70        int   numericalflux_node_ids[4];
     71        int   numericalflux_type;
     72
     73        /* Get MatPar id */
     74        numericalflux_mparid=iomodel->numberofelements+1; //matlab indexing
     75
     76        /*Get left and right elements*/
     77        e1=(double)iomodel->edges[4*i+2]; //edges are [node1 node2 elem1 elem2]
     78        e2=(double)iomodel->edges[4*i+3]; //edges are [node1 node2 elem1 elem2]
     79        if (isnan(e2)){
     80                /* Boundary edge, only one element */
     81                num_elems=1;
     82                num_nodes=2;
     83                numericalflux_type=BoundaryEnum;
     84                numericalflux_elem_ids[0]=(int)e1;
     85        }
     86        else{
     87                /* internal edge: connected to 2 elements */
     88                num_elems=2;
     89                num_nodes=4;
     90                numericalflux_type=InternalEnum;
     91                numericalflux_elem_ids[0]=(int)e1;
     92                numericalflux_elem_ids[1]=(int)e2;
     93        }
     94
     95        /*1: Get vertices ids*/
     96        i1=(int)iomodel->edges[4*i+0];
     97        i2=(int)iomodel->edges[4*i+1];
     98
     99        if (numericalflux_type==InternalEnum){
     100
     101                /*Now, we must get the nodes of the 4 nodes located on the edge*/
     102
     103                /*2: Get the column where these ids are located in the index*/
     104                pos1=pos2=UNDEF;
     105                for(j=0;j<3;j++){
     106                        if (iomodel->elements[3*(int)e1+j]==i1) pos1=j+1;
     107                        if (iomodel->elements[3*(int)e2+j]==i1) pos2=j+1;
     108                }
     109                ISSMASSERT(pos1!=UNDEF && pos2!=UNDEF);
     110
     111                /*3: We have the id of the elements and the position of the vertices in the index
     112                 * we can compute their dofs!*/
     113                numericalflux_node_ids[0]=3*(int)e1+pos1;       //ex: 1 2 3
     114                numericalflux_node_ids[1]=3*(int)e1+(pos1%3)+1; //ex: 2 3 1
     115                numericalflux_node_ids[2]=3*(int)e2+pos2;           //ex: 1 2 3
     116                numericalflux_node_ids[3]=3*(int)e2+((pos2+1)%3)+1; //ex: 3 1 2
     117        }
     118        else{
     119
     120                /*2: Get the column where these ids are located in the index*/
     121                pos1==UNDEF;
     122                for(j=0;j<3;j++){
     123                        if (iomodel->elements[3*(int)e1+j]==i1) pos1=j+1;
     124                }
     125                ISSMASSERT(pos1!=UNDEF);
     126
     127                /*3: We have the id of the elements and the position of the vertices in the index
     128                 * we can compute their dofs!*/
     129                numericalflux_node_ids[0]=3*(int)e1+pos1;
     130                numericalflux_node_ids[1]=3*(int)e1+(pos1%3)+1;
     131
     132        }
     133
     134        /*Ok, we have everything to build the object: */
     135        this->id=numericalflux_id;
     136
     137        /*Hooks: */
     138        this->hnodes.Init(numericalflux_node_ids,num_nodes);
     139        this->helements.Init(&numericalflux_elem_ids,num_elems);
     140        this->hmatpar.Init(&numericalflux_mparid,1);
     141
     142        //intialize  and add as many inputs per element as requested:
     143        this->inputs=new Inputs();
     144        this->inputs->AddInput(new IntInput(TypeEnum,numericalflux_type));
     145
     146        //this->parameters: we still can't point to it, it may not even exist. Configure will handle this.
     147        this->parameters=NULL;
    55148}
    56149/*}}}*/
Note: See TracChangeset for help on using the changeset viewer.