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

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


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

Added:
   long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/src/CorrectRHS.c
   long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/src/CorrectRHS.h
   long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/src/ZeroBCs.c
   long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/src/ZeroBCs.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/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/types.h
Log:
 r1045 at earth (orig r776):  LukeHodkinson | 2007-03-09 10:01:04 -0800
 Modifying the helper assembly class to make more like
 an algorithm class. So, instead of needing to pass in
 a context when calling the assembly helper, we can
 inherit the base class and add contextual information
 to the class itself.
 



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:775
db209038-57f2-0310-97fa-b160e0ae9d04:/trunk:669
   + 38867592-cf10-0410-9e16-a142ea72ac34:/cig:880
db209038-57f2-0310-97fa-b160e0ae9d04:/branches/decomp3d:776
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:04 UTC (rev 6241)
+++ long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/src/Assembler.c	2007-03-13 18:13:08 UTC (rev 6242)
@@ -48,14 +48,6 @@
 ** Constructors
 */
 
-Assembler* Assembler_New( Name name ) {
-	return _Assembler_New( sizeof(Assembler), 
-			       Assembler_Type, 
-			       _Assembler_Delete, 
-			       _Assembler_Print, 
-			       NULL );
-}
-
 Assembler* _Assembler_New( ASSEMBLER_DEFARGS ) {
 	Assembler*	self;
 
@@ -64,6 +56,10 @@
 	self = (Assembler*)_Stg_Class_New( STG_CLASS_PASSARGS );
 
 	/* Virtual info */
+	self->rowRestrictedFunc = rowRestrictedFunc;
+	self->rowUnrestrictedFunc = rowUnrestrictedFunc;
+	self->columnRestrictedFunc = columnRestrictedFunc;
+	self->columnUnrestrictedFunc = columnUnrestrictedFunc;
 
 	/* Assembler info */
 	_Assembler_Init( self );
@@ -77,14 +73,11 @@
 	self->rowVar = NULL;
 	self->colVar = NULL;
 	self->swarm = NULL;
-	self->rowCB = NULL;
-	self->colCB = NULL;
-	self->ctx = NULL;
-	self->rowLocalInd = 0;
+	self->rowInd = 0;
 	self->rowNodeInd = 0;
 	self->rowDofInd = 0;
 	self->rowEq = 0;
-	self->colLocalInd = 0;
+	self->colInd = 0;
 	self->colNodeInd = 0;
 	self->colDofInd = 0;
 	self->colEq = 0;
@@ -141,20 +134,26 @@
 	self->swarm = swarm;
 }
 
-void Assembler_SetCallbacks( void* assembler, 
-			     Assembler_CallbackType* rowCallback, 
-			     Assembler_CallbackType* colCallback, 
-			     void* context )
+void Assembler_SetElementStiffnessMatrix( void* assembler, double** elStiffMat, 
+					  unsigned nRowEqs, unsigned nColEqs )
 {
 	Assembler*	self = (Assembler*)assembler;
 
 	assert( self && Stg_CheckType( self, Assembler ) );
 
-	self->rowCB = rowCallback;
-	self->colCB = colCallback;
-	self->ctx = context;
+	self->elStiffMat = elStiffMat;
+	self->nRowEqs = nRowEqs;
+	self->nColEqs = nColEqs;
 }
 
+void Assembler_SetBCCorrectionArray( void* assembler, double* bcCorrects ) {
+	Assembler*	self = (Assembler*)assembler;
+
+	assert( self && Stg_CheckType( self, Assembler ) );
+
+	self->bcCorrects = bcCorrects;
+}
+
 #if 0
 void Assembler_AssembleMatrixElement( void* assembler, unsigned element ) {
 	Assembler*		self = (Assembler*)assembler;
@@ -246,7 +245,6 @@
 
 	assert( self && Stg_CheckType( self, Assembler ) );
 	assert( self->rowVar && self->colVar );
-	assert( self->colCB );
 
 	self->elInd = element;
 	rowVar = self->rowVar;
@@ -275,11 +273,15 @@
 		for( dof_i = 0; dof_i < nRowDofs; dof_i++ ) {
 			rowEq = rowEqNum->locationMatrix[element][n_i][dof_i];
 
-			self->rowLocalInd = rowInd++;
-			self->rowNodeInd = n_i;
+			self->rowInd = rowInd++;
+			self->rowNodeInd = rowElNodes[n_i];
 			self->rowDofInd = dof_i;
 			self->rowEq = rowEq;
-			if( self->rowCB && !self->rowCB( self ) )
+			if( VariableCondition_IsCondition( rowVar->bcs, rowElNodes[n_i], dof_i ) ) {
+				if( !self->rowRestrictedFunc || !self->rowRestrictedFunc( self ) )
+					continue;
+			}
+			else if( self->rowUnrestrictedFunc && !self->rowUnrestrictedFunc( self ) )
 				continue;
 
 			Mesh_GetIncidence( colMesh, Mesh_GetDimSize( colMesh ), element, MT_VERTEX, 
@@ -291,17 +293,23 @@
 				for( dof_j = 0; dof_j < nColDofs; dof_j++ ) {
 					colEq = colEqNum->locationMatrix[element][n_j][dof_j];
 
-					self->colLocalInd = colInd++;
-					self->colNodeInd = n_i;
-					self->colDofInd = dof_i;
-					self->colEq = rowEq;
-					self->colCB( self );
+					self->colInd = colInd++;
+					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 );
+					}
+					else if( self->rowUnrestrictedFunc )
+						self->rowUnrestrictedFunc( self );
 				}
 			}
 		}
 	}
 }
 
+#if 0
 void Assembler_LoopVectorElement( void* assembler, unsigned element ) {
 	Assembler*		self = (Assembler*)assembler;
 	unsigned		nDims;
@@ -342,6 +350,7 @@
 		}
 	}
 }
+#endif
 
 
 /*----------------------------------------------------------------------------------------------------------------------------------

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:04 UTC (rev 6241)
+++ long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/src/Assembler.h	2007-03-13 18:13:08 UTC (rev 6242)
@@ -38,39 +38,46 @@
 **
 **~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
 
-#ifndef __StgFEM_SLE_LinearAlgebra_Assembler_h__
-#define __StgFEM_SLE_LinearAlgebra_Assembler_h__
+#ifndef __StgFEM_SLE_SystemSetup_Assembler_h__
+#define __StgFEM_SLE_SystemSetup_Assembler_h__
 
 	/** Textual name of this class */
 	extern const Type Assembler_Type;
 
 	/** Virtual function types */
+	typedef Bool (Assembler_RowRestrictedFunc)( void* assembeler );
+	typedef Bool (Assembler_RowUnrestrictedFunc)( void* assembeler );
+	typedef void (Assembler_ColumnRestrictedFunc)( void* assembeler );
+	typedef void (Assembler_ColumnUnrestrictedFunc)( void* assembeler );
 
 	/** Assembler class contents */
-	typedef Bool (Assembler_CallbackType)( Assembler* self );
-
-	#define __Assembler				\
-		/* General info */			\
-		__Stg_Class				\
-							\
-		/* Virtual info */			\
-							\
-		/* Assembler info */			\
-		FeVariable*		rowVar;		\
-		FeVariable*		colVar;		\
-		Swarm*			swarm;		\
-		Assembler_CallbackType*	rowCB;		\
-		Assembler_CallbackType*	colCB;		\
-		void*			ctx;		\
-							\
-		unsigned		elInd;		\
-		unsigned		rowLocalInd;	\
-		unsigned		rowNodeInd;	\
-		unsigned		rowDofInd;	\
-		unsigned		rowEq;		\
-		unsigned		colLocalInd;	\
-		unsigned		colNodeInd;	\
-		unsigned		colDofInd;	\
+	#define __Assembler							\
+		/* General info */						\
+		__Stg_Class							\
+										\
+		/* Virtual info */						\
+		Assembler_RowRestrictedFunc*		rowRestrictedFunc;	\
+		Assembler_RowUnrestrictedFunc*		rowUnrestrictedFunc;	\
+		Assembler_ColumnRestrictedFunc*		columnRestrictedFunc;	\
+		Assembler_ColumnUnrestrictedFunc*	columnUnrestrictedFunc;	\
+										\
+		/* Assembler info */						\
+		FeVariable*		rowVar;					\
+		FeVariable*		colVar;					\
+		Swarm*			swarm;					\
+		double**		elStiffMat;				\
+		double*			bcCorrects;				\
+										\
+		unsigned		elInd;					\
+		unsigned		nRowEqs;				\
+		unsigned		nColEqs;				\
+		unsigned		rowInd;					\
+		unsigned		rowNodeInd;				\
+		unsigned		rowDofInd;				\
+		unsigned		rowEq;					\
+		unsigned		colInd;					\
+		unsigned		colNodeInd;				\
+		unsigned		colDofInd;				\
 		unsigned		colEq;
 
 	struct Assembler { __Assembler };
@@ -79,13 +86,20 @@
 	** Constructors
 	*/
 
-	#define ASSEMBLER_DEFARGS \
-		STG_CLASS_DEFARGS
+	#define ASSEMBLER_DEFARGS						\
+		STG_CLASS_DEFARGS,						\
+		Assembler_RowRestrictedFunc*		rowRestrictedFunc,	\
+		Assembler_RowUnrestrictedFunc*		rowUnrestrictedFunc,	\
+		Assembler_ColumnRestrictedFunc*		columnRestrictedFunc,	\
+		Assembler_ColumnUnrestrictedFunc*	columnUnrestrictedFunc
 
-	#define ASSEMBLER_PASSARGS \
-		STG_CLASS_PASSARGS
+	#define ASSEMBLER_PASSARGS	\
+		STG_CLASS_PASSARGS,	\
+		rowRestrictedFunc,	\
+		rowUnrestrictedFunc,	\
+		columnRestrictedFunc,	\
+		columnUnrestrictedFunc
 
-	Assembler* Assembler_New();
 	Assembler* _Assembler_New( ASSEMBLER_DEFARGS );
 	void _Assembler_Init( Assembler* self );
 
@@ -96,16 +110,20 @@
 	void _Assembler_Delete( void* assembler );
 	void _Assembler_Print( void* assembler, Stream* stream );
 
+	Bool _Assembler_RowRestricted( void* assembeler );
+	Bool _Assembler_RowUnrestricted( void* assembeler );
+	Bool _Assembler_ColumnRestricted( void* assembeler );
+	Bool _Assembler_ColumnUnrestricted( void* assembeler );
+
 	/*--------------------------------------------------------------------------------------------------------------------------
 	** Public functions
 	*/
 
 	void Assembler_SetVariables( void* assembler, FeVariable* rowVar, FeVariable* columnVar );
 	void Assembler_SetIntegrationSwarm( void* assembler, Swarm* swarm );
-	void Assembler_SetCallbacks( void* assembler, 
-				     Assembler_CallbackType* rowCallback, 
-				     Assembler_CallbackType* columnCallback, 
-				     void* context );
+	void Assembler_SetElementStiffnessMatrix( void* assembler, double** elStiffMat, 
+						  unsigned nRowEqs, unsigned nColEqs );
+	void Assembler_SetBCCorrectionArray( void* assembler, double* bcCorrect );
 
 	void Assembler_LoopMatrixElement( void* assembler, unsigned element );
 
@@ -113,4 +131,4 @@
 	** Private Member functions
 	*/
 
-#endif /* __StgFEM_SLE_LinearAlgebra_Assembler_h__ */
+#endif /* __StgFEM_SLE_SystemSetup_Assembler_h__ */

Added: 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:04 UTC (rev 6241)
+++ long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/src/CorrectRHS.c	2007-03-13 18:13:08 UTC (rev 6242)
@@ -0,0 +1,139 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+**
+** 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: CorrectRHS.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 CorrectRHS_Type = "CorrectRHS";
+
+
+/*----------------------------------------------------------------------------------------------------------------------------------
+** Constructors
+*/
+
+CorrectRHS* CorrectRHS_New() {
+	return _CorrectRHS_New( sizeof(CorrectRHS), 
+				CorrectRHS_Type, 
+				_CorrectRHS_Delete, 
+				_CorrectRHS_Print, 
+				NULL, 
+				NULL, 
+				NULL, 
+				CorrectRHS_ColRestricted, 
+				NULL );
+}
+
+CorrectRHS* _CorrectRHS_New( ZEROBCS_DEFARGS ) {
+	CorrectRHS*	self;
+
+	/* Allocate memory */
+	assert( sizeOfSelf >= sizeof(CorrectRHS) );
+	self = (CorrectRHS*)_Assembler_New( ASSEMBLER_PASSARGS );
+
+	/* Virtual info */
+
+	/* CorrectRHS info */
+	_CorrectRHS_Init( self );
+
+	return self;
+}
+
+void _CorrectRHS_Init( CorrectRHS* self ) {
+	assert( self && Stg_CheckType( self, CorrectRHS ) );
+
+	self->trans = False;
+}
+
+
+/*----------------------------------------------------------------------------------------------------------------------------------
+** Virtual functions
+*/
+
+void _CorrectRHS_Delete( void* assembler ) {
+	CorrectRHS*	self = (CorrectRHS*)assembler;
+
+	assert( self && Stg_CheckType( self, CorrectRHS ) );
+
+	/* Delete the parent. */
+	_Assembler_Delete( self );
+}
+
+void _CorrectRHS_Print( void* assembler, Stream* stream ) {
+	CorrectRHS*	self = (CorrectRHS*)assembler;
+	Stream* 	assemblerStream;
+	
+	/* Set the Journal for printing informations */
+	assemblerStream = Journal_Register( InfoStream_Type, "CorrectRHSStream" );
+
+	assert( self && Stg_CheckType( self, CorrectRHS ) );
+
+	/* Print parent */
+	Journal_Printf( stream, "CorrectRHS (ptr): (%p)\n", self );
+	_Assembler_Print( self, stream );
+}
+
+void CorrectRHS_ColRestricted( void* assembler ) {
+	double		bc;
+	unsigned	rowInd, colInd;
+
+	bc = DofLayout_GetValueDouble( ((CorrectRHS*)assembler)->colVar->dofLayout, 
+				       ((CorrectRHS*)assembler)->colNodeInd, 
+				       ((CorrectRHS*)assembler)->colDofInd );
+	rowInd = ((CorrectRHS*)assembler)->rowInd;
+	colInd = ((CorrectRHS*)assembler)->colInd;
+	if( !((CorrectRHS*)assembler)->trans ) {
+		((CorrectRHS*)assembler)->bcCorrects[rowInd] = bc * 
+			((CorrectRHS*)assembler)->elStiffMat[rowInd][colInd];
+	}
+	else {
+		((CorrectRHS*)assembler)->bcCorrects[rowInd] = bc * 
+			((CorrectRHS*)assembler)->elStiffMat[colInd][rowInd];
+	}
+}
+
+
+/*--------------------------------------------------------------------------------------------------------------------------
+** Public Functions
+*/
+
+
+/*----------------------------------------------------------------------------------------------------------------------------------
+** Private Functions
+*/

Added: long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/src/CorrectRHS.h
===================================================================
--- long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/src/CorrectRHS.h	2007-03-13 18:13:04 UTC (rev 6241)
+++ long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/src/CorrectRHS.h	2007-03-13 18:13:08 UTC (rev 6242)
@@ -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: CorrectRHS.h 3584 2006-05-16 11:11:07Z PatrickSunter $
+**
+**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+
+#ifndef __StgFEM_SLE_SystemSetup_CorrectRHS_h__
+#define __StgFEM_SLE_SystemSetup_CorrectRHS_h__
+
+	/** Textual name of this class */
+	extern const Type CorrectRHS_Type;
+
+	/** Virtual function types */
+
+	/** CorrectRHS class contents */
+	#define __CorrectRHS		\
+		/* General info */	\
+		__Assembler		\
+					\
+		/* Virtual info */	\
+					\
+		/* CorrectRHS info */	\
+		Bool	trans;
+
+	struct CorrectRHS { __CorrectRHS };
+
+	/*--------------------------------------------------------------------------------------------------------------------------
+	** Constructors
+	*/
+
+	#define CORRECTRHS_DEFARGS \
+		ASSEMBLER_DEFARGS
+
+	#define CORRECTRHS_PASSARGS \
+		STG_CLASS_PASSARGS
+
+	CorrectRHS* CorrectRHS_New();
+	CorrectRHS* _CorrectRHS_New( CORRECTRHS_DEFARGS );
+	void _CorrectRHS_Init( CorrectRHS* self );
+
+	/*--------------------------------------------------------------------------------------------------------------------------
+	** Virtual functions
+	*/
+
+	void _CorrectRHS_Delete( void* assembler );
+	void _CorrectRHS_Print( void* assembler, Stream* stream );
+
+	void CorrectRHS_ColRestricted( void* assembler );
+
+	/*--------------------------------------------------------------------------------------------------------------------------
+	** Public functions
+	*/
+
+	void CorrectRHS_SetTranspose( void* assembler, Bool state );
+
+	/*--------------------------------------------------------------------------------------------------------------------------
+	** Private Member functions
+	*/
+
+#endif /* __StgFEM_SLE_SystemSetup_CorrectRHS_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:04 UTC (rev 6241)
+++ long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/src/StiffnessMatrix.c	2007-03-13 18:13:08 UTC (rev 6242)
@@ -60,6 +60,8 @@
 #include "SolutionVector.h"
 #include "ForceVector.h"
 #include "Assembler.h"
+#include "ZeroBCs.h"
+#include "CorrectRHS.h"
 
 
 typedef struct {
@@ -69,11 +71,6 @@
 } StiffnessMatrix_Asm_Context;
 
 void StiffnessMatrix_NewAssemble( void* stiffnessMatrix, void* _sle, void* _context );
-Bool StiffnessMatrix_Asm_ZeroBCsRow( Assembler* self );
-Bool StiffnessMatrix_Asm_ZeroBCsCol( Assembler* self );
-Bool StiffnessMatrix_Asm_BCRow( Assembler* self );
-Bool StiffnessMatrix_Asm_BCCol( Assembler* self );
-Bool StiffnessMatrix_Asm_TransBCCol( Assembler* self );
 
 
 /* Textual name of this class */
@@ -266,6 +263,14 @@
 	/*EP_ReplaceAll( self->assembleStiffnessMatrix, StiffnessMatrix_GlobalAssembly_General );*/
 	EP_ReplaceAll( self->assembleStiffnessMatrix, StiffnessMatrix_NewAssemble );
 
+	/* We need some assembler contexts. */
+	self->zeroBCsAsm = ZeroBCs_New();
+	self->bcAsm = CorrectRHS_New();
+	self->transBCAsm = CorrectRHS_New();
+	Assembler_SetVariables( self->zeroBCsAsm, rowVariable, columnVariable );
+	Assembler_SetVariables( self->bcAsm, rowVariable, columnVariable );
+	Assembler_SetVariables( self->transBCAsm, columnVariable, rowVariable );
+
 	self->transRHS = NULL;
 }
 
@@ -278,6 +283,9 @@
 	FreeArray( self->_assembleStiffnessMatrixEPName );
 	FreeArray( self->diagonalNonZeroIndices );
 	FreeArray( self->offDiagonalNonZeroIndices );
+	FreeObject( self->zeroBCsAsm );
+	FreeObject( self->bcAsm );
+	FreeObject( self->transBCAsm );
 	/* Don't delete entry points: E.P. register will delete them automatically */
 
 	/* Stg_Class_Delete parent*/
@@ -1210,7 +1218,6 @@
 	double				one = 1.0;
 	Matrix*				matrix;
 	Vector				*vector, *transVector;
-	Assembler			*zeroBCsAsm, *bcAsm, *transBCAsm;
 	StiffnessMatrix_Asm_Context	asmCtx;
 	unsigned			e_i, eq_i, n_i;
 
@@ -1234,42 +1241,6 @@
 	bcVals = NULL;
 	maxDofs = 0;
 
-	/* We need some assembler contexts. */
-	if( !colEqNum->removeBCs ) {
-		zeroBCsAsm = Assembler_New();
-		Assembler_SetVariables( zeroBCsAsm, rowVar, colVar );
-		Assembler_SetCallbacks( zeroBCsAsm, 
-					StiffnessMatrix_Asm_ZeroBCsRow, 
-					StiffnessMatrix_Asm_ZeroBCsCol, 
-					&asmCtx );
-	}
-	else
-		zeroBCsAsm = NULL;
-	if( vector ) {
-		bcAsm = Assembler_New();
-		Assembler_SetVariables( bcAsm, rowVar, colVar );
-		Assembler_SetCallbacks( bcAsm, 
-					StiffnessMatrix_Asm_BCRow, 
-					StiffnessMatrix_Asm_BCCol, 
-					&asmCtx );
-	}
-	else
-		bcAsm = NULL;
-	if( transVector ) {
-		transBCAsm = Assembler_New();
-		Assembler_SetVariables( transBCAsm, colVar, rowVar );
-		Assembler_SetCallbacks( transBCAsm, 
-					StiffnessMatrix_Asm_BCRow, 
-					StiffnessMatrix_Asm_TransBCCol, 
-					&asmCtx );
-	}
-	else
-		transBCAsm = NULL;
-	if( !colEqNum->removeBCs || vector || transVector ) {
-		asmCtx.elStiffMatPtr = &elStiffMat;
-		asmCtx.bcValsPtr = &bcVals;
-	}
-
 	/* Begin assembling each element. */
 	for( e_i = 0; e_i < nRowEls; e_i++ ) {
 		FeMesh_GetElementNodes( rowMesh, e_i, &nRowNodes, &rowNodes );
@@ -1288,6 +1259,14 @@
 			maxRCDofs = (nRowDofs > nColDofs) ? nRowDofs : nColDofs;
 			elStiffMat = ReallocArray2D( elStiffMat, double, nRowDofs, nColDofs );
 			bcVals = ReallocArray( bcVals, double, maxRCDofs );
+			Assembler_SetElementStiffnessMatrix( self->zeroBCsAsm, elStiffMat, 
+							     nRowDofs, nColDofs );
+			Assembler_SetElementStiffnessMatrix( self->bcAsm, elStiffMat, 
+							     nRowDofs, nColDofs );
+			Assembler_SetBCCorrectionArray( self->bcAsm, bcVals );
+			Assembler_SetElementStiffnessMatrix( self->transBCAsm, elStiffMat, 
+							     nRowDofs, nColDofs );
+			Assembler_SetBCCorrectionArray( self->transBCAsm, bcVals );
 			maxDofs = nDofs;
 		}
 
@@ -1297,7 +1276,7 @@
 
 		/* If keeping BCs in, zero corresponding entries in the element stiffness matrix. */
 		if( !colEqNum->removeBCs )
-			Assembler_LoopMatrixElement( zeroBCsAsm, e_i );
+			Assembler_LoopMatrixElement( self->zeroBCsAsm, e_i );
 
 		/* Add to stiffness matrix. */
 		Matrix_AddEntries( matrix, 
@@ -1308,20 +1287,17 @@
 		/* Correct for BCs. */
 		if( vector ) {
 			memset( bcVals, 0, maxRCDofs * sizeof(double) );
-			Assembler_LoopMatrixElement( bcAsm, e_i );
+			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( transBCAsm, e_i );
+			Assembler_LoopMatrixElement( self->transBCAsm, e_i );
 			Vector_AddEntries( transVector, nRowDofs, (unsigned*)rowEqNum->locationMatrix[e_i][0], bcVals );
 		}
 	}
 
 	FreeArray( bcVals );
-	FreeObject( zeroBCsAsm );
-	FreeObject( bcAsm );
-	FreeObject( transBCAsm );
 
 	/* If keeping BCs in and rows and columnns use the same variable, put ones in all BC'd diagonals. */
 	if( !colEqNum->removeBCs && rowVar == colVar ) {
@@ -1996,43 +1972,3 @@
 	nNonZeros[rowEq]++;
 	nonZeros[rowEq][nNonZeros[rowEq] - 1] = colEq;
 }
-
-Bool StiffnessMatrix_Asm_ZeroBCsRow( Assembler* self ) {
-	if( VariableCondition_IsCondition( self->rowVar->bcs, self->rowNodeInd, self->rowDofInd ) ) {
-		memset( (*((StiffnessMatrix_Asm_Context*)self->ctx)->elStiffMatPtr)[self->rowLocalInd], 0, 
-			((StiffnessMatrix_Asm_Context*)self->ctx)->nColEqs );
-		return False;
-	}
-	return True;
-}
-
-Bool StiffnessMatrix_Asm_ZeroBCsCol( Assembler* self ) {
-	if( VariableCondition_IsCondition( self->colVar->bcs, self->colNodeInd, self->colDofInd ) ) {
-		(*((StiffnessMatrix_Asm_Context*)self->ctx)->elStiffMatPtr)[self->rowLocalInd][self->colLocalInd] = 0.0;
-	}
-	return True;
-}
-
-Bool StiffnessMatrix_Asm_BCRow( Assembler* self ) {
-	if( VariableCondition_IsCondition( self->rowVar->bcs, self->rowNodeInd, self->rowDofInd ) )
-		return False;
-	return True;
-}
-
-Bool StiffnessMatrix_Asm_BCCol( Assembler* self ) {
-	if( VariableCondition_IsCondition( self->colVar->bcs, self->colNodeInd, self->colDofInd ) ) {
-		(*((StiffnessMatrix_Asm_Context*)self->ctx)->bcValsPtr)[self->rowLocalInd] = 
-			DofLayout_GetValueDouble( self->colVar->dofLayout, self->colNodeInd, self->colDofInd ) * 
-			(*((StiffnessMatrix_Asm_Context*)self->ctx)->elStiffMatPtr)[self->rowLocalInd][self->colLocalInd];
-	}
-	return True;
-}
-
-Bool StiffnessMatrix_Asm_TransBCCol( Assembler* self ) {
-	if( VariableCondition_IsCondition( self->colVar->bcs, self->colNodeInd, self->colDofInd ) ) {
-		(*((StiffnessMatrix_Asm_Context*)self->ctx)->bcValsPtr)[self->rowLocalInd] = 
-			DofLayout_GetValueDouble( self->colVar->dofLayout, self->colNodeInd, self->colDofInd ) * 
-			(*((StiffnessMatrix_Asm_Context*)self->ctx)->elStiffMatPtr)[self->colLocalInd][self->rowLocalInd];
-	}
-	return True;
-}

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:04 UTC (rev 6241)
+++ long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/src/StiffnessMatrix.h	2007-03-13 18:13:08 UTC (rev 6242)
@@ -99,6 +99,9 @@
 		Index*                                            diagonalNonZeroIndices;         \
 		Index                                             offDiagonalNonZeroCount;        \
 		Index*                                            offDiagonalNonZeroIndices;      \
+		ZeroBCs*					zeroBCsAsm;			\
+		CorrectRHS*					bcAsm;				\
+		CorrectRHS*					transBCAsm;
 		
 	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:04 UTC (rev 6241)
+++ long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/src/SystemSetup.h	2007-03-13 18:13:08 UTC (rev 6242)
@@ -65,6 +65,8 @@
 	#include "ForceVector.h"
 	#include "ForceTerm.h"
 	#include "Assembler.h"
+	#include "ZeroBCs.h"
+	#include "CorrectRHS.h"
 
 #ifdef HAVE_PETSC
 	#include "PETScShellMatrix.h"

Added: 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:04 UTC (rev 6241)
+++ long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/src/ZeroBCs.c	2007-03-13 18:13:08 UTC (rev 6242)
@@ -0,0 +1,132 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+**
+** 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: ZeroBCs.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 ZeroBCs_Type = "ZeroBCs";
+
+
+/*----------------------------------------------------------------------------------------------------------------------------------
+** Constructors
+*/
+
+ZeroBCs* ZeroBCs_New() {
+	return _ZeroBCs_New( sizeof(ZeroBCs), 
+			     ZeroBCs_Type, 
+			     _ZeroBCs_Delete, 
+			     _ZeroBCs_Print, 
+			     NULL, 
+			     ZeroBCs_RowRestricted, 
+			     NULL, 
+			     ZeroBCs_ColRestricted, 
+			     NULL );
+}
+
+ZeroBCs* _ZeroBCs_New( ZEROBCS_DEFARGS ) {
+	ZeroBCs*	self;
+
+	/* Allocate memory */
+	assert( sizeOfSelf >= sizeof(ZeroBCs) );
+	self = (ZeroBCs*)_Assembler_New( ASSEMBLER_PASSARGS );
+
+	/* Virtual info */
+
+	/* ZeroBCs info */
+	_ZeroBCs_Init( self );
+
+	return self;
+}
+
+void _ZeroBCs_Init( ZeroBCs* self ) {
+	assert( self && Stg_CheckType( self, ZeroBCs ) );
+}
+
+
+/*----------------------------------------------------------------------------------------------------------------------------------
+** Virtual functions
+*/
+
+void _ZeroBCs_Delete( void* assembler ) {
+	ZeroBCs*	self = (ZeroBCs*)assembler;
+
+	assert( self && Stg_CheckType( self, ZeroBCs ) );
+
+	/* Delete the parent. */
+	_Assembler_Delete( self );
+}
+
+void _ZeroBCs_Print( void* assembler, Stream* stream ) {
+	ZeroBCs*	self = (ZeroBCs*)assembler;
+	Stream* 	assemblerStream;
+	
+	/* Set the Journal for printing informations */
+	assemblerStream = Journal_Register( InfoStream_Type, "ZeroBCsStream" );
+
+	assert( self && Stg_CheckType( self, ZeroBCs ) );
+
+	/* Print parent */
+	Journal_Printf( stream, "ZeroBCs (ptr): (%p)\n", self );
+	_Assembler_Print( self, stream );
+}
+
+Bool ZeroBCs_RowRestricted( void* assembler ) {
+	memset( ((ZeroBCs*)assembler)->elStiffMat[((ZeroBCs*)assembler)->rowInd], 0, 
+		((ZeroBCs*)assembler)->nColEqs );
+	return False;
+}
+
+void ZeroBCs_ColRestricted( void* assembler ) {
+	unsigned	rowInd, colInd;
+
+	rowInd = ((ZeroBCs*)assembler)->rowInd;
+	colInd = ((ZeroBCs*)assembler)->colInd;
+	((ZeroBCs*)assembler)->elStiffMat[rowInd][colInd] = 0.0;
+}
+
+
+/*--------------------------------------------------------------------------------------------------------------------------
+** Public Functions
+*/
+
+
+/*----------------------------------------------------------------------------------------------------------------------------------
+** Private Functions
+*/

Added: 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:04 UTC (rev 6241)
+++ long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/src/ZeroBCs.h	2007-03-13 18:13:08 UTC (rev 6242)
@@ -0,0 +1,92 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+**
+** 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: ZeroBCs.h 3584 2006-05-16 11:11:07Z PatrickSunter $
+**
+**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+
+#ifndef __StgFEM_SLE_SystemSetup_ZeroBCs_h__
+#define __StgFEM_SLE_SystemSetup_ZeroBCs_h__
+
+	/** Textual name of this class */
+	extern const Type ZeroBCs_Type;
+
+	/** Virtual function types */
+
+	/** ZeroBCs class contents */
+	#define __ZeroBCs		\
+		/* General info */	\
+		__Assembler		\
+					\
+		/* Virtual info */	\
+					\
+		/* ZeroBCs info */
+
+	struct ZeroBCs { __ZeroBCs };
+
+	/*--------------------------------------------------------------------------------------------------------------------------
+	** Constructors
+	*/
+
+	#define ZEROBCS_DEFARGS \
+		ASSEMBLER_DEFARGS
+
+	#define ZEROBCS_PASSARGS \
+		STG_CLASS_PASSARGS
+
+	ZeroBCs* ZeroBCs_New();
+	ZeroBCs* _ZeroBCs_New( ZEROBCS_DEFARGS );
+	void _ZeroBCs_Init( ZeroBCs* self );
+
+	/*--------------------------------------------------------------------------------------------------------------------------
+	** Virtual functions
+	*/
+
+	void _ZeroBCs_Delete( void* assembler );
+	void _ZeroBCs_Print( void* assembler, Stream* stream );
+
+	Bool ZeroBCs_RowRestricted( void* assembler );
+	void ZeroBCs_ColRestricted( void* assembler );
+
+	/*--------------------------------------------------------------------------------------------------------------------------
+	** Public functions
+	*/
+
+	/*--------------------------------------------------------------------------------------------------------------------------
+	** Private Member functions
+	*/
+
+#endif /* __StgFEM_SLE_SystemSetup_ZeroBCs_h__ */

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:04 UTC (rev 6241)
+++ long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/src/types.h	2007-03-13 18:13:08 UTC (rev 6242)
@@ -63,6 +63,8 @@
 	typedef struct SLE_Solver                   SLE_Solver;
 	typedef struct FiniteElementContext         FiniteElementContext;
 	typedef struct Assembler		Assembler;
+	typedef struct ZeroBCs			ZeroBCs;
+	typedef struct CorrectRHS		CorrectRHS;
 
 	/* types for lists etc ... for readability */
 	typedef Index                       StiffnessMatrix_Index;



More information about the cig-commits mailing list