Index: /issm/trunk-jpl/src/c/classes/Elements/Element.cpp
===================================================================
--- /issm/trunk-jpl/src/c/classes/Elements/Element.cpp	(revision 18174)
+++ /issm/trunk-jpl/src/c/classes/Elements/Element.cpp	(revision 18175)
@@ -187,4 +187,5 @@
 
 	/*Intermediaries*/
+	int        dim;
 	IssmDouble Jdet;
 	IssmDouble divergence=0.;
@@ -193,10 +194,14 @@
 
 	/*Get inputs and parameters*/
-	Input* vx_input        = this->GetInput(VxEnum); _assert_(vx_input);
-	Input* vy_input        = this->GetInput(VyEnum); _assert_(vy_input);
-	Input* vz_input        = this->GetInput(VzEnum); _assert_(vz_input);
+	this->FindParam(&dim,DomainDimensionEnum);
+	Input* vx_input = this->GetInput(VxEnum); _assert_(vx_input);
+	Input* vy_input = this->GetInput(VyEnum); _assert_(vy_input);
+	Input* vz_input = NULL;
+	if(dim==3){
+		vz_input = this->GetInput(VzEnum); _assert_(vz_input);
+	}
 	this->GetVerticesCoordinates(&xyz_list);
 
-	Gauss* gauss=this->NewGaussBase(5);
+	Gauss* gauss=this->NewGauss(5);
 	for(int ig=gauss->begin();ig<gauss->end();ig++){
 		gauss->GaussPoint(ig);
@@ -206,7 +211,12 @@
 		vx_input->GetInputDerivativeValue(&dvx[0],xyz_list,gauss);
 		vy_input->GetInputDerivativeValue(&dvy[0],xyz_list,gauss);
-		vz_input->GetInputDerivativeValue(&dvz[0],xyz_list,gauss);
-
-		divergence += (dvx[0]+dvy[1]+dvz[2])*gauss->weight*Jdet;
+		if(dim==2){
+			divergence += (dvx[0]+dvy[1])*gauss->weight*Jdet;
+		}
+		else{
+			vz_input->GetInputDerivativeValue(&dvz[0],xyz_list,gauss);
+			divergence += (dvx[0]+dvy[1]+dvz[2])*gauss->weight*Jdet;
+		}
+
 	}
 
