[cig-commits] r3950 - in long/3D/Gale/trunk/src/StgFEM: . SLE/SystemSetup/src SLE/SystemSetup/tests

walter at geodynamics.org walter at geodynamics.org
Thu Jul 6 02:08:22 PDT 2006


Author: walter
Date: 2006-07-06 02:08:22 -0700 (Thu, 06 Jul 2006)
New Revision: 3950

Modified:
   long/3D/Gale/trunk/src/StgFEM/
   long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/src/StiffnessMatrix.c
   long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/src/StiffnessMatrix.h
   long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/tests/testStiffnessMatrix-nonZeroCalculation-linkedDofs.c
   long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/tests/testStiffnessMatrix-nonZeroCalculation.c
Log:
 r666 at earth:  boo | 2006-07-06 02:04:20 -0700
  r659 at earth (orig r600):  PatrickSunter | 2006-07-03 21:06:15 -0700
  Adding a test to enable you to check that for a given global matrix,
  each element provides at least one non-zero entry
  (this replaces the check of each element having at least one int. point
  from every swarm, since this may not be the case under the new
  swarm integration approaches).
  
  By default this test isn't done to enable backward-compatibility
  (eg the compressibility matrix should allow non-zero element
  assembly if only some of the materials are compressible)
  and must be explicitly enabled in XML files.
  
 



Property changes on: long/3D/Gale/trunk/src/StgFEM
___________________________________________________________________
Name: svk:merge
   - 38867592-cf10-0410-9e16-a142ea72ac34:/cig:665
db209038-57f2-0310-97fa-b160e0ae9d04:/trunk:599
   + 38867592-cf10-0410-9e16-a142ea72ac34:/cig:666
db209038-57f2-0310-97fa-b160e0ae9d04:/trunk:600

Modified: long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/src/StiffnessMatrix.c
===================================================================
--- long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/src/StiffnessMatrix.c	2006-07-06 09:08:19 UTC (rev 3949)
+++ long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/src/StiffnessMatrix.c	2006-07-06 09:08:22 UTC (rev 3950)
@@ -90,10 +90,12 @@
 		NULL,
 		0,
 		False,
+		False,
 		NULL,
 		0 );
 }
 
+
 StiffnessMatrix* StiffnessMatrix_New(
 		Name                                             name,
 		void*                                            rowVariable,
@@ -102,6 +104,7 @@
 		Stg_Component*                                   applicationDepInfo,
 		Dimension_Index                                  dim,
 		Bool                                             isNonLinear,
+		Bool                                             allowZeroElementContributions,
 		void*                                            entryPoint_Register,
 		MPI_Comm                                         comm )
 {
@@ -126,10 +129,12 @@
 		applicationDepInfo,
 		dim,
 		isNonLinear,
+		allowZeroElementContributions,
 		entryPoint_Register,
 		comm );
 }
 
+
 StiffnessMatrix* _StiffnessMatrix_New(
 		SizeT                                            _sizeOfSelf,
 		Type                                             type,
@@ -151,6 +156,7 @@
 		Stg_Component*                                   applicationDepInfo,
 		Dimension_Index                                  dim,
 		Bool                                             isNonLinear,
+		Bool                                             allowZeroElementContributions,
 		void*                                            entryPoint_Register,
 		MPI_Comm                                         comm )
 {
@@ -179,7 +185,8 @@
 	self->_calculateNonZeroEntries = _calculateNonZeroEntries;
 	
 	if( initFlag ){
-		_StiffnessMatrix_Init( self, rowVariable, columnVariable, rhs, applicationDepInfo, dim, isNonLinear, entryPoint_Register, comm );
+		_StiffnessMatrix_Init( self, rowVariable, columnVariable, rhs, applicationDepInfo, dim,
+		isNonLinear, allowZeroElementContributions, entryPoint_Register, comm );
 	}
 	
 	return self;
@@ -193,6 +200,7 @@
 		Stg_Component*                                   applicationDepInfo,
 		Dimension_Index                                  dim,
 		Bool                                             isNonLinear,
+		Bool                                             allowZeroElementContributions,
 		void*                                            entryPoint_Register,
 		MPI_Comm                                         comm )
 {
@@ -218,6 +226,7 @@
 	self->comm = comm;
 	self->dim = dim;
 	self->isNonLinear = isNonLinear;
+	self->allowZeroElementContributions = allowZeroElementContributions;
 	
 	self->rowLocalSize = 0;
 	self->colLocalSize = 0;
@@ -284,6 +293,9 @@
 	Journal_Printf( stiffnessMatrixStream, "\trowLocalSize: %u\n", self->rowLocalSize );
 	Journal_Printf( stiffnessMatrixStream, "\tcolLocalSize: %u\n", self->colLocalSize );
 	Journal_Printf( stiffnessMatrixStream, "\tnonZeroCount: %u\n", self->nonZeroCount );
+	Journal_Printf( stiffnessMatrixStream, "\tisNonLinear: %s\n", StG_BoolToStringMap[self->isNonLinear] );
+	Journal_Printf( stiffnessMatrixStream, "\tallowZeroElementContributions: %s\n",
+		StG_BoolToStringMap[self->allowZeroElementContributions] );
 }
 
 
@@ -386,6 +398,7 @@
 	void*            entryPointRegister = NULL;
 	Dimension_Index  dim                = 0;
 	Bool             isNonLinear;
+	Bool             allowZeroElementContributions;
 	MPI_Comm         comm               = 0;
 	
 	rowVar  =  Stg_ComponentFactory_ConstructByKey(  cf,  self->name,  "RowVariable", FeVariable,  True  ) ;
@@ -402,8 +415,11 @@
 	assert( dim );
 
 	isNonLinear = Stg_ComponentFactory_GetBool( cf, self->name, "isNonLinear", False );
+
+	/* Default is to allow zero element contributions - to allow backward compatibility */
+	allowZeroElementContributions = Stg_ComponentFactory_GetBool( cf, self->name, "allowZeroElementContributions", True );
 	
-	comm = MPI_COMM_WORLD;
+	comm = rowVar->feMesh->layout->decomp->communicator;
 
 	_StiffnessMatrix_Init( 
 			self, 
@@ -413,6 +429,7 @@
 			applicationDepInfo, 
 			dim,
 			isNonLinear,
+			allowZeroElementContributions,
 			entryPointRegister, 
 			comm ); 
 }
@@ -915,6 +932,10 @@
 		elStiffMatBuildStart = MPI_Wtime();
 		StiffnessMatrix_AssembleElement( self, element_lI, sle, elStiffMatToAdd );
 		elStiffMatBuildTime += MPI_Wtime() - elStiffMatBuildStart;
+		if ( False == self->allowZeroElementContributions ) {
+			StiffnessMatrix_CheckElementAssembly( self, element_lI, elStiffMatToAdd, *totalDofsThisElement[ROW_VAR],
+				*totalDofsThisElement[COL_VAR] );
+		}	
 			
 		/* This loop is how we handle the possiblity of different row-column variables: if both variables are
 		 * the same, then numFeVars is set to 1 and the loop only progresses through once.
@@ -1303,8 +1324,7 @@
 	}
 }
 
-		
-void StiffnessMatrix_AssembleElement( void* stiffnessMatrix, Element_LocalIndex element_lI, SystemLinearEquations* sle, double** elStiffMatVecToAdd ) {
+void StiffnessMatrix_AssembleElement( void* stiffnessMatrix, Element_LocalIndex element_lI, SystemLinearEquations* sle, double** elStiffMatToAdd ) {
 	StiffnessMatrix*        self                      = (StiffnessMatrix*) stiffnessMatrix;
 	Index                   stiffnessMatrixTermCount  = Stg_ObjectList_Count( self->stiffnessMatrixTermList );
 	Index                   stiffnessMatrixTerm_I;
@@ -1314,10 +1334,44 @@
 		stiffnessMatrixTerm = (StiffnessMatrixTerm*)
 			Stg_ObjectList_At( self->stiffnessMatrixTermList, stiffnessMatrixTerm_I );
 
-		StiffnessMatrixTerm_AssembleElement( stiffnessMatrixTerm, self, element_lI, sle, elStiffMatVecToAdd );
+		StiffnessMatrixTerm_AssembleElement( stiffnessMatrixTerm, self, element_lI, sle, elStiffMatToAdd );
 	}
 }
 
+
+void StiffnessMatrix_CheckElementAssembly( 
+		void* stiffnessMatrix,
+		Element_LocalIndex element_lI,
+		double** elStiffMatToAdd,
+		Index elStiffMatToAddRowSize,
+		Index elStiffMatToAddColSize )
+{
+	StiffnessMatrix*  self = (StiffnessMatrix*)stiffnessMatrix;
+	Bool              atLeastOneNonZeroElementContributionEntry = False;
+	Index             elStiffMat_rowI = 0;
+	Index             elStiffMat_colI = 0;
+	Stream*           errorStream = Journal_Register( Error_Type, self->type );
+	
+	for ( elStiffMat_colI = 0; elStiffMat_colI < elStiffMatToAddColSize; elStiffMat_colI++ ) {
+		for ( elStiffMat_rowI = 0; elStiffMat_rowI < elStiffMatToAddColSize; elStiffMat_rowI++ ) {
+			if ( elStiffMatToAdd[elStiffMat_rowI][elStiffMat_colI] != 0.0 ) {
+				atLeastOneNonZeroElementContributionEntry = True;
+				break;
+			}	
+		}	
+		if ( atLeastOneNonZeroElementContributionEntry == True ) {
+			break;
+		}	
+	}
+
+	Journal_Firewall( atLeastOneNonZeroElementContributionEntry == True, errorStream,
+		"Error - in %s(): while assembling matrix \"%s\", for element %u - elStiffMatToAdd assembled at this "
+		"element is all zeros."
+		"Did you register a stiffnessMatrixTerm? Is there at least one integration point in this "
+		"element?\n", __func__, self->name, element_lI  );
+}
+
+
 void StiffnessMatrix_AddStiffnessMatrixTerm( void* stiffnessMatrix, StiffnessMatrixTerm* stiffnessMatrixTerm ) {
 	StiffnessMatrix*        self                 = (StiffnessMatrix*) stiffnessMatrix;
 

Modified: long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/src/StiffnessMatrix.h
===================================================================
--- long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/src/StiffnessMatrix.h	2006-07-06 09:08:19 UTC (rev 3949)
+++ long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/src/StiffnessMatrix.h	2006-07-06 09:08:22 UTC (rev 3950)
@@ -84,6 +84,7 @@
 		Matrix*                                           matrix;                         \
 		Stg_Component*                                    applicationDepInfo;             \
 		Bool                                              isNonLinear;                    \
+		Bool                                              allowZeroElementContributions;  \
 		EntryPoint_Register*                              entryPoint_Register;            \
 		Stg_ObjectList*                                   stiffnessMatrixTermList;        \
 		FeEntryPoint*                                     assembleStiffnessMatrix;        \
@@ -111,6 +112,7 @@
 		Stg_Component*                                   applicationDepInfo,
 		Dimension_Index                                  dim,
 		Bool                                             isNonLinear,
+		Bool                                             allowZeroElementContributions,
 		void*                                            entryPoint_Register,
 		MPI_Comm                                         comm );
 
@@ -136,6 +138,7 @@
 		Stg_Component*                                   applicationDepInfo,
 		Dimension_Index                                  dim,
 		Bool                                             isNonLinear,
+		Bool                                             allowZeroElementContributions,
 		void*                                            entryPoint_Register,
 		MPI_Comm                                         comm );		
 		
@@ -147,6 +150,7 @@
 		Stg_Component*                                   applicationDepInfo,
 		Dimension_Index                                  dim,
 		Bool                                             isNonLinear,
+		Bool                                             allowZeroElementContributions,
 		void*                                            entryPoint_Register,
 		MPI_Comm                                         comm );
 	
@@ -248,6 +252,16 @@
 		((stiffnessMatrix)->isNonLinear = True)
 
 	void StiffnessMatrix_AssembleElement(void* stiffnessMatrix, Element_LocalIndex element_lI, SystemLinearEquations* sle, double** elStiffMatVecToAdd);
+
+
+	/** Utility function to check that the element assembly just completeed has worked ok */
+	void StiffnessMatrix_CheckElementAssembly( 
+		void* stiffnessMatrix,
+		Element_LocalIndex element_lI,
+		double** elStiffMatToAdd,
+		Index elStiffMatToAddRowSize,
+		Index elStiffMatToAddColSize );
+	
 	void StiffnessMatrix_AddStiffnessMatrixTerm( void* stiffnessMatrixVector, StiffnessMatrixTerm* stiffnessMatrixTerm ) ;
 	
 #endif /* __StG_FEM_SLE_SystemSetup_StiffnessMatrix_h__ */

Modified: long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/tests/testStiffnessMatrix-nonZeroCalculation-linkedDofs.c
===================================================================
--- long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/tests/testStiffnessMatrix-nonZeroCalculation-linkedDofs.c	2006-07-06 09:08:19 UTC (rev 3949)
+++ long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/tests/testStiffnessMatrix-nonZeroCalculation-linkedDofs.c	2006-07-06 09:08:22 UTC (rev 3950)
@@ -233,7 +233,7 @@
 	
 	/* Create a Stiffness Matrix to use for testing */
 	fVector = ForceVector_New( "F", feVariable, numDims, entryPoint_Register, CommWorld );	
-	kMatrix = StiffnessMatrix_New( "K", feVariable, feVariable, fVector, NULL, numDims, False,
+	kMatrix = StiffnessMatrix_New( "K", feVariable, feVariable, fVector, NULL, numDims, False, True,
 		entryPoint_Register, CommWorld );
 	
 	/* Build and initialise system */

Modified: long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/tests/testStiffnessMatrix-nonZeroCalculation.c
===================================================================
--- long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/tests/testStiffnessMatrix-nonZeroCalculation.c	2006-07-06 09:08:19 UTC (rev 3949)
+++ long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/tests/testStiffnessMatrix-nonZeroCalculation.c	2006-07-06 09:08:22 UTC (rev 3950)
@@ -229,7 +229,7 @@
 	
 	/* Create a Stiffness Matrix to use for testing */
 	fVector = ForceVector_New( "F", feVariable, numDims, entryPoint_Register, CommWorld );	
-	kMatrix = StiffnessMatrix_New( "K", feVariable, feVariable, fVector, NULL, numDims, False,
+	kMatrix = StiffnessMatrix_New( "K", feVariable, feVariable, fVector, NULL, numDims, False, True,
 		entryPoint_Register, CommWorld );
 	
 	/* Build and initialise system */



More information about the cig-commits mailing list