Changeset 27293


Ignore:
Timestamp:
09/28/22 08:43:44 (2 years ago)
Author:
Mathieu Morlighem
Message:

NEW: added hydro speed as output

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified issm/trunk-jpl/src/c/analyses/HydrologyGlaDSAnalysis.cpp ΒΆ

    r27289 r27293  
    444444void           HydrologyGlaDSAnalysis::InputUpdateFromSolution(IssmDouble* solution,Element* element){/*{{{*/
    445445        element->InputUpdateFromSolutionOneDof(solution,HydraulicPotentialEnum);
     446
     447        /*Compute Hydrology Vx and Vy for time stepping purposes (These inputs do not affect GlaDS)*/
     448
     449        /*Intermediaries*/
     450   IssmDouble  dphi[3],h,k,phi;
     451        IssmDouble  oceanLS,iceLS;
     452        IssmDouble* xyz_list = NULL;
     453
     454        /*Hard coded coefficients*/
     455        const IssmPDouble alpha = 5./4.;
     456        const IssmPDouble beta  = 3./2.;
     457
     458        /*Fetch number vertices for this element*/
     459        int numvertices = element->GetNumberOfVertices();
     460
     461        /*Initialize new sheet thickness*/
     462        IssmDouble* vx = xNew<IssmDouble>(numvertices);
     463        IssmDouble* vy = xNew<IssmDouble>(numvertices);
     464
     465        /*Set to 0 if inactive element*/
     466        if(element->IsAllFloating() || !element->IsIceInElement()){
     467                for(int iv=0;iv<numvertices;iv++) vx[iv] = 0.;
     468                for(int iv=0;iv<numvertices;iv++) vy[iv] = 0.;
     469                element->AddInput(HydrologyWaterVxEnum,vx,P1DGEnum);
     470                element->AddInput(HydrologyWaterVyEnum,vy,P1DGEnum);
     471                xDelete<IssmDouble>(vx);
     472                xDelete<IssmDouble>(vy);
     473                return;
     474        }
     475
     476        /*Retrieve all inputs and parameters*/
     477        element->GetVerticesCoordinates(&xyz_list);
     478        Input *k_input       = element->GetInput(HydrologySheetConductivityEnum); _assert_(k_input);
     479        Input *phi_input     = element->GetInput(HydraulicPotentialEnum);         _assert_(phi_input);
     480        Input *h_input       = element->GetInput(HydrologySheetThicknessEnum);    _assert_(h_input);
     481        Input *oceanLS_input = element->GetInput(MaskOceanLevelsetEnum);          _assert_(oceanLS_input);
     482        Input *iceLS_input   = element->GetInput(MaskIceLevelsetEnum);            _assert_(iceLS_input);
     483
     484        /* Start  looping on the number of gaussian points: */
     485        Gauss* gauss=element->NewGauss();
     486        for(int iv=0;iv<numvertices;iv++){
     487                gauss->GaussVertex(iv);
     488
     489                /*Get input values at gauss points*/
     490      phi_input->GetInputDerivativeValue(&dphi[0],xyz_list,gauss);
     491      phi_input->GetInputValue(&phi,gauss);
     492      h_input->GetInputValue(&h,gauss);
     493      k_input->GetInputValue(&k,gauss);
     494                oceanLS_input->GetInputValue(&oceanLS,gauss);
     495                iceLS_input->GetInputValue(&iceLS,gauss);
     496
     497                /*Set sheet thickness to zero if floating or no ice*/
     498                if(oceanLS<0. || iceLS>0.){
     499                        vx[iv] = 0.;
     500         vy[iv] = 0.;
     501                }
     502                else{
     503
     504         /*Get norm of gradient of hydraulic potential and make sure it is >0*/
     505         IssmDouble normgradphi = sqrt(dphi[0]*dphi[0] + dphi[1]*dphi[1]);
     506         if(normgradphi < AEPS) normgradphi = AEPS;
     507
     508         IssmDouble coeff = k*pow(h,alpha)*pow(normgradphi,beta-2.)/max(AEPS,h); // divide by h to get speed instead of discharge
     509
     510                        vx[iv] = -coeff*dphi[0];
     511                        vy[iv] = -coeff*dphi[1];
     512                }
     513        }
     514
     515        element->AddInput(HydrologyWaterVxEnum,vx,P1DGEnum);
     516        element->AddInput(HydrologyWaterVyEnum,vy,P1DGEnum);
     517
     518        /*Clean up and return*/
     519        xDelete<IssmDouble>(xyz_list);
     520        xDelete<IssmDouble>(vx);
     521        xDelete<IssmDouble>(vy);
     522        delete gauss;
    446523}/*}}}*/
    447524void           HydrologyGlaDSAnalysis::UpdateConstraints(FemModel* femmodel){/*{{{*/
Note: See TracChangeset for help on using the changeset viewer.