Index: /issm/trunk/src/c/objects/Elements/Penta.cpp
===================================================================
--- /issm/trunk/src/c/objects/Elements/Penta.cpp	(revision 5842)
+++ /issm/trunk/src/c/objects/Elements/Penta.cpp	(revision 5843)
@@ -4077,4 +4077,94 @@
 }
 /*}}}*/
+/*FUNCTION Penta::GetLocalDofList {{{1*/
+int*  Penta::GetLocalDofList(int approximation_enum,int setenum){
+
+	int  i,j,count,numdof,numgdof;
+	int  ndof_list[NUMVERTICES];
+	int  ngdof_list_cumulative[NUMVERTICES];
+	int *doflist = NULL;
+
+	/*Get number of dofs per node, and total for this given set*/
+	numdof=0;
+	numgdof=0;
+	for(i=0;i<NUMVERTICES;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_enum,setenum);
+		numgdof    +=nodes[i]->GetNumberOfDofs(approximation_enum,GsetEnum);
+		numdof     +=ndof_list[i];
+	}
+
+	if(numdof){
+		/*Allocate: */
+		doflist=(int*)xmalloc(numdof*sizeof(int));
+
+		/*Populate: */
+		count=0;
+		for(i=0;i<NUMVERTICES;i++){
+			nodes[i]->GetLocalDofList(&doflist[count],approximation_enum,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<NUMVERTICES;i++){
+			for(j=0;j<ndof_list[i];j++){
+				doflist[count+j]+=ngdof_list_cumulative[i];
+			}
+			count+=ndof_list[i];
+		}
+	}
+	else doflist=NULL;
+
+	return doflist;
+}
+/*}}}*/
+/*FUNCTION Penta::GetGlobalDofList {{{1*/
+int* Penta::GetGlobalDofList(int approximation_enum,int setenum){
+
+	int  i,numdof,count;
+	int  ndof_list[NUMVERTICES];
+	int *doflist = NULL;
+
+	/*First, figure out size of doflist: */
+	numdof=0;
+	for(i=0;i<3;i++){
+		ndof_list[i]=nodes[i]->GetNumberOfDofs(approximation_enum,setenum);
+		numdof+=ndof_list[i];
+	}
+
+	if(numdof){
+		/*Allocate: */
+		doflist=(int*)xmalloc(numdof*sizeof(int));
+
+		/*Populate: */
+		count=0;
+		for(i=0;i<3;i++){
+			nodes[i]->GetDofList(&doflist[count],approximation_enum,setenum);
+			count+=ndof_list[i];
+		}
+	}
+	else doflist=NULL;
+
+	return doflist;
+}
+/*}}}*/
+/*FUNCTION Penta::GetNumberOfDofs {{{1*/
+int Penta::GetNumberOfDofs(int approximation_enum,int setenum){
+
+	/*output: */
+	int numberofdofs=0;
+
+	for(int i=0;i<NUMVERTICES;i++){
+		numberofdofs+=nodes[i]->GetNumberOfDofs(approximation_enum,setenum);
+	}
+
+	return numberofdofs;
+}
+/*}}}*/
 /*FUNCTION Penta::GetParameterListOnVertices(double* pvalue,int enumtype) {{{1*/
 void Penta::GetParameterListOnVertices(double* pvalue,int enumtype){
@@ -5524,4 +5614,97 @@
 }
 /*}}}*/
+/*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 5842)
+++ /issm/trunk/src/c/objects/Elements/Penta.h	(revision 5843)
@@ -19,4 +19,6 @@
 class Matpar;
 class Tria;
+class ElementMatrix;
+class ElementVector;
 
 #include "../../include/include.h"
@@ -150,4 +152,7 @@
 		void	  GetDofList(int** pdoflist,int approximation_enum,int setenum);
 		void	  GetDofList1(int* doflist);
+		int*    GetLocalDofList(int approximation_enum,int setenum);
+		int*    GetGlobalDofList(int approximation_enum,int setenum);
+		int GetNumberOfDofs(int approximation_enum,int setenum);
 		int     GetElementType(void);
 		void    GetParameterListOnVertices(double* pvalue,int enumtype);
@@ -184,4 +189,6 @@
 		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 5842)
+++ /issm/trunk/src/c/objects/Elements/Tria.cpp	(revision 5843)
@@ -5081,75 +5081,74 @@
 }
 /*}}}*/
-/*FUNCTION Tria::GetInternalDofList {{{1*/
-int*  Tria::GetInternalDofList(int approximation_enum,int setenum){
-
-	int i,j;
-	int numberofdofs=0;
-	int count=0;
-	int count2=0;
-	int ndof;
-	int ngdof;
-
-	/*output: */
-	int* doflist=NULL;
+/*FUNCTION Tria::GetLocalDofList {{{1*/
+int*  Tria::GetLocalDofList(int approximation_enum,int setenum){
+
+	int  i,j,count,numdof,numgdof;
+	int  ndof_list[NUMVERTICES];
+	int  ngdof_list_cumulative[NUMVERTICES];
+	int *doflist = NULL;
+
+	/*Get number of dofs per node, and total for this given set*/
+	numdof=0;
+	numgdof=0;
+	for(i=0;i<NUMVERTICES;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_enum,setenum);
+		numgdof    +=nodes[i]->GetNumberOfDofs(approximation_enum,GsetEnum);
+		numdof     +=ndof_list[i];
+	}
+
+	if(numdof){
+		/*Allocate: */
+		doflist=(int*)xmalloc(numdof*sizeof(int));
+
+		/*Populate: */
+		count=0;
+		for(i=0;i<NUMVERTICES;i++){
+			nodes[i]->GetLocalDofList(&doflist[count],approximation_enum,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<NUMVERTICES;i++){
+			for(j=0;j<ndof_list[i];j++){
+				doflist[count+j]+=ngdof_list_cumulative[i];
+			}
+			count+=ndof_list[i];
+		}
+	}
+	else doflist=NULL;
+
+	return doflist;
+}
+/*}}}*/
+/*FUNCTION Tria::GetGlobalDofList {{{1*/
+int* Tria::GetGlobalDofList(int approximation_enum,int setenum){
+
+	int  i,numdof,count;
+	int  ndof_list[NUMVERTICES];
+	int *doflist = NULL;
 
 	/*First, figure out size of doflist: */
+	numdof=0;
 	for(i=0;i<3;i++){
-		numberofdofs+=nodes[i]->GetNumberOfDofs(approximation_enum,setenum);
-	}
-
-	if(numberofdofs){
+		ndof_list[i]=nodes[i]->GetNumberOfDofs(approximation_enum,setenum);
+		numdof+=ndof_list[i];
+	}
+
+	if(numdof){
 		/*Allocate: */
-		doflist=(int*)xmalloc(numberofdofs*sizeof(int));
+		doflist=(int*)xmalloc(numdof*sizeof(int));
 
 		/*Populate: */
 		count=0;
 		for(i=0;i<3;i++){
-			nodes[i]->GetInternalDofList(doflist+count,approximation_enum,setenum);
-			count+=nodes[i]->GetNumberOfDofs(approximation_enum,setenum);
-		}
-		
-		/*We now have something like: [0 1 0 2 0 1]. Offset by gsize, to get something like:
-		 * [0 1 2 4 5 6]:*/
-		count=0;
-		count2=0;
-		for(i=0;i<3;i++){
-			ndof=nodes[i]->GetNumberOfDofs(approximation_enum,setenum);
-			for(j=count;j<count+ndof;j++)doflist[j]+=count2;
-			count+=ndof;
-			count2+=nodes[i]->GetNumberOfDofs(approximation_enum,GsetEnum);
-		}
-
-	}
-	else doflist=NULL;
-
-	return doflist;
-
-}
-/*}}}*/
-/*FUNCTION Tria::GetExternalDofList {{{1*/
-int* Tria::GetExternalDofList(int approximation_enum,int setenum){
-
-	int i,j;
-	int numberofdofs=0;
-	int count=0;
-
-	/*output: */
-	int* doflist=NULL;
-
-	/*First, figure out size of doflist: */
-	for(i=0;i<3;i++){
-		numberofdofs+=nodes[i]->GetNumberOfDofs(approximation_enum,setenum);
-	}
-
-	if(numberofdofs){
-		/*Allocate: */
-		doflist=(int*)xmalloc(numberofdofs*sizeof(int));
-
-		/*Populate: */
-		count=0;
-		for(i=0;i<3;i++){
-			nodes[i]->GetDofList(doflist+count,approximation_enum,setenum);
-			count+=nodes[i]->GetNumberOfDofs(approximation_enum,setenum);
+			nodes[i]->GetDofList(&doflist[count],approximation_enum,setenum);
+			count+=ndof_list[i];
 		}
 	}
@@ -5161,11 +5160,9 @@
 /*FUNCTION Tria::GetNumberOfDofs {{{1*/
 int Tria::GetNumberOfDofs(int approximation_enum,int setenum){
-
-	int i;
 	
 	/*output: */
 	int numberofdofs=0;
 
-	for(i=0;i<3;i++){
+	for(int i=0;i<NUMVERTICES;i++){
 		numberofdofs+=nodes[i]->GetNumberOfDofs(approximation_enum,setenum);
 	}
@@ -5773,10 +5770,10 @@
 
 	/*get dof lists for f and s set: */
-	gglobaldoflist=this->GetExternalDofList(approximation,GsetEnum);
+	gglobaldoflist=this->GetGlobalDofList(approximation,GsetEnum);
 	if(kff){
-		flocaldoflist=this->GetInternalDofList(approximation,FsetEnum);
-		fglobaldoflist=this->GetExternalDofList(approximation,FsetEnum);
-		slocaldoflist=this->GetInternalDofList(approximation,SsetEnum);
-		sglobaldoflist=this->GetExternalDofList(approximation,SsetEnum);
+		flocaldoflist=this->GetLocalDofList(approximation,FsetEnum);
+		fglobaldoflist=this->GetGlobalDofList(approximation,FsetEnum);
+		slocaldoflist=this->GetLocalDofList(approximation,SsetEnum);
+		sglobaldoflist=this->GetGlobalDofList(approximation,SsetEnum);
 	}
 
@@ -5818,9 +5815,9 @@
 	/*get dof lists for f and s set: */
 	if(!kff){
-		gglobaldoflist=this->GetExternalDofList(approximation,GsetEnum);
+		gglobaldoflist=this->GetGlobalDofList(approximation,GsetEnum);
 	}
 	else{
-		flocaldoflist=this->GetInternalDofList(approximation,FsetEnum);
-		fglobaldoflist=this->GetExternalDofList(approximation,FsetEnum);
+		flocaldoflist=this->GetLocalDofList(approximation,FsetEnum);
+		fglobaldoflist=this->GetGlobalDofList(approximation,FsetEnum);
 	}
 
Index: /issm/trunk/src/c/objects/Elements/Tria.h
===================================================================
--- /issm/trunk/src/c/objects/Elements/Tria.h	(revision 5842)
+++ /issm/trunk/src/c/objects/Elements/Tria.h	(revision 5843)
@@ -153,17 +153,17 @@
 		void	  CreatePVectorThermalSheet( Vec pg);
 		void	  CreatePVectorThermalShelf( Vec pg);
-		double    GetArea(void);
-		int       GetElementType(void);
+		double  GetArea(void);
+		int     GetElementType(void);
 		void	  GetDofList(int** pdoflist,int approximation_enum,int setenum);
 		void	  GetDofList1(int* doflist);
-		int*      GetInternalDofList(int approximation_enum,int setenum);
-		int*      GetExternalDofList(int approximation_enum,int setenum);
-		int       GetNumberOfDofs(int approximation_enum,int setenum);
-		void      GetParameterListOnVertices(double* pvalue,int enumtype);
-		void      GetParameterListOnVertices(double* pvalue,int enumtype,double defaultvalue);
-		void      GetParameterValue(double* pvalue,Node* node,int enumtype);
+		int*    GetLocalDofList(int approximation_enum,int setenum);
+		int*    GetGlobalDofList(int approximation_enum,int setenum);
+		int     GetNumberOfDofs(int approximation_enum,int setenum);
+		void    GetParameterListOnVertices(double* pvalue,int enumtype);
+		void    GetParameterListOnVertices(double* pvalue,int enumtype,double defaultvalue);
+		void    GetParameterValue(double* pvalue,Node* node,int enumtype);
 		void	  GetSolutionFromInputsDiagnosticHoriz(Vec solution);
 		void	  GetSolutionFromInputsDiagnosticHutter(Vec solution);
-		void      GetStrainRate2d(double* epsilon,double* xyz_list, GaussTria* gauss, Input* vx_input, Input* vy_input);
+		void    GetStrainRate2d(double* epsilon,double* xyz_list, GaussTria* gauss, Input* vx_input, Input* vy_input);
 		void	  GradjDragStokes(Vec gradient);
 		void	  InputUpdateFromSolutionAdjointBalancedthickness( double* solution);
Index: /issm/trunk/src/c/objects/Node.cpp
===================================================================
--- /issm/trunk/src/c/objects/Node.cpp	(revision 5842)
+++ /issm/trunk/src/c/objects/Node.cpp	(revision 5843)
@@ -383,6 +383,6 @@
 }
 /*}}}*/
-/*FUNCTION Node::GetInternalDofList{{{1*/
-void  Node::GetInternalDofList(int* outdoflist,int approximation_enum,int setenum){
+/*FUNCTION Node::GetLocalDofList{{{1*/
+void  Node::GetLocalDofList(int* outdoflist,int approximation_enum,int setenum){
 	int i;
 	int count=0;
Index: /issm/trunk/src/c/objects/Node.h
===================================================================
--- /issm/trunk/src/c/objects/Node.h	(revision 5842)
+++ /issm/trunk/src/c/objects/Node.h	(revision 5843)
@@ -81,5 +81,5 @@
 		int   GetConnectivity();
 		void  GetDofList(int* poutdoflist,int approximation_enum,int setenum);
-		void  GetInternalDofList(int* poutdoflist,int approximation_enum,int setenum);
+		void  GetLocalDofList(int* poutdoflist,int approximation_enum,int setenum);
 		int   GetDofList1(void);
 		double GetX();
