/* * Initialises the Linear Algebra package, then any init for this package * such as streams etc. */ Bool StgFEM_Assembly_Init( int* argc, char** argv[] ) { Stg_ComponentRegister* componentRegister = Stg_ComponentRegister_Get_ComponentRegister(); int tmp; /* DO NOT CHANGE OR REMOVE */ Journal_Printf( Journal_Register( DebugStream_Type, (Name)"Context" ), "In: %s\n", __func__ ); tmp = Stream_GetPrintingRank( Journal_Register( InfoStream_Type, (Name)"Context" ) ); Stream_SetPrintingRank( Journal_Register( InfoStream_Type, (Name)"Context" ), 0 ); Stream_Flush( Journal_Register( InfoStream_Type, (Name)"Context" ) ); Stream_SetPrintingRank( Journal_Register( InfoStream_Type, (Name)"Context" ), tmp ); /* initialise this level's streams */ StgFEM_Assembly_Debug = Stream_RegisterChild( StgFEM_Debug, "Assembly" ); Stg_ComponentRegister_Add( componentRegister, ThermalBuoyancyForceTerm_Type, (Name)"0", _ThermalBuoyancyForceTerm_DefaultNew ); Stg_ComponentRegister_Add( componentRegister, GradientStiffnessMatrixTerm_Type, (Name)"0", _GradientStiffnessMatrixTerm_DefaultNew ); Stg_ComponentRegister_Add( componentRegister, DivergenceMatrixTerm_Type, (Name)"0", _DivergenceMatrixTerm_DefaultNew ); Stg_ComponentRegister_Add( componentRegister, LaplacianStiffnessMatrixTerm_Type, (Name)"0", _LaplacianStiffnessMatrixTerm_DefaultNew ); Stg_ComponentRegister_Add( componentRegister, IsoviscousStressTensorTerm_Type, (Name)"0", _IsoviscousStressTensorTerm_DefaultNew ); Stg_ComponentRegister_Add( componentRegister, MassMatrixTerm_Type, (Name)"0", _MassMatrixTerm_DefaultNew ); RegisterParent( ThermalBuoyancyForceTerm_Type, ForceTerm_Type ); RegisterParent( GradientStiffnessMatrixTerm_Type, StiffnessMatrixTerm_Type ); RegisterParent( DivergenceMatrixTerm_Type, StiffnessMatrixTerm_Type ); RegisterParent( LaplacianStiffnessMatrixTerm_Type, StiffnessMatrixTerm_Type ); RegisterParent( IsoviscousStressTensorTerm_Type, StiffnessMatrixTerm_Type ); RegisterParent( MassMatrixTerm_Type, StiffnessMatrixTerm_Type ); return True; }
Bool lecode_tools_Init( int* argc, char** argv[] ) { /* This init function tells StGermain of all the component types, etc this module contributes. Because it can be linked at compile time or linked in by a toolbox at runtime, we need to make sure it isn't run twice (compiled in and loaded through a toolbox.*/ if( !ToolboxesManager_IsInitialised( stgToolboxesManager, "lecode_tools" ) ) { int tmp; char* directory; lecode_tools_Base_Init(argc, argv); Journal_Printf( Journal_Register( DebugStream_Type, (Name)"Context" ), "In: %s\n", __func__ ); /* DO NOT CHANGE OR REMOVE */ tmp = Stream_GetPrintingRank( Journal_Register( InfoStream_Type, (Name)"Context" ) ); Stream_SetPrintingRank( Journal_Register( InfoStream_Type, (Name)"Context" ), 0 ); Journal_Printf( /* DO NOT CHANGE OR REMOVE */ Journal_Register( InfoStream_Type, (Name)"Context" ), "lecode_tools. Copyright (C) 2012 Monash University.\n" ); Stream_Flush( Journal_Register( InfoStream_Type, (Name)"Context" ) ); Stream_SetPrintingRank( Journal_Register( InfoStream_Type, (Name)"Context" ), tmp ); /* Add the lecode_tools path to the global xml path dictionary */ directory = Memory_Alloc_Array( char, 200, "xmlDirectory" ) ; sprintf(directory, "%s%s", LIB_DIR, "/StGermain" ); XML_IO_Handler_AddDirectory( "lecode_tools", directory ); Memory_Free(directory); /* Add the plugin path to the global plugin list */ ModulesManager_AddDirectory( "lecode_tools", LIB_DIR ); return True; }
Bool StGermainBase_Init( int* argc, char** argv[] ) { char* directory; int tmp; /* Initialise enough bits and pieces to get IO going */ BaseFoundation_Init( argc, argv ); BaseIO_Init( argc, argv ); /* Write out the copyright message */ Journal_Printf( Journal_Register( DebugStream_Type, "Context" ), "In: %s\n", __func__ ); tmp = Stream_GetPrintingRank( Journal_Register( InfoStream_Type, "Context" ) ); Stream_SetPrintingRank( Journal_Register( InfoStream_Type, "Context" ), 0 ); Stream_Flush( Journal_Register( InfoStream_Type, "Context" ) ); Stream_SetPrintingRank( Journal_Register( InfoStream_Type, "Context" ), tmp ); /* Initialise the remaining bits and pieces */ BaseContainer_Init( argc, argv ); BaseAutomation_Init( argc, argv ); BaseExtensibility_Init( argc, argv ); BaseContext_Init( argc, argv ); /* Add the StGermain path to the global xml path dictionary */ directory = Memory_Alloc_Array( char, 200, "xmlDirectory" ) ; sprintf( directory, "%s%s", LIB_DIR, "/StGermain" ); XML_IO_Handler_AddDirectory( "StGermain", directory ); Memory_Free( directory ); /* Add the plugin path to the global plugin list */ ModulesManager_AddDirectory( "StGermain", LIB_DIR ); return True; }
/* * Initialises the Linear Algebra package, then any init for this package * such as streams etc. */ Bool StgFEM_SLE_Init( int* argc, char** argv[] ) { int tmp; /* DO NOT CHANGE OR REMOVE */ Journal_Printf( Journal_Register( DebugStream_Type, (Name)"Context" ), "In: %s\n", __func__ ); tmp = Stream_GetPrintingRank( Journal_Register( InfoStream_Type, (Name)"Context" ) ); Stream_SetPrintingRank( Journal_Register( InfoStream_Type, (Name)"Context" ), 0 ); Stream_Flush( Journal_Register( InfoStream_Type, (Name)"Context" ) ); Stream_SetPrintingRank( Journal_Register( InfoStream_Type, (Name)"Context" ), tmp ); //StgFEM_SLE_LinearAlgebra_Init( argc, argv ); StgFEM_SLE_SystemSetup_Init( argc, argv ); StgFEM_SLE_ProvidedSystems_Init( argc, argv ); return True; }
Bool Discretisation_Init( int* argc, char** argv[] ) { int tmp; Journal_Printf( Journal_Register( DebugStream_Type, "Context" ), "In: %s\n", __func__ ); /* DO NOT CHANGE OR REMOVE */ tmp = Stream_GetPrintingRank( Journal_Register( InfoStream_Type, "Context" ) ); Stream_SetPrintingRank( Journal_Register( InfoStream_Type, "Context" ), 0 ); Journal_Printf( /* DO NOT CHANGE OR REMOVE */ Journal_Register( InfoStream_Type, "Context" ), "StGermain Discretisation Library revision %s. Copyright (C) 2003-2005 VPAC.\n", VERSION ); Stream_Flush( Journal_Register( InfoStream_Type, "Context" ) ); Stream_SetPrintingRank( Journal_Register( InfoStream_Type, "Context" ), tmp ); DiscretisationGeometry_Init( argc, argv ); DiscretisationShape_Init( argc, argv ); DiscretisationMesh_Init( argc, argv ); DiscretisationUtils_Init( argc, argv ); DiscretisationSwarm_Init( argc, argv ); return True; }
Bool Geothermal_Init( int* argc, char** argv[] ) { /* * This init function tells StGermain of all the component types, etc this module contributes. * Because it can be linked at compile time or linked in by a toolbox at runtime, we need to make * sure it isn't run twice (compiled in and loaded through a toolbox. */ if( !ToolboxesManager_IsInitialised( stgToolboxesManager, "Geothermal" ) ) { int tmp; char* directory; Geothermal_Base_Init(argc, argv); /* DO NOT CHANGE OR REMOVE */ Journal_Printf( Journal_Register( DebugStream_Type, (Name)"Context" ), "In: %s\n", __func__ ); tmp = Stream_GetPrintingRank( Journal_Register( InfoStream_Type, (Name)"Context" ) ); Stream_SetPrintingRank( Journal_Register( InfoStream_Type, (Name)"Context" ), 0 ); /* DO NOT CHANGE OR REMOVE */ Journal_Printf( Journal_Register( InfoStream_Type, (Name)"Context" ), "Geothermal (Bleeding Edge Geodynamics framework) Revision %s. Copyright (C) 2005 Monash University.\n", VERSION ); /* Add repo indentity info in the repo dictionary. */ Dictionary_Add( versionDict, "Geothermal", Dictionary_Entry_Value_FromString( VERSION ) ); Dictionary_Add( branchDict, "Geothermal", Dictionary_Entry_Value_FromString( BRANCH ) ); Dictionary_Add( pathDict, "Geothermal", Dictionary_Entry_Value_FromString( PATH ) ); Stream_Flush( Journal_Register( InfoStream_Type, (Name)"Context" ) ); Stream_SetPrintingRank( Journal_Register( InfoStream_Type, (Name)"Context" ), tmp ); /* Add the Geothermal path to the global xml path dictionary */ directory = Memory_Alloc_Array( char, 200, "xmlDirectory" ) ; sprintf(directory, "%s%s", LIB_DIR, "/StGermain" ); XML_IO_Handler_AddDirectory( "Geothermal", directory ); Memory_Free(directory); /* Add the plugin path to the global plugin list */ ModulesManager_AddDirectory( "Geothermal", LIB_DIR ); return True; }
void HierarchyTable_PrintChildren( void* hierarchyTable, Type parentType, Stream* stream ) { HierarchyTable* self = (HierarchyTable*) hierarchyTable; HashTable_Entry* hashTableEntry; Index entry_I; Stg_ComponentRegister* componentRegister = Stg_ComponentRegister_Get_ComponentRegister(); Journal_Printf( stream, "%s \t\t\t (%s Class)\n", parentType, ( Stg_ComponentRegister_Get( componentRegister, parentType, "0" ) ? "Concrete" : "Abstract" ) ); Stream_Flush( stream ); Stream_Indent( stream ); for ( entry_I = 0 ; entry_I < self->max ; entry_I++ ) { hashTableEntry = self->entries[ entry_I ]; while( hashTableEntry ){ if ( (Type) hashTableEntry->data == parentType ) { HierarchyTable_PrintChildren( self, (Type)hashTableEntry->key, stream ); } hashTableEntry = hashTableEntry->next; } } Stream_UnIndent( stream ); }
/* Main */ int main( int argc, char* argv[] ) { MPI_Comm CommWorld; int rank; int numProcessors; int procToWatch; Dictionary* dictionary; Dictionary* componentDict; XML_IO_Handler* ioHandler; char* filename; Snac_Context* snacContext; int tmp; /* Initialise MPI, get world info */ MPI_Init( &argc, &argv ); MPI_Comm_dup( MPI_COMM_WORLD, &CommWorld ); MPI_Comm_size( CommWorld, &numProcessors ); MPI_Comm_rank( CommWorld, &rank ); if( argc >= 3 ) { procToWatch = atoi( argv[2] ); } else { procToWatch = 0; } if( rank == procToWatch ) printf( "Watching rank: %i\n", rank ); if (!Snac_Init( &argc, &argv )) { fprintf(stderr, "Error initialising StGermain, exiting.\n" ); exit(EXIT_FAILURE); } /* Snac's init message */ tmp = Stream_GetPrintingRank( Journal_Register( InfoStream_Type, "Context" ) ); Stream_SetPrintingRank( Journal_Register( InfoStream_Type, "Context" ), 0 ); Journal_Printf( /* DO NOT CHANGE OR REMOVE */ Journal_Register( InfoStream_Type, "Context" ), "Snac. Copyright (C) 2003-2005 Caltech, VPAC & University of Texas.\n" ); Stream_Flush( Journal_Register( InfoStream_Type, "Context" ) ); Stream_SetPrintingRank( Journal_Register( InfoStream_Type, "Context" ), tmp ); MPI_Barrier( CommWorld ); /* Ensures copyright info always come first in output */ /* Create the dictionary, and some fixed values */ dictionary = Dictionary_New(); Dictionary_Add( dictionary, "rank", Dictionary_Entry_Value_FromUnsignedInt( rank ) ); Dictionary_Add( dictionary, "numProcessors", Dictionary_Entry_Value_FromUnsignedInt( numProcessors ) ); /* Read input */ ioHandler = XML_IO_Handler_New(); if( argc >= 2 ) { filename = strdup( argv[1] ); } else { filename = strdup( "input.xml" ); } if ( False == IO_Handler_ReadAllFromFile( ioHandler, filename, dictionary ) ) { fprintf( stderr, "Error: Snac couldn't find specified input file %s. Exiting.\n", filename ); exit( EXIT_FAILURE ); } Journal_ReadFromDictionary( dictionary ); snacContext = Snac_Context_New( 0.0f, 0.0f, sizeof(Snac_Node), sizeof(Snac_Element), CommWorld, dictionary ); if( rank == procToWatch ) Dictionary_PrintConcise( dictionary, snacContext->verbose ); /* Construction phase -----------------------------------------------------------------------------------------------*/ Stg_Component_Construct( snacContext, 0 /* dummy */, &snacContext, True ); /* Building phase ---------------------------------------------------------------------------------------------------*/ Stg_Component_Build( snacContext, 0 /* dummy */, False ); /* Initialisaton phase ----------------------------------------------------------------------------------------------*/ Stg_Component_Initialise( snacContext, 0 /* dummy */, False ); if( rank == procToWatch ) Context_PrintConcise( snacContext, snacContext->verbose ); /* Step the context solver */ Stg_Component_Execute( snacContext, 0 /* dummy */, False ); /* Stg_Class_Delete stuff */ Stg_Component_Destroy( snacContext, 0 /* dummy */, False ); Stg_Class_Delete( snacContext ); free( filename ); Stg_Class_Delete( ioHandler ); Stg_Class_Delete( dictionary ); /* Close off frameworks */ Snac_Finalise(); MPI_Finalize(); return 0; /* success */ }
int BMI_Initialize (const char *config_file, BMI_Model ** handle) { BMI_Model *self; MPI_Comm CommWorld; int rank; int numProcessors; int procToWatch; char* filename; if (!handle) return BMI_FAILURE; self = malloc( sizeof(BMI_Model) ); /* Initialise MPI, get world info */ MPI_Init( NULL, NULL ); /* MPI_Init( &argc, &argv ); */ MPI_Comm_dup( MPI_COMM_WORLD, &CommWorld ); MPI_Comm_size( CommWorld, &numProcessors ); MPI_Comm_rank( CommWorld, &rank ); /* Hardwire the process to watch to 0. Note that it doesn't have to be 0 when multiple processrs are used. */ procToWatch = 0; #if 0 if( argc >= 3 ) { procToWatch = atoi( argv[2] ); } else { procToWatch = 0; } #endif if( rank == procToWatch ) printf( "Watching rank: %i\n", rank ); /* if (!Snac_Init( &argc, &argv )) { */ if (!Snac_Init( NULL, NULL )) { fprintf(stderr, "Error initialising StGermain, exiting.\n" ); exit(EXIT_FAILURE); } /* Snac's init message */ { int tmp = Stream_GetPrintingRank( Journal_Register( InfoStream_Type, "Context" ) ); Stream_SetPrintingRank( Journal_Register( InfoStream_Type, "Context" ), 0 ); Journal_Printf( /* DO NOT CHANGE OR REMOVE */ Journal_Register( InfoStream_Type, "Context" ), "Snac. Copyright (C) 2003-2005 Caltech, VPAC & University of Texas.\n" ); Stream_Flush( Journal_Register( InfoStream_Type, "Context" ) ); Stream_SetPrintingRank( Journal_Register( InfoStream_Type, "Context" ), tmp ); } /* Ensures copyright info always come first in output */ MPI_Barrier( CommWorld ); /* Create the dictionary, and some fixed values */ /* Hardwirred to the one-processor scenario for now. */ self->dictionary = Dictionary_New(); Dictionary_Add( self->dictionary, "rank", Dictionary_Entry_Value_FromUnsignedInt( 0 ) ); Dictionary_Add( self->dictionary, "numProcessors", Dictionary_Entry_Value_FromUnsignedInt( 1 ) ); /* Read input */ self->ioHandler = XML_IO_Handler_New(); filename = strdup( config_file ); if ( False == IO_Handler_ReadAllFromFile( self->ioHandler, filename, self->dictionary ) ) { fprintf( stderr, "Error: Snac couldn't find specified input file %s. Exiting.\n", filename ); exit( EXIT_FAILURE ); } Journal_ReadFromDictionary( self->dictionary ); free( filename ); /* This is the handle to the SNAC's model data. */ self->snacContext = Snac_Context_New( 0.0f, 0.0f, sizeof(Snac_Node), sizeof(Snac_Element), CommWorld, self->dictionary ); if( rank == procToWatch ) Dictionary_PrintConcise( self->dictionary, self->snacContext->verbose ); /* Construction phase -----------------------------------------------------------------------------------------------*/ Stg_Component_Construct( self->snacContext, 0 /* dummy */, &(self->snacContext), True ); /* Building phase ---------------------------------------------------------------------------------------------------*/ Stg_Component_Build( self->snacContext, 0 /* dummy */, False ); /* Initialisaton phase ----------------------------------------------------------------------------------------------*/ Stg_Component_Initialise( self->snacContext, 0 /* dummy */, False ); if( rank == procToWatch ) Context_PrintConcise( self->snacContext, self->snacContext->verbose ); /* pass the pointer to Snac_Context to handle */ *handle = self; return BMI_SUCCESS; }