Changeset 21463


Ignore:
Timestamp:
01/03/17 14:21:29 (8 years ago)
Author:
aleahsommers
Message:

NEW: Added under-relaxation capability and added basal flux as an output

Location:
issm/trunk-jpl/src
Files:
4 edited

Legend:

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

    r21211 r21463  
    120120        iomodel->FetchDataToInput(elements,"md.initialization.vx",VxEnum);
    121121        iomodel->FetchDataToInput(elements,"md.initialization.vy",VyEnum);
    122         //iomodel->FetchDataToInput(elements,"md.hydrology.eff_pressure",EffectivePressureEnum);
    123122        iomodel->FindConstant(&frictionlaw,"md.friction.law");
     123
    124124        /*Friction law variables*/
    125125        switch(frictionlaw){
     
    147147        parameters->AddObject(new IntParam(HydrologyModelEnum,hydrology_model));
    148148        parameters->AddObject(iomodel->CopyConstantObject("md.friction.law",FrictionLawEnum));
     149   parameters->AddObject(iomodel->CopyConstantObject("md.hydrology.relaxation",HydrologyRelaxationEnum));
    149150}/*}}}*/
    150151
     
    178179        /*Get conductivity from inputs*/
    179180        IssmDouble conductivity = GetConductivity(element);
    180 //if(element->Id()==1){
    181 //      printf("Conductivity at CreateKMatrix: %g \n",conductivity);
    182 //}
    183181
    184182        /* Start  looping on the number of gaussian points: */
     
    245243        /*Get conductivity from inputs*/
    246244        IssmDouble conductivity = GetConductivity(element);
    247 //if(element->Id()==1){
    248 //      printf("Conductivity in CreatePVector: %g \n",conductivity);
    249 //}
    250245
    251246        /*Build friction element, needed later: */
     
    306301                meltrate = 1/latentheat*(G+frictionheat+rho_water*g*conductivity*(dh[0]*dh[0]+dh[1]*dh[1])-PMPheat);
    307302                _assert_(meltrate>0.);
    308                
     303       
    309304                for(int i=0;i<numnodes;i++) pe->values[i]+=Jdet*gauss->weight*
    310305                 (
    311306                  meltrate*(1/rho_water-1/rho_ice)
    312                   +A*pow(fabs(pressure_ice - pressure_water_old),n-1)*(pressure_ice - pressure_water_old)*gap
     307                  +A*pow(fabs(pressure_ice - pressure_water),n-1)*(pressure_ice - pressure_water)*gap
    313308                  -beta*sqrt(vx*vx+vy*vy)
    314309                  +ieb
     
    354349        element->GetInputListOnNodes(&bed[0],BaseEnum);
    355350
     351        /*Get head from previous time-step and under-relaxation coefficient to use in under-relaxation for nonlinear convergence*/
     352   IssmDouble* head_old  = xNew<IssmDouble>(numnodes);
     353        element->GetInputListOnNodes(&head_old[0],HydrologyHeadEnum);
     354   IssmDouble relaxation;
     355        element->FindParam(&relaxation,HydrologyRelaxationEnum);
     356
    356357        /*Use the dof list to index into the solution vector: */
    357358        for(int i=0;i<numnodes;i++){
     
    367368                        values[i] = bed[i];
    368369                }
     370
     371                /*Under-relaxation*/
     372           values[i] = head_old[i] - relaxation*(head_old[i]-values[i]);
    369373
    370374                /*Calculate effective pressure*/
     
    385389        IssmDouble conductivity = GetConductivity(element);
    386390
    387         IssmDouble reynolds = conductivity*sqrt(dh[0]*dh[0]+dh[1]*dh[1])/(2.*NU);
     391        IssmDouble reynolds = conductivity*sqrt(dh[0]*dh[0]+dh[1]*dh[1])/NU;
    388392        element->AddInput(HydrologyReynoldsEnum,&reynolds,P0Enum);
    389393
    390         /*Free ressources:*/
     394        /*Calculate basal flux for output*/
     395        IssmDouble q = conductivity*sqrt(dh[0]*dh[0]+dh[1]*dh[1]);
     396        element->AddInput(HydrologyBasalFluxEnum,&q,P1Enum);
     397
     398        /*Free resources:*/
    391399        xDelete<IssmDouble>(values);
    392400        xDelete<IssmDouble>(thickness);
     
    395403        xDelete<int>(doflist);
    396404        xDelete<IssmDouble>(eff_pressure);
     405   xDelete<IssmDouble>(head_old);
    397406}/*}}}*/
    398407void           HydrologySommersAnalysis::UpdateConstraints(FemModel* femmodel){/*{{{*/
     
    468477        /*Get conductivity from inputs*/
    469478        IssmDouble conductivity = GetConductivity(element);
    470 //if(element->Id()==1){
    471 //      printf("Conductivity at gap update: %g \n",conductivity);
    472 //}
     479
    473480        /*Build friction element, needed later: */
    474481        Friction* friction=new Friction(element,2);
     
    537544        /*Divide by connectivity*/
    538545        newgap = newgap/totalweights;
    539         IssmDouble mingap = 1e-5;
     546        IssmDouble mingap = 1e-6;
    540547        if(newgap<mingap) newgap=mingap;
    541548
  • issm/trunk-jpl/src/c/cores/hydrology_core.cpp

    r21208 r21463  
    8989                if(save_results){
    9090                        if(VerboseSolution()) _printf0_("   saving results \n");
    91                         int outputs[3] = {HydrologyHeadEnum,HydrologyGapHeightEnum,EffectivePressureEnum};
    92                         femmodel->RequestedOutputsx(&femmodel->results,&outputs[0],3);
     91                        int outputs[4] = {HydrologyHeadEnum,HydrologyGapHeightEnum,EffectivePressureEnum,HydrologyBasalFluxEnum};
     92                        femmodel->RequestedOutputsx(&femmodel->results,&outputs[0],4);
    9393                       
    9494                        /*unload results*/
  • issm/trunk-jpl/src/c/shared/Enum/EnumDefinitions.h

    r21389 r21463  
    174174        HydrologyReynoldsEnum,
    175175        HydrologyNeumannfluxEnum,
     176   HydrologyRelaxationEnum,
     177        HydrologyBasalFluxEnum,
    176178        InversionControlParametersEnum,
    177179        InversionControlScalingFactorsEnum,
  • issm/trunk-jpl/src/m/classes/hydrologysommers.m

    r21049 r21463  
    1515                spchead         = NaN;
    1616                neumannflux     = NaN;
     17                relaxation      = 0;
    1718        end
    1819        methods
     
    3031                end % }}}
    3132                function self = setdefaultparameters(self) % {{{
     33              % Set under-relaxation parameter to be 1 (no under-relaxation of nonlinear iteration)     
     34                        self.relaxation=1;
    3235                end % }}}
    3336                function md = checkconsistency(self,md,solution,analyses) % {{{
     
    4649                        md = checkfield(md,'fieldname','hydrology.reynolds','>',0,'size',[md.mesh.numberofelements 1],'NaN',1,'Inf',1);
    4750                        md = checkfield(md,'fieldname','hydrology.neumannflux','timeseries',1,'NaN',1,'Inf',1);
    48                         md = checkfield(md,'fieldname','hydrology.spchead','size',[md.mesh.numberofvertices 1]);
     51                        md = checkfield(md,'fieldname','hydrology.spchead','size',[md.mesh.numberofvertices 1]);       
     52         md = checkfield(md,'fieldname','hydrology.relaxation','>=',0);
    4953                end % }}}
    5054                function disp(self) % {{{
     
    5963                        fielddisplay(self,'neumannflux','water flux applied along the model boundary (m^2/s)');
    6064                        fielddisplay(self,'spchead','water head constraints (NaN means no constraint) (m)');
     65                        fielddisplay(self,'relaxation','under-relaxation coefficient for nonlinear iteration');
    6166                end % }}}
    6267                function marshall(self,prefix,md,fid) % {{{
     
    7479                        WriteData(fid,prefix,'object',self,'class','hydrology','fieldname','neumannflux','format','DoubleMat','mattype',2,'timeserieslength',md.mesh.numberofelements+1,'yts',md.constants.yts);
    7580                        WriteData(fid,prefix,'object',self,'class','hydrology','fieldname','spchead','format','DoubleMat','mattype',1);
     81         WriteData(fid,prefix,'object',self,'class','hydrology','fieldname','relaxation','format','Double');
    7682                end % }}}
    7783        end
Note: See TracChangeset for help on using the changeset viewer.