Changeset 16740


Ignore:
Timestamp:
11/13/13 15:25:50 (11 years ago)
Author:
Mathieu Morlighem
Message:

NEW: trying to make TransientInput creation faster

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

Legend:

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

    r16739 r16740  
    19311931                else if(M==iomodel->numberofvertices+1){
    19321932                        /*create transient input: */
    1933                         for(t=0;t<N;t++){ //N is the number of times
    1934 
    1935                                 /*create input values: */
    1936                                 for(i=0;i<6;i++){
    1937                                         row=penta_vertex_ids[i]-1;
    1938                                         nodeinputs[i]=(IssmDouble)vector[N*row+t];
    1939                                 }
    1940 
    1941                                 /*time? :*/
    1942                                 time=(IssmDouble)vector[(M-1)*N+t];
    1943 
    1944                                 if(t==0)transientinput=new TransientInput(vector_enum);
    1945                                 transientinput->AddTimeInput(new PentaInput(vector_enum,nodeinputs,P1Enum),time);
     1933                        IssmDouble* times = xNew<IssmDouble>(N);
     1934                        for(t=0;t<N;t++) times[t] = vector[(M-1)*N+t];
     1935                        transientinput=new TransientInput(vector_enum,times,N);
     1936                        for(t=0;t<N;t++){
     1937                                for(i=0;i<NUMVERTICES;i++) nodeinputs[i]=vector[N*(penta_vertex_ids[i]-1)+t];
     1938                                transientinput->AddTimeInput(new PentaInput(vector_enum,nodeinputs,P1Enum));
    19461939                        }
    19471940                        this->inputs->AddInput(transientinput);
     1941                        xDelete<IssmDouble>(times);
    19481942                }
    19491943                else _error_("nodal vector is either numberofvertices (" << iomodel->numberofvertices << "), or numberofvertices+1 long. Field provided is " << M << " long. Enum " << EnumToStringx(vector_enum));
  • issm/trunk-jpl/src/c/classes/Elements/Tria.cpp

    r16727 r16740  
    20952095                else if(M==iomodel->numberofvertices+1){
    20962096                        /*create transient input: */
    2097                         for(t=0;t<N;t++){ //N is the number of times
    2098 
    2099                                 /*create input values: */
    2100                                 for(i=0;i<3;i++){
    2101                                         row=tria_vertex_ids[i]-1;
    2102                                         nodeinputs[i]=vector[N*row+t];
    2103                                 }
    2104 
    2105                                 /*time? :*/
    2106                                 time=vector[(M-1)*N+t];
    2107 
    2108                                 if(t==0) transientinput=new TransientInput(vector_enum);
    2109                                 transientinput->AddTimeInput(new TriaInput(vector_enum,nodeinputs,P1Enum),time);
     2097                        IssmDouble* times = xNew<IssmDouble>(N);
     2098                        for(t=0;t<N;t++) times[t] = vector[(M-1)*N+t];
     2099                        transientinput=new TransientInput(vector_enum,times,N);
     2100                        for(t=0;t<N;t++){
     2101                                for(i=0;i<NUMVERTICES;i++) nodeinputs[i]=vector[N*(tria_vertex_ids[i]-1)+t];
     2102                                transientinput->AddTimeInput(new TriaInput(vector_enum,nodeinputs,P1Enum));
    21102103                        }
    21112104                        this->inputs->AddInput(transientinput);
     2105                        xDelete<IssmDouble>(times);
    21122106                }
    21132107                else _error_("nodal vector is either numberofvertices or numberofvertices+1 long. Field provided (" << EnumToStringx(vector_enum) << ") is " << M << " long");
  • issm/trunk-jpl/src/c/classes/Inputs/TransientInput.cpp

    r16675 r16740  
    3939}
    4040/*}}}*/
     41/*FUNCTION TransientInput::TransientInput(int in_enum_type,IssmDouble* timesin,int N){{{*/
     42TransientInput::TransientInput(int in_enum_type,IssmDouble* timesin,int N){
     43
     44        /*Set Enum*/
     45        enum_type=in_enum_type;
     46
     47        /*Allocate values and timesteps, and copy: */
     48        this->numtimesteps=N;
     49        this->timesteps=xNew<IssmDouble>(N);
     50        xMemCpy(this->timesteps,timesin,N);
     51
     52        inputs = new Inputs();
     53        this->parameters=NULL;
     54}
     55/*}}}*/
    4156/*FUNCTION TransientInput::~TransientInput{{{*/
    4257TransientInput::~TransientInput(){
     
    6681        _printf_("---inputs: \n");
    6782        for(i=0;i<this->numtimesteps;i++){
    68                 _printf_("   time: " << this->timesteps[i] << "  \n");
     83                _printf_("   time: " << this->timesteps[i]<<"  ");
    6984                ((Input*)this->inputs->GetObjectByOffset(i))->Echo();
    7085        }
     
    314329}
    315330/*}}}*/
     331/*FUNCTION TransientInput::AddTimeInput{{{*/
     332void TransientInput::AddTimeInput(Input* input){
     333
     334        _assert_(this->inputs->Size()<this->numtimesteps);
     335        inputs->AddObject(input);
     336
     337}
     338/*}}}*/
    316339/*FUNCTION TransientInput::GetResultInterpolation{{{*/
    317340int  TransientInput::GetResultInterpolation(void){
  • issm/trunk-jpl/src/c/classes/Inputs/TransientInput.h

    r16675 r16740  
    2626                TransientInput();
    2727                TransientInput(int enum_type);
     28                TransientInput(int in_enum_type,IssmDouble* times,int N);
    2829                ~TransientInput();
    2930                void AddTimeInput(Input* input,IssmDouble time);
     31                void AddTimeInput(Input* input);
    3032                /*}}}*/
    3133                /*Object virtual functions definitions:{{{*/
Note: See TracChangeset for help on using the changeset viewer.