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

MeshLayoutViewer.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: FlowHierarchyViewer.c 72 2004-11-12 01:11:14Z PatrickSunter $
00021 **
00022 **~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
00023 
00024 #include <mpi.h>
00025 #include <StGermain/StGermain.h>
00026 #include "SPModel/SPModel.h"
00027 
00028 #include <math.h>
00029 #include <sys/time.h>
00030 #include <stdio.h>
00031 #include <stdlib.h>
00032 #include <limits.h>
00033 #include <string.h>
00034 
00035 #if defined(__APPLE__) && defined(__MACH__)
00036 #include <OpenGL/gl.h>  // Header File For The OpenGL32 Library
00037 #include <OpenGL/glu.h> // Header File For The GLu32 Library
00038 #else
00039 #include <GL/gl.h>  // Header File For The OpenGL32 Library
00040 #include <GL/glu.h> // Header File For The GLu32 Library
00041 #endif
00042 
00043 
00044 #include <SDL/SDL.h>    
00045 
00046 
00047 int main (int argc, char **argv)
00048 {
00049     MPI_Comm            CommWorld;
00050     int             rank;
00051     int             numProcessors;
00052     int             procToWatch;
00053     Dictionary*         dictionary;
00054     Dictionary*         componentDict;
00055     XML_IO_Handler*         ioHandler;
00056     char*               filename;
00057     SPModel_Context*        spmodelContext;
00058     
00059     /* Initialise MPI, get world info */
00060     MPI_Init( &argc, &argv );
00061     MPI_Comm_dup( MPI_COMM_WORLD, &CommWorld );
00062     MPI_Comm_size( CommWorld, &numProcessors );
00063     MPI_Comm_rank( CommWorld, &rank );
00064     if( argc >= 3 ) {
00065         procToWatch = atoi( argv[2] );
00066     }
00067     else {
00068         procToWatch = 0;
00069     }
00070     if( rank == procToWatch ) printf( "Watching rank: %i\n", rank );
00071     
00072     
00073     if (!StGermain_Init( &argc, &argv )) {
00074         fprintf(stderr, "Error initialising StGermain, exiting.\n" );
00075         exit(EXIT_FAILURE);
00076     }
00077     if (!SPModel_Init( &argc, &argv )) {
00078         fprintf(stderr, "Error initialising SPModel, exiting.\n" );
00079         exit(EXIT_FAILURE);
00080     }
00081     
00082     /* Create the dictionary, and some fixed values */
00083     dictionary = Dictionary_New();
00084     Dictionary_Add( dictionary, "rank", Dictionary_Entry_Value_FromUnsignedInt( rank ) );
00085     Dictionary_Add( dictionary, "numProcessors", Dictionary_Entry_Value_FromUnsignedInt( numProcessors ) );
00086     
00087     /* Read input */
00088     ioHandler = XML_IO_Handler_New();
00089     if( argc >= 2 ) {
00090         filename = strdup( argv[1] );
00091     }
00092     else {
00093         filename = strdup( "input.xml" );
00094     }
00095     if ( False == IO_Handler_ReadAllFromFile( ioHandler, filename, dictionary ) )
00096     {
00097         fprintf( stderr, "Error: SPModel couldn't find specified input file %s. Exiting.\n", filename );
00098         exit( EXIT_FAILURE );
00099     }
00100     Journal_ReadFromDictionary( dictionary );
00101     
00102     componentDict = Dictionary_GetDictionary( dictionary, "components" );
00103 
00104     if ( componentDict == NULL ) {
00105         componentDict = Dictionary_New();
00106     }
00107     
00108     spmodelContext = SPModel_Context_New( "context", 0.0f, 0.0f, CommWorld, dictionary );
00109     
00110     spmodelContext->CF = Stg_ComponentFactory_New( dictionary, componentDict, spmodelContext->register_Register );
00111     LiveComponentRegister_Add( spmodelContext->CF->LCRegister, (Stg_Component*) spmodelContext );
00112     
00113     Context_Build( spmodelContext );
00114     
00115     Context_Initialise( spmodelContext );
00116     
00117     PluginsManager_Load( spmodelContext->plugins, spmodelContext, dictionary );
00118     
00119     PluginsManager_ConstructPlugins( spmodelContext->plugins, spmodelContext->CF ); 
00120 
00121     /* isostacy */
00122     /*{
00123         FILE *isostacyFile = NULL;
00124         char fileName[512] = { 0 };
00125         int i;
00126         char *t = NULL, *a = NULL;
00127 
00128         t = strstr( spmodelContext->globalMesh->surfaceMeshLoader->inputFile, "topography" );
00129 
00130         if( !t ){
00131             fprintf( stderr, "Error in file name..!\n" );
00132             exit( EXIT_FAILURE );
00133         }
00134         
00135         for( a=spmodelContext->globalMesh->surfaceMeshLoader->inputFile, i = 0; a < t; a++, i++ ){
00136             fileName[i] = *a;
00137         }
00138         
00139         sprintf( &(fileName[i]), "isostacy%s", &(t[10]) );
00140 
00141         isostacyFile = fopen( fileName, "r+" );
00142         
00143         if( !isostacyFile ){
00144             fprintf( stderr, "Could not open file - %s ..!\n", fileName );
00145             exit( EXIT_FAILURE );
00146         }
00147 
00148         for( i=0; i<3; i++ ){
00149             fgets( fileName, sizeof(fileName), isostacyFile );
00150         }
00151 
00152         for( i=0; i<spmodelContext->globalMesh->numNodes; i++ ){
00153             fscanf( isostacyFile, "%f", &(spmodelContext->localMesh->hisotot[i]) );
00154         }
00155     }*/
00156     
00157     Context_Run( spmodelContext );
00158     
00159     StGermain_Finalise();
00160     MPI_Finalize();
00161     
00162     return 0; /* success */
00163 }
00164