Index: /issm/trunk/src/c/objects/Elements/Penta.cpp
===================================================================
--- /issm/trunk/src/c/objects/Elements/Penta.cpp	(revision 4368)
+++ /issm/trunk/src/c/objects/Elements/Penta.cpp	(revision 4369)
@@ -996,5 +996,5 @@
 	
 	/*Do nothing if we  don't find it: */
-	if(!input) return;
+	if(!input)return;
 
 	/*Constrain input using cm_min and cm_max: */
@@ -1045,5 +1045,4 @@
 	/*Make a copy of the original input: */
 	original=(Input*)this->inputs->GetInput(original_enum);
-	if(!original)ISSMERROR(" could not find old input with enum: %s",EnumAsString(original_enum));
 	copy=(Input*)original->copy();
 
@@ -1062,5 +1061,4 @@
 	/*Make a copy of the original input: */
 	input=(Input*)this->inputs->GetInput(enum_type);
-	if(!input)ISSMERROR(" could not find old input with enum: %s",EnumAsString(enum_type));
 
 	/*Scale: */
@@ -1765,4 +1763,8 @@
 
 	int i;
+	int analysis_counter;
+	
+	/*go into parameters and get the analysis_counter: */
+	this->parameters->FindParam(&analysis_counter,AnalysisCounterEnum);
 
 	/*out of grids g0,g1 and g2 from Penta, build a tria element: */
@@ -1787,11 +1789,11 @@
 	tria->results=tria_results;
 	tria->parameters=tria_parameters;
+	this->SpawnTriaHook(dynamic_cast<TriaHook*>(tria),&indices[0]);
+
+	/*recover nodes, matice and matpar: */
+	this->nodes=(Node**)this->hnodes[analysis_counter].deliverp();
+	this->matice=(Matice*)this->hmatice.delivers();
+	this->matpar=(Matpar*)this->hmatpar.delivers();
 	
-	/*now deal with nodes, matice and matpar: */
-	tria->nodes=(Node**)xmalloc(3*sizeof(Node*));
-	for(i=0;i<3;i++)tria->nodes[i]=this->nodes[indices[i]];
-	tria->matice=this->matice;
-	tria->matpar=this->matpar;
-
 	return tria;
 }
Index: /issm/trunk/src/c/objects/Elements/PentaHook.cpp
===================================================================
--- /issm/trunk/src/c/objects/Elements/PentaHook.cpp	(revision 4368)
+++ /issm/trunk/src/c/objects/Elements/PentaHook.cpp	(revision 4369)
@@ -62,2 +62,19 @@
 }
 /*}}}*/
+/*FUNCTION PentaHook::SpawnTriaHook(TriaHook* triahook,int* indices);{{{1*/
+void PentaHook::SpawnTriaHook(TriaHook* triahook,int* indices){
+
+	int i;
+	int zero=0;
+
+	triahook->numanalyses=this->numanalyses;
+	triahook->hnodes=new Hook[this->numanalyses];
+
+	for(i=0;i<this->numanalyses;i++){
+		this->hnodes[i].Spawn(&triahook->hnodes[i],indices,3);
+	}
+	
+	this->hmatice.copy(&triahook->hmatice);
+	this->hmatpar.copy(&triahook->hmatpar);
+}
+/*}}}*/
Index: /issm/trunk/src/c/objects/Elements/PentaHook.h
===================================================================
--- /issm/trunk/src/c/objects/Elements/PentaHook.h	(revision 4368)
+++ /issm/trunk/src/c/objects/Elements/PentaHook.h	(revision 4369)
@@ -7,4 +7,5 @@
 
 class Hook;
+class TriaHook;
 
 class PentaHook{
@@ -25,6 +26,6 @@
 		void InitHookMatpar(int matpar_id);
 		void InitHookNeighbors(int* element_ids);
+		void SpawnTriaHook(TriaHook* triahook,int* indices);
 		/*}}}*/
-
 };
 
Index: /issm/trunk/src/c/objects/Hook.cpp
===================================================================
--- /issm/trunk/src/c/objects/Hook.cpp	(revision 4368)
+++ /issm/trunk/src/c/objects/Hook.cpp	(revision 4369)
@@ -363,27 +363,21 @@
 /*}}}*/
 /*FUNCTION Hook::Spawn{{{1*/
-Hook* Hook::Spawn(int* indices, int numindices){
-
-	int i;
-	Object** subobjects=NULL;
-	int       subnum;
-	int*      suboffsets=NULL;
-	int*      subids=NULL;
+void Hook::Spawn(Hook* spawnedhook, int* indices, int numindices){
+
+	int i;
 
 	/*go pickup the correct objects, ids and offsets :*/
-	subnum=numindices;
-	if(subnum<1) ISSMERROR("Trying to spawn an empty ElementProperties!");
-
-	subobjects=(Object**)xmalloc(subnum*sizeof(Object*));
-	subids=(int*)xmalloc(subnum*sizeof(int));
-	suboffsets=(int*)xmalloc(subnum*sizeof(int));
-
-	for(i=0;i<subnum;i++){
-		subobjects[i]=this->objects[indices[i]];
-		subids[i]=this->ids[indices[i]];
-		suboffsets[i]=this->offsets[indices[i]];
-	}
-
-	return new Hook(subobjects,subids,suboffsets,subnum);
-}
-/*}}}*/
+	spawnedhook->num=numindices;
+	if(spawnedhook->num<1) ISSMERROR("Trying to spawn an empty ElementProperties!");
+
+	spawnedhook->objects=(Object**)xmalloc(spawnedhook->num*sizeof(Object*));
+	spawnedhook->ids=(int*)xmalloc(spawnedhook->num*sizeof(int));
+	spawnedhook->offsets=(int*)xmalloc(spawnedhook->num*sizeof(int));
+
+	for(i=0;i<spawnedhook->num;i++){
+		spawnedhook->objects[i]=this->objects[indices[i]];
+		spawnedhook->ids[i]=this->ids[indices[i]];
+		spawnedhook->offsets[i]=this->offsets[indices[i]];
+	}
+}
+/*}}}*/
Index: /issm/trunk/src/c/objects/Hook.h
===================================================================
--- /issm/trunk/src/c/objects/Hook.h	(revision 4368)
+++ /issm/trunk/src/c/objects/Hook.h	(revision 4369)
@@ -46,5 +46,5 @@
 		Object**   deliverp(void); //deliver all objects
 		void       configure(DataSet* dataset);
-		Hook*      Spawn(int* indices, int numindices);
+		void       Spawn(Hook* spawnedhook, int* indices, int numindices);
 		Object**   GetObjects(void);
 		int*       Ids(void);
