SPModel: plugins/fluvialErosion/FluvialErosion.c Source File
VPAC - Computational Software Development
Main | SPModel | StGermain FrameWork |
Main Page | Alphabetical List | Class List | Directories | File List | Class Members | File Members

FluvialErosion.c

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 ** $Id: Erosion.c 225 2005-12-22 00:01:19Z AlanLo $
00021 **
00022 **~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
00023 
00024 
00025 #include <mpi.h>
00026 #include <StGermain/StGermain.h>
00027 #include "SPModel/SPModel.h"
00028 #include <stdlib.h>
00029 #include <string.h>
00030 #include <assert.h>
00031 #include "FluvialErosion.h"
00032 
00033 /* Textual name of this module */
00034 const Type SPModelFluvialErosion_Type = "SPModelFluvialErosion";
00035 
00036 ExtensionInfo_Index SPModel_Simulation_ContextExtHandle;
00037 
00038 void* _SPModelFluvialErosion_DefaultNew( Name name ) {
00039     return Codelet_New(
00040             SPModelFluvialErosion_Type,
00041             _SPModelFluvialErosion_DefaultNew,
00042             _SPModelFluvialErosion_Construct,
00043             _Codelet_Build,
00044             _Codelet_Initialise,
00045             _Codelet_Execute,
00046             _Codelet_Destroy,
00047             name );
00048 }
00049 
00050 void _SPModelFluvialErosion_Construct( void* component, Stg_ComponentFactory* data ) {  
00051     SPModel_Context*                context;
00052     
00053     context = (SPModel_Context*)Stg_ComponentFactory_ConstructByName( data, "context", SPModel_Context, True );
00054     
00055     _SPModelFluvialErosion_Init( context );
00056     
00057     Journal_DPrintf( context->debug, "In %s():\n", __func__ );
00058     ContextEP_Append( context, AbstractContext_EP_Solve, SPModelFluvialErosion_Solve );
00059 }
00060 
00061 void _SPModelFluvialErosion_Init( void* _context ) {
00062     SPModel_Context *context = (SPModel_Context*)_context;
00063     
00064     assert( context );
00065     
00066     SPModel_Simulation_ContextExtHandle = ExtensionManager_GetHandle( context->extensionMgr, "Simulation" );
00067 }
00068 
00069 void SPModelFluvialErosion_BoundaryConditions( void *_context )
00070 {
00071     int i = 0;
00072     SPModel_Context *context = NULL;
00073     SPModelSimulationContextExtension *simulationExt = NULL;
00074     SurfaceMesh *mesh;
00075 
00076     context = (SPModel_Context*)_context;
00077     assert( context );
00078     
00079     simulationExt = (SPModelSimulationContextExtension*)ExtensionManager_Get
00080                 ( context->extensionMgr, context, SPModel_Simulation_ContextExtHandle );
00081     assert( simulationExt );
00082     
00083     mesh = context->localMesh;
00084     
00085     for( i=0; i<mesh->myLoad; i++ ){
00086         if( (mesh->boundaryConditions[mesh->id[i]-1]) == 0 ){
00087             mesh->h[i] -= simulationExt->sedimentHistory[i];
00088             simulationExt->sedimentHistory[i] = 0.0f;
00089             simulationExt->sediment[i] = 0.0f;
00090         }
00091     }   
00092 }
00093 
00094 float transportEquation( int localIndex, SurfaceMesh *mesh, SPModelSimulationContextExtension *simulationExt )
00095 {
00096     float slope = 0.0f; 
00097 
00098     assert( simulationExt );
00099     assert( mesh );
00100     
00101     slope = -mesh->slope[localIndex];
00102     
00103     return simulationExt->water[localIndex] * mesh->surface[localIndex] * slope;
00104 }
00105 
00106 void SPModelFluvialErosion_Solve( void *_context )
00107 {
00108     SPModel_Context *context = NULL;
00109     SPModelSimulationContextExtension *simulationExt = NULL;
00110  
00111     context = (SPModel_Context*)_context;
00112     assert( context );
00113     
00114     simulationExt = (SPModelSimulationContextExtension*)ExtensionManager_Get
00115                 ( context->extensionMgr, context, SPModel_Simulation_ContextExtHandle );
00116     assert( simulationExt );
00117 
00118     SPModelFluvialErosion_BoundaryConditions( _context );
00119 
00120     fluvial( context, simulationExt, transportEquation );
00121 }
00122 
00123 Index SPModelFluvialErosion_Register( PluginsManager* pluginsManager )
00124 {
00125     return PluginsManager_Submit( pluginsManager, SPModelFluvialErosion_Type, "0", _SPModelFluvialErosion_DefaultNew );
00126 }
00127