Changeset 22136


Ignore:
Timestamp:
10/05/17 11:31:36 (8 years ago)
Author:
seroussi
Message:

NEW: adding capability to have transient params in linearbasalforcings class

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

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/c/classes/Elements/Element.cpp

    r22105 r22136  
    18151815        IssmDouble* base     = xNew<IssmDouble>(numvertices);
    18161816        IssmDouble* values   = xNew<IssmDouble>(numvertices);
    1817 
    1818         parameters->FindParam(&deepwaterel,BasalforcingsDeepwaterElevationEnum);
    1819         parameters->FindParam(&upperwaterel,BasalforcingsUpperwaterElevationEnum);
    1820         parameters->FindParam(&deepwatermelt,BasalforcingsDeepwaterMeltingRateEnum);
     1817        IssmDouble time;
     1818
     1819        parameters->FindParam(&time,TimeEnum);
     1820        parameters->FindParam(&deepwaterel,BasalforcingsDeepwaterElevationEnum,time);
     1821        parameters->FindParam(&upperwaterel,BasalforcingsUpperwaterElevationEnum,time);
     1822        parameters->FindParam(&deepwatermelt,BasalforcingsDeepwaterMeltingRateEnum,time);
    18211823
    18221824        this->GetInputListOnVertices(base,BaseEnum);
  • issm/trunk-jpl/src/c/modules/ModelProcessorx/CreateParameters.cpp

    r22100 r22136  
    3434        bool         autodiff_mass_flux_present = false;
    3535        bool         mass_flux_present          = false;
     36        bool         interp;
    3637        IssmDouble **array                      = NULL;
    3738        int         *mdims_array                = NULL;
     
    4344
    4445        IssmDouble *temp = NULL;
     46        IssmDouble *transparam = NULL;
    4547        IssmDouble  yts;
    4648        int         N,M;
     
    173175                        break;
    174176                case LinearFloatingMeltRateEnum:
    175                         parameters->AddObject(iomodel->CopyConstantObject("md.basalforcings.deepwater_melting_rate",BasalforcingsDeepwaterMeltingRateEnum));
    176                         parameters->AddObject(iomodel->CopyConstantObject("md.basalforcings.deepwater_elevation",BasalforcingsDeepwaterElevationEnum));
    177                         parameters->AddObject(iomodel->CopyConstantObject("md.basalforcings.upperwater_elevation",BasalforcingsUpperwaterElevationEnum));
     177                        iomodel->FindConstant(&interp,"md.timestepping.interp_forcings");
     178                        iomodel->FetchData(&transparam,&N,&M,"md.basalforcings.deepwater_melting_rate");
     179                        parameters->AddObject(new TransientParam(BasalforcingsDeepwaterMeltingRateEnum,&transparam[0],&transparam[M],interp,M)); _assert_(N==2 || N==1);
     180                        iomodel->FetchData(&transparam,&N,&M,"md.basalforcings.deepwater_elevation");
     181                        parameters->AddObject(new TransientParam(BasalforcingsDeepwaterElevationEnum,&transparam[0],&transparam[M],interp,M)); _assert_(N==2 || N==1);
     182                        iomodel->FetchData(&transparam,&N,&M,"md.basalforcings.upperwater_elevation");
     183                        parameters->AddObject(new TransientParam(BasalforcingsUpperwaterElevationEnum,&transparam[0],&transparam[M],interp,M)); _assert_(N==2 || N==1);
    178184                        break;
    179185                case MismipFloatingMeltRateEnum:
  • issm/trunk-jpl/src/m/classes/linearbasalforcings.m

    r21661 r22136  
    4747                        if ismember('MasstransportAnalysis',analyses) & ~(strcmp(solution,'TransientSolution') & md.transient.ismasstransport==0),
    4848                                md = checkfield(md,'fieldname','basalforcings.groundedice_melting_rate','NaN',1,'Inf',1,'timeseries',1);
    49                                 md = checkfield(md,'fieldname','basalforcings.deepwater_melting_rate','>=',0,'numel',1);
    50                                 md = checkfield(md,'fieldname','basalforcings.deepwater_elevation','<','basalforcings.upperwater_elevation','numel',1);
    51                                 md = checkfield(md,'fieldname','basalforcings.upperwater_elevation','<',0,'numel',1);
     49                                md = checkfield(md,'fieldname','basalforcings.deepwater_melting_rate','>=',0,'singletimeseries',1);
     50                                md = checkfield(md,'fieldname','basalforcings.deepwater_elevation','<','basalforcings.upperwater_elevation','singletimeseries',1);
     51                                md = checkfield(md,'fieldname','basalforcings.upperwater_elevation','<=',0,'singletimeseries',1);
    5252                        end
    5353                        if ismember('BalancethicknessAnalysis',analyses),
    5454                                md = checkfield(md,'fieldname','basalforcings.groundedice_melting_rate','NaN',1,'Inf',1,'size',[md.mesh.numberofvertices 1]);
    55                                 md = checkfield(md,'fieldname','basalforcings.deepwater_melting_rate','>=',0,'numel',1);
    56                                 md = checkfield(md,'fieldname','basalforcings.deepwater_elevation','<','basalforcings.upperwater_elevation','numel',1);
    57                                 md = checkfield(md,'fieldname','basalforcings.upperwater_elevation','<=',0,'numel',1);
     55                                md = checkfield(md,'fieldname','basalforcings.deepwater_melting_rate','>=',0,'singletimeseries',1);
     56                                md = checkfield(md,'fieldname','basalforcings.deepwater_elevation','<','basalforcings.upperwater_elevation','singletimeseries',1);
     57                                md = checkfield(md,'fieldname','basalforcings.upperwater_elevation','<=',0,'singletimeseries',1);
    5858                        end
    5959                        if ismember('ThermalAnalysis',analyses) & ~(strcmp(solution,'TransientSolution') & md.transient.isthermal==0),
    6060                                md = checkfield(md,'fieldname','basalforcings.groundedice_melting_rate','NaN',1,'Inf',1,'timeseries',1);
    61                                 md = checkfield(md,'fieldname','basalforcings.deepwater_melting_rate','>=',0,'numel',1);
    62                                 md = checkfield(md,'fieldname','basalforcings.deepwater_elevation','<','basalforcings.upperwater_elevation','numel',1);
    63                                 md = checkfield(md,'fieldname','basalforcings.upperwater_elevation','<',0,'numel',1);
     61                                md = checkfield(md,'fieldname','basalforcings.deepwater_melting_rate','>=',0,'singletimeseries',1);
     62                                md = checkfield(md,'fieldname','basalforcings.deepwater_elevation','<','basalforcings.upperwater_elevation','singletimeseries',1);
     63                                md = checkfield(md,'fieldname','basalforcings.upperwater_elevation','<=',0,'singletimeseries',1);
    6464                                md = checkfield(md,'fieldname','basalforcings.geothermalflux','NaN',1,'Inf',1,'timeseries',1,'>=',0);
    6565                        end
     
    8080
    8181                        floatingice_melting_rate=zeros(md.mesh.numberofvertices,1);
    82                         floatingice_melting_rate(find(md.geometry.base<=md.basalforcings.deepwater_elevation))=md.basalforcings.deepwater_melting_rate;
    83                         pos=find(md.geometry.base>md.basalforcings.deepwater_elevation & md.geometry.base<md.basalforcings.upperwater_elevation);
    84                         floatingice_melting_rate(pos)=md.basalforcings.deepwater_melting_rate*(md.geometry.base(pos)-md.basalforcings.upperwater_elevation)/(md.basalforcings.deepwater_elevation-md.basalforcings.upperwater_elevation);
     82                        floatingice_melting_rate(find(md.geometry.base<=md.basalforcings.deepwater_elevation(1,1)))=md.basalforcings.deepwater_melting_rate(1,1);
     83                        pos=find(md.geometry.base>md.basalforcings.deepwater_elevation(1,1) & md.geometry.base<md.basalforcings.upperwater_elevation(1,1));
     84                        floatingice_melting_rate(pos)=md.basalforcings.deepwater_melting_rate(1,1)*(md.geometry.base(pos)-md.basalforcings.upperwater_elevation(1,1))/(md.basalforcings.deepwater_elevation(1,1)-md.basalforcings.upperwater_elevation(1,1));
    8585                        WriteData(fid,prefix,'name','md.basalforcings.model','data',2,'format','Integer');
    8686                        WriteData(fid,prefix,'data',floatingice_melting_rate,'format','DoubleMat','name','md.basalforcings.floatingice_melting_rate','mattype',1,'scale',1./yts,'timeserieslength',md.mesh.numberofvertices+1,'yts',md.constants.yts)
    8787                        WriteData(fid,prefix,'object',self,'fieldname','groundedice_melting_rate','format','DoubleMat','name','md.basalforcings.groundedice_melting_rate','mattype',1,'scale',1./yts,'timeserieslength',md.mesh.numberofvertices+1,'yts',md.constants.yts)
    8888                        WriteData(fid,prefix,'object',self,'fieldname','geothermalflux','name','md.basalforcings.geothermalflux','format','DoubleMat','mattype',1,'timeserieslength',md.mesh.numberofvertices+1,'yts',md.constants.yts);
    89                         WriteData(fid,prefix,'object',self,'fieldname','deepwater_melting_rate','format','Double','name','md.basalforcings.deepwater_melting_rate','scale',1./yts)
    90                         WriteData(fid,prefix,'object',self,'fieldname','deepwater_elevation','format','Double','name','md.basalforcings.deepwater_elevation')
    91                         WriteData(fid,prefix,'object',self,'fieldname','upperwater_elevation','format','Double','name','md.basalforcings.upperwater_elevation')
     89                        WriteData(fid,prefix,'object',self,'fieldname','deepwater_melting_rate','format','DoubleMat','mattype',3,'timeserieslength',2,'name','md.basalforcings.deepwater_melting_rate','scale',1./yts,'yts',md.constants.yts)
     90                        WriteData(fid,prefix,'object',self,'fieldname','deepwater_elevation','format','DoubleMat','mattype',3,'name','md.basalforcings.deepwater_elevation','yts',md.constants.yts)
     91                        WriteData(fid,prefix,'object',self,'fieldname','upperwater_elevation','format','DoubleMat','mattype',3,'name','md.basalforcings.upperwater_elevation','yts',md.constants.yts)
    9292                end % }}}
    9393        end
  • issm/trunk-jpl/src/m/consistency/checkfield.m

    r20450 r22136  
    149149        lowerbound=getfieldvalue(options,'>=');
    150150        field2=reshape(field,prod(size(field)),1);
    151         if getfieldvalue(options,'timeseries',0), field2=reshape(field(1:end-1,:),prod(size(field(1:end-1,:))),1); end
     151        if (getfieldvalue(options,'timeseries',0) | getfieldvalue(options,'singletimeseries',0)), field2=reshape(field(1:end-1,:),prod(size(field(1:end-1,:))),1); end
    152152        if any(field2<lowerbound),
    153153                md = checkmessage(md,getfieldvalue(options,'message',...
     
    158158        lowerbound=getfieldvalue(options,'>');
    159159        field2=reshape(field,prod(size(field)),1);
    160         if getfieldvalue(options,'timeseries',0), field2=reshape(field(1:end-1,:),prod(size(field(1:end-1,:))),1); end
     160        if (getfieldvalue(options,'timeseries',0) | getfieldvalue(options,'singletimeseries',0)), field2=reshape(field(1:end-1,:),prod(size(field(1:end-1,:))),1); end
    161161        if any(field2<=lowerbound),
    162162                md = checkmessage(md,getfieldvalue(options,'message',...
     
    169169        upperbound=getfieldvalue(options,'<=');
    170170        field2=reshape(field,prod(size(field)),1);
    171         if getfieldvalue(options,'timeseries',0), field2=reshape(field(1:end-1,:),prod(size(field(1:end-1,:))),1); end
     171        if (getfieldvalue(options,'timeseries',0) | getfieldvalue(options,'singletimeseries',0)), field2=reshape(field(1:end-1,:),prod(size(field(1:end-1,:))),1); end
    172172        if any(field2>upperbound),
    173173                md = checkmessage(md,getfieldvalue(options,'message',...
     
    178178        upperbound=getfieldvalue(options,'<');
    179179        field2=reshape(field,prod(size(field)),1);
    180         if getfieldvalue(options,'timeseries',0), field2=reshape(field(1:end-1,:),prod(size(field(1:end-1,:))),1); end
     180        if (getfieldvalue(options,'timeseries',0) | getfieldvalue(options,'singletimeseries',0)), field2=reshape(field(1:end-1,:),prod(size(field(1:end-1,:))),1); end
    181181        if any(field2>=upperbound),
    182182                md = checkmessage(md,getfieldvalue(options,'message',...
     
    244244                                ['field ''' fieldname ''' columns must not contain duplicate timesteps']));
    245245                end
    246         else
    247                 md = checkmessage(md,getfieldvalue(options,'message',...
    248                         ['field ''' fieldname ''' should have 2 lines']));
    249         end
    250 end
     246        elseif size(field,1)==1,
     247                if size(field,2)~=1,
     248                        md = checkmessage(md,getfieldvalue(options,'message',...
     249                                ['field ''' fieldname ''' should be either a scalar or have 2 lines']));
     250                end
     251        else
     252                md = checkmessage(md,getfieldvalue(options,'message',...
     253                        ['field ''' fieldname ''' should have 2 lines or be a scalar']));
     254        end
     255end
Note: See TracChangeset for help on using the changeset viewer.