Ignore:
Timestamp:
01/05/15 11:21:22 (10 years ago)
Author:
bdef
Message:

minor clean-up in Hydro Code

File:
1 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/c/analyses/HydrologyDCEfficientAnalysis.cpp

    r18903 r18975  
    2424        iomodel->Constant(&isefficientlayer,HydrologydcIsefficientlayerEnum);
    2525
     26        /*If not return*/
    2627        if(!isefficientlayer) return;
     28
     29        /*If yes, initialize a flip flop counter*/
    2730        iomodel->FetchData(&eplflip_lock,HydrologydcEplflipLockEnum);
    28  
    2931        parameters->AddObject(new IntParam(HydrologydcEplflipLockEnum,eplflip_lock));
    3032       
    31         /*Nothing for now*/
    3233}/*}}}*/
    3334void HydrologyDCEfficientAnalysis::UpdateElements(Elements* elements,IoModel* iomodel,int analysis_counter,int analysis_type){/*{{{*/
     
    3536        bool   isefficientlayer;
    3637        int    hydrology_model;
    37 
    3838
    3939        /*Now, do we really want DC?*/
     
    6161        iomodel->FetchDataToInput(elements,HydrologydcEplInitialThicknessEnum);
    6262        iomodel->FetchDataToInput(elements,HydrologydcEplMaxThicknessEnum);
    63         iomodel->FetchDataToInput(elements,HydrologydcSedimentTransmitivityEnum);
    6463        iomodel->FetchDataToInput(elements,HydrologydcEplThicknessEnum);
    65         if(iomodel->domaintype!=Domain2DhorizontalEnum){
     64                if(iomodel->domaintype!=Domain2DhorizontalEnum){
    6665                iomodel->FetchDataToInput(elements,MeshVertexonbaseEnum);
    6766                iomodel->FetchDataToInput(elements,MeshVertexonsurfaceEnum);
     
    8584        iomodel->DeleteData(2,MeshVertexonbaseEnum,MeshVertexonsurfaceEnum);
    8685}/*}}}*/
     86
    8787void HydrologyDCEfficientAnalysis::CreateConstraints(Constraints* constraints,IoModel* iomodel){/*{{{*/
    8888
     
    9898
    9999        IoModelToConstraintsx(constraints,iomodel,HydrologydcSpceplHeadEnum,HydrologyDCEfficientAnalysisEnum,P1Enum);
    100 
    101 }/*}}}*/
     100}/*}}}*/
     101
    102102void HydrologyDCEfficientAnalysis::CreateLoads(Loads* loads, IoModel* iomodel){/*{{{*/
    103103        /*Nothing for now*/
     
    131131}/*}}}*/
    132132
    133  ElementVector* HydrologyDCEfficientAnalysis::CreateDVector(Element* element){/*{{{*/
     133ElementVector* HydrologyDCEfficientAnalysis::CreateDVector(Element* element){/*{{{*/
    134134        /*Default, return NULL*/
    135135        return NULL;
    136136}/*}}}*/
    137137
    138  ElementMatrix* HydrologyDCEfficientAnalysis::CreateJacobianMatrix(Element* element){/*{{{*/
     138ElementMatrix* HydrologyDCEfficientAnalysis::CreateJacobianMatrix(Element* element){/*{{{*/
    139139_error_("Not implemented");
    140140}/*}}}*/
    141141
    142  ElementMatrix* HydrologyDCEfficientAnalysis::CreateKMatrix(Element* element){/*{{{*/
     142ElementMatrix* HydrologyDCEfficientAnalysis::CreateKMatrix(Element* element){/*{{{*/
    143143
    144144        /*Intermediaries*/
     
    244244        if(domaintype!=Domain2DhorizontalEnum){basalelement->DeleteMaterials(); delete basalelement;};
    245245        return Ke;
    246 
    247 }/*}}}*/
     246}/*}}}*/
     247
    248248ElementVector* HydrologyDCEfficientAnalysis::CreatePVector(Element* element){/*{{{*/
    249249
     
    348348        return pe;
    349349}/*}}}*/
     350
    350351void HydrologyDCEfficientAnalysis::GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element){/*{{{*/
    351352        element->GetSolutionFromInputsOneDof(solution,EplHeadEnum);
    352353}/*}}}*/
     354
    353355void HydrologyDCEfficientAnalysis::GradientJ(Vector<IssmDouble>* gradient,Element* element,int control_type,int control_index){/*{{{*/
    354356        _error_("Not implemented yet");
    355357}/*}}}*/
     358
    356359void HydrologyDCEfficientAnalysis::InputUpdateFromSolution(IssmDouble* solution,Element* element){/*{{{*/
    357360
     
    375378        /*Fetch number of nodes for this finite element*/
    376379        int numnodes = basalelement->GetNumberOfNodes();
    377 
    378380
    379381        /*Fetch dof list and allocate solution vector*/
     
    401403        if(domaintype!=Domain2DhorizontalEnum){basalelement->DeleteMaterials(); delete basalelement;};
    402404} /*}}}*/
     405
    403406void HydrologyDCEfficientAnalysis::UpdateConstraints(FemModel* femmodel){/*{{{*/
    404407        /*Default, do nothing*/
     
    415418        return rho_freshwater*g*epl_porosity*(water_compressibility+(epl_compressibility/epl_porosity));                 
    416419}/*}}}*/
     420
    417421IssmDouble HydrologyDCEfficientAnalysis::SedimentStoring(Element* element){/*{{{*/
    418422        IssmDouble rho_freshwater           = element->GetMaterialParameter(MaterialsRhoFreshwaterEnum);
     
    535539                _error_("not Implemented Yet");
    536540                }
    537                        
     541               
    538542                int         numnodes      = element->GetNumberOfNodes();
    539543                IssmDouble* thickness     = xNew<IssmDouble>(numnodes);
     
    602606                xDelete<IssmDouble>(bed);
    603607        }
    604 }
    605 /*}}}*/
     608}/*}}}*/
     609
    606610void HydrologyDCEfficientAnalysis::GetB(IssmDouble* B,Element* element,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/
    607611        /*Compute B  matrix. B=[B1 B2 B3] where Bi is of size 3*NDOF2.
     
    631635        xDelete<IssmDouble>(dbasis);
    632636}/*}}}*/
     637
    633638void  HydrologyDCEfficientAnalysis::HydrologyEPLGetMask(Vector<IssmDouble>* vec_mask, int* eplzigzag_counter, Element* element){
    634639
     
    655660        /*Intermediaries*/
    656661
    657         int         penalty_lock;
     662        int         eplflip_lock;
    658663        int         numnodes      =basalelement->GetNumberOfNodes();
    659664        IssmDouble* epl_thickness =xNew<IssmDouble>(numnodes);
     
    669674        active_element_input->GetInputValue(&active_element);
    670675
    671         basalelement->parameters->FindParam(&penalty_lock,HydrologydcEplflipLockEnum);
     676        basalelement->parameters->FindParam(&eplflip_lock,HydrologydcEplflipLockEnum);
    672677
    673678        basalelement-> GetInputListOnVertices(&old_active[0],HydrologydcMaskEplactiveNodeEnum);
     
    691696                else if(old_active[i]>0.){
    692697                        vec_mask->SetValue(basalelement->nodes[i]->Sid(),1.,INS_VAL);
    693                         /*If epl thickness gets under 10-3 initial thickness, close the layer*/
     698                        /*If epl thickness gets under colapse thickness, close the layer*/
    694699                        if(epl_thickness[i]<colapse_thick){
    695700                                eplzigzag_counter[basalelement->nodes[i]->Lid()] ++;
    696                                 if(eplzigzag_counter[basalelement->nodes[i]->Lid()]<penalty_lock |penalty_lock==0){
     701                                /*Avoid flipfloping between open and closed states*/
     702                                if(eplzigzag_counter[basalelement->nodes[i]->Lid()]<eplflip_lock |eplflip_lock==0){
    697703                                        vec_mask->SetValue(basalelement->nodes[i]->Sid(),0.,INS_VAL);
    698704                                        epl_thickness[i]=init_thick;
     
    705711                /*Increase of the efficient system is needed if the epl head reach the maximum value (sediment max value for now)*/
    706712                GetHydrologyDCInefficientHmax(&h_max,basalelement,basalelement->nodes[i]);
    707 
    708713                if(eplhead[i]>=h_max && active_element){
    709714                        for(j=0;j<numnodes;j++){
     
    729734}
    730735/*}}}*/
     736
    731737void HydrologyDCEfficientAnalysis::HydrologyEPLGetActive(Vector<IssmDouble>* active_vec, Element* element){
    732738        /*Constants*/
     
    750756        IssmDouble  flag     = 0.;
    751757        IssmDouble* active   = xNew<IssmDouble>(numnodes);
    752                
     758
     759        /*Pass the activity mask from elements to nodes*/
    753760        basalelement->GetInputListOnVertices(&active[0],HydrologydcMaskEplactiveNodeEnum);
    754761        bool active_element;
     
    758765        for(int i=0;i<numnodes;i++) flag+=active[i];
    759766
     767        /*If any node is active all the node in the element are active*/
    760768        if(flag>0.){
    761769                for(int i=0;i<numnodes;i++){
     
    763771                }
    764772        }
     773        /*If the element is active all its nodes are active*/
    765774        else if(active_element){
    766775                for(int i=0;i<numnodes;i++){
Note: See TracChangeset for help on using the changeset viewer.