Index: /issm/trunk/src/c/BuildNodeSetsx/BuildNodeSetsx.cpp
===================================================================
--- /issm/trunk/src/c/BuildNodeSetsx/BuildNodeSetsx.cpp	(revision 831)
+++ /issm/trunk/src/c/BuildNodeSetsx/BuildNodeSetsx.cpp	(revision 832)
@@ -53,8 +53,9 @@
 		nodes->FlagNodeSets(flag_pv_g,flag_pv_m,flag_pv_n,flag_pv_f,flag_pv_s);
 
+
 		/*Now, every cpu has 4 flag vectors, of size gsize. Create partition vectors (like a pos=find(flag_pv_g) in matlab*/
 		PartitionSets(&vec_pv_m,&vec_pv_n,flag_pv_g,flag_pv_m,flag_pv_n,gsize); /*! split g set into m and n sets*/
 		PartitionSets(&vec_pv_f,&vec_pv_s,flag_pv_n,flag_pv_f,flag_pv_s,gsize); /*! split n set into f and s sets*/
-
+		
 		/*Free ressources:*/
 		VecFree(&flag_pv_g);
Index: /issm/trunk/src/c/DataSet/DataSet.cpp
===================================================================
--- /issm/trunk/src/c/DataSet/DataSet.cpp	(revision 831)
+++ /issm/trunk/src/c/DataSet/DataSet.cpp	(revision 832)
@@ -813,8 +813,13 @@
 			}
 			else{
-				/*Ok, this cpu owns both nodes. Put dof for node1 into m set: */
-				node1->DofInMSet(dof-1);
+				/*Ok, this cpu owns both nodes. Put dof for node1 into m set, unless it is already there, 
+				 * in which case node2 gets into the m set: */
+				if(node1->DofIsInMSet(dof-1)){
+					node2->DofInMSet(dof-1);
+				}
+				else{
+					node1->DofInMSet(dof-1);
+				}
 				
-
 				/*Plug values into Rmg. We essentially want dofs from node1 and node2 to be the 
 				 *same: */
Index: /issm/trunk/src/c/NormalizeConstraintsx/NormalizeConstraintsx.cpp
===================================================================
--- /issm/trunk/src/c/NormalizeConstraintsx/NormalizeConstraintsx.cpp	(revision 831)
+++ /issm/trunk/src/c/NormalizeConstraintsx/NormalizeConstraintsx.cpp	(revision 832)
@@ -38,9 +38,11 @@
 			/*Build row partitioning vector for Rmm and Rmn: */
 			row_m=(double*)xmalloc(msize*sizeof(double));
-			for(i=0;i<msize;i++)row_m[i]=i+1; //matlab indexing
-
+			for(i=0;i<msize;i++)row_m[i]=i+1; //matlab indexing for nodesets
+			
 			/*Partition Rmg into Rmm and Rmn: */
 			MatPartition(&Rmm,Rmg,row_m,msize,pv_m,msize); //equivalent of Rmm=Rmg(:,mset);
 			MatPartition(&Rmn,Rmg,row_m,msize,pv_n,nsize);
+			
+			MatView(Rmm,PETSC_VIEWER_STDOUT_WORLD);
 
 			/*Invert Rmm: */
Index: /issm/trunk/src/c/objects/Node.cpp
===================================================================
--- /issm/trunk/src/c/objects/Node.cpp	(revision 831)
+++ /issm/trunk/src/c/objects/Node.cpp	(revision 832)
@@ -419,5 +419,11 @@
 	sset[dof]=0;
 }
-		
+
+int  Node::DofIsInMSet(int dof){
+
+	if (mset[dof])return 1;
+	else return 0;
+
+}
 
 int   Node::GetDof(int dofindex){
Index: /issm/trunk/src/c/objects/Node.h
===================================================================
--- /issm/trunk/src/c/objects/Node.h	(revision 831)
+++ /issm/trunk/src/c/objects/Node.h	(revision 832)
@@ -66,4 +66,5 @@
 		void  DofInSSet(int dof);
 		void  DofInMSet(int dof);
+		 int  DofIsInMSet(int dof);
 		int   GetDof(int dofindex);
 		void  CreateVecSets(Vec pv_g,Vec pv_m,Vec pv_n,Vec pv_f,Vec pv_s);
Index: /issm/trunk/src/m/solutions/cielo/CreateFemModel.m
===================================================================
--- /issm/trunk/src/m/solutions/cielo/CreateFemModel.m	(revision 831)
+++ /issm/trunk/src/m/solutions/cielo/CreateFemModel.m	(revision 832)
@@ -25,8 +25,8 @@
 	displaystring(md.debug,'%s','   reducing single point constraints vector...');
 	[m.ys m.ys0]=Reducevectorgtos(m.yg,m.nodesets);
-
+	
 	displaystring(md.debug,'%s','   normalizing rigid body constraints matrix...');
 	m.Gmn = NormalizeConstraints(m.Rmg,m.nodesets);
-	
+
 	displaystring(md.debug,'%s','   configuring element and loads...');
 	[m.elements,m.loads,m.nodes] = ConfigureObjects( m.elements, m.loads, m.nodes, m.materials);
Index: sm/trunk/src/m/solutions/cielo/Normalizeconstraints.m
===================================================================
--- /issm/trunk/src/m/solutions/cielo/Normalizeconstraints.m	(revision 831)
+++ 	(revision )
@@ -1,52 +1,0 @@
-function [G_mn]= normalizeconstraints( R_mg ,uset);
-% NORMALIZECONSTRAINTS [G_mn]= normalizeconstraints( pR_mg )
-%
-% Calculates the G_mn matrix from the Jacobian of the
-% multi point and rigid constraints R_mg
-%
-% G_mn = -inv(R_mm) * R_mn
-%
-% where R_mg = [ R_mm R_mn ]
-%
-% m dependent dof 
-% n independent dof
-% g global dof g = m + n
-%
-% Input:  pR_mg    	pointer to R_mg matrix on data base
-%		            R_mg is the m x g matrix of constraints
-%					Use m.R_mg in the calling script
-%
-% Output: G_mn      m x n normalized matrix of constraints in the workspace
-%
-% Input from global workspace:
-%
-%         uset      uset.pv_*  	partitioning vector
-%					uset.*size 	size 
-%								*=n,m etc.
-%
-% Called by  sol101 (ms), Normalmodes (ms), sol159 (ms) (all solution sequences)
-% Calls  IMdb (mex)
-% where ms= m-script, mf= m-function, mex= executable function (c-code)
-%
-% uset.pv_m and uset.pv_n partitioning indicees are with respect to the g- set
-%
-% R_mg is the matrix (Jacobian) of constraints from MPCs and rigid elements,
-% with m rows and g columns. The m constraint equations are used to eliminate m
-% dof out of g dof leaving n dof . The normalized constraint matrix G_mn
-% is needed for later elimination, partition and merge operations.
-%
-
-% Retrieve R_mg, partition, and calculate G_mn
-
-if(uset.msize>0)
-
-	R_mm = R_mg(:, uset.pv_m);
-	R_mn = R_mg(:, uset.pv_n);
-
-	G_mn= - inv(R_mm) * R_mn;
-
-else
-
-	G_mn= [];
-
-end
Index: /issm/trunk/src/m/solutions/ice/CreateFemModel.m
===================================================================
--- /issm/trunk/src/m/solutions/ice/CreateFemModel.m	(revision 831)
+++ /issm/trunk/src/m/solutions/ice/CreateFemModel.m	(revision 832)
@@ -24,9 +24,12 @@
 Rmg=MpcGrids(grids,constraints);
 
+
 %generate grid sets and reduce yg to ys from g-set to s-set.
 BuildGridSets(grids,constraints); ys=Reducevector_g(yg);
 
-%buile Gmn
+%build Gmn
 Gmn=Normalizeconstraints(Rmg);
+
+spy(Gmn)
 
 %recover dof number
