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

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


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

Added:
   long/3D/Gale/trunk/src/StGermain/Discretisation/Mesh/src/MeshGenerator.c
   long/3D/Gale/trunk/src/StGermain/Discretisation/Mesh/src/MeshGenerator.h
   long/3D/Gale/trunk/src/StGermain/Discretisation/Mesh/src/MeshGenerator.meta
Modified:
   long/3D/Gale/trunk/src/StGermain/
Log:
 r2905 at earth:  boo | 2006-10-11 13:42:37 -0700
  r2821 at earth (orig r3809):  LukeHodkinson | 2006-09-26 20:26:59 -0700
  Adding an interface for classes that generate
  a mesh (including the new MeshTopology class).
  
 



Property changes on: long/3D/Gale/trunk/src/StGermain
___________________________________________________________________
Name: svk:merge
   - 1ef209d2-b310-0410-a72d-e20c9eb0015c:/cig:2904
afb6c753-b9d0-0310-b4e7-dbd8d91cdd35:/trunk/StGermain:3808
   + 1ef209d2-b310-0410-a72d-e20c9eb0015c:/cig:2905
afb6c753-b9d0-0310-b4e7-dbd8d91cdd35:/trunk/StGermain:3809

Added: long/3D/Gale/trunk/src/StGermain/Discretisation/Mesh/src/MeshGenerator.c
===================================================================
--- long/3D/Gale/trunk/src/StGermain/Discretisation/Mesh/src/MeshGenerator.c	2006-10-11 20:46:59 UTC (rev 4847)
+++ long/3D/Gale/trunk/src/StGermain/Discretisation/Mesh/src/MeshGenerator.c	2006-10-11 20:47:01 UTC (rev 4848)
@@ -0,0 +1,238 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+**
+** 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: MeshGenerator.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 "Base/Base.h"
+
+#include "Discretisation/Geometry/Geometry.h"
+#include "Discretisation/Shape/Shape.h"
+
+#include "types.h"
+#include "shortcuts.h"
+#include "MeshClass.h"
+#include "MeshGenerator.h"
+
+
+/* Textual name of this class */
+const Type MeshGenerator_Type = "MeshGenerator";
+
+/*----------------------------------------------------------------------------------------------------------------------------------
+** Constructors
+*/
+
+MeshGenerator* _MeshGenerator_New( MESHGENERATOR_DEFARGS ) {
+	MeshGenerator* self;
+	
+	/* Allocate memory */
+	assert( sizeOfSelf >= sizeof(MeshGenerator) );
+	self = (MeshGenerator*)_Stg_Component_New( STG_COMPONENT_PASSARGS );
+
+	/* Virtual info */
+	self->generateFunc = generateFunc;
+
+	/* MeshGenerator info */
+	_MeshGenerator_Init( self );
+
+	return self;
+}
+
+void _MeshGenerator_Init( MeshGenerator* self ) {
+	self->comm = MPI_COMM_WORLD;
+	self->nMeshes = 0;
+	self->meshes = NULL;
+}
+
+
+/*----------------------------------------------------------------------------------------------------------------------------------
+** Virtual functions
+*/
+
+void _MeshGenerator_Delete( void* meshGenerator ) {
+	MeshGenerator*	self = (MeshGenerator*)meshGenerator;
+
+	FreeArray( self->meshes );
+
+	/* Delete the parent. */
+	_Stg_Component_Delete( self );
+}
+
+void _MeshGenerator_Print( void* meshGenerator, Stream* stream ) {
+	MeshGenerator*	self = (MeshGenerator*)meshGenerator;
+	
+	/* Set the Journal for printing informations */
+	Stream* meshGeneratorStream;
+	meshGeneratorStream = Journal_Register( InfoStream_Type, "MeshGeneratorStream" );
+
+	/* Print parent */
+	Journal_Printf( stream, "MeshGenerator (ptr): (%p)\n", self );
+	_Stg_Component_Print( self, stream );
+}
+
+void* _MeshGenerator_Copy( void* meshGenerator, void* destProc_I, Bool deep, Name nameExt, PtrMap* ptrMap ) {
+#if 0
+	MeshGenerator*	self = (MeshGenerator*)meshGenerator;
+	MeshGenerator*	newMeshGenerator;
+	PtrMap*	map = ptrMap;
+	Bool	ownMap = False;
+
+	/* Damn me for making copying so difficult... what was I thinking? */
+	
+	/* We need to create a map if it doesn't already exist. */
+	if( !map ) {
+		map = PtrMap_New( 10 );
+		ownMap = True;
+	}
+	
+	newMeshGenerator = (MeshGenerator*)_Mesh_Copy( self, destProc_I, deep, nameExt, map );
+	
+	/* Copy the virtual methods here. */
+
+	/* Deep or shallow? */
+	if( deep ) {
+	}
+	else {
+	}
+	
+	/* If we own the map, get rid of it here. */
+	if( ownMap ) Stg_Class_Delete( map );
+	
+	return (void*)newMeshGenerator;
+#endif
+
+	return NULL;
+}
+
+void _MeshGenerator_Construct( void* meshGenerator, Stg_ComponentFactory* cf ) {
+	MeshGenerator*		self = (MeshGenerator*)meshGenerator;
+	Dictionary*		dict;
+	Dictionary_Entry_Value*	meshList;
+	Mesh*			mesh;
+
+	assert( self );
+	assert( cf );
+
+	/* Rip out the components structure as a dictionary. */
+	dict = Dictionary_Entry_Value_AsDictionary( Dictionary_Get( cf->componentDict, self->name ) );
+
+	/* Set the communicator to a default. */
+	MeshGenerator_SetComm( self, MPI_COMM_WORLD );
+
+	/* Read the individual mesh if specified. */
+	mesh = Stg_ComponentFactory_ConstructByKey( cf, self->name, "mesh", Mesh, False );
+	if( mesh )
+		MeshGenerator_AddMesh( self, mesh );
+
+	/* Read the mesh list, if it's there. */
+	meshList = Dictionary_Get( dict, "meshes" );
+	if( meshList ) {
+		unsigned	nMeshes;
+		char*		name;
+		unsigned	m_i;
+
+		nMeshes = Dictionary_Entry_Value_GetCount( meshList );
+		for( m_i = 0; m_i < nMeshes; m_i++ ) {
+			Mesh*	mesh;
+
+			name = Dictionary_Entry_Value_AsString( Dictionary_Entry_Value_GetElement( meshList, m_i ) );
+			mesh = Stg_ComponentFactory_ConstructByName( cf, name, Mesh, True );
+			MeshGenerator_AddMesh( self, mesh );
+		}
+	}
+
+	/* Add to live component register. */
+	LiveComponentRegister_Add( cf->LCRegister, (Stg_Component*)self );
+}
+
+void _MeshGenerator_Build( void* meshGenerator, void* data ) {
+	MeshGenerator*	self = (MeshGenerator*)meshGenerator;
+	unsigned	m_i;
+
+	/* Sanity check. */
+	assert( self );
+	assert( !self->nMeshes || self->meshes );
+
+	/* Generate each mesh in our list. */
+	for( m_i = 0; m_i < self->nMeshes; m_i++ )
+		MeshGenerator_Generate( self, self->meshes[m_i] );
+}
+
+void _MeshGenerator_Initialise( void* meshGenerator, void* data ) {
+}
+
+void _MeshGenerator_Execute( void* meshGenerator, void* data ) {
+}
+
+void _MeshGenerator_Destroy( void* meshGenerator, void* data ) {
+}
+
+/*--------------------------------------------------------------------------------------------------------------------------
+** Public Functions
+*/
+
+void MeshGenerator_SetComm( void* meshGenerator, MPI_Comm comm ) {
+	MeshGenerator*	self = (MeshGenerator*)meshGenerator;
+
+	/* Sanity check. */
+	assert( self );
+
+	/* Should probably kill some stuff when I do this. Oh well. */
+	self->comm = comm;
+}
+
+void MeshGenerator_AddMesh( void* meshGenerator, void* mesh ) {
+	MeshGenerator*	self = (MeshGenerator*)meshGenerator;
+
+	/* Sanity check. */
+	assert( self );
+
+	/* If not already allocated, allocate now. */
+	if( !self->meshes ) {
+		self->nMeshes = 1;
+		self->meshes = Memory_Alloc_Array( Mesh*, 1, "MeshGenerator::meshes" );
+	}
+	else {
+		/* Otherwise reallocate. */
+		self->nMeshes++;
+		self->meshes = Memory_Realloc_Array( self->meshes, Mesh*, self->nMeshes );
+	}
+
+	/* Add the new mesh. */
+	self->meshes[self->nMeshes - 1] = mesh;
+	((Mesh*)mesh)->generator = self;
+}
+
+/*----------------------------------------------------------------------------------------------------------------------------------
+** Private Functions
+*/

Added: long/3D/Gale/trunk/src/StGermain/Discretisation/Mesh/src/MeshGenerator.h
===================================================================
--- long/3D/Gale/trunk/src/StGermain/Discretisation/Mesh/src/MeshGenerator.h	2006-10-11 20:46:59 UTC (rev 4847)
+++ long/3D/Gale/trunk/src/StGermain/Discretisation/Mesh/src/MeshGenerator.h	2006-10-11 20:47:01 UTC (rev 4848)
@@ -0,0 +1,117 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+**
+** 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: MeshGenerator.h 3584 2006-05-16 11:11:07Z PatrickSunter $
+**
+**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+
+#ifndef __Discretisaton_Mesh_MeshGenerator_h__
+#define __Discretisaton_Mesh_MeshGenerator_h__
+
+	/** Textual name of this class */
+	extern const Type MeshGenerator_Type;
+
+	/** Virtual function types */
+	typedef void (MeshGenerator_GenerateFunc)( void* meshGenerator, void* _mesh );
+
+	/** MeshGenerator class contents */
+	#define __MeshGenerator					\
+		/* General info */				\
+		__Stg_Component					\
+								\
+		/* Virtual info */				\
+		MeshGenerator_GenerateFunc*	generateFunc;	\
+								\
+		/* MeshGenerator info */			\
+		MPI_Comm			comm;		\
+		unsigned			nMeshes;	\
+		Mesh**				meshes;
+
+	struct MeshGenerator { __MeshGenerator };
+
+	/*--------------------------------------------------------------------------------------------------------------------------
+	** Constructors
+	*/
+
+	#define MESHGENERATOR_DEFARGS				\
+		STG_COMPONENT_DEFARGS,				\
+		MeshGenerator_GenerateFunc*	generateFunc
+
+	#define MESHGENERATOR_PASSARGS			\
+		STG_COMPONENT_PASSARGS, generateFunc
+
+	MeshGenerator* _MeshGenerator_New( MESHGENERATOR_DEFARGS );
+	void _MeshGenerator_Init( MeshGenerator* self );
+
+	/*--------------------------------------------------------------------------------------------------------------------------
+	** Virtual functions
+	*/
+
+	void _MeshGenerator_Delete( void* meshGenerator );
+	void _MeshGenerator_Print( void* meshGenerator, Stream* stream );
+
+	#define MeshGenerator_Copy( self ) \
+		(Mesh*)Stg_Class_Copy( self, NULL, False, NULL, NULL )
+	#define MeshGenerator_DeepCopy( self ) \
+		(Mesh*)Stg_Class_Copy( self, NULL, True, NULL, NULL )
+	void* _MeshGenerator_Copy( void* meshGenerator, void* dest, Bool deep, Name nameExt, PtrMap* ptrMap );
+
+	void _MeshGenerator_Construct( void* meshGenerator, Stg_ComponentFactory* cf );
+	void _MeshGenerator_Build( void* meshGenerator, void* data );
+	void _MeshGenerator_Initialise( void* meshGenerator, void* data );
+	void _MeshGenerator_Execute( void* meshGenerator, void* data );
+	void _MeshGenerator_Destroy( void* meshGenerator, void* data );
+
+#ifndef NDEBUG
+	#define MeshGenerator_Generate( self, mesh )			\
+		(assert( self ), (self)->generateFunc( self, mesh ))
+#else
+	#define MeshGenerator_Generate( self, mesh )	\
+		(self)->generateFunc( self, mesh )
+#endif
+
+	/*--------------------------------------------------------------------------------------------------------------------------
+	** Public functions
+	*/
+
+	void MeshGenerator_SetComm( void* meshGenerator, MPI_Comm comm );
+	void MeshGenerator_AddMesh( void* meshGenerator, void* mesh );
+
+	/*--------------------------------------------------------------------------------------------------------------------------
+	** Private Member functions
+	*/
+
+#endif /* __Discretisaton_Mesh_MeshGenerator_h__ */

Added: long/3D/Gale/trunk/src/StGermain/Discretisation/Mesh/src/MeshGenerator.meta
===================================================================
--- long/3D/Gale/trunk/src/StGermain/Discretisation/Mesh/src/MeshGenerator.meta	2006-10-11 20:46:59 UTC (rev 4847)
+++ long/3D/Gale/trunk/src/StGermain/Discretisation/Mesh/src/MeshGenerator.meta	2006-10-11 20:47:01 UTC (rev 4848)
@@ -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">MeshGenerator</param>
+<param name="Organisation">VPAC</param>
+<param name="Project">StGermain</param>
+<param name="Location">./StGermain/Discretisation/Mesh/src/</param>
+<param name="Project Web">https://csd.vpac.org/twiki/bin/view/Stgermain/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>



More information about the cig-commits mailing list