Changeset 3646


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

updated numerical flux creation (use iomodel constructor instead)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk/src/c/ModelProcessorx/Prognostic2/CreateLoadsPrognostic2.cpp

    r3633 r3646  
    1414
    1515        /*Intermediary*/
    16         int i,j;
    17         int i1,i2;
    18         int pos1,pos2;
    19         double e1,e2;
     16        int i;
     17        int element;
    2018
    2119        /*Output*/
    2220        DataSet* loads=NULL;
    23 
    24         /*numericalflux intermediary data: */
    25         char numericalflux_type[NUMERICALFLUXSTRING];
    26         int  numericalflux_id;
    27         int  numericalflux_node_ids[MAX_NUMERICALFLUX_NODES];
    28         int  numericalflux_elem_id;
    29         double numericalflux_h[MAX_NUMERICALFLUX_NODES];
    3021
    3122        /*Create loads: */
     
    4132
    4233                /*Get left and right elements*/
    43                 e1=iomodel->edges[4*i+2]-1; //edges are [node1 node2 elem1 elem2]
    44                 e2=iomodel->edges[4*i+3]-1; //edges are [node1 node2 elem1 elem2]
     34                element=(int)iomodel->edges[4*i+2]-1; //edges are [node1 node2 elem1 elem2]
    4535
    4636                /*Now, if this element is not in the partition, pass: */
    47                 if(!iomodel->my_elements[(int)e1]) continue;
     37                if(!iomodel->my_elements[element]) continue;
    4838
    49                 /*Create load*/
    50                 numericalflux_id=i+1; //Matlab indexing
    51                 numericalflux_elem_id=(int)e1+1;//id is in matlab index
    52 
    53                 /*1: Get vertices ids*/
    54                 i1=(int)iomodel->edges[4*i+0];
    55                 i2=(int)iomodel->edges[4*i+1];
    56 
    57                 if (!isnan(e2)){
    58                         strcpy(numericalflux_type,"internal");
    59 
    60                         /*Now, we must get the nodes of the 4 nodes located on the edge*/
    61 
    62                         /*2: Get the column where these ids are located in the index*/
    63                         pos1=pos2=UNDEF;
    64                         for(j=0;j<3;j++){
    65                                 if (iomodel->elements[3*(int)e1+j]==i1) pos1=j+1;
    66                                 if (iomodel->elements[3*(int)e2+j]==i1) pos2=j+1;
    67                         }
    68                         ISSMASSERT(pos1!=UNDEF && pos2!=UNDEF);
    69 
    70                         /*3: We have the id of the elements and the position of the vertices in the index
    71                          * we can compute their dofs!*/
    72                         numericalflux_node_ids[0]=3*(int)e1+pos1;       //ex: 1 2 3
    73                         numericalflux_node_ids[1]=3*(int)e1+(pos1%3)+1; //ex: 2 3 1
    74                         numericalflux_node_ids[2]=3*(int)e2+pos2;           //ex: 1 2 3
    75                         numericalflux_node_ids[3]=3*(int)e2+((pos2+1)%3)+1; //ex: 3 1 2
    76 
    77                         numericalflux_h[0]=iomodel->thickness[(int)iomodel->elements[numericalflux_node_ids[0]-1] -1];
    78                         numericalflux_h[1]=iomodel->thickness[(int)iomodel->elements[numericalflux_node_ids[1]-1]-1];
    79                         numericalflux_h[2]=iomodel->thickness[(int)iomodel->elements[numericalflux_node_ids[2]-1]-1];
    80                         numericalflux_h[3]=iomodel->thickness[(int)iomodel->elements[numericalflux_node_ids[3]-1]-1];
    81                 }
    82                 else{
    83                         strcpy(numericalflux_type,"boundary");
    84 
    85                         /*2: Get the column where these ids are located in the index*/
    86                         pos1==UNDEF;
    87                         for(j=0;j<3;j++){
    88                                 if (iomodel->elements[3*(int)e1+j]==i1) pos1=j+1;
    89                         }
    90                         ISSMASSERT(pos1!=UNDEF);
    91 
    92                         /*3: We have the id of the elements and the position of the vertices in the index
    93                          * we can compute their dofs!*/
    94                         numericalflux_node_ids[0]=3*(int)e1+pos1;
    95                         numericalflux_node_ids[1]=3*(int)e1+(pos1%3)+1;
    96 
    97                         numericalflux_h[0]=iomodel->thickness[(int)iomodel->elements[numericalflux_node_ids[0]-1]-1];
    98                         numericalflux_h[1]=iomodel->thickness[(int)iomodel->elements[numericalflux_node_ids[1]-1]-1];
    99                         numericalflux_h[2]=UNDEF;
    100                         numericalflux_h[3]=UNDEF;
    101                 }
    102 
    103                 loads->AddObject(new Numericalflux(numericalflux_id,numericalflux_type,numericalflux_node_ids,numericalflux_elem_id,numericalflux_h));
     39                /* Add load */
     40                loads->AddObject(new Numericalflux(i+1,i,iomodel));
    10441        }
    10542
Note: See TracChangeset for help on using the changeset viewer.