Changeset 10369


Ignore:
Timestamp:
10/31/11 11:09:18 (13 years ago)
Author:
seroussi
Message:

organizing Grounding line migration

Location:
issm/trunk/src/c/modules/GroundinglineMigrationx
Files:
2 deleted
2 edited

Legend:

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

    r10364 r10369  
    33 */
    44
    5 #include "./GroundinglineMigrationx.h"
    6 #include "./GroundinglineMigrationxLocal.h"
    75#include "../../shared/shared.h"
    86#include "../../io/io.h"
     
    119#include "../../EnumDefinitions/EnumDefinitions.h"
    1210#include "../../Container/Container.h"
     11#include "./GroundinglineMigrationx.h"
    1312
    1413void GroundinglineMigrationx(Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads,Materials* materials, Parameters* parameters){
     
    5049        xfree((void**)&vertices_ungrounding);
    5150}
     51/*FUNCTION PotentialSheetUngrounding {{{1*/
     52double*    PotentialSheetUngrounding(Elements* elements,Vertices* vertices,Parameters* parameters){
     53
     54        int      i,numberofvertices;
     55        double*  vertices_potentially_ungrounding      = NULL;
     56        Vec      vec_vertices_potentially_ungrounding  = NULL;
     57        Element* element                               = NULL;
     58
     59        /*Initialize vector with number of vertices*/
     60        numberofvertices=vertices->NumberOfVertices();
     61        vec_vertices_potentially_ungrounding=NewVec(numberofvertices); //grounded vertex that could start floating
     62
     63        /*Fill vector vertices_potentially_floating: */
     64        for(i=0;i<elements->Size();i++){
     65                element=(Element*)elements->GetObjectByOffset(i);
     66                element->PotentialSheetUngrounding(vec_vertices_potentially_ungrounding);
     67        }
     68
     69        /*Assemble vector: */
     70        VecAssemblyBegin(vec_vertices_potentially_ungrounding);
     71        VecAssemblyEnd(vec_vertices_potentially_ungrounding);
     72
     73        /*Serialize vector: */
     74        VecToMPISerial(&vertices_potentially_ungrounding,vec_vertices_potentially_ungrounding);
     75
     76        /*free ressouces and return: */
     77        VecFree(&vec_vertices_potentially_ungrounding);
     78        return vertices_potentially_ungrounding;
     79}
     80/*}}}*/
     81/*FUNCTION PropagateShelfIntoConnexIceSheet {{{1*/
     82double*    PropagateShelfIntoConnexIceSheet(Elements* elements,Nodes* nodes,Vertices* vertices,Parameters* parameters,double* vertices_potentially_ungrounding){
     83
     84        int      i,analysis_type;
     85        int      numberofvertices;
     86        int      nflipped,local_nflipped;
     87        double*  nodes_on_iceshelf             = NULL;
     88        double*  elements_touching_iceshelf    = NULL;
     89        Vec      vec_element_touching_iceshelf = NULL;
     90        Vec      vec_nodes_on_iceshelf         = NULL;
     91        Node*    node                          = NULL;
     92        Element* element                       = NULL;
     93
     94
     95        /*recover parameters: */
     96        parameters->FindParam(&analysis_type,AnalysisTypeEnum);
     97        numberofvertices=vertices->NumberOfVertices();
     98
     99        /*recover vec_nodes_on_iceshelf*/
     100        vec_nodes_on_iceshelf=NewVec(numberofvertices);
     101
     102        /*Loop through nodes, and fill nodes_on_iceshelf: */
     103        for(i=0;i<nodes->Size();i++){
     104                node=(Node*)nodes->GetObjectByOffset(i);
     105                if(node->InAnalysis(analysis_type)){
     106                        if(node->IsFloating()){
     107                                VecSetValue(vec_nodes_on_iceshelf,node->Sid(),1.0,INSERT_VALUES);
     108                        }
     109                }
     110        }
     111
     112        /*Assemble vector and serialize: */
     113        VecAssemblyBegin(vec_nodes_on_iceshelf);
     114        VecAssemblyEnd(vec_nodes_on_iceshelf);
     115        VecToMPISerial(&nodes_on_iceshelf,vec_nodes_on_iceshelf);
     116
     117        nflipped=1; //bootstrap
     118        while(nflipped){
     119               
     120                /*Vector of size number of elements*/
     121                vec_element_touching_iceshelf=NewVec(elements->NumberOfElements(),true);
     122
     123                /*Figure out if any of the nodes of the element will be floating -> elements neighbouting the floating ice*/
     124                for(i=0;i<elements->Size();i++){
     125                        element=(Element*)elements->GetObjectByOffset(i);
     126                        VecSetValue(vec_element_touching_iceshelf,element->Sid(),element->IsNodeOnShelfFromFlags(nodes_on_iceshelf)?1.0:0.0,INSERT_VALUES);
     127                }
     128
     129                /*Assemble vector and serialize: */
     130                VecAssemblyBegin(vec_element_touching_iceshelf);
     131                VecAssemblyEnd(vec_element_touching_iceshelf);
     132                VecToMPISerial(&elements_touching_iceshelf,vec_element_touching_iceshelf);
     133
     134                /*Go through elements_touching_iceshelf, and flag their nodes that can unground inside potential_sheet_ungrounding*/
     135                local_nflipped=0;
     136                for(i=0;i<elements->Size();i++){
     137                        element=(Element*)elements->GetObjectByOffset(i);
     138                        if(elements_touching_iceshelf[element->Sid()]){
     139                                local_nflipped+=element->UpdatePotentialSheetUngrounding(vertices_potentially_ungrounding,vec_nodes_on_iceshelf,nodes_on_iceshelf);
     140                        }
     141                }
     142               
     143                MPI_Allreduce(&local_nflipped,&nflipped,1,MPI_INT,MPI_SUM,MPI_COMM_WORLD);
     144                _printf_(VerboseConvergence(),"   number of grounded vertices  connected to grounding line: %i\n",nflipped);
     145
     146                /*Avoid leaks: */
     147                xfree((void**)&elements_touching_iceshelf);
     148                xfree((void**)&nodes_on_iceshelf);
     149
     150                /*Assemble and serialize:*/
     151                VecFree(&vec_element_touching_iceshelf);
     152                VecAssemblyBegin(vec_nodes_on_iceshelf);
     153                VecAssemblyEnd(vec_nodes_on_iceshelf);
     154                VecToMPISerial(&nodes_on_iceshelf,vec_nodes_on_iceshelf);
     155        }
     156
     157        /*Free ressources:*/
     158        VecFree(&vec_nodes_on_iceshelf);
     159        xfree((void**)&elements_touching_iceshelf);
     160
     161        return nodes_on_iceshelf;
     162}
     163/*}}}*/
  • issm/trunk/src/c/modules/GroundinglineMigrationx/GroundinglineMigrationx.h

    r10300 r10369  
    66#define _GROUNDINGLINEMIGRATIONX_H
    77
    8 #include "../../Container/Container.h"
     8class Elements;
     9class Vertices;
     10class Nodes;
     11class Parameters;
    912
    1013/* local prototypes: */
    11 void GroundinglineMigrationx(Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads,Materials* materials, Parameters* parameters);
    12 
     14void       GroundinglineMigrationx(Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads,Materials* materials, Parameters* parameters);
     15double*    PotentialSheetUngrounding(Elements* elements,Vertices* vertices,Parameters* parameters);
     16double*    PropagateShelfIntoConnexIceSheet(Elements* elements,Nodes* nodes,Vertices* vertices,Parameters* parameters,double* vertices_potentially_ungrounding);
    1317#endif  /* _GROUNDINGLINEMIGRATIONX_H */
Note: See TracChangeset for help on using the changeset viewer.