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

walter at geodynamics.org walter at geodynamics.org
Tue Mar 13 11:13:14 PDT 2007


Author: walter
Date: 2007-03-13 11:13:13 -0700 (Tue, 13 Mar 2007)
New Revision: 6243

Added:
   long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/src/InsertBCs.c
   long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/src/InsertBCs.h
   long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/src/UnifyDiagBCs.c
   long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/src/UnifyDiagBCs.h
Modified:
   long/3D/Gale/trunk/src/StgFEM/
   long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/src/Assembler.c
   long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/src/Assembler.h
   long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/src/CorrectRHS.c
   long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/src/ForceVector.c
   long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/src/ForceVector.h
   long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/src/Init.c
   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/src/SystemSetup.h
   long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/src/ZeroBCs.c
   long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/src/ZeroBCs.h
   long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/src/types.h
Log:
 r1047 at earth (orig r778):  LukeHodkinson | 2007-03-09 14:49:25 -0800
 * Adding some more helper classes for handling BC corrections.
 * Finishing off the update to the code that keeps BCs
   in the system.
 



Property changes on: long/3D/Gale/trunk/src/StgFEM
___________________________________________________________________
Name: svk:merge
   - 38867592-cf10-0410-9e16-a142ea72ac34:/cig:880
db209038-57f2-0310-97fa-b160e0ae9d04:/branches/decomp3d:776
db209038-57f2-0310-97fa-b160e0ae9d04:/trunk:669
   + 38867592-cf10-0410-9e16-a142ea72ac34:/cig:880
db209038-57f2-0310-97fa-b160e0ae9d04:/branches/decomp3d:778
db209038-57f2-0310-97fa-b160e0ae9d04:/trunk:669

Modified: long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/src/Assembler.c
===================================================================
--- long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/src/Assembler.c	2007-03-13 18:13:08 UTC (rev 6242)
+++ long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/src/Assembler.c	2007-03-13 18:13:13 UTC (rev 6243)
@@ -241,6 +241,7 @@
 	unsigned		nColElNodes, *colElNodes;
 	int			rowEq, colEq;
 	unsigned		rowInd, colInd;
+	unsigned		varInd;
 	unsigned		n_i, n_j, dof_i, dof_j;
 
 	assert( self && Stg_CheckType( self, Assembler ) );
@@ -277,7 +278,8 @@
 			self->rowNodeInd = rowElNodes[n_i];
 			self->rowDofInd = dof_i;
 			self->rowEq = rowEq;
-			if( VariableCondition_IsCondition( rowVar->bcs, rowElNodes[n_i], dof_i ) ) {
+			varInd = rowDofs->varIndices[rowElNodes[n_i]][dof_i];
+			if( rowVar->bcs && VariableCondition_IsCondition( rowVar->bcs, rowElNodes[n_i], varInd ) ) {
 				if( !self->rowRestrictedFunc || !self->rowRestrictedFunc( self ) )
 					continue;
 			}
@@ -297,18 +299,68 @@
 					self->colNodeInd = colElNodes[n_j];
 					self->colDofInd = dof_j;
 					self->colEq = colEq;
-					if( VariableCondition_IsCondition( rowVar->bcs, rowElNodes[n_i], dof_i ) ) {
-						if( self->rowRestrictedFunc )
-							self->rowRestrictedFunc( self );
+					varInd = colDofs->varIndices[colElNodes[n_j]][dof_j];
+					if( colVar->bcs && VariableCondition_IsCondition( colVar->bcs, colElNodes[n_j], varInd ) ) {
+						if( self->columnRestrictedFunc )
+							self->columnRestrictedFunc( self );
 					}
-					else if( self->rowUnrestrictedFunc )
-						self->rowUnrestrictedFunc( self );
+					else if( self->columnUnrestrictedFunc )
+						self->columnUnrestrictedFunc( self );
 				}
 			}
 		}
 	}
 }
 
+void Assembler_LoopMatrixDiagonal( void* assembler ) {
+	Assembler*		self = (Assembler*)assembler;
+	unsigned		nDims;
+	FeVariable		*rowVar;
+	FeMesh			*rowMesh;
+	FeEquationNumber	*rowEqNum;
+	DofLayout		*rowDofs;
+	unsigned		nRowDofs;
+	unsigned		nRowNodes;
+	int			rowEq;
+	unsigned		varInd;
+	unsigned		n_i, dof_i;
+
+	assert( self && Stg_CheckType( self, Assembler ) );
+	assert( self->rowVar && self->colVar );
+	assert( self->rowVar == self->colVar );
+
+	rowVar = self->rowVar;
+	rowEqNum = rowVar->eqNum;			assert( rowEqNum );
+	rowMesh = rowVar->feMesh;
+	rowDofs = rowVar->dofLayout;			assert( rowDofs );
+	nDims = Mesh_GetDimSize( rowMesh );		assert( nDims );
+	nRowNodes = FeMesh_GetNodeLocalSize( rowMesh );
+	assert( rowEqNum->destinationArray );
+	assert( rowDofs->dofCounts );
+
+	for( n_i = 0; n_i < nRowNodes; n_i++ ) {
+		assert( rowEqNum->destinationArray[n_i] );
+		nRowDofs = rowDofs->dofCounts[n_i];
+		for( dof_i = 0; dof_i < nRowDofs; dof_i++ ) {
+			rowEq = rowEqNum->destinationArray[n_i][dof_i];
+
+			self->rowNodeInd = n_i;
+			self->rowDofInd = dof_i;
+			self->rowEq = rowEq;
+			self->colNodeInd = n_i;
+			self->colDofInd = dof_i;
+			self->colEq = rowEq;
+			varInd = rowDofs->varIndices[n_i][dof_i];
+			if( rowVar->bcs && VariableCondition_IsCondition( rowVar->bcs, n_i, varInd ) ) {
+				if( self->columnRestrictedFunc )
+					self->columnRestrictedFunc( self );
+			}
+			else if( self->columnUnrestrictedFunc )
+				self->columnUnrestrictedFunc( self );
+		}
+	}
+}
+
 #if 0
 void Assembler_LoopVectorElement( void* assembler, unsigned element ) {
 	Assembler*		self = (Assembler*)assembler;

Modified: long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/src/Assembler.h
===================================================================
--- long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/src/Assembler.h	2007-03-13 18:13:08 UTC (rev 6242)
+++ long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/src/Assembler.h	2007-03-13 18:13:13 UTC (rev 6243)
@@ -126,7 +126,10 @@
 	void Assembler_SetBCCorrectionArray( void* assembler, double* bcCorrect );
 
 	void Assembler_LoopMatrixElement( void* assembler, unsigned element );
+	void Assembler_LoopMatrixDiagonal( void* assembler );
 
+	#define Assembler_LoopVector Assembler_LoopMatrixDiagonal
+
 	/*--------------------------------------------------------------------------------------------------------------------------
 	** Private Member functions
 	*/

Modified: long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/src/CorrectRHS.c
===================================================================
--- long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/src/CorrectRHS.c	2007-03-13 18:13:08 UTC (rev 6242)
+++ long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/src/CorrectRHS.c	2007-03-13 18:13:13 UTC (rev 6243)
@@ -119,11 +119,11 @@
 	rowInd = ((CorrectRHS*)assembler)->rowInd;
 	colInd = ((CorrectRHS*)assembler)->colInd;
 	if( !((CorrectRHS*)assembler)->trans ) {
-		((CorrectRHS*)assembler)->bcCorrects[rowInd] = bc * 
+		((CorrectRHS*)assembler)->bcCorrects[rowInd] -= bc * 
 			((CorrectRHS*)assembler)->elStiffMat[rowInd][colInd];
 	}
 	else {
-		((CorrectRHS*)assembler)->bcCorrects[rowInd] = bc * 
+		((CorrectRHS*)assembler)->bcCorrects[rowInd] -= bc * 
 			((CorrectRHS*)assembler)->elStiffMat[colInd][rowInd];
 	}
 }

Modified: long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/src/ForceVector.c
===================================================================
--- long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/src/ForceVector.c	2007-03-13 18:13:08 UTC (rev 6242)
+++ long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/src/ForceVector.c	2007-03-13 18:13:13 UTC (rev 6243)
@@ -55,6 +55,8 @@
 #include <assert.h>
 #include <string.h>
 #include "EntryPoint.h"
+#include "Assembler.h"
+#include "InsertBCs.h"
 
 /* Textual name of this class */
 const Type ForceVector_Type = "ForceVector";
@@ -64,92 +66,92 @@
 
 void* _ForceVector_DefaultNew( Name name ) {
 	return _ForceVector_New( 
-			sizeof(ForceVector), 
-			ForceVector_Type, 
-			_ForceVector_Delete,
-			_ForceVector_Print,
-			_ForceVector_Copy,
-			_ForceVector_DefaultNew, 
-			_ForceVector_Construct,
-			_ForceVector_Build, 
-			_ForceVector_Initialise,
-			_ForceVector_Execute, 
-			_ForceVector_Destroy,
-			name,
-			False,
-			NULL,
-			0,
-			NULL,
-			MPI_COMM_WORLD );
+		sizeof(ForceVector), 
+		ForceVector_Type, 
+		_ForceVector_Delete,
+		_ForceVector_Print,
+		_ForceVector_Copy,
+		_ForceVector_DefaultNew, 
+		_ForceVector_Construct,
+		_ForceVector_Build, 
+		_ForceVector_Initialise,
+		_ForceVector_Execute, 
+		_ForceVector_Destroy,
+		name,
+		False,
+		NULL,
+		0,
+		NULL,
+		MPI_COMM_WORLD );
 }
 
 
 ForceVector* ForceVector_New(
-		Name                                  name,
-		FeVariable*                           feVariable,
-		Dimension_Index                       dim,
-		void*                                 entryPoint_Register,
-		MPI_Comm                              comm )		
+	Name                                  name,
+	FeVariable*                           feVariable,
+	Dimension_Index                       dim,
+	void*                                 entryPoint_Register,
+	MPI_Comm                              comm )		
 {
 	return _ForceVector_New( 
-			sizeof(ForceVector), 
-			ForceVector_Type, 
-			_ForceVector_Delete,
-			_ForceVector_Print,
-			_ForceVector_Copy,
-			_ForceVector_DefaultNew, 
-			_ForceVector_Construct,
-			_ForceVector_Build, 
-			_ForceVector_Initialise,
-			_ForceVector_Execute, 
-			_ForceVector_Destroy,
-			name,
-			True,
-			feVariable,
-			dim,
-			entryPoint_Register,
-			comm );
+		sizeof(ForceVector), 
+		ForceVector_Type, 
+		_ForceVector_Delete,
+		_ForceVector_Print,
+		_ForceVector_Copy,
+		_ForceVector_DefaultNew, 
+		_ForceVector_Construct,
+		_ForceVector_Build, 
+		_ForceVector_Initialise,
+		_ForceVector_Execute, 
+		_ForceVector_Destroy,
+		name,
+		True,
+		feVariable,
+		dim,
+		entryPoint_Register,
+		comm );
 }
 
 ForceVector* _ForceVector_New( 
-		SizeT                                 _sizeOfSelf,
-		Type                                  type,
-		Stg_Class_DeleteFunction*             _delete,
-		Stg_Class_PrintFunction*              _print,
-		Stg_Class_CopyFunction*               _copy, 
-		Stg_Component_DefaultConstructorFunction* _defaultConstructor,
-		Stg_Component_ConstructFunction*      _construct,
-		Stg_Component_BuildFunction*          _build,
-		Stg_Component_InitialiseFunction*     _initialise,
-		Stg_Component_ExecuteFunction*        _execute,
-		Stg_Component_DestroyFunction*        _destroy,
-		Name                                  name,
-		Bool                                  initFlag,
-		FeVariable*                           feVariable,
-		Dimension_Index                       dim,
-		void*                                 entryPoint_Register,
-		MPI_Comm                              comm )
+	SizeT                                 _sizeOfSelf,
+	Type                                  type,
+	Stg_Class_DeleteFunction*             _delete,
+	Stg_Class_PrintFunction*              _print,
+	Stg_Class_CopyFunction*               _copy, 
+	Stg_Component_DefaultConstructorFunction* _defaultConstructor,
+	Stg_Component_ConstructFunction*      _construct,
+	Stg_Component_BuildFunction*          _build,
+	Stg_Component_InitialiseFunction*     _initialise,
+	Stg_Component_ExecuteFunction*        _execute,
+	Stg_Component_DestroyFunction*        _destroy,
+	Name                                  name,
+	Bool                                  initFlag,
+	FeVariable*                           feVariable,
+	Dimension_Index                       dim,
+	void*                                 entryPoint_Register,
+	MPI_Comm                              comm )
 {
 	ForceVector*		self;
 	
 	/* Allocate memory */
 	assert( _sizeOfSelf >= sizeof(ForceVector) );
 	self = (ForceVector*)_SolutionVector_New( 
-			_sizeOfSelf,
-			type, 
-			_delete,
-			_print,
-			_copy,
-			_defaultConstructor,
-			_construct,
-			_build,
-			_initialise,
-			_execute,
-			_destroy,
-			name,
-			initFlag,
-			comm,
-			feVariable );
+		_sizeOfSelf,
+		type, 
+		_delete,
+		_print,
+		_copy,
+		_defaultConstructor,
+		_construct,
+		_build,
+		_initialise,
+		_execute,
+		_destroy,
+		name,
+		initFlag,
+		comm,
+		feVariable );
 	
 	if ( initFlag ) {
 		_ForceVector_Init( self, dim, entryPoint_Register );
@@ -160,9 +162,9 @@
 
 
 void _ForceVector_Init(
-		void*                                     forceVector,
-		Dimension_Index                           dim,
-		EntryPoint_Register*                      entryPoint_Register )
+	void*                                     forceVector,
+	Dimension_Index                           dim,
+	EntryPoint_Register*                      entryPoint_Register )
 {
 	ForceVector* self = (ForceVector*)  forceVector;
 	
@@ -177,13 +179,16 @@
 	/* Create Entry Point for assembleForceVector */
 	Stg_asprintf( &self->_assembleForceVectorEPName, "%s-%s", self->name, ForceVector_assembleForceVectorStr );
 	self->assembleForceVector = FeEntryPoint_New( self->_assembleForceVectorEPName,
-		FeEntryPoint_AssembleForceVector_CastType );
+						      FeEntryPoint_AssembleForceVector_CastType );
 	EntryPoint_Register_Add( self->entryPoint_Register, self->assembleForceVector );	
 
 	/* Add default hook to assembleForceVector entry point */
 	EP_ReplaceAll( self->assembleForceVector, ForceVector_GlobalAssembly_General );
 
 	self->forceTermList = Stg_ObjectList_New();
+
+	self->bcAsm = InsertBCs_New();
+	Assembler_SetVariables( self->bcAsm, self->feVariable, NULL );
 }
 
 
@@ -337,7 +342,7 @@
 	ForceVector* self = (ForceVector*)forceVector;
 	
 	Journal_DPrintf( self->debug, "In %s - for vector \"%s\" - calling the \"%s\" E.P.\n", __func__, self->name,
-		self->assembleForceVector->name );
+			 self->assembleForceVector->name );
 
 	/* Call the Entry point directly from the base class */
 	/* Note that it may be empty: this is deliberate. */
@@ -352,10 +357,10 @@
 
 
 void ForceVector_PrintElementForceVector(
-		ForceVector* self,
-		Element_LocalIndex element_lI,
-		Dof_EquationNumber** elementLM,
-		double* elForceVecToAdd )
+	ForceVector* self,
+	Element_LocalIndex element_lI,
+	Dof_EquationNumber** elementLM,
+	double* elForceVecToAdd )
 {
 	DofLayout*		dofLayout = self->feVariable->dofLayout;
 	FeMesh*			feMesh = self->feVariable->feMesh;
@@ -375,9 +380,9 @@
 			vec_I = node_I * dofsPerNode + dof_I;
 
 			Journal_DPrintf( self->debug, "Entry[%d][%d] (LM (%4d)) = %.3f\n",
-				node_I, dof_I,
-				elementLM[node_I][dof_I],
-				elForceVecToAdd[vec_I] ); 
+					 node_I, dof_I,
+					 elementLM[node_I][dof_I],
+					 elForceVecToAdd[vec_I] ); 
 		}			
 	}
 }
@@ -403,87 +408,92 @@
 	
 	Stream_IndentBranch( StgFEM_Debug );
 	
-	if ( Stg_ObjectList_Count( self->forceTermList ) == 0 ) {
-		Journal_DPrintf( self->debug, "No ForceTerms registered - returning.\n" );
-		Stream_UnIndentBranch( StgFEM_Debug );
-		return;
-	}
+	if ( Stg_ObjectList_Count( self->forceTermList ) > 0 ) {
+		elementLocalCount = FeMesh_GetElementLocalSize( feVar->feMesh );
 
-	elementLocalCount = FeMesh_GetElementLocalSize( feVar->feMesh );
-
-	/* Initialise Vector */
-	outputInterval = (int)( (outputPercentage/100.0)*(double)(elementLocalCount) );
-	if( outputInterval == 0 ) { outputInterval = elementLocalCount; }
+		/* Initialise Vector */
+		outputInterval = (int)( (outputPercentage/100.0)*(double)(elementLocalCount) );
+		if( outputInterval == 0 ) { outputInterval = elementLocalCount; }
 	
-	for( element_lI = 0; element_lI < elementLocalCount; element_lI++ ) {  
-		unsigned	nInc, *inc;
+		for( element_lI = 0; element_lI < elementLocalCount; element_lI++ ) {  
+			unsigned	nInc, *inc;
 		
-		FeMesh_GetElementNodes( feVar->feMesh, element_lI, &nInc, &inc );
-		nodeCountCurrElement = nInc;
-		/* Get the local node ids */
-		nodeIdsInCurrElement = inc;
+			FeMesh_GetElementNodes( feVar->feMesh, element_lI, &nInc, &inc );
+			nodeCountCurrElement = nInc;
+			/* Get the local node ids */
+			nodeIdsInCurrElement = inc;
 
-		/* Set value of elementLM: will automatically just index into global LM table if built */
-		elementLM = FeEquationNumber_BuildOneElementLocationMatrix( feVar->eqNum, element_lI );
+			/* Set value of elementLM: will automatically just index into global LM table if built */
+			elementLM = FeEquationNumber_BuildOneElementLocationMatrix( feVar->eqNum, element_lI );
 
-		/* work out number of dofs at the node, using LM */
-		/* Since: Number of entries in LM table for this element = (by defn.) Number of dofs this element */
-		dofCountLastNode = feVar->dofLayout->dofCounts[nodeIdsInCurrElement[nodeCountCurrElement-1]]; 
-		totalDofsThisElement = &elementLM[nodeCountCurrElement-1][dofCountLastNode-1] - &elementLM[0][0] + 1;
+			/* work out number of dofs at the node, using LM */
+			/* Since: Number of entries in LM table for this element = (by defn.) Number of dofs this element */
+			dofCountLastNode = feVar->dofLayout->dofCounts[nodeIdsInCurrElement[nodeCountCurrElement-1]]; 
+			totalDofsThisElement = &elementLM[nodeCountCurrElement-1][dofCountLastNode-1] - &elementLM[0][0] + 1;
 
-		if ( totalDofsThisElement > totalDofsPrevElement ) {
-			if (elForceVecToAdd) Memory_Free( elForceVecToAdd );
-			Journal_DPrintfL( self->debug, 2, "Reallocating elForceVecToAdd to size %d\n", totalDofsThisElement );
-			elForceVecToAdd = Memory_Alloc_Array( double, totalDofsThisElement, "elForceVecToAdd" );
-		}
+			if ( totalDofsThisElement > totalDofsPrevElement ) {
+				if (elForceVecToAdd) Memory_Free( elForceVecToAdd );
+				Journal_DPrintfL( self->debug, 2, "Reallocating elForceVecToAdd to size %d\n", totalDofsThisElement );
+				elForceVecToAdd = Memory_Alloc_Array( double, totalDofsThisElement, "elForceVecToAdd" );
+			}
 
-		/* Initialise Values to Zero */
-		memset( elForceVecToAdd, 0, totalDofsThisElement * sizeof(double) );
+			/* Initialise Values to Zero */
+			memset( elForceVecToAdd, 0, totalDofsThisElement * sizeof(double) );
 		
-		/* Assemble this element's element force vector: going through each force term in list */
-		ForceVector_AssembleElement( self, element_lI, elForceVecToAdd );
+			/* Assemble this element's element force vector: going through each force term in list */
+			ForceVector_AssembleElement( self, element_lI, elForceVecToAdd );
 
 /*
-		#if DEBUG
-		if ( Stream_IsPrintableLevel( self->debug, 3 ) ) {
-			Journal_DPrintf( self->debug, "Handling Element %d:\n", element_lI );
-			FeEquationNumber_PrintElementLocationMatrix( feVar->eqNum, elementLM,
-				element_lI, self->debug );
+  #if DEBUG
+  if ( Stream_IsPrintableLevel( self->debug, 3 ) ) {
+  Journal_DPrintf( self->debug, "Handling Element %d:\n", element_lI );
+  FeEquationNumber_PrintElementLocationMatrix( feVar->eqNum, elementLM,
+  element_lI, self->debug );
 				
-			Journal_DPrintf( self->debug, "El force Vec about to be added:\n" );
-			ForceVector_PrintElementForceVector( self, element_lI, elementLM, elForceVecToAdd );
-		}	
-		#endif
+  Journal_DPrintf( self->debug, "El force Vec about to be added:\n" );
+  ForceVector_PrintElementForceVector( self, element_lI, elementLM, elForceVecToAdd );
+  }	
+  #endif
 */
 
-		/* Ok, assemble into global matrix */
-		Vector_AddEntries( self->vector, totalDofsThisElement, (Index*)(elementLM[0]), elForceVecToAdd );
+			/* Ok, assemble into global matrix */
+			Vector_AddEntries( self->vector, totalDofsThisElement, (Index*)(elementLM[0]), elForceVecToAdd );
 
-		#if DEBUG
-		if( element_lI % outputInterval == 0 ) {
-			Journal_DPrintfL( self->debug, 2, "done %d percent of global force vector assembly (general) \n",
-				(int)(100.0*((double)element_lI/(double)elementLocalCount)) );
+#if DEBUG
+			if( element_lI % outputInterval == 0 ) {
+				Journal_DPrintfL( self->debug, 2, "done %d percent of global force vector assembly (general) \n",
+						  (int)(100.0*((double)element_lI/(double)elementLocalCount)) );
+			}
+#endif
+
+			/* Cleanup: If we haven't built the big LM for all elements, free the temporary one */
+			if ( False == feVar->eqNum->locationMatrixBuilt ) {
+				Memory_Free( elementLM );
+			}
+			totalDofsPrevElement = totalDofsThisElement;
 		}
-		#endif
 
-		/* Cleanup: If we haven't built the big LM for all elements, free the temporary one */
-		if ( False == feVar->eqNum->locationMatrixBuilt ) {
-			Memory_Free( elementLM );
-		}
-		totalDofsPrevElement = totalDofsThisElement;
+		Memory_Free( elForceVecToAdd );
 	}
+	else {
+		Journal_DPrintf( self->debug, "No ForceTerms registered - returning.\n" );
+	}
 
-	Memory_Free( elForceVecToAdd );
+	/* If we're keeping BCs, insert them into the force vector. */
+	if( !feVar->eqNum->removeBCs ) {
+		InsertBCs_SetVector( self->bcAsm, self->vector );
+		Assembler_LoopVector( self->bcAsm );
+	}
 
 	Vector_AssemblyBegin( self->vector );
 	Vector_AssemblyEnd( self->vector ); 
 
-	#if DEBUG
+#if DEBUG
 	if ( Stream_IsPrintableLevel( self->debug, 3 ) ) {
 		Journal_DPrintf( self->debug, "Completely built vector %s is:\n", self->name );
 		Vector_View( self->vector, self->debug );
 	}
-	#endif
+#endif
 
 	Stream_UnIndentBranch( StgFEM_Debug );
 }

Modified: long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/src/ForceVector.h
===================================================================
--- long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/src/ForceVector.h	2007-03-13 18:13:08 UTC (rev 6242)
+++ long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/src/ForceVector.h	2007-03-13 18:13:13 UTC (rev 6243)
@@ -71,6 +71,7 @@
 		Name                                      _assembleForceVectorEPName; \
 		Stg_ObjectList*                           forceTermList;                             \
 		Stg_Component*                            applicationDepExtraInfo; /**< Default is NULL: passed to elForceVec during assembly */\
+		InsertBCs*				bcAsm;
 	
 	struct ForceVector { __ForceVector };
 	

Modified: long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/src/Init.c
===================================================================
--- long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/src/Init.c	2007-03-13 18:13:08 UTC (rev 6242)
+++ long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/src/Init.c	2007-03-13 18:13:13 UTC (rev 6243)
@@ -78,6 +78,11 @@
 	RegisterParent( ForceVector_Type,              SolutionVector_Type );
 	RegisterParent( ForceTerm_Type,                Stg_Component_Type );
 	RegisterParent( PETScShellMatrix_Type,         PETScMatrix_Type );
+	RegisterParent( Assembler_Type, Stg_Class_Type );
+	RegisterParent( ZeroBCs_Type, Assembler_Type );
+	RegisterParent( CorrectRHS_Type, Assembler_Type );
+	RegisterParent( UnifyDiagBCs_Type, Assembler_Type );
+	RegisterParent( InsertBCs_Type, Assembler_Type );
 	
 	RegisterParent( FiniteElementContext_Type,     DiscretisationContext_Type );
 

Added: long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/src/InsertBCs.c
===================================================================
--- long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/src/InsertBCs.c	2007-03-13 18:13:08 UTC (rev 6242)
+++ long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/src/InsertBCs.c	2007-03-13 18:13:13 UTC (rev 6243)
@@ -0,0 +1,137 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+**
+** Copyright (C), 2003, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street, Melbourne, 3053, Australia.
+**
+** Authors:
+**	Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
+**	Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
+**	Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
+**	Siew-Ching Tan, Software Engineer, VPAC. (siew at vpac.org)
+**	Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
+**	Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
+**
+**  This library is free software; you can redistribute it and/or
+**  modify it under the terms of the GNU Lesser General Public
+**  License as published by the Free Software Foundation; either
+**  version 2.1 of the License, or (at your option) any later version.
+**
+**  This library is distributed in the hope that it will be useful,
+**  but WITHOUT ANY WARRANTY; without even the implied warranty of
+**  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+**  Lesser General Public License for more details.
+**
+**  You should have received a copy of the GNU Lesser General Public
+**  License along with this library; if not, write to the Free Software
+**  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+**
+** $Id: InsertBCs.c 3584 2006-05-16 11:11:07Z PatrickSunter $
+**
+**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <assert.h>
+
+#include <mpi.h>
+#include "StGermain/StGermain.h"
+#include "Discretisation/Discretisation.h"
+#include "SLE/LinearAlgebra/LinearAlgebra.h"
+#include "SystemSetup.h"
+
+
+/* Textual name of this class */
+const Type InsertBCs_Type = "InsertBCs";
+
+
+/*----------------------------------------------------------------------------------------------------------------------------------
+** Constructors
+*/
+
+InsertBCs* InsertBCs_New() {
+	return _InsertBCs_New( sizeof(InsertBCs), 
+				  InsertBCs_Type, 
+				  _InsertBCs_Delete, 
+				  _InsertBCs_Print, 
+				  NULL, 
+				  NULL, 
+				  NULL, 
+				  InsertBCs_ColRestricted, 
+				  NULL );
+}
+
+InsertBCs* _InsertBCs_New( INSERTBCS_DEFARGS ) {
+	InsertBCs*	self;
+
+	/* Allocate memory */
+	assert( sizeOfSelf >= sizeof(InsertBCs) );
+	self = (InsertBCs*)_Assembler_New( ASSEMBLER_PASSARGS );
+
+	/* Virtual info */
+
+	/* InsertBCs info */
+	_InsertBCs_Init( self );
+
+	return self;
+}
+
+void _InsertBCs_Init( InsertBCs* self ) {
+	assert( self && Stg_CheckType( self, InsertBCs ) );
+}
+
+
+/*----------------------------------------------------------------------------------------------------------------------------------
+** Virtual functions
+*/
+
+void _InsertBCs_Delete( void* assembler ) {
+	InsertBCs*	self = (InsertBCs*)assembler;
+
+	assert( self && Stg_CheckType( self, InsertBCs ) );
+
+	/* Delete the parent. */
+	_Assembler_Delete( self );
+}
+
+void _InsertBCs_Print( void* assembler, Stream* stream ) {
+	InsertBCs*	self = (InsertBCs*)assembler;
+	Stream* 	assemblerStream;
+	
+	/* Set the Journal for printing informations */
+	assemblerStream = Journal_Register( InfoStream_Type, "InsertBCsStream" );
+
+	assert( self && Stg_CheckType( self, InsertBCs ) );
+
+	/* Print parent */
+	Journal_Printf( stream, "InsertBCs (ptr): (%p)\n", self );
+	_Assembler_Print( self, stream );
+}
+
+void InsertBCs_ColRestricted( void* assembler ) {
+	unsigned	rowEq;
+	double		bc;
+
+	bc = DofLayout_GetValueDouble( ((CorrectRHS*)assembler)->rowVar->dofLayout, 
+				       ((CorrectRHS*)assembler)->rowNodeInd, 
+				       ((CorrectRHS*)assembler)->rowDofInd );
+	rowEq = ((InsertBCs*)assembler)->rowEq;
+	Vector_InsertEntries( ((InsertBCs*)assembler)->vector, 1, &rowEq, &bc );
+}
+
+
+/*--------------------------------------------------------------------------------------------------------------------------
+** Public Functions
+*/
+
+void InsertBCs_SetVector( void* assembler, Vector* vector ) {
+	InsertBCs*	self = (InsertBCs*)assembler;
+
+	assert( self && Stg_CheckType( self, InsertBCs ) );
+
+	self->vector = vector;
+}
+
+
+/*----------------------------------------------------------------------------------------------------------------------------------
+** Private Functions
+*/

Added: long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/src/InsertBCs.h
===================================================================
--- long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/src/InsertBCs.h	2007-03-13 18:13:08 UTC (rev 6242)
+++ long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/src/InsertBCs.h	2007-03-13 18:13:13 UTC (rev 6243)
@@ -0,0 +1,94 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+**
+** Copyright (C), 2003, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street, Melbourne, 3053, Australia.
+**
+** Authors:
+**	Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
+**	Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
+**	Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
+**	Siew-Ching Tan, Software Engineer, VPAC. (siew at vpac.org)
+**	Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
+**	Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
+**
+**  This library is free software; you can redistribute it and/or
+**  modify it under the terms of the GNU Lesser General Public
+**  License as published by the Free Software Foundation; either
+**  version 2.1 of the License, or (at your option) any later version.
+**
+**  This library is distributed in the hope that it will be useful,
+**  but WITHOUT ANY WARRANTY; without even the implied warranty of
+**  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+**  Lesser General Public License for more details.
+**
+**  You should have received a copy of the GNU Lesser General Public
+**  License along with this library; if not, write to the Free Software
+**  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+**
+*/
+/** \file
+**  Role:
+**
+** Assumptions:
+**
+** Invariants:
+**
+** Comments:
+**
+** $Id: InsertBCs.h 3584 2006-05-16 11:11:07Z PatrickSunter $
+**
+**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+
+#ifndef __StgFEM_SLE_SystemSetup_InsertBCs_h__
+#define __StgFEM_SLE_SystemSetup_InsertBCs_h__
+
+	/** Textual name of this class */
+	extern const Type InsertBCs_Type;
+
+	/** Virtual function types */
+
+	/** InsertBCs class contents */
+	#define __InsertBCs		\
+		/* General info */	\
+		__Assembler		\
+					\
+		/* Virtual info */	\
+					\
+		/* InsertBCs info */	\
+		Vector*		vector;
+
+	struct InsertBCs { __InsertBCs };
+
+	/*--------------------------------------------------------------------------------------------------------------------------
+	** Constructors
+	*/
+
+	#define INSERTBCS_DEFARGS \
+		ASSEMBLER_DEFARGS
+
+	#define INSERTBCS_PASSARGS \
+		ASSEMBLER_PASSARGS
+
+	InsertBCs* InsertBCs_New();
+	InsertBCs* _InsertBCs_New( INSERTBCS_DEFARGS );
+	void _InsertBCs_Init( InsertBCs* self );
+
+	/*--------------------------------------------------------------------------------------------------------------------------
+	** Virtual functions
+	*/
+
+	void _InsertBCs_Delete( void* assembler );
+	void _InsertBCs_Print( void* assembler, Stream* stream );
+
+	void InsertBCs_ColRestricted( void* assembler );
+
+	/*--------------------------------------------------------------------------------------------------------------------------
+	** Public functions
+	*/
+
+	void InsertBCs_SetVector( void* assembler, Vector* vector );
+
+	/*--------------------------------------------------------------------------------------------------------------------------
+	** Private Member functions
+	*/
+
+#endif /* __StgFEM_SLE_SystemSetup_InsertBCs_h__ */

Modified: long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/src/StiffnessMatrix.c
===================================================================
--- long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/src/StiffnessMatrix.c	2007-03-13 18:13:08 UTC (rev 6242)
+++ long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/src/StiffnessMatrix.c	2007-03-13 18:13:13 UTC (rev 6243)
@@ -64,15 +64,9 @@
 #include "CorrectRHS.h"
 
 
-typedef struct {
-	double***	elStiffMatPtr;
-	double**	bcValsPtr;
-	unsigned	nColEqs;
-} StiffnessMatrix_Asm_Context;
+void StiffnessMatrix_NewAssemble( void* stiffnessMatrix, Bool removeBCs, void* _sle, void* _context );
 
-void StiffnessMatrix_NewAssemble( void* stiffnessMatrix, void* _sle, void* _context );
 
-
 /* Textual name of this class */
 const Type StiffnessMatrix_Type = "StiffnessMatrix";
 
@@ -267,9 +261,12 @@
 	self->zeroBCsAsm = ZeroBCs_New();
 	self->bcAsm = CorrectRHS_New();
 	self->transBCAsm = CorrectRHS_New();
+	self->diagBCsAsm = UnifyDiagBCs_New();
 	Assembler_SetVariables( self->zeroBCsAsm, rowVariable, columnVariable );
 	Assembler_SetVariables( self->bcAsm, rowVariable, columnVariable );
 	Assembler_SetVariables( self->transBCAsm, columnVariable, rowVariable );
+	if( rowVariable == columnVariable )
+		Assembler_SetVariables( self->diagBCsAsm, rowVariable, columnVariable );
 
 	self->transRHS = NULL;
 }
@@ -286,6 +283,7 @@
 	FreeObject( self->zeroBCsAsm );
 	FreeObject( self->bcAsm );
 	FreeObject( self->transBCAsm );
+	FreeObject( self->diagBCsAsm );
 	/* Don't delete entry points: E.P. register will delete them automatically */
 
 	/* Stg_Class_Delete parent*/
@@ -1202,7 +1200,7 @@
 	Stream_UnIndentBranch( StgFEM_Debug );
 }
 
-void StiffnessMatrix_NewAssemble( void* stiffnessMatrix, void* _sle, void* _context ) {
+void StiffnessMatrix_NewAssemble( void* stiffnessMatrix, Bool removeBCs, void* _sle, void* _context ) {
 	StiffnessMatrix*		self = (StiffnessMatrix*)stiffnessMatrix;
 	SystemLinearEquations*		sle = (SystemLinearEquations*)_sle;
 	FeVariable			*rowVar, *colVar;
@@ -1215,11 +1213,9 @@
 	unsigned			maxDofs, maxRCDofs, nDofs, nRowDofs, nColDofs;
 	double**			elStiffMat;
 	double*				bcVals;
-	double				one = 1.0;
 	Matrix*				matrix;
 	Vector				*vector, *transVector;
-	StiffnessMatrix_Asm_Context	asmCtx;
-	unsigned			e_i, eq_i, n_i;
+	unsigned			e_i, n_i;
 
 	assert( self && Stg_CheckType( self, StiffnessMatrix ) );
 
@@ -1251,7 +1247,6 @@
 		for( n_i = 0; n_i < nRowNodes; n_i++ )
 			nRowDofs += rowDofs->dofCounts[rowNodes[n_i]];
 		nColDofs = 0;
-		asmCtx.nColEqs = nColDofs;
 		for( n_i = 0; n_i < nColNodes; n_i++ )
 			nColDofs += colDofs->dofCounts[colNodes[n_i]];
 		nDofs = nRowDofs * nColDofs;
@@ -1274,6 +1269,18 @@
 		memset( &elStiffMat[0][0], 0, nDofs * sizeof(double) );
 		StiffnessMatrix_AssembleElement( self, e_i, sle, _context, elStiffMat );
 
+		/* Correct for BCs providing I'm not keeping them in. */
+		if( vector && colEqNum->removeBCs ) {
+			memset( bcVals, 0, maxRCDofs * sizeof(double) );
+			Assembler_LoopMatrixElement( self->bcAsm, e_i );
+			Vector_AddEntries( vector, nColDofs, (unsigned*)colEqNum->locationMatrix[e_i][0], bcVals );
+		}
+		if( transVector && rowEqNum->removeBCs ) {
+			memset( bcVals, 0, maxRCDofs * sizeof(double) );
+			Assembler_LoopMatrixElement( self->transBCAsm, e_i );
+			Vector_AddEntries( transVector, nRowDofs, (unsigned*)rowEqNum->locationMatrix[e_i][0], bcVals );
+		}
+
 		/* If keeping BCs in, zero corresponding entries in the element stiffness matrix. */
 		if( !colEqNum->removeBCs )
 			Assembler_LoopMatrixElement( self->zeroBCsAsm, e_i );
@@ -1283,26 +1290,14 @@
 				   nRowDofs, (unsigned*)rowEqNum->locationMatrix[e_i][0], 
 				   nColDofs, (unsigned*)colEqNum->locationMatrix[e_i][0], 
 				   elStiffMat[0] );
-
-		/* Correct for BCs. */
-		if( vector ) {
-			memset( bcVals, 0, maxRCDofs * sizeof(double) );
-			Assembler_LoopMatrixElement( self->bcAsm, e_i );
-			Vector_AddEntries( vector, nColDofs, (unsigned*)colEqNum->locationMatrix[e_i][0], bcVals );
-		}
-		if( transVector ) {
-			memset( bcVals, 0, maxRCDofs * sizeof(double) );
-			Assembler_LoopMatrixElement( self->transBCAsm, e_i );
-			Vector_AddEntries( transVector, nRowDofs, (unsigned*)rowEqNum->locationMatrix[e_i][0], bcVals );
-		}
 	}
 
 	FreeArray( bcVals );
 
 	/* If keeping BCs in and rows and columnns use the same variable, put ones in all BC'd diagonals. */
 	if( !colEqNum->removeBCs && rowVar == colVar ) {
-		for( eq_i = rowEqNum->firstOwnedEqNum; eq_i < rowEqNum->lastOwnedEqNum; eq_i++ )
-			Matrix_InsertEntries( matrix, 1, &eq_i, 1, &eq_i, &one );
+		UnifyDiagBCs_SetMatrix( self->diagBCsAsm, matrix );
+		Assembler_LoopMatrixDiagonal( self->diagBCsAsm );
 	}
 
 	/* Reassemble the matrix and vectors. */

Modified: long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/src/StiffnessMatrix.h
===================================================================
--- long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/src/StiffnessMatrix.h	2007-03-13 18:13:08 UTC (rev 6242)
+++ long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/src/StiffnessMatrix.h	2007-03-13 18:13:13 UTC (rev 6243)
@@ -101,7 +101,8 @@
 		Index*                                            offDiagonalNonZeroIndices;      \
 		ZeroBCs*					zeroBCsAsm;			\
 		CorrectRHS*					bcAsm;				\
-		CorrectRHS*					transBCAsm;
+		CorrectRHS*					transBCAsm;			\
+		UnifyDiagBCs*					diagBCsAsm;
 		
 	struct StiffnessMatrix { __StiffnessMatrix };
 	

Modified: long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/src/SystemSetup.h
===================================================================
--- long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/src/SystemSetup.h	2007-03-13 18:13:08 UTC (rev 6242)
+++ long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/src/SystemSetup.h	2007-03-13 18:13:13 UTC (rev 6243)
@@ -67,6 +67,8 @@
 	#include "Assembler.h"
 	#include "ZeroBCs.h"
 	#include "CorrectRHS.h"
+	#include "UnifyDiagBCs.h"
+	#include "InsertBCs.h"
 
 #ifdef HAVE_PETSC
 	#include "PETScShellMatrix.h"

Added: long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/src/UnifyDiagBCs.c
===================================================================
--- long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/src/UnifyDiagBCs.c	2007-03-13 18:13:08 UTC (rev 6242)
+++ long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/src/UnifyDiagBCs.c	2007-03-13 18:13:13 UTC (rev 6243)
@@ -0,0 +1,134 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+**
+** Copyright (C), 2003, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street, Melbourne, 3053, Australia.
+**
+** Authors:
+**	Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
+**	Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
+**	Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
+**	Siew-Ching Tan, Software Engineer, VPAC. (siew at vpac.org)
+**	Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
+**	Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
+**
+**  This library is free software; you can redistribute it and/or
+**  modify it under the terms of the GNU Lesser General Public
+**  License as published by the Free Software Foundation; either
+**  version 2.1 of the License, or (at your option) any later version.
+**
+**  This library is distributed in the hope that it will be useful,
+**  but WITHOUT ANY WARRANTY; without even the implied warranty of
+**  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+**  Lesser General Public License for more details.
+**
+**  You should have received a copy of the GNU Lesser General Public
+**  License along with this library; if not, write to the Free Software
+**  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+**
+** $Id: UnifyDiagBCs.c 3584 2006-05-16 11:11:07Z PatrickSunter $
+**
+**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <assert.h>
+
+#include <mpi.h>
+#include "StGermain/StGermain.h"
+#include "Discretisation/Discretisation.h"
+#include "SLE/LinearAlgebra/LinearAlgebra.h"
+#include "SystemSetup.h"
+
+
+/* Textual name of this class */
+const Type UnifyDiagBCs_Type = "UnifyDiagBCs";
+
+
+/*----------------------------------------------------------------------------------------------------------------------------------
+** Constructors
+*/
+
+UnifyDiagBCs* UnifyDiagBCs_New() {
+	return _UnifyDiagBCs_New( sizeof(UnifyDiagBCs), 
+				  UnifyDiagBCs_Type, 
+				  _UnifyDiagBCs_Delete, 
+				  _UnifyDiagBCs_Print, 
+				  NULL, 
+				  NULL, 
+				  NULL, 
+				  UnifyDiagBCs_ColRestricted, 
+				  NULL );
+}
+
+UnifyDiagBCs* _UnifyDiagBCs_New( UNIFYDIAGBCS_DEFARGS ) {
+	UnifyDiagBCs*	self;
+
+	/* Allocate memory */
+	assert( sizeOfSelf >= sizeof(UnifyDiagBCs) );
+	self = (UnifyDiagBCs*)_Assembler_New( ASSEMBLER_PASSARGS );
+
+	/* Virtual info */
+
+	/* UnifyDiagBCs info */
+	_UnifyDiagBCs_Init( self );
+
+	return self;
+}
+
+void _UnifyDiagBCs_Init( UnifyDiagBCs* self ) {
+	assert( self && Stg_CheckType( self, UnifyDiagBCs ) );
+}
+
+
+/*----------------------------------------------------------------------------------------------------------------------------------
+** Virtual functions
+*/
+
+void _UnifyDiagBCs_Delete( void* assembler ) {
+	UnifyDiagBCs*	self = (UnifyDiagBCs*)assembler;
+
+	assert( self && Stg_CheckType( self, UnifyDiagBCs ) );
+
+	/* Delete the parent. */
+	_Assembler_Delete( self );
+}
+
+void _UnifyDiagBCs_Print( void* assembler, Stream* stream ) {
+	UnifyDiagBCs*	self = (UnifyDiagBCs*)assembler;
+	Stream* 	assemblerStream;
+	
+	/* Set the Journal for printing informations */
+	assemblerStream = Journal_Register( InfoStream_Type, "UnifyDiagBCsStream" );
+
+	assert( self && Stg_CheckType( self, UnifyDiagBCs ) );
+
+	/* Print parent */
+	Journal_Printf( stream, "UnifyDiagBCs (ptr): (%p)\n", self );
+	_Assembler_Print( self, stream );
+}
+
+void UnifyDiagBCs_ColRestricted( void* assembler ) {
+	static const double	one = 1.0;
+	unsigned		rowEq;
+
+	rowEq = ((UnifyDiagBCs*)assembler)->rowEq;
+	Matrix_InsertEntries( ((UnifyDiagBCs*)assembler)->matrix, 1, &rowEq, 1, &rowEq, &one );
+}
+
+
+/*--------------------------------------------------------------------------------------------------------------------------
+** Public Functions
+*/
+
+void UnifyDiagBCs_SetMatrix( void* assembler, Matrix* matrix ) {
+	UnifyDiagBCs*	self = (UnifyDiagBCs*)assembler;
+
+	assert( self && Stg_CheckType( self, UnifyDiagBCs ) );
+
+	self->matrix = matrix;
+}
+
+
+/*----------------------------------------------------------------------------------------------------------------------------------
+** Private Functions
+*/

Added: long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/src/UnifyDiagBCs.h
===================================================================
--- long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/src/UnifyDiagBCs.h	2007-03-13 18:13:08 UTC (rev 6242)
+++ long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/src/UnifyDiagBCs.h	2007-03-13 18:13:13 UTC (rev 6243)
@@ -0,0 +1,94 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+**
+** Copyright (C), 2003, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street, Melbourne, 3053, Australia.
+**
+** Authors:
+**	Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
+**	Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
+**	Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
+**	Siew-Ching Tan, Software Engineer, VPAC. (siew at vpac.org)
+**	Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
+**	Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
+**
+**  This library is free software; you can redistribute it and/or
+**  modify it under the terms of the GNU Lesser General Public
+**  License as published by the Free Software Foundation; either
+**  version 2.1 of the License, or (at your option) any later version.
+**
+**  This library is distributed in the hope that it will be useful,
+**  but WITHOUT ANY WARRANTY; without even the implied warranty of
+**  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+**  Lesser General Public License for more details.
+**
+**  You should have received a copy of the GNU Lesser General Public
+**  License along with this library; if not, write to the Free Software
+**  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+**
+*/
+/** \file
+**  Role:
+**
+** Assumptions:
+**
+** Invariants:
+**
+** Comments:
+**
+** $Id: UnifyDiagBCs.h 3584 2006-05-16 11:11:07Z PatrickSunter $
+**
+**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+
+#ifndef __StgFEM_SLE_SystemSetup_UnifyDiagBCs_h__
+#define __StgFEM_SLE_SystemSetup_UnifyDiagBCs_h__
+
+	/** Textual name of this class */
+	extern const Type UnifyDiagBCs_Type;
+
+	/** Virtual function types */
+
+	/** UnifyDiagBCs class contents */
+	#define __UnifyDiagBCs		\
+		/* General info */	\
+		__Assembler		\
+					\
+		/* Virtual info */	\
+					\
+		/* UnifyDiagBCs info */	\
+		Matrix*		matrix;
+
+	struct UnifyDiagBCs { __UnifyDiagBCs };
+
+	/*--------------------------------------------------------------------------------------------------------------------------
+	** Constructors
+	*/
+
+	#define UNIFYDIAGBCS_DEFARGS \
+		ASSEMBLER_DEFARGS
+
+	#define UNIFYDIAGBCS_PASSARGS \
+		ASSEMBLER_PASSARGS
+
+	UnifyDiagBCs* UnifyDiagBCs_New();
+	UnifyDiagBCs* _UnifyDiagBCs_New( UNIFYDIAGBCS_DEFARGS );
+	void _UnifyDiagBCs_Init( UnifyDiagBCs* self );
+
+	/*--------------------------------------------------------------------------------------------------------------------------
+	** Virtual functions
+	*/
+
+	void _UnifyDiagBCs_Delete( void* assembler );
+	void _UnifyDiagBCs_Print( void* assembler, Stream* stream );
+
+	void UnifyDiagBCs_ColRestricted( void* assembler );
+
+	/*--------------------------------------------------------------------------------------------------------------------------
+	** Public functions
+	*/
+
+	void UnifyDiagBCs_SetMatrix( void* assembler, Matrix* matrix );
+
+	/*--------------------------------------------------------------------------------------------------------------------------
+	** Private Member functions
+	*/
+
+#endif /* __StgFEM_SLE_SystemSetup_UnifyDiagBCs_h__ */

Modified: long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/src/ZeroBCs.c
===================================================================
--- long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/src/ZeroBCs.c	2007-03-13 18:13:08 UTC (rev 6242)
+++ long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/src/ZeroBCs.c	2007-03-13 18:13:13 UTC (rev 6243)
@@ -55,8 +55,8 @@
 			     _ZeroBCs_Print, 
 			     NULL, 
 			     ZeroBCs_RowRestricted, 
+			     ZeroBCs_RowUnrestricted, 
 			     NULL, 
-			     ZeroBCs_ColRestricted, 
 			     NULL );
 }
 
@@ -107,9 +107,13 @@
 	_Assembler_Print( self, stream );
 }
 
+Bool ZeroBCs_RowUnrestricted( void* assembler ) {
+	return False;
+}
+
 Bool ZeroBCs_RowRestricted( void* assembler ) {
 	memset( ((ZeroBCs*)assembler)->elStiffMat[((ZeroBCs*)assembler)->rowInd], 0, 
-		((ZeroBCs*)assembler)->nColEqs );
+		((ZeroBCs*)assembler)->nColEqs * sizeof(double) );
 	return False;
 }
 

Modified: long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/src/ZeroBCs.h
===================================================================
--- long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/src/ZeroBCs.h	2007-03-13 18:13:08 UTC (rev 6242)
+++ long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/src/ZeroBCs.h	2007-03-13 18:13:13 UTC (rev 6243)
@@ -78,6 +78,7 @@
 	void _ZeroBCs_Delete( void* assembler );
 	void _ZeroBCs_Print( void* assembler, Stream* stream );
 
+	Bool ZeroBCs_RowUnrestricted( void* assembler );
 	Bool ZeroBCs_RowRestricted( void* assembler );
 	void ZeroBCs_ColRestricted( void* assembler );
 

Modified: long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/src/types.h
===================================================================
--- long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/src/types.h	2007-03-13 18:13:08 UTC (rev 6242)
+++ long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/src/types.h	2007-03-13 18:13:13 UTC (rev 6243)
@@ -65,6 +65,8 @@
 	typedef struct Assembler		Assembler;
 	typedef struct ZeroBCs			ZeroBCs;
 	typedef struct CorrectRHS		CorrectRHS;
+	typedef struct UnifyDiagBCs		UnifyDiagBCs;
+	typedef struct InsertBCs		InsertBCs;
 
 	/* types for lists etc ... for readability */
 	typedef Index                       StiffnessMatrix_Index;



More information about the cig-commits mailing list