Ignore:
Timestamp:
08/27/13 08:35:37 (12 years ago)
Author:
seroussi
Message:

CHG: trying to finish Grounding line changes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/c/modules/GroundinglineMigrationx/GroundinglineMigrationx.cpp

    r15962 r15967  
    5151}
    5252
    53 /*FUNCTION CreateNodesOnFloatingIce {{{*/
    54 Vector<IssmDouble>* CreateNodesOnFloatingIce(Nodes* nodes,int configuration_type){
    55 
    56         int     i,numnods;
    57         Vector<IssmDouble>*   vec_nodes_on_floatingice = NULL;
    58         Node *node                     = NULL;
    59 
    60         /*First, initialize nodes_on_floatingice, which will track which nodes have changed status: */
    61         numnods=nodes->NumberOfNodes(configuration_type);
    62         vec_nodes_on_floatingice=new Vector<IssmDouble>(numnods);
    63 
    64         /*Loop through nodes, and fill vec_nodes_on_floatingice: */
    65         for(i=0;i<nodes->Size();i++){
    66                 node=(Node*)nodes->GetObjectByOffset(i);
    67                 if(node->InAnalysis(configuration_type)){
    68                         if(node->IsFloating()){
    69                                 vec_nodes_on_floatingice->SetValue(node->Sid(),1.0,INS_VAL);
    70                         }
    71                 }
    72         }
    73 
    74         /*Assemble vector: */
    75         vec_nodes_on_floatingice->Assemble();
    76 
    77         return vec_nodes_on_floatingice;
    78 }
    79 /*%}}}*/
    8053/*FUNCTION PotentialUngrounding {{{*/
    8154IssmDouble*    PotentialUngrounding(Elements* elements,Vertices* vertices,Parameters* parameters){
     
    11184        int      numberofvertices;
    11285        int      nflipped,local_nflipped;
    113         IssmDouble*  nodes_on_floatingice                  = NULL;
     86        IssmDouble*  phi                  = NULL;
    11487        IssmDouble*  elements_neighboring_floatingce      = NULL;
    11588        Vector<IssmDouble>*      vec_elements_neighboring_floatingice = NULL;
    116         Vector<IssmDouble>*      vec_nodes_on_floatingice              = NULL;
     89        Vector<IssmDouble>*      vec_phi              = NULL;
    11790        Node*    node                                  = NULL;
    11891        Element* element                               = NULL;
     
    12295        numberofvertices=vertices->NumberOfVertices();
    12396
    124         /*recover vec_nodes_on_floatingice*/
    125         vec_nodes_on_floatingice=CreateNodesOnFloatingIce(nodes,analysis_type);
    126         nodes_on_floatingice=vec_nodes_on_floatingice->ToMPISerial();
     97        /*recover vec_phi*/
     98        vec_phi=new Vector<IssmDouble>(vertices->NumberOfVertices());
     99        for(i=0;i<elements->Size();i++){
     100                Element* element=dynamic_cast<Element*>(elements->GetObjectByOffset(i));
     101                element->GetVectorFromInputs(vec_phi,MaskGroundediceLevelsetEnum);
     102        }
     103        phi=vec_phi->ToMPISerial();
    127104
    128105        nflipped=1; //bootstrap
     
    135112                for(i=0;i<elements->Size();i++){
    136113                        element=dynamic_cast<Element*>(elements->GetObjectByOffset(i));
    137                         vec_elements_neighboring_floatingice->SetValue(element->Sid(),element->IsNodeOnShelfFromFlags(nodes_on_floatingice)?1.0:0.0,INS_VAL);
     114                        vec_elements_neighboring_floatingice->SetValue(element->Sid(),element->IsNodeOnShelfFromFlags(phi)?1.0:0.0,INS_VAL);
    138115                }
    139116
     
    147124                        element=dynamic_cast<Element*>(elements->GetObjectByOffset(i));
    148125                        if(reCast<int,IssmDouble>(elements_neighboring_floatingce[element->Sid()])){
    149                                 local_nflipped+=element->UpdatePotentialUngrounding(vertices_potentially_ungrounding,vec_nodes_on_floatingice,nodes_on_floatingice);
     126                                local_nflipped+=element->UpdatePotentialUngrounding(vertices_potentially_ungrounding,vec_phi,phi);
    150127                        }
    151128                }
    152                 vec_nodes_on_floatingice->Assemble();
     129                vec_phi->Assemble();
    153130
    154131                ISSM_MPI_Allreduce(&local_nflipped,&nflipped,1,ISSM_MPI_INT,ISSM_MPI_SUM,IssmComm::GetComm());
     
    157134                /*Avoid leaks: */
    158135                xDelete<IssmDouble>(elements_neighboring_floatingce);
    159                 xDelete<IssmDouble>(nodes_on_floatingice);
     136                xDelete<IssmDouble>(phi);
    160137
    161138                /*Assemble and serialize:*/
    162139                delete vec_elements_neighboring_floatingice;
    163                 nodes_on_floatingice=vec_nodes_on_floatingice->ToMPISerial();
     140                phi=vec_phi->ToMPISerial();
    164141        }
    165142
    166143        /*Free ressources:*/
    167         delete vec_nodes_on_floatingice;
     144        delete vec_phi;
    168145        xDelete<IssmDouble>(elements_neighboring_floatingce);
    169146
    170         return nodes_on_floatingice;
     147        return phi;
    171148}
    172149/*}}}*/
Note: See TracChangeset for help on using the changeset viewer.