Index: /issm/trunk/src/c/io/FetchData.cpp
===================================================================
--- /issm/trunk/src/c/io/FetchData.cpp	(revision 6346)
+++ /issm/trunk/src/c/io/FetchData.cpp	(revision 6347)
@@ -77,5 +77,5 @@
 	else{
 		/*This is an error: we don't have the correct input!: */
-		ISSMERROR("wrong input parameter");
+		ISSMERROR("Input parameter of class %s not supported yet",mxGetClassName(dataref));
 	}
 
Index: /issm/trunk/src/c/objects/Elements/Tria.cpp
===================================================================
--- /issm/trunk/src/c/objects/Elements/Tria.cpp	(revision 6346)
+++ /issm/trunk/src/c/objects/Elements/Tria.cpp	(revision 6347)
@@ -1275,7 +1275,8 @@
 	int        i,ig;
 	int        doflist1[NUMVERTICES];
-	double     thickness,Jdet;
+	double     thickness,Jdet,cm_noisedmp;
 	double     l1l2l3[3];
-	double     Dlambda[2];
+	double     dbasis[NDOF2][NUMVERTICES];
+	double     Dlambda[2],dp[2];
 	double     xyz_list[NUMVERTICES][3];
 	double     grade_g[NUMVERTICES] = {0.0};
@@ -1287,4 +1288,5 @@
 
 	/*Retrieve all inputs we will be needing: */
+	this->parameters->FindParam(&cm_noisedmp,CmNoiseDmpEnum);
 	Input* adjoint_input=inputs->GetInput(AdjointEnum);     ISSMASSERT(adjoint_input);
 	Input* thickness_input=inputs->GetInput(ThicknessEnum); ISSMASSERT(thickness_input);
@@ -1298,9 +1300,14 @@
 		GetJacobianDeterminant2d(&Jdet, &xyz_list[0][0],gauss);
 		GetNodalFunctions(l1l2l3, gauss);
+		GetNodalFunctionsDerivatives(&dbasis[0][0],&xyz_list[0][0],gauss);
 		
 		adjoint_input->GetParameterDerivativeValue(&Dlambda[0],&xyz_list[0][0],gauss);
 		thickness_input->GetParameterValue(&thickness, gauss);
-
-		for(i=0;i<NUMVERTICES;i++) grade_g[i]=thickness*Dlambda[0]*Jdet*gauss->weight*l1l2l3[i];
+		thickness_input->GetParameterDerivativeValue(&dp[0],&xyz_list[0][0],gauss);
+
+		for(i=0;i<NUMVERTICES;i++) grade_g[i]+=thickness*Dlambda[0]*Jdet*gauss->weight*l1l2l3[i];
+
+		//noise dampening d/dki(1/2*(dk/dx)^2)
+		for (i=0;i<NUMVERTICES;i++) grade_g[i]-=cm_noisedmp*Jdet*gauss->weight*(dbasis[0][i]*dp[0]+dbasis[1][i]*dp[1]);
 	}
 
@@ -1317,7 +1324,8 @@
 	int        i,ig;
 	int        doflist1[NUMVERTICES];
-	double     thickness,Jdet;
+	double     thickness,Jdet,cm_noisedmp;
 	double     l1l2l3[3];
-	double     Dlambda[2];
+	double     dbasis[NDOF2][NUMVERTICES];
+	double     Dlambda[2],dp[2];
 	double     xyz_list[NUMVERTICES][3];
 	double     grade_g[NUMVERTICES] = {0.0};
@@ -1325,4 +1333,5 @@
 
 	/* Get node coordinates and dof list: */
+	this->parameters->FindParam(&cm_noisedmp,CmNoiseDmpEnum);
 	GetVerticesCoordinates(&xyz_list[0][0], nodes, NUMVERTICES);
 	GetDofList1(&doflist1[0]);
@@ -1338,11 +1347,16 @@
 		gauss->GaussPoint(ig);
 
+		GetJacobianDeterminant2d(&Jdet, &xyz_list[0][0],gauss);
+		GetNodalFunctions(l1l2l3, gauss);
+		GetNodalFunctionsDerivatives(&dbasis[0][0],&xyz_list[0][0],gauss);
+
 		adjoint_input->GetParameterDerivativeValue(&Dlambda[0],&xyz_list[0][0],gauss);
 		thickness_input->GetParameterValue(&thickness, gauss);
-
-		GetJacobianDeterminant2d(&Jdet, &xyz_list[0][0],gauss);
-		GetNodalFunctions(l1l2l3, gauss);
-
-		for(i=0;i<NUMVERTICES;i++) grade_g[i]=thickness*Dlambda[1]*Jdet*gauss->weight*l1l2l3[i];
+		thickness_input->GetParameterDerivativeValue(&dp[0],&xyz_list[0][0],gauss);
+
+		for(i=0;i<NUMVERTICES;i++) grade_g[i]+=thickness*Dlambda[1]*Jdet*gauss->weight*l1l2l3[i];
+
+		//noise dampening d/dki(1/2*(dk/dx)^2)
+		for (i=0;i<NUMVERTICES;i++) grade_g[i]-=cm_noisedmp*Jdet*gauss->weight*(dbasis[0][i]*dp[0]+dbasis[1][i]*dp[1]);
 	}
 
