[cig-commits] commit:

Mercurial hg at geodynamics.org
Mon Nov 24 11:59:21 PST 2008


changeset:   126:d5ccc589b99f
user:        LukeHodkinson
date:        Mon Aug 04 16:27:14 2008 +0000
files:       Utils/src/MeshBoundaryShape.c Utils/src/MeshBoundaryShape.h Utils/src/MeshBoundaryShape.meta
description:
Adding a shape class that uses a certain depth
of boundary elements as a shape for material
layouts. This is useful for specifying friction
layers a certain number of elements deep into
the domain.


diff -r 12acb3a7bb6f -r d5ccc589b99f Utils/src/MeshBoundaryShape.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Utils/src/MeshBoundaryShape.c	Mon Aug 04 16:27:14 2008 +0000
@@ -0,0 +1,221 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+**
+** 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: MeshBoundaryShape.c 2192 2004-10-15 02:45:38Z LukeHodkinson $
+**
+**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+
+
+#include <string.h>
+#include <math.h>
+#include <assert.h>
+#include <mpi.h>
+
+#include <StGermain/StGermain.h>
+#include <StgDomain/Geometry/Geometry.h>
+#include <StgDomain/Shape/Shape.h>
+#include <StgDomain/Mesh/Mesh.h>
+
+#include "types.h"
+#include "MeshBoundaryShape.h"
+
+
+/* Textual name of this class */
+const Type MeshBoundaryShape_Type = "MeshBoundaryShape";
+
+
+/*
+** Constructors */
+
+MeshBoundaryShape* MeshBoundaryShape_New( Name name ) {
+   return (void*) _MeshBoundaryShape_New(
+      sizeof(MeshBoundaryShape),
+      MeshBoundaryShape_Type,
+      _MeshBoundaryShape_Delete,
+      _Stg_Shape_Print,
+      _Stg_Shape_Copy,
+      (void*(*)(Name))MeshBoundaryShape_New,
+      _MeshBoundaryShape_Construct,
+      _Stg_Shape_Build,
+      _Stg_Shape_Initialise,
+      _Stg_Shape_Execute,
+      _Stg_Shape_Destroy,
+      _MeshBoundaryShape_IsCoordInside,
+      _MeshBoundaryShape_CalculateVolume,
+      _MeshBoundaryShape_DistanceFromCenterAxis,
+      name );
+}
+
+MeshBoundaryShape* _MeshBoundaryShape_New( MESHBOUNDARYSHAPE_ARGS ) {
+   MeshBoundaryShape* self;
+
+   /* Allocate memory */
+   assert( _sizeOfSelf >= sizeof(MeshBoundaryShape) );
+   self = (MeshBoundaryShape*)_Stg_Shape_New( STG_SHAPE_PASSARGS );
+
+   _MeshBoundaryShape_Init( self );
+
+   return self;
+}
+
+void _MeshBoundaryShape_Init( MeshBoundaryShape* self ) {
+   self->mesh = NULL;
+   self->depth = 0;
+   memset( self->walls, 0, 6 * sizeof(Bool) );
+}
+
+
+/*
+** Virtual functions */
+
+void _MeshBoundaryShape_Delete( void* _self ) {
+   MeshBoundaryShape* self = (MeshBoundaryShape*)_self;
+
+   /* Delete parent */
+   _Stg_Shape_Delete( self );
+}
+
+void _MeshBoundaryShape_Construct( void* _self, Stg_ComponentFactory* cf, void* data ) {
+   MeshBoundaryShape* self = (MeshBoundaryShape*)_self;
+   Dictionary_Entry_Value* wallList;
+   int ii;
+
+   _Stg_Shape_Construct( self, cf, data );
+
+   self->mesh = Stg_ComponentFactory_ConstructByKey( cf, self->name, "mesh", Mesh, True, data );
+   self->depth = Stg_ComponentFactory_GetInt( cf, self->name, "depth", 1 );
+
+   /* Read in the walls to have friction applied. */
+   wallList = _Stg_ComponentFactory_GetDictionaryValue( cf, self->name, "walls", NULL );
+   if( wallList ) {
+      int nWalls, curWall;
+      char* name;
+
+      /* List exists, use it. Extract the number of walls specified. */
+      nWalls = Dictionary_Entry_Value_GetCount( wallList );
+
+      /* Read in each wall's name. */
+      curWall = 0;
+      for( ii = 0; ii < nWalls; ii++ ) {
+
+         /* Rip out the name from the list. */
+         name = Dictionary_Entry_Value_AsString(
+            Dictionary_Entry_Value_GetElement( wallList, ii ) );
+
+         /* Store enabled wall. */
+         if( !strcasecmp( name, "left" ) )
+            self->walls[0] = True;
+         else if( !strcasecmp( name, "right" ) )
+            self->walls[1] = True;
+         else if( !strcasecmp( name, "bottom" ) )
+            self->walls[2] = True;
+         else if( !strcasecmp( name, "top" ) )
+            self->walls[3] = True;
+         else if( !strcasecmp( name, "back" ) )
+            self->walls[4] = True;
+         else if( !strcasecmp( name, "front" ) )
+            self->walls[5] = True;
+         else
+            abort();
+      }
+   }
+
+   /* If no wall list, assume all walls. */
+   else {
+      for( ii = 0; ii < 6; ii++ )
+         self->walls[ii] = True;
+   }
+
+}
+
+
+/*
+** Virtual functions */
+
+void _MeshBoundaryShape_Build( void* _self, void* data ) {
+   MeshBoundaryShape* self = (MeshBoundaryShape*)_self;
+
+   _Stg_Shape_Build( self, data );
+   Stg_Component_Build( self->mesh, data, False );
+}
+
+void _MeshBoundaryShape_Initialise( void* _self, void* data ) {
+   MeshBoundaryShape* self = (MeshBoundaryShape*)_self;
+
+   _Stg_Shape_Build( self, data );
+   Stg_Component_Initialise( self->mesh, data, False );
+}
+
+Bool _MeshBoundaryShape_IsCoordInside( void* _self, Coord coord ) {
+   MeshBoundaryShape* self = (MeshBoundaryShape*)_self;
+   Coord newCoord;
+   Grid* grid;
+   int inds[3], element, nDims, wallInd;
+   int ii;
+
+   assert( self->depth > 0 );
+
+   /* Transform coordinate into canonical reference frame */
+   Stg_Shape_TransformCoord( self, coord, newCoord );
+
+   /* Get the element grid from the mesh. */
+   grid = *(Grid**)Mesh_GetExtension( self->mesh, Grid**, "elementGrid" );
+   assert( grid );
+
+   /* Find which element the current coordinate is in. */
+   if( !Mesh_SearchElements( self->mesh, newCoord, &element ) ) {
+
+      /* Couldn't find the point inside the mesh. */
+      return False;
+   }
+
+   /* Convert the element into n-dimensional indices. */
+   Grid_Lift( grid, element, inds );
+
+   /* Check if we're on any of the specified boundaries. */
+   nDims = Mesh_GetDimSize( self->mesh );
+   for( ii = 0; ii < nDims; ii++ ) {
+      wallInd = 2 * ii;
+      if( (self->walls[wallInd] && inds[ii] < self->depth) ||
+          (self->walls[wallInd + 1] && inds[ii] > (grid->sizes[ii] - self->depth - 1)) )
+      {
+         return True;
+      }
+   }
+
+   return False;
+}
+
+double _MeshBoundaryShape_CalculateVolume( void* _self ) {
+   abort();
+   return 0.0;
+}
+
+void _MeshBoundaryShape_DistanceFromCenterAxis( void* _self, Coord coord, double* disVec ) {
+   abort();
+}
+
diff -r 12acb3a7bb6f -r d5ccc589b99f Utils/src/MeshBoundaryShape.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Utils/src/MeshBoundaryShape.h	Mon Aug 04 16:27:14 2008 +0000
@@ -0,0 +1,78 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+**
+** 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
+**
+**  Role:
+**
+** Assumptions:
+**
+** Invariants:
+**
+** Comments:
+**
+** $Id: MeshBoundaryShape.h 2225 1970-01-02 13:48:23Z LukeHodkinson $
+**
+**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+
+#ifndef __StgDomain_Utils_MeshBoundaryShape_h__
+#define __StgDomain_Utils_MeshBoundaryShape_h__
+
+/* Textual name of this class */
+extern const Type MeshBoundaryShape_Type;
+
+/* Class contents. */
+#define __MeshBoundaryShape                     \
+   __Stg_Shape                                  \
+   Mesh* mesh;                                  \
+   int depth;                                   \
+   Bool walls[6];
+
+struct MeshBoundaryShape { __MeshBoundaryShape };
+
+
+/*
+** Constructors */
+
+#define MESHBOUNDARYSHAPE_ARGS                  \
+   STG_SHAPE_ARGS
+
+#define MESHBOUNDARYSHAPE_PASSARGS              \
+   STG_SHAPE_PASSARGS
+
+MeshBoundaryShape* MeshBoundaryShape_New( Name name );
+MeshBoundaryShape* _MeshBoundaryShape_New( MESHBOUNDARYSHAPE_ARGS );
+void _MeshBoundaryShape_Init( MeshBoundaryShape* _self );
+
+void _MeshBoundaryShape_Delete( void* _self );
+void _MeshBoundaryShape_Construct( void* _self, Stg_ComponentFactory* cf, void* data );
+void _MeshBoundaryShape_Build( void* _self, void* data );
+void _MeshBoundaryShape_Initialise( void* _self, void* data );
+
+Bool _MeshBoundaryShape_IsCoordInside( void* _self, Coord coord ) ;
+double _MeshBoundaryShape_CalculateVolume( void* _self );
+void _MeshBoundaryShape_DistanceFromCenterAxis( void* _self, Coord coord, double* disVec );
+
+#endif
diff -r 12acb3a7bb6f -r d5ccc589b99f Utils/src/MeshBoundaryShape.meta
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Utils/src/MeshBoundaryShape.meta	Mon Aug 04 16:27:14 2008 +0000
@@ -0,0 +1,40 @@
+<?xml version="1.0"?>
+<!DOCTYPE StGermainData SYSTEM "stgermain.dtd">
+<StGermainData xmlns="http://www.vpac.org/StGermain/XML_IO_Handler/Jun2003">
+
+<param name="Name">MeshBoundaryShape</param>
+<param name="Author">...</param>
+<param name="Organisation">VPAC</param>
+<param name="Project">StgDomain</param>
+<param name="Location">./StgDomain/Discretisation/Utils/src/</param>
+<param name="Project Web">http://www.stgermainproject.org/StgDomain.html</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">VariableCondition</param>
+<param name="Reference">...</param>
+<param name="Summary">...</param>
+<param name="Description">...</param>
+
+<!--Now the interesting stuff-->
+
+
+<list name="Params">
+
+</list>
+
+<list name="Dependencies">
+	<struct>
+		<param name="Essential">True</param>
+		<param name="Name">self->shapeName</param>
+		<param name="Type">Stg_Shape</param>
+		<param name="Description">...</param>
+	</struct>
+
+<!-- PLEASE, check the above struct information is accurate, in line number 325 of the c file and then remove this comment afterwards -->
+
+
+</list>
+<!-- Add an exmaple XML if possible -->
+<param name="Example">...</param>
+
+</StGermainData>



More information about the CIG-COMMITS mailing list