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

walter at geodynamics.org walter at geodynamics.org
Fri Dec 22 08:23:06 PST 2006


Author: walter
Date: 2006-12-22 08:23:04 -0800 (Fri, 22 Dec 2006)
New Revision: 5624

Added:
   long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/Finalise.c
   long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/Init.c
   long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/Matrix.c
   long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/Matrix.meta
   long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/MatrixSolver.c
   long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/MatrixSolver.meta
   long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/MultigridSolver.c
   long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/MultigridSolver.h
   long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/MultigridSolver.meta
   long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/PETScErrorChecking.h
   long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/PETScMatrix.c
   long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/PETScMatrix.h
   long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/PETScMatrix.meta
   long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/PETScMatrixSolver.c
   long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/PETScMatrixSolver.h
   long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/PETScMatrixSolver.meta
   long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/PETScVector.c
   long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/PETScVector.h
   long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/PETScVector.meta
   long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/Vector.c
   long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/Vector.meta
Removed:
   long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/Dummy/
   long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/PETSc/
   long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/Utils.h
   long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/dummy.c
Modified:
   long/3D/Gale/trunk/src/StgFEM/
   long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/LinearAlgebra.h
   long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/Matrix.h
   long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/MatrixSolver.h
   long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/Vector.h
   long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/types.h
Log:
Merge in changes from Luke.  SLE/LinearAlgebra/{PETSc,Dummy} were deleted, needing conflict resolution


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:671
db209038-57f2-0310-97fa-b160e0ae9d04:/trunk:669
   + 38867592-cf10-0410-9e16-a142ea72ac34:/cig:880
db209038-57f2-0310-97fa-b160e0ae9d04:/branches/decomp3d:675
db209038-57f2-0310-97fa-b160e0ae9d04:/trunk:669

Added: long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/Finalise.c
===================================================================
--- long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/Finalise.c	2006-12-22 14:06:39 UTC (rev 5623)
+++ long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/Finalise.c	2006-12-22 16:23:04 UTC (rev 5624)
@@ -0,0 +1,48 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+**
+** 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: Finalise.c 3462 2006-02-19 06:53:24Z WalterLandry $
+**
+**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+
+#include <stdio.h>
+#include <assert.h>
+
+#include <mpi.h>
+#include "StGermain/StGermain.h"
+
+#include "LinearAlgebra.h"
+
+
+Bool StgFEM_SLE_LinearAlgebra_Finalise( void ) {
+	Journal_Printf( Journal_Register( DebugStream_Type, "Context" ), "In: %s\n", __func__ ); /* DO NOT CHANGE OR REMOVE */
+
+#ifdef HAVE_PETSC
+	PetscFinalize();
+#endif
+
+	return True;
+}

Added: long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/Init.c
===================================================================
--- long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/Init.c	2006-12-22 14:06:39 UTC (rev 5623)
+++ long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/Init.c	2006-12-22 16:23:04 UTC (rev 5624)
@@ -0,0 +1,81 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+**
+** 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: Init.c 3901 2006-12-05 22:10:22Z LukeHodkinson $
+**
+**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+
+#include <stdio.h>
+#include <assert.h>
+
+#include <mpi.h>
+#include "StGermain/StGermain.h"
+
+#include "LinearAlgebra.h"
+
+
+Bool StgFEM_SLE_LinearAlgebra_Init( int* argc, char** argv[] ) {
+	int tmp;
+
+	Journal_Printf( Journal_Register( DebugStream_Type, "Context" ), "In: %s\n", __func__ ); /* DO NOT CHANGE OR REMOVE */
+	tmp = Stream_GetPrintingRank( Journal_Register( InfoStream_Type, "Context" ) );
+	Stream_SetPrintingRank( Journal_Register( InfoStream_Type, "Context" ), 0 );
+	Journal_Printf( /* DO NOT CHANGE OR REMOVE */
+		Journal_Register( InfoStream_Type, "Context" ), 
+		"StGermain PETSc-LinearAlgebra Interface revision %s. Copyright (C) 2003-2005 VPAC.\n", VERSION );
+	Stream_Flush( Journal_Register( InfoStream_Type, "Context" ) );
+	Stream_SetPrintingRank( Journal_Register( InfoStream_Type, "Context" ), tmp );
+
+	Stg_ComponentRegister_Add( Stg_ComponentRegister_Get_ComponentRegister(), 
+				   MultigridSolver_Type, "0", (Stg_Component_DefaultConstructorFunction*)MultigridSolver_New );
+
+	RegisterParent( Vector_Type, Stg_Component_Type );
+	RegisterParent( Matrix_Type, Stg_Component_Type );
+	RegisterParent( MatrixSolver_Type, Stg_Component_Type );
+	RegisterParent( MultigridSolver_Type, MatrixSolver_Type );
+
+#ifdef HAVE_PETSC
+	Stg_ComponentRegister_Add( Stg_ComponentRegister_Get_ComponentRegister(), 
+				   PETScVector_Type, "0", (Stg_Component_DefaultConstructorFunction*)PETScVector_New );
+	Stg_ComponentRegister_Add( Stg_ComponentRegister_Get_ComponentRegister(), 
+				   PETScMatrix_Type, "0", (Stg_Component_DefaultConstructorFunction*)PETScMatrix_New );
+	Stg_ComponentRegister_Add( Stg_ComponentRegister_Get_ComponentRegister(), 
+				   PETScMatrixSolver_Type, "0", (Stg_Component_DefaultConstructorFunction*)PETScMatrixSolver_New );
+
+	RegisterParent( PETScVector_Type, Vector_Type );
+	RegisterParent( PETScMatrix_Type, Matrix_Type );
+	RegisterParent( PETScMatrixSolver_Type, MatrixSolver_Type );
+
+	{
+		PetscErrorCode	ec;
+
+		ec = PetscInitialize( argc, argv, (char*)0, NULL );
+		CheckPETScError( ec );
+	}
+#endif
+
+	return True;
+}

Modified: long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/LinearAlgebra.h
===================================================================
--- long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/LinearAlgebra.h	2006-12-22 14:06:39 UTC (rev 5623)
+++ long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/LinearAlgebra.h	2006-12-22 16:23:04 UTC (rev 5624)
@@ -54,10 +54,22 @@
 #define __StgFEM_SLE_LinearAlgebra_h__
 	
 	#include "types.h"
-	#include "Utils.h"
 	#include "Vector.h"
 	#include "Matrix.h"
 	#include "MatrixSolver.h"
+	#include "MultigridSolver.h"
+
+#ifdef HAVE_PETSC
+	#include <petsc.h>
+	#include <petscvec.h>
+	#include <petscmat.h>
+	#include <petscksp.h>
+	#include "PETScErrorChecking.h"
+	#include "PETScVector.h"
+	#include "PETScMatrix.h"
+	#include "PETScMatrixSolver.h"
+#endif
+
 	#include "Init.h"
 	#include "Finalise.h"
 

Added: long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/Matrix.c
===================================================================
--- long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/Matrix.c	2006-12-22 14:06:39 UTC (rev 5623)
+++ long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/Matrix.c	2006-12-22 16:23:04 UTC (rev 5624)
@@ -0,0 +1,165 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+**
+** 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: Matrix.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 "LinearAlgebra.h"
+
+
+/* Textual name of this class */
+const Type Matrix_Type = "Matrix";
+
+
+/*----------------------------------------------------------------------------------------------------------------------------------
+** Constructors
+*/
+
+Matrix* _Matrix_New( MATRIX_DEFARGS ) {
+	Matrix*	self;
+
+	/* Allocate memory */
+	assert( sizeOfSelf >= sizeof(Matrix) );
+	self = (Matrix*)_Stg_Component_New( STG_COMPONENT_PASSARGS );
+
+	/* Virtual info */
+	self->setCommFunc = setCommFunc;
+	self->setGlobalSizeFunc = setGlobalSizeFunc;
+	self->setLocalSizeFunc = setLocalSizeFunc;
+	self->addEntriesFunc = addEntriesFunc;
+	self->insertEntriesFunc = insertEntriesFunc;
+	self->diagonalAddEntriesFunc = diagonalAddEntriesFunc;
+	self->diagonalInsertEntriesFunc = diagonalInsertEntriesFunc;
+	self->zeroFunc = zeroFunc;
+	self->loadFunc = loadFunc;
+	self->assemblyBeginFunc = assemblyBeginFunc;
+	self->assemblyEndFunc = assemblyEndFunc;
+
+	self->scaleFunc = scaleFunc;
+	self->addScaledFunc = addScaledFunc;
+	self->diagonalScaleFunc = diagonalScaleFunc;
+	self->multiplyFunc = multiplyFunc;
+	self->transposeMultiplyFunc = transposeMultiplyFunc;
+	self->multiplyAddFunc = multiplyAddFunc;
+	self->paptFunc = paptFunc;
+	self->ptapFunc = ptapFunc;
+	self->matrixMultiplyFunc = matrixMultiplyFunc;
+	self->l2NormFunc = l2NormFunc;
+	self->transposeFunc = transposeFunc;
+
+	self->getGlobalSizeFunc = getGlobalSizeFunc;
+	self->getLocalSizeFunc = getLocalSizeFunc;
+	self->getRowFunc = getRowFunc;
+	self->restoreRowFunc = restoreRowFunc;
+	self->getDiagonalFunc = getDiagonalFunc;
+	self->duplicateFunc = duplicateFunc;
+	self->copyEntriesFunc = copyEntriesFunc;
+	self->dumpFunc = dumpFunc;
+
+	/* Matrix info */
+	_Matrix_Init( self );
+
+	return self;
+}
+
+void _Matrix_Init( Matrix* self ) {
+	assert( self && Stg_CheckType( self, Matrix ) );
+
+	self->comm = MPI_COMM_WORLD;
+}
+
+
+/*----------------------------------------------------------------------------------------------------------------------------------
+** Virtual functions
+*/
+
+void _Matrix_Delete( void* matrix ) {
+	Matrix*	self = (Matrix*)matrix;
+
+	assert( self && Stg_CheckType( self, Matrix ) );
+
+	/* Delete the parent. */
+	_Stg_Component_Delete( self );
+}
+
+void _Matrix_Print( void* matrix, Stream* stream ) {
+	Matrix*	self = (Matrix*)matrix;
+	
+	/* Set the Journal for printing informations */
+	Stream* matrixStream;
+	matrixStream = Journal_Register( InfoStream_Type, "MatrixStream" );
+
+	assert( self && Stg_CheckType( self, Matrix ) );
+
+	/* Print parent */
+	Journal_Printf( stream, "Matrix (ptr): (%p)\n", self );
+	_Stg_Component_Print( self, stream );
+}
+
+void _Matrix_Construct( void* matrix, Stg_ComponentFactory* cf, void* data ) {
+	Matrix*	self = (Matrix*)matrix;
+
+	assert( self && Stg_CheckType( self, Matrix ) );
+	assert( cf );
+}
+
+void _Matrix_Build( void* matrix, void* data ) {
+}
+
+void _Matrix_Initialise( void* matrix, void* data ) {
+}
+
+void _Matrix_Execute( void* matrix, void* data ) {
+}
+
+void _Matrix_Destroy( void* matrix, void* data ) {
+}
+
+void _Matrix_SetComm( void* matrix, MPI_Comm comm ) {
+	Matrix*	self = (Matrix*)matrix;
+
+	assert( self && Stg_CheckType( self, Matrix ) );
+
+	self->comm = comm;
+}
+
+
+/*--------------------------------------------------------------------------------------------------------------------------
+** Public Functions
+*/
+
+
+/*----------------------------------------------------------------------------------------------------------------------------------
+** Private Functions
+*/

Modified: long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/Matrix.h
===================================================================
--- long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/Matrix.h	2006-12-22 14:06:39 UTC (rev 5623)
+++ long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/Matrix.h	2006-12-22 16:23:04 UTC (rev 5624)
@@ -1,25 +1,14 @@
 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 **
-** Copyright (C), 2003-2006, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street,
-**	Melbourne, 3053, Australia.
+** Copyright (C), 2003, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street, Melbourne, 3053, Australia.
 **
-** Primary Contributing Organisations:
-**	Victorian Partnership for Advanced Computing Ltd, Computational Software Development - http://csd.vpac.org
-**	Australian Computational Earth Systems Simulator - http://www.access.edu.au
-**	Monash Cluster Computing - http://www.mcc.monash.edu.au
-**	Computational Infrastructure for Geodynamics - http://www.geodynamics.org
-**
-** Contributors:
+** Authors:
+**	Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
 **	Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
-**	Robert Turnbull, Research Assistant, Monash University. (robert.turnbull at sci.monash.edu.au)
-**	Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
-**	David May, PhD Student, Monash University (david.may at sci.monash.edu.au)
-**	Louis Moresi, Associate Professor, Monash University. (louis.moresi at sci.monash.edu.au)
 **	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)
-**	Julian Giordani, Research Assistant, Monash University. (julian.giordani at sci.monash.edu.au)
-**	Vincent Lemiale, Postdoctoral Fellow, Monash University. (vincent.lemiale at sci.monash.edu.au)
 **
 **  This library is free software; you can redistribute it and/or
 **  modify it under the terms of the GNU Lesser General Public
@@ -41,6 +30,8 @@
 **
 ** Assumptions:
 **
+** Invariants:
+**
 ** Comments:
 **
 ** $Id$
@@ -49,80 +40,281 @@
 
 #ifndef __StgFEM_SLE_LinearAlgebra_Matrix_h__
 #define __StgFEM_SLE_LinearAlgebra_Matrix_h__
-	
-	Matrix* Matrix_New( 
-		MPI_Comm			comm,
-		Index				rowSize,
-		Index				colSize,
-		Index				nonZeroCount );
-	
-	
-	Matrix* Matrix_NewEmpty( MPI_Comm comm, unsigned rowLocalSize, unsigned colLocalSize );
-	
-	
-	Matrix* Matrix_New2( 
-		MPI_Comm			comm,
-		Index				rowSize,
-		Index				colSize, 
-		Index*				diagnolNonZeroIndices,
-		Index*				offDiagnolNonZeroIndices );
 
-	Matrix* Matrix_NewFromFile( Name filename );
-	
-	void Matrix_Dump( Matrix* matrix, Name filename ) ;
-	void Matrix_View( void* matrix, Stream* stream );
-	
-	void Matrix_Zero( void* matrix );
-	void Matrix_AddTo( 
-		void*				matrix,
-		Index				rowCount,
-		Index				rowIndices[],
-		Index				colCount,
-		Index				colIndices[],
-		double*				values );
-	void Matrix_Insert( 
-		void*				matrix,
-		Index				rowCount,
-		Index				rowIndices[],
-		Index				colCount,
-		Index				colIndices[],
-		double*				values );
-	void Matrix_SetValue( void* matrix, unsigned rowInd, unsigned colInd, double val );
-	void Matrix_AddValue( void* matrix, unsigned rowInd, unsigned colInd, double val );
-	void Matrix_ZeroRow( void* matrix, unsigned rowInd );
-	void Matrix_ZeroCol( void* matrix, unsigned colInd );
-	void Matrix_AssemblyBegin( void* matrix );
-	void Matrix_AssemblyEnd( void* matrix );
+	/** Textual name of this class */
+	extern const Type Matrix_Type;
 
-	void Matrix_DiagonalSet_Add( void* mat, void* vec);
-	void Matrix_DiagonalSet_Insert( void* mat, void* vec);
+	/** Virtual function types */
+	typedef void (Matrix_SetCommFunc)( void* matrix, MPI_Comm comm );
+	typedef void (Matrix_SetGlobalSizeFunc)( void* matrix, unsigned nRows, unsigned nColumns );
+	typedef void (Matrix_SetLocalSizeFunc)( void* matrix, unsigned nRows, unsigned nColumns );
+	typedef void (Matrix_AddEntriesFunc)( void* matrix, unsigned nRows, unsigned* rowIndices, 
+					      unsigned nColumns, unsigned* columnIndices, 
+					      double* values );
+	typedef void (Matrix_InsertEntriesFunc)( void* matrix, unsigned nRows, unsigned* rowIndices, 
+						 unsigned nColumns, unsigned* columnIndices, 
+						 double* values );
+	typedef void (Matrix_DiagonalAddEntriesFunc)( void* matrix, void* vector );
+	typedef void (Matrix_DiagonalInsertEntriesFunc)( void* matrix, void* vector );
+	typedef void (Matrix_ZeroFunc)( void* matrix );
+	typedef void (Matrix_LoadFunc)( void* matrix, char* filename );
+	typedef void (Matrix_AssemblyBeginFunc)( void* matrix );
+	typedef void (Matrix_AssemblyEndFunc)( void* matrix );
 
-	void Matrix_Scale( Matrix* mat, double scaleFactor );
-	
-	void MatrixMultiply( Matrix* A, Vector* x, Vector* b );
-	void MatrixTransposeMultiply( Matrix* A, Vector* x, Vector* y );
-	void MatrixMultiplyAdd( Matrix* A, Vector* x, Vector* y, Vector* z );
-	void MatrixDuplicate_DataStructureOnly( Matrix* mat, Matrix** mat_copy );
-	void MatrixDuplicate_IncludingValues( Matrix* A, Matrix** B );
+	typedef void (Matrix_ScaleFunc)( void* matrix, double factor );
+	typedef void (Matrix_AddScaledFunc)( void* matrix, double factor, void* matrix0 );
+	typedef void (Matrix_DiagonalScaleFunc)( void* matrix, void* leftVector, void* rightVector );
+	typedef void (Matrix_MultiplyFunc)( void* matrix, void* vector, void* dstVector );
+	typedef void (Matrix_TransposeMultiplyFunc)( void* matrix, void* vector, void* dstVector );
+	typedef void (Matrix_MultiplyAddFunc)( void* matrix, void* vector0, void* vector1, void* dstVector );
+	typedef void (Matrix_PAPtFunc)( void* matrix, void* P, void* dstMatrix );
+	typedef void (Matrix_PtAPFunc)( void* matrix, void* P, void* dstMatrix );
+	typedef void (Matrix_MatrixMultiplyFunc)( void* matrix, void* matrix0, void* dstMatrix );
+	typedef double (Matrix_L2NormFunc)( void* matrix );
+	typedef void (Matrix_TransposeFunc)( void* matrix, void* dstMatrix );
 
-	void Matrix_Destroy( Matrix* mat ); 
+	typedef void (Matrix_GetGlobalSizeFunc)( void* matrix, unsigned* nRows, unsigned* nColumns );
+	typedef void (Matrix_GetLocalSizeFunc)( void* matrix, unsigned* nRows, unsigned* nColumns );
+	typedef void (Matrix_GetRowFunc)( void* matrix, unsigned rowIndex, 
+					  unsigned* nEntries, unsigned** columnIndices, double** values );
+	typedef void (Matrix_RestoreRowFunc)( void* matrix, unsigned rowIndex, 
+					      unsigned* nEntries, unsigned** columnIndices, double** values );
+	typedef void (Matrix_GetDiagonalFunc)( void* matrix, void* vector );
+	typedef void (Matrix_DuplicateFunc)( void* matrix, void** dstMatrix );
+	typedef void (Matrix_CopyEntriesFunc)( void* matrix, void* dstMatrix );
+	typedef void (Matrix_DumpFunc)( void* matrix, char* filename );
 
-	void Matrix_AddScaledMatrix( Matrix* matrix, double scaleFactor, Matrix* matrixToAdd ) ;
-	void Matrix_ScaleAndAddMatrix( Matrix* matrix, double scaleFactor, Matrix* matrixToAdd ) ;
+	/** Matrix class contents */
+	#define __Matrix								\
+		/* General info */							\
+		__Stg_Component								\
+											\
+		/* Virtual info */							\
+		Matrix_SetCommFunc*			setCommFunc;			\
+		Matrix_SetGlobalSizeFunc*		setGlobalSizeFunc;		\
+		Matrix_SetLocalSizeFunc*		setLocalSizeFunc;		\
+		Matrix_AddEntriesFunc*			addEntriesFunc;			\
+		Matrix_InsertEntriesFunc*		insertEntriesFunc;		\
+		Matrix_DiagonalAddEntriesFunc*		diagonalAddEntriesFunc;		\
+		Matrix_DiagonalInsertEntriesFunc*	diagonalInsertEntriesFunc;	\
+		Matrix_ZeroFunc*			zeroFunc;			\
+		Matrix_LoadFunc*			loadFunc;			\
+		Matrix_AssemblyBeginFunc*		assemblyBeginFunc;		\
+		Matrix_AssemblyEndFunc*			assemblyEndFunc;		\
+											\
+		Matrix_ScaleFunc*			scaleFunc;			\
+		Matrix_AddScaledFunc*			addScaledFunc;			\
+		Matrix_DiagonalScaleFunc*		diagonalScaleFunc;		\
+		Matrix_MultiplyFunc*			multiplyFunc;			\
+		Matrix_TransposeMultiplyFunc*		transposeMultiplyFunc;		\
+		Matrix_MultiplyAddFunc*			multiplyAddFunc;		\
+		Matrix_PAPtFunc*			paptFunc;			\
+		Matrix_PtAPFunc*			ptapFunc;			\
+		Matrix_MatrixMultiplyFunc*		matrixMultiplyFunc;		\
+		Matrix_L2NormFunc*			l2NormFunc;			\
+		Matrix_TransposeFunc*			transposeFunc;			\
+											\
+		Matrix_GetGlobalSizeFunc*		getGlobalSizeFunc;		\
+		Matrix_GetLocalSizeFunc*		getLocalSizeFunc;		\
+		Matrix_GetRowFunc*			getRowFunc;			\
+		Matrix_RestoreRowFunc*			restoreRowFunc;			\
+		Matrix_GetDiagonalFunc*			getDiagonalFunc;		\
+		Matrix_DuplicateFunc*			duplicateFunc;			\
+		Matrix_CopyEntriesFunc*			copyEntriesFunc;		\
+		Matrix_DumpFunc*			dumpFunc;			\
+											\
+		/* Matrix info */					       		\
+		MPI_Comm		comm;
 
-	void Matrix_GetDiagonal( Matrix* matrix, Vector* vec );
-	void Matrix_DiagonalScale( Matrix* matrix, Vector* leftScale, Vector* rightScale );
-	
-	double Matrix_L2_Norm( Matrix* matrix ) ;
-	
-	void Matrix_Transpose( Matrix* srcMat, Matrix** dstMat );
-	
-	void Matrix_MatrixMult( Matrix* matA, Matrix* matB, Matrix** dst, double fillRatio );
-	void Matrix_MatrixMult_General( Matrix** cMat, Matrix* aMat, Matrix* bMat );
+	struct Matrix { __Matrix };
 
-	void Matrix_PtAP( Matrix* matA, Matrix* matP, Matrix** dst, double fillRatio );
-	void Matrix_GetLocalSize( Matrix* mat, unsigned* nRowsDst, unsigned* nColsDst );
-	void Matrix_GetRow( Matrix* mat, unsigned rowInd, unsigned* nEntries, unsigned** cols, double** entries );
-	void Matrix_RestoreRow( Matrix* mat, unsigned rowInd, unsigned nEntries, unsigned** cols, double** entries );
+	/*--------------------------------------------------------------------------------------------------------------------------
+	** Constructors
+	*/
 
+	#define MATRIX_DEFARGS								\
+		STG_COMPONENT_DEFARGS,							\
+		Matrix_SetCommFunc*			setCommFunc, 			\
+		Matrix_SetGlobalSizeFunc*		setGlobalSizeFunc,		\
+		Matrix_SetLocalSizeFunc*		setLocalSizeFunc,		\
+		Matrix_AddEntriesFunc*			addEntriesFunc,			\
+		Matrix_InsertEntriesFunc*		insertEntriesFunc,		\
+		Matrix_DiagonalAddEntriesFunc*		diagonalAddEntriesFunc,		\
+		Matrix_DiagonalInsertEntriesFunc*	diagonalInsertEntriesFunc, 	\
+		Matrix_ZeroFunc*			zeroFunc,			\
+		Matrix_LoadFunc*			loadFunc,			\
+		Matrix_AssemblyBeginFunc*		assemblyBeginFunc,		\
+		Matrix_AssemblyEndFunc*			assemblyEndFunc,		\
+											\
+		Matrix_ScaleFunc*			scaleFunc,			\
+		Matrix_AddScaledFunc*			addScaledFunc,			\
+		Matrix_DiagonalScaleFunc*		diagonalScaleFunc,		\
+		Matrix_MultiplyFunc*			multiplyFunc,			\
+		Matrix_TransposeMultiplyFunc*		transposeMultiplyFunc,		\
+		Matrix_MultiplyAddFunc*			multiplyAddFunc,		\
+		Matrix_PAPtFunc*			paptFunc,			\
+		Matrix_PtAPFunc*			ptapFunc,			\
+		Matrix_MatrixMultiplyFunc*		matrixMultiplyFunc,		\
+		Matrix_L2NormFunc*			l2NormFunc,			\
+		Matrix_TransposeFunc*			transposeFunc,			\
+											\
+		Matrix_GetGlobalSizeFunc*		getGlobalSizeFunc,		\
+		Matrix_GetLocalSizeFunc*		getLocalSizeFunc,		\
+		Matrix_GetRowFunc*			getRowFunc,			\
+		Matrix_RestoreRowFunc*			restoreRowFunc,			\
+		Matrix_GetDiagonalFunc*			getDiagonalFunc,		\
+		Matrix_DuplicateFunc*			duplicateFunc, 			\
+		Matrix_CopyEntriesFunc*			copyEntriesFunc,		\
+		Matrix_DumpFunc*			dumpFunc
+
+	#define MATRIX_PASSARGS			\
+		STG_COMPONENT_PASSARGS, 	\
+		setCommFunc, 			\
+		setGlobalSizeFunc,		\
+		setLocalSizeFunc,		\
+		addEntriesFunc,			\
+		insertEntriesFunc,		\
+		diagonalAddEntriesFunc,		\
+		diagonalInsertEntriesFunc,	\
+		zeroFunc,			\
+		loadFunc,			\
+		assemblyBeginFunc,		\
+		assemblyEndFunc,		\
+						\
+		scaleFunc,			\
+		addScaledFunc,			\
+		diagonalScaleFunc, 		\
+		multiplyFunc,			\
+		transposeMultiplyFunc,		\
+		multiplyAddFunc,		\
+		paptFunc,			\
+		ptapFunc,			\
+		matrixMultiplyFunc,		\
+		l2NormFunc,			\
+		transposeFunc,			\
+						\
+		getGlobalSizeFunc,		\
+		getLocalSizeFunc,		\
+		getRowFunc,			\
+		restoreRowFunc,			\
+		getDiagonalFunc,		\
+		duplicateFunc, 			\
+		copyEntriesFunc,		\
+		dumpFunc
+
+	Matrix* _Matrix_New( MATRIX_DEFARGS );
+	void _Matrix_Init( Matrix* self );
+
+	/*--------------------------------------------------------------------------------------------------------------------------
+	** Virtual functions
+	*/
+
+	void _Matrix_Delete( void* matrix );
+	void _Matrix_Print( void* matrix, Stream* stream );
+	void _Matrix_Construct( void* matrix, Stg_ComponentFactory* cf, void* data );
+	void _Matrix_Build( void* matrix, void* data );
+	void _Matrix_Initialise( void* matrix, void* data );
+	void _Matrix_Execute( void* matrix, void* data );
+	void _Matrix_Destroy( void* matrix, void* data );
+
+	void _Matrix_SetComm( void* matrix, MPI_Comm comm );
+
+	#define Matrix_SetComm( self, comm )									\
+		VirtualCall( self, setCommFunc, self, comm )
+
+	#define Matrix_SetGlobalSize( self, nRows, nColumns )							\
+		VirtualCall( self, setGlobalSizeFunc, self, nRows, nColumns )
+
+	#define Matrix_SetLocalSize( self, nRows, nColumns )							\
+		VirtualCall( self, setLocalSizeFunc, self, nRows, nColumns )
+
+	#define Matrix_AddEntries( self, nRows, rowIndices, nColumns, columnIndices, values )			\
+		VirtualCall( self, addEntriesFunc, self, nRows, rowIndices, nColumns, columnIndices, values )
+
+	#define Matrix_InsertEntries( self, nRows, rowIndices, nColumns, columnIndices, values )		\
+		VirtualCall( self, insertEntriesFunc, self, nRows, rowIndices, nColumns, columnIndices, values )
+
+	#define Matrix_DiagonalAddEntries( self, vector )							\
+		VirtualCall( self, diagonalAddEntriesFunc, self, vector )
+
+	#define Matrix_DiagonalInsertEntries( self, vector )							\
+		VirtualCall( self, diagonalInsertEntriesFunc, self, vector )
+
+	#define Matrix_Zero( self )										\
+		VirtualCall( self, zeroFunc, self )
+
+	#define Matrix_Load( self, filename )									\
+		VirtualCall( self, loadFunc, self, filename )
+
+	#define Matrix_AssemblyBegin( self )								\
+		VirtualCall( self, assemblyBeginFunc, self )
+
+	#define Matrix_AssemblyEnd( self )								\
+		VirtualCall( self, assemblyEndFunc, self )
+
+	#define Matrix_Scale( self, factor )								\
+		VirtualCall( self, scaleFunc, self, factor )
+
+	#define Matrix_AddScaled( self, factor, matrix0 )						\
+		VirtualCall( self, addScaledFunc, self, factor, matrix0 )
+
+	#define Matrix_DiagonalScale( self, leftVector, rightVector )					\
+		VirtualCall( self, diagonalScaleFunc, self, leftVector, rightVector )
+
+	#define Matrix_Multiply( self, vector, dstVector )						\
+		VirtualCall( self, multiplyFunc, self, vector, dstVector )
+
+	#define Matrix_TransposeMultiply( self, vector, dstVector )					\
+		VirtualCall( self, transposeMultiplyFunc, self, vector, dstVector )
+
+	#define Matrix_MultiplyAdd( self, vector0, vector1, dstVector )					\
+		VirtualCall( self, multiplyAddFunc, self, vector0, vector1, dstVector )
+
+	#define Matrix_PAPt( self, P, dstMatrix )							\
+		VirtualCall( self, paptFunc, self, P, dstMatrix )
+
+	#define Matrix_PtAP( self, P, dstMatrix )							\
+		VirtualCall( self, ptapFunc, self, P, dstMatrix )
+
+	#define Matrix_MatrixMultiply( self, matrix0, dstMatrix )					\
+		VirtualCall( self, matrixMultiplyFunc, self, matrix0, dstMatrix )
+
+	#define Matrix_L2Norm( self )									\
+		VirtualCall( self, l2NormFunc, self )
+
+	#define Matrix_Transpose( self, dstMatrix )							\
+		VirtualCall( self, transposeFunc, self, dstMatrix )
+
+	#define Matrix_GetGlobalSize( self, nRows, nColumns )						\
+		VirtualCall( self, getGlobalSizeFunc, self, nRows, nColumns )
+
+	#define Matrix_GetLocalSize( self, nRows, nColumns )						\
+		VirtualCall( self, getLocalSizeFunc, self, nRows, nColumns )
+
+	#define Matrix_GetRow( self, rowIndex, nEntries, columnIndices, values )			\
+		VirtualCall( self, getRowFunc, self, rowIndex, nEntries, columnIndices, values )
+
+	#define Matrix_RestoreRow( self, rowIndex, nEntries, columnIndices, values )			\
+		VirtualCall( self, restoreRowFunc, self, rowIndex, nEntries, columnIndices, values )
+
+	#define Matrix_GetDiagonal( self, vector )							\
+		VirtualCall( self, getDiagonalFunc, self, vector )
+
+	#define Matrix_Duplicate( self, dstMatrix )							\
+		VirtualCall( self, duplicateFunc, self, dstMatrix )
+
+	#define Matrix_CopyEntries( self, dstMatrix )							\
+		VirtualCall( self, copyEntriesFunc, self, dstMatrix )
+
+	#define Matrix_Dump( self, filename )									\
+		VirtualCall( self, dumpFunc, self, filename )
+
+	/*--------------------------------------------------------------------------------------------------------------------------
+	** Public functions
+	*/
+
+	/*--------------------------------------------------------------------------------------------------------------------------
+	** Private Member functions
+	*/
+
 #endif /* __StgFEM_SLE_LinearAlgebra_Matrix_h__ */

Added: long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/Matrix.meta
===================================================================
--- long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/Matrix.meta	2006-12-22 14:06:39 UTC (rev 5623)
+++ long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/Matrix.meta	2006-12-22 16:23:04 UTC (rev 5624)
@@ -0,0 +1,15 @@
+<?xml version="1.0"?>
+<!DOCTYPE StGermainData SYSTEM "stgermain.dtd">
+<StGermainData xmlns="http://www.vpac.org/StGermain/XML_IO_Handler/Jun2003">
+
+<param name="Name">Matrix</param>
+<param name="Organisation">VPAC</param>
+<param name="Project">StgFEM</param>
+<param name="Location">StgFEM/SLE/LinearAlgebra/src/</param>
+<param name="Project Web">https://csd.vpac.org/twiki/bin/view/StgFEM/WebHome</param>
+<param name="Copyright">StGermain Framework. Copyright (C) 2003-2005 VPAC.</param>
+<param name="License">The Gnu Lesser General Public License http://www.gnu.org/licenses/lgpl.html</param>
+<param name="Parent"></param>
+<param name="Description">...</param>
+
+</StGermainData>

Added: long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/MatrixSolver.c
===================================================================
--- long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/MatrixSolver.c	2006-12-22 14:06:39 UTC (rev 5623)
+++ long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/MatrixSolver.c	2006-12-22 16:23:04 UTC (rev 5624)
@@ -0,0 +1,188 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+**
+** 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: MatrixSolver.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 "LinearAlgebra.h"
+
+
+/* Textual name of this class */
+const Type MatrixSolver_Type = "MatrixSolver";
+
+
+/*----------------------------------------------------------------------------------------------------------------------------------
+** Constructors
+*/
+
+MatrixSolver* _MatrixSolver_New( MATRIXSOLVER_DEFARGS ) {
+	MatrixSolver*	self;
+
+	/* Allocate memory */
+	assert( sizeOfSelf >= sizeof(MatrixSolver) );
+	self = (MatrixSolver*)_Stg_Component_New( STG_COMPONENT_PASSARGS );
+
+	/* Virtual info */
+	self->setCommFunc = setCommFunc;
+	self->setMatrixFunc = setMatrixFunc;
+	self->setMaxIterationsFunc = setMaxIterationsFunc;
+	self->setRelativeToleranceFunc = setRelativeToleranceFunc;
+	self->setAbsoluteToleranceFunc = setAbsoluteToleranceFunc;
+	self->setUseInitialSolutionFunc = setUseInitialSolutionFunc;
+
+	self->solveFunc = solveFunc;
+	self->setupFunc = setupFunc;
+
+	self->getSolveStatusFunc = getSolveStatusFunc;
+	self->getIterationsFunc = getIterationsFunc;
+	self->getMaxIterationsFunc = getMaxIterationsFunc;
+
+	/* MatrixSolver info */
+	_MatrixSolver_Init( self );
+
+	return self;
+}
+
+void _MatrixSolver_Init( MatrixSolver* self ) {
+	assert( self && Stg_CheckType( self, MatrixSolver ) );
+}
+
+
+/*----------------------------------------------------------------------------------------------------------------------------------
+** Virtual functions
+*/
+
+void _MatrixSolver_Delete( void* matrixSolver ) {
+	MatrixSolver*	self = (MatrixSolver*)matrixSolver;
+
+	assert( self && Stg_CheckType( self, MatrixSolver ) );
+
+	/* Delete the parent. */
+	_Stg_Component_Delete( self );
+}
+
+void _MatrixSolver_Print( void* matrixSolver, Stream* stream ) {
+	MatrixSolver*	self = (MatrixSolver*)matrixSolver;
+	
+	/* Set the Journal for printing informations */
+	Stream* matrixSolverStream;
+	matrixSolverStream = Journal_Register( InfoStream_Type, "MatrixSolverStream" );
+
+	assert( self && Stg_CheckType( self, MatrixSolver ) );
+
+	/* Print parent */
+	Journal_Printf( stream, "MatrixSolver (ptr): (%p)\n", self );
+	_Stg_Component_Print( self, stream );
+}
+
+void _MatrixSolver_Construct( void* matrixSolver, Stg_ComponentFactory* cf, void* data ) {
+	MatrixSolver*		self = (MatrixSolver*)matrixSolver;
+
+	assert( self && Stg_CheckType( self, MatrixSolver ) );
+	assert( cf );
+}
+
+void _MatrixSolver_Build( void* matrixSolver, void* data ) {
+}
+
+void _MatrixSolver_Initialise( void* matrixSolver, void* data ) {
+}
+
+void _MatrixSolver_Execute( void* matrixSolver, void* data ) {
+}
+
+void _MatrixSolver_Destroy( void* matrixSolver, void* data ) {
+}
+
+void _MatrixSolver_SetComm( void* matrixSolver, MPI_Comm comm ) {
+	MatrixSolver*	self = (MatrixSolver*)matrixSolver;
+
+	assert( self && Stg_CheckType( self, MatrixSolver ) );
+
+	self->comm = comm;
+}
+
+void _MatrixSolver_SetMatrix( void* matrixSolver, void* matrix ) {
+	MatrixSolver*	self = (MatrixSolver*)matrixSolver;
+
+	assert( self && Stg_CheckType( self, MatrixSolver ) );
+	assert( !matrix || Stg_CheckType( matrix, Matrix ) );
+
+	self->matrix = matrix;
+}
+
+void _MatrixSolver_Setup( void* matrixSolver, void* rhs, void* solution ) {
+	MatrixSolver*	self = (MatrixSolver*)matrixSolver;
+
+	assert( self && Stg_CheckType( self, MatrixSolver ) );
+	assert( rhs && Stg_CheckType( rhs, Vector ) );
+	assert( solution && Stg_CheckType( solution, Vector ) );
+
+	self->curRHS = rhs;
+	self->curSolution = solution;
+}
+
+
+/*--------------------------------------------------------------------------------------------------------------------------
+** Public Functions
+*/
+
+void MatrixSolver_GetComm( void* matrixSolver, MPI_Comm comm ) {
+	MatrixSolver*	self = (MatrixSolver*)matrixSolver;
+
+	assert( self && Stg_CheckType( self, MatrixSolver ) );
+
+	return self->comm;
+}
+
+Matrix* MatrixSolver_GetMatrix( void* matrixSolver ) {
+	MatrixSolver*	self = (MatrixSolver*)matrixSolver;
+
+	assert( self && Stg_CheckType( self, MatrixSolver ) );
+
+	return self->matrix;
+}
+
+Vector* MatrixSolver_GetResidual( void* matrixSolver ) {
+	MatrixSolver*	self = (MatrixSolver*)matrixSolver;
+
+	assert( self && Stg_CheckType( self, MatrixSolver ) );
+
+	return self->residual;
+}
+
+
+/*----------------------------------------------------------------------------------------------------------------------------------
+** Private Functions
+*/

Modified: long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/MatrixSolver.h
===================================================================
--- long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/MatrixSolver.h	2006-12-22 14:06:39 UTC (rev 5623)
+++ long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/MatrixSolver.h	2006-12-22 16:23:04 UTC (rev 5624)
@@ -1,25 +1,14 @@
 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 **
-** Copyright (C), 2003-2006, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street,
-**	Melbourne, 3053, Australia.
+** Copyright (C), 2003, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street, Melbourne, 3053, Australia.
 **
-** Primary Contributing Organisations:
-**	Victorian Partnership for Advanced Computing Ltd, Computational Software Development - http://csd.vpac.org
-**	Australian Computational Earth Systems Simulator - http://www.access.edu.au
-**	Monash Cluster Computing - http://www.mcc.monash.edu.au
-**	Computational Infrastructure for Geodynamics - http://www.geodynamics.org
-**
-** Contributors:
+** Authors:
+**	Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
 **	Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
-**	Robert Turnbull, Research Assistant, Monash University. (robert.turnbull at sci.monash.edu.au)
-**	Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
-**	David May, PhD Student, Monash University (david.may at sci.monash.edu.au)
-**	Louis Moresi, Associate Professor, Monash University. (louis.moresi at sci.monash.edu.au)
 **	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)
-**	Julian Giordani, Research Assistant, Monash University. (julian.giordani at sci.monash.edu.au)
-**	Vincent Lemiale, Postdoctoral Fellow, Monash University. (vincent.lemiale at sci.monash.edu.au)
 **
 **  This library is free software; you can redistribute it and/or
 **  modify it under the terms of the GNU Lesser General Public
@@ -41,6 +30,8 @@
 **
 ** Assumptions:
 **
+** Invariants:
+**
 ** Comments:
 **
 ** $Id$
@@ -50,36 +41,153 @@
 #ifndef __StgFEM_SLE_LinearAlgebra_MatrixSolver_h__
 #define __StgFEM_SLE_LinearAlgebra_MatrixSolver_h__
 
-	MatrixSolver* MatrixSolver_Build( MPI_Comm comm, void* matrix );
-	void MatrixSolver_Setup( void* matSolver, void* matrix );
-	void MatrixSolver_SetupKSP( void* solver );
-	void MatrixSolver_Setup_SameNonZeroPattern( void* solverCtx, void* matrix );
-	void MatrixSolver_SetPC_Type( void* matSolver, char* pcType );
-	void MatrixSolver_SetKSP_Type( void* matSolver, char* kspType );
-    void MatrixSolver_SetMaxIts( void* matSolver, Iteration_Index maxIts );
-    void MatrixSolver_SetRelativeTolerance( void* matSolver, double relativeTolerance );
-    void MatrixSolver_SetAbsoluteTolerance( void* matSolver, double absoluteTolerance );
-	Iteration_Index MatrixSolver_Solve( MatrixSolver* matSolver, Vector* solnVec, Vector* rhsVec );
-	Iteration_Index MatrixSolver_StatSolve( MatrixSolver* solver, 
-						Vector* sol, Vector* rhs, 
-						unsigned nReps );
-	void MatrixSolver_Destroy( MatrixSolver* matSolver );
-	double MatrixSolver_GetResidualNorm( MatrixSolver* solver );
-	void MatrixSolver_HaveInitialGuess( MatrixSolver* solver );
-	void MatrixSolver_PC_GetBJacobiSubBlocks( MatrixSolver* solver, MatrixSolver*** blocks, unsigned* nBlocks );
-	void MatrixSolver_PC_SetSORIts( MatrixSolver* solver, unsigned nIts );
-	
-	void MatrixSolver_MG_SetLevels( MatrixSolver* solver, unsigned nLevels );
-	void MatrixSolver_MG_SetCycles( MatrixSolver* solver, unsigned level, unsigned nCycles );
-	void MatrixSolver_MG_SetLevelMatrix( MatrixSolver* solver, unsigned level, Matrix* mat );
-	void MatrixSolver_MG_SetSmoothUpIts( MatrixSolver* solver, unsigned nUpIts );
-	void MatrixSolver_MG_SetSmoothDownIts( MatrixSolver* solver, unsigned nDownIts );
-	void MatrixSolver_MG_GetDownSmoother( MatrixSolver* solver, unsigned level, MatrixSolver** smoother );
-	void MatrixSolver_MG_GetUpSmoother( MatrixSolver* solver, unsigned level, MatrixSolver** smoother );
-	void MatrixSolver_MG_SetRestrictionOp( MatrixSolver* solver, unsigned level, Matrix* op );
-	void MatrixSolver_MG_SetInterpolationOp( MatrixSolver* solver, unsigned level, Matrix* op );
-	void MatrixSolver_MG_SetWorkSpace( MatrixSolver* solver, unsigned level, Vector* rhsVec, Vector* xVec, Vector* rVec );
-	void MatrixSolver_MG_ForceMonitor( MatrixSolver* solver );
+	/** Textual name of this class */
+	extern const Type MatrixSolver_Type;
 
-#endif
+	/** Virtual function types */
+	typedef void (MatrixSolver_SetCommFunc)( void* matrixSolver, MPI_Comm comm );
+	typedef void (MatrixSolver_SetMatrixFunc)( void* matrixSolver, void* matrix );
+	typedef void (MatrixSolver_SetMaxIterationsFunc)( void* matrixSolver, unsigned nIterations );
+	typedef void (MatrixSolver_SetRelativeToleranceFunc)( void* matrixSolver, double tolerance );
+	typedef void (MatrixSolver_SetAbsoluteToleranceFunc)( void* matrixSolver, double tolerance );
+	typedef void (MatrixSolver_SetUseInitialSolutionFunc)( void* matrixSolver, Bool state );
 
+	typedef void (MatrixSolver_SolveFunc)( void* matrixSolver, void* rhs, void* solution );
+	typedef void (MatrixSolver_SetupFunc)( void* matrixSolver, void* rhs, void* solution );
+
+	typedef MatrixSolver_Status (MatrixSolver_GetSolveStatusFunc)( void* matrixSolver );
+	typedef unsigned (MatrixSolver_GetIterationsFunc)( void* matrixSolver );
+	typedef unsigned (MatrixSolver_GetMaxIterationsFunc)( void* matrixSolver );
+
+	/** MatrixSolver class contents */
+	#define __MatrixSolver									\
+		/* General info */								\
+		__Stg_Component									\
+												\
+		/* Virtual info */								\
+		MatrixSolver_SetCommFunc*			setCommFunc;			\
+		MatrixSolver_SetMatrixFunc*			setMatrixFunc;			\
+		MatrixSolver_SetMaxIterationsFunc*		setMaxIterationsFunc;		\
+		MatrixSolver_SetRelativeToleranceFunc*		setRelativeToleranceFunc;	\
+		MatrixSolver_SetAbsoluteToleranceFunc*		setAbsoluteToleranceFunc;	\
+		MatrixSolver_SetUseInitialSolutionFunc*		setUseInitialSolutionFunc;	\
+												\
+		MatrixSolver_SolveFunc*				solveFunc;			\
+		MatrixSolver_SetupFunc*				setupFunc;			\
+												\
+		MatrixSolver_GetSolveStatusFunc*		getSolveStatusFunc;		\
+		MatrixSolver_GetIterationsFunc*			getIterationsFunc;		\
+		MatrixSolver_GetMaxIterationsFunc*		getMaxIterationsFunc;		\
+												\
+		/* MatrixSolver info */								\
+		MPI_Comm		comm;							\
+		Matrix*			matrix;							\
+		Matrix*			inversion;						\
+		Vector*			residual;						\
+												\
+		Vector*			curRHS;							\
+		Vector*			curSolution;
+
+	struct MatrixSolver { __MatrixSolver };
+
+	/*--------------------------------------------------------------------------------------------------------------------------
+	** Constructors
+	*/
+
+	#define MATRIXSOLVER_DEFARGS								\
+		STG_COMPONENT_DEFARGS,								\
+		MatrixSolver_SetCommFunc*			setCommFunc,			\
+		MatrixSolver_SetMatrixFunc*			setMatrixFunc,			\
+		MatrixSolver_SetMaxIterationsFunc*		setMaxIterationsFunc,		\
+		MatrixSolver_SetRelativeToleranceFunc*		setRelativeToleranceFunc,	\
+		MatrixSolver_SetAbsoluteToleranceFunc*		setAbsoluteToleranceFunc,	\
+		MatrixSolver_SetUseInitialSolutionFunc*		setUseInitialSolutionFunc,	\
+												\
+		MatrixSolver_SolveFunc*				solveFunc,			\
+		MatrixSolver_SetupFunc*				setupFunc,			\
+												\
+		MatrixSolver_GetSolveStatusFunc*		getSolveStatusFunc,		\
+		MatrixSolver_GetIterationsFunc*			getIterationsFunc,		\
+		MatrixSolver_GetMaxIterationsFunc*		getMaxIterationsFunc
+
+	#define MATRIXSOLVER_PASSARGS		\
+		STG_COMPONENT_PASSARGS,		\
+		setCommFunc, 			\
+		setMatrixFunc,			\
+		setMaxIterationsFunc,		\
+		setRelativeToleranceFunc,	\
+		setAbsoluteToleranceFunc,	\
+		setUseInitialSolutionFunc,	\
+						\
+		solveFunc,			\
+		setupFunc,			\
+						\
+		getSolveStatusFunc,		\
+		getIterationsFunc,		\
+		getMaxIterationsFunc
+
+	MatrixSolver* _MatrixSolver_New( MATRIXSOLVER_DEFARGS );
+	void _MatrixSolver_Init( MatrixSolver* self );
+
+	/*--------------------------------------------------------------------------------------------------------------------------
+	** Virtual functions
+	*/
+
+	void _MatrixSolver_Delete( void* matrixSolver );
+	void _MatrixSolver_Print( void* matrixSolver, Stream* stream );
+	void _MatrixSolver_Construct( void* matrixSolver, Stg_ComponentFactory* cf, void* data );
+	void _MatrixSolver_Build( void* matrixSolver, void* data );
+	void _MatrixSolver_Initialise( void* matrixSolver, void* data );
+	void _MatrixSolver_Execute( void* matrixSolver, void* data );
+	void _MatrixSolver_Destroy( void* matrixSolver, void* data );
+
+	void _MatrixSolver_SetComm( void* matrixSolver, MPI_Comm comm );
+	void _MatrixSolver_SetMatrix( void* matrixSolver, void* matrix );
+	void _MatrixSolver_Setup( void* matrixSolver, void* rhs, void* solution );
+
+	#define MatrixSolver_SetComm( self, comm )			\
+		VirtualCall( self, setCommFunc, self, comm )
+
+	#define MatrixSolver_SetMatrix( self, matrix )			\
+		VirtualCall( self, setMatrixFunc, self, matrix )
+
+	#define MatrixSolver_SetMaxIterations( self, nIterations )	\
+		VirtualCall( self, setMaxIterationsFunc, self, nIterations )
+
+	#define MatrixSolver_SetRelativeTolerance( self, tolerance )	\
+		VirtualCall( self, setRelativeToleranceFunc, self, tolerance )
+
+	#define MatrixSolver_SetAbsoluteTolerance( self, tolerance )	\
+		VirtualCall( self, setAbsoluteToleranceFunc, self, tolerance )
+
+	#define MatrixSolver_SetUseInitialSolution( self, state )	\
+		VirtualCall( self, setUseInitialSolutionFunc, self, state )
+
+	#define MatrixSolver_Solve( self, rhs, solution )			\
+		VirtualCall( self, solveFunc, self, rhs, solution )
+
+	#define MatrixSolver_Setup( self, rhs, solution )		\
+		VirtualCall( self, setupFunc, self, rhs, solution )
+
+	#define MatrixSolver_GetSolveStatus( self )			\
+		VirtualCall( self, getSolveStatusFunc, self )
+
+	#define MatrixSolver_GetIterations( self )			\
+		VirtualCall( self, getIterationsFunc, self )
+
+	#define MatrixSolver_GetMaxIterations( self )			\
+		VirtualCall( self, getMaxIterationsFunc, self )
+
+	/*--------------------------------------------------------------------------------------------------------------------------
+	** Public functions
+	*/
+
+	void MatrixSolver_GetComm( void* matrixSolver, MPI_Comm comm );
+	Matrix* MatrixSolver_GetMatrix( void* matrixSolver );
+	Vector* MatrixSolver_GetResidual( void* matrixSolver );
+
+	/*--------------------------------------------------------------------------------------------------------------------------
+	** Private Member functions
+	*/
+
+#endif /* __StgFEM_SLE_LinearAlgebra_MatrixSolver_h__ */

Added: long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/MatrixSolver.meta
===================================================================
--- long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/MatrixSolver.meta	2006-12-22 14:06:39 UTC (rev 5623)
+++ long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/MatrixSolver.meta	2006-12-22 16:23:04 UTC (rev 5624)
@@ -0,0 +1,15 @@
+<?xml version="1.0"?>
+<!DOCTYPE StGermainData SYSTEM "stgermain.dtd">
+<StGermainData xmlns="http://www.vpac.org/StGermain/XML_IO_Handler/Jun2003">
+
+<param name="Name">MatrixSolver</param>
+<param name="Organisation">VPAC</param>
+<param name="Project">StgFEM</param>
+<param name="Location">StgFEM/SLE/LinearAlgebra/src/</param>
+<param name="Project Web">https://csd.vpac.org/twiki/bin/view/StgFEM/WebHome</param>
+<param name="Copyright">StGermain Framework. Copyright (C) 2003-2005 VPAC.</param>
+<param name="License">The Gnu Lesser General Public License http://www.gnu.org/licenses/lgpl.html</param>
+<param name="Parent"></param>
+<param name="Description">...</param>
+
+</StGermainData>

Added: long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/MultigridSolver.c
===================================================================
--- long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/MultigridSolver.c	2006-12-22 14:06:39 UTC (rev 5623)
+++ long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/MultigridSolver.c	2006-12-22 16:23:04 UTC (rev 5624)
@@ -0,0 +1,571 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+**
+** 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: MultigridSolver.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 "LinearAlgebra.h"
+
+
+/* Textual name of this class */
+const Type MultigridSolver_Type = "MultigridSolver";
+
+
+/*----------------------------------------------------------------------------------------------------------------------------------
+** Constructors
+*/
+
+MultigridSolver* MultigridSolver_New( Name name ) {
+	return _MultigridSolver_New( sizeof(MultigridSolver), 
+				     MultigridSolver_Type, 
+				     _MultigridSolver_Delete, 
+				     _MultigridSolver_Print, 
+				     NULL, 
+				     (void* (*)(Name))_MultigridSolver_New, 
+				     _MultigridSolver_Construct, 
+				     _MultigridSolver_Build, 
+				     _MultigridSolver_Initialise, 
+				     _MultigridSolver_Execute, 
+				     _MultigridSolver_Destroy, 
+				     name, 
+				     NON_GLOBAL, 
+				     _MatrixSolver_SetComm, 
+				     _MatrixSolver_SetMatrix, 
+				     MultigridSolver_SetMaxIterations, 
+				     MultigridSolver_SetRelativeTolerance, 
+				     MultigridSolver_SetAbsoluteTolerance, 
+				     MultigridSolver_SetUseInitialSolution, 
+				     MultigridSolver_Solve, 
+				     MultigridSolver_Setup, 
+				     MultigridSolver_GetSolveStatus, 
+				     MultigridSolver_GetIterations, 
+				     MultigridSolver_GetMaxIterations );
+}
+
+MultigridSolver* _MultigridSolver_New( MULTIGRIDSOLVER_DEFARGS ) {
+	MultigridSolver*	self;
+
+	/* Allocate memory */
+	assert( sizeOfSelf >= sizeof(MultigridSolver) );
+	self = (MultigridSolver*)_MatrixSolver_New( MATRIXSOLVER_PASSARGS );
+
+	/* Virtual info */
+
+	/* MultigridSolver info */
+	_MultigridSolver_Init( self );
+
+	return self;
+}
+
+void _MultigridSolver_Init( MultigridSolver* self ) {
+	assert( self && Stg_CheckType( self, MultigridSolver ) );
+
+	self->nLevels = 0;
+	self->levels = NULL;
+	self->ready = False;
+
+#ifdef HAVE_PETSC
+	self->outerSolver = (MatrixSolver*)PETScMatrixSolver_New( "" );
+	PETScMatrixSolver_SetKSPType( self->outerSolver, PETScMatrixSolver_KSPType_Richardson );
+	PETScMatrixSolver_SetPCType( self->outerSolver, PETScMatrixSolver_PCType_None );
+	PETScMatrixSolver_SetUseInitialSolution( self->outerSolver, True );
+	PETScMatrixSolver_SetMaxIterations( self->outerSolver, 1 );
+#else
+	self->outerSolver = NULL;
+#endif
+}
+
+
+/*----------------------------------------------------------------------------------------------------------------------------------
+** Virtual functions
+*/
+
+void _MultigridSolver_Delete( void* matrixSolver ) {
+	MultigridSolver*	self = (MultigridSolver*)matrixSolver;
+
+	assert( self && Stg_CheckType( self, MultigridSolver ) );
+
+	MultigridSolver_Destruct( self );
+
+	/* Delete the parent. */
+	_MatrixSolver_Delete( self );
+}
+
+void _MultigridSolver_Print( void* matrixSolver, Stream* stream ) {
+	MultigridSolver*	self = (MultigridSolver*)matrixSolver;
+	
+	/* Set the Journal for printing informations */
+	Stream* matrixSolverStream;
+	matrixSolverStream = Journal_Register( InfoStream_Type, "MultigridSolverStream" );
+
+	assert( self && Stg_CheckType( self, MultigridSolver ) );
+
+	/* Print parent */
+	Journal_Printf( stream, "MultigridSolver (ptr): (%p)\n", self );
+	_MatrixSolver_Print( self, stream );
+}
+
+void _MultigridSolver_Construct( void* matrixSolver, Stg_ComponentFactory* cf, void* data ) {
+	MultigridSolver*	self = (MultigridSolver*)matrixSolver;
+
+	assert( self && Stg_CheckType( self, MultigridSolver ) );
+	assert( cf );
+}
+
+void _MultigridSolver_Build( void* matrixSolver, void* data ) {
+}
+
+void _MultigridSolver_Initialise( void* matrixSolver, void* data ) {
+}
+
+void _MultigridSolver_Execute( void* matrixSolver, void* data ) {
+}
+
+void _MultigridSolver_Destroy( void* matrixSolver, void* data ) {
+}
+
+void MultigridSolver_SetMaxIterations( void* matrixSolver, unsigned nIterations ) {
+	MultigridSolver*	self = (MultigridSolver*)matrixSolver;
+
+	assert( self && Stg_CheckType( self, MultigridSolver ) );
+
+	self->maxIts = nIterations;
+}
+
+void MultigridSolver_SetRelativeTolerance( void* matrixSolver, double tolerance ) {
+	MultigridSolver*	self = (MultigridSolver*)matrixSolver;
+
+	assert( self && Stg_CheckType( self, MultigridSolver ) );
+
+	MatrixSolver_SetRelativeTolerance( self->outerSolver, tolerance );
+}
+
+void MultigridSolver_SetAbsoluteTolerance( void* matrixSolver, double tolerance ) {
+	MultigridSolver*	self = (MultigridSolver*)matrixSolver;
+
+	assert( self && Stg_CheckType( self, MultigridSolver ) );
+
+	MatrixSolver_SetAbsoluteTolerance( self->outerSolver, tolerance );
+}
+
+void MultigridSolver_SetUseInitialSolution( void* matrixSolver, Bool state ) {
+	MultigridSolver*	self = (MultigridSolver*)matrixSolver;
+
+	assert( self && Stg_CheckType( self, MultigridSolver ) );
+
+	self->useInitial = state;
+}
+
+void MultigridSolver_Solve( void* matrixSolver, void* _rhs, void* _solution ) {
+	MultigridSolver*	self = (MultigridSolver*)matrixSolver;
+	Vector*			rhs = (Vector*)_rhs;
+	Vector*			solution = (Vector*)_solution;
+	unsigned		curIt = 0;
+
+	assert( self && Stg_CheckType( self, MultigridSolver ) );
+	assert( rhs && Stg_CheckType( rhs, Vector ) );
+	assert( solution && Stg_CheckType( solution, Vector ) );
+
+	if( !self->useInitial )
+		Vector_Zero( solution );
+
+	MultigridSolver_Setup( self, rhs, solution );
+	self->curIt = 0;
+	while( MatrixSolver_GetSolveStatus( self ) == MatrixSolver_Status_Iterating && curIt++ < self->maxIts ) {
+		MultigridSolver_LevelCycle( self, self->nLevels - 1, rhs, solution );
+		self->curIt++;
+	}
+}
+
+void MultigridSolver_Setup( void* matrixSolver, void* _rhs, void* _solution ) {
+	MultigridSolver*	self = (MultigridSolver*)matrixSolver;
+	Vector*			rhs = (Vector*)_rhs;
+	Vector*			solution = (Vector*)_solution;
+	unsigned		l_i;
+
+	assert( self && Stg_CheckType( self, MultigridSolver ) );
+	assert( rhs && Stg_CheckType( rhs, Vector ) );
+	assert( solution && Stg_CheckType( solution, Vector ) );
+
+	MatrixSolver_Setup( self, rhs, solution );
+
+	if( self->ready )
+		return;
+
+	for( l_i = self->nLevels - 1; l_i < self->nLevels; l_i-- ) {
+		MultigridSolver_Level*	level = self->levels + l_i;
+
+		if( MatrixSolver_GetMaxIterations( level->downSolver ) != level->nDownIts )
+			MatrixSolver_SetMaxIterations( level->downSolver, level->nDownIts );
+		if( level->upSolver != level->downSolver ) {
+			if( MatrixSolver_GetMaxIterations( level->upSolver ) != level->nUpIts )
+				MatrixSolver_SetMaxIterations( level->upSolver, level->nUpIts );
+		}
+
+		if( l_i < self->nLevels - 1 ) {
+			Matrix*	mat;
+
+			mat = MatrixSolver_GetMatrix( level->downSolver );
+			if( !mat )
+				Matrix_Duplicate( self->matrix, (void**)&mat );
+			MultigridSolver_RestrictMatrix( self, level, mat );
+			MatrixSolver_SetMatrix( level->downSolver, mat );
+			if( level->upSolver != level->downSolver )
+				MatrixSolver_SetMatrix( level->upSolver, mat );
+		}
+		else {
+			MatrixSolver_SetMatrix( level->downSolver, self->matrix );
+			if( level->upSolver != level->downSolver )
+				MatrixSolver_SetMatrix( level->upSolver, self->matrix );
+		}
+
+		MatrixSolver_SetUseInitialSolution( level->downSolver, True );
+		if( level->upSolver != level->downSolver )
+			MatrixSolver_SetUseInitialSolution( level->upSolver, True );
+	}
+
+	for( l_i = 1; l_i < self->nLevels; l_i++ ) {
+		MultigridSolver_Level*	level = self->levels + l_i;
+		MultigridSolver_Level*	nextLevel = self->levels + l_i - 1;
+		unsigned		rowSize, colSize;
+
+		Matrix_GetLocalSize( MatrixSolver_GetMatrix( nextLevel->downSolver ), &rowSize, &colSize );
+		Vector_Duplicate( solution, (void**)&level->nextSol );
+		Vector_SetLocalSize( level->nextSol, rowSize );
+		Vector_Duplicate( rhs, (void**)&level->nextRHS );
+		Vector_SetLocalSize( level->nextRHS, rowSize );
+	}
+
+	MatrixSolver_SetMatrix( self->outerSolver,  self->matrix );
+
+	self->ready = True;
+}
+
+MatrixSolver_Status MultigridSolver_GetSolveStatus( void* matrixSolver ) {
+	MultigridSolver*	self = (MultigridSolver*)matrixSolver;
+	MatrixSolver_Status	outerStatus;
+
+	assert( self && Stg_CheckType( self, MultigridSolver ) );
+
+	MatrixSolver_Solve( self->outerSolver, self->curRHS, self->curSolution );
+	outerStatus = MatrixSolver_GetSolveStatus( self->outerSolver );
+	if( outerStatus == MatrixSolver_Status_ConvergedIterations )
+		return MatrixSolver_Status_Iterating;
+	else
+		return outerStatus;
+}
+
+unsigned MultigridSolver_GetIterations( void* matrixSolver ) {
+	MultigridSolver*	self = (MultigridSolver*)matrixSolver;
+
+	assert( self && Stg_CheckType( self, MultigridSolver ) );
+
+	return self->curIt;
+}
+
+unsigned MultigridSolver_GetMaxIterations( void* matrixSolver ) {
+	MultigridSolver*	self = (MultigridSolver*)matrixSolver;
+
+	assert( self && Stg_CheckType( self, MultigridSolver ) );
+
+	return self->maxIts;
+}
+
+
+/*--------------------------------------------------------------------------------------------------------------------------
+** Public Functions
+*/
+
+void MultigridSolver_SetLevels( void* matrixSolver, unsigned nLevels ) {
+	MultigridSolver*	self = (MultigridSolver*)matrixSolver;
+	unsigned		l_i;
+
+	assert( self && Stg_CheckType( self, MultigridSolver ) );
+
+	MultigridSolver_Destruct( self );
+	self->nLevels = nLevels;
+	self->levels = AllocArray( MultigridSolver_Level, nLevels );
+	for( l_i = 0; l_i < nLevels; l_i++ ) {
+		MultigridSolver_Level*	level = self->levels + l_i;
+
+		level->nDownIts = 1;
+		level->nUpIts = 1;
+		level->nCycles = 1;
+
+		if( l_i == 0 ) {
+			/* Create direct solve. */
+			level->downSolver = NULL;
+		}
+		else if( l_i == 1 ) {
+			/* Create smoother. */
+			level->downSolver = NULL;
+		}
+		else {
+			/* Copy previous smoother. */
+			level->downSolver = self->levels[l_i - 1].downSolver;
+			Stg_Class_AddRef( level->downSolver );
+		}
+		level->upSolver = level->downSolver;
+		Stg_Class_AddRef( level->upSolver );
+
+		level->R = NULL;
+		level->P = NULL;
+	}
+}
+
+void MultigridSolver_SetLevelDownSolver( void* matrixSolver, unsigned level, MatrixSolver* solver ) {
+	MultigridSolver*	self = (MultigridSolver*)matrixSolver;
+	MatrixSolver*		curSolver;
+
+	assert( self && Stg_CheckType( self, MultigridSolver ) );
+	assert( level < self->nLevels );
+
+	curSolver = self->levels[level].downSolver;
+	if( curSolver )
+		Stg_Class_RemoveRef( curSolver );
+	self->levels[level].downSolver = solver;
+	if( solver )
+		Stg_Class_AddRef( solver );
+
+	self->ready = False;
+}
+
+void MultigridSolver_SetLevelDownIterations( void* matrixSolver, unsigned level, unsigned nIts ) {
+	MultigridSolver*	self = (MultigridSolver*)matrixSolver;
+
+	assert( self && Stg_CheckType( self, MultigridSolver ) );
+	assert( level < self->nLevels );
+
+	self->levels[level].nDownIts = nIts;
+	self->ready = False;
+}
+
+void MultigridSolver_SetLevelUpSolver( void* matrixSolver, unsigned level, MatrixSolver* solver ) {
+	MultigridSolver*	self = (MultigridSolver*)matrixSolver;
+	MatrixSolver*		curSolver;
+
+	assert( self && Stg_CheckType( self, MultigridSolver ) );
+	assert( level < self->nLevels );
+	assert( level > 0 );
+
+	curSolver = self->levels[level].upSolver;
+	if( curSolver )
+		Stg_Class_RemoveRef( curSolver );
+	self->levels[level].upSolver = solver;
+	if( solver )
+		Stg_Class_AddRef( solver );
+
+	self->ready = False;
+}
+
+void MultigridSolver_SetLevelUpIterations( void* matrixSolver, unsigned level, unsigned nIts ) {
+	MultigridSolver*	self = (MultigridSolver*)matrixSolver;
+
+	assert( self && Stg_CheckType( self, MultigridSolver ) );
+	assert( level < self->nLevels );
+	assert( level > 0 );
+
+	self->levels[level].nUpIts = nIts;
+	self->ready = False;
+}
+
+void MultigridSolver_SetLevelCycles( void* matrixSolver, unsigned level, unsigned nCycles ) {
+	MultigridSolver*	self = (MultigridSolver*)matrixSolver;
+
+	assert( self && Stg_CheckType( self, MultigridSolver ) );
+	assert( level < self->nLevels );
+	assert( level > 0 );
+
+	self->levels[level].nCycles = nCycles;
+	self->ready = False;
+}
+
+void MultigridSolver_SetAllDownSolver( void* matrixSolver, MatrixSolver* solver ) {
+	MultigridSolver*	self = (MultigridSolver*)matrixSolver;
+	unsigned		l_i;
+
+	assert( self && Stg_CheckType( self, MultigridSolver ) );
+
+	for( l_i = 1; l_i < self->nLevels; l_i++ )
+		MultigridSolver_SetLevelDownSolver( self, l_i, solver );
+}
+
+void MultigridSolver_SetAllDownIterations( void* matrixSolver, unsigned level, unsigned nIts ) {
+	MultigridSolver*	self = (MultigridSolver*)matrixSolver;
+	unsigned		l_i;
+
+	assert( self && Stg_CheckType( self, MultigridSolver ) );
+
+	for( l_i = 1; l_i < self->nLevels; l_i++ )
+		MultigridSolver_SetLevelDownIterations( self, l_i, nIts );
+}
+
+void MultigridSolver_SetAllUpSolver( void* matrixSolver, MatrixSolver* solver ) {
+	MultigridSolver*	self = (MultigridSolver*)matrixSolver;
+	unsigned		l_i;
+
+	assert( self && Stg_CheckType( self, MultigridSolver ) );
+
+	for( l_i = 1; l_i < self->nLevels; l_i++ )
+		MultigridSolver_SetLevelUpSolver( self, l_i, solver );
+}
+
+void MultigridSolver_SetAllUpIterations( void* matrixSolver, unsigned level, unsigned nIts ) {
+	MultigridSolver*	self = (MultigridSolver*)matrixSolver;
+	unsigned		l_i;
+
+	assert( self && Stg_CheckType( self, MultigridSolver ) );
+
+	for( l_i = 1; l_i < self->nLevels; l_i++ )
+		MultigridSolver_SetLevelUpIterations( self, l_i, nIts );
+}
+
+void MultigridSolver_SetAllSolver( void* matrixSolver, MatrixSolver* solver ) {
+	MultigridSolver*	self = (MultigridSolver*)matrixSolver;
+
+	assert( self );
+
+	MultigridSolver_SetAllDownSolver( self, solver );
+	MultigridSolver_SetAllUpSolver( self, solver );
+}
+
+void MultigridSolver_SetCoarseSolver( void* matrixSolver, MatrixSolver* solver ) {
+	MultigridSolver*	self = (MultigridSolver*)matrixSolver;
+
+	assert( self );
+
+	MultigridSolver_SetLevelDownSolver( self, 0, solver );
+}
+
+void MultigridSolver_SetRestriction( void* matrixSolver, unsigned level, Matrix* matrix ) {
+	MultigridSolver*	self = (MultigridSolver*)matrixSolver;
+	Matrix*			curMat;
+
+	assert( self );
+	assert( level < self->nLevels && level > 0 );
+
+	curMat = self->levels[level].R;
+	self->levels[level].R = matrix;
+	if( matrix )
+		Stg_Class_AddRef( matrix );
+	if( curMat )
+		Stg_Class_RemoveRef( curMat );
+
+	self->ready = False;
+}
+
+void MultigridSolver_SetProlongation( void* matrixSolver, unsigned level, Matrix* matrix ) {
+	MultigridSolver*	self = (MultigridSolver*)matrixSolver;
+	Matrix*			curMat;
+
+	assert( self );
+	assert( level < self->nLevels && level > 0 );
+
+	curMat = self->levels[level].P;
+	self->levels[level].P = matrix;
+	if( matrix )
+		Stg_Class_AddRef( matrix );
+	if( curMat )
+		Stg_Class_RemoveRef( curMat );
+
+	self->ready = False;
+}
+
+
+/*----------------------------------------------------------------------------------------------------------------------------------
+** Private Functions
+*/
+
+void MultigridSolver_RestrictMatrix( MultigridSolver* self, MultigridSolver_Level* level, Matrix* dstMatrix ) {
+	Matrix		*srcMat, *R;
+	unsigned	nSrcRows, nSrcCols;
+	unsigned	nRRows, nRCols;
+
+	assert( self );
+	assert( level );
+	assert( dstMatrix );
+
+	srcMat = MatrixSolver_GetMatrix( level->downSolver ); assert( srcMat );
+	Matrix_GetGlobalSize( srcMat, &nSrcRows, &nSrcCols );
+	Matrix_GetGlobalSize( R, &nRRows, &nRCols );
+	if( nRCols == nSrcRows )
+		Matrix_PAPt( dstMatrix, R, srcMat );
+	else
+		Matrix_PtAP( dstMatrix, R, srcMat );
+}
+
+void MultigridSolver_LevelCycle( MultigridSolver* self, unsigned levelInd, Vector* rhs, Vector* solution ) {
+	MultigridSolver_Level*	level;
+
+	assert( self );
+	assert( levelInd < self->nLevels );
+
+	level = self->levels + levelInd;
+
+	if( level->nDownIts )
+		MatrixSolver_Solve( level->downSolver, rhs, solution );
+
+	if( levelInd > 0 ) {
+		unsigned	c_i;
+
+		Matrix_Multiply( level->R, MatrixSolver_GetResidual( level->downSolver ), level->nextRHS );
+		for( c_i = 0; c_i < level->nCycles; c_i++ )
+			MultigridSolver_LevelCycle( self, levelInd - 1, level->nextSol, level->nextRHS );
+	}
+
+	Matrix_MultiplyAdd( level->P, level->nextSol, solution, solution );
+}
+
+void MultigridSolver_Destruct( MultigridSolver* self ) {
+	unsigned	l_i;
+
+	assert( self );
+
+	for( l_i = 0; l_i < self->nLevels; l_i++ ) {
+		MultigridSolver_Level*	level = self->levels + l_i;
+
+		if( level->downSolver )
+			Stg_Class_RemoveRef( level->downSolver );
+		if( level->upSolver )
+			Stg_Class_RemoveRef( level->upSolver );
+		if( level->R )
+			Stg_Class_RemoveRef( level->R );
+		if( level->P )
+			Stg_Class_RemoveRef( level->P );
+	}
+
+	KillArray( self->levels );
+	self->nLevels = 0;
+	self->ready = False;
+}

Added: long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/MultigridSolver.h
===================================================================
--- long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/MultigridSolver.h	2006-12-22 14:06:39 UTC (rev 5623)
+++ long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/MultigridSolver.h	2006-12-22 16:23:04 UTC (rev 5624)
@@ -0,0 +1,147 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+**
+** 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: MultigridSolver.h 3584 2006-05-16 11:11:07Z PatrickSunter $
+**
+**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+
+#ifndef __StgFEM_SLE_LinearAlgebra_MultigridSolver_h__
+#define __StgFEM_SLE_LinearAlgebra_MultigridSolver_h__
+
+	/** Textual name of this class */
+	extern const Type MultigridSolver_Type;
+
+	/** Virtual function types */
+
+	/** MultigridSolver class contents */
+	typedef struct {
+		MatrixSolver*	downSolver;
+		unsigned	nDownIts;
+		MatrixSolver*	upSolver;
+		unsigned	nUpIts;
+		unsigned	nCycles;
+
+		Matrix*		R;
+		Matrix*		P;
+
+		Vector*		nextRHS;
+		Vector*		nextSol;
+		Vector*		residual;
+	} MultigridSolver_Level;
+
+	#define __MultigridSolver			\
+		/* General info */			\
+		__MatrixSolver				\
+							\
+		/* Virtual info */			\
+							\
+		/* MultigridSolver info */		\
+		unsigned		nLevels;	\
+		MultigridSolver_Level*	levels;		\
+		Bool			ready;		\
+							\
+		unsigned		curIt;		\
+		unsigned		maxIts;		\
+		Bool			useInitial;	\
+		MatrixSolver*		outerSolver;
+
+	struct MultigridSolver { __MultigridSolver };
+
+	/*--------------------------------------------------------------------------------------------------------------------------
+	** Constructors
+	*/
+
+	#define MULTIGRIDSOLVER_DEFARGS	\
+		MATRIXSOLVER_DEFARGS
+
+	#define MULTIGRIDSOLVER_PASSARGS \
+		MATRIXSOLVER_PASSARGS
+
+	MultigridSolver* MultigridSolver_New( Name name );
+	MultigridSolver* _MultigridSolver_New( MATRIXSOLVER_DEFARGS );
+	void _MultigridSolver_Init( MultigridSolver* self );
+
+	/*--------------------------------------------------------------------------------------------------------------------------
+	** Virtual functions
+	*/
+
+	void _MultigridSolver_Delete( void* matrixSolver );
+	void _MultigridSolver_Print( void* matrixSolver, Stream* stream );
+	void _MultigridSolver_Construct( void* matrixSolver, Stg_ComponentFactory* cf, void* data );
+	void _MultigridSolver_Build( void* matrixSolver, void* data );
+	void _MultigridSolver_Initialise( void* matrixSolver, void* data );
+	void _MultigridSolver_Execute( void* matrixSolver, void* data );
+	void _MultigridSolver_Destroy( void* matrixSolver, void* data );
+
+	void MultigridSolver_SetMaxIterations( void* matrixSolver, unsigned nIterations );
+	void MultigridSolver_SetRelativeTolerance( void* matrixSolver, double tolerance );
+	void MultigridSolver_SetAbsoluteTolerance( void* matrixSolver, double tolerance );
+	void MultigridSolver_SetUseInitialSolution( void* matrixSolver, Bool state );
+
+	void MultigridSolver_Solve( void* matrixSolver, void* rhs, void* solution );
+	void MultigridSolver_Setup( void* matrixSolver, void* rhs, void* solution );
+
+	MatrixSolver_Status MultigridSolver_GetSolveStatus( void* matrixSolver );
+	unsigned MultigridSolver_GetIterations( void* matrixSolver );
+	unsigned MultigridSolver_GetMaxIterations( void* matrixSolver );
+
+	/*--------------------------------------------------------------------------------------------------------------------------
+	** Public functions
+	*/
+
+	void MultigridSolver_SetLevels( void* matrixSolver, unsigned nLevels );
+	void MultigridSolver_SetLevelDownSolver( void* matrixSolver, unsigned level, MatrixSolver* solver );
+	void MultigridSolver_SetLevelDownIterations( void* matrixSolver, unsigned level, unsigned nIts );
+	void MultigridSolver_SetLevelUpSolver( void* matrixSolver, unsigned level, MatrixSolver* solver );
+	void MultigridSolver_SetLevelUpIterations( void* matrixSolver, unsigned level, unsigned nIts );
+	void MultigridSolver_SetLevelCycles( void* matrixSolver, unsigned level, unsigned nCycles );
+	void MultigridSolver_SetAllDownSolver( void* matrixSolver, MatrixSolver* solver );
+	void MultigridSolver_SetAllDownIterations( void* matrixSolver, unsigned level, unsigned nIts );
+	void MultigridSolver_SetAllUpSolver( void* matrixSolver, MatrixSolver* solver );
+	void MultigridSolver_SetAllUpIterations( void* matrixSolver, unsigned level, unsigned nIts );
+	void MultigridSolver_SetAllSolver( void* matrixSolver, MatrixSolver* solver );
+	void MultigridSolver_SetCoarseSolver( void* matrixSolver, MatrixSolver* solver );
+
+	/*--------------------------------------------------------------------------------------------------------------------------
+	** Private Member functions
+	*/
+
+	void MultigridSolver_RestrictMatrix( MultigridSolver* self, MultigridSolver_Level* level, Matrix* dstMatrix );
+	void MultigridSolver_LevelCycle( MultigridSolver* self, unsigned levelInd, Vector* rhs, Vector* solution );
+	void MultigridSolver_CalcResidual( MultigridSolver* self, Vector* solution, Vector* residual );
+	void MultigridSolver_Destruct( MultigridSolver* self );
+
+#endif /* __StgFEM_SLE_LinearAlgebra_MultigridSolver_h__ */

Added: long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/MultigridSolver.meta
===================================================================
--- long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/MultigridSolver.meta	2006-12-22 14:06:39 UTC (rev 5623)
+++ long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/MultigridSolver.meta	2006-12-22 16:23:04 UTC (rev 5624)
@@ -0,0 +1,15 @@
+<?xml version="1.0"?>
+<!DOCTYPE StGermainData SYSTEM "stgermain.dtd">
+<StGermainData xmlns="http://www.vpac.org/StGermain/XML_IO_Handler/Jun2003">
+
+<param name="Name">MultigridSolver</param>
+<param name="Organisation">VPAC</param>
+<param name="Project">StgFEM</param>
+<param name="Location">StgFEM/SLE/LinearAlgebra/src/</param>
+<param name="Project Web">https://csd.vpac.org/twiki/bin/view/StgFEM/WebHome</param>
+<param name="Copyright">StGermain Framework. Copyright (C) 2003-2005 VPAC.</param>
+<param name="License">The Gnu Lesser General Public License http://www.gnu.org/licenses/lgpl.html</param>
+<param name="Parent"></param>
+<param name="Description">...</param>
+
+</StGermainData>

Added: long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/PETScErrorChecking.h
===================================================================
--- long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/PETScErrorChecking.h	2006-12-22 14:06:39 UTC (rev 5623)
+++ long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/PETScErrorChecking.h	2006-12-22 16:23:04 UTC (rev 5624)
@@ -0,0 +1,52 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+**
+** Copyright (C), 2003-2006, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street,
+**	Melbourne, 3053, Australia.
+**
+** Primary Contributing Organisations:
+**	Victorian Partnership for Advanced Computing Ltd, Computational Software Development - http://csd.vpac.org
+**	Australian Computational Earth Systems Simulator - http://www.access.edu.au
+**	Monash Cluster Computing - http://www.mcc.monash.edu.au
+**	Computational Infrastructure for Geodynamics - http://www.geodynamics.org
+**
+** Contributors:
+**	Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
+**	Robert Turnbull, Research Assistant, Monash University. (robert.turnbull at sci.monash.edu.au)
+**	Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
+**	David May, PhD Student, Monash University (david.may at sci.monash.edu.au)
+**	Louis Moresi, Associate Professor, Monash University. (louis.moresi at sci.monash.edu.au)
+**	Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
+**	Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
+**	Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
+**	Julian Giordani, Research Assistant, Monash University. (julian.giordani at sci.monash.edu.au)
+**	Vincent Lemiale, Postdoctoral Fellow, Monash University. (vincent.lemiale at sci.monash.edu.au)
+**
+**  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
+**
+*/
+
+#ifndef __StgFEM_SLE_LinearAlgebra_PETScErrorChecking_h__
+#define __StgFEM_SLE_LinearAlgebra_PETScErrorChecking_h__
+	
+	#define CheckPETScError( errorFlag ) \
+		do {								\
+			if ( ! errorFlag ) { 				\
+				Stream* myNewErrorStream = Journal_Register( Error_Type, CURR_MODULE_NAME );	\
+				CHKERRCONTINUE(errorFlag); 			\
+				Journal_Firewall( ! errorFlag , myNewErrorStream, "Function %s failed.\n", __func__ );	\
+			}						\
+		} while (0)
+
+#endif	/* __StgFEM_SLE_LinearAlgebra_PETScErrorChecking_h__ */

Added: long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/PETScMatrix.c
===================================================================
--- long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/PETScMatrix.c	2006-12-22 14:06:39 UTC (rev 5623)
+++ long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/PETScMatrix.c	2006-12-22 16:23:04 UTC (rev 5624)
@@ -0,0 +1,678 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+**
+** 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: PETScMatrix.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 "LinearAlgebra.h"
+
+
+/* Textual name of this class */
+const Type PETScMatrix_Type = "PETScMatrix";
+
+
+/*----------------------------------------------------------------------------------------------------------------------------------
+** Constructors
+*/
+
+PETScMatrix* PETScMatrix_New( Name name ) {
+	return _PETScMatrix_New( sizeof(PETScMatrix), 
+				 PETScMatrix_Type, 
+				 _PETScMatrix_Delete, 
+				 _PETScMatrix_Print, 
+				 NULL, 
+				 (void* (*)(Name))PETScMatrix_New, 
+				 _PETScMatrix_Construct, 
+				 _PETScMatrix_Build, 
+				 _PETScMatrix_Initialise, 
+				 _PETScMatrix_Execute, 
+				 _PETScMatrix_Destroy, 
+				 name, 
+				 NON_GLOBAL, 
+				 PETScMatrix_SetComm, 
+				 PETScMatrix_SetGlobalSize, 
+				 PETScMatrix_SetLocalSize, 
+				 PETScMatrix_AddEntries, 
+				 PETScMatrix_InsertEntries, 
+				 PETScMatrix_DiagonalAddEntries, 
+				 PETScMatrix_DiagonalInsertEntries, 
+				 PETScMatrix_Zero, 
+				 PETScMatrix_Load, 
+				 PETScMatrix_AssemblyBegin, 
+				 PETScMatrix_AssemblyEnd, 
+				 PETScMatrix_Scale, 
+				 PETScMatrix_AddScaled, 
+				 PETScMatrix_DiagonalScale, 
+				 PETScMatrix_Multiply, 
+				 PETScMatrix_TransposeMultiply, 
+				 PETScMatrix_MultiplyAdd, 
+				 PETScMatrix_PAPt, 
+				 PETScMatrix_PtAP, 
+				 PETScMatrix_MatrixMultiply, 
+				 PETScMatrix_L2Norm, 
+				 PETScMatrix_Transpose, 
+				 PETScMatrix_GetGlobalSize, 
+				 PETScMatrix_GetLocalSize, 
+				 PETScMatrix_GetRow, 
+				 PETScMatrix_RestoreRow, 
+				 PETScMatrix_GetDiagonal, 
+				 PETScMatrix_Duplicate, 
+				 PETScMatrix_CopyEntries, 
+				 PETScMatrix_Dump );
+}
+
+PETScMatrix* _PETScMatrix_New( PETSCMATRIX_DEFARGS ) {
+	PETScMatrix*	self;
+
+	/* Allocate memory */
+	assert( sizeOfSelf >= sizeof(PETScMatrix) );
+	self = (PETScMatrix*)_Matrix_New( MATRIX_PASSARGS );
+
+	/* Virtual info */
+
+	/* PETScMatrix info */
+	_PETScMatrix_Init( self );
+
+	return self;
+}
+
+void _PETScMatrix_Init( PETScMatrix* self ) {
+	assert( self && Stg_CheckType( self, PETScMatrix ) );
+
+	self->petscMat = PETSC_NULL;
+}
+
+
+/*----------------------------------------------------------------------------------------------------------------------------------
+** Virtual functions
+*/
+
+void _PETScMatrix_Delete( void* matrix ) {
+	PETScMatrix*	self = (PETScMatrix*)matrix;
+
+	assert( self && Stg_CheckType( self, PETScMatrix ) );
+
+	if( self->petscMat != PETSC_NULL ) {
+		PetscErrorCode	ec;
+
+		ec = MatDestroy( self->petscMat );
+		CheckPETScError( ec );
+	}
+
+	/* Delete the parent. */
+	_Matrix_Delete( self );
+}
+
+void _PETScMatrix_Print( void* matrix, Stream* stream ) {
+	PETScMatrix*	self = (PETScMatrix*)matrix;
+	
+	/* Set the Journal for printing informations */
+	Stream* matrixStream;
+	matrixStream = Journal_Register( InfoStream_Type, "PETScMatrixStream" );
+
+	assert( self && Stg_CheckType( self, PETScMatrix ) );
+
+	/* Print parent */
+	Journal_Printf( stream, "PETScMatrix (ptr): (%p)\n", self );
+	_Matrix_Print( self, stream );
+}
+
+void _PETScMatrix_Construct( void* matrix, Stg_ComponentFactory* cf, void* data ) {
+	PETScMatrix*	self = (PETScMatrix*)matrix;
+
+	assert( self && Stg_CheckType( self, PETScMatrix ) );
+	assert( cf );
+}
+
+void _PETScMatrix_Build( void* matrix, void* data ) {
+}
+
+void _PETScMatrix_Initialise( void* matrix, void* data ) {
+}
+
+void _PETScMatrix_Execute( void* matrix, void* data ) {
+}
+
+void _PETScMatrix_Destroy( void* matrix, void* data ) {
+}
+
+void PETScMatrix_SetComm( void* matrix, MPI_Comm comm ) {
+	PETScMatrix*	self = (PETScMatrix*)matrix;
+	PetscErrorCode	ec;
+
+	assert( self && Stg_CheckType( self, PETScMatrix ) );
+
+	_Matrix_SetComm( self, comm );
+
+	if( self->petscMat != PETSC_NULL )
+		MatDestroy( self->petscMat );
+	ec = MatCreate( self->comm, &self->petscMat );
+	CheckPETScError( ec );
+}
+
+void PETScMatrix_SetGlobalSize( void* matrix, unsigned nRows, unsigned nColumns ) {
+	PETScMatrix*	self = (PETScMatrix*)matrix;
+	PetscErrorCode	ec;
+
+	assert( self && Stg_CheckType( self, PETScMatrix ) );
+
+	ec = MatSetSizes( self->petscMat, PETSC_DETERMINE, PETSC_DETERMINE, (PetscInt)nRows, (PetscInt)nColumns );
+	CheckPETScError( ec );
+	ec = MatSetFromOptions( self->petscMat );
+	CheckPETScError( ec );
+}
+
+void PETScMatrix_SetLocalSize( void* matrix, unsigned nRows, unsigned nColumns ) {
+	PETScMatrix*	self = (PETScMatrix*)matrix;
+	PetscErrorCode	ec;
+
+	assert( self && Stg_CheckType( self, PETScMatrix ) );
+
+	ec = MatSetSizes( self->petscMat, (PetscInt)nRows, (PetscInt)nColumns, PETSC_DETERMINE, PETSC_DETERMINE );
+	CheckPETScError( ec );
+	ec = MatSetFromOptions( self->petscMat );
+	CheckPETScError( ec );
+}
+
+void PETScMatrix_AddEntries( void* matrix, unsigned nRows, unsigned* rowIndices, 
+			     unsigned nColumns, unsigned* columnIndices, 
+			     double* values )
+{
+	PETScMatrix*	self = (PETScMatrix*)matrix;
+	PetscErrorCode	ec;
+
+	assert( self && Stg_CheckType( self, PETScMatrix ) );
+	assert( !nRows || rowIndices );
+	assert( !nColumns || columnIndices );
+	assert( (!nRows && !nColumns) || values );
+	assert( sizeof(PetscInt) == sizeof(unsigned) );
+
+	ec = MatSetValues( self->petscMat, (PetscInt)nRows, (PetscInt*)rowIndices, 
+			   (PetscInt)nColumns, (PetscInt*)columnIndices, 
+			   (PetscScalar*)values, ADD_VALUES );
+	CheckPETScError( ec );
+}
+
+void PETScMatrix_InsertEntries( void* matrix, unsigned nRows, unsigned* rowIndices, 
+				unsigned nColumns, unsigned* columnIndices, 
+				double* values )
+{
+	PETScMatrix*	self = (PETScMatrix*)matrix;
+	PetscErrorCode	ec;
+
+	assert( self && Stg_CheckType( self, PETScMatrix ) );
+	assert( !nRows || rowIndices );
+	assert( !nColumns || columnIndices );
+	assert( (!nRows && !nColumns) || values );
+
+	ec = MatSetValues( self->petscMat, (PetscInt)nRows, (PetscInt*)rowIndices, 
+			   (PetscInt)nColumns, (PetscInt*)columnIndices, 
+			   (PetscScalar*)values, INSERT_VALUES );
+	CheckPETScError( ec );
+}
+
+void PETScMatrix_DiagonalAddEntries( void* matrix, void* _vector ) {
+	PETScMatrix*	self = (PETScMatrix*)matrix;
+	PETScVector*	vector = (PETScVector*)_vector;
+	PetscErrorCode	ec;
+
+	assert( self && Stg_CheckType( self, PETScMatrix ) );
+	assert( vector && Stg_CheckType( vector, PETScVector ) );
+
+	ec = MatDiagonalSet( self->petscMat, vector->petscVec, ADD_VALUES );
+	CheckPETScError( ec );
+}
+
+void PETScMatrix_DiagonalInsertEntries( void* matrix, void* _vector ) {
+	PETScMatrix*	self = (PETScMatrix*)matrix;
+	PETScVector*	vector = (PETScVector*)_vector;
+	PetscErrorCode	ec;
+
+	assert( self && Stg_CheckType( self, PETScMatrix ) );
+	assert( vector && Stg_CheckType( vector, PETScVector ) );
+
+	ec = MatDiagonalSet( self->petscMat, vector->petscVec, INSERT_VALUES );
+	CheckPETScError( ec );
+}
+
+void PETScMatrix_Zero( void* matrix ) {
+	PETScMatrix*	self = (PETScMatrix*)matrix;
+	PetscErrorCode	ec;
+
+	assert( self && Stg_CheckType( self, PETScMatrix ) );
+
+	ec = MatZeroEntries( self->petscMat );
+	CheckPETScError( ec );
+}
+
+void PETScMatrix_Load( void* matrix, char* filename ) {
+	PETScMatrix*	self = (PETScMatrix*)matrix;
+	PetscViewer	viewer;
+	PetscErrorCode	ec;
+
+	assert( self && Stg_CheckType( self, PETScMatrix ) );
+
+	ec = PetscViewerBinaryOpen( PETSC_COMM_SELF, filename, FILE_MODE_READ, &viewer );
+	CheckPETScError( ec );
+	if( self->petscMat != PETSC_NULL )
+		MatDestroy( self->petscMat );
+	ec = MatLoad( viewer, MATSEQAIJ, &self->petscMat );
+	CheckPETScError( ec );
+	ec = PetscViewerDestroy( viewer );
+	CheckPETScError( ec );
+}
+
+void PETScMatrix_AssemblyBegin( void* matrix ) {
+	PETScMatrix*	self = (PETScMatrix*)matrix;
+	PetscErrorCode	ec;
+
+	assert( self && Stg_CheckType( self, PETScMatrix ) );
+
+	ec = MatAssemblyBegin( self->petscMat, MAT_FINAL_ASSEMBLY );
+	CheckPETScError( ec );
+}
+
+void PETScMatrix_AssemblyEnd( void* matrix ) {
+	PETScMatrix*	self = (PETScMatrix*)matrix;
+	PetscErrorCode	ec;
+
+	assert( self && Stg_CheckType( self, PETScMatrix ) );
+
+	ec = MatAssemblyEnd( self->petscMat, MAT_FINAL_ASSEMBLY );
+	CheckPETScError( ec );
+}
+
+void PETScMatrix_Scale( void* matrix, double factor ) {
+	PETScMatrix*	self = (PETScMatrix*)matrix;
+	PetscErrorCode	ec;
+
+	assert( self && Stg_CheckType( self, PETScMatrix ) );
+
+	ec = MatScale( self->petscMat, (PetscScalar)factor );
+	CheckPETScError( ec );
+}
+
+void PETScMatrix_AddScaled( void* matrix, double factor, void* _matrix0 ) {
+	PETScMatrix*	self = (PETScMatrix*)matrix;
+	PETScMatrix*	matrix0 = (PETScMatrix*)_matrix0;
+	PetscErrorCode	ec;
+
+	assert( self && Stg_CheckType( self, PETScMatrix ) );
+	assert( matrix0 && Stg_CheckType( matrix0, PETScMatrix ) );
+
+	ec = MatAXPY( self->petscMat, (PetscScalar)factor, matrix0->petscMat, SAME_NONZERO_PATTERN );
+	CheckPETScError( ec );
+}
+
+void PETScMatrix_DiagonalScale( void* matrix, void* _leftVector, void* _rightVector ) {
+	PETScMatrix*	self = (PETScMatrix*)matrix;
+	PETScVector*	leftVector = (PETScVector*)_leftVector;
+	PETScVector*	rightVector = (PETScVector*)_rightVector;
+	PetscErrorCode	ec;
+
+	assert( self && Stg_CheckType( self, PETScMatrix ) );
+	assert( leftVector ? (leftVector && Stg_CheckType( leftVector, PETScVector )) : (rightVector != NULL) );
+	assert( rightVector ? (rightVector && Stg_CheckType( rightVector, PETScVector )) : (leftVector != NULL) );
+
+	ec = MatDiagonalScale( self->petscMat, leftVector ? leftVector->petscVec : PETSC_NULL, 
+			       rightVector ? rightVector->petscVec : PETSC_NULL );
+	CheckPETScError( ec );
+}
+
+void PETScMatrix_Multiply( void* matrix, void* _vector, void* _dstVector ) {
+	PETScMatrix*	self = (PETScMatrix*)matrix;
+	PETScVector*	vector = (PETScVector*)_vector;
+	PETScVector*	dstVector = (PETScVector*)_dstVector;
+	PetscErrorCode	ec;
+
+	assert( self && Stg_CheckType( self, PETScMatrix ) );
+	assert( vector && Stg_CheckType( vector, PETScVector ) );
+	assert( dstVector && Stg_CheckType( dstVector, PETScVector ) );
+
+	ec = MatMult( self->petscMat, vector->petscVec, dstVector->petscVec );
+	CheckPETScError( ec );
+}
+
+void PETScMatrix_TransposeMultiply( void* matrix, void* _vector, void* _dstVector ) {
+	PETScMatrix*	self = (PETScMatrix*)matrix;
+	PETScVector*	vector = (PETScVector*)_vector;
+	PETScVector*	dstVector = (PETScVector*)_dstVector;
+	PetscErrorCode	ec;
+
+	assert( self && Stg_CheckType( self, PETScMatrix ) );
+	assert( vector && Stg_CheckType( vector, PETScVector ) );
+	assert( dstVector && Stg_CheckType( dstVector, PETScVector ) );
+
+	ec = MatMultTranspose( self->petscMat, vector->petscVec, dstVector->petscVec );
+	CheckPETScError( ec );
+}
+
+void PETScMatrix_MultiplyAdd( void* matrix, void* _vector0, void* _vector1, void* _dstVector ) {
+	PETScMatrix*	self = (PETScMatrix*)matrix;
+	PETScVector*	vector0 = (PETScVector*)_vector0;
+	PETScVector*	vector1 = (PETScVector*)_vector1;
+	PETScVector*	dstVector = (PETScVector*)_dstVector;
+	PetscErrorCode	ec;
+
+	assert( self && Stg_CheckType( self, PETScMatrix ) );
+	assert( vector0 && Stg_CheckType( vector0, PETScVector ) );
+	assert( vector1 && Stg_CheckType( vector1, PETScVector ) );
+	assert( dstVector && Stg_CheckType( dstVector, PETScVector ) );
+
+	ec = MatMultAdd( self->petscMat, vector0->petscVec, vector1->petscVec, dstVector->petscVec );
+	CheckPETScError( ec );
+}
+
+void PETScMatrix_PAPt( void* matrix, void* _P, void* _dstMatrix ) {
+	PETScMatrix*	self = (PETScMatrix*)matrix;
+	PETScMatrix*	P = (PETScMatrix*)_P;
+	PETScMatrix*	dstMatrix = (PETScMatrix*)_dstMatrix;
+	PetscErrorCode	ec;
+	double		fillRatio;
+	double		nRowsA, nRowsC;
+	double		nzA, nzP, nzC;
+	MatInfo		mInfo;
+
+	assert( self && Stg_CheckType( self, PETScMatrix ) );
+	assert( P && Stg_CheckType( P, PETScMatrix ) );
+	assert( dstMatrix && Stg_CheckType( dstMatrix, PETScMatrix ) );
+
+	MatGetInfo( self->petscMat, MAT_GLOBAL_SUM, &mInfo );
+	nRowsA = mInfo.rows_global;
+	nzA = mInfo.nz_used;
+
+	MatGetInfo( P->petscMat, MAT_GLOBAL_SUM, &mInfo );
+	nRowsC = mInfo.columns_global;
+	nzP = mInfo.nz_used;
+
+	nzC = (nRowsC / nRowsA) * nzA;
+	fillRatio = nzC / (nzA + nzP);
+
+	assert( 0 );
+	/*ec = MatPAPt( self->petscMat, P->petscMat, MAT_REUSE_MATRIX, (PetscScalar)fillRatio, &dstMatrix->petscMat );*/
+	CheckPETScError( ec );
+}
+
+void PETScMatrix_PtAP( void* matrix, void* _P, void* _dstMatrix ) {
+	PETScMatrix*	self = (PETScMatrix*)matrix;
+	PETScMatrix*	P = (PETScMatrix*)_P;
+	PETScMatrix*	dstMatrix = (PETScMatrix*)_dstMatrix;
+	PetscErrorCode	ec;
+	double		fillRatio;
+	double		nRowsA, nRowsC;
+	double		nzA, nzP, nzC;
+	MatInfo		mInfo;
+
+	assert( self && Stg_CheckType( self, PETScMatrix ) );
+	assert( P && Stg_CheckType( P, PETScMatrix ) );
+	assert( dstMatrix && Stg_CheckType( dstMatrix, PETScMatrix ) );
+
+	MatGetInfo( self->petscMat, MAT_GLOBAL_SUM, &mInfo );
+	nRowsA = mInfo.rows_global;
+	nzA = mInfo.nz_used;
+
+	MatGetInfo( P->petscMat, MAT_GLOBAL_SUM, &mInfo );
+	nRowsC = mInfo.columns_global;
+	nzP = mInfo.nz_used;
+
+	nzC = (nRowsC / nRowsA) * nzA;
+	fillRatio = nzC / (nzA + nzP);
+
+	if( dstMatrix->petscMat != PETSC_NULL )
+		ec = MatDestroy( dstMatrix->petscMat );
+	CheckPETScError( ec );
+	ec = MatPtAP( self->petscMat, P->petscMat, MAT_INITIAL_MATRIX, (PetscScalar)fillRatio, &dstMatrix->petscMat );
+	CheckPETScError( ec );
+}
+
+void PETScMatrix_MatrixMultiply( void* matrix, void* _matrix0, void* _dstMatrix ) {
+	PETScMatrix*	self = (PETScMatrix*)matrix;
+	PETScMatrix*	matrix0 = (PETScMatrix*)_matrix0;
+	PETScMatrix*	dstMatrix = (PETScMatrix*)_dstMatrix;
+	PetscErrorCode	ec;
+	double		fillRatio;
+	double		nRowsA, nRowsC;
+	double		nzA, nzP, nzC;
+	MatInfo		mInfo;
+
+	assert( self && Stg_CheckType( self, PETScMatrix ) );
+	assert( matrix0 && Stg_CheckType( matrix0, PETScMatrix ) );
+	assert( dstMatrix && Stg_CheckType( dstMatrix, PETScMatrix ) );
+
+	MatGetInfo( self->petscMat, MAT_GLOBAL_SUM, &mInfo );
+	nRowsA = mInfo.rows_global;
+	nzA = mInfo.nz_used;
+
+	MatGetInfo( matrix0->petscMat, MAT_GLOBAL_SUM, &mInfo );
+	nRowsC = mInfo.columns_global;
+	nzP = mInfo.nz_used;
+
+	nzC = (nRowsC / nRowsA) * nzA;
+	fillRatio = nzC / (nzA + nzP);
+
+	if( dstMatrix->petscMat != PETSC_NULL )
+		ec = MatDestroy( dstMatrix->petscMat );
+	CheckPETScError( ec );
+	ec = MatPtAP( self->petscMat, matrix0->petscMat, MAT_INITIAL_MATRIX, (PetscScalar)fillRatio, &dstMatrix->petscMat );
+	CheckPETScError( ec );
+}
+
+double PETScMatrix_L2Norm( void* matrix ) {
+	PETScMatrix*	self = (PETScMatrix*)matrix;
+	PetscErrorCode	ec;
+	PetscScalar	norm;
+
+	assert( self && Stg_CheckType( self, PETScMatrix ) );
+
+	ec = MatNorm( self->petscMat, NORM_FROBENIUS, &norm );
+	CheckPETScError( ec );
+
+	return (double)norm;
+}
+
+void PETScMatrix_Transpose( void* matrix, void* _dstMatrix ) {
+	PETScMatrix*	self = (PETScMatrix*)matrix;
+	PetscErrorCode	ec;
+	PETScMatrix*	dstMatrix = (PETScMatrix*)_dstMatrix;
+
+	assert( self && Stg_CheckType( self, PETScMatrix ) );
+	assert( dstMatrix && Stg_CheckType( dstMatrix, PETScMatrix ) );
+
+	if( self != dstMatrix ) {
+		if( dstMatrix->petscMat != PETSC_NULL )
+			ec = MatDestroy( dstMatrix->petscMat );
+		CheckPETScError( ec );
+		ec = MatTranspose( self->petscMat, &dstMatrix->petscMat );
+	}
+	else
+		ec = MatTranspose( self->petscMat, PETSC_NULL );
+	CheckPETScError( ec );
+}
+
+void PETScMatrix_GetGlobalSize( void* matrix, unsigned* nRows, unsigned* nColumns ) {
+	PETScMatrix*	self = (PETScMatrix*)matrix;
+	PetscErrorCode	ec;
+	PetscInt	nr, nc;
+
+	assert( self && Stg_CheckType( self, PETScMatrix ) );
+	assert( nRows );
+	assert( nColumns );
+
+	ec = MatGetSize( self->petscMat, &nr, &nc );
+	CheckPETScError( ec );
+
+	*nRows = (unsigned)nr;
+	*nColumns = (unsigned)nc;
+}
+
+void PETScMatrix_GetLocalSize( void* matrix, unsigned* nRows, unsigned* nColumns ) {
+	PETScMatrix*	self = (PETScMatrix*)matrix;
+	PetscErrorCode	ec;
+	PetscInt	nr, nc;
+
+	assert( self && Stg_CheckType( self, PETScMatrix ) );
+	assert( nRows );
+	assert( nColumns );
+
+	ec = MatGetLocalSize( self->petscMat, &nr, &nc );
+	CheckPETScError( ec );
+
+	*nRows = (unsigned)nr;
+	*nColumns = (unsigned)nc;
+}
+
+void PETScMatrix_GetRow( void* matrix, unsigned rowIndex, 
+			 unsigned* nEntries, unsigned** columnIndices, double** values )
+{
+	PETScMatrix*	self = (PETScMatrix*)matrix;
+	PetscErrorCode	ec;
+
+	assert( self && Stg_CheckType( self, PETScMatrix ) );
+	assert( nEntries );
+	assert( columnIndices );
+	assert( values );
+	assert( sizeof(PetscScalar) == sizeof(double) );
+	assert( sizeof(PetscInt) == sizeof(unsigned) );
+
+	ec = MatGetRow( self->petscMat, (PetscInt)rowIndex, 
+			(PetscInt*)nEntries, (const PetscInt**)columnIndices, (const PetscScalar**)values );
+	CheckPETScError( ec );
+}
+
+void PETScMatrix_RestoreRow( void* matrix, unsigned rowIndex, 
+			     unsigned* nEntries, unsigned** columnIndices, double** values )
+{
+	PETScMatrix*	self = (PETScMatrix*)matrix;
+	PetscErrorCode	ec;
+
+	assert( self && Stg_CheckType( self, PETScMatrix ) );
+	assert( nEntries );
+	assert( columnIndices );
+	assert( values );
+
+	ec = MatRestoreRow( self->petscMat, (PetscInt)rowIndex, 
+			    (PetscInt*)nEntries, (const PetscInt**)columnIndices, (const PetscScalar**)values );
+	CheckPETScError( ec );
+}
+
+void PETScMatrix_GetDiagonal( void* matrix, void* _vector ) {
+	PETScMatrix*	self = (PETScMatrix*)matrix;
+	PETScVector*	vector = (PETScVector*)_vector;
+	PetscErrorCode	ec;
+
+	assert( self && Stg_CheckType( self, PETScMatrix ) );
+	assert( vector && Stg_CheckType( vector, PETScVector ) );
+
+	ec = MatGetDiagonal( self->petscMat, vector->petscVec );
+	CheckPETScError( ec );
+}
+
+void PETScMatrix_Duplicate( void* matrix, void** dstMatrix ) {
+	PETScMatrix*	self = (PETScMatrix*)matrix;
+	PetscErrorCode	ec;
+
+	assert( self && Stg_CheckType( self, PETScMatrix ) );
+	assert( dstMatrix );
+
+	*dstMatrix = self->_defaultConstructor( "" );
+	ec = MatDuplicate( self->petscMat, MAT_DO_NOT_COPY_VALUES, &((PETScMatrix*)*dstMatrix)->petscMat );
+	CheckPETScError( ec );
+}
+
+void PETScMatrix_CopyEntries( void* matrix, void* _dstMatrix ) {
+	PETScMatrix*	self = (PETScMatrix*)matrix;
+	PETScMatrix*	dstMatrix = (PETScMatrix*)dstMatrix;
+	PetscErrorCode	ec;
+
+	assert( self && Stg_CheckType( self, PETScMatrix ) );
+	assert( dstMatrix && Stg_CheckType( dstMatrix, PETScMatrix ) );
+
+	ec = MatCopy( self->petscMat, dstMatrix->petscMat, DIFFERENT_NONZERO_PATTERN );
+	CheckPETScError( ec );
+}
+
+void PETScMatrix_Dump( void* matrix, char* filename ) {
+	PETScMatrix*	self = (PETScMatrix*)matrix;
+	PetscViewer	viewer;
+	PetscErrorCode	ec;
+
+	assert( self && Stg_CheckType( self, PETScMatrix ) );
+
+	ec = PetscViewerBinaryOpen( PETSC_COMM_SELF, filename, FILE_MODE_WRITE, &viewer );
+	CheckPETScError( ec );
+	if( self->petscMat != PETSC_NULL )
+		MatDestroy( self->petscMat );
+	ec = MatView( self->petscMat, viewer );
+	CheckPETScError( ec );
+	ec = PetscViewerDestroy( viewer );
+	CheckPETScError( ec );
+}
+
+
+/*--------------------------------------------------------------------------------------------------------------------------
+** Public Functions
+*/
+
+void PETScMatrix_SetNonZeroStructure( void* matrix, unsigned nNonZeros, 
+				      unsigned* diagonalNonZeroIndices, unsigned* offDiagonalNonZeroIndices )
+{
+	PETScMatrix*	self = (PETScMatrix*)matrix;
+	PetscErrorCode	ec;
+	unsigned	nProcs;
+
+	assert( self && Stg_CheckType( self, PETScMatrix ) );
+
+	MPI_Comm_size( self->comm, (int*)&nProcs );
+	if( diagonalNonZeroIndices || offDiagonalNonZeroIndices ) {
+		if( nProcs > 1 ) {
+			ec = MatMPIAIJSetPreallocation( self->petscMat, 
+							PETSC_NULL, (int*)diagonalNonZeroIndices,
+							PETSC_NULL, (int*)offDiagonalNonZeroIndices );
+		}
+		else
+			ec = MatSeqAIJSetPreallocation( self->petscMat, PETSC_NULL, (int*)diagonalNonZeroIndices );
+	}
+	else {
+		if( nProcs > 1 )
+			ec = MatMPIAIJSetPreallocation( self->petscMat, nNonZeros, PETSC_NULL, nNonZeros, PETSC_NULL );
+		else
+			ec = MatSeqAIJSetPreallocation( self->petscMat, nNonZeros, PETSC_NULL );
+	}
+	CheckPETScError( ec );
+}
+
+
+/*----------------------------------------------------------------------------------------------------------------------------------
+** Private Functions
+*/

Added: long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/PETScMatrix.h
===================================================================
--- long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/PETScMatrix.h	2006-12-22 14:06:39 UTC (rev 5623)
+++ long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/PETScMatrix.h	2006-12-22 16:23:04 UTC (rev 5624)
@@ -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
+**
+*/
+/** \file
+**  Role:
+**
+** Assumptions:
+**
+** Invariants:
+**
+** Comments:
+**
+** $Id: PETScMatrix.h 3584 2006-05-16 11:11:07Z PatrickSunter $
+**
+**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+
+#ifndef __StgFEM_SLE_LinearAlgebra_PETScMatrix_h__
+#define __StgFEM_SLE_LinearAlgebra_PETScMatrix_h__
+
+	/** Textual name of this class */
+	extern const Type PETScMatrix_Type;
+
+	/** Virtual function types */
+
+	/** PETScMatrix class contents */
+	#define __PETScMatrix				\
+		/* General info */			\
+		__Matrix				\
+							\
+		/* Virtual info */			\
+							\
+		/* PETScMatrix info */			\
+		Mat		petscMat;
+
+	struct PETScMatrix { __PETScMatrix };
+
+	/*--------------------------------------------------------------------------------------------------------------------------
+	** Constructors
+	*/
+
+	#define PETSCMATRIX_DEFARGS \
+		MATRIX_DEFARGS
+
+	#define PETSCMATRIX_PASSARGS \
+		MATRIX_PASSARGS
+
+	PETScMatrix* PETScMatrix_New( Name name );
+	PETScMatrix* _PETScMatrix_New( PETSCMATRIX_DEFARGS );
+	void _PETScMatrix_Init( PETScMatrix* self );
+
+	/*--------------------------------------------------------------------------------------------------------------------------
+	** Virtual functions
+	*/
+
+	void _PETScMatrix_Delete( void* matrix );
+	void _PETScMatrix_Print( void* matrix, Stream* stream );
+	void _PETScMatrix_Construct( void* matrix, Stg_ComponentFactory* cf, void* data );
+	void _PETScMatrix_Build( void* matrix, void* data );
+	void _PETScMatrix_Initialise( void* matrix, void* data );
+	void _PETScMatrix_Execute( void* matrix, void* data );
+	void _PETScMatrix_Destroy( void* matrix, void* data );
+
+	void PETScMatrix_SetComm( void* matrix, MPI_Comm comm );
+	void PETScMatrix_SetGlobalSize( void* matrix, unsigned nRows, unsigned nColumns );
+	void PETScMatrix_SetLocalSize( void* matrix, unsigned nRows, unsigned nColumns );
+	void PETScMatrix_AddEntries( void* matrix, unsigned nRows, unsigned* rowIndices, 
+				     unsigned nColumns, unsigned* columnIndices, 
+				     double* values );
+	void PETScMatrix_InsertEntries( void* matrix, unsigned nRows, unsigned* rowIndices, 
+					unsigned nColumns, unsigned* columnIndices, 
+					double* values );
+	void PETScMatrix_DiagonalAddEntries( void* matrix, void* vector );
+	void PETScMatrix_DiagonalInsertEntries( void* matrix, void* vector );
+	void PETScMatrix_Zero( void* matrix );
+	void PETScMatrix_Load( void* matrix, char* filename );
+	void PETScMatrix_AssemblyBegin( void* matrix );
+	void PETScMatrix_AssemblyEnd( void* matrix );
+
+	void PETScMatrix_Scale( void* matrix, double factor );
+	void PETScMatrix_AddScaled( void* matrix, double factor, void* matrix0 );
+	void PETScMatrix_DiagonalScale( void* matrix, void* leftVector, void* rightVector );
+	void PETScMatrix_Multiply( void* matrix, void* vector, void* dstVector );
+	void PETScMatrix_TransposeMultiply( void* matrix, void* vector, void* dstVector );
+	void PETScMatrix_MultiplyAdd( void* matrix, void* vector0, void* vector1, void* dstVector );
+	void PETScMatrix_PAPt( void* matrix, void* P, void* dstMatrix );
+	void PETScMatrix_PtAP( void* matrix, void* P, void* dstMatrix );
+	void PETScMatrix_MatrixMultiply( void* matrix, void* matrix0, void* dstMatrix );
+	double PETScMatrix_L2Norm( void* matrix );
+	void PETScMatrix_Transpose( void* matrix, void* dstMatrix );
+
+	void PETScMatrix_GetGlobalSize( void* matrix, unsigned* nRows, unsigned* nColumns );
+	void PETScMatrix_GetLocalSize( void* matrix, unsigned* nRows, unsigned* nColumns );
+	void PETScMatrix_GetRow( void* matrix, unsigned rowIndex, 
+				 unsigned* nEntries, unsigned** columnIndices, double** values );
+	void PETScMatrix_RestoreRow( void* matrix, unsigned rowIndex, 
+				     unsigned* nEntries, unsigned** columnIndices, double** values );
+	void PETScMatrix_GetDiagonal( void* matrix, void* vector );
+	void PETScMatrix_Duplicate( void* matrix, void** dstMatrix );
+	void PETScMatrix_CopyEntries( void* matrix, void* dstMatrix );
+	void PETScMatrix_Dump( void* matrix, char* filename );
+
+	/*--------------------------------------------------------------------------------------------------------------------------
+	** Public functions
+	*/
+
+	void PETScMatrix_SetNonZeroStructure( void* matrix, unsigned nNonZeros, 
+					      unsigned* diagonalNonZeroIndices, unsigned* offDiagonalNonZeroIndices);
+
+	/*--------------------------------------------------------------------------------------------------------------------------
+	** Private Member functions
+	*/
+
+#endif /* __StgFEM_SLE_LinearAlgebra_PETScMatrix_h__ */

Added: long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/PETScMatrix.meta
===================================================================
--- long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/PETScMatrix.meta	2006-12-22 14:06:39 UTC (rev 5623)
+++ long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/PETScMatrix.meta	2006-12-22 16:23:04 UTC (rev 5624)
@@ -0,0 +1,15 @@
+<?xml version="1.0"?>
+<!DOCTYPE StGermainData SYSTEM "stgermain.dtd">
+<StGermainData xmlns="http://www.vpac.org/StGermain/XML_IO_Handler/Jun2003">
+
+<param name="Name">PETScMatrix</param>
+<param name="Organisation">VPAC</param>
+<param name="Project">StgFEM</param>
+<param name="Location">StgFEM/SLE/LinearAlgebra/src/</param>
+<param name="Project Web">https://csd.vpac.org/twiki/bin/view/StgFEM/WebHome</param>
+<param name="Copyright">StGermain Framework. Copyright (C) 2003-2005 VPAC.</param>
+<param name="License">The Gnu Lesser General Public License http://www.gnu.org/licenses/lgpl.html</param>
+<param name="Parent"></param>
+<param name="Description">...</param>
+
+</StGermainData>

Added: long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/PETScMatrixSolver.c
===================================================================
--- long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/PETScMatrixSolver.c	2006-12-22 14:06:39 UTC (rev 5623)
+++ long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/PETScMatrixSolver.c	2006-12-22 16:23:04 UTC (rev 5624)
@@ -0,0 +1,311 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+**
+** 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: PETScMatrixSolver.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 "LinearAlgebra.h"
+
+
+/* Textual name of this class */
+const Type PETScMatrixSolver_Type = "PETScMatrixSolver";
+
+
+/*----------------------------------------------------------------------------------------------------------------------------------
+** Constructors
+*/
+
+PETScMatrixSolver* PETScMatrixSolver_New( Name name ) {
+	return _PETScMatrixSolver_New( sizeof(PETScMatrixSolver), 
+				       PETScMatrixSolver_Type, 
+				       _PETScMatrixSolver_Delete, 
+				       _PETScMatrixSolver_Print, 
+				       NULL, 
+				       (void* (*)(Name))PETScMatrixSolver_New, 
+				       _PETScMatrixSolver_Construct, 
+				       _PETScMatrixSolver_Build, 
+				       _PETScMatrixSolver_Initialise, 
+				       _PETScMatrixSolver_Execute, 
+				       _PETScMatrixSolver_Destroy, 
+				       name, 
+				       NON_GLOBAL, 
+				       PETScMatrixSolver_SetComm, 
+				       PETScMatrixSolver_SetMatrix, 
+				       PETScMatrixSolver_SetMaxIterations, 
+				       PETScMatrixSolver_SetRelativeTolerance, 
+				       PETScMatrixSolver_SetAbsoluteTolerance, 
+				       PETScMatrixSolver_SetUseInitialSolution, 
+				       PETScMatrixSolver_Solve, 
+				       _MatrixSolver_Setup, 
+				       PETScMatrixSolver_GetSolveStatus, 
+				       PETScMatrixSolver_GetIterations, 
+				       PETScMatrixSolver_GetMaxIterations );
+}
+
+PETScMatrixSolver* _PETScMatrixSolver_New( PETSCMATRIXSOLVER_DEFARGS ) {
+	PETScMatrixSolver*	self;
+
+	/* Allocate memory */
+	assert( sizeOfSelf >= sizeof(PETScMatrixSolver) );
+	self = (PETScMatrixSolver*)_MatrixSolver_New( MATRIXSOLVER_PASSARGS );
+
+	/* Virtual info */
+
+	/* PETScMatrixSolver info */
+	_PETScMatrixSolver_Init( self );
+
+	return self;
+}
+
+void _PETScMatrixSolver_Init( PETScMatrixSolver* self ) {
+	assert( self && Stg_CheckType( self, PETScMatrixSolver ) );
+
+	self->ksp = PETSC_NULL;
+	PETScMatrixSolver_SetComm( self, MPI_COMM_WORLD );
+}
+
+
+/*----------------------------------------------------------------------------------------------------------------------------------
+** Virtual functions
+*/
+
+void _PETScMatrixSolver_Delete( void* matrixSolver ) {
+	PETScMatrixSolver*	self = (PETScMatrixSolver*)matrixSolver;
+
+	assert( self && Stg_CheckType( self, PETScMatrixSolver ) );
+
+	KSPDestroy( self->ksp );
+
+	/* Delete the parent. */
+	_MatrixSolver_Delete( self );
+}
+
+void _PETScMatrixSolver_Print( void* matrixSolver, Stream* stream ) {
+	PETScMatrixSolver*	self = (PETScMatrixSolver*)matrixSolver;
+	
+	/* Set the Journal for printing informations */
+	Stream* matrixSolverStream;
+	matrixSolverStream = Journal_Register( InfoStream_Type, "PETScMatrixSolverStream" );
+
+	assert( self && Stg_CheckType( self, PETScMatrixSolver ) );
+
+	/* Print parent */
+	Journal_Printf( stream, "PETScMatrixSolver (ptr): (%p)\n", self );
+	_MatrixSolver_Print( self, stream );
+}
+
+void _PETScMatrixSolver_Construct( void* matrixSolver, Stg_ComponentFactory* cf, void* data ) {
+	PETScMatrixSolver*		self = (PETScMatrixSolver*)matrixSolver;
+
+	assert( self && Stg_CheckType( self, PETScMatrixSolver ) );
+	assert( cf );
+}
+
+void _PETScMatrixSolver_Build( void* matrixSolver, void* data ) {
+}
+
+void _PETScMatrixSolver_Initialise( void* matrixSolver, void* data ) {
+}
+
+void _PETScMatrixSolver_Execute( void* matrixSolver, void* data ) {
+}
+
+void _PETScMatrixSolver_Destroy( void* matrixSolver, void* data ) {
+}
+
+void PETScMatrixSolver_SetComm( void* matrixSolver, MPI_Comm comm ) {
+	PETScMatrixSolver*	self = (PETScMatrixSolver*)matrixSolver;
+	PetscErrorCode		ec;
+
+	assert( self && Stg_CheckType( self, PETScMatrixSolver ) );
+
+	_MatrixSolver_SetComm( self, comm );
+
+	if( self->ksp != PETSC_NULL )
+		KSPDestroy( self->ksp );
+	ec = KSPCreate( self->comm, &self->ksp );
+	CheckPETScError( ec );
+	ec = KSPSetFromOptions( self->ksp );
+	CheckPETScError( ec );
+}
+
+void PETScMatrixSolver_SetMatrix( void* matrixSolver, void* _matrix ) {
+	PETScMatrixSolver*	self = (PETScMatrixSolver*)matrixSolver;
+	PETScMatrix*		matrix = (PETScMatrix*)_matrix;
+
+	assert( self && Stg_CheckType( self, PETScMatrixSolver ) );
+	assert( matrix && Stg_CheckType( matrix, PETScMatrix ) );
+
+	_MatrixSolver_SetMatrix( self, matrix );
+
+	KSPSetOperators( self->ksp, matrix->petscMat, matrix->petscMat, DIFFERENT_NONZERO_PATTERN );
+}
+
+void PETScMatrixSolver_SetMaxIterations( void* matrixSolver, unsigned nIterations ) {
+	PETScMatrixSolver*	self = (PETScMatrixSolver*)matrixSolver;
+
+	assert( self && Stg_CheckType( self, PETScMatrixSolver ) );
+
+	KSPSetTolerances( self->ksp, PETSC_DEFAULT, PETSC_DEFAULT, PETSC_DEFAULT, (PetscInt)nIterations );
+}
+
+void PETScMatrixSolver_SetRelativeTolerance( void* matrixSolver, double tolerance ) {
+	PETScMatrixSolver*	self = (PETScMatrixSolver*)matrixSolver;
+
+	assert( self && Stg_CheckType( self, PETScMatrixSolver ) );
+
+	KSPSetTolerances( self->ksp, tolerance, PETSC_DEFAULT, PETSC_DEFAULT, PETSC_DEFAULT );
+}
+
+void PETScMatrixSolver_SetAbsoluteTolerance( void* matrixSolver, double tolerance ) {
+	PETScMatrixSolver*	self = (PETScMatrixSolver*)matrixSolver;
+
+	assert( self && Stg_CheckType( self, PETScMatrixSolver ) );
+
+	KSPSetTolerances( self->ksp, PETSC_DEFAULT, tolerance, PETSC_DEFAULT, PETSC_DEFAULT );
+}
+
+void PETScMatrixSolver_SetUseInitialSolution( void* matrixSolver, Bool state ) {
+	PETScMatrixSolver*	self = (PETScMatrixSolver*)matrixSolver;
+
+	assert( self && Stg_CheckType( self, PETScMatrixSolver ) );
+
+	KSPSetInitialGuessNonzero( self->ksp, (PetscTruth)state );
+}
+
+void PETScMatrixSolver_Solve( void* matrixSolver, void* _rhs, void* _solution ) {
+	PETScMatrixSolver*	self = (PETScMatrixSolver*)matrixSolver;
+	PETScVector*		rhs = (PETScVector*)_rhs;
+	PETScVector*		solution = (PETScVector*)_solution;
+
+	assert( self && Stg_CheckType( self, PETScMatrixSolver ) );
+	assert( solution && Stg_CheckType( solution, PETScVector ) );
+	assert( rhs && Stg_CheckType( rhs, PETScVector ) );
+
+	KSPSolve( self->ksp, rhs->petscVec, solution->petscVec );
+}
+
+MatrixSolver_Status PETScMatrixSolver_GetSolveStatus( void* matrixSolver ) {
+	PETScMatrixSolver*	self = (PETScMatrixSolver*)matrixSolver;
+	KSPConvergedReason	reason;
+
+	assert( self && Stg_CheckType( self, PETScMatrixSolver ) );
+
+	KSPGetConvergedReason( self->ksp, &reason );
+
+	return reason;
+}
+
+unsigned PETScMatrixSolver_GetIterations( void* matrixSolver ) {
+	PETScMatrixSolver*	self = (PETScMatrixSolver*)matrixSolver;
+	PetscInt		nIts;
+
+	assert( self && Stg_CheckType( self, PETScMatrixSolver ) );
+
+	KSPGetIterationNumber( self->ksp, &nIts );
+
+	return (unsigned)nIts;
+}
+
+unsigned PETScMatrixSolver_GetMaxIterations( void* matrixSolver ) {
+	PETScMatrixSolver*	self = (PETScMatrixSolver*)matrixSolver;
+	PetscInt		nIts;
+
+	assert( self && Stg_CheckType( self, PETScMatrixSolver ) );
+
+	KSPGetTolerances( self->ksp, PETSC_NULL, PETSC_NULL, PETSC_NULL, &nIts );
+
+	return (unsigned)nIts;
+}
+
+
+/*--------------------------------------------------------------------------------------------------------------------------
+** Public Functions
+*/
+
+void PETScMatrixSolver_SetKSPType( void* matrixSolver, PETScMatrixSolver_KSPType type ) {
+	PETScMatrixSolver*	self = (PETScMatrixSolver*)matrixSolver;
+
+	assert( self && Stg_CheckType( self, PETScMatrixSolver ) );
+
+	switch( type ) {
+	case PETScMatrixSolver_KSPType_Richardson:
+		KSPSetType( self->ksp, KSPRICHARDSON );
+		break;
+	case PETScMatrixSolver_KSPType_GMRes:
+		KSPSetType( self->ksp, KSPGMRES );
+		break;
+	case PETScMatrixSolver_KSPType_PreOnly:
+		KSPSetType( self->ksp, KSPPREONLY );
+		break;
+	default:
+		assert( 0 );
+	}
+}
+
+void PETScMatrixSolver_SetPCType( void* matrixSolver, PETScMatrixSolver_PCType type ) {
+	PETScMatrixSolver*	self = (PETScMatrixSolver*)matrixSolver;
+	PC			pc;
+
+	assert( self && Stg_CheckType( self, PETScMatrixSolver ) );
+
+	KSPGetPC( self->ksp, &pc );
+	switch( type ) {
+	case PETScMatrixSolver_PCType_Jacobi:
+		PCSetType( pc, PCJACOBI );
+		break;
+	case PETScMatrixSolver_PCType_BlockJacobi:
+		PCSetType( pc, PCBJACOBI );
+		break;
+	case PETScMatrixSolver_PCType_SOR:
+		PCSetType( pc, PCSOR );
+		break;
+	case PETScMatrixSolver_PCType_LU:
+		PCSetType( pc, PCLU );
+		break;
+	case PETScMatrixSolver_PCType_ILU:
+		PCSetType( pc, PCILU );
+		break;
+	case PETScMatrixSolver_PCType_None:
+		PCSetType( pc, PCNONE );
+		break;
+	default:
+		assert( 0 );
+	}
+}
+
+
+/*----------------------------------------------------------------------------------------------------------------------------------
+** Private Functions
+*/

Added: long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/PETScMatrixSolver.h
===================================================================
--- long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/PETScMatrixSolver.h	2006-12-22 14:06:39 UTC (rev 5623)
+++ long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/PETScMatrixSolver.h	2006-12-22 16:23:04 UTC (rev 5624)
@@ -0,0 +1,111 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+**
+** 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: PETScMatrixSolver.h 672 2006-12-14 00:58:36Z LukeHodkinson $
+**
+**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+
+#ifndef __StgFEM_SLE_LinearAlgebra_PETScMatrixSolver_h__
+#define __StgFEM_SLE_LinearAlgebra_PETScMatrixSolver_h__
+
+	/** Textual name of this class */
+	extern const Type PETScMatrixSolver_Type;
+
+	/** Virtual function types */
+
+	/** PETScMatrixSolver class contents */
+	#define __PETScMatrixSolver		\
+		/* General info */		\
+		__MatrixSolver			\
+						\
+		/* Virtual info */		\
+						\
+		/* PETScMatrixSolver info */	\
+		KSP		ksp;
+
+	struct PETScMatrixSolver { __PETScMatrixSolver };
+
+	/*--------------------------------------------------------------------------------------------------------------------------
+	** Constructors
+	*/
+
+	#define PETSCMATRIXSOLVER_DEFARGS \
+		MATRIXSOLVER_DEFARGS
+
+	#define PETSCMATRIXSOLVER_PASSARGS \
+		MATRIXSOLVER_PASSARGS
+
+	PETScMatrixSolver* PETScMatrixSolver_New( Name name );
+	PETScMatrixSolver* _PETScMatrixSolver_New( PETSCMATRIXSOLVER_DEFARGS );
+	void _PETScMatrixSolver_Init( PETScMatrixSolver* self );
+
+	/*--------------------------------------------------------------------------------------------------------------------------
+	** Virtual functions
+	*/
+
+	void _PETScMatrixSolver_Delete( void* matrixSolver );
+	void _PETScMatrixSolver_Print( void* matrixSolver, Stream* stream );
+	void _PETScMatrixSolver_Construct( void* matrixSolver, Stg_ComponentFactory* cf, void* data );
+	void _PETScMatrixSolver_Build( void* matrixSolver, void* data );
+	void _PETScMatrixSolver_Initialise( void* matrixSolver, void* data );
+	void _PETScMatrixSolver_Execute( void* matrixSolver, void* data );
+	void _PETScMatrixSolver_Destroy( void* matrixSolver, void* data );
+
+	void PETScMatrixSolver_SetComm( void* matrixSolver, MPI_Comm comm );
+	void PETScMatrixSolver_SetMatrix( void* matrixSolver, void* matrix );
+	void PETScMatrixSolver_SetMaxIterations( void* matrixSolver, unsigned nIterations );
+	void PETScMatrixSolver_SetRelativeTolerance( void* matrixSolver, double tolerance );
+	void PETScMatrixSolver_SetAbsoluteTolerance( void* matrixSolver, double tolerance );
+	void PETScMatrixSolver_SetUseInitialSolution( void* matrixSolver, Bool state );
+
+	void PETScMatrixSolver_Solve( void* matrixSolver, void* rhs, void* solution );
+
+	MatrixSolver_Status PETScMatrixSolver_GetSolveStatus( void* matrixSolver );
+	unsigned PETScMatrixSolver_GetIterations( void* matrixSolver );
+	unsigned PETScMatrixSolver_GetMaxIterations( void* matrixSolver );
+
+	/*--------------------------------------------------------------------------------------------------------------------------
+	** Public functions
+	*/
+
+	void PETScMatrixSolver_SetKSPType( void* matrixSolver, PETScMatrixSolver_KSPType type );
+	void PETScMatrixSolver_SetPCType( void* matrixSolver, PETScMatrixSolver_PCType type );
+
+	/*--------------------------------------------------------------------------------------------------------------------------
+	** Private Member functions
+	*/
+
+#endif /* __StgFEM_SLE_LinearAlgebra_PETScMatrixSolver_h__ */

Added: long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/PETScMatrixSolver.meta
===================================================================
--- long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/PETScMatrixSolver.meta	2006-12-22 14:06:39 UTC (rev 5623)
+++ long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/PETScMatrixSolver.meta	2006-12-22 16:23:04 UTC (rev 5624)
@@ -0,0 +1,15 @@
+<?xml version="1.0"?>
+<!DOCTYPE StGermainData SYSTEM "stgermain.dtd">
+<StGermainData xmlns="http://www.vpac.org/StGermain/XML_IO_Handler/Jun2003">
+
+<param name="Name">PETScMatrixSolver</param>
+<param name="Organisation">VPAC</param>
+<param name="Project">StgFEM</param>
+<param name="Location">StgFEM/SLE/LinearAlgebra/src/</param>
+<param name="Project Web">https://csd.vpac.org/twiki/bin/view/StgFEM/WebHome</param>
+<param name="Copyright">StGermain Framework. Copyright (C) 2003-2005 VPAC.</param>
+<param name="License">The Gnu Lesser General Public License http://www.gnu.org/licenses/lgpl.html</param>
+<param name="Parent"></param>
+<param name="Description">...</param>
+
+</StGermainData>

Added: long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/PETScVector.c
===================================================================
--- long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/PETScVector.c	2006-12-22 14:06:39 UTC (rev 5623)
+++ long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/PETScVector.c	2006-12-22 16:23:04 UTC (rev 5624)
@@ -0,0 +1,458 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+**
+** 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: PETScVector.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 "LinearAlgebra.h"
+
+
+/* Textual name of this class */
+const Type PETScVector_Type = "PETScVector";
+
+
+/*----------------------------------------------------------------------------------------------------------------------------------
+** Constructors
+*/
+
+PETScVector* PETScVector_New( Name name ) {
+	return _PETScVector_New( sizeof(PETScVector), 
+				 PETScVector_Type, 
+				 _PETScVector_Delete, 
+				 _PETScVector_Print, 
+				 NULL, 
+				 (void* (*)(Name))PETScVector_New, 
+				 _PETScVector_Construct, 
+				 _PETScVector_Build, 
+				 _PETScVector_Initialise, 
+				 _PETScVector_Execute, 
+				 _PETScVector_Destroy, 
+				 name, 
+				 NON_GLOBAL, 
+				 PETScVector_SetComm, 
+				 PETScVector_SetGlobalSize, 
+				 PETScVector_SetLocalSize, 
+				 PETScVector_AddEntries, 
+				 PETScVector_InsertEntries, 
+				 PETScVector_SetScalar, 
+				 PETScVector_Zero, 
+				 PETScVector_AssemblyBegin, 
+				 PETScVector_AssemblyEnd, 
+				 PETScVector_Add, 
+				 PETScVector_AddScaled, 
+				 PETScVector_ScaleAdd, 
+				 PETScVector_Subtract, 
+				 PETScVector_Scale, 
+				 PETScVector_DotProduct, 
+				 PETScVector_L2Norm, 
+				 PETScVector_LInfNorm, 
+				 PETScVector_PointwiseMultiply, 
+				 PETScVector_PointwiseDivide, 
+				 PETScVector_Reciprocal, 
+				 PETScVector_GetGlobalSize, 
+				 PETScVector_GetLocalSize, 
+				 PETScVector_GetArray, 
+				 PETScVector_RestoreArray, 
+				 PETScVector_Duplicate, 
+				 PETScVector_CopyEntries, 
+				 _Vector_View );
+}
+
+PETScVector* _PETScVector_New( PETSCVECTOR_DEFARGS ) {
+	PETScVector*	self;
+
+	/* Allocate memory */
+	assert( sizeOfSelf >= sizeof(PETScVector) );
+	self = (PETScVector*)_Vector_New( VECTOR_PASSARGS );
+
+	/* Virtual info */
+
+	/* PETScVector info */
+	_PETScVector_Init( self );
+
+	return self;
+}
+
+void _PETScVector_Init( PETScVector* self ) {
+	assert( self && Stg_CheckType( self, PETScVector ) );
+
+	self->petscVec = PETSC_NULL;
+	PETScVector_SetComm( self, MPI_COMM_WORLD );
+}
+
+
+/*----------------------------------------------------------------------------------------------------------------------------------
+** Virtual functions
+*/
+
+void _PETScVector_Delete( void* vector ) {
+	PETScVector*	self = (PETScVector*)vector;
+	PetscErrorCode	ec;
+
+	assert( self && Stg_CheckType( self, PETScVector ) );
+
+	ec = VecDestroy( self->petscVec );
+	CheckPETScError( ec );
+
+	/* Delete the parent. */
+	_Vector_Delete( self );
+}
+
+void _PETScVector_Print( void* vector, Stream* stream ) {
+	PETScVector*	self = (PETScVector*)vector;
+	
+	/* Set the Journal for printing informations */
+	Stream* vectorStream;
+	vectorStream = Journal_Register( InfoStream_Type, "PETScVectorStream" );
+
+	assert( self && Stg_CheckType( self, PETScVector ) );
+
+	/* Print parent */
+	Journal_Printf( stream, "PETScVector (ptr): (%p)\n", self );
+	_Vector_Print( self, stream );
+}
+
+void _PETScVector_Construct( void* vector, Stg_ComponentFactory* cf, void* data ) {
+	PETScVector*	self = (PETScVector*)vector;
+
+	assert( self && Stg_CheckType( self, PETScVector ) );
+	assert( cf );
+}
+
+void _PETScVector_Build( void* vector, void* data ) {
+}
+
+void _PETScVector_Initialise( void* vector, void* data ) {
+}
+
+void _PETScVector_Execute( void* vector, void* data ) {
+}
+
+void _PETScVector_Destroy( void* vector, void* data ) {
+}
+
+void PETScVector_SetComm( void* vector, MPI_Comm comm ) {
+	PETScVector*	self = (PETScVector*)vector;
+	PetscErrorCode	ec;
+
+	assert( self && Stg_CheckType( self, PETScVector ) );
+
+	_Vector_SetComm( self, comm );
+
+	if( self->petscVec != PETSC_NULL )
+		VecDestroy( self->petscVec );
+	ec = VecCreate( comm, &self->petscVec );
+	CheckPETScError( ec );
+}
+
+void PETScVector_SetGlobalSize( void* vector, unsigned size ) {
+	PETScVector*	self = (PETScVector*)vector;
+	PetscErrorCode	ec;
+
+	assert( self && Stg_CheckType( self, PETScVector ) );
+
+	ec = VecSetSizes( self->petscVec, PETSC_DECIDE, size );
+	CheckPETScError( ec );
+	ec = VecSetFromOptions( self->petscVec );
+	CheckPETScError( ec );
+}
+
+void PETScVector_SetLocalSize( void* vector, unsigned size ) {
+	PETScVector*	self = (PETScVector*)vector;
+	PetscErrorCode	ec;
+
+	assert( self && Stg_CheckType( self, PETScVector ) );
+
+	ec = VecSetSizes( self->petscVec, PETSC_DECIDE, size );
+	CheckPETScError( ec );
+	ec = VecSetFromOptions( self->petscVec );
+	CheckPETScError( ec );
+}
+
+void PETScVector_AddEntries( void* vector, unsigned nEntries, unsigned* indices, double* values ) {
+	PETScVector*	self = (PETScVector*)vector;
+	PetscErrorCode	ec;
+
+	assert( self && Stg_CheckType( self, PETScVector ) );
+	assert( !nEntries || (indices && values) );
+
+	ec = VecSetValues( self->petscVec, nEntries, (PetscInt*)indices, (PetscScalar*)values, ADD_VALUES );
+	CheckPETScError( ec );
+}
+
+void PETScVector_InsertEntries( void* vector, unsigned nEntries, unsigned* indices, double* values ) {
+	PETScVector*	self = (PETScVector*)vector;
+	PetscErrorCode	ec;
+
+	assert( self && Stg_CheckType( self, PETScVector ) );
+	assert( !nEntries || (indices && values) );
+
+	ec = VecSetValues( self->petscVec, nEntries, (PetscInt*)indices, (PetscScalar*)values, INSERT_VALUES );
+	CheckPETScError( ec );
+}
+
+void PETScVector_SetScalar( void* vector, double scalar ) {
+	PETScVector*	self = (PETScVector*)vector;
+	PetscErrorCode	ec;
+
+	assert( self && Stg_CheckType( self, PETScVector ) );
+
+	ec = VecSet( self->petscVec, scalar );
+	CheckPETScError( ec );
+}
+
+void PETScVector_Zero( void* vector ) {
+	PETScVector_SetScalar( vector, 0.0 );
+}
+
+void PETScVector_AssemblyBegin( void* vector ) {
+	PETScVector*	self = (PETScVector*)vector;
+	PetscErrorCode	ec;
+
+	assert( self && Stg_CheckType( self, PETScVector ) );
+
+	ec = VecAssemblyBegin( self->petscVec );
+	CheckPETScError( ec );
+}
+
+void PETScVector_AssemblyEnd( void* vector ) {
+	PETScVector*	self = (PETScVector*)vector;
+	PetscErrorCode	ec;
+
+	assert( self && Stg_CheckType( self, PETScVector ) );
+
+	ec = VecAssemblyEnd( self->petscVec );
+	CheckPETScError( ec );
+}
+
+void PETScVector_Add( void* vector, void* vector0 ) {
+	PETScVector_AddScaled( vector, 1.0, vector0 );
+}
+
+void PETScVector_AddScaled( void* vector, double scalar, void* _vector0 ) {
+	PETScVector*	self = (PETScVector*)vector;
+	PETScVector*	vector0 = (PETScVector*)_vector0;
+	PetscErrorCode	ec;
+
+	assert( self && Stg_CheckType( self, PETScVector ) );
+	assert( vector0 && Stg_CheckType( vector0, PETScVector ) );
+
+	ec = VecAXPY( self->petscVec, (PetscScalar)scalar, vector0->petscVec );
+	CheckPETScError( ec );
+}
+
+void PETScVector_ScaleAdd( void* vector, double scalar, void* _vector0 ) {
+	PETScVector*	self = (PETScVector*)vector;
+	PETScVector*	vector0 = (PETScVector*)_vector0;
+	PetscErrorCode	ec;
+
+	assert( self && Stg_CheckType( self, PETScVector ) );
+	assert( vector0 && Stg_CheckType( vector0, PETScVector ) );
+
+	ec = VecAYPX( self->petscVec, (PetscScalar)scalar, vector0->petscVec );
+	CheckPETScError( ec );
+}
+
+void PETScVector_Subtract( void* vector, void* vector0 ) {
+	PETScVector_AddScaled( vector, -1.0, vector0 );
+}
+
+void PETScVector_Scale( void* vector, double factor ) {
+	PETScVector*	self = (PETScVector*)vector;
+	PetscErrorCode	ec;
+
+	assert( self && Stg_CheckType( self, PETScVector ) );
+
+	ec = VecScale( self->petscVec, (PetscScalar)factor );
+	CheckPETScError(ec);
+}
+
+double PETScVector_DotProduct( void* vector, void* _vector0 ) {
+	PETScVector*	self = (PETScVector*)vector;
+	PETScVector*	vector0 = (PETScVector*)_vector0;
+	PetscErrorCode	ec;
+	double		dot;
+
+	assert( self && Stg_CheckType( self, PETScVector ) );
+	assert( vector0 && Stg_CheckType( vector0, PETScVector ) );
+
+	ec = VecDot( self->petscVec, vector0->petscVec, (PetscScalar*)&dot );
+	CheckPETScError(ec);
+
+	return dot;
+}
+
+double PETScVector_L2Norm( void* vector ) {
+	PETScVector*	self = (PETScVector*)vector;
+	PetscErrorCode	ec;
+	double         norm;
+
+	ec = VecNorm( self->petscVec, NORM_2, (PetscScalar*)&norm );
+	CheckPETScError(ec);
+
+	return norm;
+}
+
+double PETScVector_LInfNorm( void* vector ) {
+	PETScVector*	self = (PETScVector*)vector;
+	PetscErrorCode	ec;
+	double         norm;
+
+	ec = VecNorm( self->petscVec, NORM_INFINITY, (PetscScalar*)&norm );
+	CheckPETScError(ec);
+
+	return norm;
+}
+
+void PETScVector_PointwiseMultiply( void* vector, void* _vector0, void* _dstVector ) {
+	PETScVector*	self = (PETScVector*)vector;
+	PETScVector*	vector0 = (PETScVector*)_vector0;
+	PETScVector*	dstVector = (PETScVector*)_dstVector;
+	PetscErrorCode	ec;
+
+	assert( self && Stg_CheckType( self, PETScVector ) );
+	assert( vector0 && Stg_CheckType( vector0, PETScVector ) );
+	assert( dstVector && Stg_CheckType( dstVector, PETScVector ) );
+
+	ec = VecPointwiseMult( self->petscVec, vector0->petscVec, dstVector->petscVec ); 
+	CheckPETScError(ec);
+}
+
+void PETScVector_PointwiseDivide( void* vector, void* _vector0, void* _dstVector ) {
+	PETScVector*	self = (PETScVector*)vector;
+	PETScVector*	vector0 = (PETScVector*)_vector0;
+	PETScVector*	dstVector = (PETScVector*)_dstVector;
+	PetscErrorCode	ec;
+
+	assert( self && Stg_CheckType( self, PETScVector ) );
+	assert( vector0 && Stg_CheckType( vector0, PETScVector ) );
+	assert( dstVector && Stg_CheckType( dstVector, PETScVector ) );
+	
+	ec = VecPointwiseDivide( self->petscVec, vector0->petscVec, self->petscVec ); 
+	CheckPETScError(ec);
+}
+
+void PETScVector_Reciprocal( void* vector ) {
+	PETScVector*	self = (PETScVector*)vector;
+	PetscErrorCode	ec;
+
+	assert( self && Stg_CheckType( self, PETScVector ) );
+
+	ec = VecReciprocal( self->petscVec ); 
+	CheckPETScError(ec);
+}
+
+unsigned PETScVector_GetGlobalSize( void* vector ) {
+	PETScVector*	self = (PETScVector*)vector;
+	PetscErrorCode	ec;
+	unsigned	size;
+
+	assert( self && Stg_CheckType( self, PETScVector ) );
+
+	ec = VecGetSize( self->petscVec, (PetscInt*)&size );
+	CheckPETScError( ec );
+
+	return size;
+}
+
+unsigned PETScVector_GetLocalSize( void* vector ) {
+	PETScVector*	self = (PETScVector*)vector;
+	PetscErrorCode	ec;
+	unsigned	size;
+
+	assert( self && Stg_CheckType( self, PETScVector ) );
+
+	ec = VecGetLocalSize( self->petscVec, (PetscInt*)&size );
+	CheckPETScError( ec );
+
+	return size;
+}
+
+void PETScVector_GetArray( void* vector, double** array ) {
+	PETScVector*	self = (PETScVector*)vector;
+	PetscErrorCode	ec;
+
+	assert( self && Stg_CheckType( self, PETScVector ) );
+	assert( array );
+
+	ec = VecGetArray( self->petscVec, (PetscScalar**)array );
+	CheckPETScError( ec );
+}
+
+void PETScVector_RestoreArray( void* vector, double** array ) {
+	PETScVector*	self = (PETScVector*)vector;
+	PetscErrorCode	ec;
+
+	assert( self && Stg_CheckType( self, PETScVector ) );
+	assert( array );
+
+	ec = VecRestoreArray( self->petscVec, (PetscScalar**)array );
+	CheckPETScError( ec );
+}
+
+void PETScVector_Duplicate( void* vector, void** dstVector ) {
+	PETScVector*	self = (PETScVector*)vector;
+	PetscErrorCode	ec;
+
+	assert( self && Stg_CheckType( self, PETScVector ) );
+	assert( dstVector );
+
+	*dstVector = (void*)self->_defaultConstructor( "" );
+	ec = VecDestroy( ((PETScVector*)*dstVector)->petscVec );
+	CheckPETScError( ec );
+	ec = VecDuplicate( self->petscVec, &((PETScVector*)*dstVector)->petscVec );
+	CheckPETScError( ec );
+}
+
+void PETScVector_CopyEntries( void* vector, void* _dstVector ) {
+	PETScVector*	self = (PETScVector*)vector;
+	PETScVector*	dstVector = (PETScVector*)_dstVector;
+	PetscErrorCode	ec;
+
+	assert( self && Stg_CheckType( self, PETScVector ) );
+	assert( dstVector && Stg_CheckType( dstVector, PETScVector ) );
+
+	ec = VecCopy( self->petscVec, dstVector->petscVec );
+	CheckPETScError( ec );
+}
+
+
+/*--------------------------------------------------------------------------------------------------------------------------
+** Public Functions
+*/
+
+
+/*----------------------------------------------------------------------------------------------------------------------------------
+** Private Functions
+*/

Added: long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/PETScVector.h
===================================================================
--- long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/PETScVector.h	2006-12-22 14:06:39 UTC (rev 5623)
+++ long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/PETScVector.h	2006-12-22 16:23:04 UTC (rev 5624)
@@ -0,0 +1,127 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+**
+** 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: PETScVector.h 3584 2006-05-16 11:11:07Z PatrickSunter $
+**
+**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+
+#ifndef __StgFEM_SLE_LinearAlgebra_PETScVector_h__
+#define __StgFEM_SLE_LinearAlgebra_PETScVector_h__
+
+	/** Textual name of this class */
+	extern const Type PETScVector_Type;
+
+	/** Virtual function types */
+
+	/** PETScVector class contents */
+	#define __PETScVector			\
+		/* General info */		\
+		__Vector			\
+						\
+		/* Virtual info */		\
+						\
+		/* PETScVector info */		\
+		double*		array;		\
+		Vec		petscVec;
+
+	struct PETScVector { __PETScVector };
+
+	/*--------------------------------------------------------------------------------------------------------------------------
+	** Constructors
+	*/
+
+	#define PETSCVECTOR_DEFARGS	\
+		VECTOR_DEFARGS
+
+	#define PETSCVECTOR_PASSARGS	\
+		VECTOR_PASSARGS
+
+	PETScVector* PETScVector_New( Name name );
+	PETScVector* _PETScVector_New( VECTOR_DEFARGS );
+	void _PETScVector_Init( PETScVector* self );
+
+	/*--------------------------------------------------------------------------------------------------------------------------
+	** Virtual functions
+	*/
+
+	void _PETScVector_Delete( void* vector );
+	void _PETScVector_Print( void* vector, Stream* stream );
+	void _PETScVector_Construct( void* vector, Stg_ComponentFactory* cf, void* data );
+	void _PETScVector_Build( void* vector, void* data );
+	void _PETScVector_Initialise( void* vector, void* data );
+	void _PETScVector_Execute( void* vector, void* data );
+	void _PETScVector_Destroy( void* vector, void* data );
+
+	void PETScVector_SetComm( void* vector, MPI_Comm comm );
+	void PETScVector_SetGlobalSize( void* vector, unsigned size );
+	void PETScVector_SetLocalSize( void* vector, unsigned size );
+	void PETScVector_AddEntries( void* vector, unsigned nEntries, unsigned* indices, double* values );
+	void PETScVector_InsertEntries( void* vector, unsigned nEntries, unsigned* indices, double* values );
+	void PETScVector_SetScalar( void* vector, double scalar );
+	void PETScVector_Zero( void* vector );
+	void PETScVector_AssemblyBegin( void* vector );
+	void PETScVector_AssemblyEnd( void* vector );
+
+	void PETScVector_Add( void* vector, void* vector0 );
+	void PETScVector_AddScaled( void* vector, double scalar, void* vector0 );
+	void PETScVector_ScaleAdd( void* vector, double scalar, void* vector0 );
+	void PETScVector_Subtract( void* vector, void* vector0 );
+	void PETScVector_Scale( void* vector, double factor );
+	double PETScVector_DotProduct( void* vector, void* vector0 );
+	double PETScVector_L2Norm( void* vector );
+	double PETScVector_LInfNorm( void* vector );
+	void PETScVector_PointwiseMultiply( void* vector, void* vector0, void* dstVector );
+	void PETScVector_PointwiseDivide( void* vector, void* vector0, void* dstVector );
+	void PETScVector_Reciprocal( void* vector );
+
+	unsigned PETScVector_GetGlobalSize( void* vector );
+	unsigned PETScVector_GetLocalSize( void* vector );
+	void PETScVector_GetArray( void* vector, double** array );
+	void PETScVector_RestoreArray( void* vector, double** array );
+	void PETScVector_Duplicate( void* vector, void** dstVector );
+	void PETScVector_CopyEntries( void* vector, void* dstVector );
+
+	/*--------------------------------------------------------------------------------------------------------------------------
+	** Public functions
+	*/
+
+	void PETScVector_SetComm( void* vector, MPI_Comm comm );
+
+	/*--------------------------------------------------------------------------------------------------------------------------
+	** Private Member functions
+	*/
+
+#endif /* __StgFEM_SLE_LinearAlgebra_PETScVector_h__ */

Added: long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/PETScVector.meta
===================================================================
--- long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/PETScVector.meta	2006-12-22 14:06:39 UTC (rev 5623)
+++ long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/PETScVector.meta	2006-12-22 16:23:04 UTC (rev 5624)
@@ -0,0 +1,15 @@
+<?xml version="1.0"?>
+<!DOCTYPE StGermainData SYSTEM "stgermain.dtd">
+<StGermainData xmlns="http://www.vpac.org/StGermain/XML_IO_Handler/Jun2003">
+
+<param name="Name">PETScVector</param>
+<param name="Organisation">VPAC</param>
+<param name="Project">StgFEM</param>
+<param name="Location">StgFEM/SLE/LinearAlgebra/src/</param>
+<param name="Project Web">https://csd.vpac.org/twiki/bin/view/StgFEM/WebHome</param>
+<param name="Copyright">StGermain Framework. Copyright (C) 2003-2005 VPAC.</param>
+<param name="License">The Gnu Lesser General Public License http://www.gnu.org/licenses/lgpl.html</param>
+<param name="Parent"></param>
+<param name="Description">...</param>
+
+</StGermainData>

Deleted: long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/Utils.h
===================================================================
--- long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/Utils.h	2006-12-22 14:06:39 UTC (rev 5623)
+++ long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/Utils.h	2006-12-22 16:23:04 UTC (rev 5624)
@@ -1,57 +0,0 @@
-/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-**
-** Copyright (C), 2003-2006, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street,
-**	Melbourne, 3053, Australia.
-**
-** Primary Contributing Organisations:
-**	Victorian Partnership for Advanced Computing Ltd, Computational Software Development - http://csd.vpac.org
-**	Australian Computational Earth Systems Simulator - http://www.access.edu.au
-**	Monash Cluster Computing - http://www.mcc.monash.edu.au
-**	Computational Infrastructure for Geodynamics - http://www.geodynamics.org
-**
-** Contributors:
-**	Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
-**	Robert Turnbull, Research Assistant, Monash University. (robert.turnbull at sci.monash.edu.au)
-**	Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
-**	David May, PhD Student, Monash University (david.may at sci.monash.edu.au)
-**	Louis Moresi, Associate Professor, Monash University. (louis.moresi at sci.monash.edu.au)
-**	Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
-**	Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
-**	Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
-**	Julian Giordani, Research Assistant, Monash University. (julian.giordani at sci.monash.edu.au)
-**	Vincent Lemiale, Postdoctoral Fellow, Monash University. (vincent.lemiale at sci.monash.edu.au)
-**
-**  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:
-**
-** Comments:
-**
-** $Id: Matrix.h 384 2005-10-03 06:07:50Z LukeHodkinson $
-**
-**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-
-#ifndef __StgFEM_SLE_LinearAlgebra_Utils_h__
-#define __StgFEM_SLE_LinearAlgebra_Utils_h__
-
-
-size_t LinearAlgebra_GetMemoryUsage( void );
-
-
-#endif /* __StgFEM_SLE_LinearAlgebra_Utils_h__ */

Added: long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/Vector.c
===================================================================
--- long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/Vector.c	2006-12-22 14:06:39 UTC (rev 5623)
+++ long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/Vector.c	2006-12-22 16:23:04 UTC (rev 5624)
@@ -0,0 +1,181 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+**
+** 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: Vector.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 "LinearAlgebra.h"
+
+
+/* Textual name of this class */
+const Type Vector_Type = "Vector";
+
+
+/*----------------------------------------------------------------------------------------------------------------------------------
+** Constructors
+*/
+
+Vector* _Vector_New( VECTOR_DEFARGS ) {
+	Vector*	self;
+
+	/* Allocate memory */
+	assert( sizeOfSelf >= sizeof(Vector) );
+	self = (Vector*)_Stg_Component_New( STG_COMPONENT_PASSARGS );
+
+	/* Virtual info */
+	self->setCommFunc = setCommFunc;
+	self->setGlobalSizeFunc = setGlobalSizeFunc;
+	self->setLocalSizeFunc = setLocalSizeFunc;
+	self->addEntriesFunc = addEntriesFunc;
+	self->insertEntriesFunc = insertEntriesFunc;
+	self->setScalarFunc = setScalarFunc;
+	self->zeroFunc = zeroFunc;
+	self->assemblyBeginFunc = assemblyBeginFunc;
+	self->assemblyEndFunc = assemblyEndFunc;
+
+	self->addFunc = addFunc;
+	self->addScaledFunc = addScaledFunc;
+	self->scaleAddFunc = scaleAddFunc;
+	self->subtractFunc = subtractFunc;
+	self->scaleFunc = scaleFunc;
+	self->dotProductFunc = dotProductFunc;
+	self->l2NormFunc = l2NormFunc;
+	self->lInfNormFunc = lInfNormFunc; 
+	self->pointwiseMultiplyFunc = pointwiseMultiplyFunc;
+	self->pointwiseDivideFunc = pointwiseDivideFunc;
+	self->reciprocalFunc = reciprocalFunc;
+
+	self->getSizeFunc = getSizeFunc;
+	self->getLocalSizeFunc = getLocalSizeFunc;
+	self->getArrayFunc = getArrayFunc;
+	self->restoreArrayFunc = restoreArrayFunc;
+	self->duplicateFunc = duplicateFunc;
+	self->copyEntriesFunc = copyEntriesFunc;
+	self->viewFunc = viewFunc;
+
+	/* Vector info */
+	_Vector_Init( self );
+
+	return self;
+}
+
+void _Vector_Init( Vector* self ) {
+	assert( self && Stg_CheckType( self, Vector ) );
+
+	self->comm = MPI_COMM_WORLD;
+}
+
+
+/*----------------------------------------------------------------------------------------------------------------------------------
+** Virtual functions
+*/
+
+void _Vector_Delete( void* vector ) {
+	Vector*	self = (Vector*)vector;
+
+	assert( self && Stg_CheckType( self, Vector ) );
+
+	/* Delete the parent. */
+	_Stg_Component_Delete( self );
+}
+
+void _Vector_Print( void* vector, Stream* stream ) {
+	Vector*	self = (Vector*)vector;
+	
+	/* Set the Journal for printing informations */
+	Stream* vectorStream;
+	vectorStream = Journal_Register( InfoStream_Type, "VectorStream" );
+
+	assert( self && Stg_CheckType( self, Vector ) );
+
+	/* Print parent */
+	Journal_Printf( stream, "Vector (ptr): (%p)\n", self );
+	_Stg_Component_Print( self, stream );
+}
+
+void _Vector_Construct( void* vector, Stg_ComponentFactory* cf, void* data ) {
+	Vector*	self = (Vector*)vector;
+
+	assert( self && Stg_CheckType( self, Vector ) );
+	assert( cf );
+}
+
+void _Vector_Build( void* vector, void* data ) {
+}
+
+void _Vector_Initialise( void* vector, void* data ) {
+}
+
+void _Vector_Execute( void* vector, void* data ) {
+}
+
+void _Vector_Destroy( void* vector, void* data ) {
+}
+
+void _Vector_SetComm( void* vector, MPI_Comm comm ) {
+	Vector*	self = (Vector*)vector;
+
+	assert( self && Stg_CheckType( self, Vector ) );
+
+	self->comm = comm;
+}
+
+void _Vector_View( void* vector, void* _stream ) {
+	Vector*		self = (Vector*)vector;
+	Stream*		stream = (Stream*)_stream;
+	unsigned	size;
+	double*		array;
+	unsigned	entry_i;
+
+	assert( self && Stg_CheckType( self, Vector ) );
+	assert( stream );
+
+	size = Vector_GetLocalSize( self );
+	Vector_GetArray( self, &array );
+	Journal_Printf( stream, "%s = [\n", self->name );
+	for( entry_i = 0; entry_i < size; entry_i++ ) 
+		Journal_Printf( stream , "\t%u: \t %2.4g\n", entry_i, array[entry_i] );
+	Journal_Printf( stream, "];\n");
+	Vector_RestoreArray( self, &array );
+}
+
+
+/*--------------------------------------------------------------------------------------------------------------------------
+** Public Functions
+*/
+
+
+/*----------------------------------------------------------------------------------------------------------------------------------
+** Private Functions
+*/

Modified: long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/Vector.h
===================================================================
--- long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/Vector.h	2006-12-22 14:06:39 UTC (rev 5623)
+++ long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/Vector.h	2006-12-22 16:23:04 UTC (rev 5624)
@@ -1,25 +1,14 @@
 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 **
-** Copyright (C), 2003-2006, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street,
-**	Melbourne, 3053, Australia.
+** Copyright (C), 2003, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street, Melbourne, 3053, Australia.
 **
-** Primary Contributing Organisations:
-**	Victorian Partnership for Advanced Computing Ltd, Computational Software Development - http://csd.vpac.org
-**	Australian Computational Earth Systems Simulator - http://www.access.edu.au
-**	Monash Cluster Computing - http://www.mcc.monash.edu.au
-**	Computational Infrastructure for Geodynamics - http://www.geodynamics.org
-**
-** Contributors:
+** Authors:
+**	Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
 **	Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
-**	Robert Turnbull, Research Assistant, Monash University. (robert.turnbull at sci.monash.edu.au)
-**	Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
-**	David May, PhD Student, Monash University (david.may at sci.monash.edu.au)
-**	Louis Moresi, Associate Professor, Monash University. (louis.moresi at sci.monash.edu.au)
 **	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)
-**	Julian Giordani, Research Assistant, Monash University. (julian.giordani at sci.monash.edu.au)
-**	Vincent Lemiale, Postdoctoral Fellow, Monash University. (vincent.lemiale at sci.monash.edu.au)
 **
 **  This library is free software; you can redistribute it and/or
 **  modify it under the terms of the GNU Lesser General Public
@@ -41,6 +30,8 @@
 **
 ** Assumptions:
 **
+** Invariants:
+**
 ** Comments:
 **
 ** $Id$
@@ -49,61 +40,255 @@
 
 #ifndef __StgFEM_SLE_LinearAlgebra_Vector_h__
 #define __StgFEM_SLE_LinearAlgebra_Vector_h__
-	
-	Vector* Vector_New_SpecifyLocalSize( MPI_Comm comm, Index size );
-	Vector* Vector_New_SpecifyGlobalSize( MPI_Comm comm, Index size );
-	Vector* Vector_New_FromArray( MPI_Comm comm, Index size, double* array );
-	Vector* Vector_New_Ghost(MPI_Comm comm, Index localSize, Index ghostCount, Index *ghosts);
-	Vector* Vector_New_GhostFromArray(MPI_Comm comm, Index localSize, Index ghostCount, Index *ghosts, double *array);
-	Vector* Vector_New_Seq( Index size );
-	void Vector_Destroy(Vector *vector);
-	
-	void Vector_View( Vector* vector, Stream* stream );
-	
-	void Vector_AddTo( Vector* vector, Index count, Index indices[], double* values );
-	void Vector_Insert( Vector* vector, Index count, Index indices[], double* values );
-	void Vector_SetEntry( Vector* vector, Index ind, double val );
-	void Vector_AddEntry( Vector* vector, Index ind, double val );
-	void Vector_AssemblyBegin( Vector* vector );
-	void Vector_AssemblyEnd( Vector* vector );
-	void Vector_Zero( Vector* vector );
-	
-	void Vector_Get(Vector *vector, double **array);
-	void Vector_GetValues( Vector* vector, unsigned nInds, unsigned* inds, double* array );
-	void Vector_GhostGetLocal(Vector *vector, Vector **local);
-	void Vector_Restore(Vector *vector, double **array);
-	void Vector_GhostRestoreLocal(Vector *vector, Vector **local);
-	void Vector_Duplicate(Vector *vector, Vector **newVector);
-	Index Vector_LocalSize(Vector *vector);
-	Index Vector_GlobalSize(Vector *vector);
 
-	void Vector_SetContents( Vector* x, double a );
-	void Vector_ScaleContents( Vector* x, double a );
-	void Vector_CopyContents( Vector* x, Vector* y );
-	void Vector_DotProduct( Vector* x, Vector* y, double* dot_prod );
-	void Vector_AddScaledVector( Vector* vector, double scaleFactor, Vector* vectorToAdd );
-	void Vector_ScaleAndAddVector( Vector* vector, double scaleFactor, Vector* vectorToAdd );
-	double Vector_L2_Norm( Vector* x );
-	double Vector_Linf_Norm( Vector* x );
-	
-	void Vector_MaxComponent ( Vector* x, int* position, double* maxValue);
-	
-	
-	/** Vector_PointwiseDivide - for each entry in vector x and y calculates "result = x/y" */
-	void Vector_PointwiseDivide( Vector* x, Vector* y, Vector* result );
-	void Vector_PointwiseMultiply( Vector* x, Vector* y, Vector* result );
+	/** Textual name of this class */
+	extern const Type Vector_Type;
 
-	void Vector_Transfer( Vector*		dst, 
-			      Vector*		src, 
-			      Index		idxCnt, 
-			      Index		dstIndices[], 
-			      Index		srcIndices[], 
-			      MPI_Comm		comm );
-	
-	void Vector_SetLocalSize( Vector* vec, unsigned size );
-	
-	void Vector_DupNewSize( MPI_Comm comm, Vector* src, unsigned localSize, Vector** dst );
+	/** Virtual function types */
+	typedef void (Vector_SetCommFunc)( void* vector, MPI_Comm comm );
+	typedef void (Vector_SetGlobalSizeFunc)( void* vector, unsigned size );
+	typedef void (Vector_SetLocalSizeFunc)( void* vector, unsigned size );
+	typedef void (Vector_AddEntriesFunc)( void* vector, unsigned nEntries, unsigned* indices, double* values );
+	typedef void (Vector_InsertEntriesFunc)( void* vector, unsigned nEntries, unsigned* indices, double* values );
+	typedef void (Vector_SetScalarFunc)( void* vector, double scalar );
+	typedef void (Vector_ZeroFunc)( void* vector );
+	typedef void (Vector_AssemblyBeginFunc)( void* vector );
+	typedef void (Vector_AssemblyEndFunc)( void* vector );
 
-	void Vector_Reciprocal( Vector* vec );
+	typedef void (Vector_AddFunc)( void* vector, void* vector0 );
+	typedef void (Vector_AddScaledFunc)( void* vector, double scalar, void* vector0 );
+	typedef void (Vector_ScaleAddFunc)( void* vector, double scalar, void* vector0 );
+	typedef void (Vector_SubtractFunc)( void* vector, void* vector0 );
+	typedef void (Vector_ScaleFunc)( void* vector, double factor );
+	typedef double (Vector_DotProductFunc)( void* vector, void* vector0 );
+	typedef double (Vector_L2NormFunc)( void* vector );
+	typedef double (Vector_LInfNormFunc)( void* vector );
+	typedef void (Vector_PointwiseMultiplyFunc)( void* vector, void* vector0, void* dstVector );
+	typedef void (Vector_PointwiseDivideFunc)( void* vector, void* vector0, void* dstVector );
+	typedef void (Vector_ReciprocalFunc)( void* vector );
 
+	typedef unsigned (Vector_GetGlobalSizeFunc)( void* vector );
+	typedef unsigned (Vector_GetLocalSizeFunc)( void* vector );
+	typedef void (Vector_GetArrayFunc)( void* vector, double** array );
+	typedef void (Vector_RestoreArrayFunc)( void* vector, double** array );
+	typedef void (Vector_DuplicateFunc)( void* vector, void** dstVector );
+	typedef void (Vector_CopyEntriesFunc)( void* vector, void* dstVector );
+	typedef void (Vector_ViewFunc)( void* vector, void* stream );
+
+	/** Vector class contents */
+	#define __Vector						\
+		/* General info */					\
+		__Stg_Component						\
+									\
+		/* Virtual info */					\
+		Vector_SetCommFunc*		setCommFunc;		\
+		Vector_SetGlobalSizeFunc*	setGlobalSizeFunc;	\
+		Vector_SetLocalSizeFunc*	setLocalSizeFunc;	\
+		Vector_AddEntriesFunc*		addEntriesFunc;		\
+		Vector_InsertEntriesFunc*	insertEntriesFunc;	\
+		Vector_SetScalarFunc*		setScalarFunc;		\
+		Vector_ZeroFunc*		zeroFunc;		\
+		Vector_AssemblyBeginFunc*	assemblyBeginFunc;	\
+		Vector_AssemblyEndFunc*		assemblyEndFunc;	\
+									\
+		Vector_AddFunc*			addFunc;		\
+		Vector_AddScaledFunc*		addScaledFunc;		\
+		Vector_ScaleAddFunc*		scaleAddFunc;		\
+		Vector_SubtractFunc*		subtractFunc;		\
+		Vector_ScaleFunc*		scaleFunc;		\
+		Vector_DotProductFunc*		dotProductFunc;		\
+		Vector_L2NormFunc*		l2NormFunc;		\
+		Vector_LInfNormFunc*		lInfNormFunc;		\
+		Vector_PointwiseMultiplyFunc*	pointwiseMultiplyFunc;	\
+		Vector_PointwiseDivideFunc*	pointwiseDivideFunc;	\
+		Vector_ReciprocalFunc*		reciprocalFunc;		\
+									\
+		Vector_GetGlobalSizeFunc*	getSizeFunc;		\
+		Vector_GetLocalSizeFunc*	getLocalSizeFunc;	\
+		Vector_GetArrayFunc*		getArrayFunc;		\
+		Vector_RestoreArrayFunc*	restoreArrayFunc;	\
+		Vector_DuplicateFunc*		duplicateFunc;		\
+		Vector_CopyEntriesFunc*		copyEntriesFunc;	\
+		Vector_ViewFunc*		viewFunc;		\
+									\
+		/* Vector info */					\
+		MPI_Comm		comm;
+
+	struct Vector { __Vector };
+
+	/*--------------------------------------------------------------------------------------------------------------------------
+	** Constructors
+	*/
+
+	#define VECTOR_DEFARGS						\
+		STG_COMPONENT_DEFARGS,					\
+		Vector_SetCommFunc*		setCommFunc, 		\
+		Vector_SetGlobalSizeFunc*	setGlobalSizeFunc,	\
+		Vector_SetLocalSizeFunc*	setLocalSizeFunc,	\
+		Vector_AddEntriesFunc*		addEntriesFunc,		\
+		Vector_InsertEntriesFunc*	insertEntriesFunc,	\
+		Vector_SetScalarFunc*		setScalarFunc,		\
+		Vector_ZeroFunc*		zeroFunc,		\
+		Vector_AssemblyBeginFunc*	assemblyBeginFunc,	\
+		Vector_AssemblyEndFunc*		assemblyEndFunc,	\
+									\
+		Vector_AddFunc*			addFunc,		\
+		Vector_AddScaledFunc*		addScaledFunc,		\
+		Vector_ScaleAddFunc*		scaleAddFunc,		\
+		Vector_SubtractFunc*		subtractFunc,		\
+		Vector_ScaleFunc*		scaleFunc,		\
+		Vector_DotProductFunc*		dotProductFunc,		\
+		Vector_L2NormFunc*		l2NormFunc,		\
+		Vector_LInfNormFunc*		lInfNormFunc,		\
+		Vector_PointwiseMultiplyFunc*	pointwiseMultiplyFunc,	\
+		Vector_PointwiseDivideFunc*	pointwiseDivideFunc,	\
+		Vector_ReciprocalFunc*		reciprocalFunc,		\
+									\
+		Vector_GetGlobalSizeFunc*	getSizeFunc,		\
+		Vector_GetLocalSizeFunc*	getLocalSizeFunc,	\
+		Vector_GetArrayFunc*		getArrayFunc,		\
+		Vector_RestoreArrayFunc*	restoreArrayFunc,	\
+		Vector_DuplicateFunc*		duplicateFunc,		\
+		Vector_CopyEntriesFunc*		copyEntriesFunc,	\
+		Vector_ViewFunc*		viewFunc
+
+	#define VECTOR_PASSARGS			\
+		STG_COMPONENT_PASSARGS, 	\
+		setCommFunc, 			\
+		setGlobalSizeFunc,		\
+		setLocalSizeFunc,		\
+		addEntriesFunc,			\
+		insertEntriesFunc,		\
+		setScalarFunc,			\
+		zeroFunc,			\
+		assemblyBeginFunc,		\
+		assemblyEndFunc,		\
+						\
+		addFunc,			\
+		addScaledFunc,			\
+		scaleAddFunc,			\
+		subtractFunc,			\
+		scaleFunc,			\
+		dotProductFunc,			\
+		l2NormFunc,			\
+		lInfNormFunc,			\
+		pointwiseMultiplyFunc,		\
+		pointwiseDivideFunc,		\
+		reciprocalFunc,			\
+						\
+		getSizeFunc,			\
+		getLocalSizeFunc,		\
+		getArrayFunc,			\
+		restoreArrayFunc,		\
+		duplicateFunc,			\
+		copyEntriesFunc,		\
+		viewFunc
+
+	Vector* _Vector_New( VECTOR_DEFARGS );
+	void _Vector_Init( Vector* self );
+
+	/*--------------------------------------------------------------------------------------------------------------------------
+	** Virtual functions
+	*/
+
+	void _Vector_Delete( void* vector );
+	void _Vector_Print( void* vector, Stream* stream );
+	void _Vector_Construct( void* vector, Stg_ComponentFactory* cf, void* data );
+	void _Vector_Build( void* vector, void* data );
+	void _Vector_Initialise( void* vector, void* data );
+	void _Vector_Execute( void* vector, void* data );
+	void _Vector_Destroy( void* vector, void* data );
+
+	void _Vector_SetComm( void* vector, MPI_Comm comm );
+	void _Vector_View( void* vector, void* stream );
+
+	#define Vector_SetComm( self, comm )			\
+		VirtualCall( self, setCommFunc, self, comm )
+
+	#define Vector_SetGlobalSize( self, size )	\
+		VirtualCall( self, setGlobalSizeFunc, self, size )
+
+	#define Vector_SetLocalSize( self, size )	\
+		VirtualCall( self, setLocalSizeFunc, self, size )
+
+	#define Vector_AddEntries( self, nEntries, indices, values )	\
+		VirtualCall( self, addEntriesFunc, self, nEntries, indices, values )
+
+	#define Vector_InsertEntries( self, nEntries, indices, values )	\
+		VirtualCall( self, insertEntriesFunc, self, nEntries, indices, values )
+
+	#define Vector_SetScalar( self, scalar )	\
+		VirtualCall( self, setScalarFunc, self, scalar )
+
+	#define Vector_Zero( self )	\
+		VirtualCall( self, zeroFunc, self )
+
+	#define Vector_AssemblyBegin( self )	\
+		VirtualCall( self, assemblyBeginFunc, self )
+
+	#define Vector_AssemblyEnd( self )	\
+		VirtualCall( self, assemblyEndFunc, self )
+
+	#define Vector_Add( self, vector0 )		\
+		VirtualCall( self, addFunc, self, vector0 )
+
+	#define Vector_AddScaled( self, scalar, vector0 )	\
+		VirtualCall( self, addScaledFunc, self, scalar, vector0 )
+
+	#define Vector_ScaleAdd( self, scalar, vector0 )	\
+		VirtualCall( self, scaleAddFunc, self, scalar, vector0 )
+
+	#define Vector_Subtract( self, vector0 )	\
+		VirtualCall( self, subtractFunc, self, vector0 )
+
+	#define Vector_Scale( self, factor )	\
+		VirtualCall( self, scaleFunc, self, factor )
+
+	#define Vector_DotProduct( self, vector0 )	\
+		VirtualCall( self, dotProductFunc, self, vector0 )
+
+	#define Vector_L2Norm( self )	\
+		VirtualCall( self, l2NormFunc, self )
+
+	#define Vector_LInfNorm( self )	\
+		VirtualCall( self, lInfNormFunc, self )
+
+	#define Vector_PointwiseMultiply( self, vector0, dstVector )	\
+		VirtualCall( self, pointwiseMultiplyFunc, self, vector0, dstVector )
+
+	#define Vector_PointwiseDivide( self, vector0, dstVector )	\
+		VirtualCall( self, pointwiseDivideFunc, self, vector0, dstVector )
+
+	#define Vector_Reciprocal( self )	\
+		VirtualCall( self, reciprocalFunc, self )
+
+	#define Vector_GetGlobalSize( self )	\
+		VirtualCall( self, getSizeFunc, self )
+
+	#define Vector_GetLocalSize( self )	\
+		VirtualCall( self, getLocalSizeFunc, self )
+
+	#define Vector_GetArray( self, array )			\
+		VirtualCall( self, getArrayFunc, self, array )
+
+	#define Vector_RestoreArray( self, array )	\
+		VirtualCall( self, restoreArrayFunc, self, array )
+
+	#define Vector_Duplicate( self, dstVector )	\
+		VirtualCall( self, duplicateFunc, self, dstVector )
+
+	#define Vector_CopyEntries( self, dstVector )	\
+		VirtualCall( self, copyEntriesFunc, self, dstVector )
+
+	#define Vector_View( self, stream )			\
+		VirtualCall( self, viewFunc, self, stream )
+
+	/*--------------------------------------------------------------------------------------------------------------------------
+	** Public functions
+	*/
+
+	/*--------------------------------------------------------------------------------------------------------------------------
+	** Private Member functions
+	*/
+
 #endif /* __StgFEM_SLE_LinearAlgebra_Vector_h__ */

Added: long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/Vector.meta
===================================================================
--- long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/Vector.meta	2006-12-22 14:06:39 UTC (rev 5623)
+++ long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/Vector.meta	2006-12-22 16:23:04 UTC (rev 5624)
@@ -0,0 +1,15 @@
+<?xml version="1.0"?>
+<!DOCTYPE StGermainData SYSTEM "stgermain.dtd">
+<StGermainData xmlns="http://www.vpac.org/StGermain/XML_IO_Handler/Jun2003">
+
+<param name="Name">Vector</param>
+<param name="Organisation">VPAC</param>
+<param name="Project">StgFEM</param>
+<param name="Location">StgFEM/SLE/LinearAlgebra/src/</param>
+<param name="Project Web">https://csd.vpac.org/twiki/bin/view/StgFEM/WebHome</param>
+<param name="Copyright">StGermain Framework. Copyright (C) 2003-2005 VPAC.</param>
+<param name="License">The Gnu Lesser General Public License http://www.gnu.org/licenses/lgpl.html</param>
+<param name="Parent"></param>
+<param name="Description">...</param>
+
+</StGermainData>

Deleted: long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/dummy.c
===================================================================
--- long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/dummy.c	2006-12-22 14:06:39 UTC (rev 5623)
+++ long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/dummy.c	2006-12-22 16:23:04 UTC (rev 5624)
@@ -1,46 +0,0 @@
-/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-**
-** Copyright (C), 2003-2006, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street,
-**	Melbourne, 3053, Australia.
-**
-** Primary Contributing Organisations:
-**	Victorian Partnership for Advanced Computing Ltd, Computational Software Development - http://csd.vpac.org
-**	Australian Computational Earth Systems Simulator - http://www.access.edu.au
-**	Monash Cluster Computing - http://www.mcc.monash.edu.au
-**	Computational Infrastructure for Geodynamics - http://www.geodynamics.org
-**
-** Contributors:
-**	Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
-**	Robert Turnbull, Research Assistant, Monash University. (robert.turnbull at sci.monash.edu.au)
-**	Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
-**	David May, PhD Student, Monash University (david.may at sci.monash.edu.au)
-**	Louis Moresi, Associate Professor, Monash University. (louis.moresi at sci.monash.edu.au)
-**	Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
-**	Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
-**	Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
-**	Julian Giordani, Research Assistant, Monash University. (julian.giordani at sci.monash.edu.au)
-**	Vincent Lemiale, Postdoctoral Fellow, Monash University. (vincent.lemiale at sci.monash.edu.au)
-**
-**  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$
-**
-**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-
-/* exists only such that MM doesn't fail to create an empty ".a" */
- 
-/* dummy function so that Tru64 CC doesn't complain about doing nothing */
-const int StgSLE_LinearAlgebraSrcDummy = 0;
-

Modified: long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/types.h
===================================================================
--- long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/types.h	2006-12-22 14:06:39 UTC (rev 5623)
+++ long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/types.h	2006-12-22 16:23:04 UTC (rev 5624)
@@ -50,28 +50,43 @@
 #ifndef __StgFEM_SLE_LinearAlgrebra_types_h__
 #define __StgFEM_SLE_LinearAlgrebra_types_h__
 	
-	/* Types user needs to define */
-	typedef struct _Matrix          Matrix;
-	typedef struct _Vector          Vector;
-	typedef struct _MatrixSolver    MatrixSolver;
+	/* Classes. */
+	typedef struct Vector			Vector;
+	typedef struct Matrix			Matrix;
+	typedef struct MatrixSolver		MatrixSolver;
+	typedef struct MultigridSolver		MultigridSolver;
+#ifdef HAVE_PETSC
+	typedef struct PETScVector		PETScVector;
+	typedef struct PETScMatrix		PETScMatrix;
+	typedef struct PETScMatrixSolver	PETScMatrixSolver;
+#endif
 
+	typedef enum {
+		MatrixSolver_Status_ConvergedRelative = 2, 
+		MatrixSolver_Status_ConvergedAbsolute = 3, 
+		MatrixSolver_Status_ConvergedIterations = 4, 
+		MatrixSolver_Status_DivergedNull = -2, 
+		MatrixSolver_Status_DivergedIterations = -3, 
+		MatrixSolver_Status_DivergedTolerance = -4, 
+		MatrixSolver_Status_Iterating = 0
+	} MatrixSolver_Status;
 
 	/* KSP enumerations. */
 	typedef enum {
-		richardson, 
-		gmRes, 
-		preOnly
-	} MatrixSolver_KSP;
+		PETScMatrixSolver_KSPType_Richardson, 
+		PETScMatrixSolver_KSPType_GMRes, 
+		PETScMatrixSolver_KSPType_PreOnly
+	} PETScMatrixSolver_KSPType;
 
 	/* PC enumerations. */
 	typedef enum {
-		jacobi, 
-		blockJacobi, 
-		sor, 
-		lu, 
-		ilu
-	} MatrixSolver_PC;
+		PETScMatrixSolver_PCType_Jacobi, 
+		PETScMatrixSolver_PCType_BlockJacobi, 
+		PETScMatrixSolver_PCType_SOR, 
+		PETScMatrixSolver_PCType_LU, 
+		PETScMatrixSolver_PCType_ILU, 
+		PETScMatrixSolver_PCType_None
+	} PETScMatrixSolver_PCType;
 
-
 #endif /* __StgFEM_SLE_LinearAlgrebra_types_h__ */
 



More information about the cig-commits mailing list