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

walter at geodynamics.org walter at geodynamics.org
Fri Feb 23 10:03:55 PST 2007


Author: walter
Date: 2007-02-23 10:03:54 -0800 (Fri, 23 Feb 2007)
New Revision: 6095

Modified:
   long/3D/Gale/trunk/src/StgFEM/
   long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/Matrix.c
   long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/Matrix.h
   long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/PETScMGSolver.c
   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/Vector.c
   long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/Vector.h
Log:
 r981 at earth (orig r723):  LukeHodkinson | 2007-01-30 14:45:46 -0800
 * Adding some debugging functions to the Vector and
   Matrix classes; dumps out bit-for-bit hexadecimal
   representations of their contents.
 * Reducing the number of default smoothing steps to 
   one for both up and down solves.
 



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

Modified: long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/Matrix.c
===================================================================
--- long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/Matrix.c	2007-02-23 18:03:52 UTC (rev 6094)
+++ long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/Matrix.c	2007-02-23 18:03:54 UTC (rev 6095)
@@ -86,7 +86,6 @@
 	self->getDiagonalFunc = getDiagonalFunc;
 	self->duplicateFunc = duplicateFunc;
 	self->copyEntriesFunc = copyEntriesFunc;
-	self->dumpFunc = dumpFunc;
 
 	/* Matrix info */
 	_Matrix_Init( self );
@@ -182,6 +181,32 @@
 ** Public Functions
 */
 
+void Matrix_Dump( void* matrix, const char* filename ) {
+	Matrix*		self = (Matrix*)matrix;
+	FILE*		fp;
+	unsigned	nRows, nEntries, *entries;
+	double*		values;
+	unsigned	row_i, entry_i, b_i;
+
+	assert( self && Stg_CheckType( self, Matrix ) );
+
+	insist( fp = fopen( filename, "w" ) );
+
+	Matrix_GetLocalSize( self, &nRows, NULL );
+	for( row_i = 0; row_i < nRows; row_i++ ) {
+		Matrix_GetRow( self, row_i, &nEntries, &entries, &values );
+		for( entry_i = 0; entry_i < nEntries; entry_i++ ) {
+			fprintf( fp, "(%d, %d): ", row_i, entries[entry_i] );
+			for( b_i = 0; b_i < sizeof(double) / sizeof(unsigned); b_i++ )
+				fprintf( fp, "%x", ((unsigned*)(values + entry_i))[b_i] );
+			fprintf( fp, "\n" );
+		}
+		Matrix_RestoreRow( self, row_i, &nEntries, &entries, &values );
+	}
+
+	fclose( fp );
+}
+
 void Matrix_InvalidateSolvers( void* matrix ) {
 	Matrix*		self = (Matrix*)matrix;
 	MatrixSolver*	solver;

Modified: long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/Matrix.h
===================================================================
--- long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/Matrix.h	2007-02-23 18:03:52 UTC (rev 6094)
+++ long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/Matrix.h	2007-02-23 18:03:54 UTC (rev 6095)
@@ -82,7 +82,6 @@
 	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 );
 
 	/** Matrix class contents */
 	#define __Matrix								\
@@ -121,7 +120,6 @@
 		Matrix_GetDiagonalFunc*			getDiagonalFunc;		\
 		Matrix_DuplicateFunc*			duplicateFunc;			\
 		Matrix_CopyEntriesFunc*			copyEntriesFunc;		\
-		Matrix_DumpFunc*			dumpFunc;			\
 											\
 		/* Matrix info */					       		\
 		MPI_Comm		comm;						\
@@ -166,8 +164,7 @@
 		Matrix_RestoreRowFunc*			restoreRowFunc,			\
 		Matrix_GetDiagonalFunc*			getDiagonalFunc,		\
 		Matrix_DuplicateFunc*			duplicateFunc, 			\
-		Matrix_CopyEntriesFunc*			copyEntriesFunc,		\
-		Matrix_DumpFunc*			dumpFunc
+		Matrix_CopyEntriesFunc*			copyEntriesFunc
 
 	#define MATRIX_PASSARGS			\
 		STG_COMPONENT_PASSARGS, 	\
@@ -201,8 +198,7 @@
 		restoreRowFunc,			\
 		getDiagonalFunc,		\
 		duplicateFunc, 			\
-		copyEntriesFunc,		\
-		dumpFunc
+		copyEntriesFunc
 
 	Matrix* _Matrix_New( MATRIX_DEFARGS );
 	void _Matrix_Init( Matrix* self );
@@ -309,13 +305,11 @@
 	#define Matrix_CopyEntries( self, dstMatrix )							\
 		VirtualCall( self, copyEntriesFunc, self, dstMatrix )
 
-	#define Matrix_Dump( self, filename )								\
-		VirtualCall( self, dumpFunc, self, filename )
-
 	/*--------------------------------------------------------------------------------------------------------------------------
 	** Public functions
 	*/
 
+	void Matrix_Dump( void* matrix, const char* filename );
 	void Matrix_InvalidateSolvers( void* matrix );
 
 	/*--------------------------------------------------------------------------------------------------------------------------

Modified: long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/PETScMGSolver.c
===================================================================
--- long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/PETScMGSolver.c	2007-02-23 18:03:52 UTC (rev 6094)
+++ long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/PETScMGSolver.c	2007-02-23 18:03:54 UTC (rev 6095)
@@ -237,8 +237,8 @@
 	for( l_i = 0; l_i < nLevels; l_i++ ) {
 		PETScMGSolver_Level*	level = self->levels + l_i;
 
-		level->nDownIts = 2;
-		level->nUpIts = (l_i == 0) ? 0 : 2;
+		level->nDownIts = 1;
+		level->nUpIts = (l_i == 0) ? 0 : 1;
 		level->nCycles = 1;
 		level->R = NULL;
 		level->P = NULL;

Modified: long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/PETScMatrix.c
===================================================================
--- long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/PETScMatrix.c	2007-02-23 18:03:52 UTC (rev 6094)
+++ long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/PETScMatrix.c	2007-02-23 18:03:54 UTC (rev 6095)
@@ -89,8 +89,7 @@
 				 PETScMatrix_RestoreRow, 
 				 PETScMatrix_GetDiagonal, 
 				 PETScMatrix_Duplicate, 
-				 PETScMatrix_CopyEntries, 
-				 PETScMatrix_Dump );
+				 PETScMatrix_CopyEntries );
 }
 
 PETScMatrix* _PETScMatrix_New( PETSCMATRIX_DEFARGS ) {
@@ -680,24 +679,7 @@
 	dstMatrix->hasChanged = True;
 }
 
-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
 */

Modified: long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/PETScMatrix.h
===================================================================
--- long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/PETScMatrix.h	2007-02-23 18:03:52 UTC (rev 6094)
+++ long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/PETScMatrix.h	2007-02-23 18:03:54 UTC (rev 6095)
@@ -121,7 +121,6 @@
 	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

Modified: long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/Vector.c
===================================================================
--- long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/Vector.c	2007-02-23 18:03:52 UTC (rev 6094)
+++ long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/Vector.c	2007-02-23 18:03:54 UTC (rev 6095)
@@ -178,7 +178,30 @@
 ** Public Functions
 */
 
+void Vector_Dump( void* vector, const char* filename ) {
+	Vector*		self = (Vector*)vector;
+	FILE*		fp;
+	unsigned	size;
+	double*		array;
+	unsigned	entry_i, b_i;
 
+	assert( self && Stg_CheckType( self, Vector ) );
+
+	insist( fp = fopen( filename, "w" ) );
+
+	size = Vector_GetLocalSize( self );
+	Vector_GetArray( self, &array );
+	for( entry_i = 0; entry_i < size; entry_i++ ) {
+		for( b_i = 0; b_i < sizeof(double) / sizeof(unsigned); b_i++ )
+			fprintf( fp, "%x", ((unsigned*)(array + entry_i))[b_i] );
+		fprintf( fp, "\n" );
+	}
+	Vector_RestoreArray( self, &array );
+
+	fclose( fp );
+}
+
+
 /*----------------------------------------------------------------------------------------------------------------------------------
 ** 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	2007-02-23 18:03:52 UTC (rev 6094)
+++ long/3D/Gale/trunk/src/StgFEM/SLE/LinearAlgebra/src/Vector.h	2007-02-23 18:03:54 UTC (rev 6095)
@@ -287,6 +287,8 @@
 	** Public functions
 	*/
 
+	void Vector_Dump( void* vector, const char* filename );
+
 	/*--------------------------------------------------------------------------------------------------------------------------
 	** Private Member functions
 	*/



More information about the cig-commits mailing list