[cig-commits] r4854 - in long/3D/Gale/trunk/src/StGermain: . Discretisation/Mesh/tests

walter at geodynamics.org walter at geodynamics.org
Wed Oct 11 13:47:17 PDT 2006


Author: walter
Date: 2006-10-11 13:47:16 -0700 (Wed, 11 Oct 2006)
New Revision: 4854

Added:
   long/3D/Gale/trunk/src/StGermain/Discretisation/Mesh/tests/testCartesianGenerator.c
   long/3D/Gale/trunk/src/StGermain/Discretisation/Mesh/tests/testMeshTopology.c
Modified:
   long/3D/Gale/trunk/src/StGermain/
Log:
 r2911 at earth:  boo | 2006-10-11 13:42:39 -0700
  r2827 at earth (orig r3815):  LukeHodkinson | 2006-09-26 20:34:17 -0700
  Adding a couple of tests for the new meshing
  stuff. More to come.
  
 



Property changes on: long/3D/Gale/trunk/src/StGermain
___________________________________________________________________
Name: svk:merge
   - 1ef209d2-b310-0410-a72d-e20c9eb0015c:/cig:2910
afb6c753-b9d0-0310-b4e7-dbd8d91cdd35:/trunk/StGermain:3814
   + 1ef209d2-b310-0410-a72d-e20c9eb0015c:/cig:2911
afb6c753-b9d0-0310-b4e7-dbd8d91cdd35:/trunk/StGermain:3815

Added: long/3D/Gale/trunk/src/StGermain/Discretisation/Mesh/tests/testCartesianGenerator.c
===================================================================
--- long/3D/Gale/trunk/src/StGermain/Discretisation/Mesh/tests/testCartesianGenerator.c	2006-10-11 20:47:14 UTC (rev 4853)
+++ long/3D/Gale/trunk/src/StGermain/Discretisation/Mesh/tests/testCartesianGenerator.c	2006-10-11 20:47:16 UTC (rev 4854)
@@ -0,0 +1,118 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+**
+** 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: testMeshTopology.c 2136 2004-09-30 02:47:13Z PatrickSunter $
+**
+**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <assert.h>
+#include <mpi.h>
+
+#include "Base/Base.h"
+#include "Discretisation/Geometry/Geometry.h"
+#include "Discretisation/Mesh/Mesh.h"
+
+
+Bool testSetParams( unsigned rank, unsigned nProcs, unsigned watch );
+Bool testGen( unsigned rank, unsigned nProcs, unsigned watch );
+
+
+#define nTests	2
+
+TestSuite*	suite;
+TestSuite_Test	tests[nTests] = {{"set parameters", testSetParams}, 
+				 {"generate mesh", testGen}};
+
+
+Bool testSetParams( unsigned rank, unsigned nProcs, unsigned watch ) {
+	CartesianGenerator*	gen;
+	unsigned		sizes[3];
+
+	sizes[0] = 5;
+	sizes[1] = 2;
+	sizes[2] = 2;
+
+	gen = CartesianGenerator_New( "" );
+	CartesianGenerator_SetTopologyParams( gen, 3, sizes );
+
+	FreeObject( gen );
+
+	return True;
+}
+
+Bool testGen( unsigned rank, unsigned nProcs, unsigned watch ) {
+	CartesianGenerator*	gen;
+	Mesh*			mesh;
+	unsigned		sizes[3];
+
+	sizes[0] = 2;
+	sizes[1] = 1;
+	sizes[2] = 1;
+
+	gen = CartesianGenerator_New( "" );
+	mesh = Mesh_DefaultNew( "" );
+	CartesianGenerator_SetTopologyParams( gen, 3, sizes );
+	CartesianGenerator_Generate( gen, mesh );
+
+	FreeObject( gen );
+
+	return True;
+}
+
+
+int main( int argc, char* argv[] ) {
+	/* Initialise MPI, get world info. */
+	MPI_Init( &argc, &argv );
+
+	/* Initialise StGermain. */
+	BaseFoundation_Init( &argc, &argv );
+	BaseIO_Init( &argc, &argv );
+	BaseContainer_Init( &argc, &argv );
+
+	/* Create the test suite. */
+	suite = TestSuite_New();
+	TestSuite_SetProcToWatch( suite, (argc >= 2) ? atoi( argv[1] ) : 0 );
+	TestSuite_SetTests( suite, nTests, tests );
+
+	/* Run the tests. */
+	TestSuite_Run( suite );
+
+	/* Destroy test suites. */
+	FreeObject( suite );
+
+	/* Finalise StGermain. */
+	BaseContainer_Finalise();
+	BaseIO_Finalise();
+	BaseFoundation_Finalise();
+
+	/* Close off MPI */
+	MPI_Finalize();
+
+	return MPI_SUCCESS;
+}

Added: long/3D/Gale/trunk/src/StGermain/Discretisation/Mesh/tests/testMeshTopology.c
===================================================================
--- long/3D/Gale/trunk/src/StGermain/Discretisation/Mesh/tests/testMeshTopology.c	2006-10-11 20:47:14 UTC (rev 4853)
+++ long/3D/Gale/trunk/src/StGermain/Discretisation/Mesh/tests/testMeshTopology.c	2006-10-11 20:47:16 UTC (rev 4854)
@@ -0,0 +1,124 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+**
+** 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: testMeshTopology.c 2136 2004-09-30 02:47:13Z PatrickSunter $
+**
+**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <assert.h>
+#include <mpi.h>
+
+#include "Base/Base.h"
+#include "Discretisation/Geometry/Geometry.h"
+#include "Discretisation/Mesh/Mesh.h"
+
+
+Bool testSetElements( unsigned rank, unsigned nProcs, unsigned watch );
+void buildElements( unsigned rank, unsigned nProcs, 
+		    unsigned* nEls, unsigned** els );
+
+
+#define nTests	1
+
+TestSuite*	suite;
+TestSuite_Test	tests[nTests] = {{"set elements", testSetElements}};
+
+
+Bool testSetElements( unsigned rank, unsigned nProcs, unsigned watch ) {
+	MeshTopology*	topo;
+	unsigned	nDims = 3;
+	unsigned	nEls = 0;
+	unsigned*	els = NULL;
+
+	buildElements( rank, nProcs, &nEls, &els );
+	topo = MeshTopology_New( "" );
+	MeshTopology_SetNDims( topo, nDims );
+	MeshTopology_SetElements( topo, MT_VERTEX, nEls, els );
+
+	if( rank == watch ) {
+		if( topo->nDims != 3 || topo->nTDims != 4 || 
+		    !topo->domains || !topo->domains[MT_VERTEX] || !topo->domains[MT_VERTEX]->decomp )
+		{
+			FreeArray( els );
+			FreeObject( topo );
+			return False;
+		}
+	}
+
+	FreeArray( els );
+	FreeObject( topo );
+
+	return True;
+}
+
+void buildElements( unsigned rank, unsigned nProcs, 
+		    unsigned* nEls, unsigned** els )
+{
+	unsigned	start;
+	unsigned	e_i;
+
+	*nEls = 100;
+	*els = Memory_Alloc_Array_Unnamed( unsigned, *nEls );
+	start = rank * (*nEls - 10);
+
+	for( e_i = 0; e_i < *nEls; e_i++ )
+		(*els)[e_i] = start + e_i;
+}
+
+
+int main( int argc, char* argv[] ) {
+	/* Initialise MPI, get world info. */
+	MPI_Init( &argc, &argv );
+
+	/* Initialise StGermain. */
+	BaseFoundation_Init( &argc, &argv );
+	BaseIO_Init( &argc, &argv );
+	BaseContainer_Init( &argc, &argv );
+
+	/* Create the test suite. */
+	suite = TestSuite_New();
+	TestSuite_SetProcToWatch( suite, (argc >= 2) ? atoi( argv[1] ) : 0 );
+	TestSuite_SetTests( suite, nTests, tests );
+
+	/* Run the tests. */
+	TestSuite_Run( suite );
+
+	/* Destroy test suites. */
+	FreeObject( suite );
+
+	/* Finalise StGermain. */
+	BaseContainer_Finalise();
+	BaseIO_Finalise();
+	BaseFoundation_Finalise();
+
+	/* Close off MPI */
+	MPI_Finalize();
+
+	return MPI_SUCCESS;
+}



More information about the cig-commits mailing list