Index: /issm/trunk/src/c/DataSet/DataSet.cpp
===================================================================
--- /issm/trunk/src/c/DataSet/DataSet.cpp	(revision 3846)
+++ /issm/trunk/src/c/DataSet/DataSet.cpp	(revision 3847)
@@ -364,9 +364,4 @@
 	
 	return dataset;
-}
-/*}}}*/
-/*FUNCTION DataSet::Spawn{{{1*/
-DataSet* DataSet::Spawn(int* indices, int num){
-	ISSMERROR(" not supported yet!");
 }
 /*}}}*/
Index: /issm/trunk/src/c/DataSet/DataSet.h
===================================================================
--- /issm/trunk/src/c/DataSet/DataSet.h	(revision 3846)
+++ /issm/trunk/src/c/DataSet/DataSet.h	(revision 3847)
@@ -101,5 +101,4 @@
 		void  UpdateVertexPositions(double* thickness,double* bed);
 		void  OutputRifts(Vec riftproperties);
-		DataSet* Spawn(int* indices, int num);
 		/*}}}*/
 
@@ -129,4 +128,5 @@
 		/*numerics: {{{1*/
 		int  AddInput(Input* in_input);
+		Inputs* SpawnTriaInputs(int* indices);
 		
 		void GetParameterValue(bool* pvalue,int enum_type);
Index: /issm/trunk/src/c/DataSet/Inputs.cpp
===================================================================
--- /issm/trunk/src/c/DataSet/Inputs.cpp	(revision 3846)
+++ /issm/trunk/src/c/DataSet/Inputs.cpp	(revision 3847)
@@ -413,2 +413,28 @@
 }
 /*}}}*/
+/*FUNCTION Inputs::SpawnTriaInputs{{{1*/
+Inputs* Inputs::SpawnTriaInputs(int* indices){
+
+	/*Intermediary*/
+	vector<Object*>::iterator object;
+	Input* inputin=NULL;
+	Input* inputout=NULL;
+
+	/*Output*/
+	Inputs* newinputs=new Inputs();
+
+	/*Go through inputs and call Spawn function*/
+	for ( object=objects.begin() ; object < objects.end(); object++ ){
+
+		/*Create new input*/
+		inputin=(Input*)(*object); 
+		inputout=inputin->SpawnTriaInput(indices);
+
+		/*Add input to new inputs*/
+		newinputs->AddObject(inputout);
+	}
+
+	/*Assign output pointer*/
+	return newinputs;
+}
+/*}}}*/
Index: /issm/trunk/src/c/objects/Elements/Beam.cpp
===================================================================
--- /issm/trunk/src/c/objects/Elements/Beam.cpp	(revision 3846)
+++ /issm/trunk/src/c/objects/Elements/Beam.cpp	(revision 3847)
@@ -375,5 +375,4 @@
 /*}}}*/
 /*FUNCTION Beam::CreateKMatrix{{{1*/
-
 void  Beam::CreateKMatrix(Mat Kgg,int analysis_type,int sub_analysis_type){
 
Index: /issm/trunk/src/c/objects/Elements/Penta.cpp
===================================================================
--- /issm/trunk/src/c/objects/Elements/Penta.cpp	(revision 3846)
+++ /issm/trunk/src/c/objects/Elements/Penta.cpp	(revision 3847)
@@ -392,5 +392,5 @@
 	tria_hmatpar=this->hmatpar.Spawn(&zero,1);
 	tria_parameters=this->parameters;
-	tria_inputs=(Inputs*)this->inputs->Spawn(indices,3);
+	tria_inputs=(Inputs*)this->inputs->SpawnTriaInputs(indices);
 	
 	tria=new Tria();
@@ -412,5 +412,4 @@
 	delete tria_hmatice;
 	delete tria_hmatpar;
-	delete tria_inputs;
 
 	return tria;
@@ -817,6 +816,8 @@
 /*}}}*/
 /*FUNCTION CreateKMatrix {{{1*/
-
 void  Penta::CreateKMatrix(Mat Kgg,int analysis_type,int sub_analysis_type){
+
+	/*if debugging mode, check that all pointers exist*/
+	ISSMASSERT(this->nodes && this->matice && this->matpar && this->neighbors && this->parameters && this->inputs);
 
 	/*Just branch to the correct element stiffness matrix generator, according to the type of analysis we are carrying out: */
@@ -933,5 +934,4 @@
 /*FUNCTION CreateKMatrixDiagnosticHoriz {{{1*/
 void Penta::CreateKMatrixDiagnosticHoriz( Mat Kgg,  int analysis_type,int sub_analysis_type){
-
 
 	/* local declarations */
@@ -1880,4 +1880,7 @@
 /*FUNCTION CreatePVector {{{1*/
 void  Penta::CreatePVector(Vec pg,  int analysis_type,int sub_analysis_type){
+
+	/*if debugging mode, check that all pointers exist*/
+	ISSMASSERT(this->nodes && this->matice && this->matpar && this->neighbors && this->parameters && this->inputs);
 
 	/*Just branch to the correct element stiffness matrix generator, according to the type of analysis we are carrying out: */
Index: /issm/trunk/src/c/objects/Elements/Tria.cpp
===================================================================
--- /issm/trunk/src/c/objects/Elements/Tria.cpp	(revision 3846)
+++ /issm/trunk/src/c/objects/Elements/Tria.cpp	(revision 3847)
@@ -273,13 +273,24 @@
 	printf("Tria:\n");
 	printf("   id: %i\n",id);
-	nodes[0]->DeepEcho();
-	nodes[1]->DeepEcho();
-	nodes[2]->DeepEcho();
-	matice->DeepEcho();
-	matpar->DeepEcho();
+	if(nodes){
+		nodes[0]->DeepEcho();
+		nodes[1]->DeepEcho();
+		nodes[2]->DeepEcho();
+	}
+	else printf("nodes = NULL\n");
+
+	if (matice) matice->DeepEcho();
+	else printf("matice = NULL\n");
+
+	if (matpar) matpar->DeepEcho();
+	else printf("matpar = NULL\n");
+
 	printf("   parameters\n");
-	parameters->DeepEcho();
+	if (parameters) parameters->DeepEcho();
+	else printf("parameters = NULL\n");
+
 	printf("   inputs\n");
-	inputs->DeepEcho();
+	if (inputs) inputs->DeepEcho();
+	else printf("inputs=NULL\n");
 	
 	return;
@@ -696,6 +707,8 @@
 /*}}}*/
 /*FUNCTION Tria::CreateKMatrix {{{1*/
-
 void  Tria::CreateKMatrix(Mat Kgg,int analysis_type,int sub_analysis_type){
+
+	/*if debugging mode, check that all pointers exist*/
+	ISSMASSERT(this->nodes && this->matice && this->matpar && this->parameters && this->inputs);
 
 	/*Just branch to the correct element stiffness matrix generator, according to the type of analysis we are carrying out: */
@@ -2081,4 +2094,7 @@
 void  Tria::CreatePVector(Vec pg,int analysis_type,int sub_analysis_type){
 	
+	/*if debugging mode, check that all pointers exist*/
+	ISSMASSERT(this->nodes && this->matice && this->matpar && this->parameters && this->inputs);
+
 	/*Just branch to the correct load generator, according to the type of analysis we are carrying out: */
 	if (analysis_type==ControlAnalysisEnum){
Index: /issm/trunk/src/c/objects/Inputs/BeamVertexInput.cpp
===================================================================
--- /issm/trunk/src/c/objects/Inputs/BeamVertexInput.cpp	(revision 3846)
+++ /issm/trunk/src/c/objects/Inputs/BeamVertexInput.cpp	(revision 3847)
@@ -49,6 +49,6 @@
 
 	printf("BeamVertexInput:\n");
-	printf("   enum: %i\n",this->enum_type);
-	printf("   %g|%g\n",this->values[0],this->values[1]);
+	printf("   enum: %i (%s)\n",this->enum_type,EnumAsString(this->enum_type));
+	printf("   values: [%g %g]\n",this->values[0],this->values[1]);
 }
 /*}}}*/
@@ -130,4 +130,11 @@
 }
 /*}}}*/
+/*FUNCTION BeamVertexInput::SpawnTriaInput{{{1*/
+Input* BeamVertexInput::SpawnTriaInput(int* indices){
+
+	ISSMERROR("Cannot spaw a Tria from a Beam");
+
+}
+/*}}}*/
 
 /*Object functions*/
Index: /issm/trunk/src/c/objects/Inputs/BeamVertexInput.h
===================================================================
--- /issm/trunk/src/c/objects/Inputs/BeamVertexInput.h	(revision 3846)
+++ /issm/trunk/src/c/objects/Inputs/BeamVertexInput.h	(revision 3847)
@@ -38,14 +38,14 @@
 		Object* copy();
 		int   EnumType();
-		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  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!");}
+		void  UpdateInputsFromSolution(double* solution, int analysis_type, int sub_analysis_type){ISSMERROR("Not implemented yet!");}
 
-
+		Input* SpawnTriaInput(int* indices);
 		/*}}}*/
 		/*numerics: {{{1*/
Index: /issm/trunk/src/c/objects/Inputs/BoolInput.cpp
===================================================================
--- /issm/trunk/src/c/objects/Inputs/BoolInput.cpp	(revision 3846)
+++ /issm/trunk/src/c/objects/Inputs/BoolInput.cpp	(revision 3847)
@@ -48,6 +48,6 @@
 
 	printf("BoolInput:\n");
-	printf("   enum: %i\n",this->enum_type);
-	printf("   %s\n",value?"true":"false");
+	printf("   enum: %i (%s)\n",this->enum_type,EnumAsString(this->enum_type));
+	printf("   value: %s\n",value?"true":"false");
 }
 /*}}}*/
@@ -129,4 +129,19 @@
 }
 /*}}}*/
+/*FUNCTION BoolInput::SpawnTriaInput{{{1*/
+Input* BoolInput::SpawnTriaInput(int* indices){
+
+		/*output*/
+		BoolInput* outinput=new BoolInput();
+
+		/*only copy current value*/
+		outinput->enum_type=this->enum_type;
+		outinput->value=this->value;
+
+		/*Assign output*/
+		return outinput;
+
+}
+/*}}}*/
 
 /*Object functions*/
Index: /issm/trunk/src/c/objects/Inputs/BoolInput.h
===================================================================
--- /issm/trunk/src/c/objects/Inputs/BoolInput.h	(revision 3846)
+++ /issm/trunk/src/c/objects/Inputs/BoolInput.h	(revision 3847)
@@ -47,5 +47,5 @@
 		void    UpdateInputsFromSolution(double* solution, int analysis_type, int sub_analysis_type){ISSMERROR("Not implemented yet!");}
 
-
+		Input* SpawnTriaInput(int* indices);
 		/*}}}*/
 		/*numerics: {{{1*/
Index: /issm/trunk/src/c/objects/Inputs/DoubleInput.cpp
===================================================================
--- /issm/trunk/src/c/objects/Inputs/DoubleInput.cpp	(revision 3846)
+++ /issm/trunk/src/c/objects/Inputs/DoubleInput.cpp	(revision 3847)
@@ -48,6 +48,6 @@
 
 	printf("DoubleInput:\n");
-	printf("   enum: %i\n",this->enum_type);
-	printf("   %g\n",this->value);
+	printf("   enum: %i (%s)\n",this->enum_type,EnumAsString(this->enum_type));
+	printf("   value: %g\n",this->value);
 }
 /*}}}*/
@@ -129,4 +129,19 @@
 }
 /*}}}*/
+/*FUNCTION DoubleInput::SpawnTriaInput{{{1*/
+Input* DoubleInput::SpawnTriaInput(int* indices){
+
+	/*output*/
+	DoubleInput* outinput=new DoubleInput();
+
+	/*only copy current value*/
+	outinput->enum_type=this->enum_type;
+	outinput->value=this->value;
+
+	/*Assign output*/
+	return outinput;
+
+}
+/*}}}*/
 
 /*Object functions*/
Index: /issm/trunk/src/c/objects/Inputs/DoubleInput.h
===================================================================
--- /issm/trunk/src/c/objects/Inputs/DoubleInput.h	(revision 3846)
+++ /issm/trunk/src/c/objects/Inputs/DoubleInput.h	(revision 3847)
@@ -47,5 +47,5 @@
 		void    UpdateInputsFromSolution(double* solution, int analysis_type, int sub_analysis_type){ISSMERROR("Not implemented yet!");}
 
-
+		Input* SpawnTriaInput(int* indices);
 		/*}}}*/
 		/*numerics: {{{1*/
Index: /issm/trunk/src/c/objects/Inputs/Input.h
===================================================================
--- /issm/trunk/src/c/objects/Inputs/Input.h	(revision 3846)
+++ /issm/trunk/src/c/objects/Inputs/Input.h	(revision 3847)
@@ -42,4 +42,5 @@
 		virtual void GetVzStrainRate3d(double* epsilonvz,double* xyz_list, double* gauss,int formulation_enum=StokesFormulationEnum)=0;
 		virtual void ChangeEnum(int newenumtype)=0;
+		virtual Input* SpawnTriaInput(int* indices)=0;
 		/*}}}*/
 
Index: /issm/trunk/src/c/objects/Inputs/IntInput.cpp
===================================================================
--- /issm/trunk/src/c/objects/Inputs/IntInput.cpp	(revision 3846)
+++ /issm/trunk/src/c/objects/Inputs/IntInput.cpp	(revision 3847)
@@ -48,6 +48,6 @@
 
 	printf("IntInput:\n");
-	printf("   enum: %i\n",this->enum_type);
-	printf("   %i\n",this->value);
+	printf("   enum: %i (%s)\n",this->enum_type,EnumAsString(this->enum_type));
+	printf("   value: %i\n",this->value);
 }
 /*}}}*/
@@ -129,4 +129,18 @@
 }
 /*}}}*/
+/*FUNCTION IntInput::SpawnTriaInput{{{1*/
+Input* IntInput::SpawnTriaInput(int* indices){
+
+	/*output*/
+	IntInput* outinput=new IntInput();
+
+	/*only copy current value*/
+	outinput->enum_type=this->enum_type;
+	outinput->value=this->value;
+
+	/*Assign output*/
+	return outinput;
+}
+/*}}}*/
 
 /*Object functions*/
Index: /issm/trunk/src/c/objects/Inputs/IntInput.h
===================================================================
--- /issm/trunk/src/c/objects/Inputs/IntInput.h	(revision 3846)
+++ /issm/trunk/src/c/objects/Inputs/IntInput.h	(revision 3847)
@@ -47,5 +47,5 @@
 		void    UpdateInputsFromSolution(double* solution, int analysis_type, int sub_analysis_type){ISSMERROR("Not implemented yet!");}
 
-
+		Input* SpawnTriaInput(int* indices);
 		/*}}}*/
 		/*numerics: {{{1*/
Index: /issm/trunk/src/c/objects/Inputs/PentaVertexInput.cpp
===================================================================
--- /issm/trunk/src/c/objects/Inputs/PentaVertexInput.cpp	(revision 3846)
+++ /issm/trunk/src/c/objects/Inputs/PentaVertexInput.cpp	(revision 3847)
@@ -23,5 +23,5 @@
 }
 /*}}}*/
-/*FUNCTION PentaVertexInput::PentaVertexInput(double* values){{{1*/
+/*FUNCTION PentaVertexInput::PentaVertexInput(int in_enum_type,double* values){{{1*/
 PentaVertexInput::PentaVertexInput(int in_enum_type,double* in_values){
 
@@ -53,6 +53,6 @@
 
 	printf("PentaVertexInput:\n");
-	printf("   enum: %i\n",this->enum_type);
-	printf("   %g|%g|%g|%g|%g|%g\n",this->values[0],this->values[1],this->values[2],this->values[3],this->values[4],this->values[5]);
+	printf("   enum: %i (%s)\n",this->enum_type,EnumAsString(this->enum_type));
+	printf("   values: [%g %g %g %g %g %g]\n",this->values[0],this->values[1],this->values[2],this->values[3],this->values[4],this->values[5]);
 }
 /*}}}*/
@@ -132,4 +132,29 @@
 	extern int my_rank;
 	return my_rank; 
+}
+/*}}}*/
+/*FUNCTION PentaVertexInput::SpawnTriaInput{{{1*/
+Input* PentaVertexInput::SpawnTriaInput(int* indices){
+
+	/*output*/
+	TriaVertexInput* outinput=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 input*/
+		newvalues[i]=this->values[indices[i]];
+	}
+
+	/*Create new Tria input*/
+	outinput=new TriaVertexInput(this->enum_type,&newvalues[0]);
+
+	/*Assign output*/
+	return outinput;
+
 }
 /*}}}*/
Index: /issm/trunk/src/c/objects/Inputs/PentaVertexInput.h
===================================================================
--- /issm/trunk/src/c/objects/Inputs/PentaVertexInput.h	(revision 3846)
+++ /issm/trunk/src/c/objects/Inputs/PentaVertexInput.h	(revision 3847)
@@ -46,5 +46,5 @@
 		void    UpdateInputsFromSolution(double* solution, int analysis_type, int sub_analysis_type){ISSMERROR("Not implemented yet!");}
 
-
+		Input* SpawnTriaInput(int* indices);
 		/*}}}*/
 		/*numerics: {{{1*/
Index: /issm/trunk/src/c/objects/Inputs/SingVertexInput.cpp
===================================================================
--- /issm/trunk/src/c/objects/Inputs/SingVertexInput.cpp	(revision 3846)
+++ /issm/trunk/src/c/objects/Inputs/SingVertexInput.cpp	(revision 3847)
@@ -48,6 +48,6 @@
 
 	printf("SingVertexInput:\n");
-	printf("   enum: %i\n",this->enum_type);
-	printf("   %g\n",this->value);
+	printf("   enum: %i (%s)\n",this->enum_type,EnumAsString(this->enum_type));
+	printf("   value: %g\n",this->value);
 }
 /*}}}*/
@@ -129,4 +129,11 @@
 }
 /*}}}*/
+/*FUNCTION SingVertexInput::SpawnTriaInput{{{1*/
+Input* SingVertexInput::SpawnTriaInput(int* indices){
+
+	ISSMERROR("Cannot spaw a Tria from a Sing");
+
+}
+/*}}}*/
 
 /*Object functions*/
Index: /issm/trunk/src/c/objects/Inputs/SingVertexInput.h
===================================================================
--- /issm/trunk/src/c/objects/Inputs/SingVertexInput.h	(revision 3846)
+++ /issm/trunk/src/c/objects/Inputs/SingVertexInput.h	(revision 3847)
@@ -46,5 +46,5 @@
 		void    UpdateInputsFromSolution(double* solution, int analysis_type, int sub_analysis_type){ISSMERROR("Not implemented yet!");}
 
-
+		Input* SpawnTriaInput(int* indices);
 		/*}}}*/
 		/*numerics: {{{1*/
Index: /issm/trunk/src/c/objects/Inputs/TriaVertexInput.cpp
===================================================================
--- /issm/trunk/src/c/objects/Inputs/TriaVertexInput.cpp	(revision 3846)
+++ /issm/trunk/src/c/objects/Inputs/TriaVertexInput.cpp	(revision 3847)
@@ -23,5 +23,5 @@
 }
 /*}}}*/
-/*FUNCTION TriaVertexInput::TriaVertexInput(double* values){{{1*/
+/*FUNCTION TriaVertexInput::TriaVertexInput(int in_enum_type,double* values){{{1*/
 TriaVertexInput::TriaVertexInput(int in_enum_type,double* in_values){
 
@@ -50,6 +50,6 @@
 
 	printf("TriaVertexInput:\n");
-	printf("   enum: %i\n",this->enum_type);
-	printf("   %g|%g|%g\n",this->values[0],this->values[1],this->values[2]);
+	printf("   enum: %i (%s)\n",this->enum_type,EnumAsString(this->enum_type));
+	printf("   values: [%g %g %g]\n",this->values[0],this->values[1],this->values[2]);
 }
 /*}}}*/
@@ -129,4 +129,19 @@
 	extern int my_rank;
 	return my_rank; 
+}
+/*}}}*/
+/*FUNCTION TriaVertexInput::SpawnTriaInput{{{1*/
+Input* TriaVertexInput::SpawnTriaInput(int* indices){
+
+	/*output*/
+	TriaVertexInput* outinput=NULL;
+
+	/*Create new Tria input (copy of current input)*/
+	outinput=new TriaVertexInput(this->enum_type,&this->values[0]);
+
+	/*Assign output*/
+	return outinput;
+
+
 }
 /*}}}*/
Index: /issm/trunk/src/c/objects/Inputs/TriaVertexInput.h
===================================================================
--- /issm/trunk/src/c/objects/Inputs/TriaVertexInput.h	(revision 3846)
+++ /issm/trunk/src/c/objects/Inputs/TriaVertexInput.h	(revision 3847)
@@ -47,5 +47,5 @@
 		void    UpdateInputsFromSolution(double* solution, int analysis_type, int sub_analysis_type){ISSMERROR("Not implemented yet!");}
 
-
+		Input* SpawnTriaInput(int* indices);
 		/*}}}*/
 		/*numerics: {{{1*/
