Index: /issm/trunk/src/c/DataSet/DataSet.h
===================================================================
--- /issm/trunk/src/c/DataSet/DataSet.h	(revision 4036)
+++ /issm/trunk/src/c/DataSet/DataSet.h	(revision 4037)
@@ -92,10 +92,8 @@
 
 
+/********************************************************INPUT************************************************/
 
-/********************************************************INPUTS************************************************/
 class Input;
 class Node;
-#include "./DataSet.h"
-#include "../objects/objects.h"
 
 class Inputs: public DataSet{
@@ -139,4 +137,6 @@
 
 
+
+
 /********************************************************PARAMETERS************************************************/
 
@@ -165,4 +165,5 @@
 };
 
+
 /********************************************************RESULTS************************************************/
 
@@ -176,7 +177,8 @@
 		~Results();
 		/*}}}*/
-		/*methods: {{{1*/
-		int   FindResult(Vec* presult,char* name);
-		int   FindResult(void* pvalue, char* name);
+		/*numerics: {{{1*/
+		Results* SpawnTriaResults(int* indices);
+		Results* SpawnBeamResults(int* indices);
+		Results* SpawnSingResults(int  index  );
 		/*}}}*/
 
@@ -184,3 +186,4 @@
 
 
+
 #endif
Index: /issm/trunk/src/c/DataSet/Results.cpp
===================================================================
--- /issm/trunk/src/c/DataSet/Results.cpp	(revision 4036)
+++ /issm/trunk/src/c/DataSet/Results.cpp	(revision 4037)
@@ -31,5 +31,5 @@
 /*}}}*/
 /*FUNCTION Results::Results(int in_enum){{{1*/
-Results::Results(int in_enum): DataSet(in_enum){
+Results::Results(int in_enum): DataSet(in_enum) {
 	//do nothing;
 	return;
@@ -42,65 +42,81 @@
 /*}}}*/
 
-/*Object methods*/
-/*FUNCTION Results::FindResult(Vec* presult,char* name){{{1*/
-int   Results::FindResult(Vec* presult,char* name){
+/*Object management*/
+/*FUNCTION Results::SpawnBeamResults{{{1*/
+Results* Results::SpawnBeamResults(int* indices){
 
-	/*Go through a dataset, and find a Result* object 
-	 *whith result name is "name" : */
-	
+	/*Intermediary*/
 	vector<Object*>::iterator object;
-	Result* result=NULL;
+	Result* resultin=NULL;
+	Result* resultout=NULL;
 
-	int found=0;
+	/*Output*/
+	Results* newresults=new Results();
 
+	/*Go through results and call Spawn function*/
 	for ( object=objects.begin() ; object < objects.end(); object++ ){
 
-		/*Find param type objects: */
-		if((*object)->Enum()==ResultEnum){
+		/*Create new result*/
+		resultin=(Result*)(*object); 
+		resultout=resultin->SpawnBeamResult(indices);
 
-			/*Ok, this object is a result,recover it and ask which name it has: */
-			result=(Result*)(*object);
+		/*Add result to new results*/
+		newresults->AddObject(resultout);
+	}
 
-			if (strcmp(result->GetFieldName(),name)==0){
-				/*Ok, this is the one! Recover the value of this result: */
-				result->GetField(presult);
-				found=1;
-				break;
-			}
-		}
-	}
-	return found;
+	/*Assign output pointer*/
+	return newresults;
 }
 /*}}}*/
-/*FUNCTION Results::FindResult(void* pvalue, char* name){{{1*/
-int   Results::FindResult(void* pvalue, char* name){
+/*FUNCTION Results::SpawnSingResults{{{1*/
+Results* Results::SpawnSingResults(int index){
 
-	/*Go through a dataset, and find a Result* object 
-	 *which field name is "name" : */
-	
+	/*Intermediary*/
 	vector<Object*>::iterator object;
-	Result* result=NULL;
+	Result* resultin=NULL;
+	Result* resultout=NULL;
 
-	int found=0;
+	/*Output*/
+	Results* newresults=new Results();
 
+	/*Go through results and call Spawn function*/
 	for ( object=objects.begin() ; object < objects.end(); object++ ){
 
-		/*Find param type objects: */
-		if((*object)->Enum()==ResultEnum){
+		/*Create new result*/
+		resultin=(Result*)(*object); 
+		resultout=resultin->SpawnSingResult(index);
 
-			/*Ok, this object is a result, recover it and ask which name it has: */
-			result=(Result*)(*object);
+		/*Add result to new results*/
+		newresults->AddObject(resultout);
+	}
 
-			if (strcmp(result->GetFieldName(),name)==0){
-				/*Ok, this is the one! Recover the value of this result: */
-				double** field=NULL;
-				field=(double**)pvalue; //not very safe, but hey!
-				result->GetField(field);
-				found=1;
-				break;
-			}
-		}
-	}
-	return found;
+	/*Assign output pointer*/
+	return newresults;
 }
 /*}}}*/
+/*FUNCTION Results::SpawnTriaResults{{{1*/
+Results* Results::SpawnTriaResults(int* indices){
+
+	/*Intermediary*/
+	vector<Object*>::iterator object;
+	Result* resultin=NULL;
+	Result* resultout=NULL;
+
+	/*Output*/
+	Results* newresults=new Results();
+
+	/*Go through results and call Spawn function*/
+	for ( object=objects.begin() ; object < objects.end(); object++ ){
+
+		/*Create new result*/
+		resultin=(Result*)(*object); 
+		resultout=resultin->SpawnTriaResult(indices);
+
+		/*Add result to new results*/
+		newresults->AddObject(resultout);
+	}
+
+	/*Assign output pointer*/
+	return newresults;
+}
+/*}}}*/
Index: /issm/trunk/src/c/EnumDefinitions/EnumDefinitions.h
===================================================================
--- /issm/trunk/src/c/EnumDefinitions/EnumDefinitions.h	(revision 4036)
+++ /issm/trunk/src/c/EnumDefinitions/EnumDefinitions.h	(revision 4037)
@@ -235,7 +235,7 @@
 	/*}}}*/
 	/*Results{{{1*/
-	StringResultEnum,
-	DoubleVecResultEnum,
-	DoubleMatResultEnum,
+	DoubleResultEnum,
+	TriaVertexResultEnum,
+	PentaVertexResultEnum,
 	/*}}}*/
 	/*Parameters{{{1*/
Index: /issm/trunk/src/c/Makefile.am
===================================================================
--- /issm/trunk/src/c/Makefile.am	(revision 4036)
+++ /issm/trunk/src/c/Makefile.am	(revision 4037)
@@ -103,11 +103,10 @@
 					./objects/Node.h\
 					./objects/Node.cpp\
-					./objects/Results/Result.h\
-					./objects/Results/DoubleVecResult.h\
-					./objects/Results/DoubleVecResult.cpp\
-					./objects/Results/DoubleMatResult.h\
-					./objects/Results/DoubleMatResult.cpp\
-					./objects/Results/StringResult.h\
-					./objects/Results/StringResult.cpp\
+					./objects/Results/DoubleResults.h\
+					./objects/Results/DoubleResults.cpp\
+					./objects/Results/TriaVertexResults.h\
+					./objects/Results/TriaVertexResults.cpp\
+					./objects/Results/PentaVertexResults.h\
+					./objects/Results/PentaVertexResults.cpp\
 					./objects/Elements/Tria.h\
 					./objects/Elements/Tria.cpp\
@@ -471,6 +470,4 @@
 					./modules/InputToResultx/InputToResultx.cpp\
 					./modules/InputToResultx/InputToResultx.h\
-					./modules/InputToResultx/PatchesSize.cpp\
-					./modules/InputToResultx/InputToPatches.cpp\
 					./modules/ExtrudeInputx/ExtrudeInputx.cpp\
 					./modules/ExtrudeInputx/ExtrudeInputx.h\
@@ -574,11 +571,10 @@
 					./objects/Hook.h\
 					./objects/Hook.cpp\
-					./objects/Results/Result.h\
-					./objects/Results/DoubleVecResult.h\
-					./objects/Results/DoubleVecResult.cpp\
-					./objects/Results/DoubleMatResult.h\
-					./objects/Results/DoubleMatResult.cpp\
-					./objects/Results/StringResult.h\
-					./objects/Results/StringResult.cpp\
+					./objects/Results/DoubleResults.h\
+					./objects/Results/DoubleResults.cpp\
+					./objects/Results/TriaVertexResults.h\
+					./objects/Results/TriaVertexResults.cpp\
+					./objects/Results/PentaVertexResults.h\
+					./objects/Results/PentaVertexResults.cpp\
 					./objects/Elements/Tria.h\
 					./objects/Elements/Tria.cpp\
@@ -935,6 +931,4 @@
 					./modules/InputToResultx/InputToResultx.cpp\
 					./modules/InputToResultx/InputToResultx.h\
-					./modules/InputToResultx/PatchesSize.cpp\
-					./modules/InputToResultx/InputToPatches.cpp\
 					./modules/ExtrudeInputx/ExtrudeInputx.cpp\
 					./modules/ExtrudeInputx/ExtrudeInputx.h\
Index: /issm/trunk/src/c/modules/InputToResultx/InputToResultx.cpp
===================================================================
--- /issm/trunk/src/c/modules/InputToResultx/InputToResultx.cpp	(revision 4037)
+++ /issm/trunk/src/c/modules/InputToResultx/InputToResultx.cpp	(revision 4037)
@@ -0,0 +1,29 @@
+/*!\file InputToResultx
+ * \brief: transfer an input to the results  dataset inside the elements
+ */
+
+#include "./InputToResultx.h"
+
+#include "../../shared/shared.h"
+#include "../../include/include.h"
+#include "../../toolkits/toolkits.h"
+#include "../../EnumDefinitions/EnumDefinitions.h"
+
+void InputToResultx(DataSet* elements,DataSet* nodes,DataSet* vertices,DataSet* loads,DataSet* materials,Parameters* parameters,int enum_type,int step=1, double time=0){
+
+	/*intermediary:*/
+	int      i;
+	Element *element = NULL;
+
+	/*First, get elements and nodes configured: */
+	elements->Configure(elements,loads, nodes,vertices, materials,parameters);
+
+	/*Go through elemnets, and ask each element to transfer the enum_type input into the results dataset, with step and time information: */
+	 
+	for(i=0;i<elements->Size();i++){
+
+		element=(Element*)elements->GetObjectByOffset(i);
+		element->InputToResult(enum_type,step,time);
+	}
+
+}
Index: /issm/trunk/src/c/modules/InputToResultx/InputToResultx.h
===================================================================
--- /issm/trunk/src/c/modules/InputToResultx/InputToResultx.h	(revision 4037)
+++ /issm/trunk/src/c/modules/InputToResultx/InputToResultx.h	(revision 4037)
@@ -0,0 +1,14 @@
+/*!\file:  InputToResultx.h
+ * \brief header file for field extrusion
+ */ 
+
+#ifndef _INPUTTORESULTX_H
+#define _INPUTTORESULTX_H
+
+#include "../../DataSet/DataSet.h"
+
+/* local prototypes: */
+void InputToResultx(DataSet* elements,DataSet* nodes,DataSet* vertices,DataSet* loads,DataSet* materials,Parameters* parameters,int enum_type,int step=1, double time=0);
+
+#endif  /* _INPUTTORESULTX_H */
+
Index: /issm/trunk/src/c/modules/OutputResultsx/InputToResultx/InputToPatches.cpp
===================================================================
--- /issm/trunk/src/c/modules/OutputResultsx/InputToResultx/InputToPatches.cpp	(revision 4037)
+++ /issm/trunk/src/c/modules/OutputResultsx/InputToResultx/InputToPatches.cpp	(revision 4037)
@@ -0,0 +1,35 @@
+/*!\file:  InputsToPatches.cpp
+ * \brief  fill patches from inputs
+ */ 
+
+#ifdef HAVE_CONFIG_H
+	#include "config.h"
+#else
+#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
+#endif
+
+#undef __FUNCT__ 
+#define __FUNCT__ "InputsToPatches"
+
+#include "./InputToResultx.h"
+#include "../../DataSet/DataSet.h"
+
+void InputToPatches(DataSet* elements,double* patches,int patch_numcols,int max_vertices,int enum_type){
+
+	int i;
+
+	/*intermediary:*/
+	Element* element=NULL;
+	int count=0;
+
+	/*Go through elemnets, and each time an element holds an input with the correct enum_type, increase count by 1, and fill the 
+	 * patches matrix with the input data: */
+	 
+	for(i=0;i<elements->Size();i++){
+
+		element=(Element*)elements->GetObjectByOffset(i);
+		element->PatchFill(&count,patches,patch_numcols,max_vertices,enum_type);
+
+	}
+
+}
Index: /issm/trunk/src/c/modules/OutputResultsx/InputToResultx/InputToResultx.cpp
===================================================================
--- /issm/trunk/src/c/modules/OutputResultsx/InputToResultx/InputToResultx.cpp	(revision 4037)
+++ /issm/trunk/src/c/modules/OutputResultsx/InputToResultx/InputToResultx.cpp	(revision 4037)
@@ -0,0 +1,73 @@
+/*!\file InputToResultx
+ * \brief: average field throfieldh thickness
+ */
+
+#include "./InputToResultx.h"
+
+#include "../../shared/shared.h"
+#include "../../objects/objects.h"
+#include "../../include/include.h"
+#include "../../toolkits/toolkits.h"
+#include "../../EnumDefinitions/EnumDefinitions.h"
+
+void InputToResultx(Result** presult,DataSet* elements,DataSet* nodes, DataSet* vertices, DataSet* loads, DataSet* materials,Parameters* parameters,int enum_type,int id, double time, int step){
+
+	/*We are going to extract from the inputs, the results desired, and create a table 
+	 * of patch information, that will hold, for each element that computed the result that 
+	 * we desire, the id of the element, the interpolation type, the vertices ids, and the values 
+	 * at the nodes (could be different from the vertices). This will be used for visualization purposed. 
+	 * For example, we could build the following patch table, for velocities: 
+	 * 
+	 * 1 P0  1 2       4.5 NaN  NaN (constant on a beam element)
+	 * 2 P1  1 3 4     4.5 3.2  2.5  (linear values on a tria element)
+	 * 3 P0  1 5 4     5.5 NaN  NaN  (contant on a tria element)
+	 * ... etc ...
+	 *
+	 * So what do we need to build the table: the maximum number of vertices included in the table, 
+	 * and the maximum number of nodal values, as well as the number of rows. Once we have that, 
+	 * we ask the elements to fill their own row in the table, by looping on the elememnts.
+	 * Finally, we include the table in a Result object, that will be used by the OutputResults 
+	 * module to write to disk: */
+
+	int i,j,count;
+
+	/*output: */
+	Result* result=NULL;
+
+	/*Intermediary output vector*/
+	double* patches=NULL; //build a matrix of patch information, corresponding to the input with  name enum_type
+	int     patch_numrows,patch_numcols;
+	int     max_vertices;
+	int     max_nodes;
+
+	/*First, get elements*/
+	elements->Configure(elements,loads, nodes,vertices, materials,parameters);
+
+	/*Figure out size of patches matrix: */
+	PatchesSize(elements,&patch_numrows, &max_vertices, &max_nodes, enum_type);
+
+	patch_numcols=1+ //element id
+		          1+ //interpolation type
+				  max_vertices+ //vertices
+				  max_nodes; //values+
+
+	/*Allocate matrix: */
+	patches=(double*)xmalloc(patch_numrows*patch_numcols*sizeof(double));
+
+	/*Fill patches with NaN, default value: */
+	for(i=0;i<patch_numrows;i++){
+		for(j=0;j<patch_numcols;j++){
+			*(patches+patch_numcols*i+j)=NAN;
+		}
+	}
+
+	/*Now, go through elements, their inputs with the correct enum_type, and fill the patches: */
+	InputToPatches(elements,patches,patch_numrows,max_vertices,enum_type); 
+
+	/*Create result object embedding patches: */
+	result=new DoubleMatResult(id,enum_type,time,step,patches,patch_numrows,patch_numcols);
+
+	/*Assign output pointer*/
+	*presult=result;
+
+}
Index: /issm/trunk/src/c/modules/OutputResultsx/InputToResultx/InputToResultx.h
===================================================================
--- /issm/trunk/src/c/modules/OutputResultsx/InputToResultx/InputToResultx.h	(revision 4037)
+++ /issm/trunk/src/c/modules/OutputResultsx/InputToResultx/InputToResultx.h	(revision 4037)
@@ -0,0 +1,17 @@
+/*!\file:  InputToResultx.h
+ * \brief header file for averaging a field throfieldh thickness
+ */ 
+
+#ifndef _INPUTTORESULTX_H
+#define _INPUTTORESULTX_H
+
+#include "../../DataSet/DataSet.h"
+
+/* global prototype: */
+void InputToResultx(Result** presult,DataSet* elements,DataSet* nodes, DataSet* vertices, DataSet* loads, DataSet* materials,Parameters* parameters,int enum_type,int id, double time, int step);
+
+/* local prototypes: */
+void PatchesSize(DataSet* elements,int* pnumrows, int* pnumvertices, int* pnumnodes,int enum_type);
+void InputToPatches(DataSet* elements,double* patches,int numcols, int max_vertices, int enum_type);
+
+#endif  /* _INPUTTORESULTX_H */
Index: /issm/trunk/src/c/modules/OutputResultsx/InputToResultx/PatchesSize.cpp
===================================================================
--- /issm/trunk/src/c/modules/OutputResultsx/InputToResultx/PatchesSize.cpp	(revision 4037)
+++ /issm/trunk/src/c/modules/OutputResultsx/InputToResultx/PatchesSize.cpp	(revision 4037)
@@ -0,0 +1,54 @@
+/*!\file:  PatchesSize.cpp
+ * \brief  determine size of patches from inputs
+ */ 
+
+#ifdef HAVE_CONFIG_H
+	#include "config.h"
+#else
+#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
+#endif
+
+#undef __FUNCT__ 
+#define __FUNCT__ "PatchesSize"
+
+#include "./InputToResultx.h"
+#include "../../DataSet/DataSet.h"
+
+void PatchesSize(DataSet* elements,int* pnumrows, int* pnumvertices, int* pnumnodes,int enum_type){
+
+	int i;
+
+	/*output: */
+	int numrows;
+	int numvertices;
+	int numnodes;
+
+	/*intermediary:*/
+	Element* element=NULL;
+	int element_numvertices;
+	int element_numnodes;
+	
+	/*Go through elemnets, and each time an element holds an input with the correct enum_type, increase numrows by 1. At the 
+	 * same time, retrieve number of vertices this element holds, as well as number of nodes the input holds values for. 
+	 * Update the values of numvertices and numnodes to be the max of all the input numvertices and numnodes:*/
+	
+	numrows=0;
+	numvertices=0;
+	numnodes=0;
+
+	for(i=0;i<elements->Size();i++){
+
+		element=(Element*)elements->GetObjectByOffset(i);
+		element->PatchSize(&numrows,&element_numvertices,&element_numnodes,enum_type);
+		
+		if(element_numvertices>numvertices)numvertices=element_numvertices;
+		if(element_numnodes>numnodes)numnodes=element_numnodes;
+
+	}
+
+	/*Assign output pointers:*/
+	*pnumrows=numrows;
+	*pnumvertices=numvertices;
+	*pnumnodes=numnodes;
+}
+
Index: /issm/trunk/src/c/modules/UpdateInputsFromSolutionx/UpdateInputsFromSolutionx.cpp
===================================================================
--- /issm/trunk/src/c/modules/UpdateInputsFromSolutionx/UpdateInputsFromSolutionx.cpp	(revision 4036)
+++ /issm/trunk/src/c/modules/UpdateInputsFromSolutionx/UpdateInputsFromSolutionx.cpp	(revision 4037)
@@ -9,5 +9,5 @@
 #include "../../EnumDefinitions/EnumDefinitions.h"
 
-void UpdateInputsFromSolutionx( DataSet* elements,DataSet* nodes, DataSet* vertices, DataSet* loads, DataSet* materials, Parameters* parameters,Vec solution, int analysis_type, int sub_analysis_type){
+void UpdateInputsFromSolutionx( DataSet* elements,DataSet* nodes, DataSet* vertices, DataSet* loads, DataSet* materials, Parameters* parameters,Vec solution, int analysis_type, int sub_analysis_type,int step=0){
 
 	double* serial_solution=NULL;
@@ -17,5 +17,5 @@
 
 	/*Call overloaded form of UpdateInputsFromSolutionx: */
-	UpdateInputsFromSolutionx( elements, nodes,  vertices,  loads,  materials,  parameters,serial_solution, analysis_type, sub_analysis_type);
+	UpdateInputsFromSolutionx( elements, nodes,  vertices,  loads,  materials,  parameters,serial_solution, analysis_type, sub_analysis_type,step);
 
 	/*Free ressources:*/
@@ -44,2 +44,41 @@
 
 }
+
+/*Same routines, with additional timestep argument: */
+void UpdateInputsFromSolutionx( DataSet* elements,DataSet* nodes, DataSet* vertices, DataSet* loads, DataSet* materials, Parameters* parameters,Vec solution, int analysis_type, int sub_analysis_type,int timestep){
+	
+	
+	double* serial_solution=NULL;
+
+	/*Serialize solution, so that elements can index into it on every CPU: */
+	VecToMPISerial(&serial_solution,solution);
+
+	/*Call overloaded form of UpdateInputsFromSolutionx: */
+	UpdateInputsFromSolutionx( elements, nodes,  vertices,  loads,  materials,  parameters,serial_solution, analysis_type, sub_analysis_type,int timestep);
+
+	/*Free ressources:*/
+	xfree((void**)&serial_solution);
+
+}
+
+
+
+void UpdateInputsFromSolutionx( DataSet* elements,DataSet* nodes, DataSet* vertices, DataSet* loads, DataSet* materials, Parameters* parameters,double* solution, int analysis_type, int sub_analysis_type,int timestep){
+
+	/*Intermediary*/
+	int i;
+	Element* element=NULL;
+
+	/*First, get elements and loads configured: */
+	elements->  Configure(elements,loads, nodes,vertices, materials,parameters);
+	loads->     Configure(elements,loads, nodes,vertices, materials,parameters);
+	nodes->     Configure(elements,loads, nodes,vertices, materials,parameters);
+	parameters->Configure(elements,loads, nodes,vertices, materials,parameters);
+	
+	/*Elements drive the update: */
+	for (i=0;i<elements->Size();i++){
+		element=(Element*)elements->GetObjectByOffset(i);
+		element->UpdateInputsFromSolution(solution,analysis_type,sub_analysis_type,timestep);
+	}
+
+}
Index: /issm/trunk/src/c/modules/UpdateInputsFromSolutionx/UpdateInputsFromSolutionx.h
===================================================================
--- /issm/trunk/src/c/modules/UpdateInputsFromSolutionx/UpdateInputsFromSolutionx.h	(revision 4036)
+++ /issm/trunk/src/c/modules/UpdateInputsFromSolutionx/UpdateInputsFromSolutionx.h	(revision 4037)
@@ -13,4 +13,8 @@
 void        UpdateInputsFromSolutionx( DataSet* elements,DataSet* nodes, DataSet* vertices, DataSet* loads, DataSet* materials, Parameters* parameters,double* solution, int analysis_type, int sub_analysis_type);
 
+//with timestep
+void		UpdateInputsFromSolutionx( DataSet* elements,DataSet* nodes, DataSet* vertices,DataSet* loads, DataSet* materials,  Parameters* parameters,Vec solution, int analysis_type, int sub_analysis_type,int timestep);
+void        UpdateInputsFromSolutionx( DataSet* elements,DataSet* nodes, DataSet* vertices, DataSet* loads, DataSet* materials, Parameters* parameters,double* solution, int analysis_type, int sub_analysis_type,int timestep);
+
 #endif  /* _UPDATEINPUTSFROMSOLUTIONXX_H */
 
Index: /issm/trunk/src/c/objects/Elements/Beam.cpp
===================================================================
--- /issm/trunk/src/c/objects/Elements/Beam.cpp	(revision 4036)
+++ /issm/trunk/src/c/objects/Elements/Beam.cpp	(revision 4037)
@@ -137,4 +137,9 @@
 /*FUNCTION Beam::GetSolutionFromInputs(Vec solution,  int analysis_type,int sub_analysis_type);{{{1*/
 void  Beam::GetSolutionFromInputs(Vec solution,  int analysis_type,int sub_analysis_type){
+	ISSMERROR(" not supported yet!");
+}
+/*}}}*/
+/*FUNCTION Beam::InputToResult(int enum_type,int step,double time){{{1*/
+void  Beam::InputToResult(int enum_type,int step,double time){
 	ISSMERROR(" not supported yet!");
 }
Index: /issm/trunk/src/c/objects/Elements/Beam.h
===================================================================
--- /issm/trunk/src/c/objects/Elements/Beam.h	(revision 4036)
+++ /issm/trunk/src/c/objects/Elements/Beam.h	(revision 4037)
@@ -61,8 +61,7 @@
 		void  UpdateInputsFromConstant(int constant, int name){ISSMERROR("Not implemented yet!");}
 		void  UpdateInputsFromConstant(bool constant, int name){ISSMERROR("Not implemented yet!");}
-
 		void  UpdateInputsFromSolution(double* solution, int analysis_type, int sub_analysis_type);
-
-		void   DepthAverageInputAtBase(int enum_type){ISSMERROR("not implemented yet");};
+		void  DepthAverageInputAtBase(int enum_type){ISSMERROR("not implemented yet");};
+		void  InputToResult(int enum_type,int step,double time);
 		/*}}}*/
 		/*numerics: {{{1*/
Index: /issm/trunk/src/c/objects/Elements/Element.h
===================================================================
--- /issm/trunk/src/c/objects/Elements/Element.h	(revision 4036)
+++ /issm/trunk/src/c/objects/Elements/Element.h	(revision 4037)
@@ -50,4 +50,5 @@
 		virtual void   PatchFill(int* pcount, double* patches,int numcols,int max_vertices,int enum_type)=0;
 		virtual void   Update(int index, IoModel* iomodel,int analysis_counter,int analysis_type)=0;
+		virtual void   InputToResult(int enum_type,int step,double time);
 
 		/*Implementation: */
Index: /issm/trunk/src/c/objects/Elements/Penta.cpp
===================================================================
--- /issm/trunk/src/c/objects/Elements/Penta.cpp	(revision 4036)
+++ /issm/trunk/src/c/objects/Elements/Penta.cpp	(revision 4037)
@@ -30,4 +30,5 @@
 	
 	this->inputs=NULL;
+	this->results=NULL;
 	this->parameters=NULL;
 }
@@ -36,4 +37,5 @@
 Penta::~Penta(){
 	delete inputs;
+	delete results;
 	this->parameters=NULL;
 	xfree((void**)&collapse);
@@ -77,4 +79,8 @@
 	this->parameters=NULL;
 
+	/*intialize inputs and results: */
+	this->inputs=new Inputs();
+	this->results=new Results();
+
 	//collpase flags
 	collapse=(bool*)xcalloc(nummodels,sizeof(bool));
@@ -109,6 +115,5 @@
 	this->SetHookNodes(penta_node_ids,analysis_counter); this->nodes=NULL; //set hook to nodes, for this analysis type
 
-	//intialize inputs, and add as many inputs per element as requested: 
-	this->inputs=new Inputs();
+	//add as many inputs per element as requested: 
 	if (iomodel->thickness) {
 		for(i=0;i<6;i++)nodeinputs[i]=iomodel->thickness[penta_vertex_ids[i]-1];
@@ -241,4 +246,10 @@
 		penta->inputs=new Inputs();
 	}
+	if(this->results){
+		penta->results=(Results*)this->results->Copy();
+	}
+	else{
+		penta->results=new Results();
+	}
 	/*point parameters: */
 	penta->parameters=this->parameters;
@@ -319,6 +330,7 @@
 	neighbors=NULL;
 	
-	/*demarshall inputs: */
+	/*demarshall inputs and results: */
 	inputs=(Inputs*)DataSetDemarshallRaw(&marshalled_dataset); 
+	results=(Results*)DataSetDemarshallRaw(&marshalled_dataset); 
 
 	/*demarshall internal parameters: */
@@ -353,4 +365,6 @@
 	printf("   inputs\n");
 	inputs->DeepEcho();
+	printf("   results\n");
+	results->DeepEcho();
 	printf("   collapse: \n   ");
 	for(i=0;i<numanalyses;i++)printf("%s|",collapse[i]?"true":"false");
@@ -379,4 +393,6 @@
 	char* marshalled_inputs=NULL;
 	int   marshalled_inputs_size;
+	char* marshalled_results=NULL;
+	int   marshalled_results_size;
 
 	/*recover marshalled_dataset: */
@@ -399,5 +415,5 @@
 	hneighbors.Marshall(&marshalled_dataset);
 
-	/*Marshall inputs: */
+	/*Marshall inputs and results: */
 	marshalled_inputs_size=inputs->MarshallSize();
 	marshalled_inputs=inputs->Marshall();
@@ -405,4 +421,9 @@
 	marshalled_dataset+=marshalled_inputs_size;
 
+	marshalled_results_size=results->MarshallSize();
+	marshalled_results=results->Marshall();
+	memcpy(marshalled_dataset,marshalled_results,marshalled_results_size*sizeof(char));
+	marshalled_dataset+=marshalled_results_size;
+
 	/*marshall internal parameters: */
 	memcpy(marshalled_dataset,collapse,numanalyses*sizeof(bool));marshalled_dataset+=numanalyses*sizeof(bool);
@@ -411,4 +432,5 @@
 
 	xfree((void**)&marshalled_inputs);
+	xfree((void**)&marshalled_results);
 
 	*pmarshalled_dataset=marshalled_dataset;
@@ -430,4 +452,5 @@
 		+hneighbors.MarshallSize()
 		+inputs->MarshallSize()
+		+results->MarshallSize()
 		+numanalyses*sizeof(bool)
 		+sizeof(int); //sizeof(int) for enum type
@@ -445,4 +468,5 @@
 	Parameters* tria_parameters=NULL;
 	Inputs* tria_inputs=NULL;
+	Results* tria_results=NULL;
 
 	indices[0]=g0;
@@ -452,8 +476,10 @@
 	tria_parameters=this->parameters;
 	tria_inputs=(Inputs*)this->inputs->SpawnTriaInputs(indices);
+	tria_results=(Results*)this->results->SpawnTriaResults(indices);
 	
 	tria=new Tria();
 	tria->id=this->id;
 	tria->inputs=tria_inputs;
+	tria->results=tria_results;
 	tria->parameters=tria_parameters;
 
@@ -478,4 +504,5 @@
 	Parameters *beam_parameters = NULL;
 	Inputs     *beam_inputs     = NULL;
+	Results     *beam_results     = NULL;
 
 	indices[0]=g0;
@@ -484,8 +511,10 @@
 	beam_parameters=this->parameters;
 	beam_inputs=(Inputs*)this->inputs->SpawnBeamInputs(indices);
+	beam_results=(Results*)this->results->SpawnBeamResults(indices);
 
 	beam=new Beam();
 	beam->id=this->id;
 	beam->inputs=beam_inputs;
+	beam->results=beam_results;
 	beam->parameters=beam_parameters;
 
@@ -506,11 +535,14 @@
 	Parameters *sing_parameters = NULL;
 	Inputs     *sing_inputs     = NULL;
+	Results     *sing_results     = NULL;
 
 	sing_parameters=this->parameters;
 	sing_inputs=(Inputs*)this->inputs->SpawnSingInputs(index);
+	sing_results=(Results*)this->results->SpawnSingResults(index);
 
 	sing=new Sing();
 	sing->id=this->id;
 	sing->inputs=sing_inputs;
+	sing->results=sing_results;
 	sing->parameters=sing_parameters;
 
@@ -560,4 +592,26 @@
 	/*output error if not found*/
 	ISSMERROR("Node not found in Penta");
+}
+/*}}}*/
+/*FUNCTION Penta::InputToResult(int enum_type,int step,double time){{{1*/
+void  Penta::InputToResult(int enum_type,int step,double time){
+
+	int    i;
+	bool   found = false;
+	Input *input = NULL;
+
+	/*Go through all the input objects, and find the one corresponding to enum_type, if it exists: */
+	for (i=0;i<this->inputs->Size();i++){
+		input=(Input*)this->inputs->GetObjectByOffset(i);
+		if (input->EnumType()==enum_type){
+			found=true;
+			break;
+		}
+	}
+
+	/*If we don't find it, no big deal, just don't do the transfer. Otherwise, build a new Result 
+	 * object out of the input, with the additional step and time information: */
+	this->results->AddObject(input->SpawnResult(step,time));
+
 }
 /*}}}*/
Index: /issm/trunk/src/c/objects/Elements/Penta.h
===================================================================
--- /issm/trunk/src/c/objects/Elements/Penta.h	(revision 4036)
+++ /issm/trunk/src/c/objects/Elements/Penta.h	(revision 4037)
@@ -36,4 +36,5 @@
 		Parameters  *parameters;   //pointer to solution parameters
 		Inputs      *inputs;
+		Results      *results;
 
 		/*internal parameters: */
@@ -60,9 +61,10 @@
 		int   MarshallSize();
 		int   MyRank();
-		void*  SpawnSing(int g0);
-		void*  SpawnBeam(int g0, int g1);
-		void*  SpawnTria(int g0, int g1, int g2);
+		void* SpawnSing(int g0);
+		void* SpawnBeam(int g0, int g1);
+		void* SpawnTria(int g0, int g1, int g2);
 		void  SetClone(int* minranks);
 		double* GaussFromNode(Node* node);
+		void  InputToResult(int enum_type,int step,double time);
 
 		/*}}}*/
Index: /issm/trunk/src/c/objects/Elements/Sing.cpp
===================================================================
--- /issm/trunk/src/c/objects/Elements/Sing.cpp	(revision 4036)
+++ /issm/trunk/src/c/objects/Elements/Sing.cpp	(revision 4037)
@@ -134,4 +134,9 @@
 /*FUNCTION Sing::GetSolutionFromInputs(Vec solution,  int analysis_type,int sub_analysis_type);{{{1*/
 void  Sing::GetSolutionFromInputs(Vec solution,  int analysis_type,int sub_analysis_type){
+	ISSMERROR(" not supported yet!");
+}
+/*}}}*/
+/*FUNCTION Sing::InputToResult(int enum_type,int step,double time){{{1*/
+void  Sing::InputToResult(int enum_type,int step,double time){
 	ISSMERROR(" not supported yet!");
 }
Index: /issm/trunk/src/c/objects/Elements/Sing.h
===================================================================
--- /issm/trunk/src/c/objects/Elements/Sing.h	(revision 4036)
+++ /issm/trunk/src/c/objects/Elements/Sing.h	(revision 4037)
@@ -61,8 +61,7 @@
 		void  UpdateInputsFromConstant(int constant, int name){ISSMERROR("Not implemented yet!");}
 		void  UpdateInputsFromConstant(bool constant, int name){ISSMERROR("Not implemented yet!");}
-
 		void  UpdateInputsFromSolution(double* solution, int analysis_type, int sub_analysis_type);
-
 		void  DepthAverageInputAtBase(int enum_type){ISSMERROR("not implemented yet");};
+		void  InputToResult(int enum_type,int step,double time);
 		/*}}}*/
 		/*numerics: {{{1*/
Index: /issm/trunk/src/c/objects/Elements/Tria.cpp
===================================================================
--- /issm/trunk/src/c/objects/Elements/Tria.cpp	(revision 4036)
+++ /issm/trunk/src/c/objects/Elements/Tria.cpp	(revision 4037)
@@ -28,4 +28,5 @@
 	this->inputs=NULL;
 	this->parameters=NULL;
+	this->results=NULL;
 }
 /*}}}*/
@@ -33,4 +34,5 @@
 Tria::~Tria(){
 	delete inputs;
+	delete results;
 	this->parameters=NULL;
 }
@@ -60,4 +62,8 @@
 	this->parameters=NULL;
 
+	/*intialize inputs and results: */
+	this->inputs=new Inputs();
+	this->results=new Results();
+
 }
 /*}}}*/
@@ -98,7 +104,5 @@
 	this->SetHookNodes(tria_node_ids,analysis_counter); this->nodes=NULL; //set hook to nodes, for this analysis type
 	
-	/*intialize inputs, and add as many inputs per element as requested:*/
-	this->inputs=new Inputs();
-	
+	/*add as many inputs per element as requested:*/
 	if (iomodel->thickness) {
 		for(i=0;i<3;i++)nodeinputs[i]=iomodel->thickness[tria_vertex_ids[i]-1];
@@ -224,4 +228,10 @@
 	else{
 		tria->inputs=new Inputs();
+	}
+	if(this->results){
+		tria->results=(Results*)this->results->Copy();
+	}
+	else{
+		tria->results=new Results();
 	}
 	/*point parameters: */
@@ -299,4 +309,5 @@
 	/*demarshall inputs: */
 	inputs=(Inputs*)DataSetDemarshallRaw(&marshalled_dataset); 
+	results=(Results*)DataSetDemarshallRaw(&marshalled_dataset); 
 
 	/*parameters: may not exist even yet, so let Configure handle it: */
@@ -334,4 +345,7 @@
 	if (inputs) inputs->DeepEcho();
 	else printf("inputs=NULL\n");
+
+	if (results) results->DeepEcho();
+	else printf("results=NULL\n");
 	
 	return;
@@ -352,4 +366,6 @@
 	char* marshalled_inputs=NULL;
 	int   marshalled_inputs_size;
+	char* marshalled_results=NULL;
+	int   marshalled_results_size;
 
 	/*recover marshalled_dataset: */
@@ -378,7 +394,14 @@
 	marshalled_dataset+=marshalled_inputs_size;
 
+	/*Marshall results: */
+	marshalled_results_size=results->MarshallSize();
+	marshalled_results=results->Marshall();
+	memcpy(marshalled_dataset,marshalled_results,marshalled_results_size*sizeof(char));
+	marshalled_dataset+=marshalled_results_size;
+
 	/*parameters: don't do anything about it. parameters are marshalled somewhere else!*/
 
 	xfree((void**)&marshalled_inputs);
+	xfree((void**)&marshalled_results);
 
 	*pmarshalled_dataset=marshalled_dataset;
@@ -400,4 +423,5 @@
 		+hmatpar.MarshallSize()
 		+inputs->MarshallSize()
+		+results->MarshallSize()
 		+sizeof(int); //sizeof(int) for enum type
 }
@@ -414,4 +438,5 @@
 	Parameters *beam_parameters = NULL;
 	Inputs     *beam_inputs     = NULL;
+	Results     *beam_results     = NULL;
 
 	indices[0]=g0;
@@ -420,8 +445,10 @@
 	beam_parameters=this->parameters;
 	beam_inputs=(Inputs*)this->inputs->SpawnBeamInputs(indices);
+	beam_results=(Results*)this->results->SpawnBeamResults(indices);
 
 	beam=new Beam();
 	beam->id=this->id;
 	beam->inputs=beam_inputs;
+	beam->results=beam_results;
 	beam->parameters=beam_parameters;
 
@@ -443,11 +470,14 @@
 	Parameters *sing_parameters = NULL;
 	Inputs     *sing_inputs     = NULL;
+	Results     *sing_results     = NULL;
 
 	sing_parameters=this->parameters;
 	sing_inputs=(Inputs*)this->inputs->SpawnSingInputs(index);
+	sing_results=(Results*)this->results->SpawnSingResults(index);
 
 	sing=new Sing();
 	sing->id=this->id;
 	sing->inputs=sing_inputs;
+	sing->results=sing_results;
 	sing->parameters=sing_parameters;
 
@@ -458,4 +488,26 @@
 	
 	return sing;
+}
+/*}}}*/
+/*FUNCTION Tria::InputToResult(int enum_type,int step,double time){{{1*/
+void  Tria::InputToResult(int enum_type,int step,double time){
+
+	int    i;
+	bool   found = false;
+	Input *input = NULL;
+
+	/*Go through all the input objects, and find the one corresponding to enum_type, if it exists: */
+	for (i=0;i<this->inputs->Size();i++){
+		input=(Input*)this->inputs->GetObjectByOffset(i);
+		if (input->EnumType()==enum_type){
+			found=true;
+			break;
+		}
+	}
+
+	/*If we don't find it, no big deal, just don't do the transfer. Otherwise, build a new Result 
+	 * object out of the input, with the additional step and time information: */
+	this->results->AddObject(input->SpawnResult(step,time));
+
 }
 /*}}}*/
Index: /issm/trunk/src/c/objects/Elements/Tria.h
===================================================================
--- /issm/trunk/src/c/objects/Elements/Tria.h	(revision 4036)
+++ /issm/trunk/src/c/objects/Elements/Tria.h	(revision 4037)
@@ -58,4 +58,5 @@
 		void*  SpawnSing(int g0);
 		void*  SpawnBeam(int g0, int g1);
+		void  InputToResult(int enum_type,int step,double time);
 		/*}}}*/
 		/*FUNCTION element numerical routines {{{1*/
Index: /issm/trunk/src/c/objects/Inputs/BeamVertexInput.cpp
===================================================================
--- /issm/trunk/src/c/objects/Inputs/BeamVertexInput.cpp	(revision 4036)
+++ /issm/trunk/src/c/objects/Inputs/BeamVertexInput.cpp	(revision 4037)
@@ -167,4 +167,11 @@
 }
 /*}}}*/
+/*FUNCTION BeamVertexInput::SpawnResult{{{1*/
+Result* BeamVertexInput::SpawnResult(int step, double time){
+
+	return new BeamVertexResult(this->enum_type,this->values,step,time);
+
+}
+/*}}}*/
 
 /*Object functions*/
Index: /issm/trunk/src/c/objects/Inputs/BeamVertexInput.h
===================================================================
--- /issm/trunk/src/c/objects/Inputs/BeamVertexInput.h	(revision 4036)
+++ /issm/trunk/src/c/objects/Inputs/BeamVertexInput.h	(revision 4037)
@@ -50,4 +50,6 @@
 		Input* SpawnBeamInput(int* indices);
 		Input* SpawnTriaInput(int* indices);
+		Result* SpawnResult(int step, double time);
+
 		/*}}}*/
 		/*numerics: {{{1*/
Index: /issm/trunk/src/c/objects/Inputs/BoolInput.cpp
===================================================================
--- /issm/trunk/src/c/objects/Inputs/BoolInput.cpp	(revision 4036)
+++ /issm/trunk/src/c/objects/Inputs/BoolInput.cpp	(revision 4037)
@@ -175,4 +175,11 @@
 }
 /*}}}*/
+/*FUNCTION BoolInput::SpawnResult{{{1*/
+Result* BoolInput::SpawnResult(int step, double time){
+
+	return new BoolResult(this->enum_type,this->value,step,time);
+
+}
+/*}}}*/
 
 /*Object functions*/
Index: /issm/trunk/src/c/objects/Inputs/BoolInput.h
===================================================================
--- /issm/trunk/src/c/objects/Inputs/BoolInput.h	(revision 4036)
+++ /issm/trunk/src/c/objects/Inputs/BoolInput.h	(revision 4037)
@@ -50,4 +50,6 @@
 		Input* SpawnBeamInput(int* indices);
 		Input* SpawnTriaInput(int* indices);
+		Result* SpawnResult(int step, double time);
+
 		/*}}}*/
 		/*numerics: {{{1*/
Index: /issm/trunk/src/c/objects/Inputs/DoubleInput.cpp
===================================================================
--- /issm/trunk/src/c/objects/Inputs/DoubleInput.cpp	(revision 4036)
+++ /issm/trunk/src/c/objects/Inputs/DoubleInput.cpp	(revision 4037)
@@ -175,4 +175,11 @@
 }
 /*}}}*/
+/*FUNCTION DoubleInput::SpawnResult{{{1*/
+Result* DoubleInput::SpawnResult(int step, double time){
+
+	return new DoubleResult(this->enum_type,this->value,step,time);
+
+}
+/*}}}*/
 
 /*Object functions*/
Index: /issm/trunk/src/c/objects/Inputs/DoubleInput.h
===================================================================
--- /issm/trunk/src/c/objects/Inputs/DoubleInput.h	(revision 4036)
+++ /issm/trunk/src/c/objects/Inputs/DoubleInput.h	(revision 4037)
@@ -50,4 +50,6 @@
 		Input* SpawnBeamInput(int* indices);
 		Input* SpawnTriaInput(int* indices);
+		Result* SpawnResult(int step, double time);
+
 		/*}}}*/
 		/*numerics: {{{1*/
Index: /issm/trunk/src/c/objects/Inputs/Input.h
===================================================================
--- /issm/trunk/src/c/objects/Inputs/Input.h	(revision 4036)
+++ /issm/trunk/src/c/objects/Inputs/Input.h	(revision 4037)
@@ -11,4 +11,5 @@
 #include "../Object.h"
 class Node;
+class Result;
 #include "../Node.h"
 /*}}}*/
@@ -44,9 +45,13 @@
 		virtual void GetVyStrainRate3dPattyn(double* epsilonvy,double* xyz_list, double* gauss)=0;
 		virtual void ChangeEnum(int newenumtype)=0;
+		
 		virtual Input* SpawnSingInput(int  index)=0;
 		virtual Input* SpawnBeamInput(int* indices)=0;
 		virtual Input* SpawnTriaInput(int* indices)=0;
+		virtual Result* SpawnResult(int step, double time)=0;
 		virtual int  PatchSize(void)=0;
 		virtual void PatchFill(double* patch, int max_vertices,Parameters* parameters)=0;
+
+
 		/*}}}*/
 
Index: /issm/trunk/src/c/objects/Inputs/IntInput.cpp
===================================================================
--- /issm/trunk/src/c/objects/Inputs/IntInput.cpp	(revision 4036)
+++ /issm/trunk/src/c/objects/Inputs/IntInput.cpp	(revision 4037)
@@ -172,4 +172,11 @@
 }
 /*}}}*/
+/*FUNCTION IntInput::SpawnResult{{{1*/
+Result* IntInput::SpawnResult(int step, double time){
+
+	return new IntResult(this->enum_type,this->value,step,time);
+
+}
+/*}}}*/
 
 /*Object functions*/
Index: /issm/trunk/src/c/objects/Inputs/IntInput.h
===================================================================
--- /issm/trunk/src/c/objects/Inputs/IntInput.h	(revision 4036)
+++ /issm/trunk/src/c/objects/Inputs/IntInput.h	(revision 4037)
@@ -50,4 +50,6 @@
 		Input* SpawnBeamInput(int* indices);
 		Input* SpawnTriaInput(int* indices);
+		Result* SpawnResult(int step, double time);
+
 		/*}}}*/
 		/*numerics: {{{1*/
Index: /issm/trunk/src/c/objects/Inputs/PentaVertexInput.cpp
===================================================================
--- /issm/trunk/src/c/objects/Inputs/PentaVertexInput.cpp	(revision 4036)
+++ /issm/trunk/src/c/objects/Inputs/PentaVertexInput.cpp	(revision 4037)
@@ -197,4 +197,11 @@
 	/*Assign output*/
 	return outinput;
+
+}
+/*}}}*/
+/*FUNCTION PentaVertexInput::SpawnResult{{{1*/
+Result* PentaVertexInput::SpawnResult(int step, double time){
+
+	return new PentaVertexResult(this->enum_type,this->values,step,time);
 
 }
Index: /issm/trunk/src/c/objects/Inputs/PentaVertexInput.h
===================================================================
--- /issm/trunk/src/c/objects/Inputs/PentaVertexInput.h	(revision 4036)
+++ /issm/trunk/src/c/objects/Inputs/PentaVertexInput.h	(revision 4037)
@@ -49,4 +49,6 @@
 		Input* SpawnBeamInput(int* indices);
 		Input* SpawnTriaInput(int* indices);
+		Result* SpawnResult(int step, double time);
+
 		/*}}}*/
 		/*numerics: {{{1*/
Index: /issm/trunk/src/c/objects/Inputs/SingVertexInput.cpp
===================================================================
--- /issm/trunk/src/c/objects/Inputs/SingVertexInput.cpp	(revision 4036)
+++ /issm/trunk/src/c/objects/Inputs/SingVertexInput.cpp	(revision 4037)
@@ -158,4 +158,11 @@
 }
 /*}}}*/
+/*FUNCTION SingVertexInput::SpawnResult{{{1*/
+Result* SingVertexInput::SpawnResult(int step, double time){
+
+	return new SingVertexResult(this->enum_type,this->value,step,time);
+
+}
+/*}}}*/
 
 /*Object functions*/
Index: /issm/trunk/src/c/objects/Inputs/SingVertexInput.h
===================================================================
--- /issm/trunk/src/c/objects/Inputs/SingVertexInput.h	(revision 4036)
+++ /issm/trunk/src/c/objects/Inputs/SingVertexInput.h	(revision 4037)
@@ -49,4 +49,6 @@
 		Input* SpawnBeamInput(int* indices);
 		Input* SpawnTriaInput(int* indices);
+		Result* SpawnResult(int step, double time);
+
 		/*}}}*/
 		/*numerics: {{{1*/
Index: /issm/trunk/src/c/objects/Inputs/TriaVertexInput.cpp
===================================================================
--- /issm/trunk/src/c/objects/Inputs/TriaVertexInput.cpp	(revision 4036)
+++ /issm/trunk/src/c/objects/Inputs/TriaVertexInput.cpp	(revision 4037)
@@ -183,4 +183,11 @@
 	/*Assign output*/
 	return outinput;
+
+}
+/*}}}*/
+/*FUNCTION TriaVertexInput::SpawnResult{{{1*/
+Result* TriaVertexInput::SpawnResult(int step, double time){
+
+	return new TriaVertexResult(this->enum_type,this->values,step,time);
 
 }
Index: /issm/trunk/src/c/objects/Inputs/TriaVertexInput.h
===================================================================
--- /issm/trunk/src/c/objects/Inputs/TriaVertexInput.h	(revision 4036)
+++ /issm/trunk/src/c/objects/Inputs/TriaVertexInput.h	(revision 4037)
@@ -49,4 +49,6 @@
 		Input* SpawnBeamInput(int* indices);
 		Input* SpawnTriaInput(int* indices);
+		Result* SpawnResult(int step, double time);
+
 		/*}}}*/
 		/*numerics: {{{1*/
Index: sm/trunk/src/c/objects/Result.cpp
===================================================================
--- /issm/trunk/src/c/objects/Result.cpp	(revision 4036)
+++ 	(revision )
@@ -1,284 +1,0 @@
-/*!\file Result.cpp
- * \brief: implementation of the Result object
- */
-
-
-#ifdef HAVE_CONFIG_H
-	#include "config.h"
-#else
-#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
-#endif
-
-#include "stdio.h"
-#include <string.h>
-#include "./objects.h"
-#include "../EnumDefinitions/EnumDefinitions.h"
-#include "../include/include.h"
-#include "../shared/shared.h"
-
-/*Object constructors and destructor*/
-/*FUNCTION Result::constructor {{{1*/
-Result::Result(){
-	return;
-}
-/*}}}1*/
-/*FUNCTION Result::destructor {{{1*/
-Result::~Result(){
-	xfree((void**)&fieldname);
-	VecFree(&field);
-	xfree((void**)&dfield);
-	xfree((void**)&cfield);
-}
-/*}}}1*/
-/*FUNCTION Result::Result(const Result& result) {{{1*/
-Result::Result(const Result& result){
-
-	id=result.id;
-	time=result.time;
-	step=result.step;
-	size=result.size;
-	
-	/*copy constructor: copy dynamically allocated fields: */
-	if(result.fieldname){
-		fieldname=(char*)xmalloc((strlen(result.fieldname)+1)*sizeof(char));
-		strcpy(fieldname,result.fieldname);
-	}
-	if(result.field){
-		VecDuplicatePatch(&field,result.field);
-		dfield=NULL;
-		cfield=NULL;
-	}
-	if(result.dfield){
-		dfield=(double*)xmalloc(result.size*sizeof(double));
-		memcpy(dfield,result.dfield,result.size*sizeof(double));
-		field=NULL;
-		cfield=NULL;
-	}
-	if(result.cfield){
-		cfield=(char*)xmalloc((strlen(result.cfield)+1)*sizeof(char));
-		strcpy(cfield,result.cfield);
-		field=NULL;
-		dfield=NULL;
-	}
-}
-/*}}}1*/
-/*FUNCTION Result::Result(int result_id,double result_time,int result_step,char* result_fieldname,Vec result_field) {{{1*/
-Result::Result(int result_id,double result_time,int result_step,char* result_fieldname,Vec result_field){
-
-	id=result_id;
-	time=result_time;
-	step=result_step;
-	
-	if(!result_fieldname){
-		ISSMERROR("NULL fieldname in constructor argument");
-	}
-	else{
-		fieldname=(char*)xmalloc((strlen(result_fieldname)+1)*sizeof(char));
-		strcpy(fieldname,result_fieldname);
-	}
-
-	VecDuplicatePatch(&field,result_field);
-	dfield=NULL;
-	cfield=NULL;
-}
-/*}}}1*/
-/*FUNCTION Result::Result(int result_id,double result_time,int result_step,char* result_fldname,double* result_field,int result_size){{{1*/
-Result::Result(int result_id,double result_time,int result_step,char* result_fieldname,double* result_field,int result_size){
-
-	id=result_id;
-	time=result_time;
-	step=result_step;
-	
-	if(!result_fieldname){
-		ISSMERROR(" NULL fieldname in constructor argument");
-	}
-	else{
-		fieldname=(char*)xmalloc((strlen(result_fieldname)+1)*sizeof(char));
-		strcpy(fieldname,result_fieldname);
-	}
-
-	dfield=(double*)xmalloc(result_size*sizeof(double));
-	memcpy(dfield,result_field,result_size*sizeof(double));
-	size=result_size;
-	field=NULL;
-	cfield=NULL;
-}
-/*}}}1*/
-/*FUNCTION Result::Result(int result_id,double result_time,int result_step,char* result_fieldname,char* result_field) {{{1*/
-Result::Result(int result_id,double result_time,int result_step,char* result_fieldname,char* result_field){
-
-	id=result_id;
-	time=result_time;
-	step=result_step;
-	
-	if(!result_fieldname){
-		ISSMERROR(" NULL fieldname in constructor argument");
-	}
-	else{
-		fieldname=(char*)xmalloc((strlen(result_fieldname)+1)*sizeof(char));
-		strcpy(fieldname,result_fieldname);
-	}
-	cfield=(char*)xmalloc((strlen(result_field)+1)*sizeof(char));
-	strcpy(cfield,result_field);
-
-	field=NULL;
-	dfield=NULL;
-}
-/*}}}1*/
-		
-/*Object marshall*/
-/*FUNCTION Result::Marshall {{{1*/
-void  Result::Marshall(char** pmarshalled_dataset){
-
-	ISSMERROR(" not supported yet!");
-
-}
-/*}}}1*/
-/*FUNCTION Result::MarshallSize {{{1*/
-int   Result::MarshallSize(){
-
-	ISSMERROR(" not supported yet!");
-}
-/*}}}1*/
-/*FUNCTION Result::Demarshall {{{1*/
-void  Result::Demarshall(char** pmarshalled_dataset){
-
-	ISSMERROR(" not supported yet!");
-}
-/*}}}1*/
-
-/*Object functions*/
-/*FUNCTION Result::copy {{{1*/
-Object* Result::copy() {
-	return new Result(*this); 
-}
-/*}}}1*/
-/*FUNCTION Result::DeepEcho {{{1*/
-void Result::DeepEcho(void){
-
-	printf("Result:\n");
-	printf("   id: %i\n",id);
-	printf("   time: %g\n",time);
-	printf("   step: %i\n",step);
-	printf("   field name: %s\n",fieldname);
-	if(field){
-		printf("   field pointer %p\n",field);
-	}
-	if(dfield){
-		printf("   field pointer %p\n",dfield);
-		printf("   field size %i\n",size);
-	}
-	if(cfield){
-		printf("   field pointer %p\n",cfield);
-		printf("   field string %s\n",cfield);
-	}
-}	
-/*}}}1*/
-/*FUNCTION Result::Echo {{{1*/
-void Result::Echo(void){
-
-	printf("Result:\n");
-	printf("   id: %i\n",id);
-	printf("   time: %g\n",time);
-	printf("   step: %i\n",step);
-	printf("   field name: %s\n",fieldname);
-	if(field){
-		printf("   field pointer %p\n",field);
-	}
-	if(dfield){
-		printf("   field pointer %p\n",dfield);
-		printf("   field size %i\n",size);
-	}
-	if(cfield){
-		printf("   field pointer %p\n",cfield);
-		printf("   field string %s\n",cfield);
-	}
-}
-/*}}}1*/
-/*FUNCTION Result::Enum {{{1*/
-int Result::Enum(void){
-
-	return ResultEnum;
-
-}
-/*}}}1*/
-/*FUNCTION Result::GetFieldName {{{1*/
-char*    Result::GetFieldName(){
-	return fieldname;
-}
-/*}}}1*/
-/*FUNCTION Result::GetField(Vec* pfield) {{{1*/
-void  Result::GetField(Vec* pfield){
-
-	VecDuplicatePatch(pfield,field);
-
-}
-/*}}}1*/
-/*FUNCTION Result::GetField(char** pcfield) {{{1*/
-void  Result::GetField(char** pcfield){
-
-	char* string=NULL;
-
-	string=(char*)xmalloc((strlen(cfield)+1)*sizeof(char));
-	strcpy(string,cfield);
-
-	*pcfield=string;
-}
-/*}}}1*/
-/*FUNCTION Result::GetField(double** pfield) {{{1*/
-void  Result::GetField(double** pfield){
-	*pfield=(double*)xmalloc(size*sizeof(double));
-	memcpy(*pfield,dfield,size*sizeof(double));
-}
-/*}}}1*/
-/*FUNCTION Result::Id {{{1*/
-int    Result::Id(void){ return id; }
-/*}}}1*/
-/*FUNCTION Result::GetStep {{{1*/
-int    Result::GetStep(){
-	return step;
-}
-/*}}}1*/
-/*FUNCTION Result::GetTime {{{1*/
-double Result::GetTime(){
-	return time;
-}
-/*}}}1*/
-/*FUNCTION Result::MyRank {{{1*/
-int    Result::MyRank(void){ 
-	extern int my_rank;
-
-	return my_rank; 
-}
-/*}}}1*/
-/*FUNCTION Result::WriteData {{{1*/
-void   Result::WriteData(FILE* fid){
-
-	int length;
-	int type;
-
-	/*First write field name :*/
-	length=(strlen(fieldname)+1)*sizeof(char);
-	fwrite(&length,sizeof(int),1,fid);
-	fwrite(fieldname,length,1,fid);
-
-	/*Now write time and step: */
-	fwrite(&time,sizeof(double),1,fid);
-	fwrite(&step,sizeof(int),1,fid);
-
-	/*Now write field: */
-	if(dfield){
-		type=1;
-		fwrite(&type,sizeof(int),1,fid);
-		fwrite(&size,sizeof(int),1,fid);
-		fwrite(dfield,size*sizeof(double),1,fid);
-	}
-	if(cfield){
-		type=2;
-		fwrite(&type,sizeof(int),1,fid);
-		length=(strlen(cfield)+1)*sizeof(char);
-		fwrite(&length,sizeof(int),1,fid);
-		fwrite(cfield,length,1,fid);
-	}
-}
-/*}}}1*/
Index: sm/trunk/src/c/objects/Result.h
===================================================================
--- /issm/trunk/src/c/objects/Result.h	(revision 4036)
+++ 	(revision )
@@ -1,66 +1,0 @@
-/*!\file Result.h
- * \brief: header file for result object
- */
-
-#ifndef _RESULT_H_
-#define _RESULT_H_
-
-/*Headers:*/
-/*{{{1*/
-#include "stdio.h"
-#include "./Object.h"
-#include "../toolkits/toolkits.h"
-/*}}}*/
-
-class Result: public Object{
-
-	private: 
-		int    id;
-		double time;
-		int    step;
-		char*  fieldname;
-		Vec    field;
-		double* dfield;
-		char*   cfield;
-		int     size;
-
-	public:
-
-		Result();
-		Result(const Result& result);
-		Result(int result_id,double result_time,int result_step,char* result_fieldname,Vec result_field);
-		Result(int result_id,double result_time,int result_step,char* result_fieldname,double* result_field,int result_size);
-		Result(int result_id,double result_time,int result_step,char* result_fieldname,char* result_field);
-		~Result();
-
-		void  Echo();
-		void  DeepEcho();
-		int   Id(void); 
-		int   MyRank(void);
-		void  Marshall(char** pmarshalled_dataset);
-		int   MarshallSize();
-		void  Demarshall(char** pmarshalled_dataset);
-		int   Enum();
-		Object* copy();
-		void    UpdateInputsFromVector(double* vector, int name, int type){ISSMERROR("Not implemented yet!");}
-		void    UpdateInputsFromVector(int* vector, int name, int type){ISSMERROR("Not implemented yet!");}
-		void    UpdateInputsFromVector(bool* vector, int name, int type){ISSMERROR("Not implemented yet!");}
-		void    UpdateInputsFromConstant(double constant, int name){ISSMERROR("Not implemented yet!");}
-		void    UpdateInputsFromConstant(int constant, int name){ISSMERROR("Not implemented yet!");}
-		void    UpdateInputsFromConstant(bool constant, int name){ISSMERROR("Not implemented yet!");}
-
-		void    UpdateInputsFromSolution(double* solution, int analysis_type, int sub_analysis_type){ISSMERROR("Not implemented yet!");}
-
-		double GetTime();
-		void  GetField(Vec* pfield);
-		void  GetField(double** pfield);
-		void  GetField(char** pcfield);
-		int    GetStep();
-		void   WriteData(FILE* fid);
-		char*  GetFieldName();
-
-	
-};
-
-#endif  /* _RESULT_H_ */
-
Index: /issm/trunk/src/c/objects/Results/DoubleResult.cpp
===================================================================
--- /issm/trunk/src/c/objects/Results/DoubleResult.cpp	(revision 4037)
+++ /issm/trunk/src/c/objects/Results/DoubleResult.cpp	(revision 4037)
@@ -0,0 +1,193 @@
+/*!\file DoubleResult.c
+ * \brief: implementation of the DoubleResult object
+ */
+
+#ifdef HAVE_CONFIG_H
+	#include "config.h"
+#else
+#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
+#endif
+
+#include "stdio.h"
+#include <string.h>
+#include "./ResultLocal.h"
+#include "../objects.h"
+#include "../../EnumDefinitions/EnumDefinitions.h"
+#include "../../shared/shared.h"
+#include "../../DataSet/DataSet.h"
+#include "../../include/include.h"
+
+/*Object constructors and destructor*/
+/*FUNCTION DoubleResult::DoubleResult(){{{1*/
+DoubleResult::DoubleResult(){
+	return;
+}
+/*}}}*/
+/*FUNCTION DoubleResult::DoubleResult(int in_enum_type,IssmDouble in_value,int in_step, double in_time){{{1*/
+DoubleResult::DoubleResult(int in_enum_type,IssmDouble in_value,int in_step, double in_time): DoubleInput(in_enum_type,in_value){
+		
+	step=in_step;
+	time=in_time;
+}
+/*}}}*/
+/*FUNCTION DoubleResult::~DoubleResult(){{{1*/
+DoubleResult::~DoubleResult(){
+	return;
+}
+/*}}}*/
+
+/*Object management*/
+/*FUNCTION DoubleResult::copy{{{1*/
+Object* DoubleResult::copy() {
+	
+	return new DoubleResult(this->enum_type,this->value,this->step,this->time);
+
+}
+/*}}}*/
+/*FUNCTION DoubleResult::DeepEcho{{{1*/
+void DoubleResult::DeepEcho(void){
+
+	printf("DoubleResult:\n");
+	DoubleInput::DeepEcho();
+	printf("   step: %i\n",this->step);
+	printf("   time: %g\n",this->time);
+}
+/*}}}*/
+/*FUNCTION DoubleResult::Demarshall{{{1*/
+void  DoubleResult::Demarshall(char** pmarshalled_dataset){
+
+	char* marshalled_dataset=NULL;
+	int   i;
+
+	/*recover marshalled_dataset: */
+	marshalled_dataset=*pmarshalled_dataset;
+
+	/*this time, no need to get enum type, the pointer directly points to the beginning of the 
+	 *object data (thanks to DataSet::Demarshall):*/
+	memcpy(&enum_type,marshalled_dataset,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
+	memcpy(&value,marshalled_dataset,sizeof(value));marshalled_dataset+=sizeof(value);
+	memcpy(&step,marshalled_dataset,sizeof(step));marshalled_dataset+=sizeof(step);
+	memcpy(&time,marshalled_dataset,sizeof(time));marshalled_dataset+=sizeof(time);
+
+	/*return: */
+	*pmarshalled_dataset=marshalled_dataset;
+	return;
+}
+/*}}}*/
+/*FUNCTION DoubleResult::Echo {{{1*/
+void DoubleResult::Echo(void){
+	this->DeepEcho();
+}
+/*}}}*/
+/*FUNCTION DoubleResult::Enum{{{1*/
+int DoubleResult::Enum(void){
+
+	return DoubleResultEnum;
+
+}
+/*}}}*/
+/*FUNCTION DoubleResult::EnumType{{{1*/
+int DoubleResult::EnumType(void){
+
+	return this->enum_type;
+
+}
+/*}}}*/
+/*FUNCTION DoubleResult::Id{{{1*/
+int    DoubleResult::Id(void){ return -1; }
+/*}}}*/
+/*FUNCTION DoubleResult::Marshall{{{1*/
+void  DoubleResult::Marshall(char** pmarshalled_dataset){
+
+	char* marshalled_dataset=NULL;
+	int   enum_value=0;
+
+	/*recover marshalled_dataset: */
+	marshalled_dataset=*pmarshalled_dataset;
+
+	/*get enum value of DoubleResult: */
+	enum_value=DoubleResultEnum;
+	
+	/*marshall enum: */
+	memcpy(marshalled_dataset,&enum_value,sizeof(enum_value));marshalled_dataset+=sizeof(enum_value);
+	
+	/*marshall DoubleResult data: */
+	memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
+	memcpy(marshalled_dataset,&value,sizeof(value));marshalled_dataset+=sizeof(value);
+	memcpy(marshalled_dataset,&time,sizeof(time));marshalled_dataset+=sizeof(time);
+	memcpy(marshalled_dataset,&step,sizeof(step));marshalled_dataset+=sizeof(step);
+
+	*pmarshalled_dataset=marshalled_dataset;
+}
+/*}}}*/
+/*FUNCTION DoubleResult::MarshallSize{{{1*/
+int   DoubleResult::MarshallSize(){
+	
+	return sizeof(value)+
+		+sizeof(enum_type)
+		+sizeof(time)
+		+sizeof(step)
+		+sizeof(int); //sizeof(int) for enum value
+}
+/*}}}*/
+/*FUNCTION DoubleResult::MyRank{{{1*/
+int    DoubleResult::MyRank(void){ 
+	extern int my_rank;
+	return my_rank; 
+}
+/*}}}*/
+
+/*Result functions*/
+/*FUNCTION DoubleResult::SpawnSingResult{{{1*/
+Result* DoubleResult::SpawnSingResult(int index){
+
+	/*output*/
+	DoubleResult* outresult=new DoubleResult();
+
+	/*copy fields: */
+	outresult->enum_type=this->enum_type;
+	outresult->value=this->value;
+	outresult->time=this->time;
+	outresult->step=this->step;
+
+	/*Assign output*/
+	return outresult;
+
+}
+/*}}}*/
+/*FUNCTION DoubleResult::SpawnBeamResult{{{1*/
+Result* DoubleResult::SpawnBeamResult(int* indices){
+
+	/*output*/
+	DoubleResult* outresult=new DoubleResult();
+
+	/*copy fields: */
+	outresult->enum_type=this->enum_type;
+	outresult->value=this->value;
+	outresult->time=this->time;
+	outresult->step=this->step;
+
+
+	/*Assign output*/
+	return outresult;
+
+}
+/*}}}*/
+/*FUNCTION DoubleResult::SpawnTriaResult{{{1*/
+Result* DoubleResult::SpawnTriaResult(int* indices){
+
+	/*output*/
+	DoubleResult* outresult=new DoubleResult();
+
+	/*copy fields: */
+	outresult->enum_type=this->enum_type;
+	outresult->value=this->value;
+	outresult->time=this->time;
+	outresult->step=this->step;
+
+	/*Assign output*/
+	return outresult;
+
+}
+/*}}}*/
+
Index: /issm/trunk/src/c/objects/Results/DoubleResult.h
===================================================================
--- /issm/trunk/src/c/objects/Results/DoubleResult.h	(revision 4037)
+++ /issm/trunk/src/c/objects/Results/DoubleResult.h	(revision 4037)
@@ -0,0 +1,48 @@
+/*! \file DoubleResult.h 
+ *  \brief: header file for double result object
+ *  A double result object is just derived from a DoubleInput object, with additional time and step information.
+ */
+
+
+#ifndef _DOUBLERESULT_H_
+#define _DOUBLERESULT_H_
+
+/*Headers:*/
+/*{{{1*/
+#include "../Inputs/Input.h"
+#include "../../include/include.h"
+/*}}}*/
+
+class DoubleResult: public DoubleInput,public Result{
+
+	private: 
+		int    step;
+		double time;
+
+	public:
+
+		/*constructors, destructors: {{{1*/
+		DoubleResult();
+		DoubleResult(int enum_type,IssmDouble value,int step,double time);
+		~DoubleResult();
+		/*}}}*/
+		/*object management: {{{1*/
+		void  DeepEcho();
+		void  Echo();
+		int   Id(); 
+		void  Marshall(char** pmarshalled_dataset);
+		int   MarshallSize();
+		void  Demarshall(char** pmarshalled_dataset);
+		int   Enum();
+		int   MyRank();
+		Object* copy();
+		int   EnumType();
+				/*}}}*/
+		/*result virtual functions: {{{1*/
+		Result* SpawnSingResult(int  index);
+		Result* SpawnBeamResult(int* indices);
+		Result* SpawnTriaResult(int* indices);
+		/*}}}*/
+
+};
+#endif  /* _DOUBLERESULT_H */
Index: /issm/trunk/src/c/objects/Results/PentaVertexResult.cpp
===================================================================
--- /issm/trunk/src/c/objects/Results/PentaVertexResult.cpp	(revision 4037)
+++ /issm/trunk/src/c/objects/Results/PentaVertexResult.cpp	(revision 4037)
@@ -0,0 +1,207 @@
+/*!\file PentaVertexResult.c
+ * \brief: implementation of the PentaVertexResult object
+ */
+
+#ifdef HAVE_CONFIG_H
+	#include "config.h"
+#else
+#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
+#endif
+
+#include "stdio.h"
+#include <string.h>
+#include "./ResultLocal.h"
+#include "../objects.h"
+#include "../../EnumDefinitions/EnumDefinitions.h"
+#include "../../shared/shared.h"
+#include "../../DataSet/DataSet.h"
+#include "../../include/include.h"
+
+/*Object constructors and destructor*/
+/*FUNCTION PentaVertexResult::PentaVertexResult(){{{1*/
+PentaVertexResult::PentaVertexResult(){
+	return;
+}
+/*}}}*/
+/*FUNCTION PentaVertexResult::PentaVertexResult(int in_enum_type,double* in_values,int in_step, double in_time){{{1*/
+PentaVertexResult::PentaVertexResult(int in_enum_type,double* in_values,int in_step, double in_time): PentaVertexInput(in_enum_type,in_values){
+
+	step=in_step;
+	time=in_time;
+}
+/*}}}*/
+/*FUNCTION PentaVertexResult::~PentaVertexResult(){{{1*/
+PentaVertexResult::~PentaVertexResult(){
+	return;
+}
+/*}}}*/
+
+/*Object management*/
+/*FUNCTION PentaVertexResult::copy{{{1*/
+Object* PentaVertexResult::copy() {
+	
+	return new PentaVertexResult(this->enum_type,this->values,this->step,this->time);
+
+}
+/*}}}*/
+/*FUNCTION PentaVertexResult::DeepEcho{{{1*/
+void PentaVertexResult::DeepEcho(void){
+
+	printf("PentaVertexResult:\n");
+	PentaVertexResult::DeepEcho();
+	printf("   step: %i\n",this->step);
+	printf("   time: %g\n",this->time);
+
+}
+/*}}}*/
+/*FUNCTION PentaVertexResult::Demarshall{{{1*/
+void  PentaVertexResult::Demarshall(char** pmarshalled_dataset){
+
+	char* marshalled_dataset=NULL;
+	int   i;
+
+	/*recover marshalled_dataset: */
+	marshalled_dataset=*pmarshalled_dataset;
+
+	/*this time, no need to get enum type, the pointer directly points to the beginning of the 
+	 *object data (thanks to DataSet::Demarshall):*/
+	memcpy(&enum_type,marshalled_dataset,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
+	memcpy(&values,marshalled_dataset,sizeof(values));marshalled_dataset+=sizeof(values);
+	memcpy(&time,marshalled_dataset,sizeof(time));marshalled_dataset+=sizeof(time);
+	memcpy(&step,marshalled_dataset,sizeof(step));marshalled_dataset+=sizeof(step);
+
+	/*return: */
+	*pmarshalled_dataset=marshalled_dataset;
+	return;
+}
+/*}}}*/
+/*FUNCTION PentaVertexResult::Echo {{{1*/
+void PentaVertexResult::Echo(void){
+	this->DeepEcho();
+}
+/*}}}*/
+/*FUNCTION PentaVertexResult::Enum{{{1*/
+int PentaVertexResult::Enum(void){
+
+	return PentaVertexResultEnum;
+
+}
+/*}}}*/
+/*FUNCTION PentaVertexResult::EnumType{{{1*/
+int PentaVertexResult::EnumType(void){
+
+	return this->enum_type;
+
+}
+/*}}}*/
+/*FUNCTION PentaVertexResult::Id{{{1*/
+int    PentaVertexResult::Id(void){ return -1; }
+/*}}}*/
+/*FUNCTION PentaVertexResult::Marshall{{{1*/
+void  PentaVertexResult::Marshall(char** pmarshalled_dataset){
+
+	char* marshalled_dataset=NULL;
+	int   enum_value=0;
+
+	/*recover marshalled_dataset: */
+	marshalled_dataset=*pmarshalled_dataset;
+
+	/*get enum value of PentaVertexResult: */
+	enum_value=PentaVertexResultEnum;
+	
+	/*marshall enum: */
+	memcpy(marshalled_dataset,&enum_value,sizeof(enum_value));marshalled_dataset+=sizeof(enum_value);
+	
+	/*marshall PentaVertexResult data: */
+	memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
+	memcpy(marshalled_dataset,&values,sizeof(values));marshalled_dataset+=sizeof(values);
+	memcpy(marshalled_dataset,&time,sizeof(time));marshalled_dataset+=sizeof(time);
+	memcpy(marshalled_dataset,&step,sizeof(step));marshalled_dataset+=sizeof(step);
+
+	*pmarshalled_dataset=marshalled_dataset;
+}
+/*}}}*/
+/*FUNCTION PentaVertexResult::MarshallSize{{{1*/
+int   PentaVertexResult::MarshallSize(){
+	
+	return sizeof(values)+
+		+sizeof(enum_type)
+		+sizeof(time)
+		+sizeof(step)
+		+sizeof(int); //sizeof(int) for enum value
+}
+/*}}}*/
+/*FUNCTION PentaVertexResult::MyRank{{{1*/
+int    PentaVertexResult::MyRank(void){ 
+	extern int my_rank;
+	return my_rank; 
+}
+/*}}}*/
+
+/*Result functions*/
+/*FUNCTION PentaVertexResult::SpawnSingResult{{{1*/
+Result* PentaVertexResult::SpawnSingResult(int index){
+
+	/*output*/
+	SingVertexResult* outresult=NULL;
+
+	/*Create new Sing result (copy of current result)*/
+	ISSMASSERT(index<6 && index>=0);
+	outresult=new SingVertexResult(this->enum_type,this->values[index],this->step,this->time);
+
+	/*Assign output*/
+	return outresult;
+
+}
+/*}}}*/
+/*FUNCTION PentaVertexResult::SpawnBeamResult{{{1*/
+Result* PentaVertexResult::SpawnBeamResult(int* indices){
+
+	/*output*/
+	BeamVertexResult* outresult=NULL;
+	double newvalues[2];
+
+	/*Loop over the new indices*/
+	for(int i=0;i<2;i++){
+
+		/*Check index value*/
+		ISSMASSERT(indices[i]>=0 && indices[i]<6);
+
+		/*Assign value to new result*/
+		newvalues[i]=this->values[indices[i]];
+	}
+
+	/*Create new Beam result*/
+	outresult=new BeamVertexResult(this->enum_type,&newvalues[0],this->step,this->time);
+
+	/*Assign output*/
+	return outresult;
+
+}
+/*}}}*/
+/*FUNCTION PentaVertexResult::SpawnTriaResult{{{1*/
+Result* PentaVertexResult::SpawnTriaResult(int* indices){
+
+	/*output*/
+	TriaVertexResult* outresult=NULL;
+	double newvalues[3];
+
+	/*Loop over the new indices*/
+	for(int i=0;i<3;i++){
+
+		/*Check index value*/
+		ISSMASSERT(indices[i]>=0 && indices[i]<6);
+
+		/*Assign value to new result*/
+		newvalues[i]=this->values[indices[i]];
+	}
+
+	/*Create new Tria result*/
+	outresult=new TriaVertexResult(this->enum_type,&newvalues[0],this->step,this->time);
+
+	/*Assign output*/
+	return outresult;
+
+}
+/*}}}*/
+
Index: /issm/trunk/src/c/objects/Results/PentaVertexResult.h
===================================================================
--- /issm/trunk/src/c/objects/Results/PentaVertexResult.h	(revision 4037)
+++ /issm/trunk/src/c/objects/Results/PentaVertexResult.h	(revision 4037)
@@ -0,0 +1,48 @@
+/*! \file PentaVertexResult.h 
+ *  \brief: header file for penta vertex result  object. 
+ *  this object is just a PentaVertexInput with additional time and step info.
+ */
+
+
+#ifndef _PENTAVERTEXRESULT_H_
+#define _PENTAVERTEXRESULT_H_
+
+/*Headers:*/
+/*{{{1*/
+#include "../Inputs/Input.h"
+#include "../../include/include.h"
+/*}}}*/
+
+class PentaVertexResult: public PentaVertexInput,public Result{
+
+	private: 
+		int    step;
+		double time;
+
+	public:
+
+		/*constructors, destructors: {{{1*/
+		PentaVertexResult();
+		PentaVertexResult(int enum_type,double* values,int step, double time);
+		~PentaVertexResult();
+		/*}}}*/
+		/*object management: {{{1*/
+		void  DeepEcho();
+		void  Echo();
+		int   Id(); 
+		void  Marshall(char** pmarshalled_dataset);
+		int   MarshallSize();
+		void  Demarshall(char** pmarshalled_dataset);
+		int   Enum();
+		int   MyRank();
+		Object* copy();
+		int   EnumType();
+		/*}}}*/
+		/*result virtual functions: {{{1*/
+		Result* SpawnSingResult(int  index);
+		Result* SpawnBeamResult(int* indices);
+		Result* SpawnTriaResult(int* indices);
+		/*}}}*/
+
+};
+#endif  /* _PENTAVERTEXRESULT_H */
Index: /issm/trunk/src/c/objects/Results/Result.h
===================================================================
--- /issm/trunk/src/c/objects/Results/Result.h	(revision 4037)
+++ /issm/trunk/src/c/objects/Results/Result.h	(revision 4037)
@@ -0,0 +1,25 @@
+/*!\file:  Result.h
+ * \brief abstract class for Result object
+ */ 
+
+
+#ifndef _RESULT_H_
+#define _RESULT_H_
+
+/*Headers:*/
+/*{{{1*/
+#include "../Object.h"
+/*}}}*/
+
+class Result: public Object{
+
+	public: 
+		
+		virtual        ~Result(){};
+		
+		virtual Result* SpawnSingResult(int  index)=0;
+		virtual Result* SpawnBeamResult(int* indices)=0;
+		virtual Result* SpawnTriaResult(int* indices)=0;
+
+};
+#endif
Index: /issm/trunk/src/c/objects/Results/TriaVertexResult.cpp
===================================================================
--- /issm/trunk/src/c/objects/Results/TriaVertexResult.cpp	(revision 4037)
+++ /issm/trunk/src/c/objects/Results/TriaVertexResult.cpp	(revision 4037)
@@ -0,0 +1,196 @@
+/*!\file TriaVertexResult.c
+ * \brief: implementation of the TriaVertexResult object
+ */
+
+#ifdef HAVE_CONFIG_H
+	#include "config.h"
+#else
+#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
+#endif
+
+#include "stdio.h"
+#include <string.h>
+#include "./ResultLocal.h"
+#include "../objects.h"
+#include "../../EnumDefinitions/EnumDefinitions.h"
+#include "../../shared/shared.h"
+#include "../../DataSet/DataSet.h"
+#include "../../include/include.h"
+
+/*Object constructors and destructor*/
+/*FUNCTION TriaVertexResult::TriaVertexResult(){{{1*/
+TriaVertexResult::TriaVertexResult(){
+	return;
+}
+/*}}}*/
+/*FUNCTION TriaVertexResult::TriaVertexResult(int in_enum_type,double* in_values,int in_step, double in_time){{{1*/
+TriaVertexResult::TriaVertexResult(int in_enum_type,double* in_values,int in_step, double in_time):TriaVertexInput(in_enum_type,in_values){
+
+	step=in_step;
+	time=in_time;
+}
+/*}}}*/
+/*FUNCTION TriaVertexResult::~TriaVertexResult(){{{1*/
+TriaVertexResult::~TriaVertexResult(){
+	return;
+}
+/*}}}*/
+
+/*Object management*/
+/*FUNCTION TriaVertexResult::copy{{{1*/
+Object* TriaVertexResult::copy() {
+	
+	return new TriaVertexResult(this->enum_type,this->values,this->step,this->time);
+
+}
+/*}}}*/
+/*FUNCTION TriaVertexResult::DeepEcho{{{1*/
+void TriaVertexResult::DeepEcho(void){
+		
+	printf("TriaVertexResult:\n");
+	TriaVertexResult::DeepEcho();
+	printf("   step: %i\n",this->step);
+	printf("   time: %g\n",this->time);
+
+}
+/*}}}*/
+/*FUNCTION TriaVertexResult::Demarshall{{{1*/
+void  TriaVertexResult::Demarshall(char** pmarshalled_dataset){
+
+	char* marshalled_dataset=NULL;
+	int   i;
+
+	/*recover marshalled_dataset: */
+	marshalled_dataset=*pmarshalled_dataset;
+
+	/*this time, no need to get enum type, the pointer directly points to the beginning of the 
+	 *object data (thanks to DataSet::Demarshall):*/
+	memcpy(&enum_type,marshalled_dataset,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
+	memcpy(&values,marshalled_dataset,sizeof(values));marshalled_dataset+=sizeof(values);
+	memcpy(&time,marshalled_dataset,sizeof(time));marshalled_dataset+=sizeof(time);
+	memcpy(&step,marshalled_dataset,sizeof(step));marshalled_dataset+=sizeof(step);
+
+	/*return: */
+	*pmarshalled_dataset=marshalled_dataset;
+	return;
+}
+/*}}}*/
+/*FUNCTION TriaVertexResult::Echo {{{1*/
+void TriaVertexResult::Echo(void){
+	this->DeepEcho();
+}
+/*}}}*/
+/*FUNCTION TriaVertexResult::Enum{{{1*/
+int TriaVertexResult::Enum(void){
+
+	return TriaVertexResultEnum;
+
+}
+/*}}}*/
+/*FUNCTION TriaVertexResult::EnumType{{{1*/
+int TriaVertexResult::EnumType(void){
+
+	return this->enum_type;
+
+}
+/*}}}*/
+/*FUNCTION TriaVertexResult::Id{{{1*/
+int    TriaVertexResult::Id(void){ return -1; }
+/*}}}*/
+/*FUNCTION TriaVertexResult::Marshall{{{1*/
+void  TriaVertexResult::Marshall(char** pmarshalled_dataset){
+
+	char* marshalled_dataset=NULL;
+	int   enum_value=0;
+
+	/*recover marshalled_dataset: */
+	marshalled_dataset=*pmarshalled_dataset;
+
+	/*get enum value of TriaVertexResult: */
+	enum_value=TriaVertexResultEnum;
+	
+	/*marshall enum: */
+	memcpy(marshalled_dataset,&enum_value,sizeof(enum_value));marshalled_dataset+=sizeof(enum_value);
+	
+	/*marshall TriaVertexResult data: */
+	memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
+	memcpy(marshalled_dataset,&values,sizeof(values));marshalled_dataset+=sizeof(values);
+	memcpy(marshalled_dataset,&time,sizeof(time));marshalled_dataset+=sizeof(time);
+	memcpy(marshalled_dataset,&step,sizeof(step));marshalled_dataset+=sizeof(step);
+
+	*pmarshalled_dataset=marshalled_dataset;
+}
+/*}}}*/
+/*FUNCTION TriaVertexResult::MarshallSize{{{1*/
+int   TriaVertexResult::MarshallSize(){
+	
+	return sizeof(values)+
+		+sizeof(enum_type)
+		+sizeof(time)
+		+sizeof(step)
+		+sizeof(int); //sizeof(int) for enum value
+}
+/*}}}*/
+/*FUNCTION TriaVertexResult::MyRank{{{1*/
+int    TriaVertexResult::MyRank(void){ 
+	extern int my_rank;
+	return my_rank; 
+}
+/*}}}*/
+
+/*Result functions*/
+/*FUNCTION TriaVertexResult::SpawnSingResult{{{1*/
+Result* TriaVertexResult::SpawnSingResult(int index){
+
+	/*output*/
+	SingVertexResult* outresult=NULL;
+
+	/*Create new Sing result (copy of current result)*/
+	ISSMASSERT(index<3 && index>=0);
+	outresult=new SingVertexResult(this->enum_type,this->values[index],this->step,this->time);
+
+	/*Assign output*/
+	return outresult;
+
+}
+/*}}}*/
+/*FUNCTION BeamVertexResult::SpawnBeamResult{{{1*/
+Result* TriaVertexResult::SpawnBeamResult(int* indices){
+
+	/*output*/
+	BeamVertexResult* outresult=NULL;
+	double newvalues[2];
+
+	/*Loop over the new indices*/
+	for(int i=0;i<2;i++){
+
+		/*Check index value*/
+		ISSMASSERT(indices[i]>=0 && indices[i]<3);
+
+		/*Assign value to new result*/
+		newvalues[i]=this->values[indices[i]];
+	}
+
+	/*Create new Beam result*/
+	outresult=new BeamVertexResult(this->enum_type,&newvalues[0],this->step,this->time);
+
+	/*Assign output*/
+	return outresult;
+
+}
+/*}}}*/
+/*FUNCTION TriaVertexResult::SpawnTriaResult{{{1*/
+Result* TriaVertexResult::SpawnTriaResult(int* indices){
+
+	/*output*/
+	TriaVertexResult* outresult=NULL;
+
+	/*Create new Tria result (copy of current result)*/
+	outresult=new TriaVertexResult(this->enum_type,&this->values[0],this->step,this->time);
+
+	/*Assign output*/
+	return outresult;
+
+}
+/*}}}*/
+
Index: /issm/trunk/src/c/objects/Results/TriaVertexResult.h
===================================================================
--- /issm/trunk/src/c/objects/Results/TriaVertexResult.h	(revision 4037)
+++ /issm/trunk/src/c/objects/Results/TriaVertexResult.h	(revision 4037)
@@ -0,0 +1,47 @@
+/*! \file TriaVertexResult.h 
+ *  \brief: header file for triavertexresult object
+ */
+
+
+#ifndef _TRIAVERTEXRESULT_H_
+#define _TRIAVERTEXRESULT_H_
+
+/*Headers:*/
+/*{{{1*/
+#include "../Inputs/Input.h"
+#include "../../include/include.h"
+/*}}}*/
+
+class TriaVertexResult: public TriaVertexInput,public Result{
+
+	private: 
+		int    step;
+		double time;
+
+	public:
+
+		/*constructors, destructors: {{{1*/
+		TriaVertexResult();
+		TriaVertexResult(int enum_type,double* values,int step,double time);
+		~TriaVertexResult();
+		/*}}}*/
+		/*object management: {{{1*/
+		void  DeepEcho();
+		void  Echo();
+		int   Id(); 
+		void  Marshall(char** pmarshalled_dataset);
+		int   MarshallSize();
+		void  Demarshall(char** pmarshalled_dataset);
+		int   Enum();
+		int   MyRank();
+		Object* copy();
+		int   EnumType();
+		/*}}}*/
+		/*result virtual functions: {{{1*/
+		Result* SpawnSingResult(int  index);
+		Result* SpawnBeamResult(int* indices);
+		Result* SpawnTriaResult(int* indices);
+		/*}}}*/
+
+};
+#endif  /* _TRIAVERTEXRESULT_H */
Index: /issm/trunk/src/c/objects/objects.h
===================================================================
--- /issm/trunk/src/c/objects/objects.h	(revision 4036)
+++ /issm/trunk/src/c/objects/objects.h	(revision 4037)
@@ -15,5 +15,4 @@
 #include "./Node.h"
 #include "./NodeSets.h"
-#include "./Result.h"
 #include "./IoModel.h"
 
@@ -52,7 +51,7 @@
 /*Results: */
 #include "./Results/Result.h"
-#include "./Results/StringResult.h"
-#include "./Results/DoubleVecResult.h"
-#include "./Results/DoubleMatResult.h"
+#include "./Results/DoubleResult.h"
+#include "./Results/TriaVertexResult.h"
+#include "./Results/PentaVertexResult.h"
 
 /*Materials: */
Index: /issm/trunk/src/c/solutions/bedslope_core.cpp
===================================================================
--- /issm/trunk/src/c/solutions/bedslope_core.cpp	(revision 4036)
+++ /issm/trunk/src/c/solutions/bedslope_core.cpp	(revision 4037)
@@ -1,4 +1,4 @@
 /*!\file: bedslope_core.cpp
- * \brief: core of the bed slope solution 
+ * \brief: core of the slope solution 
  */ 
 
@@ -17,7 +17,4 @@
 	bool ishutter;
 
-	Vec slopex=NULL;
-	Vec slopey=NULL;
-
 	/*Recover some parameters: */
 	femmodel->parameters->FindParam(&verbose,VerboseEnum);
@@ -27,12 +24,8 @@
 
 	/*Call on core computations: */
-	solver_linear(&slopex,femmodel,SlopeComputeAnalysisEnum,BedSlopeXAnalysisEnum);
-	solver_linear(&slopey,femmodel,SlopeComputeAnalysisEnum,BedSlopeYAnalysisEnum);
+	solver_linear(NULL,femmodel,SlopeComputeAnalysisEnum,BedSlopeXAnalysisEnum);
+	solver_linear(NULL,femmodel,SlopeComputeAnalysisEnum,BedSlopeYAnalysisEnum);
 	
-	/*Plug solution into inputs: */
-	UpdateInputsFromSolutionx( femmodel->elements,femmodel->nodes, femmodel->vertices, femmodel->loads, femmodel->materials, femmodel->parameters,slopex,SlopeComputeAnalysisEnum,BedSlopeXAnalysisEnum);
-	UpdateInputsFromSolutionx( femmodel->elements,femmodel->nodes, femmodel->vertices, femmodel->loads, femmodel->materials, femmodel->parameters,slopey,SlopeComputeAnalysisEnum,BedSlopeYAnalysisEnum);
-
-	/*extrude if we are in 3D: */
+	/*extrude inputs if we are in 3D: */
 	if (dim==3){
 		if(verbose)_printf_("%s\n","extruding slope in 3d...");
@@ -40,7 +33,3 @@
 		InputsExtrudex( femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,BedSlopeYEnum,0);
 	}
-
-	/*Free ressources:*/
-	VecFree(&slopex);
-	VecFree(&slopey);
 }
Index: /issm/trunk/src/c/solutions/diagnostic.cpp
===================================================================
--- /issm/trunk/src/c/solutions/diagnostic.cpp	(revision 4036)
+++ /issm/trunk/src/c/solutions/diagnostic.cpp	(revision 4037)
@@ -26,11 +26,9 @@
 	bool  qmu_analysis=false;
 	bool  control_analysis=false;
+	bool waitonlock=false;
 
 	/*FemModel: */
 	FemModel* femmodel=NULL;
 
-	/*Results: */
-	bool waitonlock=false;
-	
 	/*time*/
 	double   start, finish;
@@ -66,5 +64,5 @@
 	fid=pfopen(inputfilename,"rb");
 
-	_printf_("create finite element model, using analyses types statically defined above:\n");
+	_printf_("create finite element model:\n");
 	femmodel=new FemModel(fid,solution_type,analyses,5);
 	
@@ -96,5 +94,5 @@
 
 		_printf_("write results to disk:\n");
-		OutputResults(femmodel,outputfilename,DiagnosticAnalysisEnum);
+		OutputResults(femmodel,outputfilename,DiagnosticSolutionEnum);
 	}
 	else{
Index: /issm/trunk/src/c/solutions/diagnostic_core.cpp
===================================================================
--- /issm/trunk/src/c/solutions/diagnostic_core.cpp	(revision 4036)
+++ /issm/trunk/src/c/solutions/diagnostic_core.cpp	(revision 4037)
@@ -46,5 +46,5 @@
 			
 		if(verbose)_printf_("%s\n"," computing hutter velocities...");
-		solver_linear(NULL,femmodel,DiagnosticAnalysisEnum,HutterAnalysisEnum);
+		solver_linear(NULL,femmodel,DiagnosticAnalysisEnum,HutterAnalysisEnum); 
 		
 		if (ismacayealpattyn) ResetBoundaryConditions(femmodel,DiagnosticAnalysisEnum,HorizAnalysisEnum);
@@ -76,3 +76,11 @@
 		}
 	}
+
+	if(verbose)_printf_("saving results:\n");
+	InputToResultx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,VxEnum);
+	InputToResultx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,VyEnum);
+	InputToResultx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,PressureEnum);
+	if(dim==3) InputToResultx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,VxEnum);
+
+	
 }
Index: /issm/trunk/src/c/solutions/surfaceslope_core.cpp
===================================================================
--- /issm/trunk/src/c/solutions/surfaceslope_core.cpp	(revision 4036)
+++ /issm/trunk/src/c/solutions/surfaceslope_core.cpp	(revision 4037)
@@ -17,7 +17,4 @@
 	bool ishutter;
 
-	Vec slopex=NULL;
-	Vec slopey=NULL;
-
 	/*Recover some parameters: */
 	femmodel->parameters->FindParam(&verbose,VerboseEnum);
@@ -27,12 +24,8 @@
 
 	/*Call on core computations: */
-	solver_linear(&slopex,femmodel,SlopeComputeAnalysisEnum,SurfaceSlopeXAnalysisEnum);
-	solver_linear(&slopey,femmodel,SlopeComputeAnalysisEnum,SurfaceSlopeYAnalysisEnum);
+	solver_linear(NULL,femmodel,SlopeComputeAnalysisEnum,SurfaceSlopeXAnalysisEnum);
+	solver_linear(NULL,femmodel,SlopeComputeAnalysisEnum,SurfaceSlopeYAnalysisEnum);
 	
-	/*Plug solution into inputs: */
-	UpdateInputsFromSolutionx( femmodel->elements,femmodel->nodes, femmodel->vertices, femmodel->loads, femmodel->materials, femmodel->parameters,slopex,SlopeComputeAnalysisEnum,SurfaceSlopeXAnalysisEnum);
-	UpdateInputsFromSolutionx( femmodel->elements,femmodel->nodes, femmodel->vertices, femmodel->loads, femmodel->materials, femmodel->parameters,slopey,SlopeComputeAnalysisEnum,SurfaceSlopeYAnalysisEnum);
-
-	/*extrude if we are in 3D: */
+	/*extrude inputs if we are in 3D: */
 	if (dim==3){
 		if(verbose)_printf_("%s\n","extruding slope in 3d...");
@@ -40,7 +33,3 @@
 		InputsExtrudex( femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,SurfaceSlopeYEnum,0);
 	}
-
-	/*Free ressources:*/
-	VecFree(&slopex);
-	VecFree(&slopey);
 }
Index: /issm/trunk/src/c/solutions/thermal.cpp
===================================================================
--- /issm/trunk/src/c/solutions/thermal.cpp	(revision 4036)
+++ /issm/trunk/src/c/solutions/thermal.cpp	(revision 4037)
@@ -27,22 +27,17 @@
 	char* lockname=NULL;
 	bool  qmu_analysis=false;
-	int   numberofnodes;
 	bool  waitonlock=false;
 
-	/*Model: */
-	Model* model=NULL;
-
-	/*Results: */
-	Results* results=NULL;
+	/*FemModel: */
+	FemModel* femmodel=NULL;
 	
-	Param*           param=NULL;
-	double  dt;
-	double  yts;
-
 	/*time*/
 	double   start, finish;
 	double   start_core, finish_core;
 	double   start_init, finish_init;
-		
+
+	int analyses[2]={ThermalAnalysisEnum,MeltingAnalysisEnum};
+	int solution_type=ThermalSolutionEnum;
+
 	MODULEBOOT();
 
@@ -59,23 +54,21 @@
 	MPI_Comm_size(MPI_COMM_WORLD,&num_procs); 
 
+	_printf_("recover , input file name and output file name:\n");
 	inputfilename=argv[2];
 	outputfilename=argv[3];
 	lockname=argv[4];
 
+	/*Initialize femmodel structure: */
+	MPI_Barrier(MPI_COMM_WORLD); start_init=MPI_Wtime();
+
 	/*Open handle to data on disk: */
 	fid=pfopen(inputfilename,"rb");
 
-	/*Initialize model structure: */
-	MPI_Barrier(MPI_COMM_WORLD); start_init=MPI_Wtime();
-	model=new Model();
+	_printf_("create finite element model:\n");
+	femmodel=new FemModel(fid,solution_type,analyses,2);
 
-	_printf_("read and create thermal finite element model:\n");
-	model->AddFormulation(fid,ThermalAnalysisEnum);
-	_printf_("read and create melting finite element model:\n");
-	model->AddFormulation(fid,MeltingAnalysisEnum);
-
-	/*recover parameters: */
-	model->FindParam(&waitonlock,WaitOnLockEnum);
-	model->FindParam(&qmu_analysis,QmuAnalysisEnum);
+	/*get parameters: */
+	femmodel->parameters->FindParam(&qmu_analysis,QmuAnalysisEnum);
+	femmodel->parameters->FindParam(&waitonlock,WaitOnLockEnum);
 
 	MPI_Barrier(MPI_COMM_WORLD); finish_init=MPI_Wtime();
@@ -87,11 +80,14 @@
 		_printf_("call computational core:\n");
 		MPI_Barrier(MPI_COMM_WORLD); start_core=MPI_Wtime( );
-		results=thermal_core(model);
+		thermal_core(femmodel);
 		MPI_Barrier(MPI_COMM_WORLD); finish_core=MPI_Wtime( );
+		
+		
+		_printf_("write results to disk:\n");
+		OutputResults(femmodel,outputfilename,ThermalSolutionEnum);
 
-		_printf_("write results to disk:\n");
-		OutputResults(results,outputfilename);
 	}
 	else{
+	
 		/*run qmu analysis: */
 		_printf_("calling qmu analysis on thermal core:\n");
@@ -112,6 +108,5 @@
 
 	/*Free ressources */
-	delete model;
-	delete results;
+	delete femmodel;
 
 	/*Get finish time and close*/
Index: /issm/trunk/src/c/solutions/thermal_core.cpp
===================================================================
--- /issm/trunk/src/c/solutions/thermal_core.cpp	(revision 4036)
+++ /issm/trunk/src/c/solutions/thermal_core.cpp	(revision 4037)
@@ -9,124 +9,46 @@
 #include "./solutions.h"
 #include "../modules/modules.h"
+#include "../include/include.h"
 
-Results* thermal_core(Model* model){
+void thermal_core(FemModel* femmodel){
 
-	extern int my_rank;
 	int i;
 
-	/*fem models: */
-	FemModel* fem_t=NULL;
-	FemModel* fem_m=NULL;
-
-	/*output: */
-	Results* results=NULL;
-	Result*  result=NULL;
-
-	/*solutions vectors: */
-	Vec*    t_g=NULL;
-	Vec*    m_g=NULL;
-	double* time=NULL;
-	double* t_g_serial=NULL;
-	double* m_g_serial=NULL;
-
 	/*intermediary*/
-	Vec Vect=NULL;
-	Vec Vecm=NULL;
-
-	/*flags: */
-	int    verbose=0;
-	int    numberofdofspernode;
-	int    numberofnodes;
+	double time;
+	int    verbose;
 	int    nsteps;
 	double ndt;
 	double dt;
-
-	int    sub_analysis_type;
 	double melting_offset;
 
-	//initialize results
-	results=new Results();
+	//first recover parameters common to all solutions
+	femmodel->parameters->FindParam(&verbose,VerboseEnum);
+	femmodel->parameters->FindParam(&ndt,NdtEnum);
+	femmodel->parameters->FindParam(&dt,DtEnum);
 
-	/*recover fem models: */
-	fem_t=model->GetFormulation(ThermalAnalysisEnum);
-	fem_m=model->GetFormulation(MeltingAnalysisEnum);
+	/*Compute number of time steps: */
+	if((dt==0)|| (ndt==0)){
+		dt=0;
+		nsteps=1;
+	}
+	else nsteps=(int)(ndt/dt);
 
-	//first recover parameters common to all solutions
-	fem_t->parameters->FindParam(&numberofnodes,NumberOfNodesEnum);
-	fem_t->parameters->FindParam(&sub_analysis_type,SubAnalysisTypeEnum);
-	fem_t->parameters->FindParam(&verbose,VerboseEnum);
-	fem_t->parameters->FindParam(&ndt,NdtEnum);
-	fem_t->parameters->FindParam(&dt,DtEnum);
-
-	if(dt==0){
-
-		time=(double*)xmalloc(sizeof(double));
-		time[0]=0;
-
-		/*allocate t_g and m_g arrays: */
-		t_g=(Vec*)xmalloc(sizeof(Vec));
-		m_g=(Vec*)xmalloc(sizeof(Vec));
+	/*Loop through time: */
+	for(i=0;i<nsteps;i++){
+		
+		if(verbose)_printf_("time step: %i/%i\n",i+1,nsteps);
+		time=(i+1)*dt;
 
 		if(verbose)_printf_("computing temperatures:\n");
-		thermal_core_nonlinear(&t_g[0],&melting_offset,fem_t,ThermalAnalysisEnum,NoneAnalysisEnum);
-		model->UpdateInputsFromVector(t_g[0],TemperatureEnum,VertexEnum);
-		model->UpdateInputsFromConstant(melting_offset,MeltingOffsetEnum);
-		
+		solver_thermal_nonlinear(NULL,NULL,femmodel,ThermalAnalysisEnum,NoneAnalysisEnum);
+
 		if(verbose)_printf_("computing melting:\n");
-		diagnostic_core_linear(&m_g[0],fem_m,MeltingAnalysisEnum,NoneAnalysisEnum);
+		solver_linear(NULL,femmodel,MeltingAnalysisEnum,NoneAnalysisEnum);
+
+		if(verbose)_printf_("saving results:\n");
+		InputToResultx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,TemperatureEnum,i,time);
+		InputToResultx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,MeltingRateEnum,i,time);
+
 	}
-	else{
-		
-		nsteps=(int)(ndt/dt);
-		time=(double*)xmalloc((nsteps)*sizeof(double));
-
-		/*allocate t_g and m_g arrays: */
-		t_g=(Vec*)xmalloc((nsteps)*sizeof(Vec));
-		m_g=(Vec*)xmalloc((nsteps)*sizeof(Vec));
-
-		for(i=0;i<nsteps;i++){
-			if(verbose)_printf_("time step: %i/%i\n",i+1,nsteps);
-			time[i]=(i+1)*dt;
-			
-			if(verbose)_printf_("computing temperatures:\n");
-			thermal_core_nonlinear(&t_g[i],&melting_offset,fem_t,ThermalAnalysisEnum,NoneAnalysisEnum);
-			
-			if(verbose)_printf_("computing melting:\n");
-			model->UpdateInputsFromVector(t_g[i],TemperatureEnum,VertexEnum);
-			model->UpdateInputsFromConstant(melting_offset,MeltingOffsetEnum);
-			diagnostic_core_linear(&m_g[i],fem_m,MeltingAnalysisEnum,NoneAnalysisEnum);
-		}
-	}
-	
-	/*Plug results into output dataset: */
-	if(dt==0){
-		InputToResultx(&result,fem_t->elements,fem_t->nodes,fem_t->vertices, fem_t->loads, fem_t->materials,fem_t->parameters,TemperatureEnum,results->Size()+1,0,1); results->AddObject(result);
-		InputToResultx(&result,fem_m->elements,fem_m->nodes,fem_m->vertices, fem_m->loads, fem_m->materials,fem_m->parameters,MeltingRateEnum,results->Size()+1,0,1); results->AddObject(result);
-
-		/*free ressource*/
-		Vect=t_g[0];    Vecm=m_g[0];
-		VecFree(&Vect); VecFree(&Vecm);
-	}
-	else{
-		for(i=0;i<nsteps;i++){
-			/*To be moved inside the loop!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
-			InputToResultx(&result,fem_t->elements,fem_t->nodes,fem_t->vertices, fem_t->loads, fem_t->materials,fem_t->parameters,TemperatureEnum,results->Size()+1,time[i],i+1); results->AddObject(result);
-			InputToResultx(&result,fem_m->elements,fem_m->nodes,fem_m->vertices, fem_m->loads, fem_m->materials,fem_m->parameters,MeltingRateEnum,results->Size()+1,time[i],i+1); results->AddObject(result);
-
-			/*free ressource*/
-			Vect=t_g[i];    Vecm=m_g[i];
-			VecFree(&Vect); VecFree(&Vecm);
-		}
-	}
-	/*Add analysis_type to results: */
-	results->AddObject(new StringResult(results->Size()+1,AnalysisTypeEnum,0,1,EnumAsString(ThermalAnalysisEnum)));
-
-	/*free ressource*/
-	xfree((void**)&t_g);
-	xfree((void**)&m_g);
-	xfree((void**)&time);
-	
-	//return: 
-	return results;
-
 }
