Changeset 26973


Ignore:
Timestamp:
04/27/22 11:22:23 (3 years ago)
Author:
Cheng Gong
Message:

CHG: add a special test case for killberg with only one single node of ice and has ocean_levelset crossing the neighbour elements, select the initial mask more strict to fix this bug

Location:
issm/trunk-jpl
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified issm/trunk-jpl/src/c/cores/movingfront_core.cpp

    r26972 r26973  
    1616
    1717        /* intermediaries */
    18         bool save_results,isstressbalance,ismasstransport,isthermal,isenthalpy,islevelset,ismovingfront,killicebergs,haskillberg;
     18        bool save_results,isstressbalance,ismasstransport,isthermal,isenthalpy,islevelset,ismovingfront,killicebergs;
    1919        int  domaintype, num_extrapol_vars, index,reinit_frequency,step;
    2020        int* extrapol_vars=NULL;
     
    120120        /*Kill ice berg to avoid free body motion*/
    121121        if(killicebergs){
     122                int killberg = 0;
    122123                if(VerboseSolution()) _printf0_("   looking for icebergs to kill\n");
    123                 KillIcebergsx(femmodel);
    124                 femmodel->parameters->FindParam(&haskillberg,LevelsetHasKillIcebergsEnum);
    125                 if (haskillberg) {
    126                         if(VerboseSolution()) _printf0_("   reinitializing level set after killing icebergs\n");
     124                killberg = KillIcebergsx(femmodel);
     125                /*wait for all cores*/
     126                int totalkill;
     127                ISSM_MPI_Reduce(&killberg,&totalkill,1,ISSM_MPI_INT,ISSM_MPI_SUM,0,IssmComm::GetComm());
     128                ISSM_MPI_Bcast(&totalkill,1,ISSM_MPI_INT,0,IssmComm::GetComm());
     129
     130                if (totalkill > 0) {
     131                        if(VerboseSolution()) _printf0_("   reinitializing level set after killing " << totalkill << " icebergs\n");
    127132                        femmodel->ResetLevelset();
    128133                        ResetBoundaryConditions(femmodel,LevelsetAnalysisEnum);
  • TabularUnified issm/trunk-jpl/src/c/modules/KillIcebergsx/KillIcebergsx.cpp

    r26965 r26973  
    99#include "../InputUpdateFromVectorx/InputUpdateFromVectorx.h"
    1010
    11 void KillIcebergsx(FemModel* femmodel){
     11int KillIcebergsx(FemModel* femmodel){
    1212
    1313        /*Intermediaries*/
     
    1818        IssmDouble *local_mask   = xNewZeroInit<IssmDouble>(nbv_local);
    1919        bool       *element_flag = xNewZeroInit<bool>(femmodel->elements->Size());
     20        IssmDouble ice;
    2021
    2122        /*Step 1, go through all elements and put 1 in local_mask if the element is grounded*/
     
    2728                        element_flag[i] = true;
    2829                }
    29                 else{
     30                else {
    3031                        if(element->IsAllGrounded()){
     32                                /* only look at element with ice but not fully grounded */
    3133                                int numvertices = element->GetNumberOfVertices();
    32                                 for(int v=0;v<numvertices;v++) local_mask[element->vertices[v]->Lid()] = 1.;
     34                                Gauss* gauss=element->NewGauss();
     35                                Input* icelevel_input = element->GetInput(MaskIceLevelsetEnum);                         _assert_(icelevel_input);
     36
     37                                for(int v=0;v<numvertices;v++) {
     38                                        gauss->GaussVertex(v);
     39                                        icelevel_input->GetInputValue(&ice,gauss);
     40                                        /* The initial mask is very strict, we look at all grounded elements and set the mask for ice nodes only. */
     41                                        if (ice < 0) local_mask[element->vertices[v]->Lid()] = 1.;
     42                                }
     43                                delete gauss;
    3344                        }
    3445                }
     
    4859                /*Local iterations on partition*/
    4960                bool keepgoing    = true;
    50                 int  didsomething = 0;
    5161                int  iter         = 1;
    5262                while(keepgoing){
     
    5464
    5565                        keepgoing    = false;
    56                         didsomething = 0;
    5766                        int i=0;
    5867                        for(Object* & object : femmodel->elements->objects){
     
    6271                                        int numvertices = element->GetNumberOfVertices();
    6372                                        bool found1 = false;
     73                                        IssmDouble sumlocalmask = 0.;
     74
    6475                                        for(int j=0;j<numvertices;j++){
    6576                                                lid = element->vertices[j]->Lid();
    66                                                 if(local_mask[lid]>0.){
     77                                                /*we need to have at least a sharing edge, to extend the mask*/
     78                                                sumlocalmask += local_mask[lid];
     79                                                if(sumlocalmask > 1.5){
    6780                                                        found1 = true;
    6881                                                        break;
     
    7386                                                for(int j=0;j<numvertices;j++){
    7487                                                        lid = element->vertices[j]->Lid();
    75                                                         if(local_mask[lid]==0.){
    76                                                                 local_mask[lid]=1.;
    77                                                                 keepgoing = true;
    78                                                                 didsomething = 1;
    79                                                         }
     88                                                        local_mask[lid]=1.;
    8089                                                }
     90                                                keepgoing = true;
    8191                                        }
    8292                                }
     
    99109        xDelete<bool>(element_flag);
    100110
    101         bool killbergReinit = false;
     111        int killbergReinit = 0;
    102112        /*OK, now deactivate iceberg and count the number of deactivated vertices*/
    103113        for(Object* & object : femmodel->elements->objects){
     
    121131                                element->AddInput(MaskIceLevelsetEnum,values,P1Enum);
    122132                                xDelete<IssmDouble>(values);
    123                                 killbergReinit = true;
     133                                killbergReinit += 1;
    124134                        }
    125135                }
    126136        }
    127         /*Recompute the sign distance for the levelset function*/
    128    femmodel->parameters->SetParam(killbergReinit,LevelsetHasKillIcebergsEnum);
    129 
    130137        /*cleanup*/
    131138        xDelete<IssmDouble>(local_mask);
     139
     140        /*Recompute the sign distance for the levelset function*/
     141        return killbergReinit;
    132142}
  • TabularUnified issm/trunk-jpl/src/c/modules/KillIcebergsx/KillIcebergsx.h

    r23992 r26973  
    66
    77/* local prototypes: */
    8 void KillIcebergsx(FemModel* femmodel);
     8int KillIcebergsx(FemModel* femmodel);
    99
    1010#endif
  • TabularUnified issm/trunk-jpl/src/c/shared/Enum/EnumDefinitions.h

    r26965 r26973  
    270270        LevelsetReinitFrequencyEnum,
    271271        LevelsetStabilizationEnum,
    272         LevelsetHasKillIcebergsEnum,
    273272        LockFileNameEnum,
    274273        LoveAllowLayerDeletionEnum,
  • TabularUnified issm/trunk-jpl/src/m/parameterization/killberg.m

    r26965 r26973  
    2828%isgrounded = max(md.mask.ocean_levelset(md.mesh.elements),[],2)>0;
    2929pos = find(isgrounded);
    30 element_flag(pos) = 1;
     30%element_flag(pos) = 1;
    3131mask(md.mesh.elements(pos,:)) = 1;
     32mask(md.mask.ice_levelset>=0) = 0;
    3233
    3334iter = 1;
Note: See TracChangeset for help on using the changeset viewer.