[issm-svn] r12299 - issm/trunk/src/c/objects

morlighe at issm.ess.uci.edu morlighe at issm.ess.uci.edu
Tue May 29 13:58:10 PDT 2012


Author: morlighe
Date: 2012-05-29 13:58:10 -0700 (Tue, 29 May 2012)
New Revision: 12299

Modified:
   issm/trunk/src/c/objects/Elements/Tria.cpp
   issm/trunk/src/c/objects/Inputs/BoolInput.h
   issm/trunk/src/c/objects/Inputs/ControlInput.h
   issm/trunk/src/c/objects/Inputs/DatasetInput.h
   issm/trunk/src/c/objects/Inputs/DoubleInput.h
   issm/trunk/src/c/objects/Inputs/Input.h
   issm/trunk/src/c/objects/Inputs/IntInput.h
   issm/trunk/src/c/objects/Inputs/PentaP1Input.h
   issm/trunk/src/c/objects/Inputs/TransientInput.cpp
   issm/trunk/src/c/objects/Inputs/TransientInput.h
   issm/trunk/src/c/objects/Inputs/TriaP1Input.h
Log:
Recover monthly temperatures for PDD module

Modified: issm/trunk/src/c/objects/Elements/Tria.cpp
===================================================================
--- issm/trunk/src/c/objects/Elements/Tria.cpp	2012-05-29 18:25:53 UTC (rev 12298)
+++ issm/trunk/src/c/objects/Elements/Tria.cpp	2012-05-29 20:58:10 UTC (rev 12299)
@@ -2254,7 +2254,6 @@
    double st;             // elevation between altitude of the temp record and current altitude
    double sp;             // elevation between altitude of the prec record and current altitude
 
-
    // PDD and PD constants and variables
    double siglim;          // sigma limit for the integration which is equal to 2.5 sigmanorm
    double signormc = signorm - 0.5;     // sigma of the temperature distribution for cloudy day
@@ -2294,7 +2293,19 @@
    GetInputListOnVertices(&ttmp[0],ThermalSpctemperatureEnum);
    GetInputListOnVertices(&prectmp[0],SurfaceforcingsPrecipitationEnum);
 
-   for(i=0;i<NUMVERTICES;i++) ttmp[i]=ttmp[i]-273.15; // convertion from Kelvin to celcius
+	/*Recover monthly temperatures*/
+	Input* input=inputs->GetInput(SurfaceforcingsMonthlytemperatures); _assert_(input);
+	GaussTria* gauss=new GaussTria();
+	double time,yts;
+	this->parameters->FindParam(&time,TimeEnum);
+	this->parameters->FindParam(&yts,ConstantsYtsEnum);
+	for(int month=0;month<12;month++){
+		for(int iv=0;iv<NUMVERTICES;iv++){
+			gauss->GaussVertex(iv);
+			input->GetInputValue(&t[iv][month],gauss,time+month/12*yts);
+			t[iv][month]=t[iv][month]-273.15; // conversion from Kelvin to celcius
+		}
+	}
 
    for(i=0;i<NUMVERTICES;i++)
      for(imonth=0;imonth<12;imonth++){

Modified: issm/trunk/src/c/objects/Inputs/BoolInput.h
===================================================================
--- issm/trunk/src/c/objects/Inputs/BoolInput.h	2012-05-29 18:25:53 UTC (rev 12298)
+++ issm/trunk/src/c/objects/Inputs/BoolInput.h	2012-05-29 20:58:10 UTC (rev 12299)
@@ -53,6 +53,7 @@
 		void GetInputValue(int* pvalue);
 		void GetInputValue(double* pvalue);
 		void GetInputValue(double* pvalue,GaussTria* gauss);
+		void GetInputValue(double* pvalue,GaussTria* gauss,double time){_error_("not implemented yet");};
 		void GetInputValue(double* pvalue,GaussPenta* gauss);
 		void GetInputValue(double* pvalue,GaussTria* gauss ,int index){_error_("not implemented yet");};
 		void GetInputValue(double* pvalue,GaussPenta* gauss ,int index){_error_("not implemented yet");};

Modified: issm/trunk/src/c/objects/Inputs/ControlInput.h
===================================================================
--- issm/trunk/src/c/objects/Inputs/ControlInput.h	2012-05-29 18:25:53 UTC (rev 12298)
+++ issm/trunk/src/c/objects/Inputs/ControlInput.h	2012-05-29 20:58:10 UTC (rev 12299)
@@ -58,6 +58,7 @@
 		void GetInputValue(int* pvalue);
 		void GetInputValue(double* pvalue);
 		void GetInputValue(double* pvalue,GaussTria* gauss);
+		void GetInputValue(double* pvalue,GaussTria* gauss,double time){_error_("not implemented yet");};
 		void GetInputValue(double* pvalue,GaussPenta* gauss);
 		void GetInputValue(double* pvalue,GaussTria* gauss ,int index){_error_("not implemented yet");};
 		void GetInputValue(double* pvalue,GaussPenta* gauss ,int index){_error_("not implemented yet");};

Modified: issm/trunk/src/c/objects/Inputs/DatasetInput.h
===================================================================
--- issm/trunk/src/c/objects/Inputs/DatasetInput.h	2012-05-29 18:25:53 UTC (rev 12298)
+++ issm/trunk/src/c/objects/Inputs/DatasetInput.h	2012-05-29 20:58:10 UTC (rev 12299)
@@ -53,6 +53,7 @@
 		void GetInputValue(int* pvalue){_error_("not implemented yet");};
 		void GetInputValue(double* pvalue){_error_("not implemented yet");};
 		void GetInputValue(double* pvalue,GaussTria* gauss){_error_("not implemented yet");};
+		void GetInputValue(double* pvalue,GaussTria* gauss,double time){_error_("not implemented yet");};
 		void GetInputValue(double* pvalue,GaussPenta* gauss){_error_("not implemented yet");};
 		void GetInputValue(double* pvalue,GaussTria* gauss ,int index);
 		void GetInputValue(double* pvalue,GaussPenta* gauss ,int index){_error_("not implemented yet");};

Modified: issm/trunk/src/c/objects/Inputs/DoubleInput.h
===================================================================
--- issm/trunk/src/c/objects/Inputs/DoubleInput.h	2012-05-29 18:25:53 UTC (rev 12298)
+++ issm/trunk/src/c/objects/Inputs/DoubleInput.h	2012-05-29 20:58:10 UTC (rev 12299)
@@ -52,6 +52,7 @@
 		void GetInputValue(int* pvalue);
 		void GetInputValue(double* pvalue);
 		void GetInputValue(double* pvalue,GaussTria* gauss);
+		void GetInputValue(double* pvalue,GaussTria* gauss,double time){_error_("not implemented yet");};
 		void GetInputValue(double* pvalue,GaussPenta* gauss);
 		void GetInputValue(double* pvalue,GaussTria* gauss ,int index){_error_("not implemented yet");};
 		void GetInputValue(double* pvalue,GaussPenta* gauss ,int index){_error_("not implemented yet");};

Modified: issm/trunk/src/c/objects/Inputs/Input.h
===================================================================
--- issm/trunk/src/c/objects/Inputs/Input.h	2012-05-29 18:25:53 UTC (rev 12298)
+++ issm/trunk/src/c/objects/Inputs/Input.h	2012-05-29 20:58:10 UTC (rev 12299)
@@ -26,6 +26,7 @@
 		virtual void GetInputValue(int* pvalue)=0;
 		virtual void GetInputValue(double* pvalue)=0;
 		virtual void GetInputValue(double* pvalue,GaussTria* gauss)=0;
+		virtual void GetInputValue(double* pvalue,GaussTria* gauss,double time)=0;
 		virtual void GetInputValue(double* pvalue,GaussPenta* gauss)=0;
 		virtual void GetInputValue(double* pvalue,GaussTria* gauss ,int index)=0;
 		virtual void GetInputValue(double* pvalue,GaussPenta* gauss,int index)=0;

Modified: issm/trunk/src/c/objects/Inputs/IntInput.h
===================================================================
--- issm/trunk/src/c/objects/Inputs/IntInput.h	2012-05-29 18:25:53 UTC (rev 12298)
+++ issm/trunk/src/c/objects/Inputs/IntInput.h	2012-05-29 20:58:10 UTC (rev 12299)
@@ -53,6 +53,7 @@
 		void GetInputValue(int* pvalue);
 		void GetInputValue(double* pvalue);
 		void GetInputValue(double* pvalue,GaussTria* gauss);
+		void GetInputValue(double* pvalue,GaussTria* gauss,double time){_error_("not implemented yet");};
 		void GetInputValue(double* pvalue,GaussPenta* gauss);
 		void GetInputValue(double* pvalue,GaussTria* gauss ,int index){_error_("not implemented yet");};
 		void GetInputValue(double* pvalue,GaussPenta* gauss ,int index){_error_("not implemented yet");};

Modified: issm/trunk/src/c/objects/Inputs/PentaP1Input.h
===================================================================
--- issm/trunk/src/c/objects/Inputs/PentaP1Input.h	2012-05-29 18:25:53 UTC (rev 12298)
+++ issm/trunk/src/c/objects/Inputs/PentaP1Input.h	2012-05-29 20:58:10 UTC (rev 12299)
@@ -53,6 +53,7 @@
 		void GetInputValue(int* pvalue){_error_("not implemented yet");};
 		void GetInputValue(double* pvalue){_error_("not implemented yet");};
 		void GetInputValue(double* pvalue,GaussTria* gauss){_error_("not implemented yet");};
+		void GetInputValue(double* pvalue,GaussTria* gauss,double time){_error_("not implemented yet");};
 		void GetInputValue(double* pvalue,GaussPenta* gauss);
 		void GetInputValue(double* pvalue,GaussTria* gauss ,int index){_error_("not implemented yet");};
 		void GetInputValue(double* pvalue,GaussPenta* gauss ,int index){_error_("not implemented yet");};

Modified: issm/trunk/src/c/objects/Inputs/TransientInput.cpp
===================================================================
--- issm/trunk/src/c/objects/Inputs/TransientInput.cpp	2012-05-29 18:25:53 UTC (rev 12298)
+++ issm/trunk/src/c/objects/Inputs/TransientInput.cpp	2012-05-29 20:58:10 UTC (rev 12299)
@@ -1,7 +1,7 @@
 /*!\file TransientInput.c
  * \brief: implementation of the TransientInput object
  */
-/*Headers{{{1*/
+/*Headers{{{*/
 #ifdef HAVE_CONFIG_H
 	#include <config.h>
 #else
@@ -18,7 +18,7 @@
 /*}}}*/
 
 /*TransientInput constructors and destructor*/
-/*FUNCTION TransientInput::TransientInput(){{{1*/
+/*FUNCTION TransientInput::TransientInput(){{{*/
 TransientInput::TransientInput(){
 
 	enum_type=UNDEF;
@@ -29,7 +29,7 @@
 
 }
 /*}}}*/
-/*FUNCTION TransientInput::TransientInput(int in_enum_type){{{1*/
+/*FUNCTION TransientInput::TransientInput(int in_enum_type){{{*/
 TransientInput::TransientInput(int in_enum_type)
 {
 	/*Set Enum*/
@@ -43,7 +43,7 @@
 
 }
 /*}}}*/
-/*FUNCTION TransientInput::~TransientInput{{{1*/
+/*FUNCTION TransientInput::~TransientInput{{{*/
 TransientInput::~TransientInput(){
 	xfree((void**)&this->timesteps);
 	this->timesteps=NULL;
@@ -53,43 +53,14 @@
 	return;
 }
 /*}}}*/
-/*FUNCTION void TransientInput::AddTimeInput(Input* input,double time){{{1*/
-void TransientInput::AddTimeInput(Input* input,double time){
 
-	/*insert values at time step: */
-	if (this->numtimesteps>0 && time<=this->timesteps[this->numtimesteps-1]) _assert_("timestep values must increase sequentially");
-
-	//copy timesteps, add the new time, delete previous timesteps, and add the new input: inputs->AddObject(input);
-   double* old_timesteps=NULL;
-
-	if (this->numtimesteps > 0){
-		old_timesteps=(double*)xmalloc(this->numtimesteps*sizeof(double));
-		memcpy(old_timesteps,this->timesteps,this->numtimesteps*sizeof(double));
-		xfree((void**)&this->timesteps); 
-	}
-
-	this->numtimesteps=this->numtimesteps+1;
-   this->timesteps=(double*)xmalloc(this->numtimesteps*sizeof(double));
-
-	if (this->numtimesteps > 1){
-		memcpy(this->timesteps,old_timesteps,(this->numtimesteps-1)*sizeof(double));
-		xfree((void**)&old_timesteps);
-	}
-
-	/*go ahead and plug: */
-	this->timesteps[this->numtimesteps-1]=time;
-	inputs->AddObject(input);
-
-}
-/*}}}*/
-
 /*Object virtual functions definitions:*/
-/*FUNCTION TransientInput::Echo {{{1*/
+/*FUNCTION TransientInput::Echo {{{*/
 void TransientInput::Echo(void){
 	this->DeepEcho();
 }
 /*}}}*/
-/*FUNCTION TransientInput::DeepEcho{{{1*/
+/*FUNCTION TransientInput::DeepEcho{{{*/
 void TransientInput::DeepEcho(void){
 
 	int i;
@@ -104,17 +75,17 @@
 	}
 }
 /*}}}*/
-/*FUNCTION TransientInput::Id{{{1*/
+/*FUNCTION TransientInput::Id{{{*/
 int    TransientInput::Id(void){ return -1; }
 /*}}}*/
-/*FUNCTION TransientInput::MyRank{{{1*/
+/*FUNCTION TransientInput::MyRank{{{*/
 int    TransientInput::MyRank(void){ 
 	extern int my_rank;
 	return my_rank; 
 }
 /*}}}*/
 #ifdef _SERIAL_
-/*FUNCTION TransientInput::Marshall{{{1*/
+/*FUNCTION TransientInput::Marshall{{{*/
 void  TransientInput::Marshall(char** pmarshalled_dataset){
 
 	char* marshalled_dataset=NULL;
@@ -148,7 +119,7 @@
 
 }
 /*}}}*
-/*FUNCTION TransientInput::MarshallSize{{{1*/
+/*FUNCTION TransientInput::MarshallSize{{{*/
 int   TransientInput::MarshallSize(){
 
 	return 
@@ -159,7 +130,7 @@
 		+sizeof(int); //sizeof(int) for enum value
 }
 /*}}}*/
-/*FUNCTION TransientInput::Demarshall{{{1*/
+/*FUNCTION TransientInput::Demarshall{{{*/
 void  TransientInput::Demarshall(char** pmarshalled_dataset){
 
 	char* marshalled_dataset=NULL;
@@ -186,14 +157,14 @@
 }
 /*}}}*/
 #endif
-/*FUNCTION TransientInput::ObjectEnum{{{1*/
+/*FUNCTION TransientInput::ObjectEnum{{{*/
 int TransientInput::ObjectEnum(void){
 
 	return TransientInputEnum;
 
 }
 /*}}}*/
-/*FUNCTION TransientInput::copy{{{1*/
+/*FUNCTION TransientInput::copy{{{*/
 Object* TransientInput::copy() {
 
 	TransientInput* output=NULL;
@@ -212,14 +183,14 @@
 /*}}}*/
 	
 /*TransientInput management*/
-/*FUNCTION TransientInput::InstanceEnum{{{1*/
+/*FUNCTION TransientInput::InstanceEnum{{{*/
 int TransientInput::InstanceEnum(void){
 
 	return this->enum_type;
 
 }
 /*}}}*/
-/*FUNCTION TransientInput::SpawnTriaInput{{{1*/
+/*FUNCTION TransientInput::SpawnTriaInput{{{*/
 Input* TransientInput::SpawnTriaInput(int* indices){
 
 	/*output*/
@@ -239,7 +210,7 @@
 
 }
 /*}}}*/
-/*FUNCTION TransientInput::SpawnResult{{{1*/
+/*FUNCTION TransientInput::SpawnResult{{{*/
 ElementResult* TransientInput::SpawnResult(int step, double time){
 
 	ElementResult* elementresult=NULL;
@@ -257,9 +228,8 @@
 /*}}}*/
 
 /*Object functions*/
-/*FUNCTION TransientInput::GetInputValue(double* pvalue,GaussTria* gauss){{{1*/
+/*FUNCTION TransientInput::GetInputValue(double* pvalue,GaussTria* gauss){{{*/
 void TransientInput::GetInputValue(double* pvalue,GaussTria* gauss){
-	
 	double time;
 
 	/*First, recover current time from parameters: */
@@ -272,10 +242,21 @@
 	input->GetInputValue(pvalue,gauss);
 
 	delete input;
+}
+/*}}}*/
+/*FUNCTION TransientInput::GetInputValue(double* pvalue,GaussTria* gauss,double time){{{*/
+void TransientInput::GetInputValue(double* pvalue,GaussTria* gauss,double time){
 
+	/*Retrieve interpolated values for this time step: */
+	Input* input=GetTimeInput(time);
+
+	/*Call input function*/
+	input->GetInputValue(pvalue,gauss);
+
+	delete input;
 }
 /*}}}*/
-/*FUNCTION TransientInput::GetInputDerivativeValue(double* p, double* xyz_list, GaussTria* gauss){{{1*/
+/*FUNCTION TransientInput::GetInputDerivativeValue(double* p, double* xyz_list, GaussTria* gauss){{{*/
 void TransientInput::GetInputDerivativeValue(double* p, double* xyz_list, GaussTria* gauss){
 
 	double time;
@@ -293,12 +274,12 @@
 
 }
 /*}}}*/
-/*FUNCTION TransientInput::ChangeEnum{{{1*/
+/*FUNCTION TransientInput::ChangeEnum{{{*/
 void TransientInput::ChangeEnum(int newenumtype){
 	this->enum_type=newenumtype;
 }
 /*}}}*/
-/*FUNCTION TransientInput::GetInputAverage{{{1*/
+/*FUNCTION TransientInput::GetInputAverage{{{*/
 void TransientInput::GetInputAverage(double* pvalue){
 	
 	double time;
@@ -318,7 +299,36 @@
 /*}}}*/
 
 /*Intermediary*/
-/*FUNCTION TransientInput::SquareMin{{{1*/
+/*FUNCTION TransientInput::AddTimeInput{{{*/
+void TransientInput::AddTimeInput(Input* input,double time){
+
+	/*insert values at time step: */
+	if (this->numtimesteps>0 && time<=this->timesteps[this->numtimesteps-1]) _assert_("timestep values must increase sequentially");
+
+	//copy timesteps, add the new time, delete previous timesteps, and add the new input: inputs->AddObject(input);
+	double* old_timesteps=NULL;
+
+	if (this->numtimesteps > 0){
+		old_timesteps=(double*)xmalloc(this->numtimesteps*sizeof(double));
+		memcpy(old_timesteps,this->timesteps,this->numtimesteps*sizeof(double));
+		xfree((void**)&this->timesteps); 
+	}
+
+	this->numtimesteps=this->numtimesteps+1;
+	this->timesteps=(double*)xmalloc(this->numtimesteps*sizeof(double));
+
+	if (this->numtimesteps > 1){
+		memcpy(this->timesteps,old_timesteps,(this->numtimesteps-1)*sizeof(double));
+		xfree((void**)&old_timesteps);
+	}
+
+	/*go ahead and plug: */
+	this->timesteps[this->numtimesteps-1]=time;
+	inputs->AddObject(input);
+
+}
+/*}}}*/
+/*FUNCTION TransientInput::SquareMin{{{*/
 void TransientInput::SquareMin(double* psquaremin, bool process_units,Parameters* parameters){
 
 	double time;
@@ -336,7 +346,7 @@
 
 }
 /*}}}*/
-/*FUNCTION TransientInput::InfinityNorm{{{1*/
+/*FUNCTION TransientInput::InfinityNorm{{{*/
 double TransientInput::InfinityNorm(void){
 
 	double time;
@@ -356,7 +366,7 @@
 	return infnorm;
 }
 /*}}}*/
-/*FUNCTION TransientInput::Max{{{1*/
+/*FUNCTION TransientInput::Max{{{*/
 double TransientInput::Max(void){
 
 	double time;
@@ -376,7 +386,7 @@
 	return max;
 }
 /*}}}*/
-/*FUNCTION TransientInput::MaxAbs{{{1*/
+/*FUNCTION TransientInput::MaxAbs{{{*/
 double TransientInput::MaxAbs(void){
 
 	double time;
@@ -397,7 +407,7 @@
 
 }
 /*}}}*/
-/*FUNCTION TransientInput::Min{{{1*/
+/*FUNCTION TransientInput::Min{{{*/
 double TransientInput::Min(void){
 
 	double time;
@@ -418,7 +428,7 @@
 
 }
 /*}}}*/
-/*FUNCTION TransientInput::MinAbs{{{1*/
+/*FUNCTION TransientInput::MinAbs{{{*/
 double TransientInput::MinAbs(void){
 
 	double time;
@@ -438,7 +448,7 @@
 	return minabs;
 }
 /*}}}*/
-/*FUNCTION TransientInput::GetVectorFromInputs{{{1*/
+/*FUNCTION TransientInput::GetVectorFromInputs{{{*/
 void TransientInput::GetVectorFromInputs(Vector* vector,int* doflist){
 
 	double time;
@@ -455,7 +465,7 @@
 	delete input;
 
 } /*}}}*/
-/*FUNCTION TransientInput::GetTimeInput{{{1*/
+/*FUNCTION TransientInput::GetTimeInput{{{*/
 Input* TransientInput::GetTimeInput(double intime){
 
 	int     i,j;
@@ -514,7 +524,7 @@
 	return input;
 }
 /*}}}*/
-/*FUNCTION TransientInput::Configure{{{1*/
+/*FUNCTION TransientInput::Configure{{{*/
 void TransientInput::Configure(Parameters* parameters){
 	this->parameters=parameters;
 }

Modified: issm/trunk/src/c/objects/Inputs/TransientInput.h
===================================================================
--- issm/trunk/src/c/objects/Inputs/TransientInput.h	2012-05-29 18:25:53 UTC (rev 12298)
+++ issm/trunk/src/c/objects/Inputs/TransientInput.h	2012-05-29 20:58:10 UTC (rev 12299)
@@ -55,6 +55,7 @@
 		void GetInputValue(int* pvalue){_error_("not implemented yet");};
 		void GetInputValue(double* pvalue){_error_("not implemented yet");};
 		void GetInputValue(double* pvalue,GaussTria* gauss);
+		void GetInputValue(double* pvalue,GaussTria* gauss,double time);
 		void GetInputValue(double* pvalue,GaussPenta* gauss){_error_("not implemented yet");};
 		void GetInputValue(double* pvalue,GaussTria* gauss ,int index){_error_("not implemented yet");};
 		void GetInputValue(double* pvalue,GaussPenta* gauss ,int index){_error_("not implemented yet");};

Modified: issm/trunk/src/c/objects/Inputs/TriaP1Input.h
===================================================================
--- issm/trunk/src/c/objects/Inputs/TriaP1Input.h	2012-05-29 18:25:53 UTC (rev 12298)
+++ issm/trunk/src/c/objects/Inputs/TriaP1Input.h	2012-05-29 20:58:10 UTC (rev 12299)
@@ -53,6 +53,7 @@
 		void GetInputValue(int* pvalue){_error_("not implemented yet");}
 		void GetInputValue(double* pvalue){_error_("not implemented yet");}
 		void GetInputValue(double* pvalue,GaussTria* gauss);
+		void GetInputValue(double* pvalue,GaussTria* gauss,double time){_error_("not implemented yet");};
 		void GetInputValue(double* pvalue,GaussPenta* gauss){_error_("not implemented yet");};
 		void GetInputValue(double* pvalue,GaussTria* gauss ,int index){_error_("not implemented yet");};
 		void GetInputValue(double* pvalue,GaussPenta* gauss,int index){_error_("not implemented yet");};



More information about the issm-svn mailing list