Index: /issm/trunk/src/c/Makefile.am
===================================================================
--- /issm/trunk/src/c/Makefile.am	(revision 5907)
+++ /issm/trunk/src/c/Makefile.am	(revision 5908)
@@ -269,4 +269,9 @@
 					./shared/Elements/Paterson.cpp\
 					./shared/Elements/GetVerticesCoordinates.cpp\
+					./shared/Elements/GetLocalDofList.cpp\
+					./shared/Elements/GetGlobalDofList.cpp\
+					./shared/Elements/GetNumberOfDofs.cpp\
+					./shared/Elements/NewElementMatrix.cpp\
+					./shared/Elements/NewElementVector.cpp\
 					./shared/String/DescriptorIndex.cpp\
 					./shared/String/sharedstring.h\
@@ -824,4 +829,9 @@
 					./shared/Elements/Paterson.cpp\
 					./shared/Elements/GetVerticesCoordinates.cpp\
+					./shared/Elements/GetLocalDofList.cpp\
+					./shared/Elements/GetGlobalDofList.cpp\
+					./shared/Elements/GetNumberOfDofs.cpp\
+					./shared/Elements/NewElementMatrix.cpp\
+					./shared/Elements/NewElementVector.cpp\
 					./shared/String/DescriptorIndex.cpp\
 					./shared/String/sharedstring.h\
Index: /issm/trunk/src/c/objects/Elements/Penta.cpp
===================================================================
--- /issm/trunk/src/c/objects/Elements/Penta.cpp	(revision 5907)
+++ /issm/trunk/src/c/objects/Elements/Penta.cpp	(revision 5908)
@@ -2048,6 +2048,6 @@
 	/*Initialize Element matrix and return if necessary*/
 	if(IsOnWater()) return NULL;
-	ElementMatrix* Ke1=pentabase->NewElementMatrix(MacAyealApproximationEnum);
-	ElementMatrix* Ke2=this->NewElementMatrix(PattynApproximationEnum);
+	ElementMatrix* Ke1=NewElementMatrix(pentabase->nodes,NUMVERTICES,this->parameters,MacAyealApproximationEnum);
+	ElementMatrix* Ke2=NewElementMatrix(this->nodes     ,NUMVERTICES,this->parameters,PattynApproximationEnum);
 	ElementMatrix* Ke=new ElementMatrix(Ke1,Ke2);
 	delete Ke1; delete Ke2;
@@ -2196,5 +2196,5 @@
 	/*Initialize Element matrix and return if necessary*/
 	if(IsOnWater()) return NULL;
-	ElementMatrix* Ke=this->NewElementMatrix(NoneApproximationEnum);
+	ElementMatrix* Ke=NewElementMatrix(nodes,NUMVERTICES,this->parameters,NoneApproximationEnum);
 
 	/*Spawn 3 beam elements: */
@@ -2319,5 +2319,5 @@
 	/*Initialize Element matrix and return if necessary*/
 	if(IsOnWater()) return NULL;
-	ElementMatrix* Ke=tria->NewElementMatrix(MacAyealApproximationEnum);
+	ElementMatrix* Ke=NewElementMatrix(tria->nodes,NUMVERTICES2D,this->parameters,MacAyealApproximationEnum);
 
 	/*Retrieve all inputs and parameters*/
@@ -2447,5 +2447,5 @@
 	/*Initialize Element matrix and return if necessary*/
 	if(IsOnWater()) return NULL;
-	ElementMatrix* Ke=this->NewElementMatrix(PattynApproximationEnum);
+	ElementMatrix* Ke=NewElementMatrix(nodes,NUMVERTICES,this->parameters,PattynApproximationEnum);
 
 	/*Retrieve all inputs and parameters*/
@@ -2567,5 +2567,5 @@
 	inputs->GetParameterValue(&approximation,ApproximationEnum);
 	if(IsOnWater() || approximation!=StokesApproximationEnum) return NULL;
-	ElementMatrix* Ke=this->NewElementMatrix(StokesApproximationEnum);
+	ElementMatrix* Ke=NewElementMatrix(nodes,NUMVERTICES,this->parameters,StokesApproximationEnum);
 
 	/*Retrieve all inputs and parameters*/
@@ -2648,5 +2648,5 @@
 	inputs->GetParameterValue(&approximation,ApproximationEnum);
 	if(IsOnWater() || IsOnShelf() || !IsOnBed() || approximation!=StokesApproximationEnum) return NULL;
-	ElementMatrix* Ke=this->NewElementMatrix(StokesApproximationEnum);
+	ElementMatrix* Ke=NewElementMatrix(nodes,NUMVERTICES,this->parameters,StokesApproximationEnum);
 
 	/*Retrieve all inputs and parameters*/
@@ -2739,5 +2739,5 @@
 	/*Initialize Element matrix and return if necessary*/
 	if(IsOnWater()) return NULL;
-	ElementMatrix* Ke=this->NewElementMatrix(NoneApproximationEnum);
+	ElementMatrix* Ke=NewElementMatrix(nodes,NUMVERTICES,this->parameters,NoneApproximationEnum);
 
 	/*Retrieve all inputs and parameters*/
@@ -2885,5 +2885,5 @@
 	/*Initialize Element matrix and return if necessary*/
 	if(IsOnWater()) return NULL;
-	ElementMatrix* Ke=this->NewElementMatrix(NoneApproximationEnum);
+	ElementMatrix* Ke=NewElementMatrix(nodes,NUMVERTICES,this->parameters,NoneApproximationEnum);
 
 	/*Retrieve all inputs and parameters*/
@@ -5515,97 +5515,4 @@
 }
 /*}}}*/
-/*FUNCTION Penta::NewElementMatrix{{{1*/
-ElementMatrix* Penta::NewElementMatrix(int approximation){
-
-	/*parameters: */
-	bool kff=false;
-
-	/*output: */
-	ElementMatrix* Ke=NULL;
-	int gsize;
-	int fsize;
-	int ssize;
-	int* gglobaldoflist=NULL;
-	int* flocaldoflist=NULL;
-	int* fglobaldoflist=NULL;
-	int* slocaldoflist=NULL;
-	int* sglobaldoflist=NULL;
-	bool square=true;
-
-	/*retrieve some parameters: */
-	this->parameters->FindParam(&kff,KffEnum);
-
-	/*get number of dofs in sets g,f and s: */
-	gsize=this->GetNumberOfDofs(approximation,GsetEnum);
-	if(kff){
-		fsize=this->GetNumberOfDofs(approximation,FsetEnum);
-		ssize=this->GetNumberOfDofs(approximation,SsetEnum);
-	}
-
-	/*get dof lists for f and s set: */
-	gglobaldoflist=this->GetGlobalDofList(approximation,GsetEnum);
-	if(kff){
-		flocaldoflist=this->GetLocalDofList(approximation,FsetEnum);
-		fglobaldoflist=this->GetGlobalDofList(approximation,FsetEnum);
-		slocaldoflist=this->GetLocalDofList(approximation,SsetEnum);
-		sglobaldoflist=this->GetGlobalDofList(approximation,SsetEnum);
-	}
-
-	/*Use square constructor for ElementMatrix: */
-	if(!kff) Ke=new ElementMatrix(square,gglobaldoflist,gsize);
-	else     Ke=new ElementMatrix(square,gglobaldoflist,gsize,flocaldoflist,fglobaldoflist,fsize,slocaldoflist,sglobaldoflist,ssize);
-
-	/*Free ressources and return:*/
-	xfree((void**)&gglobaldoflist);
-	xfree((void**)&flocaldoflist);
-	xfree((void**)&fglobaldoflist);
-	xfree((void**)&slocaldoflist);
-	xfree((void**)&sglobaldoflist);
-
-	return Ke;
-}
-/*}}}*/
-/*FUNCTION Penta::NewElementVector{{{1*/
-ElementVector* Penta::NewElementVector(int approximation){
-
-	/*parameters: */
-	bool kff=false;
-
-	/*output: */
-	ElementVector* pe=NULL;
-	int gsize;
-	int fsize;
-	int* gglobaldoflist=NULL;
-	int* flocaldoflist=NULL;
-	int* fglobaldoflist=NULL;
-
-	/*retrieve some parameters: */
-	this->parameters->FindParam(&kff,KffEnum);
-
-	/*get number of dofs in sets g,f and s: */
-	gsize=this->GetNumberOfDofs(approximation,GsetEnum);
-	if(kff)fsize=this->GetNumberOfDofs(approximation,FsetEnum);
-
-	/*get dof lists for f and s set: */
-	if(!kff){
-		gglobaldoflist=this->GetGlobalDofList(approximation,GsetEnum);
-	}
-	else{
-		flocaldoflist=this->GetLocalDofList(approximation,FsetEnum);
-		fglobaldoflist=this->GetGlobalDofList(approximation,FsetEnum);
-	}
-
-	/*constructor for ElementVector: */
-	if(!kff)pe=new ElementVector(gsize,gglobaldoflist);
-	else    pe=new ElementVector(gsize,flocaldoflist,fglobaldoflist,fsize);
-
-	/*Free ressources and return:*/
-	xfree((void**)&gglobaldoflist);
-	xfree((void**)&flocaldoflist);
-	xfree((void**)&fglobaldoflist);
-
-	return pe;
-}
-/*}}}*/
 /*FUNCTION Penta::ReduceMatrixStokes {{{1*/
 void Penta::ReduceMatrixStokes(double* Ke_reduced, double* Ke_temp){
Index: /issm/trunk/src/c/objects/Elements/Penta.h
===================================================================
--- /issm/trunk/src/c/objects/Elements/Penta.h	(revision 5907)
+++ /issm/trunk/src/c/objects/Elements/Penta.h	(revision 5908)
@@ -204,6 +204,4 @@
 		bool    IsOnShelf(void); 
 		bool    IsOnWater(void); 
-		ElementMatrix* NewElementMatrix(int approximation);
-		ElementVector* NewElementVector(int approximation);
 		void	  ReduceMatrixStokes(double* Ke_reduced, double* Ke_temp);
 		void	  ReduceVectorStokes(double* Pe_reduced, double* Ke_temp, double* Pe_temp);
Index: /issm/trunk/src/c/objects/Elements/Tria.cpp
===================================================================
--- /issm/trunk/src/c/objects/Elements/Tria.cpp	(revision 5907)
+++ /issm/trunk/src/c/objects/Elements/Tria.cpp	(revision 5908)
@@ -2429,5 +2429,5 @@
 	/*Initialize Element matrix and return if necessary*/
 	if(IsOnWater()) return NULL;
-	ElementMatrix* Ke=this->NewElementMatrix(NoneApproximationEnum);
+	ElementMatrix* Ke=NewElementMatrix(nodes,NUMVERTICES,this->parameters,NoneApproximationEnum);
 
 	/*Retrieve all Inputs and parameters: */
@@ -2534,5 +2534,5 @@
 	/*Initialize Element matrix and return if necessary*/
 	if(IsOnWater()) return NULL;
-	ElementMatrix* Ke=this->NewElementMatrix(NoneApproximationEnum);
+	ElementMatrix* Ke=NewElementMatrix(nodes,NUMVERTICES,this->parameters,NoneApproximationEnum);
 
 	/*Retrieve all inputs and parameters*/
@@ -2601,5 +2601,5 @@
 	/*Initialize Element matrix and return if necessary*/
 	if(IsOnWater()) return NULL;
-	ElementMatrix* Ke=this->NewElementMatrix(NoneApproximationEnum);
+	ElementMatrix* Ke=NewElementMatrix(nodes,NUMVERTICES,this->parameters,NoneApproximationEnum);
 
 	/*Retrieve all inputs and parameters*/
@@ -2733,5 +2733,5 @@
 	/*Initialize Element matrix and return if necessary*/
 	if(IsOnWater()) return NULL;
-	ElementMatrix* Ke=this->NewElementMatrix(MacAyealApproximationEnum);
+	ElementMatrix* Ke=NewElementMatrix(nodes,NUMVERTICES,this->parameters,MacAyealApproximationEnum);
 
 	/*Retrieve all inputs and parameters*/
@@ -2801,5 +2801,5 @@
 	/*Initialize Element matrix and return if necessary*/
 	if(IsOnWater() || IsOnShelf()) return NULL;
-	ElementMatrix* Ke=this->NewElementMatrix(MacAyealApproximationEnum);
+	ElementMatrix* Ke=NewElementMatrix(nodes,NUMVERTICES,this->parameters,MacAyealApproximationEnum);
 
 	/*Retrieve all inputs and parameters*/
@@ -2872,6 +2872,6 @@
 	/*Initialize Element matrix and return if necessary*/
 	if(IsOnWater() || IsOnShelf()) return NULL;
-	ElementMatrix* Ke1=this->NewElementMatrix(MacAyealApproximationEnum);
-	ElementMatrix* Ke2=this->NewElementMatrix(PattynApproximationEnum);
+	ElementMatrix* Ke1=NewElementMatrix(nodes,NUMVERTICES,this->parameters,MacAyealApproximationEnum);
+	ElementMatrix* Ke2=NewElementMatrix(nodes,NUMVERTICES,this->parameters,PattynApproximationEnum);
 	ElementMatrix* Ke=new ElementMatrix(Ke1,Ke2);
 	delete Ke1; delete Ke2;
@@ -2961,5 +2961,5 @@
 	/*Initialize Element matrix and return if necessary*/
 	if(IsOnWater() || IsOnShelf()) return NULL;
-	ElementMatrix* Ke=this->NewElementMatrix(PattynApproximationEnum);
+	ElementMatrix* Ke=NewElementMatrix(nodes,NUMVERTICES,this->parameters,PattynApproximationEnum);
 
 	/*Retrieve all inputs and parameters*/
@@ -3021,5 +3021,5 @@
 	/*Initialize Element matrix and return if necessary*/
 	if(IsOnWater()) return NULL;
-	ElementMatrix* Ke=this->NewElementMatrix(NoneApproximationEnum);
+	ElementMatrix* Ke=NewElementMatrix(nodes,NUMVERTICES,this->parameters,NoneApproximationEnum);
 
 	/*Create Element matrix*/
@@ -3052,5 +3052,5 @@
 	/*Initialize Element matrix and return if necessary*/
 	if(IsOnWater()) return NULL;
-	ElementMatrix* Ke=this->NewElementMatrix(NoneApproximationEnum);
+	ElementMatrix* Ke=NewElementMatrix(nodes,NUMVERTICES,this->parameters,NoneApproximationEnum);
 
 	/*Retrieve all inputs and parameters*/
@@ -3102,5 +3102,5 @@
 	/*Initialize Element matrix and return if necessary*/
 	if(IsOnWater()) return NULL;
-	ElementMatrix* Ke=this->NewElementMatrix(NoneApproximationEnum);
+	ElementMatrix* Ke=NewElementMatrix(nodes,NUMVERTICES,this->parameters,NoneApproximationEnum);
 
 	/*Retrieve all inputs and parameters*/
@@ -3173,5 +3173,5 @@
 	/*Initialize Element matrix and return if necessary*/
 	if(IsOnWater()) return NULL;
-	ElementMatrix* Ke=this->NewElementMatrix(NoneApproximationEnum);
+	ElementMatrix* Ke=NewElementMatrix(nodes,NUMVERTICES,this->parameters,NoneApproximationEnum);
 
 	/*Retrieve all inputs and parameters*/
@@ -3293,5 +3293,5 @@
 	/*Initialize Element matrix and return if necessary*/
 	if(IsOnWater()) return NULL;
-	ElementMatrix* Ke=this->NewElementMatrix(NoneApproximationEnum);
+	ElementMatrix* Ke=NewElementMatrix(nodes,NUMVERTICES,this->parameters,NoneApproximationEnum);
 
 	/*Retrieve all inputs and parameters*/
@@ -3368,5 +3368,5 @@
 	/*Initialize Element matrix and return if necessary*/
 	if(IsOnWater()) return NULL;
-	ElementMatrix* Ke=this->NewElementMatrix(NoneApproximationEnum);
+	ElementMatrix* Ke=NewElementMatrix(nodes,NUMVERTICES,this->parameters,NoneApproximationEnum);
 
 	GetVerticesCoordinates(&xyz_list[0][0],nodes,NUMVERTICES);
@@ -3419,5 +3419,5 @@
 	/*Initialize Element matrix and return if necessary*/
 	if(IsOnWater() || !IsOnShelf()) return NULL;
-	ElementMatrix* Ke=this->NewElementMatrix(NoneApproximationEnum);
+	ElementMatrix* Ke=NewElementMatrix(nodes,NUMVERTICES,this->parameters,NoneApproximationEnum);
 
 	/*Retrieve all inputs and parameters*/
@@ -3744,5 +3744,5 @@
 
 	/*Initialize element vector: */
-	pe=this->NewElementVector(MacAyealApproximationEnum);
+	pe=NewElementVector(nodes,NUMVERTICES,this->parameters,MacAyealApproximationEnum);
 
 	/*Add pe_g values to pe element stifness load: */
@@ -5453,97 +5453,4 @@
 }
 /*}}}*/
-/*FUNCTION Tria::NewElementMatrix{{{1*/
-ElementMatrix* Tria::NewElementMatrix(int approximation){
-
-	/*parameters: */
-	bool kff=false;
-
-	/*output: */
-	ElementMatrix* Ke=NULL;
-	int gsize;
-	int fsize;
-	int ssize;
-	int* gglobaldoflist=NULL;
-	int* flocaldoflist=NULL;
-	int* fglobaldoflist=NULL;
-	int* slocaldoflist=NULL;
-	int* sglobaldoflist=NULL;
-	bool square=true;
-
-	/*retrieve some parameters: */
-	this->parameters->FindParam(&kff,KffEnum);
-
-	/*get number of dofs in sets g,f and s: */
-	gsize=this->GetNumberOfDofs(approximation,GsetEnum);
-	if(kff){
-		fsize=this->GetNumberOfDofs(approximation,FsetEnum);
-		ssize=this->GetNumberOfDofs(approximation,SsetEnum);
-	}
-
-	/*get dof lists for f and s set: */
-	gglobaldoflist=this->GetGlobalDofList(approximation,GsetEnum);
-	if(kff){
-		flocaldoflist=this->GetLocalDofList(approximation,FsetEnum);
-		fglobaldoflist=this->GetGlobalDofList(approximation,FsetEnum);
-		slocaldoflist=this->GetLocalDofList(approximation,SsetEnum);
-		sglobaldoflist=this->GetGlobalDofList(approximation,SsetEnum);
-	}
-
-	/*Use square constructor for ElementMatrix: */
-	if(!kff) Ke=new ElementMatrix(square,gglobaldoflist,gsize);
-	else     Ke=new ElementMatrix(square,gglobaldoflist,gsize,flocaldoflist,fglobaldoflist,fsize,slocaldoflist,sglobaldoflist,ssize);
-
-	/*Free ressources and return:*/
-	xfree((void**)&gglobaldoflist);
-	xfree((void**)&flocaldoflist);
-	xfree((void**)&fglobaldoflist);
-	xfree((void**)&slocaldoflist);
-	xfree((void**)&sglobaldoflist);
-
-	return Ke;
-}
-/*}}}*/
-/*FUNCTION Tria::NewElementVector{{{1*/
-ElementVector* Tria::NewElementVector(int approximation){
-
-	/*parameters: */
-	bool kff=false;
-
-	/*output: */
-	ElementVector* pe=NULL;
-	int gsize;
-	int fsize;
-	int* gglobaldoflist=NULL;
-	int* flocaldoflist=NULL;
-	int* fglobaldoflist=NULL;
-
-	/*retrieve some parameters: */
-	this->parameters->FindParam(&kff,KffEnum);
-
-	/*get number of dofs in sets g,f and s: */
-	gsize=this->GetNumberOfDofs(approximation,GsetEnum);
-	if(kff)fsize=this->GetNumberOfDofs(approximation,FsetEnum);
-
-	/*get dof lists for f and s set: */
-	if(!kff){
-		gglobaldoflist=this->GetGlobalDofList(approximation,GsetEnum);
-	}
-	else{
-		flocaldoflist=this->GetLocalDofList(approximation,FsetEnum);
-		fglobaldoflist=this->GetGlobalDofList(approximation,FsetEnum);
-	}
-
-	/*constructor for ElementVector: */
-	if(!kff)pe=new ElementVector(gsize,gglobaldoflist);
-	else    pe=new ElementVector(gsize,flocaldoflist,fglobaldoflist,fsize);
-
-	/*Free ressources and return:*/
-	xfree((void**)&gglobaldoflist);
-	xfree((void**)&flocaldoflist);
-	xfree((void**)&fglobaldoflist);
-	
-	return pe;
-}
-/*}}}*/
 /*FUNCTION Tria::SetClone {{{1*/
 void  Tria::SetClone(int* minranks){
Index: /issm/trunk/src/c/objects/Elements/Tria.h
===================================================================
--- /issm/trunk/src/c/objects/Elements/Tria.h	(revision 5907)
+++ /issm/trunk/src/c/objects/Elements/Tria.h	(revision 5908)
@@ -172,6 +172,4 @@
 		void	  InputUpdateFromSolutionOneDof(double* solution,int enum_type);
 		bool	  IsInput(int name);
-		ElementMatrix* NewElementMatrix(int approximation);
-		ElementVector* NewElementVector(int approximation);
 		void	  SetClone(int* minranks);
 		void	  SurfaceNormal(double* surface_normal, double xyz_list[3][3]);
Index: /issm/trunk/src/c/objects/Loads/Icefront.cpp
===================================================================
--- /issm/trunk/src/c/objects/Loads/Icefront.cpp	(revision 5907)
+++ /issm/trunk/src/c/objects/Loads/Icefront.cpp	(revision 5908)
@@ -496,5 +496,5 @@
 
 	/*Initialize element matrix: */
-	pe=this->NewElementVector(MacAyealApproximationEnum);
+	pe=NewElementVector(nodes,NUMVERTICESSEG,this->parameters,MacAyealApproximationEnum);
 
 	/*Add pe_g values to pe element stifness load: */
@@ -910,44 +910,2 @@
 }
 /*}}}*/
-/*FUNCTION Icefront::NewElementVector{{{1*/
-ElementVector* Icefront::NewElementVector(int approximation){
-
-	/*parameters: */
-	bool kff=false;
-
-	/*output: */
-	ElementVector* pe=NULL;
-	int gsize;
-	int fsize;
-	int* gexternaldoflist=NULL;
-	int* finternaldoflist=NULL;
-	int* fexternaldoflist=NULL;
-
-	/*retrieve some parameters: */
-	this->parameters->FindParam(&kff,KffEnum);
-
-	/*get number of dofs in sets g and f: */
-	gsize=this->GetNumberOfDofs(approximation,GsetEnum);
-	if(kff)fsize=this->GetNumberOfDofs(approximation,FsetEnum);
-
-	/*get dof lists for f and s set: */
-	if(!kff){
-		gexternaldoflist=this->GetExternalDofList(approximation,GsetEnum);
-	}
-	else{
-		finternaldoflist=this->GetInternalDofList(approximation,FsetEnum);
-		fexternaldoflist=this->GetExternalDofList(approximation,FsetEnum);
-	}
-
-	/*Use symmetric constructor for ElementVector: */
-	if(!kff)pe=new ElementVector(gsize,gexternaldoflist);
-	else    pe=new ElementVector(gsize,finternaldoflist,fexternaldoflist,fsize);
-
-	/*Free ressources and return:*/
-	xfree((void**)&gexternaldoflist);
-	xfree((void**)&finternaldoflist);
-	xfree((void**)&fexternaldoflist);
-	
-	return pe;
-}
-/*}}}*/
Index: /issm/trunk/src/c/objects/Loads/Icefront.h
===================================================================
--- /issm/trunk/src/c/objects/Loads/Icefront.h	(revision 5907)
+++ /issm/trunk/src/c/objects/Loads/Icefront.h	(revision 5908)
@@ -87,5 +87,4 @@
 		void GetSegmentNormal(double* normal,double xyz_list[2][3]);
 		void GetQuadNormal(double* normal,double xyz_list[4][3]);
-		ElementVector* NewElementVector(int approximation);
 		/*}}}*/
 };
Index: /issm/trunk/src/c/objects/objects.h
===================================================================
--- /issm/trunk/src/c/objects/objects.h	(revision 5907)
+++ /issm/trunk/src/c/objects/objects.h	(revision 5908)
@@ -77,5 +77,4 @@
 #include "./Numerics/ElementVector.h"
 
-
 /*Params: */
 #include "./Params/BoolParam.h"
Index: /issm/trunk/src/c/shared/Elements/GetGlobalDofList.cpp
===================================================================
--- /issm/trunk/src/c/shared/Elements/GetGlobalDofList.cpp	(revision 5908)
+++ /issm/trunk/src/c/shared/Elements/GetGlobalDofList.cpp	(revision 5908)
@@ -0,0 +1,33 @@
+/*!\file:  GetGlobalDofList.cpp
+ * \brief create new element matrix
+ */ 
+#include "./elements.h"
+
+int* GetGlobalDofList(Node** nodes,int numnodes,int setenum,int approximation){
+
+	int  i,numdof,count;
+	int  ndof_list[numnodes];
+	int *doflist = NULL;
+
+	/*First, figure out size of doflist: */
+	numdof=0;
+	for(i=0;i<numnodes;i++){
+		ndof_list[i]=nodes[i]->GetNumberOfDofs(approximation,setenum);
+		numdof+=ndof_list[i];
+	}
+
+	if(numdof){
+		/*Allocate: */
+		doflist=(int*)xmalloc(numdof*sizeof(int));
+
+		/*Populate: */
+		count=0;
+		for(i=0;i<numnodes;i++){
+			nodes[i]->GetDofList(&doflist[count],approximation,setenum);
+			count+=ndof_list[i];
+		}
+	}
+	else doflist=NULL;
+
+	return doflist;
+}
Index: /issm/trunk/src/c/shared/Elements/GetLocalDofList.cpp
===================================================================
--- /issm/trunk/src/c/shared/Elements/GetLocalDofList.cpp	(revision 5908)
+++ /issm/trunk/src/c/shared/Elements/GetLocalDofList.cpp	(revision 5908)
@@ -0,0 +1,51 @@
+/*!\file:  GetLocalDofList.cpp
+ * \brief create new element matrix
+ */ 
+#include "./elements.h"
+
+int* GetLocalDofList(Node** nodes,int numnodes,int setenum,int approximation){
+
+	int  i,j,count,numdof,numgdof;
+	int  ndof_list[numnodes];
+	int  ngdof_list_cumulative[numnodes];
+	int *doflist = NULL;
+
+	/*Get number of dofs per node, and total for this given set*/
+	numdof=0;
+	numgdof=0;
+	for(i=0;i<numnodes;i++){
+
+		/*Cumulative list= number of dofs before node i*/
+		ngdof_list_cumulative[i]=numgdof;
+
+		/*Number of dofs for node i for given set and for the g set*/
+		ndof_list[i]=nodes[i]->GetNumberOfDofs(approximation,setenum);
+		numgdof    +=nodes[i]->GetNumberOfDofs(approximation,GsetEnum);
+		numdof     +=ndof_list[i];
+	}
+
+	if(numdof){
+		/*Allocate: */
+		doflist=(int*)xmalloc(numdof*sizeof(int));
+
+		/*Populate: */
+		count=0;
+		for(i=0;i<numnodes;i++){
+			nodes[i]->GetLocalDofList(&doflist[count],approximation,setenum);
+			count+=ndof_list[i];
+		}
+
+		/*We now have something like: [0 1 0 2 1 2]. Offset by gsize, to get something like: [0 1 2 4 6 7]:*/
+		count=0;
+		for(i=0;i<numnodes;i++){
+			for(j=0;j<ndof_list[i];j++){
+				doflist[count+j]+=ngdof_list_cumulative[i];
+			}
+			count+=ndof_list[i];
+		}
+	}
+	else doflist=NULL;
+
+	/*CLean-up and return*/
+	return doflist;
+}
Index: /issm/trunk/src/c/shared/Elements/GetNumberOfDofs.cpp
===================================================================
--- /issm/trunk/src/c/shared/Elements/GetNumberOfDofs.cpp	(revision 5908)
+++ /issm/trunk/src/c/shared/Elements/GetNumberOfDofs.cpp	(revision 5908)
@@ -0,0 +1,16 @@
+/*!\file:  GetNumberOfDofs.cpp
+ * \brief create new element matrix
+ */ 
+#include "./elements.h"
+
+int GetNumberOfDofs(Node** nodes,int numnodes,int setenum,int approximation){
+
+	/*output: */
+	int numberofdofs=0;
+
+	for(int i=0;i<numnodes;i++){
+		numberofdofs+=nodes[i]->GetNumberOfDofs(approximation,setenum);
+	}
+
+	return numberofdofs;
+}
Index: /issm/trunk/src/c/shared/Elements/GetVerticesCoordinates.cpp
===================================================================
--- /issm/trunk/src/c/shared/Elements/GetVerticesCoordinates.cpp	(revision 5907)
+++ /issm/trunk/src/c/shared/Elements/GetVerticesCoordinates.cpp	(revision 5908)
@@ -3,7 +3,7 @@
  */ 
 
-#include "../../objects/objects.h"
+#include "./elements.h"
 
-int GetVerticesCoordinates( double* xyz,  Node** nodes, int numvertices){
+int GetVerticesCoordinates(double* xyz,  Node** nodes, int numvertices){
 
 	/*In debugging mode, check that nodes is not a NULL pointer*/
Index: /issm/trunk/src/c/shared/Elements/NewElementMatrix.cpp
===================================================================
--- /issm/trunk/src/c/shared/Elements/NewElementMatrix.cpp	(revision 5908)
+++ /issm/trunk/src/c/shared/Elements/NewElementMatrix.cpp	(revision 5908)
@@ -0,0 +1,53 @@
+/*!\file:  NewElementMatrix.cpp
+ * \brief create new element matrix
+ */ 
+#include "./elements.h"
+
+ElementMatrix* NewElementMatrix(Node** nodes,int numnodes,Parameters* parameters,int approximation){
+
+	/*parameters: */
+	bool kff=false;
+
+	/*output: */
+	ElementMatrix* Ke=NULL;
+	int gsize;
+	int fsize;
+	int ssize;
+	int* gglobaldoflist=NULL;
+	int* flocaldoflist=NULL;
+	int* fglobaldoflist=NULL;
+	int* slocaldoflist=NULL;
+	int* sglobaldoflist=NULL;
+	bool square=true;
+
+	/*retrieve some parameters: */
+	parameters->FindParam(&kff,KffEnum);
+
+	/*get number of dofs in sets g,f and s: */
+	gsize=GetNumberOfDofs(nodes,numnodes,GsetEnum,approximation);
+	if(kff){
+		fsize=GetNumberOfDofs(nodes,numnodes,FsetEnum,approximation);
+		ssize=GetNumberOfDofs(nodes,numnodes,SsetEnum,approximation);
+	}
+
+	/*get dof lists for f and s set: */
+	gglobaldoflist=GetGlobalDofList(nodes,numnodes,GsetEnum,approximation);
+	if(kff){
+		flocaldoflist= GetLocalDofList( nodes,numnodes,FsetEnum,approximation);
+		fglobaldoflist=GetGlobalDofList(nodes,numnodes,FsetEnum,approximation);
+		slocaldoflist= GetLocalDofList( nodes,numnodes,SsetEnum,approximation);
+		sglobaldoflist=GetGlobalDofList(nodes,numnodes,SsetEnum,approximation);
+	}
+
+	/*constructor for ElementMatrix: */
+	if(!kff) Ke=new ElementMatrix(square,gglobaldoflist,gsize);
+	else     Ke=new ElementMatrix(square,gglobaldoflist,gsize,flocaldoflist,fglobaldoflist,fsize,slocaldoflist,sglobaldoflist,ssize);
+
+	/*Clean-up and return*/
+	xfree((void**)&gglobaldoflist);
+	xfree((void**)&flocaldoflist);
+	xfree((void**)&sglobaldoflist);
+	xfree((void**)&slocaldoflist);
+	xfree((void**)&fglobaldoflist);
+	return Ke;
+}
Index: /issm/trunk/src/c/shared/Elements/NewElementVector.cpp
===================================================================
--- /issm/trunk/src/c/shared/Elements/NewElementVector.cpp	(revision 5908)
+++ /issm/trunk/src/c/shared/Elements/NewElementVector.cpp	(revision 5908)
@@ -0,0 +1,44 @@
+/*!\file:  NewElementVector.cpp
+ * \brief create new element matrix
+ */ 
+#include "./elements.h"
+
+ElementVector* NewElementVector(Node** nodes,int numnodes,Parameters* parameters,int approximation){
+
+	/*parameters: */
+	bool kff=false;
+
+	/*output: */
+	ElementVector* pe=NULL;
+	int gsize;
+	int fsize;
+	int* gglobaldoflist=NULL;
+	int* flocaldoflist=NULL;
+	int* fglobaldoflist=NULL;
+
+	/*retrieve some parameters: */
+	parameters->FindParam(&kff,KffEnum);
+
+	/*get number of dofs in sets g,f and s: */
+	gsize=GetNumberOfDofs(nodes,numnodes,GsetEnum,approximation);
+	if(kff)fsize=GetNumberOfDofs(nodes,numnodes,FsetEnum,approximation);
+
+	/*get dof lists for f and s set: */
+	if(!kff){
+		gglobaldoflist=GetGlobalDofList(nodes,numnodes,GsetEnum,approximation);
+	}
+	else{
+		flocaldoflist= GetLocalDofList( nodes,numnodes,FsetEnum,approximation);
+		fglobaldoflist=GetGlobalDofList(nodes,numnodes,FsetEnum,approximation);
+	}
+
+	/*constructor for ElementVector: */
+	if(!kff)pe=new ElementVector(gsize,gglobaldoflist);
+	else    pe=new ElementVector(gsize,flocaldoflist,fglobaldoflist,fsize);
+
+	/*Clean-up and return*/
+	xfree((void**)&gglobaldoflist);
+	xfree((void**)&flocaldoflist);
+	xfree((void**)&fglobaldoflist);
+	return pe;
+}
Index: /issm/trunk/src/c/shared/Elements/elements.h
===================================================================
--- /issm/trunk/src/c/shared/Elements/elements.h	(revision 5907)
+++ /issm/trunk/src/c/shared/Elements/elements.h	(revision 5908)
@@ -8,7 +8,15 @@
 #include "../../objects/objects.h"
 #include "../../Container/Container.h"
+class ElementMatrix;
+class ElementVector;
 
-double Paterson(double temperature);
-int    GetVerticesCoordinates(double* xyz,  Node** nodes, int numvertices);
+double         Paterson(double temperature);
+int            GetVerticesCoordinates(double* xyz,  Node** nodes, int numvertices);
+int            GetNumberOfDofs( Node** nodes,int numnodes,int setenum,int approximation_enum);
+int*           GetLocalDofList( Node** nodes,int numnodes,int setenum,int approximation_enum);
+int*           GetGlobalDofList(Node** nodes,int numnodes,int setenum,int approximation_enum);
+ElementMatrix* NewElementMatrix(Node** nodes,int numnodes,Parameters* parameters,int approximation=NoneApproximationEnum);
+ElementVector* NewElementVector(Node** nodes,int numnodes,Parameters* parameters,int approximation=NoneApproximationEnum);
+//ElementVector* NewElementVector(Nodes** nodes,int numnodes,Parameters* parameters,int approximation=NoneApproximationEnum);
 
 inline void printarray(double* array,int lines,int cols=1){
