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

Orography.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 "Orography.h"
00032 
00033 /* Textual name of this module */
00034 const Type SPModelOrography_Type = "SPModelOrography";
00035 
00036 ExtensionInfo_Index SPModel_Simulation_ContextExtHandle;
00037 
00038 void* _SPModelOrography_DefaultNew( Name name ) {
00039     return Codelet_New(
00040             SPModelOrography_Type,
00041             _SPModelOrography_DefaultNew,
00042             _SPModelOrography_Construct,
00043             _Codelet_Build,
00044             _Codelet_Initialise,
00045             _Codelet_Execute,
00046             _Codelet_Destroy,
00047             name );
00048 }
00049 
00050 void _SPModelOrography_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     _SPModelOrography_Init( context );
00056     
00057     Journal_DPrintf( context->debug, "In %s():\n", __func__ );
00058     ContextEP_Append( context, AbstractContext_EP_Solve, SPModelOrography_Solve );
00059 }
00060 
00061 void _SPModelOrography_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 SPModelOrography_Solve( void *_context ) {
00070     int i = 0;
00071     SPModel_Context *context = NULL;
00072     SPModelSimulationContextExtension *simulationExt = NULL;
00073     SurfaceMesh *mesh;
00074 
00075     context = (SPModel_Context*)_context;
00076     assert( context );
00077     
00078     simulationExt = (SPModelSimulationContextExtension*)ExtensionManager_Get
00079                 ( context->extensionMgr, context, SPModel_Simulation_ContextExtHandle );
00080     assert( simulationExt );
00081     
00082     mesh = context->localMesh;
00083     
00084     if ( context->oroLength <= 0 ) {
00085         for (i=0; i<mesh->myLoad; i++) {
00086             if( mesh->h[i] > context->seaLevel->value ){
00087                 simulationExt->water[i] = context->oroRate * context->dt * context->fluvialConstant * mesh->surface[i];
00088             }
00089             else{
00090                 simulationExt->water[i] = context->seaLevel->value - mesh->h[i];
00091             }
00092         }
00093     }
00094 }
00095 
00096 Index SPModelOrography_Register( PluginsManager* pluginsManager )
00097 {
00098     return PluginsManager_Submit( pluginsManager, SPModelOrography_Type, "0", _SPModelOrography_DefaultNew );
00099 }
00100