Changeset 22281


Ignore:
Timestamp:
11/30/17 08:06:43 (7 years ago)
Author:
bdef
Message:

CHG:implementing some 3D compliance and hydro_core clean-up

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

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/c/classes/Inputs/TransientInput.cpp

    r22280 r22281  
    315315void TransientInput::GetInputAverageOnTimes(IssmDouble** pvalues, IssmDouble init_time){/*{{{*/
    316316
    317         IssmDouble  time;
    318         IssmDouble  preceding_time;
     317        int                                     numnodes;
     318        IssmDouble  subtimestep;
    319319        IssmDouble* values= NULL;
    320 
    321         values=xNew<IssmDouble>(3);
    322        
     320        Input* input=NULL;
     321
     322        /*Initialize numnode from transientinput out of time loop*/
    323323        for(int i=0;i<this->numtimesteps;i++){
    324                 time                                             = this->timesteps[i];
    325                 TriaInput*      input            = (TriaInput*)this->inputs->GetObjectByOffset(i); _assert_(input);
    326                 int                                     numnodes = input->NumberofNodes(input->interpolation_type);
     324                /*First compute the lengt of the sub-timestep*/
    327325                if(i==0){
    328                         preceding_time = init_time;
    329                         for(int j=0;j<numnodes;j++){
    330                                 values[j]=(input->values[j]*(time-preceding_time));
    331                         }
     326                        subtimestep = this->timesteps[i]-init_time;
    332327                }
    333328                else{
    334                         preceding_time = this->timesteps[i-1];
     329                        subtimestep = this->timesteps[i]-this->timesteps[i-1];
     330                }       
     331                /*Figure out type of input and get it*/
     332                input = xDynamicCast<Input*>(this->inputs->GetObjectByOffset(i)); _assert_(input);
     333                switch(input->ObjectEnum()){
     334                case TriaInputEnum:{
     335                        TriaInput* triainput = xDynamicCast<TriaInput*>(this->inputs->GetObjectByOffset(i)); _assert_(triainput);
     336                        numnodes= triainput->NumberofNodes(triainput->interpolation_type);
     337                        values=xNewZeroInit<IssmDouble>(numnodes);
     338                        /*Sum the values weighted by their respective sub-timestep*/
    335339                        for(int j=0;j<numnodes;j++){
    336                                 values[j]+=(input->values[j]*(time-preceding_time));
    337                                 if(i==this->numtimesteps-1){
    338                                         values[j]=values[j]/(this->timesteps[this->numtimesteps-1]-init_time);
    339                                 }
     340                                values[j]+=(triainput->values[j]*subtimestep);
    340341                        }
     342                        break;
    341343                }
     344                case PentaInputEnum:{
     345                        PentaInput*     pentainput = xDynamicCast<PentaInput*>(this->inputs->GetObjectByOffset(i)); _assert_(pentainput);
     346                        numnodes= pentainput->NumberofNodes(pentainput->interpolation_type);
     347                        values=xNewZeroInit<IssmDouble>(numnodes);
     348                        /*Sum the values weighted by their respective sub-timestep*/
     349                        for(int j=0;j<numnodes;j++){
     350                                values[j]+=(pentainput->values[j]*subtimestep);
     351                        }
     352                        break;
     353                }
     354                case TetraInputEnum:{
     355                        TetraInput*     tetrainput = xDynamicCast<TetraInput*>(this->inputs->GetObjectByOffset(i)); _assert_(tetrainput);
     356                        numnodes= tetrainput->NumberofNodes(tetrainput->interpolation_type);
     357                        values=xNewZeroInit<IssmDouble>(numnodes);
     358                        /*Sum the values weighted by their respective sub-timestep*/
     359                        for(int j=0;j<numnodes;j++){
     360                                values[j]+=(tetrainput->values[j]*subtimestep);
     361                        }
     362                        break;
     363                }
     364                default: _error_("not implemented yet");
     365                }
     366        }
     367        /*Compute the average based on the length of the full timestep*/
     368        for(int j=0;j<numnodes;j++){
     369                values[j]=values[j]/(this->timesteps[this->numtimesteps-1]-init_time);
    342370        }
    343371        *pvalues=values;
  • issm/trunk-jpl/src/c/cores/hydrology_core.cpp

    r22277 r22281  
    2424        femmodel->parameters->FindParam(&solution_type,SolutionTypeEnum);       
    2525
    26         if(VerboseSolution()) _printf0_("   computing water heads\n");
    27                        
    28         /*first compute slopes: */
     26        /*Using the Shreve based Model*/
    2927        if (hydrology_model==HydrologyshreveEnum){
     28                if(VerboseSolution()) _printf0_("   computing water heads\n");
     29                /*first compute slopes: */
    3030                surfaceslope_core(femmodel);
    3131                bedslope_core(femmodel);
    32         }
    33 
    34         /*Using the Shreve based Model*/
    35         if (hydrology_model==HydrologyshreveEnum){
     32                /*and then go to water column*/
    3633                if(VerboseSolution()) _printf0_("   computing water column\n");
    3734                femmodel->SetCurrentConfiguration(HydrologyShreveAnalysisEnum);
     
    4542                        int outputs[3] = {WatercolumnEnum,HydrologyWaterVxEnum,HydrologyWaterVyEnum};
    4643                        femmodel->RequestedOutputsx(&femmodel->results,&outputs[0],3);
    47                        
    48                         /*unload results*/
    49                         if(VerboseSolution()) _printf0_("   saving temporary results\n");
    50                         OutputResultsx(femmodel);
    5144                }
    5245        }
     
    5649                /*intermediary: */
    5750                int        step,hydroslices;
    58                 int        numoutputs;
     51                int        numoutputs=0;
    5952                char       **requested_outputs = NULL;
    6053                IssmDouble time,init_time,hydrotime,yts;
     
    111104                        if(VerboseSolution()) _printf0_("   saving results \n");
    112105                        femmodel->RequestedOutputsx(&femmodel->results,requested_outputs,numoutputs);
    113                         /*unload results removed 23/11 needs checking*/
    114                         /* if(VerboseSolution()) _printf0_("   saving temporary results\n"); */
    115                         /* OutputResultsx(femmodel); */
    116106                }
    117107                /*Free ressources:*/   
     
    119109                        for(int i=0;i<numoutputs;i++){
    120110                                xDelete<char>(requested_outputs[i]);
    121                         } 
     111                        }
    122112                        xDelete<char*>(requested_outputs);
    123113                }
     
    138128                        int outputs[5] = {HydrologyHeadEnum,HydrologyGapHeightEnum,EffectivePressureEnum,HydrologyBasalFluxEnum,DegreeOfChannelizationEnum};
    139129                        femmodel->RequestedOutputsx(&femmodel->results,&outputs[0],5);
    140                        
    141                         /*unload results*/
    142                         if(VerboseSolution()) _printf0_("   saving temporary results\n");
    143                         OutputResultsx(femmodel);
    144130                }
    145131        }
Note: See TracChangeset for help on using the changeset viewer.