Index: /issm/trunk/src/c/modules/PenaltyConstraintsx/PenaltyConstraintsLocal.h
===================================================================
--- /issm/trunk/src/c/modules/PenaltyConstraintsx/PenaltyConstraintsLocal.h	(revision 5159)
+++ /issm/trunk/src/c/modules/PenaltyConstraintsx/PenaltyConstraintsLocal.h	(revision 5160)
@@ -13,16 +13,18 @@
 int   MeltingIsPresent(Loads* loads,int analysis_type);
 
-/*rifts: */
-int   RiftConstraints(int* pconverged, int* pnum_unstable_constraints,Loads* loads,int min_mechanical_constraints,int analysis_type);
-int   RiftIsPresent(Loads* loads,int analysis_type);
-int   IsPreStable(Loads* loads);
-int   SetPreStable(Loads* loads);
-int   PreConstrain(int* pnum_unstable_constraints,Loads* loads);
-int   Constrain(int* pnum_unstable_constraints,Loads* loads);
-void  FreezeConstraints(Loads* loads);
-int   MaxPenetrationInInputs(Loads* loads);
-int   PotentialUnstableConstraints(Loads* loads);
-int   IsMaterialStable(Loads* loads);
-int   IsFrozen(Loads* loads);
+/*rifts module: */
+int    RiftIsPresent(Loads* loads,int analysis_type);
+void   RiftConstraints(int* pconverged, int* pnum_unstable_constraints,Loads* loads,int min_mechanical_constraints,int analysis_type);
+void   RiftConstrain(int* pnum_unstable_constraints,Loads* loads,int analysis_type);
+int    RiftIsFrozen(Loads* loads,int analysis_type);
+void   RiftFreezeConstraints(Loads* loads,int analysis_type);
+
+/*rifts, trial and errors: */
+int    RiftIsPreStable(Loads* loads);
+void   RiftSetPreStable(Loads* loads);
+void   RiftPreConstrain(int* pnum_unstable_constraints,Loads* loads);
+void   RiftMaxPenetrationInInputs(Loads* loads);
+int    RiftPotentialUnstableConstraints(Loads* loads);
+int    RiftIsMaterialStable(Loads* loads);
 
 #endif  /* _PENALTYCONSTRAINTSX_H */
Index: /issm/trunk/src/c/modules/PenaltyConstraintsx/RiftConstraints.cpp
===================================================================
--- /issm/trunk/src/c/modules/PenaltyConstraintsx/RiftConstraints.cpp	(revision 5159)
+++ /issm/trunk/src/c/modules/PenaltyConstraintsx/RiftConstraints.cpp	(revision 5160)
@@ -10,60 +10,6 @@
 #define _ZIGZAGCOUNTER_
 
-int RiftConstraints(int* pconverged, int* pnum_unstable_constraints,Loads* loads,int min_mechanical_constraints,int analysis_type){
-
-	int num_unstable_constraints=0;
-	int converged=0;
-	int potential;
-	ISSMERROR(" check analysis_type across all routine!");
-
-	Constrain(&num_unstable_constraints,loads);
-	if(num_unstable_constraints==0)converged=1;
-	
-	
-	if(IsFrozen(loads)){
-		converged=1;
-		num_unstable_constraints=0;
-	}
-	else if(num_unstable_constraints<=min_mechanical_constraints){
-		_printf_("   freezing constraints\n");
-		FreezeConstraints(loads);
-	}
-
-	/*Assign output pointers: */
-	*pconverged=converged;
-	*pnum_unstable_constraints=num_unstable_constraints;
-}
-
-int IsMaterialStable(Loads* loads){
-
-	int i;
-	
-	Riftfront* riftfront=NULL;
-	int found=0;
-	int mpi_found=0;
-
-	/*go though loads, and if non-linearity of the material has converged, let all penalties know: */
-	for (i=0;i<loads->Size();i++){
-
-		if(RiftfrontEnum==loads->GetEnum(i)){
-
-			riftfront=(Riftfront*)loads->GetObjectByOffset(i);
-
-			if (riftfront->IsMaterialStable()){
-				found=1;
-				/*do not break! all penalties should get informed the non-linearity converged!*/
-			}
-		}
-	}
-
-	#ifdef _PARALLEL_
-	MPI_Reduce (&found,&mpi_found,1,MPI_INT,MPI_SUM,0,MPI_COMM_WORLD );
-	MPI_Bcast(&mpi_found,1,MPI_INT,0,MPI_COMM_WORLD);                
-	found=mpi_found;
-	#endif
-
-	return found;
-}
-
+/*current module: */
+/*RiftIsPresent(Loads* loads,int analysis_type){{{1*/
 int RiftIsPresent(Loads* loads,int analysis_type){
 
@@ -93,69 +39,37 @@
 	return found;
 }
-
-int IsPreStable(Loads* loads){
-
-
-	int i;
-	
-	Riftfront* riftfront=NULL;
-	int found=0;
-	int mpi_found=0;
-
-	/*go though loads, and figure out if one of the penpair loads is still not stable: */
-	for (i=0;i<loads->Size();i++){
-
-		if(RiftfrontEnum==loads->GetEnum(i)){
-
-			riftfront=(Riftfront*)loads->GetObjectByOffset(i);
-
-			if (riftfront->PreStable()==0){
-				found=1;
-				break;
-			}
-		}
-	}
-
-	#ifdef _PARALLEL_
-	MPI_Reduce (&found,&mpi_found,1,MPI_INT,MPI_SUM,0,MPI_COMM_WORLD );
-	MPI_Bcast(&mpi_found,1,MPI_INT,0,MPI_COMM_WORLD);                
-	found=mpi_found;
-	#endif
-
-	if (found){
-		/*We found an unstable constraint. : */
-		return 0;
-	}
-	else{
-		return 1;
-	}
-}
-
-int SetPreStable(Loads* loads){
-
-
-	int i;
-	
-	Riftfront* riftfront=NULL;
-	int found=0;
-	int mpi_found=0;
-
-	/*go though loads, and set loads to pre stable.:*/
-	for (i=0;i<loads->Size();i++){
-
-		if(RiftfrontEnum==loads->GetEnum(i)){
-
-			riftfront=(Riftfront*)loads->GetObjectByOffset(i);
-			riftfront->SetPreStable();
-		}
-	}
-}
-
-int PreConstrain(int* pnum_unstable_constraints,Loads* loads){
-
-	int			i;
-	
-	/* generic object pointer: */
-	Riftfront* riftfront=NULL;
+/*}}}*/
+/*RiftConstraints(int* pconverged, int* pnum_unstable_constraints,Loads* loads,int min_mechanical_constraints,int analysis_type){{{1*/
+void RiftConstraints(int* pconverged, int* pnum_unstable_constraints,Loads* loads,int min_mechanical_constraints,int analysis_type){
+
+	int num_unstable_constraints=0;
+	int converged=0;
+	int potential;
+
+	RiftConstrain(&num_unstable_constraints,loads,analysis_type);
+	if(num_unstable_constraints==0)converged=1;
+	
+	if(RiftIsFrozen(loads,analysis_type)){
+		converged=1;
+		num_unstable_constraints=0;
+	}
+	else if(num_unstable_constraints<=min_mechanical_constraints){
+		_printf_("   freezing constraints\n");
+		RiftFreezeConstraints(loads,analysis_type);
+	}
+
+	/*Assign output pointers: */
+	*pconverged=converged;
+	*pnum_unstable_constraints=num_unstable_constraints;
+}
+/*}}}*/
+/*RiftConstrain(int* pnum_unstable_constraints,Loads* loads,int analysis_type){{{1*/
+void RiftConstrain(int* pnum_unstable_constraints,Loads* loads,int analysis_type){
+
+	int			i;
+	
+	/* generic object pointer: */
+	Riftfront* riftfront=NULL;
+	Load*      load=NULL;
 
 	int unstable;
@@ -168,9 +82,13 @@
 		if (RiftfrontEnum==loads->GetEnum(i)){
 
-			riftfront=(Riftfront*)loads->GetObjectByOffset(i);
-
-			riftfront->PreConstrain(&unstable);
-
-			num_unstable_constraints+=unstable;
+			load=(Load*)loads->GetObjectByOffset(i);
+			if(load->InAnalysis(analysis_type)){
+
+				riftfront=(Riftfront*)load;
+
+				riftfront->Constrain(&unstable);
+
+				num_unstable_constraints+=unstable;
+			}
 		}
 	}
@@ -186,6 +104,165 @@
 
 }
-
-int Constrain(int* pnum_unstable_constraints,Loads* loads){
+/*}}}*/
+/*RiftIsFrozen(Loads* loads,int analysis_type){{{1*/
+int RiftIsFrozen(Loads* loads,int analysis_type){
+
+	int			i;
+	
+	/* generic object pointer: */
+	Load*      load=NULL;
+	Riftfront* riftfront=NULL;
+	int found=0;
+	int mpi_found=0;
+
+	/*Enforce constraints: */
+	for (i=0;i<loads->Size();i++){
+
+		if (RiftfrontEnum==loads->GetEnum(i)){
+			
+			load=(Load*)loads->GetObjectByOffset(i);
+			if(load->InAnalysis(analysis_type)){
+
+				riftfront=(Riftfront*)load;
+				if (riftfront->IsFrozen()){
+					found=1;
+					break;
+				}
+			}
+		}
+	}
+	
+	/*Is there just one found? that would mean we have frozen! : */
+	#ifdef _PARALLEL_
+	MPI_Reduce (&found,&mpi_found,1,MPI_DOUBLE,MPI_MAX,0,MPI_COMM_WORLD );
+	MPI_Bcast(&mpi_found,1,MPI_DOUBLE,0,MPI_COMM_WORLD);                
+	found=mpi_found;
+	#endif
+
+	return found;
+}
+/*}}}*/
+/*RiftFreezeConstraints(Loads* loads,int analysis_type){{{1*/
+void RiftFreezeConstraints(Loads* loads,int analysis_type){
+
+	int			i;
+	
+	/* generic object pointer: */
+	Load*      load=NULL;
+	Riftfront* riftfront=NULL;
+
+	/*Enforce constraints: */
+	for (i=0;i<loads->Size();i++){
+
+		if (RiftfrontEnum==loads->GetEnum(i)){
+
+			load=(Load*)loads->GetObjectByOffset(i);
+			if(load->InAnalysis(analysis_type)){
+				
+				riftfront=(Riftfront*)load;
+				riftfront->FreezeConstraints();
+			}
+
+		}
+	}
+
+}
+/*}}}*/
+
+/*diverse trials and errors: */
+/*RiftIsMaterialStable(Loads* loads){{{1*/
+int RiftIsMaterialStable(Loads* loads){
+
+	int i;
+	
+	Riftfront* riftfront=NULL;
+	int found=0;
+	int mpi_found=0;
+
+	/*go though loads, and if non-linearity of the material has converged, let all penalties know: */
+	for (i=0;i<loads->Size();i++){
+
+		if(RiftfrontEnum==loads->GetEnum(i)){
+
+			riftfront=(Riftfront*)loads->GetObjectByOffset(i);
+
+			if (riftfront->IsMaterialStable()){
+				found=1;
+				/*do not break! all penalties should get informed the non-linearity converged!*/
+			}
+		}
+	}
+
+	#ifdef _PARALLEL_
+	MPI_Reduce (&found,&mpi_found,1,MPI_INT,MPI_SUM,0,MPI_COMM_WORLD );
+	MPI_Bcast(&mpi_found,1,MPI_INT,0,MPI_COMM_WORLD);                
+	found=mpi_found;
+	#endif
+
+	return found;
+}
+/*}}}*/
+/*RiftIsPreStable(Loads* loads){{{1*/
+int RiftIsPreStable(Loads* loads){
+
+
+	int i;
+	
+	Riftfront* riftfront=NULL;
+	int found=0;
+	int mpi_found=0;
+
+	/*go though loads, and figure out if one of the penpair loads is still not stable: */
+	for (i=0;i<loads->Size();i++){
+
+		if(RiftfrontEnum==loads->GetEnum(i)){
+
+			riftfront=(Riftfront*)loads->GetObjectByOffset(i);
+
+			if (riftfront->PreStable()==0){
+				found=1;
+				break;
+			}
+		}
+	}
+
+	#ifdef _PARALLEL_
+	MPI_Reduce (&found,&mpi_found,1,MPI_INT,MPI_SUM,0,MPI_COMM_WORLD );
+	MPI_Bcast(&mpi_found,1,MPI_INT,0,MPI_COMM_WORLD);                
+	found=mpi_found;
+	#endif
+
+	if (found){
+		/*We found an unstable constraint. : */
+		return 0;
+	}
+	else{
+		return 1;
+	}
+}
+/*}}}*/
+/*RiftSetPreStable(Loads* loads){{{1*/
+void RiftSetPreStable(Loads* loads){
+
+
+	int i;
+	
+	Riftfront* riftfront=NULL;
+	int found=0;
+	int mpi_found=0;
+
+	/*go though loads, and set loads to pre stable.:*/
+	for (i=0;i<loads->Size();i++){
+
+		if(RiftfrontEnum==loads->GetEnum(i)){
+
+			riftfront=(Riftfront*)loads->GetObjectByOffset(i);
+			riftfront->SetPreStable();
+		}
+	}
+}
+/*}}}*/
+/*RiftPreConstrain(int* pnum_unstable_constraints,Loads* loads){{{1*/
+void RiftPreConstrain(int* pnum_unstable_constraints,Loads* loads){
 
 	int			i;
@@ -205,5 +282,5 @@
 			riftfront=(Riftfront*)loads->GetObjectByOffset(i);
 
-			riftfront->Constrain(&unstable);
+			riftfront->PreConstrain(&unstable);
 
 			num_unstable_constraints+=unstable;
@@ -221,59 +298,7 @@
 
 }
-
-void FreezeConstraints(Loads* loads){
-
-	int			i;
-	
-	/* generic object pointer: */
-	Riftfront* riftfront=NULL;
-
-	/*Enforce constraints: */
-	for (i=0;i<loads->Size();i++){
-
-		if (RiftfrontEnum==loads->GetEnum(i)){
-
-			riftfront=(Riftfront*)loads->GetObjectByOffset(i);
-
-			riftfront->FreezeConstraints();
-
-		}
-	}
-
-}
-
-int IsFrozen(Loads* loads){
-
-	int			i;
-	
-	/* generic object pointer: */
-	Riftfront* riftfront=NULL;
-	int found=0;
-	int mpi_found=0;
-
-	/*Enforce constraints: */
-	for (i=0;i<loads->Size();i++){
-
-		if (RiftfrontEnum==loads->GetEnum(i)){
-
-			riftfront=(Riftfront*)loads->GetObjectByOffset(i);
-			if (riftfront->IsFrozen()){
-				found=1;
-				break;
-			}
-		}
-	}
-	
-	/*Is there just one found? that would mean we have frozen! : */
-	#ifdef _PARALLEL_
-	MPI_Reduce (&found,&mpi_found,1,MPI_DOUBLE,MPI_MAX,0,MPI_COMM_WORLD );
-	MPI_Bcast(&mpi_found,1,MPI_DOUBLE,0,MPI_COMM_WORLD);                
-	found=mpi_found;
-	#endif
-
-	return found;
-}
-
-int MaxPenetrationInInputs(Loads* loads){
+/*}}}*/
+/*RiftMaxPenetrationInInputs(Loads* loads){{{1*/
+void RiftMaxPenetrationInInputs(Loads* loads){
 
 	int			i;
@@ -315,6 +340,7 @@
 	}
 }
-
-int PotentialUnstableConstraints(Loads* loads){
+/*}}}*/
+/*RiftPotentialUnstableConstraints(Loads* loads){{{1*/
+int RiftPotentialUnstableConstraints(Loads* loads){
 
 	int			i;
@@ -349,2 +375,3 @@
 	return num_unstable_constraints;
 }
+/*}}}*/
