SPModel: libSPModel/src/SurfaceMesh.h Source File
VPAC - Computational Software Development
Main | SPModel | StGermain FrameWork |
Main Page | Alphabetical List | Class List | Directories | File List | Class Members | File Members

SurfaceMesh.h

Go to the documentation of this file.
00001 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00002 **
00003 ** Copyright (C), 2004, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street, Melbourne, 3053, Australia.
00004 **
00005 ** Authors:
00006 **  Ogar R. Widjaja, Computational Scientist, VPAC.
00007 **  Raquibul Hassan, Software Engineer, VPAC. (raq@vpac.org)
00008 **  Keith Hsuan, Computational Scientist, VPAC (keith@vpac.org)
00009 **  William F. Appelbe, Director, VPAC. (bill@vpac.org)
00010 **  Stevan M. Quenette, Senior Software Engineer, VPAC. (steve@vpac.org)
00011 **  Patrick D. Sunter, Software Engineer, VPAC. (patrick@vpac.org)
00012 **
00013 ** This file may be distributed under the terms of the VPAC Public License
00014 ** as defined by VPAC of Australia and appearing in the file
00015 ** LICENSE.VPL included in the packaging of this file.
00016 **
00017 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00018 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00019 **
00020 */
00056 #ifndef __SPModel_SurfaceMesh_h__
00057 #define __SPModel_SurfaceMesh_h__
00058 
00059     /* Textual name of this class */
00060     extern const Type SurfaceMesh_Type;
00061 
00062     /* Strings to determine how mesh data is read/created */
00063     extern const char* MESH_TYPE_AUTOGENERATED;
00064     extern const char* MESH_TYPE_FROM_TEXT_INPUT;
00065     extern const char* MESH_TYPE_FROM_ENVI_INPUT;
00066     
00068     #define __SurfaceMeshHaloNodes \
00069         int                     numHaloNodes; \
00070         int                     *haloId; \
00071         float                   *x; \
00072         float                   *y; \
00073         float                   *h; \
00074         int                     *receiver; \
00075         float                   *surface;
00076     struct SurfaceMeshHaloNodes { __SurfaceMeshHaloNodes };
00077     
00078     #define __SurfaceMeshForeignHaloNodes \
00079         int                     numForeignHaloNodes; \
00080         int                     *foreignHaloId;
00081     struct SurfaceMeshForeignHaloNodes { __SurfaceMeshForeignHaloNodes };
00082         
00083     
00085     #define __SurfaceMesh \
00086         struct          { __Stg_Component }; \
00087         \
00088         Dictionary              *dictionary; \
00089         Stream                  *debug; \
00090         SurfaceMeshLoader       *surfaceMeshLoader; \
00091         /* The fixed boundary nodes. TODO: change these to StG style BCs */ \
00092         float                   *boundaryConditions; \
00093             /* global nodes and elements */ \
00094         int                     elementGlobalCount; \
00095         int                     arrayElements; \
00096             /* mesh specific information */ \
00097         float                   delta; \
00098         float                   surfScale; \
00099         int                     iAdapt; \
00100         float                   sideX, sideY;  \
00101         int                     *numNeigh; /* this is the number of neighbours for each node, currently hacked */ \
00102         int                     **nodeNeighbours; \
00103         int                     numNodes;  \
00104         int                     maxNeighboursPerNode;  \
00105             /* mesh decomposition related information */ \
00106         int                     *id; \
00107         int                     *sortedId; \
00108         int                     numProcs; \
00109         int                     rank; \
00110         MPI_Request             *requestTable; \
00111         MPI_Status              *statusTable; \
00112             /* local mesh information */ \
00113         int                     myLoad; \
00114         int                     *processor; \
00115         LinkedList              **nodeProviders; \
00116         int                     *numProviders; \
00117         int                     *mapGlobalToLocal; \
00118         \
00119         float                   **sides; /*sides of nodes sides[NNODEMAX][NBMAX]*/ \
00120         int                     **vertices; /*triangle vertices[NNODEMAX*3][3];*/ \
00121         float                   *surface; /*voronoi surface area surface[NNODEMAX];*/ \
00122         float                   *x; /*contains all the x coords of the mesh x[NNODEMAX]*/ \
00123         float                   *y; /*contains all the y coords of the mesh y[NNODEMAX]*/ \
00124         float                   *h; /*contains all the h coords of the mesh h[NNODEMAX]*/ \
00125         int                     *receiver; /*contains the receiver of each node*/ \
00126         int                     *highestNeighbour; /* contains the highest neighbour of each node */ \
00127         int                     *size; /*contains the size of catchment upstream, at nodes size[NNODEMAX]*/ \
00128         int                     *nCatch; /*contains the catchment-number of the catchment this node belongs to*/ \
00129         int                     *nLake; /*indicates whether the node is a lake/ridge.. nLake[NNODEMAX]*/ \
00130         int                     *nodeType; /*indicates whether the node is a lake or ..*/ \
00131         float                   *slope; /*contains the slope of a node with its receiver slope[NNODEMAX]*/ \
00132         float                   *length; /*contains the length associated with nodal points length[NNODEMAX]*/ \
00133         float                   *hi; /*contains the bedrock-alluvion interface of the topography hi[NNODEMAX]*/ \
00134         float                   *h0; /*contains all the initial topography of the mesh h0[NNODEMAX]*/ \
00135         SurfaceMeshHaloNodes    *haloNodes; \
00136         SurfaceMeshForeignHaloNodes *foreignHaloNodes; \
00137         LinkedList              **foreignProviderChanges; \
00138         LinkedList              **localProviderChanges;
00139 
00141     struct SurfaceMesh { __SurfaceMesh };
00142 
00143     typedef struct providerSyncStruct_t{
00144         int nodeId;
00145         int provider;
00146     }providerSyncStruct;
00147 
00148     /* --- Constructors / Destructor --- */
00149     
00151     SurfaceMesh* SurfaceMesh_DefaultNew( Name name );
00152     
00153     SurfaceMesh* SurfaceMesh_New(
00154         Name                    name,
00155         int                     numProcs,
00156         int                     rank,
00157         void*                   extension_Register,
00158         Dictionary*             dictionary );
00159     
00161     SurfaceMesh* _SurfaceMesh_New(
00162         SizeT                   _sizeOfSelf,
00163         Type                    type,
00164         Stg_Class_DeleteFunction*               _delete,
00165         Stg_Class_PrintFunction*                _print,
00166         Stg_Class_CopyFunction*             _copy, 
00167         Stg_Component_DefaultConstructorFunction*   _defaultConstructor,
00168         Stg_Component_ConstructFunction*            _construct,
00169         Stg_Component_BuildFunction*        _build,
00170         Stg_Component_InitialiseFunction*       _initialise,
00171         Stg_Component_ExecuteFunction*      _execute,
00172         Stg_Component_DestroyFunction*      _destroy,
00173         Name                    name,
00174         Bool                            initFlag,
00175         int                     numProcs,
00176         int                     rank,
00177         void*                   extension_Register,
00178         Dictionary*             dictionary );
00179 
00181     // TODO: change interface to handle the extension register and other mesh parameters etc...
00182     void _SurfaceMesh_Init( SurfaceMesh* self );
00183     
00185     void _SurfaceMesh_Delete( void* surfaceMesh );
00186 
00187     /* --- Virtual Function implementations --- */
00188     
00190     void _SurfaceMesh_Print( void* surfaceMesh, Stream* stream );
00191     
00193     void _SurfaceMesh_Construct( void* surfaceMesh, Stg_ComponentFactory* cf );
00194     
00195     void _SurfaceMesh_Build( void* surfaceMesh, void* data );
00196     
00198     void _SurfaceMesh_Initialise( void* surfaceMesh, void* data );
00199     
00201     void _SurfaceMesh_Execute( void* surfaceMesh, void* data );
00202     
00203     void _SurfaceMesh_Destroy( void* surfaceMesh, void* data );
00204 
00205     /* --- Public functions --- */
00206     void SurfaceMesh_FindHaloNode( SurfaceMesh *mesh, int nodeId, int *processor, int *index );
00207 
00208     /* --- Private Functions --- */
00209 
00210     void _SurfaceMesh_FindNeighbours( SurfaceMesh* mesh );
00211 
00212     void SurfaceMesh_AllocateMemoryForHaloNodes( SurfaceMesh *mesh );
00213 
00214     /* Cleanup */
00215     void SurfaceMesh_ReleaseMemory( SurfaceMesh* mesh );
00216 
00218     void _SurfaceMesh_DetermineFlows( SurfaceMesh* mesh, float* boundaryConditions );
00219 
00220     void _SurfaceMesh_FindDonors( SurfaceMesh* mesh );
00221 
00222     /* Function used to calculate the number of nodes above a node */
00223     int getSize( SurfaceMesh *mesh, int nodeId );
00224 
00225     void _SurfaceMesh_DetermineCatchmentSizes( SurfaceMesh* mesh );
00226     
00227     void SurfaceMesh_BuildRiverNetwork( SurfaceMesh *self );
00228 
00229     void SurfaceMesh_UpdateFlows( SurfaceMesh *mesh );
00230     
00231     void SurfaceMesh_OrderNodes( SurfaceMesh *mesh );
00232 
00233     void SurfaceMesh_BoundaryConditions( SurfaceMesh *surfaceMesh );
00234 
00235 #endif /* __SPModel_SurfaceMesh_h__ */