Changeset 10356


Ignore:
Timestamp:
10/28/11 17:11:38 (14 years ago)
Author:
seroussi
Message:

minor

Location:
issm/trunk/src/c/modules/GroundinglineMigrationx
Files:
3 edited

Legend:

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

    r10355 r10356  
    1616        int      i, migration_style;
    1717        double*  vertices_potentially_ungrounding = NULL;
    18         double*  sheet_ungrounding                = NULL;
     18        double*  vertices_ungrounding             = NULL;
    1919        Element* element                          = NULL;
    2020       
     
    3131
    3232                /*propagate ice shelf into connex areas of the ice sheet that potentially want to unground: */
    33                 sheet_ungrounding=PropagateShelfIntoConnexIceSheet(elements,nodes,parameters,vertices_potentially_ungrounding);
     33                vertices_ungrounding=PropagateShelfIntoConnexIceSheet(elements,nodes,parameters,vertices_potentially_ungrounding);
    3434        }
    3535
     
    3737        for(i=0;i<elements->Size();i++){
    3838                element=(Element*)elements->GetObjectByOffset(i);
    39                 element->Migration(sheet_ungrounding);
     39                element->Migration(vertices_ungrounding);
    4040        }
    4141
     
    4848        /*free ressouces: */
    4949        xfree((void**)&vertices_potentially_ungrounding);
    50         xfree((void**)&sheet_ungrounding);
     50        xfree((void**)&vertices_ungrounding);
    5151}
  • issm/trunk/src/c/modules/GroundinglineMigrationx/GroundinglineMigrationxLocal.h

    r10354 r10356  
    1717double*    CreateElementOnIceShelf(Elements* elements);
    1818double*    CreateElementTouchingIceShelf(Elements* elements,Vec vec_nodes_on_iceshelf);
     19Vec        CreateNodesOnIceShelf(Nodes* nodes,int analysis_type);
     20
    1921int        UpdateShelfStatus(Elements* elements,Nodes* nodes,Parameters* parameters,double* element_touching_iceshelf);
    20 Vec        CreateNodesOnIceShelf(Nodes* nodes,int analysis_type);
    2122#endif  /* _GROUNDINGLINEMIGRATIONXLOCAL_H */
  • issm/trunk/src/c/modules/GroundinglineMigrationx/GroundinglineMigrationxUtils.cpp

    r10355 r10356  
    1111#include "../../EnumDefinitions/EnumDefinitions.h"
    1212
    13 /*FUNCTION PotentialSheetUngrounding {{{1*/
    14 double*    PotentialSheetUngrounding(Elements* elements,Vertices* vertices,Parameters* parameters){
    15 
    16         int      i,numberofvertices;
    17         double*  vertices_potentially_ungrounding      = NULL;
    18         Vec      vec_vertices_potentially_ungrounding  = NULL;
    19         Element* element                               = NULL;
    20 
    21         /*Initialize vector with number of vertices*/
    22         numberofvertices=vertices->NumberOfVertices();
    23         vec_vertices_potentially_ungrounding=NewVec(numberofvertices); //grounded vertex that could start floating
    24 
    25         /*Fill vector vertices_potentially_floating: */
    26         for(i=0;i<elements->Size();i++){
    27                 element=(Element*)elements->GetObjectByOffset(i);
    28                 element->PotentialSheetUngrounding(vec_vertices_potentially_ungrounding);
    29         }
    30 
    31         /*Assemble vector: */
    32         VecAssemblyBegin(vec_vertices_potentially_ungrounding);
    33         VecAssemblyEnd(vec_vertices_potentially_ungrounding);
    34 
    35         /*Serialize vector: */
    36         VecToMPISerial(&vertices_potentially_ungrounding,vec_vertices_potentially_ungrounding);
    37 
    38         /*free ressouces and return: */
    39         VecFree(&vec_vertices_potentially_ungrounding);
    40         return vertices_potentially_ungrounding;
    41 }
    42 /*}}}*/
    43 /*FUNCTION PropagateShelfIntoConnexIceSheet {{{1*/
    44 double*    PropagateShelfIntoConnexIceSheet(Elements* elements,Nodes* nodes,Parameters* parameters,double* potential_sheet_ungrounding){
    45 
    46         int      i;
    47         Element* element=NULL;
    48         int      numnods;
    49         int      analysis_type;
    50         Vec      vec_nodes_on_iceshelf=NULL;
    51         double*  nodes_on_iceshelf=NULL;
    52         int      nflipped,local_nflipped;
    53         double*  elements_touching_iceshelf=NULL;
    54 
    55         /*recover parameters: */
    56         parameters->FindParam(&analysis_type,AnalysisTypeEnum);
    57 
    58         /*recover vec_nodes_on_iceshelf: */
    59         vec_nodes_on_iceshelf=CreateNodesOnIceShelf(nodes,analysis_type);
    60 
    61         nflipped=1; //bootstrap
    62         while(nflipped){
    63                
    64                 /*get a list of potential elements that have nodes on ice shelf: */
    65                 elements_touching_iceshelf=CreateElementTouchingIceShelf(elements,vec_nodes_on_iceshelf);
    66 
    67                 /*now,  go through elements_touching_iceshelf, and if they have nodes inside potential_sheet_ungrounding,
    68                  * flag it: */
    69                 local_nflipped=0;
    70 
    71                 /*serialize vec_nodes_on_iceshelf, needed by element's UpdatePotentialSheetUngrounding routine, to figure out if
    72                  * nodes have flipped from grounded to ungrounded: */
    73                 VecToMPISerial(&nodes_on_iceshelf,vec_nodes_on_iceshelf);
    74 
    75                 for(i=0;i<elements->Size();i++){
    76                         element=(Element*)elements->GetObjectByOffset(i);
    77                         if(elements_touching_iceshelf[element->Sid()]){
    78                                 local_nflipped+=element->UpdatePotentialSheetUngrounding(potential_sheet_ungrounding,vec_nodes_on_iceshelf,nodes_on_iceshelf);
    79                         }
    80                 }
    81                
    82                 MPI_Allreduce(&local_nflipped,&nflipped,1,MPI_INT,MPI_SUM,MPI_COMM_WORLD);
    83                 _printf_(VerboseConvergence(),"   number of grounded vertices  connected to grounding line: %i\n",nflipped);
    84 
    85                 /*Avoid leaks: */
    86                 xfree((void**)&nodes_on_iceshelf);
    87                 xfree((void**)&elements_touching_iceshelf);
    88 
    89                 /*Assemble:*/
    90                 VecAssemblyBegin(vec_nodes_on_iceshelf);
    91                 VecAssemblyEnd(vec_nodes_on_iceshelf);
    92         }
    93 
    94         /*Serialize: */
    95         VecToMPISerial(&nodes_on_iceshelf,vec_nodes_on_iceshelf);
    96 
    97         /*Free ressources:*/
    98         VecFree(&vec_nodes_on_iceshelf);
    99         xfree((void**)&elements_touching_iceshelf);
    100 
    101         return nodes_on_iceshelf;
    102 }
    103 /*}}}*/
    10413/*FUNCTION CreateElementOnGroundingline {{{1*/
    10514bool*      CreateElementOnGroundingline(Elements* elements,double* element_on_iceshelf){
    10615
    107         int      i,j;
    108         Element *element       = NULL;
    10916        bool    *element_on_gl = NULL;
    11017        bool     ongl=false;
     18        int      i,j,sid,shelf;
    11119        int     *neighboorsids = NULL;
    112         int      sid;
    113         int      shelf;
     20        Element *element       = NULL;
    11421
    11522        /*Go through elements, and look for elements that can possibly have a grounding line migration. These
     
    14047double*    CreateElementOnIceShelf(Elements* elements){
    14148
    142         int i;
    143         Element* element=NULL;
    144         Vec vec_element_on_iceshelf=NULL;
    145         double* element_on_iceshelf=NULL;
     49        int      i;
     50        double  *element_on_iceshelf     = NULL;
     51        Element *element                 = NULL;
     52        Vec      vec_element_on_iceshelf = NULL;
    14653
    14754        /*Create  vector holding  all the elements IsFloating flags: */
     
    17077double*    CreateElementTouchingIceShelf(Elements* elements,Vec vec_nodes_on_iceshelf){
    17178
    172         int i;
    173         Element* element=NULL;
    174         Vec vec_element_touching_iceshelf=NULL;
    175         double* nodes_on_iceshelf=NULL;
    176        
    177         /*output: */
    178         double* element_touching_iceshelf=NULL;
     79        int      i;
     80        double  *nodes_on_iceshelf             = NULL;
     81        double  *element_touching_iceshelf     = NULL;
     82        Element *element                       = NULL;
     83        Vec      vec_element_touching_iceshelf = NULL;
    17984
    18085        /*serialize: */
     
    204109}
    205110/*}}}*/
    206 /*FUNCTION UpdateShelfStatus {{{1*/
    207 int        UpdateShelfStatus(Elements* elements,Nodes* nodes,Parameters* parameters,double* element_touching_iceshelf){
    208 
    209         int i;
    210         Element* element=NULL;
    211         int configuration_type;
    212         int numnods;
    213         Vec vec_new_shelf_nodes=NULL;
    214         double* new_shelf_nodes=NULL;
    215 
    216         /*output: */
    217         int local_nflipped=0;
    218         int nflipped=0;
    219 
    220         /*recover parameters: */
    221         parameters->FindParam(&configuration_type,ConfigurationTypeEnum);
    222 
    223         /*First, initialize vec_new_shelf_nodes, which will track which nodes have changed status: */
    224         numnods=nodes->NumberOfNodes(configuration_type);
    225         vec_new_shelf_nodes=NewVec(numnods);
    226 
    227         /*Ok, now go through  the elements that have gone through grounding line migration,
    228          * and update their flags: */
    229         for(i=0;i<elements->Size();i++){
    230                 element=(Element*)elements->GetObjectByOffset(i);
    231                 if(element_touching_iceshelf[element->Sid()]){
    232                         local_nflipped+=element->UpdateShelfStatus(vec_new_shelf_nodes);
    233                 }
    234         }
    235         MPI_Allreduce(&local_nflipped,&nflipped,1,MPI_INT,MPI_SUM,MPI_COMM_WORLD);
    236 
    237         /*Serialize vec_new_shelf_nodes: */
    238         VecToMPISerial(&new_shelf_nodes,vec_new_shelf_nodes);
    239 
    240         /*Now, go through ALL elements, and update the status of the nodes, to propagate what happened at the grounding line: */
    241         /*Carry out grounding line migration for those elements: */
    242         for(i=0;i<elements->Size();i++){
    243                 element=(Element*)elements->GetObjectByOffset(i);
    244                 element->UpdateShelfFlags(new_shelf_nodes);
    245         }
    246 
    247         /*Free ressources: */
    248         VecFree(&vec_new_shelf_nodes);
    249         xfree((void**)&new_shelf_nodes);
    250 
    251         return nflipped;
    252 }
    253 /*}}}*/
    254111/*FUNCTION CreateNodesOnIceShelf {{{1*/
    255112Vec CreateNodesOnIceShelf(Nodes* nodes,int configuration_type){
    256113
    257         /*output: */
    258         Vec     nodes_on_iceshelf=NULL;
    259 
    260         /*intermediary: */
    261         int     numnods;
    262         int     i;
    263         Node*   node=NULL;
     114        int     i,numnods;
     115        Vec     nodes_on_iceshelf = NULL;
     116        Node*   node              = NULL;
    264117
    265118        /*First, initialize nodes_on_iceshelf, which will track which nodes have changed status: */
     
    284137}
    285138/*}}}*/
     139/*FUNCTION PotentialSheetUngrounding {{{1*/
     140double*    PotentialSheetUngrounding(Elements* elements,Vertices* vertices,Parameters* parameters){
     141
     142        int      i,numberofvertices;
     143        double*  vertices_potentially_ungrounding      = NULL;
     144        Vec      vec_vertices_potentially_ungrounding  = NULL;
     145        Element* element                               = NULL;
     146
     147        /*Initialize vector with number of vertices*/
     148        numberofvertices=vertices->NumberOfVertices();
     149        vec_vertices_potentially_ungrounding=NewVec(numberofvertices); //grounded vertex that could start floating
     150
     151        /*Fill vector vertices_potentially_floating: */
     152        for(i=0;i<elements->Size();i++){
     153                element=(Element*)elements->GetObjectByOffset(i);
     154                element->PotentialSheetUngrounding(vec_vertices_potentially_ungrounding);
     155        }
     156
     157        /*Assemble vector: */
     158        VecAssemblyBegin(vec_vertices_potentially_ungrounding);
     159        VecAssemblyEnd(vec_vertices_potentially_ungrounding);
     160
     161        /*Serialize vector: */
     162        VecToMPISerial(&vertices_potentially_ungrounding,vec_vertices_potentially_ungrounding);
     163
     164        /*free ressouces and return: */
     165        VecFree(&vec_vertices_potentially_ungrounding);
     166        return vertices_potentially_ungrounding;
     167}
     168/*}}}*/
     169/*FUNCTION PropagateShelfIntoConnexIceSheet {{{1*/
     170double*    PropagateShelfIntoConnexIceSheet(Elements* elements,Nodes* nodes,Parameters* parameters,double* vertices_potentially_ungrounding){
     171
     172        int      i,numnods,analysis_type;
     173        int      nflipped,local_nflipped;
     174        double*  nodes_on_iceshelf          = NULL;
     175        double*  elements_touching_iceshelf = NULL;
     176        Vec      vec_nodes_on_iceshelf      = NULL;
     177        Element* element                    = NULL;
     178
     179        /*recover parameters: */
     180        parameters->FindParam(&analysis_type,AnalysisTypeEnum);
     181
     182        /*recover vec_nodes_on_iceshelf: */
     183        vec_nodes_on_iceshelf=CreateNodesOnIceShelf(nodes,analysis_type);
     184
     185        nflipped=1; //bootstrap
     186        while(nflipped){
     187               
     188                /*get a list of potential elements that have nodes on ice shelf: */
     189                elements_touching_iceshelf=CreateElementTouchingIceShelf(elements,vec_nodes_on_iceshelf);
     190
     191                /*now,  go through elements_touching_iceshelf, and if they have nodes inside potential_sheet_ungrounding,
     192                 * flag it: */
     193                local_nflipped=0;
     194
     195                /*serialize vec_nodes_on_iceshelf, needed by element's UpdatePotentialSheetUngrounding routine, to figure out if
     196                 * nodes have flipped from grounded to ungrounded: */
     197                VecToMPISerial(&nodes_on_iceshelf,vec_nodes_on_iceshelf);
     198
     199                for(i=0;i<elements->Size();i++){
     200                        element=(Element*)elements->GetObjectByOffset(i);
     201                        if(elements_touching_iceshelf[element->Sid()]){
     202                                local_nflipped+=element->UpdatePotentialSheetUngrounding(potential_sheet_ungrounding,vec_nodes_on_iceshelf,nodes_on_iceshelf);
     203                        }
     204                }
     205               
     206                MPI_Allreduce(&local_nflipped,&nflipped,1,MPI_INT,MPI_SUM,MPI_COMM_WORLD);
     207                _printf_(VerboseConvergence(),"   number of grounded vertices  connected to grounding line: %i\n",nflipped);
     208
     209                /*Avoid leaks: */
     210                xfree((void**)&nodes_on_iceshelf);
     211                xfree((void**)&elements_touching_iceshelf);
     212
     213                /*Assemble:*/
     214                VecAssemblyBegin(vec_nodes_on_iceshelf);
     215                VecAssemblyEnd(vec_nodes_on_iceshelf);
     216        }
     217
     218        /*Serialize: */
     219        VecToMPISerial(&nodes_on_iceshelf,vec_nodes_on_iceshelf);
     220
     221        /*Free ressources:*/
     222        VecFree(&vec_nodes_on_iceshelf);
     223        xfree((void**)&elements_touching_iceshelf);
     224
     225        return nodes_on_iceshelf;
     226}
     227/*}}}*/
     228
     229/*FUNCTION UpdateShelfStatus {{{1*/
     230int UpdateShelfStatus(Elements* elements,Nodes* nodes,Parameters* parameters,double* element_touching_iceshelf){
     231
     232        int      i,numnods,configuration_type;
     233        int      nflipped=0;
     234        int      local_nflipped=0;
     235        Vec      vec_new_shelf_nodes = NULL;
     236        double*  new_shelf_nodes     = NULL;
     237        Element* element             = NULL;
     238
     239        /*recover parameters: */
     240        parameters->FindParam(&configuration_type,ConfigurationTypeEnum);
     241
     242        /*First, initialize vec_new_shelf_nodes, which will track which nodes have changed status: */
     243        numnods=nodes->NumberOfNodes(configuration_type);
     244        vec_new_shelf_nodes=NewVec(numnods);
     245
     246        /*Ok, now go through  the elements that have gone through grounding line migration,
     247         * and update their flags: */
     248        for(i=0;i<elements->Size();i++){
     249                element=(Element*)elements->GetObjectByOffset(i);
     250                if(element_touching_iceshelf[element->Sid()]){
     251                        local_nflipped+=element->UpdateShelfStatus(vec_new_shelf_nodes);
     252                }
     253        }
     254        MPI_Allreduce(&local_nflipped,&nflipped,1,MPI_INT,MPI_SUM,MPI_COMM_WORLD);
     255
     256        /*Serialize vec_new_shelf_nodes: */
     257        VecToMPISerial(&new_shelf_nodes,vec_new_shelf_nodes);
     258
     259        /*Now, go through ALL elements, and update the status of the nodes, to propagate what happened at the grounding line: */
     260        /*Carry out grounding line migration for those elements: */
     261        for(i=0;i<elements->Size();i++){
     262                element=(Element*)elements->GetObjectByOffset(i);
     263                element->UpdateShelfFlags(new_shelf_nodes);
     264        }
     265
     266        /*Free ressources: */
     267        VecFree(&vec_new_shelf_nodes);
     268        xfree((void**)&new_shelf_nodes);
     269
     270        return nflipped;
     271}
     272/*}}}*/
Note: See TracChangeset for help on using the changeset viewer.