Index: /issm/trunk/src/c/objects/Elements/Penta.cpp
===================================================================
--- /issm/trunk/src/c/objects/Elements/Penta.cpp	(revision 3804)
+++ /issm/trunk/src/c/objects/Elements/Penta.cpp	(revision 3805)
@@ -3,4 +3,6 @@
  */
 
+/*Headers:*/
+/*{{{1*/
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -16,29 +18,21 @@
 #include "../../include/include.h"
 #include "../../DataSet/DataSet.h"
+/*}}}*/
 
 /*Object constructors and destructor*/
 /*FUNCTION Penta::Penta(){{{1*/
 Penta::Penta(){
+	this->nodes=NULL;
+	this->matice=NULL;
+	this->matpar=NULL;
+	
 	this->inputs=NULL;
 	this->parameters=NULL;
 }
 /*}}}*/
-/*FUNCTION Penta::Penta(int id, Hook* hnodes, Hook* hmatice, Hook* hmatpar, Parameters* parameters, Inputs* penta_inputs) {{{1*/
-Penta::Penta(int penta_id,Hook* penta_hnodes, Hook* penta_hmatice, Hook* penta_hmatpar, Parameters* penta_parameters, Inputs* penta_inputs):
-	hnodes(penta_hnodes),
-	hmatice(penta_hmatice),
-	hmatpar(penta_hmatpar)
-{
-
-	/*all the initialization has been done by the initializer, just fill in the id: */
-	this->id=penta_id;
-	if(penta_inputs){
-		this->inputs=(Inputs*)penta_inputs->Copy();
-	}
-	else{
-		this->inputs=new Inputs();
-	}
-	/*point parameters: */
-	this->parameters=penta_parameters;
+/*FUNCTION Penta::~Penta(){{{1*/
+Penta::~Penta(){
+	delete inputs;
+	this->parameters=NULL;
 }
 /*}}}*/
@@ -63,7 +57,7 @@
 	penta_matpar_id=iomodel->numberofelements+1; //refers to the constant material parameters object
 
-	this->hnodes.Init(&penta_node_ids[0],6);
-	this->hmatice.Init(&penta_matice_id,1);
-	this->hmatpar.Init(&penta_matpar_id,1);
+	this->InitHookNodes(penta_node_ids); this->nodes=NULL;
+	this->InitHookMatice(penta_matice_id);this->matice=NULL;
+	this->InitHookMatpar(penta_matpar_id);this->matpar=NULL;
 
 	//intialize inputs, and add as many inputs per element as requested: 
@@ -181,8 +175,33 @@
 }
 /*}}}*/
-/*FUNCTION Penta::~Penta(){{{1*/
-Penta::~Penta(){
-	delete inputs;
-	this->parameters=NULL;
+/*FUNCTION Penta::copy {{{1*/
+Object* Penta::copy() {
+
+	Penta* penta=NULL;
+
+	penta=new Penta();
+
+	/*copy fields: */
+	penta->id=this->id;
+	if(this->inputs){
+		penta->inputs=(Inputs*)this->inputs->Copy();
+	}
+	else{
+		penta->inputs=new Inputs();
+	}
+	/*point parameters: */
+	penta->parameters=this->parameters;
+
+	/*now deal with hooks and objects: */
+	penta->hnodes.copy(&this->hnodes);
+	penta->hmatice.copy(&this->hmatice);
+	penta->hmatpar.copy(&this->hmatpar);
+
+	/*recover objects: */
+	penta->nodes=(Node**)penta->hnodes.deliverp();
+	penta->matice=(Matice*)penta->hmatice.delivers();
+	penta->matpar=(Matpar*)penta->hmatpar.delivers();
+
+	return penta;
 }
 /*}}}*/
@@ -192,11 +211,14 @@
 void  Penta::Configure(DataSet* loadsin, DataSet* nodesin, DataSet* materialsin, Parameters* parametersin){
 
-	int i;
-
 	/*Take care of hooking up all objects for this element, ie links the objects in the hooks to their respective 
 	 * datasets, using internal ids and offsets hidden in hooks: */
-	hnodes.configure(nodesin);
-	hmatice.configure(materialsin);
-	hmatpar.configure(materialsin);
+	this->hnodes.configure(nodesin);
+	this->hmatice.configure(materialsin);
+	this->hmatpar.configure(materialsin);
+
+	/*Now, go pick up the objects inside the hooks: */
+	this->nodes=(Node**)this->hnodes.deliverp();
+	this->matice=(Matice*)this->hmatice.delivers();
+	this->matpar=(Matpar*)this->hmatpar.delivers();
 
 	/*point parameters to real dataset: */
@@ -205,10 +227,5 @@
 }
 /*}}}*/
-/*FUNCTION copy {{{1*/
-Object* Penta::copy() {
-	return new Penta(this->id,&this->hnodes,&this->hmatice,&this->hmatpar,this->parameters,this->inputs);
-}
-/*}}}*/
-/*FUNCTION Demarshall {{{1*/
+/*FUNCTION Penta::Demarshall {{{1*/
 void  Penta::Demarshall(char** pmarshalled_dataset){
 
@@ -229,4 +246,9 @@
 	hmatpar.Demarshall(&marshalled_dataset);
 
+	/*pointers are garbabe, until configuration is carried out: */
+	nodes=NULL;
+	matice=NULL;
+	matpar=NULL;
+	
 	/*demarshall inputs: */
 	inputs=(Inputs*)DataSetDemarshallRaw(&marshalled_dataset); 
@@ -240,35 +262,29 @@
 }
 /*}}}*/
-/*FUNCTION DeepEcho{{{1*/
-
+/*FUNCTION Penta::DeepEcho{{{1*/
 void Penta::DeepEcho(void){
 
 	printf("Penta:\n");
 	printf("   id: %i\n",id);
-	hnodes.DeepEcho();
-	hmatice.DeepEcho();
-	hmatpar.DeepEcho();
+	nodes[0]->DeepEcho();
+	nodes[1]->DeepEcho();
+	nodes[2]->DeepEcho();
+	nodes[3]->DeepEcho();
+	nodes[4]->DeepEcho();
+	nodes[5]->DeepEcho();
+	matice->DeepEcho();
+	matpar->DeepEcho();
 	printf("   parameters\n");
 	parameters->DeepEcho();
 	printf("   inputs\n");
 	inputs->DeepEcho();
-
+	
 	return;
 }
 /*}}}*/
-/*FUNCTION Echo{{{1*/
+/*FUNCTION Penta::Echo{{{1*/
 
 void Penta::Echo(void){
-
-	printf("Penta:\n");
-	printf("   id: %i\n",id);
-	hnodes.Echo();
-	hmatice.Echo();
-	hmatpar.Echo();
-	printf("   parameters\n");
-	parameters->Echo();
-	printf("   inputs\n");
-	inputs->Echo();
-
+	this->DeepEcho();
 }
 /*}}}*/
@@ -553,16 +569,6 @@
 	double stokesreconditioning;
 
-	/*dynamic objects pointed to by hooks: */
-	Node**  nodes=NULL;
-	Matpar* matpar=NULL;
-	Matice* matice=NULL;
-
 	/*Check analysis_types*/
 	if (analysis_type!=DiagnosticAnalysisEnum || sub_analysis_type!=StokesAnalysisEnum) ISSMERROR("Not supported yet!");
-
-	/*recover objects from hooks: */
-	nodes=(Node**)hnodes.deliverp();
-	matpar=(Matpar*)hmatpar.delivers();
-	matice=(Matice*)hmatice.delivers();
 
 	/*recover some inputs: */
@@ -652,12 +658,4 @@
 	/*inputs: */
 	bool onwater;
-
-	/*dynamic objects pointed to by hooks: */
-	Node**  nodes=NULL;
-	Matpar* matpar=NULL;
-
-	/*recover objects from hooks: */
-	nodes=(Node**)hnodes.deliverp();
-	matpar=(Matpar*)hmatpar.delivers();
 
 	/*retrieve inputs :*/
@@ -938,12 +936,4 @@
 	/*Collapsed formulation: */
 	Tria*  tria=NULL;
-
-	/*dynamic objects pointed to by hooks: */
-	Node**  nodes=NULL;
-	Matice* matice=NULL;
-
-	/*recover objects from hooks: */
-	nodes=(Node**)hnodes.deliverp();
-	matice=(Matice*)hmatice.delivers();
 
 	/*inputs: */
@@ -1174,9 +1164,4 @@
 	double stokesreconditioning;
 
-	/*dynamic objects pointed to by hooks: */
-	Node**  nodes=NULL;
-	Matpar* matpar=NULL;
-	Matice* matice=NULL;
-
 	/*inputs: */
 	bool onwater;
@@ -1191,10 +1176,4 @@
 	/*If on water, skip stiffness: */
 	if(onwater)return;
-
-	/*recover objects from hooks: */
-	nodes=(Node**)hnodes.deliverp();
-	matpar=(Matpar*)hmatpar.delivers();
-	matice=(Matice*)hmatice.delivers();
-
 
 	/*recovre material parameters: */
@@ -1438,10 +1417,4 @@
 	double  Bprime[NDOF1][numgrids];
 	double  DL_scalar;
-
-	/*dynamic objects pointed to by hooks: */
-	Node**  nodes=NULL;
-
-	/*recover objects from hooks: */
-	nodes=(Node**)hnodes.deliverp();
 
 	/*Collapsed formulation: */
@@ -1688,8 +1661,4 @@
 	double dt,artdiff,epsvel;
 
-	/*dynamic objects pointed to by hooks: */
-	Node**  nodes=NULL;
-	Matpar* matpar=NULL;
-
 	/*Collapsed formulation: */
 	Tria*  tria=NULL;
@@ -1708,8 +1677,4 @@
 	/*If on water, skip: */
 	if(onwater)return;
-
-	/*recover objects from hooks: */
-	nodes=(Node**)hnodes.deliverp();
-	matpar=(Matpar*)hmatpar.delivers();
 
 	/* Get node coordinates and dof list: */
@@ -2025,8 +1990,4 @@
 	double  pe_g_gaussian[numdof];
 
-	/*dynamic objects pointed to by hooks: */
-	Node**  nodes=NULL;
-	Matpar* matpar=NULL;
-
 	/*Spawning: */
 	Tria* tria=NULL;
@@ -2044,9 +2005,4 @@
 	/*If on water, skip load: */
 	if(onwater)return;
-
-	/*recover objects from hooks: */
-	nodes=(Node**)hnodes.deliverp();
-	matpar=(Matpar*)hmatpar.delivers();
-
 
 	/*Figure out if this pentaelem is collapsed. If so, then bailout, except if it is at the 
@@ -2205,9 +2161,4 @@
 	Tria*            tria=NULL;
 
-	/*dynamic objects pointed to by hooks: */
-	Node**  nodes=NULL;
-	Matpar* matpar=NULL;
-	Matice* matice=NULL;
-
 	/*parameters: */
 	double stokesreconditioning;
@@ -2228,10 +2179,4 @@
 	/*If on water, skip load: */
 	if(onwater)return;
-
-	/*recover objects from hooks: */
-	nodes=(Node**)hnodes.deliverp();
-	matpar=(Matpar*)hmatpar.delivers();
-	matice=(Matice*)hmatice.delivers();
-
 
 	/*recovre material parameters: */
@@ -2438,13 +2383,7 @@
 	int     dofs2[1]={1};
 
-	/*dynamic objects pointed to by hooks: */
-	Node**  nodes=NULL;
-
 	/*inputs: */
 	bool onwater;
 	bool onbed;
-
-	/*recover objects from hooks: */
-	nodes=(Node**)hnodes.deliverp();
 
 	/*retrieve inputs :*/
@@ -2657,9 +2596,4 @@
 	double dt;
 
-	/*dynamic objects pointed to by hooks: */
-	Node**  nodes=NULL;
-	Matpar* matpar=NULL;
-	Matice* matice=NULL;
-
 	/*inputs: */
 	bool onwater;
@@ -2677,9 +2611,4 @@
 	/*If on water, skip: */
 	if(onwater)return;
-
-	/*recover objects from hooks: */
-	nodes=(Node**)hnodes.deliverp();
-	matpar=(Matpar*)hmatpar.delivers();
-	matice=(Matice*)hmatice.delivers();
 
 	/* Get node coordinates and dof list: */
@@ -2833,10 +2762,4 @@
 	int   i;
 	int   extrude=0;
-
-	/*dynamic objects pointed to by hooks: */
-	Node**  nodes=NULL;
-
-	/*recover objects from hooks: */
-	nodes=(Node**)hnodes.deliverp();
 
 	/*inputs: */
@@ -3394,10 +3317,4 @@
 	int numberofdofspernode;
 
-	/*dynamic objects pointed to by hooks: */
-	Node**  nodes=NULL;
-
-	/*recover objects from hooks: */
-	nodes=(Node**)hnodes.deliverp();
-
 	for(i=0;i<6;i++){
 		nodes[i]->GetDofList(&doflist_per_node[0],&numberofdofspernode);
@@ -3416,9 +3333,4 @@
 	
 	int i;
-	/*dynamic objects pointed to by hooks: */
-	Node**  nodes=NULL;
-
-	/*recover objects from hooks: */
-	nodes=(Node**)hnodes.deliverp();
 
 	for(i=0;i<6;i++){
@@ -3727,10 +3639,4 @@
 void* Penta::GetMatPar(){
 
-	/*dynamic objects pointed to by hooks: */
-	Matpar* matpar=NULL;
-
-	/*recover objects from hooks: */
-	matpar=(Matpar*)hmatpar.delivers();
-
 	return matpar;
 }
@@ -3984,9 +3890,4 @@
 	int i;
 	Node** pnodes=NULL;
-	/*dynamic objects pointed to by hooks: */
-	Node**  nodes=NULL;
-	
-	/*recover objects from hooks: */
-	nodes=(Node**)hnodes.deliverp();
 	
 	/*virtual object: */
Index: /issm/trunk/src/c/objects/Elements/Penta.h
===================================================================
--- /issm/trunk/src/c/objects/Elements/Penta.h	(revision 3804)
+++ /issm/trunk/src/c/objects/Elements/Penta.h	(revision 3805)
@@ -8,12 +8,13 @@
 /*Headers:*/
 /*{{{1*/
-
-#include "../Elements/Element.h"
+#include "./Element.h"
+#include "./PentaHook.h"
 class  Object;
-class  Hook;
-class  Parameters;
-class  Inputs;
-
+class Parameters;
+class Inputs;
 class IoModel;
+class Node;
+class Matice;
+class Matpar;
 
 #include "../../shared/Exceptions/exceptions.h"
@@ -22,12 +23,13 @@
 /*}}}*/
 
-class Penta: public Element{
+class Penta: public Element,public PentaHook{
 
 	public:
 
 		int id;
-		Hook hnodes;  //hook to 6 nodes
-		Hook hmatice; //hook to 1 matice
-		Hook hmatpar; //hook to 1 matpar
+		
+		Node** nodes; // 6 nodes
+		Matice* matice;  // 1 material ice
+		Matpar* matpar;  // 1 material parameter
 
 		Parameters* parameters; //pointer to solution parameters
@@ -36,5 +38,4 @@
 		/*FUNCTION constructors, destructors {{{1*/
 		Penta();
-		Penta(int penta_id,Hook* penta_hnodes, Hook* penta_hmatice, Hook* penta_hmatpar, Parameters* penta_parameters, Inputs* inputs);
 		Penta(int penta_id,int i, IoModel* iomodel);
 		~Penta();
Index: /issm/trunk/src/c/objects/Elements/PentaHook.cpp
===================================================================
--- /issm/trunk/src/c/objects/Elements/PentaHook.cpp	(revision 3805)
+++ /issm/trunk/src/c/objects/Elements/PentaHook.cpp	(revision 3805)
@@ -0,0 +1,46 @@
+/*!\file PentaHook.c
+ * \brief: implementation of the PentaHook object
+ */
+
+/*Headers:*/
+/*{{{1*/
+#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 "../../shared/shared.h"
+#include "../../DataSet/DataSet.h"
+#include "../../include/include.h"
+/*}}}*/
+
+/*Object constructors and destructor*/
+/*FUNCTION PentaHook::PentaHook(){{{1*/
+PentaHook::PentaHook(){
+}
+/*}}}*/
+/*FUNCTION PentaHook::~PentaHook(){{{1*/
+PentaHook::~PentaHook(){
+}
+/*}}}*/
+/*FUNCTION PentaHook::InitHookNodes(int* node_ids){{{1*/
+void PentaHook::InitHookNodes(int* node_ids){
+	this->hnodes.Init(node_ids,6);
+
+}
+/*}}}*/
+/*FUNCTION PentaHook::InitHookMatice(int matice_id){{{1*/
+void PentaHook::InitHookMatice(int matice_id){
+	this->hmatice.Init(&matice_id,1);
+}
+
+/*FUNCTION PentaHook::InitHookMatpar(int matpar_id){{{1*/
+void PentaHook::InitHookMatpar(int matpar_id){
+	this->hmatpar.Init(&matpar_id,1);
+}
+
Index: /issm/trunk/src/c/objects/Elements/PentaHook.h
===================================================================
--- /issm/trunk/src/c/objects/Elements/PentaHook.h	(revision 3805)
+++ /issm/trunk/src/c/objects/Elements/PentaHook.h	(revision 3805)
@@ -0,0 +1,30 @@
+/*!\file: PentaHook.h
+ * \brief prototypes for PentaHook.h
+ */ 
+
+#ifndef _PENTAHOOK_H_
+#define  _PENTAHOOK_H_
+
+class Hook;
+
+class PentaHook{
+
+	public: 
+		Hook hnodes; // 6 nodes
+		Hook hmatice; // 1 ice material
+		Hook hmatpar; // 1 material parameter
+
+
+		/*FUNCTION constructors, destructors {{{1*/
+		PentaHook();
+		~PentaHook();
+		void InitHookNodes(int* node_ids);
+		void InitHookMatice(int matice_id);
+		void InitHookMatpar(int matpar_id);
+		/*}}}*/
+
+};
+
+
+#endif //ifndef _PENTAHOOK_H_
+
Index: /issm/trunk/src/c/objects/Elements/Tria.cpp
===================================================================
--- /issm/trunk/src/c/objects/Elements/Tria.cpp	(revision 3804)
+++ /issm/trunk/src/c/objects/Elements/Tria.cpp	(revision 3805)
@@ -66,7 +66,7 @@
 	tria_matpar_id=iomodel->numberofelements+1; //refers to the constant material parameters object
 
-	this->InitHookNodes(tria_node_ids);
-	this->InitHookMatice(tria_matice_id);
-	this->InitHookMatpar(tria_matpar_id);
+	this->InitHookNodes(tria_node_ids); this->nodes=NULL;
+	this->InitHookMatice(tria_matice_id);this->matice=NULL;
+	this->InitHookMatpar(tria_matpar_id);this->matpar=NULL;
 
 	//intialize inputs, and add as many inputs per element as requested: 
Index: /issm/trunk/src/c/objects/Elements/Tria.h
===================================================================
--- /issm/trunk/src/c/objects/Elements/Tria.h	(revision 3804)
+++ /issm/trunk/src/c/objects/Elements/Tria.h	(revision 3805)
@@ -27,8 +27,8 @@
 		int  id;
 
-		Node** nodes;
-		Matice* matice; 
-		Matpar* matpar; 
-
+		Node** nodes; // 3 nodes
+		Matice* matice;  // 1 material ice
+		Matpar* matpar;  // 1 material parameter
+ 
 		Parameters* parameters; //pointer to solution parameters
 		Inputs*  inputs;
@@ -36,5 +36,4 @@
 		/*FUNCTION constructors, destructors {{{1*/
 		Tria();
-		Tria(int tria_id,Node* tria_nodes, Matice* tria_matice, Matpar* tria_matpar, Parameters* parameters, Inputs* tria_inputs);
 		Tria(int tria_id,int i, IoModel* iomodel);
 		~Tria();
Index: /issm/trunk/src/c/objects/Elements/TriaHook.h
===================================================================
--- /issm/trunk/src/c/objects/Elements/TriaHook.h	(revision 3804)
+++ /issm/trunk/src/c/objects/Elements/TriaHook.h	(revision 3805)
@@ -11,7 +11,7 @@
 
 	public: 
-		Hook hnodes;
-		Hook hmatice;
-		Hook hmatpar;
+		Hook hnodes; // 3 nodes
+		Hook hmatice; // 1 ice material
+		Hook hmatpar; // 1 material parameter
 
 
