Changeset 24352


Ignore:
Timestamp:
11/18/19 20:56:14 (5 years ago)
Author:
Mathieu Morlighem
Message:

CHG: implementation of GIA Ivins

Location:
issm/trunk-jpl/src/c/classes/Elements
Files:
2 edited

Legend:

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

    r24351 r24352  
    22172217        delete gauss;
    22182218        xDelete<IssmDouble>(timesteps);
     2219}
     2220/*}}}*/
     2221void       Tria::GetInputAveragesUpToCurrentTime(int input_enum,IssmDouble** pvalues, IssmDouble** ptimes, int* pnumtimes, IssmDouble currenttime){/*{{{*/
     2222
     2223        /*Get transient input time steps*/
     2224        int         numtimesteps;
     2225        IssmDouble *timesteps    = NULL;
     2226        TransientInput2* transient_input  = this->inputs2->GetTransientInput(input_enum);
     2227        transient_input->GetAllTimes(&timesteps,&numtimesteps);
     2228
     2229        /*Figure out how many time steps we are going to return: */
     2230        int  numsteps               = 0;
     2231        bool iscurrenttime_included = false;
     2232        for(int i=0;i<numtimesteps;i++){
     2233                if(timesteps[i]==currenttime) iscurrenttime_included=true;
     2234                if(timesteps[i]>currenttime)  break;
     2235                else numsteps++;
     2236        }
     2237        if(iscurrenttime_included==false)numsteps++;
     2238
     2239        /*allocate: */
     2240        IssmDouble* times=xNew<IssmDouble>(numsteps);
     2241        IssmDouble* values=xNew<IssmDouble>(numsteps);
     2242
     2243        for(int i=0;i<numsteps;i++){
     2244                if((iscurrenttime_included==false) && (i==(numsteps-1))){
     2245                        Input2* input = this->GetInput2(input_enum,currenttime);
     2246                        input->GetInputAverage(&values[i]);
     2247                        times[i]=currenttime;
     2248                }
     2249                else{
     2250                        TriaInput2* input = transient_input->GetTriaInput(i);
     2251                        this->InputServe(input);
     2252                        input->GetInputAverage(&values[i]);
     2253                        times[i]=timesteps[i];
     2254                }
     2255        }
     2256
     2257        /*Assign output pointers*/
     2258        *pvalues=values;
     2259        *ptimes=times;
     2260        *pnumtimes=numtimesteps;
    22192261}
    22202262/*}}}*/
     
    51585200
    51595201        /*pull thickness averages! */
    5160         TransientInput2* thickness_input=this->inputs2->GetTransientInput(ThicknessEnum);
    5161         IssmDouble* hes=NULL;
    5162         IssmDouble* times=NULL;
     5202        IssmDouble *hes      = NULL;
     5203        IssmDouble *times    = NULL;
    51635204        int         numtimes;
    5164         _error_("Next line not implemented yet");
    5165         //thickness_input->GetInputAveragesUpToCurrentTime(&hes,&times,&numtimes,currenttime);
    5166 
     5205        this->GetInputAveragesUpToCurrentTime(ThicknessEnum,&hes,&times,&numtimes,currenttime);
    51675206
    51685207        /*recover mantle viscosity: */
  • issm/trunk-jpl/src/c/classes/Elements/Tria.h

    r24351 r24352  
    177177                void           DatasetInputCreate(IssmDouble* array,int M,int N,int* individual_enums,int num_inputs,Inputs2* inputs2,IoModel* iomodel,int input_enum);
    178178                void           CreateInputTimeAverage(int transientinput_enum,int averagedinput_enum,IssmDouble init_time,IssmDouble end_time);
     179                void           GetInputAveragesUpToCurrentTime(int input_enum,IssmDouble** pvalues, IssmDouble** ptimes, int* pnumtimes, IssmDouble currenttime);
    179180                IssmDouble     GetArea(void);
    180181                IssmDouble     GetHorizontalSurfaceArea(void);
Note: See TracChangeset for help on using the changeset viewer.