Index: /issm/trunk-jpl/src/c/EnumDefinitions/EnumDefinitions.h
===================================================================
--- /issm/trunk-jpl/src/c/EnumDefinitions/EnumDefinitions.h	(revision 14655)
+++ /issm/trunk-jpl/src/c/EnumDefinitions/EnumDefinitions.h	(revision 14656)
@@ -547,4 +547,10 @@
 	XYZPEnum,
 	/*}}}*/
+	/*Toolkits{{{1*/
+	DenseEnum,
+	MpiDenseEnum,
+	SeqEnum,
+	MpiEnum,
+	/*}}}*/
 	/*Options{{{1*/
 	OptionEnum,
Index: /issm/trunk-jpl/src/c/Makefile.am
===================================================================
--- /issm/trunk-jpl/src/c/Makefile.am	(revision 14655)
+++ /issm/trunk-jpl/src/c/Makefile.am	(revision 14656)
@@ -220,6 +220,14 @@
 					./toolkits/metis/metisincludes.h\
 					./toolkits/issm/issmtoolkit.h\
-					./toolkits/issm/SeqVec.h\
-					./toolkits/issm/SeqMat.h\
+					./toolkits/issm/IssmToolkitUtils.h\
+					./toolkits/issm/IssmToolkitUtils.cpp\
+					./toolkits/issm/IssmAbsMat.h\
+					./toolkits/issm/IssmAbsVec.h\
+					./toolkits/issm/IssmDenseMat.h\
+					./toolkits/issm/IssmMat.h\
+					./toolkits/issm/IssmMpiDenseMat.h\
+					./toolkits/issm/IssmMpiVec.h\
+					./toolkits/issm/IssmSeqVec.h\
+					./toolkits/issm/IssmVec.h\
 					./toolkits/triangle/triangleincludes.h\
 					./toolkitsenums.h\
Index: /issm/trunk-jpl/src/c/classes/ToolkitOptions.cpp
===================================================================
--- /issm/trunk-jpl/src/c/classes/ToolkitOptions.cpp	(revision 14655)
+++ /issm/trunk-jpl/src/c/classes/ToolkitOptions.cpp	(revision 14656)
@@ -32,4 +32,9 @@
 
 	return TokenValue(toolkitoptions,"toolkit");
+
+}/*}}}*/
+char* ToolkitOptions::GetToolkitOptionValue(char* option){  /*{{{*/
+
+	return TokenValue(toolkitoptions,option);
 
 }/*}}}*/
Index: /issm/trunk-jpl/src/c/classes/ToolkitOptions.h
===================================================================
--- /issm/trunk-jpl/src/c/classes/ToolkitOptions.h	(revision 14655)
+++ /issm/trunk-jpl/src/c/classes/ToolkitOptions.h	(revision 14656)
@@ -26,4 +26,5 @@
 		static void Init(char* options);
 		static char* GetToolkitType(void);
+		static char* GetToolkitOptionValue(char* option);
 };
 
Index: /issm/trunk-jpl/src/c/classes/matrix/Matrix.h
===================================================================
--- /issm/trunk-jpl/src/c/classes/matrix/Matrix.h	(revision 14655)
+++ /issm/trunk-jpl/src/c/classes/matrix/Matrix.h	(revision 14656)
@@ -18,5 +18,5 @@
 /*}}}*/
 
-enum matrixtype { PetscMatType, SeqMatType };
+enum matrixtype { PetscMatType, IssmMatType };
 
 template <class doubletype> class Vector;
@@ -27,174 +27,139 @@
 	public:
 
+		int       type;
 		#ifdef _HAVE_PETSC_
-		PetscMat *pmatrix;
+		PetscMat              *pmatrix;
 		#endif
-		SeqMat<doubletype>   *smatrix;
-		int       type;
+		IssmMat<doubletype>   *imatrix;
 
 		/*Matrix constructors, destructors*/
 		/*FUNCTION Matrix(){{{*/
 		Matrix(){
+			InitCheckAndSetType();
+		}
+		/*}}}*/
+		/*FUNCTION Matrix(int M,int N){{{*/
+		Matrix(int M,int N){
+			
+			InitCheckAndSetType();
+
+			if(type==PetscMatType){
+				#ifdef _HAVE_PETSC_
+				this->pmatrix=new PetscMat(M,N);
+				#endif
+			}
+			else{
+				this->imatrix=new IssmMat<doubletype>(M,N);
+			}
+
+		}
+		/*}}}*/
+		/*FUNCTION Matrix(int m,int n,int M,int N,int* d_nnz,int* o_nnz){{{*/
+		Matrix(int m,int n,int M,int N,int* d_nnz,int* o_nnz){
+
+			InitCheckAndSetType();
+
+			if(type==PetscMatType){
+				#ifdef _HAVE_PETSC_
+				this->pmatrix=new PetscMat(m,n,M,N,d_nnz,o_nnz);
+				#endif
+			}
+			else{
+				this->imatrix=new IssmMat<doubletype>(m,n,M,N,d_nnz,o_nnz);
+			}
+
+		}
+		/*}}}*/
+		/*FUNCTION Matrix(int M,int N,IssmDouble sparsity){{{*/
+		Matrix(int M,int N,double sparsity){
+			
+			InitCheckAndSetType();
+
+			if(type==PetscMatType){
+				#ifdef _HAVE_PETSC_
+				this->pmatrix=new PetscMat(M,N,sparsity);
+				#endif
+			}
+			else{
+				this->imatrix=new IssmMat<doubletype>(M,N,sparsity);
+			}
+		}
+		/*}}}*/
+		/*FUNCTION Matrix(IssmDouble* serial_mat, int M,int N,IssmDouble sparsity){{{*/
+		Matrix(IssmPDouble* serial_mat,int M,int N,IssmPDouble sparsity){
+			
+			InitCheckAndSetType();
+
+			if(type==PetscMatType){
+				#ifdef _HAVE_PETSC_
+				this->pmatrix=new PetscMat(serial_mat,M,N,sparsity);
+				#endif
+			}
+			else{
+				this->imatrix=new IssmMat<doubletype>(serial_mat,M,N,sparsity);
+			}
+
+		}
+		/*}}}*/
+		/*FUNCTION Matrix(int M,int N,int connectivity,int numberofdofspernode,int in_type){{{*/
+		Matrix(int M,int N,int connectivity,int numberofdofspernode){
+			
+			InitCheckAndSetType();
+
+			if(type==PetscMatType){
+				#ifdef _HAVE_PETSC_
+				this->pmatrix=new PetscMat(M,N,connectivity,numberofdofspernode);
+				#endif
+			}
+			else{
+				this->imatrix=new IssmMat<doubletype>(M,N,connectivity,numberofdofspernode);
+			}
+
+		}
+		/*}}}*/
+		/*FUNCTION ~Matrix(){{{*/
+		~Matrix(){
+
+			if(type==PetscMatType){
+				#ifdef _HAVE_PETSC_
+				delete this->pmatrix;
+				#endif
+			}
+			else delete this->imatrix;
+
+		}
+		/*}}}*/
+		/*FUNCTION InitCheckAndSetType(){{{*/
+		void InitCheckAndSetType(void){
+
+			char* toolkittype=NULL;
 
 			#ifdef _HAVE_PETSC_
 			pmatrix=NULL;
 			#endif
-			smatrix=NULL;
-
-			type=PetscMatType; //default
-			#ifndef _HAVE_PETSC_
-			type=SeqMatType;
-			#endif
-
-		}
-		/*}}}*/
-		/*FUNCTION Matrix(int M,int N,int in_type){{{*/
-		#ifdef _HAVE_PETSC_
-		Matrix(int M,int N,int in_type=PetscMatType){
-		#else
-		Matrix(int M,int N,int in_type=SeqMatType){
-		#endif
-
-			#ifdef _HAVE_PETSC_
-			pmatrix=NULL;
-			#endif
-			smatrix=NULL;
-			type=in_type;
-
-			if(type==PetscMatType){
-				#ifdef _HAVE_PETSC_
-				this->pmatrix=new PetscMat(M,N);
+			imatrix=NULL;
+
+			/*retrieve toolkittype: */
+			toolkittype=ToolkitOptions::GetToolkitType();
+
+			/*set matrix type: */
+			if (strcmp(toolkittype,"petsc")==0){
+				#ifdef _HAVE_PETSC_
+				type=PetscMatType; 
 				#else
-				_error_("Petsc matrix format not usable, as Petsc has not been compiled!");
-				#endif
-			}
-			else if(type==SeqMatType){
-				this->smatrix=new SeqMat<doubletype>(M,N);
-			}
-			else _error_("Matrix type: " << type << " not supported yet!");
-
-		}
-		/*}}}*/
-		/*FUNCTION Matrix(int m,int n,int M,int N,int* d_nnz,int* o_nnz,int type){{{*/
-		#ifdef _HAVE_PETSC_
-		Matrix(int m,int n,int M,int N,int* d_nnz,int* o_nnz,int in_type=PetscMatType){
-		#else
-		Matrix(int m,int n,int M,int N,int* d_nnz,int* o_nnz,int in_type=SeqMatType){
-		#endif
-
-			#ifdef _HAVE_PETSC_
-			pmatrix=NULL;
-			#endif
-			smatrix=NULL;
-			type=in_type;
-
-			if(type==PetscMatType){
-				#ifdef _HAVE_PETSC_
-				this->pmatrix=new PetscMat(m,n,M,N,d_nnz,o_nnz);
-				#else
-				_error_("Petsc matrix format not usable, as Petsc has not been compiled!");
-				#endif
-			}
-			else if(type==SeqMatType){
-				this->smatrix=new SeqMat<doubletype>(m,n,M,N,d_nnz,o_nnz);
-			}
-			else _error_("Matrix type: " << type << " not supported yet!");
-
-		}
-		/*}}}*/
-		/*FUNCTION Matrix(int M,int N,IssmDouble sparsity,int in_type){{{*/
-		#ifdef _HAVE_PETSC_
-		Matrix(int M,int N,double sparsity,int in_type=PetscMatType){
-		#else
-		Matrix(int M,int N,double sparsity,int in_type=SeqMatType){
-		#endif
-
-			#ifdef _HAVE_PETSC_
-			pmatrix=NULL;
-			#endif
-
-			smatrix=NULL;
-			type=in_type;
-
-			if(type==PetscMatType){
-				#ifdef _HAVE_PETSC_
-				this->pmatrix=new PetscMat(M,N,sparsity);
-				#else
-				_error_("Petsc matrix format not usable, as Petsc has not been compiled!");
-				#endif
-			}
-			else if(type==SeqMatType){
-				this->smatrix=new SeqMat<doubletype>(M,N,sparsity);
-			}
-			else _error_("Matrix type: " << type << " not supported yet!");
-		}
-		/*}}}*/
-		/*FUNCTION Matrix(IssmDouble* serial_mat, int M,int N,IssmDouble sparsity,int in_type){{{*/
-		#ifdef _HAVE_PETSC_
-		Matrix(IssmPDouble* serial_mat,int M,int N,IssmPDouble sparsity,int in_type=PetscMatType){
-		#else
-		Matrix(IssmPDouble* serial_mat,int M,int N,IssmPDouble sparsity,int in_type=SeqMatType){
-		#endif
-
-			#ifdef _HAVE_PETSC_
-			pmatrix=NULL;
-			#endif
-			smatrix=NULL;
-			type=in_type;
-
-			if(type==PetscMatType){
-				#ifdef _HAVE_PETSC_
-				this->pmatrix=new PetscMat(serial_mat,M,N,sparsity);
-				#else
-				_error_("Petsc matrix format not usable, as Petsc has not been compiled!");
-				#endif
-			}
-			else if(type==SeqMatType){
-				this->smatrix=new SeqMat<doubletype>(serial_mat,M,N,sparsity);
-			}
-			else _error_("Matrix type: " << type << " not supported yet!");
-
-		}
-		/*}}}*/
-		/*FUNCTION Matrix(int M,int N,int connectivity,int numberofdofspernode,int in_type){{{*/
-		#ifdef _HAVE_PETSC_
-		Matrix(int M,int N,int connectivity,int numberofdofspernode,int in_type=PetscMatType){
-		#else
-		Matrix(int M,int N,int connectivity,int numberofdofspernode,int in_type=SeqMatType){
-		#endif
-
-			#ifdef _HAVE_PETSC_
-			pmatrix=NULL;
-			#endif
-			smatrix=NULL;
-			type=in_type;
-
-			if(type==PetscMatType){
-				#ifdef _HAVE_PETSC_
-				this->pmatrix=new PetscMat(M,N,connectivity,numberofdofspernode);
-				#else
-				_error_("Petsc matrix format not usable, as Petsc has not been compiled!");
-				#endif
-			}
-			else if(type==SeqMatType){
-				this->smatrix=new SeqMat<doubletype>(M,N,connectivity,numberofdofspernode);
-			}
-			else _error_("Matrix type: " << type << " not supported yet!");
-
-		}
-		/*}}}*/
-		/*FUNCTION ~Matrix(){{{*/
-		~Matrix(){
-
-			if(type==PetscMatType){
-				#ifdef _HAVE_PETSC_
-				delete this->pmatrix;
-				#endif
-			}
-			else if(type==SeqMatType){
-				delete this->smatrix;
-			}
-
-		}
+				_error_("cannot create petsc matrix without PETSC compiled!");
+				#endif
+			}
+			else if(strcmp(toolkittype,"issm")==0){
+				/*let this choice stand:*/
+				type=IssmMatType;
+			}
+			else _error_("unknow toolkit type ");
+			
+			/*Free ressources: */
+			xDelete<char>(toolkittype);
+		}
+
+		
 		/*}}}*/
 
@@ -209,8 +174,7 @@
 				#endif
 			}
-			else if(type==SeqMatType){
-				this->smatrix->Echo();
-			}
-			else _error_("Matrix type: " << type << " not supported yet!");
+			else{
+				this->imatrix->Echo();
+			}
 
 		}
@@ -224,8 +188,7 @@
 				#endif
 			}
-			else if(type==SeqMatType){
-				//this->smatrix->AllocationInfo();
-			}
-			else _error_("Matrix type: " << type << " not supported yet!");
+			else{
+				this->imatrix->AllocationInfo();
+			}
 		}/*}}}*/
 		/*FUNCTION Assemble{{{*/
@@ -237,9 +200,6 @@
 				#endif
 			}
-			else if(type==SeqMatType){
-				this->smatrix->Assemble();
-			}
-			else{
-				_error_("Matrix type: " << type << " not supported yet!");
+			else{
+				this->imatrix->Assemble();
 			}
 		}
@@ -255,8 +215,7 @@
 				#endif
 			}
-			else if(type==SeqMatType){
-				norm=this->smatrix->Norm(norm_type);
-			}
-			else _error_("Matrix type: " << type << " not supported yet!");
+			else{
+				norm=this->imatrix->Norm(norm_type);
+			}
 
 			return norm;
@@ -271,8 +230,7 @@
 				#endif
 			}
-			else if(type==SeqMatType){
-				this->smatrix->GetSize(pM,pN);
-			}
-			else _error_("Matrix type: " << type << " not supported yet!");
+			else{
+				this->imatrix->GetSize(pM,pN);
+			}
 
 		}
@@ -286,8 +244,7 @@
 				#endif
 			}
-			else if(type==SeqMatType){
-				this->smatrix->GetLocalSize(pM,pN);
-			}
-			else _error_("Matrix type: " << type << " not supported yet!");
+			else{
+				this->imatrix->GetLocalSize(pM,pN);
+			}
 
 		}
@@ -301,8 +258,7 @@
 				#endif
 			}
-			else if(type==SeqMatType){
-				this->smatrix->MatMult(X->svector,AX->svector);
-			}
-			else _error_("Matrix type: " << type << " not supported yet!");
+			else{
+				this->imatrix->MatMult(X->ivector,AX->ivector);
+			}
 
 		}
@@ -318,8 +274,7 @@
 				#endif
 			}
-			else if(type==SeqMatType){
-				output->smatrix=this->smatrix->Duplicate();
-			}
-			else _error_("Matrix type: " << type << " not supported yet!");
+			else{
+				output->imatrix=this->imatrix->Duplicate();
+			}
 
 			return output;
@@ -336,8 +291,7 @@
 				#endif
 			}
-			else if(type==SeqMatType){
-				output=this->smatrix->ToSerial();
-			}
-			else _error_("Matrix type: " << type << " not supported yet!");
+			else{
+				output=this->imatrix->ToSerial();
+			}
 
 			return output;
@@ -352,8 +306,7 @@
 				#endif
 			}
-			else if(type==SeqMatType){
-				this->smatrix->SetValues(m,idxm,n,idxn,values,mode);
-			}
-			else _error_("Matrix type: " << type << " not supported yet!");
+			else{
+				this->imatrix->SetValues(m,idxm,n,idxn,values,mode);
+			}
 		}
 		/*}}}*/
@@ -366,9 +319,6 @@
 				#endif
 			}
-			else if(type==SeqMatType){
-				this->smatrix->Convert(newtype);
-			}
-			else{
-				_error_("Matrix type: " << type << " not supported yet!");
+			else{
+				this->imatrix->Convert(newtype);
 			}
 
Index: /issm/trunk-jpl/src/c/classes/matrix/Vector.h
===================================================================
--- /issm/trunk-jpl/src/c/classes/matrix/Vector.h	(revision 14655)
+++ /issm/trunk-jpl/src/c/classes/matrix/Vector.h	(revision 14656)
@@ -16,8 +16,7 @@
 #include "../../toolkits/toolkits.h"
 #include "../../EnumDefinitions/EnumDefinitions.h"
-
 /*}}}*/
 
-enum vectortype { PetscVecType, SeqVecType };
+enum vectortype { PetscVecType, IssmVecType };
 
 template <class doubletype> 
@@ -30,129 +29,101 @@
 		PetscVec* pvector;
 		#endif
-		SeqVec<doubletype>* svector; 
+		IssmVec<doubletype>* ivector; 
 
 		/*Vector constructors, destructors */
-		/*FUNCTION Vector(){{{*/
-		Vector(){
-
-			#ifdef _HAVE_PETSC_
-			this->pvector=NULL;
-			#endif
-			this->svector=NULL;
-
-			type=PetscVecType; //default
-			#ifndef _HAVE_PETSC_
-			type=SeqVecType;
-			#endif
-
-		}
-		/*}}}*/
-		/*FUNCTION Vector(int M,bool fromlocalsize,int in_type){{{*/
+		Vector(){ /*{{{*/
+
+			InitCheckAndSetType();
+		}
+		/*}}}*/
+		Vector(int M,bool fromlocalsize=false){ /*{{{*/
+			
+			InitCheckAndSetType();
+
+			if(type==PetscVecType){
+				#ifdef _HAVE_PETSC_
+				this->pvector=new PetscVec(M,fromlocalsize);
+				#endif
+			}
+			else this->ivector=new IssmVec<doubletype>(M,fromlocalsize);
+
+		}
+		/*}}}*/
+		Vector(int m,int M){ /*{{{*/
+
+			InitCheckAndSetType();
+
+			if(type==PetscVecType){
+				#ifdef _HAVE_PETSC_
+					this->pvector=new PetscVec(m,M);
+				 #endif
+			}
+			else this->ivector=new IssmVec<doubletype>(m,M);
+		}
+		/*}}}*/
+		Vector(doubletype* serial_vec,int M){ /*{{{*/
+			
+			InitCheckAndSetType();
+
+			if(type==PetscVecType){
+				#ifdef _HAVE_PETSC_
+				this->pvector=new PetscVec(serial_vec,M);
+				#endif
+			}
+			else this->ivector=new IssmVec<doubletype>(serial_vec,M);
+		}
+		/*}}}*/
+		~Vector(){ /*{{{*/
+
+			if(type==PetscVecType){
+				#ifdef _HAVE_PETSC_
+				delete this->pvector;
+				#endif
+			}
+			else delete this->ivector;
+		}
+		/*}}}*/
 		#ifdef _HAVE_PETSC_
-		Vector(int M,bool fromlocalsize=false,int in_type=PetscVecType){
-		#else
-		Vector(int M,bool fromlocalsize=false,int in_type=SeqVecType){
+		Vector(Vec petsc_vector){ /*{{{*/
+
+			this->type=PetscVecType;
+			this->ivector=NULL;
+			this->pvector=new PetscVec(petsc_vector);
+
+		}
+		/*}}}*/
 		#endif
+		void InitCheckAndSetType(void){ /*{{{*/
+
+			char* toolkittype=NULL;
 
 			#ifdef _HAVE_PETSC_
 			pvector=NULL;
 			#endif
-			svector=NULL;
-			type=in_type;
-
-			if(type==PetscVecType){
-			#ifdef _HAVE_PETSC_
-				this->pvector=new PetscVec(M,fromlocalsize);
-			 #else
-				_error_("Petsc matrix format not usable, as Petsc has not been compiled!");
-			 #endif
-			}
-			else if(type==SeqVecType){
-				this->svector=new SeqVec<doubletype>(M,fromlocalsize);
-			}
-			else _error_("Vector type: " << type << " not supported yet!");
-
-		}
-		/*}}}*/
-		/*FUNCTION Vector(int m,int M,int in_type){{{*/
-		#ifdef _HAVE_PETSC_
-		Vector(int m,int M,int in_type=PetscVecType){
-		#else
-		Vector(int m,int M,int in_type=SeqVecType){
-		#endif
-
-			#ifdef _HAVE_PETSC_
-			pvector=NULL;
-			#endif
-			svector=NULL;
-			type=in_type;
-
-			if(type==PetscVecType){
-			#ifdef _HAVE_PETSC_
-				this->pvector=new PetscVec(m,M);
-			 #else
-				_error_("Petsc matrix format not usable, as Petsc has not been compiled!");
-			 #endif
-			}
-			else if(type==SeqVecType){
-				this->svector=new SeqVec<doubletype>(m,M);
-			}
-			else _error_("Vector type: " << type << " not supported yet!");
-
-		}
-		/*}}}*/
-		/*FUNCTION Vector(doubletype* serial_vec,int M,int in_type){{{*/
-		#ifdef _HAVE_PETSC_
-		Vector(doubletype* serial_vec,int M,int in_type=PetscVecType){
-		#else
-		Vector(doubletype* serial_vec,int M,int in_type=SeqVecType){
-			//} for vim
-		#endif
-
-			#ifdef _HAVE_PETSC_
-			pvector=NULL;
-			#endif
-
-			svector=NULL;
-			type=in_type;
-
-			if(type==PetscVecType){
-				#ifdef _HAVE_PETSC_
-				this->pvector=new PetscVec(serial_vec,M);
+			ivector=NULL;
+
+			/*retrieve toolkittype: */
+			toolkittype=ToolkitOptions::GetToolkitType();
+
+			/*set vector type: */
+			if (strcmp(toolkittype,"petsc")==0){
+				#ifdef _HAVE_PETSC_
+				type=PetscVecType; 
 				#else
-				_error_("Petsc matrix format not usable, as Petsc has not been compiled!");
-				#endif
-			}
-			else if(type==SeqVecType){
-				this->svector=new SeqVec<doubletype>(serial_vec,M);
-			}
-			else _error_("Vector type: " << type << " not supported yet!");
-
-		}
-		/*}}}*/
-		/*FUNCTION ~Vector(){{{*/
-		~Vector(){
-
-			if(type==PetscVecType){
-				#ifdef _HAVE_PETSC_
-				delete this->pvector;
-				#endif
-			}
-			else if(type==SeqVecType){
-				delete this->svector;
-			}
-		}
-		/*}}}*/
-		#ifdef _HAVE_PETSC_
-		/*FUNCTION Vector(Vec petsc_vector){{{*/
-		Vector(Vec petsc_vector){
-
-			this->type=PetscVecType;
-			this->svector=NULL;
-			this->pvector=new PetscVec(petsc_vector);
-
-		}
-		/*}}}*/
-		#endif
+				_error_("cannot create petsc vector without PETSC compiled!");
+				#endif
+			}
+			else if(strcmp(toolkittype,"issm")==0){
+				/*let this choice stand:*/
+				type=IssmVecType;
+			}
+			else _error_("unknow toolkit type ");
+			
+			/*Free ressources: */
+			xDelete<char>(toolkittype);
+		}
+
+		
+		/*}}}*/
 
 		/*Vector specific routines*/
@@ -163,12 +134,7 @@
 				#ifdef _HAVE_PETSC_
 				this->pvector->Echo();
-				#else
-				_error_("Petsc matrix format not usable, as Petsc has not been compiled!");
-				#endif
-			}
-			else if(type==SeqVecType){
-				this->svector->Echo();
-			}
-			else _error_("Vector type: " << type << " not supported yet!");
+				#endif
+			}
+			else this->ivector->Echo();
 
 		}
@@ -180,12 +146,7 @@
 				#ifdef _HAVE_PETSC_
 				this->pvector->Assemble();
-				#else
-				_error_("Petsc matrix format not usable, as Petsc has not been compiled!");
-				#endif
-			}
-			else if(type==SeqVecType){
-				this->svector->Assemble();
-			}
-			else _error_("Vector type: " << type << " not supported yet!");
+				#endif
+			}
+			else this->ivector->Assemble();
 
 		}
@@ -196,12 +157,7 @@
 				#ifdef _HAVE_PETSC_
 				this->pvector->SetValues(ssize,list,values,mode);
-				#else
-				_error_("Petsc matrix format not usable, as Petsc has not been compiled!");
-				#endif
-			}
-			else if(type==SeqVecType){
-				this->svector->SetValues(ssize,list,values,mode);
-			}
-			else _error_("Vector type: " << type << " not supported yet!");
+				#endif
+			}
+			else this->ivector->SetValues(ssize,list,values,mode);
 
 		}
@@ -213,12 +169,7 @@
 				#ifdef _HAVE_PETSC_
 				this->pvector->SetValue(dof,value,mode);
-				#else
-				_error_("Petsc matrix format not usable, as Petsc has not been compiled!");
-				#endif
-			}
-			else if(type==SeqVecType){
-				this->svector->SetValue(dof,value,mode);
-			}
-			else _error_("Vector type: " << type << " not supported yet!");
+				#endif
+			}
+			else this->ivector->SetValue(dof,value,mode);
 
 		}
@@ -230,12 +181,7 @@
 				#ifdef _HAVE_PETSC_
 				this->pvector->GetValue(pvalue,dof);
-				#else
-				_error_("Petsc matrix format not usable, as Petsc has not been compiled!");
-				#endif
-			}
-			else if(type==SeqVecType){
-				this->svector->GetValue(pvalue,dof);
-			}
-			else _error_("Vector type: " << type << " not supported yet!");
+				#endif
+			}
+			else this->ivector->GetValue(pvalue,dof);
 
 		}
@@ -247,20 +193,15 @@
 				#ifdef _HAVE_PETSC_
 				this->pvector->GetSize(pM);
-				#else
-				_error_("Petsc matrix format not usable, as Petsc has not been compiled!");
-				#endif
-			}
-			else if(type==SeqVecType){
-				this->svector->GetSize(pM);
-			}
-			else _error_("Vector type: " << type << " not supported yet!");
+				#endif
+			}
+			else this->ivector->GetSize(pM);
 
 		}
 		/*}}}*/
 		/*FUNCTION IsEmpty{{{*/
-		bool IsEmpty(void){_assert_(this);
-
+		bool IsEmpty(void){
 			int M;
-
+			
+			_assert_(this);
 			this->GetSize(&M);
 
@@ -277,12 +218,7 @@
 				#ifdef _HAVE_PETSC_
 				this->pvector->GetLocalSize(pM);
-				#else
-				_error_("Petsc matrix format not usable, as Petsc has not been compiled!");
-				#endif
-			}
-			else if(type==SeqVecType){
-				this->svector->GetLocalSize(pM);
-			}
-			else _error_("Vector type: " << type << " not supported yet!");
+				#endif
+			}
+			else this->ivector->GetLocalSize(pM);
 
 		}
@@ -292,18 +228,13 @@
 
 			Vector* output=NULL;
-
-			if(type==PetscVecType){
-				#ifdef _HAVE_PETSC_
-				output=new Vector();
+				
+			output=new Vector();
+
+			if(type==PetscVecType){
+				#ifdef _HAVE_PETSC_
 				output->pvector=this->pvector->Duplicate();
-				#else
-				_error_("Petsc matrix format not usable, as Petsc has not been compiled!");
-				#endif
-			}
-			else if(type==SeqVecType){
-				output=new Vector();
-				output->svector=this->svector->Duplicate();
-			}
-			else _error_("Vector type: " << type << " not supported yet!");
+				#endif
+			}
+			else output->ivector=this->ivector->Duplicate();
 
 			return output;
@@ -317,12 +248,7 @@
 				#ifdef _HAVE_PETSC_
 				this->pvector->Set(value);
-				#else
-				_error_("Petsc matrix format not usable, as Petsc has not been compiled!");
-				#endif
-			}
-			else if(type==SeqVecType){
-				this->svector->Set(value);
-			}
-			else _error_("Vector type: " << type << " not supported yet!");
+				#endif
+			}
+			else this->ivector->Set(value);
 
 		}
@@ -334,12 +260,7 @@
 				#ifdef _HAVE_PETSC_
 				this->pvector->AXPY(X->pvector,a);
-				#else
-				_error_("Petsc matrix format not usable, as Petsc has not been compiled!");
-				#endif
-			}
-			else if(type==SeqVecType){
-				this->svector->AXPY(X->svector,a);
-			}
-			else _error_("Vector type: " << type << " not supported yet!");
+				#endif
+			}
+			else this->ivector->AXPY(X->ivector,a);
 
 		}
@@ -351,31 +272,21 @@
 				#ifdef _HAVE_PETSC_
 				this->pvector->AYPX(X->pvector,a);
-				#else
-				_error_("Petsc matrix format not usable, as Petsc has not been compiled!");
-				#endif
-			}
-			else if(type==SeqVecType){
-				this->svector->AYPX(X->svector,a);
-			}
-			else _error_("Vector type: " << type << " not supported yet!");
-
+				#endif
+			}
+			else this->ivector->AYPX(X->ivector,a);
 		}
 		/*}}}*/
 		/*FUNCTION ToMPISerial{{{*/
-		doubletype* ToMPISerial(void){_assert_(this);
+		doubletype* ToMPISerial(void){
 
 			doubletype* vec_serial=NULL;
-
+			
+			_assert_(this);
 			if(type==PetscVecType){
 				#ifdef _HAVE_PETSC_
 				vec_serial=this->pvector->ToMPISerial();
-				#else
-				_error_("Petsc matrix format not usable, as Petsc has not been compiled!");
-				#endif
-			}
-			else if(type==SeqVecType){
-				vec_serial=this->svector->ToMPISerial();
-			}
-			else _error_("Vector type: " << type << " not supported yet!");
+				#endif
+			}
+			else vec_serial=this->ivector->ToMPISerial();
 
 			return vec_serial;
@@ -389,13 +300,7 @@
 				#ifdef _HAVE_PETSC_
 				this->pvector->Copy(to->pvector);
-				#else
-				_error_("Petsc matrix format not usable, as Petsc has not been compiled!");
-				#endif
-			}
-			else if(type==SeqVecType){
-				this->svector->Copy(to->svector);
-			}
-			else _error_("Vector type: " << type << " not supported yet!");
-
+				#endif
+			}
+			else this->ivector->Copy(to->ivector);
 		}
 		/*}}}*/
@@ -408,13 +313,7 @@
 				#ifdef _HAVE_PETSC_
 				norm=this->pvector->Norm(norm_type);
-				#else
-				_error_("Petsc matrix format not usable, as Petsc has not been compiled!");
-				#endif
-			}
-			else if(type==SeqVecType){
-				norm=this->svector->Norm(norm_type);
-			}
-			else _error_("Vector type: " << type << " not supported yet!");
-
+				#endif
+			}
+			else norm=this->ivector->Norm(norm_type);
 			return norm;
 		}
@@ -426,13 +325,7 @@
 				#ifdef _HAVE_PETSC_
 				this->pvector->Scale(scale_factor);
-				#else
-				_error_("Petsc matrix format not usable, as Petsc has not been compiled!");
-				#endif
-			}
-			else if(type==SeqVecType){
-				this->svector->Scale(scale_factor);
-			}
-			else _error_("Vector type: " << type << " not supported yet!");
-
+				#endif
+			}
+			else this->ivector->Scale(scale_factor);
 		}
 		/*}}}*/
@@ -445,13 +338,7 @@
 				#ifdef _HAVE_PETSC_
 				dot=this->pvector->Dot(vector->pvector);
-				#else
-				_error_("Petsc matrix format not usable, as Petsc has not been compiled!");
-				#endif
-			}
-			else if(type==SeqVecType){
-				dot=this->svector->Dot(vector->svector);
-			}
-			else _error_("Vector type: " << type << " not supported yet!");
-
+				#endif
+			}
+			else dot=this->ivector->Dot(vector->ivector);
 			return dot;
 		}
@@ -463,13 +350,7 @@
 				#ifdef _HAVE_PETSC_
 				this->pvector->PointwiseDivide(x->pvector,y->pvector);
-				#else
-				_error_("Petsc matrix format not usable, as Petsc has not been compiled!");
-				#endif
-			}
-			else if(type==SeqVecType){
-				this->svector->PointwiseDivide(x->svector,y->svector);
-			}
-			else _error_("Vector type: " << type << " not supported yet!");
-
+				#endif
+			}
+			else this->ivector->PointwiseDivide(x->ivector,y->ivector);
 		}
 		/*}}}*/
Index: /issm/trunk-jpl/src/c/modules/ContourToMeshx/ContourToMeshx.cpp
===================================================================
--- /issm/trunk-jpl/src/c/modules/ContourToMeshx/ContourToMeshx.cpp	(revision 14655)
+++ /issm/trunk-jpl/src/c/modules/ContourToMeshx/ContourToMeshx.cpp	(revision 14656)
@@ -10,5 +10,5 @@
 #include "./ContourToMeshx.h"
 
-int ContourToMeshx(SeqVec<double>** pin_nod,SeqVec<double>** pin_elem, double* index, double* x, double* y,DataSet* contours,char* interptype,int nel,int nods, int edgevalue) {
+int ContourToMeshx(IssmSeqVec<double>** pin_nod,IssmSeqVec<double>** pin_elem, double* index, double* x, double* y,DataSet* contours,char* interptype,int nel,int nods, int edgevalue) {
 
 	/*Contour:*/
@@ -24,8 +24,8 @@
 
 	/*output: */
-	SeqVec<double>* in_nod=NULL;
-	SeqVec<double>* in_elem=NULL;
-	in_nod  = new SeqVec<double>(nods);
-	in_elem = new SeqVec<double>(nel);
+	IssmSeqVec<double>* in_nod=NULL;
+	IssmSeqVec<double>* in_elem=NULL;
+	in_nod  = new IssmSeqVec<double>(nods);
+	in_elem = new IssmSeqVec<double>(nel);
 
 	/*initialize thread parameters: */
Index: /issm/trunk-jpl/src/c/modules/ContourToMeshx/ContourToMeshx.h
===================================================================
--- /issm/trunk-jpl/src/c/modules/ContourToMeshx/ContourToMeshx.h	(revision 14655)
+++ /issm/trunk-jpl/src/c/modules/ContourToMeshx/ContourToMeshx.h	(revision 14656)
@@ -15,5 +15,5 @@
 	int    nods;
 	int    edgevalue;
-	SeqVec<double> *in_nod;
+	IssmSeqVec<double> *in_nod;
 	double *x;
 	double *y;
@@ -22,5 +22,5 @@
 
 /* local prototypes: */
-int ContourToMeshx(SeqVec<double>** pin_nods,SeqVec<double>** pin_elem, double* index, double* x, double* y,DataSet* contours,char* interptype,int nel,int nods, int edgevalue);
+int ContourToMeshx(IssmSeqVec<double>** pin_nods,IssmSeqVec<double>** pin_elem, double* index, double* x, double* y,DataSet* contours,char* interptype,int nel,int nods, int edgevalue);
 
 void* ContourToMeshxt(void* vContourToMeshxThreadStruct);
Index: /issm/trunk-jpl/src/c/modules/ContourToMeshx/ContourToMeshxt.cpp
===================================================================
--- /issm/trunk-jpl/src/c/modules/ContourToMeshx/ContourToMeshxt.cpp	(revision 14655)
+++ /issm/trunk-jpl/src/c/modules/ContourToMeshx/ContourToMeshxt.cpp	(revision 14656)
@@ -33,5 +33,5 @@
 	double* x=NULL;
 	double* y=NULL;
-	SeqVec<double>* in_nod=NULL;
+	IssmSeqVec<double>* in_nod=NULL;
 
 	/*recover handle and gate: */
Index: /issm/trunk-jpl/src/c/modules/ContourToNodesx/ContourToNodesx.cpp
===================================================================
--- /issm/trunk-jpl/src/c/modules/ContourToNodesx/ContourToNodesx.cpp	(revision 14655)
+++ /issm/trunk-jpl/src/c/modules/ContourToNodesx/ContourToNodesx.cpp	(revision 14656)
@@ -4,5 +4,5 @@
 #include "./ContourToNodesx.h"
 
-int ContourToNodesx(SeqVec<IssmPDouble>** pflags,double* x, double* y, int nods, Contour<IssmPDouble>** contours,int numcontours,int edgevalue){
+int ContourToNodesx(IssmSeqVec<IssmPDouble>** pflags,double* x, double* y, int nods, Contour<IssmPDouble>** contours,int numcontours,int edgevalue){
 
 	int i;
@@ -15,6 +15,6 @@
 
 	/*output: */
-	SeqVec<IssmPDouble>* flags=NULL;
-	flags=new SeqVec<IssmPDouble>(nods);
+	IssmSeqVec<IssmPDouble>* flags=NULL;
+	flags=new IssmSeqVec<IssmPDouble>(nods);
 
 	/*Loop through all contours: */
@@ -35,5 +35,5 @@
 }
 
-int ContourToNodesx(SeqVec<IssmPDouble>** pflags,double* x, double* y, int nods, DataSet* contours, int edgevalue){
+int ContourToNodesx(IssmSeqVec<IssmPDouble>** pflags,double* x, double* y, int nods, DataSet* contours, int edgevalue){
 
 	/*Contour:*/
@@ -43,6 +43,6 @@
 
 	/*output: */
-	SeqVec<IssmPDouble>* flags=NULL;
-	flags=new SeqVec<IssmPDouble>(nods);
+	IssmSeqVec<IssmPDouble>* flags=NULL;
+	flags=new IssmSeqVec<IssmPDouble>(nods);
 
 	/*Loop through all contours: */
Index: /issm/trunk-jpl/src/c/modules/ContourToNodesx/ContourToNodesx.h
===================================================================
--- /issm/trunk-jpl/src/c/modules/ContourToNodesx/ContourToNodesx.h	(revision 14655)
+++ /issm/trunk-jpl/src/c/modules/ContourToNodesx/ContourToNodesx.h	(revision 14656)
@@ -10,6 +10,6 @@
 
 /* local prototypes: */
-int ContourToNodesx(SeqVec<IssmPDouble>** pflags,double* x, double* y, int nods, Contour<IssmPDouble>** contours,int numcontours,int edgevalue);
-int ContourToNodesx(SeqVec<IssmPDouble>** pflags,double* x, double* y, int nods, DataSet* contours, int edgevalue);
+int ContourToNodesx(IssmSeqVec<IssmPDouble>** pflags,double* x, double* y, int nods, Contour<IssmPDouble>** contours,int numcontours,int edgevalue);
+int ContourToNodesx(IssmSeqVec<IssmPDouble>** pflags,double* x, double* y, int nods, DataSet* contours, int edgevalue);
 
 #endif /* _CONTOURTONODESX_H */
Index: /issm/trunk-jpl/src/c/modules/EnumToStringx/EnumToStringx.cpp
===================================================================
--- /issm/trunk-jpl/src/c/modules/EnumToStringx/EnumToStringx.cpp	(revision 14655)
+++ /issm/trunk-jpl/src/c/modules/EnumToStringx/EnumToStringx.cpp	(revision 14656)
@@ -519,4 +519,8 @@
 		case XYEnum : return "XY";
 		case XYZPEnum : return "XYZP";
+		case DenseEnum : return "Dense";
+		case MpiDenseEnum : return "MpiDense";
+		case SeqEnum : return "Seq";
+		case MpiEnum : return "Mpi";
 		case OptionEnum : return "Option";
 		case GenericOptionEnum : return "GenericOption";
Index: /issm/trunk-jpl/src/c/modules/InterpFromGridToMeshx/InterpFromGridToMeshx.cpp
===================================================================
--- /issm/trunk-jpl/src/c/modules/InterpFromGridToMeshx/InterpFromGridToMeshx.cpp	(revision 14655)
+++ /issm/trunk-jpl/src/c/modules/InterpFromGridToMeshx/InterpFromGridToMeshx.cpp	(revision 14656)
@@ -17,8 +17,8 @@
 
 /*InterpFromGridToMeshx{{{*/
-int InterpFromGridToMeshx(SeqVec<IssmPDouble>** pdata_mesh,double* x_in, int x_rows, double* y_in, int y_rows, double* data, int M, int N, double* x_mesh, double* y_mesh, int nods,double default_value, int interpenum){
+int InterpFromGridToMeshx(IssmSeqVec<IssmPDouble>** pdata_mesh,double* x_in, int x_rows, double* y_in, int y_rows, double* data, int M, int N, double* x_mesh, double* y_mesh, int nods,double default_value, int interpenum){
 
 	/*output: */
-	SeqVec<IssmPDouble>* data_mesh=NULL;
+	IssmSeqVec<IssmPDouble>* data_mesh=NULL;
 
 	/*Intermediary*/
@@ -46,5 +46,5 @@
 
 	/*Allocate output vector: */
-	data_mesh=new SeqVec<IssmPDouble>(nods);
+	data_mesh=new IssmSeqVec<IssmPDouble>(nods);
 
 	/*Find out what kind of coordinates (x_in,y_in) have been given is input*/
@@ -126,5 +126,5 @@
 	double *y                     = gate->y;
 	int     nods                  = gate->nods;
-	SeqVec<IssmPDouble>*data_mesh = gate->data_mesh;
+	IssmSeqVec<IssmPDouble>*data_mesh = gate->data_mesh;
 	double *data                  = gate->data;
 	double  default_value         = gate->default_value;
Index: /issm/trunk-jpl/src/c/modules/InterpFromGridToMeshx/InterpFromGridToMeshx.h
===================================================================
--- /issm/trunk-jpl/src/c/modules/InterpFromGridToMeshx/InterpFromGridToMeshx.h	(revision 14655)
+++ /issm/trunk-jpl/src/c/modules/InterpFromGridToMeshx/InterpFromGridToMeshx.h	(revision 14656)
@@ -24,8 +24,8 @@
 	double*             x_mesh;
 	double*             y_mesh;
-	SeqVec<IssmPDouble>* data_mesh;
+	IssmSeqVec<IssmPDouble>* data_mesh;
 } InterpFromGridToMeshxThreadStruct;
 
-int    InterpFromGridToMeshx(SeqVec<IssmPDouble>** pdata_mesh,double* x, int x_rows, double* y, int y_rows, double* data, int M, int N, double* x_mesh, double* y_mesh, int nods, double default_value, int interpenum=BilinearInterpEnum);
+int    InterpFromGridToMeshx(IssmSeqVec<IssmPDouble>** pdata_mesh,double* x, int x_rows, double* y, int y_rows, double* data, int M, int N, double* x_mesh, double* y_mesh, int nods, double default_value, int interpenum=BilinearInterpEnum);
 void*  InterpFromGridToMeshxt(void* vInterpFromGridToMeshxThreadStruct);
 bool   findindices(int* pn,int* pm,double* x,int x_rows, double* y,int y_rows, double xgrid,double ygrid);
Index: /issm/trunk-jpl/src/c/modules/InterpFromMesh2dx/InterpFromMesh2dx.cpp
===================================================================
--- /issm/trunk-jpl/src/c/modules/InterpFromMesh2dx/InterpFromMesh2dx.cpp	(revision 14655)
+++ /issm/trunk-jpl/src/c/modules/InterpFromMesh2dx/InterpFromMesh2dx.cpp	(revision 14656)
@@ -10,5 +10,5 @@
 #include "../modules.h"
 
-int InterpFromMesh2dx(SeqVec<IssmPDouble>** pdata_prime,
+int InterpFromMesh2dx(IssmSeqVec<IssmPDouble>** pdata_prime,
 			double* index_data, double* x_data, double* y_data, int nods_data,int nels_data, double* data, int data_length,
 			double* x_prime, double* y_prime, int nods_prime,
@@ -16,5 +16,5 @@
 
 	/*Output*/
-	SeqVec<IssmPDouble>* data_prime=NULL;
+	IssmSeqVec<IssmPDouble>* data_prime=NULL;
 
 	/*Intermediary*/
@@ -26,5 +26,5 @@
 
 	/*contours: */
-	SeqVec<IssmPDouble> *vec_incontour = NULL;
+	IssmSeqVec<IssmPDouble> *vec_incontour = NULL;
 	double              *incontour     = NULL;
 
@@ -70,5 +70,5 @@
 
 	/*Initialize output*/
-	data_prime=new SeqVec<IssmPDouble>(nods_prime);
+	data_prime=new IssmSeqVec<IssmPDouble>(nods_prime);
 	if(num_default_values){
 		if(num_default_values==1)for (i=0;i<nods_prime;i++) data_prime->SetValue(i,default_values[0],INS_VAL);
Index: /issm/trunk-jpl/src/c/modules/InterpFromMesh2dx/InterpFromMesh2dx.h
===================================================================
--- /issm/trunk-jpl/src/c/modules/InterpFromMesh2dx/InterpFromMesh2dx.h	(revision 14655)
+++ /issm/trunk-jpl/src/c/modules/InterpFromMesh2dx/InterpFromMesh2dx.h	(revision 14656)
@@ -22,5 +22,5 @@
 	double              ymin,ymax;
 	int                 nods_prime;
-	SeqVec<IssmPDouble> *data_prime;
+	IssmSeqVec<IssmPDouble> *data_prime;
 	double              *x_prime;
 	double              *y_prime;
@@ -31,5 +31,5 @@
 } InterpFromMesh2dxThreadStruct;
 
-int InterpFromMesh2dx(SeqVec<IssmPDouble>** pdata_prime,double* index_data, double* x_data, double* y_data, int nods_data,int nels_data, double* data, int data_length, double* x_prime, double* y_prime, int nods_prime,
+int InterpFromMesh2dx(IssmSeqVec<IssmPDouble>** pdata_prime,double* index_data, double* x_data, double* y_data, int nods_data,int nels_data, double* data, int data_length, double* x_prime, double* y_prime, int nods_prime,
 		double* default_values,int num_default_values,Contour<IssmPDouble>** contours,int numcontours);
 
Index: /issm/trunk-jpl/src/c/modules/InterpFromMesh2dx/InterpFromMesh2dxt.cpp
===================================================================
--- /issm/trunk-jpl/src/c/modules/InterpFromMesh2dx/InterpFromMesh2dxt.cpp	(revision 14655)
+++ /issm/trunk-jpl/src/c/modules/InterpFromMesh2dx/InterpFromMesh2dxt.cpp	(revision 14656)
@@ -32,5 +32,5 @@
 	double  ymax                    = gate->ymax;
 	int     nods_prime              = gate->nods_prime;
-	SeqVec<IssmPDouble>* data_prime = gate->data_prime;
+	IssmSeqVec<IssmPDouble>* data_prime = gate->data_prime;
 	double *x_prime                 = gate->x_prime;
 	double *y_prime                 = gate->y_prime;
Index: /issm/trunk-jpl/src/c/modules/InterpFromMeshToMesh3dx/InterpFromMeshToMesh3dx.cpp
===================================================================
--- /issm/trunk-jpl/src/c/modules/InterpFromMeshToMesh3dx/InterpFromMeshToMesh3dx.cpp	(revision 14655)
+++ /issm/trunk-jpl/src/c/modules/InterpFromMeshToMesh3dx/InterpFromMeshToMesh3dx.cpp	(revision 14656)
@@ -7,8 +7,8 @@
 #include "../../include/include.h"
 
-int InterpFromMeshToMesh3dx( SeqVec<IssmPDouble>** pdata_prime,double* index_data, double* x_data, double* y_data, double* z_data, int nods_data,int nels_data, double* data, int data_length, double* x_prime, double* y_prime, double* z_prime, int nods_prime,double default_value) {
+int InterpFromMeshToMesh3dx( IssmSeqVec<IssmPDouble>** pdata_prime,double* index_data, double* x_data, double* y_data, double* z_data, int nods_data,int nels_data, double* data, int data_length, double* x_prime, double* y_prime, double* z_prime, int nods_prime,double default_value) {
 
 	/*Output*/
-	SeqVec<IssmPDouble>* data_prime=NULL;
+	IssmSeqVec<IssmPDouble>* data_prime=NULL;
 
 	/*Intermediary*/
@@ -54,5 +54,5 @@
 
 	/*Initialize output*/
-	data_prime=new SeqVec<IssmPDouble>(nods_prime);
+	data_prime=new IssmSeqVec<IssmPDouble>(nods_prime);
 	for (i=0;i<nods_prime;i++) data_prime->SetValue(i,default_value,INS_VAL);
 
Index: /issm/trunk-jpl/src/c/modules/InterpFromMeshToMesh3dx/InterpFromMeshToMesh3dx.h
===================================================================
--- /issm/trunk-jpl/src/c/modules/InterpFromMeshToMesh3dx/InterpFromMeshToMesh3dx.h	(revision 14655)
+++ /issm/trunk-jpl/src/c/modules/InterpFromMeshToMesh3dx/InterpFromMeshToMesh3dx.h	(revision 14656)
@@ -9,5 +9,5 @@
 #include "../../classes/objects/objects.h"
 
-int InterpFromMeshToMesh3dx(SeqVec<IssmPDouble>** pdata_prime,double* index_data, double* x_data, double* y_data, double* z_data, int nods_data,int nels_data, double* data, int data_length, double* x_prime, double* y_prime, double* z_prime, int nods_prime,double default_value);
+int InterpFromMeshToMesh3dx(IssmSeqVec<IssmPDouble>** pdata_prime,double* index_data, double* x_data, double* y_data, double* z_data, int nods_data,int nels_data, double* data, int data_length, double* x_prime, double* y_prime, double* z_prime, int nods_prime,double default_value);
 
 #endif /* _INTERPFROMMESHTOMESH3DX_H */
Index: /issm/trunk-jpl/src/c/modules/PointCloudFindNeighborsx/PointCloudFindNeighborsx.cpp
===================================================================
--- /issm/trunk-jpl/src/c/modules/PointCloudFindNeighborsx/PointCloudFindNeighborsx.cpp	(revision 14655)
+++ /issm/trunk-jpl/src/c/modules/PointCloudFindNeighborsx/PointCloudFindNeighborsx.cpp	(revision 14656)
@@ -4,9 +4,9 @@
 #include "./PointCloudFindNeighborsx.h"
 
-int PointCloudFindNeighborsx(SeqVec<IssmPDouble>** pflags,double* x, double* y, int nods, double mindistance,double multithread){
+int PointCloudFindNeighborsx(IssmSeqVec<IssmPDouble>** pflags,double* x, double* y, int nods, double mindistance,double multithread){
 
 	/*output: */
-	SeqVec<IssmPDouble>* flags=NULL;
-	flags=new SeqVec<IssmPDouble>(nods);
+	IssmSeqVec<IssmPDouble>* flags=NULL;
+	flags=new IssmSeqVec<IssmPDouble>(nods);
 
 	/*threading: */
Index: /issm/trunk-jpl/src/c/modules/PointCloudFindNeighborsx/PointCloudFindNeighborsx.h
===================================================================
--- /issm/trunk-jpl/src/c/modules/PointCloudFindNeighborsx/PointCloudFindNeighborsx.h	(revision 14655)
+++ /issm/trunk-jpl/src/c/modules/PointCloudFindNeighborsx/PointCloudFindNeighborsx.h	(revision 14656)
@@ -10,5 +10,5 @@
 
 /* local prototypes: */
-int PointCloudFindNeighborsx(SeqVec<IssmPDouble>** pflags,double* x, double* y, int nods, double mindistance,double multithread);
+int PointCloudFindNeighborsx(IssmSeqVec<IssmPDouble>** pflags,double* x, double* y, int nods, double mindistance,double multithread);
 
 /*threading: */
@@ -19,5 +19,5 @@
 	int nods;
 	double mindistance;
-	SeqVec<IssmPDouble>* flags;
+	IssmSeqVec<IssmPDouble>* flags;
 
 } PointCloudFindNeighborsThreadStruct;
Index: /issm/trunk-jpl/src/c/modules/PointCloudFindNeighborsx/PointCloudFindNeighborsxt.cpp
===================================================================
--- /issm/trunk-jpl/src/c/modules/PointCloudFindNeighborsx/PointCloudFindNeighborsxt.cpp	(revision 14655)
+++ /issm/trunk-jpl/src/c/modules/PointCloudFindNeighborsx/PointCloudFindNeighborsxt.cpp	(revision 14656)
@@ -17,5 +17,5 @@
 	int     nods;
 	double  mindistance;
-	SeqVec<IssmPDouble>*     flags;
+	IssmSeqVec<IssmPDouble>*     flags;
 
 	/*recover handle and gate: */
Index: /issm/trunk-jpl/src/c/modules/Solverx/Solverx.cpp
===================================================================
--- /issm/trunk-jpl/src/c/modules/Solverx/Solverx.cpp	(revision 14655)
+++ /issm/trunk-jpl/src/c/modules/Solverx/Solverx.cpp	(revision 14656)
@@ -37,6 +37,6 @@
 			break;}
 		#endif
-		case SeqMatType:{
-			SolverxSeq(&uf->svector,Kff->smatrix,pf->svector,parameters);
+		case IssmMatType:{
+			SolverxSeq(&uf->ivector,Kff->imatrix,pf->ivector,parameters);
 			break;}
 		default:
Index: /issm/trunk-jpl/src/c/modules/Solverx/Solverx.h
===================================================================
--- /issm/trunk-jpl/src/c/modules/Solverx/Solverx.h	(revision 14655)
+++ /issm/trunk-jpl/src/c/modules/Solverx/Solverx.h	(revision 14656)
@@ -13,4 +13,5 @@
 
 #include "../../classes/objects/objects.h"
+#include "../../toolkits/toolkits.h"
 
 /* local prototypes: */
@@ -23,5 +24,5 @@
 #endif
 
-void SolverxSeq(SeqVec<IssmDouble>** puf,SeqMat<IssmDouble>* Kff, SeqVec<IssmDouble>* pf,Parameters* parameters);
+void SolverxSeq(IssmVec<IssmDouble>** puf,IssmMat<IssmDouble>* Kff, IssmVec<IssmDouble>* pf,Parameters* parameters);
 void SolverxSeq(IssmPDouble **pX, IssmPDouble *A, IssmPDouble *B,int n);
 void SolverxSeq(IssmPDouble *X, IssmPDouble *A, IssmPDouble *B,int n);
Index: /issm/trunk-jpl/src/c/modules/Solverx/SolverxSeq.cpp
===================================================================
--- /issm/trunk-jpl/src/c/modules/Solverx/SolverxSeq.cpp	(revision 14655)
+++ /issm/trunk-jpl/src/c/modules/Solverx/SolverxSeq.cpp	(revision 14656)
@@ -20,10 +20,14 @@
 #endif
 
-void SolverxSeq(SeqVec<IssmDouble>** puf,SeqMat<IssmDouble>* Kff, SeqVec<IssmDouble>* pf, Parameters* parameters){/*{{{*/
+void SolverxSeq(IssmVec<IssmDouble>** pout,IssmMat<IssmDouble>* Kffin, IssmVec<IssmDouble>* pfin, Parameters* parameters){/*{{{*/
+
+	/*First off, we assume that the type of IssmVec is IssmSeqVec and the type of IssmMat is IssmDenseMat. So downcast: */
+	IssmSeqVec<IssmDouble>* pf=(IssmSeqVec<IssmDouble>*)pfin->vector;
+	IssmDenseMat<IssmDouble>* Kff=(IssmDenseMat<IssmDouble>*)Kffin->matrix;
 
 #ifdef _HAVE_GSL_
 	/*Intermediary: */
 	int M,N,N2;
-	SeqVec<IssmDouble> *uf = NULL;
+	IssmSeqVec<IssmDouble> *uf = NULL;
 
 	Kff->GetSize(&M,&N);
@@ -42,9 +46,11 @@
 #endif
 
-	uf=new SeqVec<IssmDouble>(x,N);
+	uf=new IssmSeqVec<IssmDouble>(x,N);
 	xDelete(x);
 
 	/*Assign output pointers:*/
-	*puf=uf;
+	IssmVec<IssmDouble>* out=new IssmVec<IssmDouble>();
+	out->matrix=(IssmAbsMat<IssmDouble>*)uf;
+	*pout=out;
 
 #else
Index: /issm/trunk-jpl/src/c/modules/StringToEnumx/StringToEnumx.cpp
===================================================================
--- /issm/trunk-jpl/src/c/modules/StringToEnumx/StringToEnumx.cpp	(revision 14655)
+++ /issm/trunk-jpl/src/c/modules/StringToEnumx/StringToEnumx.cpp	(revision 14656)
@@ -532,4 +532,8 @@
 	      else if (strcmp(name,"XY")==0) return XYEnum;
 	      else if (strcmp(name,"XYZP")==0) return XYZPEnum;
+	      else if (strcmp(name,"Dense")==0) return DenseEnum;
+	      else if (strcmp(name,"MpiDense")==0) return MpiDenseEnum;
+	      else if (strcmp(name,"Seq")==0) return SeqEnum;
+	      else if (strcmp(name,"Mpi")==0) return MpiEnum;
 	      else if (strcmp(name,"Option")==0) return OptionEnum;
 	      else if (strcmp(name,"GenericOption")==0) return GenericOptionEnum;
Index: /issm/trunk-jpl/src/c/modules/TriMeshx/TriMeshx.cpp
===================================================================
--- /issm/trunk-jpl/src/c/modules/TriMeshx/TriMeshx.cpp	(revision 14655)
+++ /issm/trunk-jpl/src/c/modules/TriMeshx/TriMeshx.cpp	(revision 14656)
@@ -22,5 +22,5 @@
 /*}}}*/
 
-void TriMeshx(SeqMat<int>** pindex,SeqVec<IssmPDouble>** px,SeqVec<IssmPDouble>** py,SeqMat<int>** psegments,SeqVec<int>** psegmentmarkerlist,DataSet* domain,DataSet* rifts,double area){
+void TriMeshx(IssmDenseMat<int>** pindex,IssmSeqVec<IssmPDouble>** px,IssmSeqVec<IssmPDouble>** py,IssmDenseMat<int>** psegments,IssmSeqVec<int>** psegmentmarkerlist,DataSet* domain,DataSet* rifts,double area){
 
 #if !defined(_HAVE_TRIANGLE_)
@@ -32,9 +32,9 @@
 	/*output: */
 	int         *index             = NULL;
-	SeqMat<int> *index_matrix      = NULL;
+	IssmDenseMat<int> *index_matrix      = NULL;
 	double      *x                 = NULL;
 	double      *y                 = NULL;
 	int         *segments          = NULL;
-	SeqMat<int> *segments_matrix   = NULL;
+	IssmDenseMat<int> *segments_matrix   = NULL;
 	int         *segmentmarkerlist = NULL;
 
@@ -197,13 +197,13 @@
 
 	/*Output : */
-	index_matrix=new SeqMat<int>(index,out.numberoftriangles,3,1);
+	index_matrix=new IssmDenseMat<int>(index,out.numberoftriangles,3,1);
 	*pindex=index_matrix;
 
-	segments_matrix=new SeqMat<int>(segments,out.numberofsegments,3,1);
+	segments_matrix=new IssmDenseMat<int>(segments,out.numberofsegments,3,1);
 	*psegments=segments_matrix;
 
-	*px=new SeqVec<IssmPDouble>(x,out.numberofpoints);
-	*py=new SeqVec<IssmPDouble>(y,out.numberofpoints);
-	*psegmentmarkerlist=new SeqVec<int>(segmentmarkerlist,out.numberofsegments);
+	*px=new IssmSeqVec<IssmPDouble>(x,out.numberofpoints);
+	*py=new IssmSeqVec<IssmPDouble>(y,out.numberofpoints);
+	*psegmentmarkerlist=new IssmSeqVec<int>(segmentmarkerlist,out.numberofsegments);
 #endif
 }
Index: /issm/trunk-jpl/src/c/modules/TriMeshx/TriMeshx.h
===================================================================
--- /issm/trunk-jpl/src/c/modules/TriMeshx/TriMeshx.h	(revision 14655)
+++ /issm/trunk-jpl/src/c/modules/TriMeshx/TriMeshx.h	(revision 14656)
@@ -11,5 +11,5 @@
 
 /* local prototypes: */
-void TriMeshx(SeqMat<int>** pindex,SeqVec<IssmPDouble>** px,SeqVec<IssmPDouble>** py,SeqMat<int>** psegments,SeqVec<int>** psegmentmarkerlist,DataSet* domain,DataSet* rifts,double area);
+void TriMeshx(IssmDenseMat<int>** pindex,IssmSeqVec<IssmPDouble>** px,IssmSeqVec<IssmPDouble>** py,IssmDenseMat<int>** psegments,IssmSeqVec<int>** psegmentmarkerlist,DataSet* domain,DataSet* rifts,double area);
 
 #endif  /* _TRIMESHX_H */
Index: /issm/trunk-jpl/src/c/shared/Exp/exp.h
===================================================================
--- /issm/trunk-jpl/src/c/shared/Exp/exp.h	(revision 14655)
+++ /issm/trunk-jpl/src/c/shared/Exp/exp.h	(revision 14656)
@@ -18,5 +18,5 @@
 /*IsInPoly {{{*/
 template <class doubletype>
-int IsInPoly(SeqVec<doubletype>* in,double* xc,double* yc,int numvertices,double* x,double* y,int i0,int i1, int edgevalue){
+int IsInPoly(IssmSeqVec<doubletype>* in,double* xc,double* yc,int numvertices,double* x,double* y,int i0,int i1, int edgevalue){
 
 	int i;
Index: /issm/trunk-jpl/src/c/toolkits/issm/IssmAbsMat.h
===================================================================
--- /issm/trunk-jpl/src/c/toolkits/issm/IssmAbsMat.h	(revision 14656)
+++ /issm/trunk-jpl/src/c/toolkits/issm/IssmAbsMat.h	(revision 14656)
@@ -0,0 +1,57 @@
+/*!\file:  IssmAbsMat.h
+ * \brief Main abstract class for the ISSM matrices.  This abstract class defines the pure virtual
+ * functions that each of its descendants need to implement, such as contructors, destructors, as well
+ * as matrix specific routines, such as SetValue, Assemple, MatMult, etc ...
+ * Descendants include among others:
+ * IssmDenseMat and IssmMpiDenseMat
+ *
+ */ 
+
+#ifndef _ISSM_ABS_MAT_H_
+#define _ISSM_ABS_MAT_H_
+
+/*Headers:*/
+/*{{{*/
+#ifdef HAVE_CONFIG_H
+	#include <config.h>
+#else
+#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
+#endif
+
+#include "../../shared/Exceptions/exceptions.h"
+#include "../../shared/MemOps/xMemCpy.h"
+#include "../../shared/Alloc/alloc.h"
+#include "../../include/macros.h"
+#include "./IssmAbsVec.h"
+
+/*}}}*/
+
+/*We need to template this class, in case we want to create Matrices that hold
+  IssmDouble* matrix or IssmPDouble* matrix. 
+  Such vectors are useful for use without or with the matlab or python
+  interface (which do not care for IssmDouble types, but only rely on
+  IssmPDouble types)
+*/
+
+template <class doubletype> 
+class IssmAbsMat{
+
+	public:
+	
+		/*IssmAbsMat constructors, destructors*/
+		virtual ~IssmAbsMat(){};
+
+		/*Functionality: */
+		virtual void Echo(void)=0;
+		virtual void Assemble(void)=0;
+		virtual doubletype Norm(NormMode mode)=0;
+		virtual void GetSize(int* pM,int* pN)=0;
+		virtual void GetLocalSize(int* pM,int* pN)=0;
+		virtual void MatMult(IssmAbsVec<doubletype>* X,IssmAbsVec<doubletype>* AX)=0;
+		virtual IssmAbsMat* Duplicate(void)=0;
+		virtual doubletype* ToSerial(void)=0;
+		virtual void SetValues(int m,int* idxm,int n,int* idxn,doubletype* values,InsMode mode)=0;
+		virtual void Convert(MatrixType type)=0;
+};
+
+#endif //#ifndef _ISSM_ABS_MAT_H_
Index: /issm/trunk-jpl/src/c/toolkits/issm/IssmAbsVec.h
===================================================================
--- /issm/trunk-jpl/src/c/toolkits/issm/IssmAbsVec.h	(revision 14656)
+++ /issm/trunk-jpl/src/c/toolkits/issm/IssmAbsVec.h	(revision 14656)
@@ -0,0 +1,65 @@
+/*!\file:  IssmAbsVec.h
+ * \brief Main abstract class for the ISSM vectors.  This abstract class defines the pure virtual
+ * functions that each of its descendants need to implement, such as contructors, destructors, as well
+ * as matrix specific routines, such as SetValue, Assemple, VecMult, etc ...
+ * Descendants include among others:
+ *	  IssmSeqVec and IssmMpiVec
+ *
+ */ 
+
+#ifndef _ISSM_ABS_VEC_H_
+#define _ISSM_ABS_VEC_H_
+
+/*Headers:*/
+/*{{{*/
+#ifdef HAVE_CONFIG_H
+	#include <config.h>
+#else
+#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
+#endif
+
+#include "../../shared/Exceptions/exceptions.h"
+#include "../../shared/MemOps/xMemCpy.h"
+#include "../../shared/Alloc/alloc.h"
+#include "../../include/macros.h"
+#include <math.h>
+
+/*}}}*/
+
+/*We need to template this class, in case we want to create Vectors that hold
+  IssmDouble* vector or IssmPDouble* vector. 
+  Such vectors are useful for use without or with the matlab or python
+  interface (which do not care for IssmDouble types, but only rely on
+  IssmPDouble types)
+*/
+template <class doubletype> 
+class IssmAbsVec{
+
+	public:
+		
+		/*IssmAbsVec constructors, destructors*/
+		~IssmAbsVec(){/*{{{*/
+		}
+		/*}}}*/
+
+		/*IssmAbsVec specific routines*/
+		virtual void Echo(void)=0;
+		virtual void Assemble(void)=0;
+		virtual void SetValues(int ssize, int* list, doubletype* values, InsMode mode)=0;
+		virtual void SetValue(int dof, doubletype value, InsMode mode)=0;
+		virtual void GetValue(doubletype* pvalue,int dof)=0;
+		virtual void GetSize(int* pM)=0;
+		virtual void GetLocalSize(int* pM)=0;
+		virtual IssmAbsVec* Duplicate(void)=0;
+		virtual void Set(doubletype value)=0;
+		virtual void AXPY(IssmAbsVec* X, doubletype a)=0;
+		virtual void AYPX(IssmAbsVec* X, doubletype a)=0;
+		virtual doubletype* ToMPISerial(void)=0;
+		virtual void Copy(IssmAbsVec* to)=0;
+		virtual doubletype Norm(NormMode mode)=0;
+		virtual void Scale(doubletype scale_factor)=0;
+		virtual doubletype Dot(IssmAbsVec* input)=0;
+		virtual void PointwiseDivide(IssmAbsVec* x,IssmAbsVec* y)=0;
+};
+
+#endif //#ifndef _ISSM_ABS_VEC_H_
Index: /issm/trunk-jpl/src/c/toolkits/issm/IssmDenseMat.h
===================================================================
--- /issm/trunk-jpl/src/c/toolkits/issm/IssmDenseMat.h	(revision 14656)
+++ /issm/trunk-jpl/src/c/toolkits/issm/IssmDenseMat.h	(revision 14656)
@@ -0,0 +1,255 @@
+/*!\file:  IssmDenseMat.h
+ * \brief implementation of an ISSM matrix which run serially (1 cpu only), which is made of a fully dense 
+ * matrix. Internally, this dense matrix is just a linear buffer of type doubletype. 
+ * This object needs to answer the API defined by the virtual functions in IssmAbsMat, 
+ * and the contructors required by IssmMat (see IssmMat.h)
+ */ 
+
+#ifndef _ISSM_DENSE_MAT_H_
+#define _ISSM_DENSE_MAT_H_
+
+/*Headers:*/
+/*{{{*/
+#ifdef HAVE_CONFIG_H
+	#include <config.h>
+#else
+#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
+#endif
+
+#include "../../shared/Exceptions/exceptions.h"
+#include "../../shared/MemOps/xMemCpy.h"
+#include "../../shared/Alloc/alloc.h"
+#include "../../include/macros.h"
+#include <math.h>
+
+/*}}}*/
+
+/*We need to template this class, in case we want to create Matrices that hold
+  IssmDouble* matrix or IssmPDouble* matrix. 
+  Such matrices would be useful for use without or with the matlab or python
+  interface (which do not care for IssmDouble types, but only rely on
+  IssmPDouble types)*/
+
+template <class doubletype> class IssmAbsVec;
+template <class doubletype> class IssmAbsMat;
+template <class doubletype> class IssmSeqVec;
+
+template <class doubletype> 
+class IssmDenseMat: public IssmAbsMat<doubletype>{
+
+	public:
+
+		int M,N; 
+		doubletype* matrix;  /*here, doubletype is either IssmDouble or IssmPDouble*/
+
+		/*IssmDenseMat constructors, destructors*/
+		/*FUNCTION IssmDenseMat(){{{*/
+		IssmDenseMat(){
+
+			this->M=0;
+			this->N=0;
+			this->matrix=NULL;
+		}
+		/*}}}*/
+		/*FUNCTION IssmDenseMat(int M,int N){{{*/
+		IssmDenseMat(int pM,int pN){
+
+			this->M=pM;
+			this->N=pN;
+			this->matrix=NULL;
+			if(M*N) this->matrix=xNewZeroInit<doubletype>(pM*pN);
+		}
+		/*}}}*/
+		/*FUNCTION IssmDenseMat(int M,int N, doubletype sparsity){{{*/
+		IssmDenseMat(int pM,int pN, doubletype sparsity){
+
+			this->M=pM;
+			this->N=pN;
+			this->matrix=NULL;
+			if(M*N) this->matrix=xNewZeroInit<doubletype>(pM*pN);
+		}
+		/*}}}*/
+		/*FUNCTION IssmDenseMat(int m,int n,int M,int N,int* d_nnz,int* o_nnz){{{*/
+		IssmDenseMat(int m,int n,int pM,int pN,int* d_nnz,int* o_nnz){
+
+			this->M=pM;
+			this->N=pN;
+			this->matrix=NULL;
+			if(pM*pN) this->matrix=xNewZeroInit<doubletype>(pM*pN);
+		}
+		/*}}}*/
+		/*FUNCTION IssmDenseMat(doubletype* serial_mat,int M,int N,doubletype sparsity){{{*/
+		IssmDenseMat(doubletype* serial_mat,int pM,int pN,doubletype sparsity){
+
+			this->M=pM;
+			this->N=pN;
+			this->matrix=NULL;
+			if(M*N){
+				this->matrix=xNewZeroInit<doubletype>(pM*pN);
+				xMemCpy<doubletype>(this->matrix,serial_mat,pM*pN);
+			}
+
+		}
+		/*}}}*/
+		/*FUNCTION IssmDenseMat(int M,int N, int connectivity, int numberofdofspernode){{{*/
+		IssmDenseMat(int pM,int pN, int connectivity,int numberofdofspernode){
+
+			this->M=pM;
+			this->N=pN;
+			this->matrix=NULL;
+			if(M*N) this->matrix=xNewZeroInit<doubletype>(pM*pN);
+		}
+		/*}}}*/
+		/*FUNCTION ~IssmDenseMat(){{{*/
+		~IssmDenseMat(){
+
+			xDelete<doubletype>(this->matrix);
+			M=0;
+			N=0;
+		}
+		/*}}}*/
+
+		/*IssmDenseMat specific routines */
+		/*FUNCTION Echo{{{*/
+		void Echo(void){
+
+			int i,j;
+			_printLine_("IssmDenseMat size " << this->M << "-" << this->N);
+			for(i=0;i<M;i++){
+				for(j=0;j<N;j++){
+					_printString_(this->matrix[N*i+j] << " ");
+				}
+				_printLine_("");
+			}
+		}
+		/*}}}*/
+		/*FUNCTION Assemble{{{*/
+		void Assemble(void){
+
+			/*do nothing*/
+
+		}
+		/*}}}*/
+		/*FUNCTION Norm{{{*/
+		doubletype Norm(NormMode mode){
+
+			doubletype norm;
+			doubletype absolute;
+			int i,j;
+
+			switch(mode){
+				case NORM_INF:
+					norm=0;
+					for(i=0;i<this->M;i++){
+						absolute=0;
+						for(j=0;j<this->N;j++){
+							absolute+=fabs(this->matrix[N*i+j]);
+						}
+						norm=max(norm,absolute);
+					}
+					return norm;
+					break; 
+				default:
+					_error_("unknown norm !");
+					break;
+			}
+		}
+		/*}}}*/
+		/*FUNCTION GetSize{{{*/
+		void GetSize(int* pM,int* pN){
+
+			*pM=this->M;
+			*pN=this->N;
+
+		}
+		/*}}}*/
+		/*FUNCTION GetLocalSize{{{*/
+		void GetLocalSize(int* pM,int* pN){
+
+			*pM=this->M;
+			*pN=this->N;
+
+		}
+		/*}}}*/
+		/*FUNCTION MatMult{{{*/
+		void MatMult(IssmAbsVec<doubletype>* Xin,IssmAbsVec<doubletype>* AXin){
+
+			/*We assume that the vectors coming in are of compatible type: */
+			int i,j;
+			int XM,AXM;
+			doubletype dummy;
+			IssmSeqVec<doubletype>* X=NULL;
+			IssmSeqVec<doubletype>* AX=NULL;
+
+			/*downcast X and AX: */
+			X=(IssmSeqVec<doubletype>*)Xin;
+			AX=(IssmSeqVec<doubletype>*)AXin;
+
+			/*Some checks first: */
+			X->GetSize(&XM);
+			AX->GetSize(&AXM);
+
+			if(M!=AXM)_error_("A and AX should have the same number of rows!");
+			if(N!=XM)_error_("A and X should have the same number of columns!");
+
+			for(i=0;i<M;i++){
+				dummy=0;
+				for(j=0;j<N;j++){
+					dummy+= this->matrix[N*i+j]*X->vector[j];
+				}
+				AX->vector[i]=dummy;
+			}
+
+		}
+		/*}}}*/
+		/*FUNCTION Duplicate{{{*/
+		IssmDenseMat* Duplicate(void){
+
+			doubletype dummy=0;
+
+			return new IssmDenseMat(this->matrix,this->M,this->N,dummy);
+
+		}
+		/*}}}*/
+		/*FUNCTION ToSerial{{{*/
+		doubletype* ToSerial(void){
+
+			doubletype* buffer=NULL;
+
+			if(this->M*this->N){
+				buffer=xNew<doubletype>(this->M*this->N);
+				xMemCpy<doubletype>(buffer,this->matrix,this->M*this->N);
+			}
+			return buffer;
+
+		}
+		/*}}}*/
+		/*FUNCTION SetValues{{{*/
+		void SetValues(int m,int* idxm,int n,int* idxn,doubletype* values,InsMode mode){
+
+			int i,j;
+			switch(mode){
+				case ADD_VAL:
+					for(i=0;i<m;i++) for(j=0;j<n;j++) this->matrix[N*idxm[i]+idxn[j]]+=values[n*i+j];
+					break;
+				case INS_VAL:
+					for(i=0;i<m;i++) for(j=0;j<n;j++) this->matrix[N*idxm[i]+idxn[j]]=values[n*i+j];
+					break;
+				default:
+					_error_("unknown insert mode!");
+					break;
+			}
+
+		}
+		/*}}}*/
+		/*FUNCTION Convert{{{*/
+		void Convert(MatrixType type){
+
+			/*do nothing*/
+
+		}
+		/*}}}*/		
+
+};
+
+#endif //#ifndef _ISSM_DENSE_MAT_H_
Index: /issm/trunk-jpl/src/c/toolkits/issm/IssmMat.h
===================================================================
--- /issm/trunk-jpl/src/c/toolkits/issm/IssmMat.h	(revision 14656)
+++ /issm/trunk-jpl/src/c/toolkits/issm/IssmMat.h	(revision 14656)
@@ -0,0 +1,182 @@
+/*!\file:  IssmMat.h
+ * \brief Main Matrix class for the Issm toolkit. 
+ */ 
+
+#ifndef _ISSM_MAT_H_
+#define _ISSM_MAT_H_
+
+/*Headers:*/
+/*{{{*/
+#ifdef HAVE_CONFIG_H
+	#include <config.h>
+#else
+#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
+#endif
+
+#include "../../shared/Exceptions/exceptions.h"
+#include "../../shared/MemOps/xMemCpy.h"
+#include "../../shared/Alloc/alloc.h"
+#include "../../include/macros.h"
+#include "../../classes/ToolkitOptions.h"
+#include "../../classes/IssmComm.h"
+#include "../../EnumDefinitions/EnumDefinitions.h"
+#include "./IssmToolkitUtils.h"
+
+/*}}}*/
+
+/*We need to template this class, in case we want to create Matrices that hold
+  IssmDouble* matrix or IssmPDouble* matrix. 
+  Such matrices are useful for use without or with the matlab or python
+  interface (which do not care for IssmDouble types, but only rely on
+  IssmPDouble types)
+*/
+template <class doubletype> class IssmVec;
+template <class doubletype> class IssmDenseMat;
+template <class doubletype> class IssmMpiDenseMat;
+
+template <class doubletype> 
+class IssmMat{
+
+
+	public:
+	
+		IssmAbsMat<doubletype>* matrix; /*abstract matrix, which implements object orientation*/
+
+		/*IssmMat constructors, destructors*/
+		IssmMat(){ /*{{{*/
+
+			switch(IssmMatTypeFromToolkitOptions()){
+
+				case DenseEnum: 
+					this->matrix=new IssmDenseMat<doubletype>();
+					break;
+				case MpiDenseEnum:
+					this->matrix=new IssmMpiDenseMat<doubletype>();
+					break;
+				default:
+					_error_("matrix type not supported yet!");
+			}
+		}
+		/*}}}*/
+		IssmMat(int M,int N){ /*{{{*/
+		
+			switch(IssmMatTypeFromToolkitOptions()){
+
+				case DenseEnum: 
+					this->matrix=new IssmDenseMat<doubletype>(M,N);
+					break;
+				case MpiDenseEnum:
+					this->matrix=new IssmMpiDenseMat<doubletype>(M,N);
+					break;
+				default:
+					_error_("matrix type not supported yet!");
+			}
+		}
+		/*}}}*/
+		IssmMat(int M,int N, doubletype sparsity){ /*{{{*/
+
+			switch(IssmMatTypeFromToolkitOptions()){
+
+				case DenseEnum: 
+					this->matrix=new IssmDenseMat<doubletype>(M,N,sparsity);
+					break;
+				case MpiDenseEnum:
+					this->matrix=new IssmMpiDenseMat<doubletype>(M,N,sparsity);
+					break;
+				default:
+					_error_("matrix type not supported yet!");
+			}
+		}
+		/*}}}*/
+		IssmMat(int m,int n,int M,int N,int* d_nnz,int* o_nnz){ /*{{{*/
+
+			switch(IssmMatTypeFromToolkitOptions()){
+
+				case DenseEnum: 
+					this->matrix=new IssmDenseMat<doubletype>(m,n,M,N,d_nnz,o_nnz);
+					break;
+				case MpiDenseEnum:
+					this->matrix=new IssmMpiDenseMat<doubletype>(m,n,M,N,d_nnz,o_nnz);
+					break;
+				default:
+					_error_("matrix type not supported yet!");
+			}
+		}
+		/*}}}*/
+		IssmMat(doubletype* serial_mat,int M,int N,doubletype sparsity){ /*{{{*/
+
+			switch(IssmMatTypeFromToolkitOptions()){
+
+				case DenseEnum: 
+					this->matrix=new IssmDenseMat<doubletype>(serial_mat,M,N,sparsity);
+					break;
+				case MpiDenseEnum:
+					this->matrix=new IssmMpiDenseMat<doubletype>(serial_mat,M,N,sparsity);
+					break;
+				default:
+					_error_("matrix type not supported yet!");
+			}
+
+		}
+		/*}}}*/
+		IssmMat(int M,int N, int connectivity, int numberofdofspernode){ /*{{{*/
+			
+			switch(IssmMatTypeFromToolkitOptions()){
+
+				case DenseEnum: 
+					this->matrix=new IssmDenseMat<doubletype>(M,N,connectivity,numberofdofspernode);
+					break;
+				case MpiDenseEnum:
+					this->matrix=new IssmMpiDenseMat<doubletype>(M,N,connectivity,numberofdofspernode);
+					break;
+				default:
+					_error_("matrix type not supported yet!");
+			}
+		}
+		/*}}}*/
+		~IssmMat(){ /*{{{*/
+		} /*}}}*/
+
+		/*Functionality: */
+		void Echo(void){  /*{{{*/
+			matrix->Echo();
+		} /*}}}*/
+		void Assemble(void){  /*{{{*/
+			matrix->Assemble();
+		} /*}}}*/
+		doubletype Norm(NormMode mode){ /*{{{*/
+			return matrix->Norm(mode);
+		}
+		/*}}}*/
+		void GetSize(int* pM,int* pN){ /*{{{*/
+			matrix->GetSize(pM,pN);
+		} /*}}}*/
+		void GetLocalSize(int* pM,int* pN){ /*{{{*/
+			matrix->GetLocalSize(pM,pN);
+		} /*}}}*/
+		void MatMult(IssmVec<doubletype>* X,IssmVec<doubletype>* AX){ /*{{{*/
+			matrix->MatMult(X->vector,AX->vector);
+		} /*}}}*/
+		IssmMat* Duplicate(void){ /*{{{*/
+
+			IssmMat* issmmatrix=NULL;
+
+			issmmatrix=new IssmMat<doubletype>();
+			issmmatrix->matrix=this->matrix->Duplicate();
+
+			return issmmatrix;
+		} /*}}}*/
+		doubletype* ToSerial(void){/*{{{*/
+			return matrix->ToSerial();
+		}/*}}}*/
+		void SetValues(int m,int* idxm,int n,int* idxn,doubletype* values,InsMode mode){/*{{{*/
+			matrix->SetValues(m,idxm,n,idxn,values,mode);
+		}/*}}}*/
+		void Convert(MatrixType type){/*{{{*/
+			matrix->convert(type);
+		}/*}}}*/
+
+};
+
+
+#endif //#ifndef _ISSMMAT_H_
Index: /issm/trunk-jpl/src/c/toolkits/issm/IssmMpiDenseMat.h
===================================================================
--- /issm/trunk-jpl/src/c/toolkits/issm/IssmMpiDenseMat.h	(revision 14656)
+++ /issm/trunk-jpl/src/c/toolkits/issm/IssmMpiDenseMat.h	(revision 14656)
@@ -0,0 +1,134 @@
+/*!\file:  IssmMpiDenseMat.h
+ * \brief implementation of parallel dense ISSM matrix. Internally, the parallel dense matrix is 
+ * split in rows across each cpu. Each matrix (representing a subset of rows) on each cpu is fully 
+ * dense, and is represented by a linear buffer of type doubletype. 
+ * This object needs to answer the API defined by the virtual functions in IssmAbsMat, 
+ * and the contructors required by IssmMat (see IssmMat.h)
+ */ 
+
+#ifndef _ISSM_MPI_DENSE_MAT_H_
+#define _ISSM_MPI_DENSE_MAT_H_
+
+/*Headers:*/
+/*{{{*/
+#ifdef HAVE_CONFIG_H
+	#include <config.h>
+#else
+#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
+#endif
+
+#include "../../shared/Exceptions/exceptions.h"
+#include "../../shared/MemOps/xMemCpy.h"
+#include "../../shared/Alloc/alloc.h"
+#include "../../include/macros.h"
+#include <math.h>
+
+/*}}}*/
+
+/*We need to template this class, in case we want to create Matrices that hold
+  IssmDouble* matrix or IssmPDouble* matrix. 
+  Such matrices would be useful for use without or with the matlab or python
+  interface (which do not care for IssmDouble types, but only rely on
+  IssmPDouble types)*/
+template <class doubletype> class IssmAbsMat;
+
+template <class doubletype> 
+class IssmMpiDenseMat:public IssmAbsMat<doubletype>{
+
+	public:
+
+		int M,N; 
+		doubletype* matrix;  /*here, doubletype is either IssmDouble or IssmPDouble*/
+
+		/*IssmMpiDenseMat constructors, destructors*/
+		/*FUNCTION IssmMpiDenseMat(){{{*/
+		IssmMpiDenseMat(){
+			_error_("not supported yet!");
+		}
+		/*}}}*/
+		/*FUNCTION IssmMpiDenseMat(int M,int N){{{*/
+		IssmMpiDenseMat(int pM,int pN){
+			_error_("not supported yet!");
+		}
+		/*}}}*/
+		/*FUNCTION IssmMpiDenseMat(int M,int N, doubletype sparsity){{{*/
+		IssmMpiDenseMat(int pM,int pN, doubletype sparsity){
+			_error_("not supported yet!");
+		}
+		/*}}}*/
+		/*FUNCTION IssmMpiDenseMat(int m,int n,int M,int N,int* d_nnz,int* o_nnz){{{*/
+		IssmMpiDenseMat(int m,int n,int pM,int pN,int* d_nnz,int* o_nnz){
+			_error_("not supported yet!");
+		}
+		/*}}}*/
+		/*FUNCTION IssmMpiDenseMat(doubletype* serial_mat,int M,int N,doubletype sparsity){{{*/
+		IssmMpiDenseMat(doubletype* serial_mat,int pM,int pN,doubletype sparsity){
+			_error_("not supported yet!");
+		}
+		/*}}}*/
+		/*FUNCTION IssmMpiDenseMat(int M,int N, int connectivity, int numberofdofspernode){{{*/
+		IssmMpiDenseMat(int pM,int pN, int connectivity,int numberofdofspernode){
+			_error_("not supported yet!");
+		}
+		/*}}}*/
+		/*FUNCTION ~IssmMpiDenseMat(){{{*/
+		~IssmMpiDenseMat(){
+			_error_("not supported yet!");
+		}
+		/*}}}*/
+
+		/*IssmMpiDenseMat specific routines */
+		/*FUNCTION Echo{{{*/
+		void Echo(void){
+			_error_("not supported yet!");
+		}
+		/*}}}*/
+		/*FUNCTION Assemble{{{*/
+		void Assemble(void){
+			_error_("not supported yet!");
+		}
+		/*}}}*/
+		/*FUNCTION Norm{{{*/
+		doubletype Norm(NormMode mode){
+			_error_("not supported yet!");
+		}
+		/*}}}*/
+		/*FUNCTION GetSize{{{*/
+		void GetSize(int* pM,int* pN){
+			_error_("not supported yet!");
+		}
+		/*}}}*/
+		/*FUNCTION GetLocalSize{{{*/
+		void GetLocalSize(int* pM,int* pN){
+			_error_("not supported yet!");
+		}
+		/*}}}*/
+		/*FUNCTION MatMult{{{*/
+		void MatMult(IssmAbsVec<doubletype>* Xin,IssmAbsVec<doubletype>* AXin){
+			_error_("not supported yet!");
+		}
+		/*}}}*/
+		/*FUNCTION Duplicate{{{*/
+		IssmMpiDenseMat* Duplicate(void){
+			_error_("not supported yet!");
+		}
+		/*}}}*/
+		/*FUNCTION ToSerial{{{*/
+		doubletype* ToSerial(void){
+			_error_("not supported yet!");
+		}
+		/*}}}*/
+		/*FUNCTION SetValues{{{*/
+		void SetValues(int m,int* idxm,int n,int* idxn,doubletype* values,InsMode mode){
+			_error_("not supported yet!");
+		}
+		/*}}}*/
+		/*FUNCTION Convert{{{*/
+		void Convert(MatrixType type){
+			_error_("not supported yet!");
+		}
+		/*}}}*/		
+
+};
+
+#endif //#ifndef _ISSM_MPI_DENSE_MAT_H_
Index: /issm/trunk-jpl/src/c/toolkits/issm/IssmMpiVec.h
===================================================================
--- /issm/trunk-jpl/src/c/toolkits/issm/IssmMpiVec.h	(revision 14656)
+++ /issm/trunk-jpl/src/c/toolkits/issm/IssmMpiVec.h	(revision 14656)
@@ -0,0 +1,303 @@
+/*!\file:  IssmMpiVec.h
+ * \brief implementation of parallel dense ISSM vector. Internally, the parallel dense vector is 
+ * split in rows across each cpu. Each vector (representing a subset of rows) on each cpu is fully 
+ * dense, and is represented by a linear buffer of type doubletype. 
+ * This object needs to answer the API defined by the virtual functions in IssmAbsVec, 
+ * and the contructors required by IssmVec (see IssmVec.h)
+ */ 
+
+#ifndef _ISSM_MPI_VEC_H_
+#define _ISSM_MPI_VEC_H_
+
+/*Headers:*/
+/*{{{*/
+#ifdef HAVE_CONFIG_H
+	#include <config.h>
+#else
+#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
+#endif
+
+#include "../../shared/Exceptions/exceptions.h"
+#include "../../shared/MemOps/xMemCpy.h"
+#include "../../shared/Alloc/alloc.h"
+#include "../../include/macros.h"
+#include <math.h>
+
+/*}}}*/
+
+/*We need to template this class, in case we want to create vectors that hold IssmDouble* vector or IssmPDouble* vector. 
+  Such vectors would be useful for use without or with the matlab or python interface (which do not care for IssmDouble types, 
+  but only rely on IssmPDouble types)*/
+template <class doubletype> class IssmAbsVec;
+
+template <class doubletype> 
+class IssmMpiVec:public IssmAbsVec<doubletype>{
+
+	public:
+
+		doubletype* vector;
+		int M;
+
+		/*IssmMpiVec constructors, destructors*/
+		/*FUNCTION IssmMpiVec(){{{*/
+		IssmMpiVec(){
+
+			this->M=0;
+			this->vector=NULL;
+		}
+		/*}}}*/
+		/*FUNCTION IssmMpiVec(int M){{{*/
+		IssmMpiVec(int pM){
+
+			this->M=pM;
+			this->vector=NULL;
+			if(this->M) this->vector=xNewZeroInit<doubletype>(pM);
+		}
+		/*}}}*/
+		/*FUNCTION IssmMpiVec(int m,int M){{{*/
+		IssmMpiVec(int pm,int pM){
+
+			this->M=pM;
+			this->vector=NULL;
+			if(this->M) this->vector=xNewZeroInit<doubletype>(pM);
+		}
+		/*}}}*/
+		/*FUNCTION IssmMpiVec(int M,bool fromlocalsize){{{*/
+		IssmMpiVec(int pM,bool fromlocalsize){
+
+			this->M=pM;
+			this->vector=NULL;
+			if(this->M) this->vector=xNewZeroInit<doubletype>(pM);
+		}
+		/*}}}*/
+		/*FUNCTION IssmMpiVec(doubletype* serial_vec,int M){{{*/
+		IssmMpiVec(doubletype* buffer,int pM){
+
+			this->M=pM;
+			this->vector=NULL;
+			if(this->M){
+				this->vector=xNew<doubletype>(pM);
+				xMemCpy<doubletype>(this->vector,buffer,pM);
+			}
+		}
+		/*}}}*/
+		/*FUNCTION ~IssmMpiVec(){{{*/
+		~IssmMpiVec(){
+			xDelete<doubletype>(this->vector);
+			M=0;
+		}
+		/*}}}*/
+
+		/*IssmMpiVec specific routines*/
+		/*FUNCTION Echo{{{*/
+		void Echo(void){
+
+			int i;
+			_printLine_("IssmMpiVec size " << this->M);
+			for(i=0;i<M;i++){
+				_printString_(vector[i] << "\n ");
+			}
+		}
+		/*}}}*/
+		/*FUNCTION Assemble{{{*/
+		void Assemble(void){
+
+			/*do nothing*/
+
+		}
+		/*}}}*/
+		/*FUNCTION SetValues{{{*/
+		void SetValues(int ssize, int* list, doubletype* values, InsMode mode){
+
+			int i;
+			switch(mode){
+				case ADD_VAL:
+					for(i=0;i<ssize;i++) this->vector[list[i]]+=values[i];
+					break;
+				case INS_VAL:
+					for(i=0;i<ssize;i++) this->vector[list[i]]=values[i];
+					break;
+				default:
+					_error_("unknown insert mode!");
+					break;
+			}
+
+		}
+		/*}}}*/
+		/*FUNCTION SetValue{{{*/
+		void SetValue(int dof, doubletype value, InsMode mode){
+
+			switch(mode){
+				case ADD_VAL:
+					this->vector[dof]+=value;
+					break;
+				case INS_VAL:
+					this->vector[dof]=value;
+					break;
+				default:
+					_error_("unknown insert mode!");
+					break;
+			}
+		}
+		/*}}}*/
+		/*FUNCTION GetValue{{{*/
+		void GetValue(doubletype* pvalue,int dof){
+
+			*pvalue=this->vector[dof];
+
+		}
+		/*}}}*/
+		/*FUNCTION GetSize{{{*/
+		void GetSize(int* pM){
+
+			*pM=this->M;
+
+		}
+		/*}}}*/
+		/*FUNCTION GetLocalSize{{{*/
+		void GetLocalSize(int* pM){
+
+			*pM=this->M;
+
+		}
+		/*}}}*/
+		/*FUNCTION Duplicate{{{*/
+		IssmMpiVec* Duplicate(void){
+
+			return new IssmMpiVec(this->vector,this->M);
+
+		}
+		/*}}}*/
+		/*FUNCTION Set{{{*/
+		void Set(doubletype value){
+
+			int i;
+			for(i=0;i<this->M;i++)this->vector[i]=value;
+
+		}
+		/*}}}*/
+		/*FUNCTION AXPY{{{*/
+		void AXPY(IssmAbsVec<doubletype>* Xin, doubletype a){
+
+			int i;
+			
+			/*Assume X is of the correct type, and downcast: */
+			IssmMpiVec* X=NULL;
+
+			X=(IssmMpiVec<doubletype>*)Xin;
+
+
+			/*y=a*x+y where this->vector is y*/
+			for(i=0;i<this->M;i++)this->vector[i]=a*X->vector[i]+this->vector[i];
+
+		}
+		/*}}}*/
+		/*FUNCTION AYPX{{{*/
+		void AYPX(IssmAbsVec<doubletype>* Xin, doubletype a){
+
+			int i;
+
+			/*Assume X is of the correct type, and downcast: */
+			IssmMpiVec* X=NULL;
+
+			X=(IssmMpiVec<doubletype>*)Xin;
+
+			/*y=x+a*y where this->vector is y*/
+			for(i=0;i<this->M;i++)this->vector[i]=X->vector[i]+a*this->vector[i];
+
+		}
+		/*}}}*/
+		/*FUNCTION ToMPISerial{{{*/
+		doubletype* ToMPISerial(void){
+
+			doubletype* buffer=NULL;
+
+			if(this->M){
+				buffer=xNew<doubletype>(this->M);
+				xMemCpy<doubletype>(buffer,this->vector,this->M);
+			}
+			return buffer;
+
+		}
+		/*}}}*/
+		/*FUNCTION Copy{{{*/
+		void Copy(IssmAbsVec<doubletype>* toin){
+
+			int i;
+
+			/*Assume toin is of the correct type, and downcast: */
+			IssmMpiVec* to=NULL;
+
+			to=(IssmMpiVec<doubletype>*)toin;
+
+			to->M=this->M;
+			for(i=0;i<this->M;i++)to->vector[i]=this->vector[i];
+
+		}
+		/*}}}*/
+		/*FUNCTION Norm{{{*/
+		doubletype Norm(NormMode mode){
+
+			doubletype norm;
+			int i;
+
+			switch(mode){
+				case NORM_INF:
+					norm=0; for(i=0;i<this->M;i++)norm=max(norm,fabs(this->vector[i]));
+					return norm;
+					break;
+				case NORM_TWO:
+					norm=0; 
+					for(i=0;i<this->M;i++)norm+=pow(this->vector[i],2);
+					return sqrt(norm);
+					break;
+				default:
+					_error_("unknown norm !");
+					break;
+			}
+		}
+		/*}}}*/
+		/*FUNCTION Scale{{{*/
+		void Scale(doubletype scale_factor){
+
+			int i;
+			for(i=0;i<this->M;i++)this->vector[i]=scale_factor*this->vector[i];
+
+		}
+		/*}}}*/
+		/*FU		/*FUNCTION Dot{{{*/
+		doubletype Dot(IssmAbsVec<doubletype>* inputin){
+
+			int i;
+
+			/*Assume inputin is of the correct type, and downcast: */
+			IssmMpiVec* input=NULL;
+
+			input=(IssmMpiVec<doubletype>*)inputin;
+
+
+			doubletype dot=0;
+			for(i=0;i<this->M;i++)dot+=this->vector[i]*input->vector[i];
+			return dot;
+
+		}
+		/*}}}*/
+		/*FUNCTION PointwiseDivide{{{*/
+		void PointwiseDivide(IssmAbsVec<doubletype>* xin,IssmAbsVec<doubletype>* yin){
+
+			int i;
+			
+			/*Assume xin and yin are of the correct type, and downcast: */
+			IssmMpiVec* x=NULL;
+			IssmMpiVec* y=NULL;
+
+			x=(IssmMpiVec<doubletype>*)xin;
+			y=(IssmMpiVec<doubletype>*)yin;
+
+
+			/*pointwise w=x/y where this->vector is w: */
+			for(i=0;i<this->M;i++)this->vector[i]=x->vector[i]/y->vector[i];
+		}
+		/*}}}*/
+};
+#endif //#ifndef _ISSM_MPI_VEC_H_
Index: /issm/trunk-jpl/src/c/toolkits/issm/IssmSeqVec.h
===================================================================
--- /issm/trunk-jpl/src/c/toolkits/issm/IssmSeqVec.h	(revision 14656)
+++ /issm/trunk-jpl/src/c/toolkits/issm/IssmSeqVec.h	(revision 14656)
@@ -0,0 +1,305 @@
+/*!\file:  IssmSeqVec.h
+ * \brief implementation of an ISSM vector which run serially (1 cpu only), which is made of a fully dense 
+ * vector. Internally, this dense vector is just a linear buffer of type doubletype. 
+ * This object needs to answer the API defined by the virtual functions in IssmAbsVec, 
+ * and the contructors required by IssmVec (see IssmVec.h)
+ */ 
+
+
+#ifndef _ISSM_SEQ_VEC_H_
+#define _ISSM_SEQ_VEC_H_
+
+/*Headers:*/
+/*{{{*/
+#ifdef HAVE_CONFIG_H
+	#include <config.h>
+#else
+#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
+#endif
+
+#include "../../shared/Exceptions/exceptions.h"
+#include "../../shared/MemOps/xMemCpy.h"
+#include "../../shared/Alloc/alloc.h"
+#include "../../include/macros.h"
+#include <math.h>
+
+/*}}}*/
+
+/*We need to template this class, in case we want to create vectors that hold IssmDouble* vector or IssmPDouble* vector. 
+  Such vectors would be useful for use without or with the matlab or python interface (which do not care for IssmDouble types, 
+  but only rely on IssmPDouble types)*/
+
+template <class doubletype> class IssmAbsVec;
+
+template <class doubletype> 
+class IssmSeqVec: public IssmAbsVec<doubletype>{
+
+	public:
+
+		doubletype* vector;
+		int M;
+
+		/*IssmSeqVec constructors, destructors*/
+		/*FUNCTION IssmSeqVec(){{{*/
+		IssmSeqVec(){
+
+			this->M=0;
+			this->vector=NULL;
+		}
+		/*}}}*/
+		/*FUNCTION IssmSeqVec(int M){{{*/
+		IssmSeqVec(int pM){
+
+			this->M=pM;
+			this->vector=NULL;
+			if(this->M) this->vector=xNewZeroInit<doubletype>(pM);
+		}
+		/*}}}*/
+		/*FUNCTION IssmSeqVec(int m,int M){{{*/
+		IssmSeqVec(int pm,int pM){
+
+			this->M=pM;
+			this->vector=NULL;
+			if(this->M) this->vector=xNewZeroInit<doubletype>(pM);
+		}
+		/*}}}*/
+		/*FUNCTION IssmSeqVec(int M,bool fromlocalsize){{{*/
+		IssmSeqVec(int pM,bool fromlocalsize){
+
+			this->M=pM;
+			this->vector=NULL;
+			if(this->M) this->vector=xNewZeroInit<doubletype>(pM);
+		}
+		/*}}}*/
+		/*FUNCTION IssmSeqVec(doubletype* serial_vec,int M){{{*/
+		IssmSeqVec(doubletype* buffer,int pM){
+
+			this->M=pM;
+			this->vector=NULL;
+			if(this->M){
+				this->vector=xNew<doubletype>(pM);
+				xMemCpy<doubletype>(this->vector,buffer,pM);
+			}
+		}
+		/*}}}*/
+		/*FUNCTION ~IssmSeqVec(){{{*/
+		~IssmSeqVec(){
+			xDelete<doubletype>(this->vector);
+			M=0;
+		}
+		/*}}}*/
+
+		/*IssmSeqVec specific routines*/
+		/*FUNCTION Echo{{{*/
+		void Echo(void){
+
+			int i;
+			_printLine_("IssmSeqVec size " << this->M);
+			for(i=0;i<M;i++){
+				_printString_(vector[i] << "\n ");
+			}
+		}
+		/*}}}*/
+		/*FUNCTION Assemble{{{*/
+		void Assemble(void){
+
+			/*do nothing*/
+
+		}
+		/*}}}*/
+		/*FUNCTION SetValues{{{*/
+		void SetValues(int ssize, int* list, doubletype* values, InsMode mode){
+
+			int i;
+			switch(mode){
+				case ADD_VAL:
+					for(i=0;i<ssize;i++) this->vector[list[i]]+=values[i];
+					break;
+				case INS_VAL:
+					for(i=0;i<ssize;i++) this->vector[list[i]]=values[i];
+					break;
+				default:
+					_error_("unknown insert mode!");
+					break;
+			}
+
+		}
+		/*}}}*/
+		/*FUNCTION SetValue{{{*/
+		void SetValue(int dof, doubletype value, InsMode mode){
+
+			switch(mode){
+				case ADD_VAL:
+					this->vector[dof]+=value;
+					break;
+				case INS_VAL:
+					this->vector[dof]=value;
+					break;
+				default:
+					_error_("unknown insert mode!");
+					break;
+			}
+		}
+		/*}}}*/
+		/*FUNCTION GetValue{{{*/
+		void GetValue(doubletype* pvalue,int dof){
+
+			*pvalue=this->vector[dof];
+
+		}
+		/*}}}*/
+		/*FUNCTION GetSize{{{*/
+		void GetSize(int* pM){
+
+			*pM=this->M;
+
+		}
+		/*}}}*/
+		/*FUNCTION GetLocalSize{{{*/
+		void GetLocalSize(int* pM){
+
+			*pM=this->M;
+
+		}
+		/*}}}*/
+		/*FUNCTION Duplicate{{{*/
+		IssmSeqVec* Duplicate(void){
+
+			return new IssmSeqVec(this->vector,this->M);
+
+		}
+		/*}}}*/
+		/*FUNCTION Set{{{*/
+		void Set(doubletype value){
+
+			int i;
+			for(i=0;i<this->M;i++)this->vector[i]=value;
+
+		}
+		/*}}}*/
+		/*FUNCTION AXPY{{{*/
+		void AXPY(IssmAbsVec<doubletype>* Xin, doubletype a){
+
+			int i;
+			
+			/*Assume X is of the correct type, and downcast: */
+			IssmSeqVec* X=NULL;
+
+			X=(IssmSeqVec<doubletype>*)Xin;
+
+
+			/*y=a*x+y where this->vector is y*/
+			for(i=0;i<this->M;i++)this->vector[i]=a*X->vector[i]+this->vector[i];
+
+		}
+		/*}}}*/
+		/*FUNCTION AYPX{{{*/
+		void AYPX(IssmAbsVec<doubletype>* Xin, doubletype a){
+
+			int i;
+
+			/*Assume X is of the correct type, and downcast: */
+			IssmSeqVec* X=NULL;
+
+			X=(IssmSeqVec<doubletype>*)Xin;
+
+			/*y=x+a*y where this->vector is y*/
+			for(i=0;i<this->M;i++)this->vector[i]=X->vector[i]+a*this->vector[i];
+
+		}
+		/*}}}*/
+		/*FUNCTION ToMPISerial{{{*/
+		doubletype* ToMPISerial(void){
+
+			doubletype* buffer=NULL;
+
+			if(this->M){
+				buffer=xNew<doubletype>(this->M);
+				xMemCpy<doubletype>(buffer,this->vector,this->M);
+			}
+			return buffer;
+
+		}
+		/*}}}*/
+		/*FUNCTION Copy{{{*/
+		void Copy(IssmAbsVec<doubletype>* toin){
+
+			int i;
+
+			/*Assume toin is of the correct type, and downcast: */
+			IssmSeqVec* to=NULL;
+
+			to=(IssmSeqVec<doubletype>*)toin;
+
+			to->M=this->M;
+			for(i=0;i<this->M;i++)to->vector[i]=this->vector[i];
+
+		}
+		/*}}}*/
+		/*FUNCTION Norm{{{*/
+		doubletype Norm(NormMode mode){
+
+			doubletype norm;
+			int i;
+
+			switch(mode){
+				case NORM_INF:
+					//norm=0; for(i=0;i<this->M;i++)norm=max(norm,fabs(this->vector[i]));
+					norm=0; for(i=0;i<this->M;i++)norm=max(norm,this->vector[i]);
+					return norm;
+					break;
+				case NORM_TWO:
+					norm=0; 
+					for(i=0;i<this->M;i++)norm+=pow(this->vector[i],2);
+					return sqrt(norm);
+					break;
+				default:
+					_error_("unknown norm !");
+					break;
+			}
+		}
+		/*}}}*/
+		/*FUNCTION Scale{{{*/
+		void Scale(doubletype scale_factor){
+
+			int i;
+			for(i=0;i<this->M;i++)this->vector[i]=scale_factor*this->vector[i];
+
+		}
+		/*}}}*/
+		/*FUNCTION Dot{{{*/
+		doubletype Dot(IssmAbsVec<doubletype>* inputin){
+
+			int i;
+
+			/*Assume inputin is of the correct type, and downcast: */
+			IssmSeqVec* input=NULL;
+
+			input=(IssmSeqVec<doubletype>*)inputin;
+
+
+			doubletype dot=0;
+			for(i=0;i<this->M;i++)dot+=this->vector[i]*input->vector[i];
+			return dot;
+
+		}
+		/*}}}*/
+		/*FUNCTION PointwiseDivide{{{*/
+		void PointwiseDivide(IssmAbsVec<doubletype>* xin,IssmAbsVec<doubletype>* yin){
+
+			int i;
+			
+			/*Assume xin and yin are of the correct type, and downcast: */
+			IssmSeqVec* x=NULL;
+			IssmSeqVec* y=NULL;
+
+			x=(IssmSeqVec<doubletype>*)xin;
+			y=(IssmSeqVec<doubletype>*)yin;
+
+
+			/*pointwise w=x/y where this->vector is w: */
+			for(i=0;i<this->M;i++)this->vector[i]=x->vector[i]/y->vector[i];
+		}
+		/*}}}*/
+};
+#endif //#ifndef _ISSM_SEQ_VEC_H_
Index: /issm/trunk-jpl/src/c/toolkits/issm/IssmToolkitUtils.cpp
===================================================================
--- /issm/trunk-jpl/src/c/toolkits/issm/IssmToolkitUtils.cpp	(revision 14656)
+++ /issm/trunk-jpl/src/c/toolkits/issm/IssmToolkitUtils.cpp	(revision 14656)
@@ -0,0 +1,78 @@
+/*!\file:  IssmToolkitUtils.cpp
+ * \brief utilities used throughout our ISSM toolkit
+ */ 
+
+/*Headers:*/
+/*{{{*/
+#ifdef HAVE_CONFIG_H
+	#include <config.h>
+#else
+#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
+#endif
+
+#include "../../shared/MemOps/xMemCpy.h"
+#include "../../shared/Alloc/alloc.h"
+#include "../../classes/IssmComm.h"
+#include "../../include/macros.h"
+#include "../../classes/ToolkitOptions.h"
+#include "../../EnumDefinitions/EnumDefinitions.h"
+#include "../../shared/Exceptions/exceptions.h"
+#include "./IssmToolkitUtils.h"
+#include <string.h>
+/*}}}*/
+
+/*Routines: */
+int IssmMatTypeFromToolkitOptions(void){ /*{{{*/
+					
+	char* mat_type=NULL;
+	int   mat_type_enum=NULL;
+	int   num_procs=0;
+	bool  isparallel=false;
+
+	/*first, figure out if we are running in parallel: */
+	num_procs=IssmComm::GetSize();
+	if(num_procs>1)isparallel=true;
+	
+	/*retrieve matrix type as a string, from the Toolkits Options database, similar to what Petsc does. Actually, 
+	 *we try and stick with the Petsc matrix types: */
+	mat_type=ToolkitOptions::GetToolkitOptionValue("mat_type");
+
+	if ((strcmp(mat_type,"mpidense")==0) || (strcmp(mat_type,"dense")==0)){
+		if (isparallel) mat_type_enum=MpiDenseEnum;
+		else mat_type_enum=DenseEnum;
+	}
+	else _error_("matrix type not supported yet!");
+	
+	/*free ressources: */
+	xDelete<char>(mat_type);
+	
+	/*return: */
+	return mat_type_enum;
+} /*}}}*/
+int IssmVecTypeFromToolkitOptions(void){ /*{{{*/
+					
+	char* vec_type=NULL;
+	int   vec_type_enum=NULL;
+	int   num_procs=0;
+	bool  isparallel=false;
+
+	/*first, figure out if we are running in parallel: */
+	num_procs=IssmComm::GetSize();
+	if(num_procs>1)isparallel=true;
+	
+	/*retrieve vector type as a string, from the Toolkits Options database, similar to what Petsc does. Actually, 
+	 *we try and stick with the Petsc vector types: */
+	vec_type=ToolkitOptions::GetToolkitOptionValue("vec_type");
+
+	if ((strcmp(vec_type,"mpi")==0) || (strcmp(vec_type,"seq")==0)){
+		if (isparallel) vec_type_enum=MpiEnum;
+		else vec_type_enum=SeqEnum;
+	}
+	else _error_("vector type not supported yet!");
+	
+	/*free ressources: */
+	xDelete<char>(vec_type);
+	
+	/*return: */
+	return vec_type_enum;
+} /*}}}*/  
Index: /issm/trunk-jpl/src/c/toolkits/issm/IssmToolkitUtils.h
===================================================================
--- /issm/trunk-jpl/src/c/toolkits/issm/IssmToolkitUtils.h	(revision 14656)
+++ /issm/trunk-jpl/src/c/toolkits/issm/IssmToolkitUtils.h	(revision 14656)
@@ -0,0 +1,21 @@
+/*!\file:  IssmToolkitUtils.h
+ * \brief routines used throughout the ISSM toolkit
+ */ 
+
+#ifndef _ISSM_TOOLKIT_UTILS_H_
+#define _ISSM_TOOLKIT_UTILS_H_
+
+/*Headers:*/
+/*{{{*/
+#ifdef HAVE_CONFIG_H
+	#include <config.h>
+#else
+#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
+#endif
+
+/*}}}*/
+
+int IssmMatTypeFromToolkitOptions(void);
+int IssmVecTypeFromToolkitOptions(void);
+
+#endif //#ifndef _ISSMMAT_H_
Index: /issm/trunk-jpl/src/c/toolkits/issm/IssmVec.h
===================================================================
--- /issm/trunk-jpl/src/c/toolkits/issm/IssmVec.h	(revision 14656)
+++ /issm/trunk-jpl/src/c/toolkits/issm/IssmVec.h	(revision 14656)
@@ -0,0 +1,198 @@
+/*!\file:  IssmVec.h
+ * \brief Main Vector class for the Issm toolkit. 
+ */ 
+
+#ifndef _ISSMVEC_H_
+#define _ISSMVEC_H_
+
+/*Headers:*/
+/*{{{*/
+#ifdef HAVE_CONFIG_H
+	#include <config.h>
+#else
+#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
+#endif
+
+#include "../../EnumDefinitions/EnumDefinitions.h"
+#include "../../shared/Exceptions/exceptions.h"
+#include "../../shared/MemOps/xMemCpy.h"
+#include "../../shared/Alloc/alloc.h"
+#include "../../include/macros.h"
+#include "./IssmToolkitUtils.h"
+#include <math.h>
+
+/*}}}*/
+
+/*We need to template this class, in case we want to create Vectors that hold
+  IssmDouble* matrix or IssmPDouble* matrix. 
+  Such vectors are useful for use without or with the matlab or python
+  interface (which do not care for IssmDouble types, but only rely on
+  IssmPDouble types)
+*/
+int IssmVecTypeFromToolkitOptions(void);
+
+template <class doubletype> 
+class IssmVec{
+
+	public:
+		
+		IssmAbsVec<doubletype>* vector; /*abstract vector, which implements object orientation*/
+
+		/*IssmVec constructors, destructors*/
+		IssmVec(){ /*{{{*/
+
+			switch(IssmVecTypeFromToolkitOptions()){
+
+				case SeqEnum: 
+					this->vector=new IssmSeqVec<doubletype>();
+					break;
+				case MpiEnum:
+					this->vector=new IssmMpiVec<doubletype>();
+					break;
+				default:
+					_error_("vector type not supported yet!");
+			}
+		}
+		/*}}}*/
+		IssmVec(int M){/*{{{*/
+			
+			switch(IssmVecTypeFromToolkitOptions()){
+
+				case SeqEnum: 
+					this->vector=new IssmSeqVec<doubletype>(M);
+					break;
+				case MpiEnum:
+					this->vector=new IssmMpiVec<doubletype>(M);
+					break;
+				default:
+					_error_("vector type not supported yet!");
+			}
+		}
+		/*}}}*/
+		IssmVec(int m,int M){/*{{{*/
+			
+			switch(IssmVecTypeFromToolkitOptions()){
+
+				case SeqEnum: 
+					this->vector=new IssmSeqVec<doubletype>(m,M);
+					break;
+				case MpiEnum:
+					this->vector=new IssmMpiVec<doubletype>(m,M);
+					break;
+				default:
+					_error_("vector type not supported yet!");
+			}
+		}
+		/*}}}*/
+		IssmVec(int M,bool fromlocalsize){/*{{{*/
+			
+			switch(IssmVecTypeFromToolkitOptions()){
+
+				case SeqEnum: 
+					this->vector=new IssmSeqVec<doubletype>(M,fromlocalsize);
+					break;
+				case MpiEnum:
+					this->vector=new IssmMpiVec<doubletype>(M,fromlocalsize);
+					break;
+				default:
+					_error_("vector type not supported yet!");
+			}
+		}
+		/*}}}*/
+		IssmVec(doubletype* buffer,int M){/*{{{*/
+			
+			switch(IssmVecTypeFromToolkitOptions()){
+
+				case SeqEnum: 
+					this->vector=new IssmSeqVec<doubletype>(buffer,M);
+					break;
+				case MpiEnum:
+					this->vector=new IssmMpiVec<doubletype>(buffer,M);
+					break;
+				default:
+					_error_("vector type not supported yet!");
+			}
+		}
+		/*}}}*/
+		~IssmVec(){/*{{{*/
+		}
+		/*}}}*/
+
+		/*IssmVec specific routines*/
+		void Echo(void){/*{{{*/
+			vector->Echo();
+		}
+		/*}}}*/
+		void Assemble(void){/*{{{*/
+			vector->Assemble();
+		}
+		/*}}}*/
+		void SetValues(int ssize, int* list, doubletype* values, InsMode mode){/*{{{*/
+			vector->SetValues(ssize,list,values,mode);
+		}
+		/*}}}*/
+		void SetValue(int dof, doubletype value, InsMode mode){/*{{{*/
+			vector->SetValue(dof,value,mode);
+		}
+		/*}}}*/
+		void GetValue(doubletype* pvalue,int dof){/*{{{*/
+			vector->GetValue(pvalue,dof);
+		}
+		/*}}}*/
+		void GetSize(int* pM){/*{{{*/
+			vector->GetSize(pM);
+		}
+		/*}}}*/
+		void GetLocalSize(int* pM){/*{{{*/
+			vector->GetLocalSize(pM);
+		}
+		/*}}}*/
+		IssmVec* Duplicate(void){/*{{{*/
+			
+			IssmVec* issmvector=NULL;
+
+			issmvector=new IssmVec<doubletype>();
+			this->vector->Copy(issmvector->vector);
+
+			return issmvector;
+		}
+		/*}}}*/
+		void Set(doubletype value){/*{{{*/
+			vector->Set(value);
+		}
+		/*}}}*/
+		void AXPY(IssmVec* X, doubletype a){/*{{{*/
+			vector->AXPY(X->vector,a);
+		}
+		/*}}}*/
+		void AYPX(IssmVec* X, doubletype a){/*{{{*/
+			vector->AYPX(X->vector,a);
+		}
+		/*}}}*/
+		doubletype* ToMPISerial(void){/*{{{*/
+			return vector->ToMPISerial();
+		}
+		/*}}}*/
+		void Copy(IssmVec* to){/*{{{*/
+			vector->Copy(to->vector);
+		}
+		/*}}}*/
+		doubletype Norm(NormMode mode){/*{{{*/
+			return vector->Norm(mode);
+		}
+		/*}}}*/
+		void Scale(doubletype scale_factor){/*{{{*/
+			vector->Scale(scale_factor);
+		}
+		/*}}}*/
+		doubletype Dot(IssmVec* input){/*{{{*/
+			return vector->Dot(input->vector);
+		}
+		/*}}}*/
+		void PointwiseDivide(IssmVec* x,IssmVec* y){/*{{{*/
+			vector->PointwiseDivide(x->vector,y->vector);
+		}
+		/*}}}*/
+};
+
+#endif //#ifndef _ISSMVEC_H_
Index: /issm/trunk-jpl/src/c/toolkits/issm/issmtoolkit.h
===================================================================
--- /issm/trunk-jpl/src/c/toolkits/issm/issmtoolkit.h	(revision 14655)
+++ /issm/trunk-jpl/src/c/toolkits/issm/issmtoolkit.h	(revision 14656)
@@ -6,6 +6,12 @@
 #define _ISSM_TOOLKIT_H_
 
-#include "./SeqMat.h"
-#include "./SeqVec.h"
+#include "./IssmAbsMat.h"
+#include "./IssmAbsVec.h"
+#include "./IssmDenseMat.h"
+#include "./IssmMat.h"
+#include "./IssmMpiDenseMat.h"
+#include "./IssmMpiVec.h"
+#include "./IssmSeqVec.h"
+#include "./IssmVec.h"
 
 #endif
Index: /issm/trunk-jpl/src/m/enum/DenseEnum.m
===================================================================
--- /issm/trunk-jpl/src/m/enum/DenseEnum.m	(revision 14656)
+++ /issm/trunk-jpl/src/m/enum/DenseEnum.m	(revision 14656)
@@ -0,0 +1,11 @@
+function macro=DenseEnum()
+%DENSEENUM - Enum of Dense
+%
+%   WARNING: DO NOT MODIFY THIS FILE
+%            this file has been automatically generated by src/c/EnumDefinitions/Synchronize.sh
+%            Please read src/c/EnumDefinitions/README for more information
+%
+%   Usage:
+%      macro=DenseEnum()
+
+macro=StringToEnum('Dense');
Index: /issm/trunk-jpl/src/m/enum/EnumDefinitions.py
===================================================================
--- /issm/trunk-jpl/src/m/enum/EnumDefinitions.py	(revision 14655)
+++ /issm/trunk-jpl/src/m/enum/EnumDefinitions.py	(revision 14656)
@@ -5029,4 +5029,44 @@
 	return StringToEnum('XYZP')[0]
 
+def DenseEnum():
+	"""
+	DENSEENUM - Enum of Dense
+
+	   Usage:
+	      macro=DenseEnum()
+	"""
+
+	return StringToEnum('Dense')[0]
+
+def MpiDenseEnum():
+	"""
+	MPIDENSEENUM - Enum of MpiDense
+
+	   Usage:
+	      macro=MpiDenseEnum()
+	"""
+
+	return StringToEnum('MpiDense')[0]
+
+def SeqEnum():
+	"""
+	SEQENUM - Enum of Seq
+
+	   Usage:
+	      macro=SeqEnum()
+	"""
+
+	return StringToEnum('Seq')[0]
+
+def MpiEnum():
+	"""
+	MPIENUM - Enum of Mpi
+
+	   Usage:
+	      macro=MpiEnum()
+	"""
+
+	return StringToEnum('Mpi')[0]
+
 def OptionEnum():
 	"""
@@ -5127,4 +5167,4 @@
 	"""
 
-	return 511
-
+	return 515
+
Index: /issm/trunk-jpl/src/m/enum/MaximumNumberOfEnums.m
===================================================================
--- /issm/trunk-jpl/src/m/enum/MaximumNumberOfEnums.m	(revision 14655)
+++ /issm/trunk-jpl/src/m/enum/MaximumNumberOfEnums.m	(revision 14656)
@@ -9,3 +9,3 @@
 %      macro=MaximumNumberOfEnums()
 
-macro=511;
+macro=515;
Index: /issm/trunk-jpl/src/m/enum/MpiDenseEnum.m
===================================================================
--- /issm/trunk-jpl/src/m/enum/MpiDenseEnum.m	(revision 14656)
+++ /issm/trunk-jpl/src/m/enum/MpiDenseEnum.m	(revision 14656)
@@ -0,0 +1,11 @@
+function macro=MpiDenseEnum()
+%MPIDENSEENUM - Enum of MpiDense
+%
+%   WARNING: DO NOT MODIFY THIS FILE
+%            this file has been automatically generated by src/c/EnumDefinitions/Synchronize.sh
+%            Please read src/c/EnumDefinitions/README for more information
+%
+%   Usage:
+%      macro=MpiDenseEnum()
+
+macro=StringToEnum('MpiDense');
Index: /issm/trunk-jpl/src/m/enum/MpiEnum.m
===================================================================
--- /issm/trunk-jpl/src/m/enum/MpiEnum.m	(revision 14656)
+++ /issm/trunk-jpl/src/m/enum/MpiEnum.m	(revision 14656)
@@ -0,0 +1,11 @@
+function macro=MpiEnum()
+%MPIENUM - Enum of Mpi
+%
+%   WARNING: DO NOT MODIFY THIS FILE
+%            this file has been automatically generated by src/c/EnumDefinitions/Synchronize.sh
+%            Please read src/c/EnumDefinitions/README for more information
+%
+%   Usage:
+%      macro=MpiEnum()
+
+macro=StringToEnum('Mpi');
Index: /issm/trunk-jpl/src/m/enum/SeqEnum.m
===================================================================
--- /issm/trunk-jpl/src/m/enum/SeqEnum.m	(revision 14656)
+++ /issm/trunk-jpl/src/m/enum/SeqEnum.m	(revision 14656)
@@ -0,0 +1,11 @@
+function macro=SeqEnum()
+%SEQENUM - Enum of Seq
+%
+%   WARNING: DO NOT MODIFY THIS FILE
+%            this file has been automatically generated by src/c/EnumDefinitions/Synchronize.sh
+%            Please read src/c/EnumDefinitions/README for more information
+%
+%   Usage:
+%      macro=SeqEnum()
+
+macro=StringToEnum('Seq');
Index: /issm/trunk-jpl/src/wrappers/ContourToMesh/ContourToMesh.cpp
===================================================================
--- /issm/trunk-jpl/src/wrappers/ContourToMesh/ContourToMesh.cpp	(revision 14655)
+++ /issm/trunk-jpl/src/wrappers/ContourToMesh/ContourToMesh.cpp	(revision 14656)
@@ -40,6 +40,6 @@
 
 	/* output: */
-	SeqVec<double> *in_nod  = NULL;
-	SeqVec<double> *in_elem = NULL;
+	IssmSeqVec<double> *in_nod  = NULL;
+	IssmSeqVec<double> *in_elem = NULL;
 
 	/*Boot module: */
Index: /issm/trunk-jpl/src/wrappers/ContourToNodes/ContourToNodes.cpp
===================================================================
--- /issm/trunk-jpl/src/wrappers/ContourToNodes/ContourToNodes.cpp	(revision 14655)
+++ /issm/trunk-jpl/src/wrappers/ContourToNodes/ContourToNodes.cpp	(revision 14656)
@@ -25,5 +25,5 @@
 
 	/* output: */
-	SeqVec<double> *flags = NULL;
+	IssmSeqVec<double> *flags = NULL;
 
 	/*Boot module: */
Index: /issm/trunk-jpl/src/wrappers/InterpFromGridToMesh/InterpFromGridToMesh.cpp
===================================================================
--- /issm/trunk-jpl/src/wrappers/InterpFromGridToMesh/InterpFromGridToMesh.cpp	(revision 14655)
+++ /issm/trunk-jpl/src/wrappers/InterpFromGridToMesh/InterpFromGridToMesh.cpp	(revision 14656)
@@ -42,5 +42,5 @@
 
 	/* output: */
-	SeqVec<double>*  data_mesh=NULL;
+	IssmSeqVec<double>*  data_mesh=NULL;
 
 	/*Boot module: */
Index: /issm/trunk-jpl/src/wrappers/InterpFromMesh2d/InterpFromMesh2d.cpp
===================================================================
--- /issm/trunk-jpl/src/wrappers/InterpFromMesh2d/InterpFromMesh2d.cpp	(revision 14655)
+++ /issm/trunk-jpl/src/wrappers/InterpFromMesh2d/InterpFromMesh2d.cpp	(revision 14656)
@@ -60,5 +60,5 @@
 
 	/* output: */
-	SeqVec<double> *data_prime = NULL;
+	IssmSeqVec<double> *data_prime = NULL;
 
 	/*Boot module: */
Index: /issm/trunk-jpl/src/wrappers/InterpFromMeshToMesh3d/InterpFromMeshToMesh3d.cpp
===================================================================
--- /issm/trunk-jpl/src/wrappers/InterpFromMeshToMesh3d/InterpFromMeshToMesh3d.cpp	(revision 14655)
+++ /issm/trunk-jpl/src/wrappers/InterpFromMeshToMesh3d/InterpFromMeshToMesh3d.cpp	(revision 14656)
@@ -60,5 +60,5 @@
 
 	/* output: */
-	SeqVec<double>*  data_prime=NULL;
+	IssmSeqVec<double>*  data_prime=NULL;
 
 	/*Boot module: */
Index: /issm/trunk-jpl/src/wrappers/MeshProfileIntersection/MeshProfileIntersection.cpp
===================================================================
--- /issm/trunk-jpl/src/wrappers/MeshProfileIntersection/MeshProfileIntersection.cpp	(revision 14655)
+++ /issm/trunk-jpl/src/wrappers/MeshProfileIntersection/MeshProfileIntersection.cpp	(revision 14656)
@@ -76,5 +76,5 @@
 	//contours
 	FetchData(&domain,FILENAME);
-	// MeshProfileIntersectionx should be modified to take DataSet directly (and perhaps SeqMat and SeqVec).
+	// MeshProfileIntersectionx should be modified to take DataSet directly (and perhaps IssmDenseMat and IssmSeqVec).
 	numcontours=domain->Size();
 	contours=xNew<Contour<double>*>(numcontours);
Index: /issm/trunk-jpl/src/wrappers/PointCloudFindNeighbors/PointCloudFindNeighbors.cpp
===================================================================
--- /issm/trunk-jpl/src/wrappers/PointCloudFindNeighbors/PointCloudFindNeighbors.cpp	(revision 14655)
+++ /issm/trunk-jpl/src/wrappers/PointCloudFindNeighbors/PointCloudFindNeighbors.cpp	(revision 14656)
@@ -27,5 +27,5 @@
 
 	/* output: */
-	SeqVec<double> *flags = NULL;
+	IssmSeqVec<double> *flags = NULL;
 
 	/*Boot module: */
Index: /issm/trunk-jpl/src/wrappers/TriMesh/TriMesh.cpp
===================================================================
--- /issm/trunk-jpl/src/wrappers/TriMesh/TriMesh.cpp	(revision 14655)
+++ /issm/trunk-jpl/src/wrappers/TriMesh/TriMesh.cpp	(revision 14656)
@@ -22,9 +22,9 @@
 
 	/* output: */
-	SeqMat<int>    *index             = NULL;
-	SeqVec<double> *x                 = NULL;
-	SeqVec<double> *y                 = NULL;
-	SeqMat<int>    *segments          = NULL;
-	SeqVec<int>    *segmentmarkerlist = NULL;
+	IssmDenseMat<int>    *index             = NULL;
+	IssmSeqVec<double> *x                 = NULL;
+	IssmSeqVec<double> *y                 = NULL;
+	IssmDenseMat<int>    *segments          = NULL;
+	IssmSeqVec<int>    *segmentmarkerlist = NULL;
 
 	/*Boot module: */
Index: /issm/trunk-jpl/src/wrappers/matlab/Makefile.am
===================================================================
--- /issm/trunk-jpl/src/wrappers/matlab/Makefile.am	(revision 14655)
+++ /issm/trunk-jpl/src/wrappers/matlab/Makefile.am	(revision 14656)
@@ -23,6 +23,6 @@
 				./io/MatlabVectorToDoubleVector.cpp\
 				./io/MatlabMatrixToDoubleMatrix.cpp\
-				./io/MatlabMatrixToSeqMat.cpp\
-				./io/MatlabVectorToSeqVec.cpp
+				./io/MatlabMatrixToIssmDenseMat.cpp\
+				./io/MatlabVectorToIssmSeqVec.cpp
 				
 if PETSC
Index: /issm/trunk-jpl/src/wrappers/matlab/io/MatlabMatrixToIssmDenseMat.cpp
===================================================================
--- /issm/trunk-jpl/src/wrappers/matlab/io/MatlabMatrixToIssmDenseMat.cpp	(revision 14656)
+++ /issm/trunk-jpl/src/wrappers/matlab/io/MatlabMatrixToIssmDenseMat.cpp	(revision 14656)
@@ -0,0 +1,25 @@
+/*!\file MatlabMatrixToIssmDenseMat.cpp
+ */
+
+/*Headers:*/
+#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 "./matlabio.h"
+#include "../../c/toolkits/toolkits.h"
+#include "../../c/shared/shared.h"
+
+IssmDenseMat<double>* MatlabMatrixToIssmDenseMat(const mxArray* dataref){
+
+	IssmDenseMat<double>* output=NULL;
+
+	output=new IssmDenseMat<double>();
+	MatlabMatrixToDoubleMatrix(&output->matrix,&output->M,&output->N,dataref);
+	return output;
+
+}
Index: /issm/trunk-jpl/src/wrappers/matlab/io/MatlabMatrixToMatrix.cpp
===================================================================
--- /issm/trunk-jpl/src/wrappers/matlab/io/MatlabMatrixToMatrix.cpp	(revision 14655)
+++ /issm/trunk-jpl/src/wrappers/matlab/io/MatlabMatrixToMatrix.cpp	(revision 14656)
@@ -25,5 +25,5 @@
 	matrix->pmatrix=MatlabMatrixToPetscMat(mxmatrix);
 	#else
-	matrix->smatrix=MatlabMatrixToSeqMat(mxmatrix);
+	matrix->smatrix=MatlabMatrixToIssmDenseMat(mxmatrix);
 	#endif
 
Index: /issm/trunk-jpl/src/wrappers/matlab/io/MatlabVectorToIssmSeqVec.cpp
===================================================================
--- /issm/trunk-jpl/src/wrappers/matlab/io/MatlabVectorToIssmSeqVec.cpp	(revision 14656)
+++ /issm/trunk-jpl/src/wrappers/matlab/io/MatlabVectorToIssmSeqVec.cpp	(revision 14656)
@@ -0,0 +1,20 @@
+/*!\file MatlabVectorToIssmSeqVec.cpp
+ */
+
+/*Headers:*/
+#include <mex.h>
+#include <stdio.h>
+#include <string.h>
+#include "./matlabio.h"
+#include "../../c/toolkits/toolkits.h"
+#include "../../c/shared/shared.h"
+
+IssmSeqVec<double>* MatlabVectorToIssmSeqVec(const mxArray* dataref){
+
+	IssmSeqVec<double>* output=NULL;
+
+	output=new IssmSeqVec<double>();
+	MatlabVectorToDoubleVector(&output->vector,&output->M,dataref);
+	return output;
+
+}
Index: /issm/trunk-jpl/src/wrappers/matlab/io/MatlabVectorToVector.cpp
===================================================================
--- /issm/trunk-jpl/src/wrappers/matlab/io/MatlabVectorToVector.cpp	(revision 14655)
+++ /issm/trunk-jpl/src/wrappers/matlab/io/MatlabVectorToVector.cpp	(revision 14656)
@@ -25,5 +25,5 @@
 	vector->pvector=MatlabVectorToPetscVec(mxvector);
 	#else
-	vector->svector=MatlabVectorToSeqVec(mxvector);
+	vector->svector=MatlabVectorToIssmSeqVec(mxvector);
 	#endif
 
Index: /issm/trunk-jpl/src/wrappers/matlab/io/WriteMatlabData.cpp
===================================================================
--- /issm/trunk-jpl/src/wrappers/matlab/io/WriteMatlabData.cpp	(revision 14655)
+++ /issm/trunk-jpl/src/wrappers/matlab/io/WriteMatlabData.cpp	(revision 14656)
@@ -221,6 +221,6 @@
 }
 /*}}}*/
-/*FUNCTION WriteData(mxArray** pdataref,SeqMat<double>* matrix){{{*/
-void WriteData(mxArray** pdataref,SeqMat<double>* matrix){
+/*FUNCTION WriteData(mxArray** pdataref,IssmDenseMat<double>* matrix){{{*/
+void WriteData(mxArray** pdataref,IssmDenseMat<double>* matrix){
 
 	int      i,j;
@@ -259,6 +259,6 @@
 }
 /*}}}*/
-/*FUNCTION WriteData(mxArray** pdataref,SeqVec<double>* vector){{{*/
-void WriteData(mxArray** pdataref,SeqVec<double>* vector){
+/*FUNCTION WriteData(mxArray** pdataref,IssmSeqVec<double>* vector){{{*/
+void WriteData(mxArray** pdataref,IssmSeqVec<double>* vector){
 
 	mxArray* dataref=NULL;
@@ -290,6 +290,6 @@
 }
 /*}}}*/
-/*FUNCTION WriteData(mxArray** pdataref,SeqMat<int>* matrix){{{*/
-void WriteData(mxArray** pdataref,SeqMat<int>* matrix){
+/*FUNCTION WriteData(mxArray** pdataref,IssmDenseMat<int>* matrix){{{*/
+void WriteData(mxArray** pdataref,IssmDenseMat<int>* matrix){
 
 	int      i,j;
@@ -328,6 +328,6 @@
 }
 /*}}}*/
-/*FUNCTION WriteData(mxArray** pdataref,SeqVec<int>* vector){{{*/
-void WriteData(mxArray** pdataref,SeqVec<int>* vector){
+/*FUNCTION WriteData(mxArray** pdataref,IssmSeqVec<int>* vector){{{*/
+void WriteData(mxArray** pdataref,IssmSeqVec<int>* vector){
 
 	mxArray* dataref=NULL;
Index: /issm/trunk-jpl/src/wrappers/matlab/io/matlabio.h
===================================================================
--- /issm/trunk-jpl/src/wrappers/matlab/io/matlabio.h	(revision 14655)
+++ /issm/trunk-jpl/src/wrappers/matlab/io/matlabio.h	(revision 14656)
@@ -16,11 +16,12 @@
 #include "../../c/Container/Container.h"
 #include "../../c/include/include.h"
+#include "../../c/toolkits/toolkits.h"
 
-void WriteData(mxArray** pdataref,SeqMat<int>* matrix);
-void WriteData(mxArray** pdataref,SeqMat<double>* matrix);
+void WriteData(mxArray** pdataref,IssmDenseMat<int>* matrix);
+void WriteData(mxArray** pdataref,IssmDenseMat<double>* matrix);
 void WriteData(mxArray** pdataref,double* matrix, int M,int N);
 void WriteData(mxArray** pdataref,int*    matrix, int M,int N);
-void WriteData(mxArray** pdataref,SeqVec<int>* vector);
-void WriteData(mxArray** pdataref,SeqVec<double>* vector);
+void WriteData(mxArray** pdataref,IssmSeqVec<int>* vector);
+void WriteData(mxArray** pdataref,IssmSeqVec<double>* vector);
 void WriteData(mxArray** pdataref,double* vector, int M);
 void WriteData(mxArray** pdataref,int integer);
@@ -82,7 +83,7 @@
 int MatlabNArrayToNArray(char** pmatrix,int* pmatrix_numel,int* pmatrix_ndims,int** pmatrix_size,const mxArray* mxmatrix);
 
-/*Matlab to SeqMat routines: */
-SeqMat<double>* MatlabMatrixToSeqMat(const mxArray* dataref);
-SeqVec<double>* MatlabVectorToSeqVec(const mxArray* dataref);
+/*Matlab to IssmDenseMat routines: */
+IssmDenseMat<double>* MatlabMatrixToIssmDenseMat(const mxArray* dataref);
+IssmSeqVec<double>* MatlabVectorToIssmSeqVec(const mxArray* dataref);
 
 /*Matlab to Petsc routines: */
Index: /issm/trunk-jpl/src/wrappers/python/io/WritePythonData.cpp
===================================================================
--- /issm/trunk-jpl/src/wrappers/python/io/WritePythonData.cpp	(revision 14655)
+++ /issm/trunk-jpl/src/wrappers/python/io/WritePythonData.cpp	(revision 14656)
@@ -129,6 +129,6 @@
 }
 /*}}}*/
-/*FUNCTION WriteData(PyObject* py_tuple,int index,SeqMat<double>* matrix){{{*/
-void WriteData(PyObject* py_tuple,int index,SeqMat<double>* matrix){
+/*FUNCTION WriteData(PyObject* py_tuple,int index,IssmDenseMat<double>* matrix){{{*/
+void WriteData(PyObject* py_tuple,int index,IssmDenseMat<double>* matrix){
 
 	int M,N;
@@ -147,6 +147,6 @@
 
 }/*}}}*/
-/*FUNCTION WriteData(PyObject* py_tuple,int index,SeqVec<double>* vector){{{*/
-void WriteData(PyObject* py_tuple,int index,SeqVec<double>* vector){
+/*FUNCTION WriteData(PyObject* py_tuple,int index,IssmSeqVec<double>* vector){{{*/
+void WriteData(PyObject* py_tuple,int index,IssmSeqVec<double>* vector){
 
 	int M;
@@ -164,6 +164,6 @@
 }
 /*}}}*/
-/*FUNCTION WriteData(PyObject* py_tuple,int index,SeqMat<int>* matrix){{{*/
-void WriteData(PyObject* py_tuple,int index,SeqMat<int>* matrix){
+/*FUNCTION WriteData(PyObject* py_tuple,int index,IssmDenseMat<int>* matrix){{{*/
+void WriteData(PyObject* py_tuple,int index,IssmDenseMat<int>* matrix){
 
 	int M,N;
@@ -187,6 +187,6 @@
 
 }/*}}}*/
-/*FUNCTION WriteData(PyObject* py_tuple,int index,SeqVec<int>* vector){{{*/
-void WriteData(PyObject* py_tuple,int index,SeqVec<int>* vector){
+/*FUNCTION WriteData(PyObject* py_tuple,int index,IssmSeqVec<int>* vector){{{*/
+void WriteData(PyObject* py_tuple,int index,IssmSeqVec<int>* vector){
 
 	int M;
@@ -209,6 +209,6 @@
 }
 /*}}}*/
-/*FUNCTION WriteData(PyObject* py_tuple,int index,SeqMat<bool>* matrix){{{*/
-void WriteData(PyObject* py_tuple,int index,SeqMat<bool>* matrix){
+/*FUNCTION WriteData(PyObject* py_tuple,int index,IssmDenseMat<bool>* matrix){{{*/
+void WriteData(PyObject* py_tuple,int index,IssmDenseMat<bool>* matrix){
 
 	int M,N;
@@ -227,6 +227,6 @@
 
 }/*}}}*/
-/*FUNCTION WriteData(PyObject* py_tuple,int index,SeqVec<bool>* vector){{{*/
-void WriteData(PyObject* py_tuple,int index,SeqVec<bool>* vector){
+/*FUNCTION WriteData(PyObject* py_tuple,int index,IssmSeqVec<bool>* vector){{{*/
+void WriteData(PyObject* py_tuple,int index,IssmSeqVec<bool>* vector){
 
 	int M;
Index: /issm/trunk-jpl/src/wrappers/python/io/pythonio.h
===================================================================
--- /issm/trunk-jpl/src/wrappers/python/io/pythonio.h	(revision 14655)
+++ /issm/trunk-jpl/src/wrappers/python/io/pythonio.h	(revision 14656)
@@ -23,10 +23,10 @@
 void WriteData(PyObject* py_tuple,int index, char* string);
 void WriteData(PyObject* py_tuple,int index);
-void WriteData(PyObject* py_tuple,int index, SeqMat<double>* matrix);
-void WriteData(PyObject* py_tuple,int index, SeqVec<double>* vector);
-void WriteData(PyObject* py_tuple,int index, SeqMat<int>* matrix);
-void WriteData(PyObject* py_tuple,int index, SeqVec<int>* vector);
-void WriteData(PyObject* py_tuple,int index, SeqMat<bool>* matrix);
-void WriteData(PyObject* py_tuple,int index, SeqVec<bool>* vector);
+void WriteData(PyObject* py_tuple,int index, IssmDenseMat<double>* matrix);
+void WriteData(PyObject* py_tuple,int index, IssmSeqVec<double>* vector);
+void WriteData(PyObject* py_tuple,int index, IssmDenseMat<int>* matrix);
+void WriteData(PyObject* py_tuple,int index, IssmSeqVec<int>* vector);
+void WriteData(PyObject* py_tuple,int index, IssmDenseMat<bool>* matrix);
+void WriteData(PyObject* py_tuple,int index, IssmSeqVec<bool>* vector);
 void WriteData(PyObject* py_tuple,int index, BamgGeom* bamggeom);
 void WriteData(PyObject* py_tuple,int index, BamgMesh* bamgmesh);
