Dictionary_Entry_Value* _Dictionary_GetDouble_WithScopeDefault( Dictionary* dictionary, Dictionary_Entry_Key key, Dictionary_Entry_Value* defaultVal ) { Dictionary_Entry_Value *returnVal=NULL; Bool usedDefault = False; Stream* stream = Journal_Register( Info_Type, "Dictionary" ); returnVal = Dictionary_GetDefault( dictionary, key, defaultVal ); if( returnVal && returnVal->type == Dictionary_Entry_Value_Type_String ) { Dictionary_Entry_Key rootDictKey = Dictionary_Entry_Value_AsString( returnVal ); Dictionary* rootDict = dictionary; /* Check if the number really is a string or not */ if( Stg_StringIsNumeric( rootDictKey ) ) return returnVal; Journal_PrintfL( stream, 2, "Key '%s' points to key '%s' in the root dictionary: ", key, rootDictKey ); /* Get Value from dictionary */ returnVal = Dictionary_Get( rootDict, rootDictKey ); if( !returnVal && defaultVal ) { returnVal = Dictionary_GetDefault( rootDict, rootDictKey, defaultVal ); usedDefault = True; } /* Print Stuff */ if( usedDefault ) { Journal_PrintfL( stream, 2, "Using default value = " ); if( Stream_IsPrintableLevel( stream, 2 ) ) Dictionary_Entry_Value_Print( returnVal, stream ); Journal_PrintfL( stream, 2, "\n" ); return returnVal; } else if( returnVal ) { Journal_PrintfL( stream, 2, "Found - Value = " ); if( Stream_IsPrintableLevel( stream, 2 ) ) Dictionary_Entry_Value_Print( returnVal, stream ); Journal_PrintfL( stream, 2, "\n" ); } else Journal_PrintfL( stream, 2, "Not found.\n" ); } return returnVal; }
Dictionary_Entry_Value* _Stg_ComponentFactory_PluginGetNumericalValue( void* cf, void *codelet, Dictionary_Entry_Key key, Dictionary_Entry_Value* defaultVal ) { Stg_ComponentFactory* self = (Stg_ComponentFactory*)cf; Dictionary_Entry_Value* returnVal; Bool usedDefault = False; Stream* stream = self->infoStream; Stream* errorStream = Journal_Register( Error_Type, self->type ); Journal_Firewall( self != NULL, errorStream, "In func %s: Stg_Component is NULL.\n", __func__ ); returnVal = _Stg_ComponentFactory_PluginGetDictionaryValue( self, codelet, key, defaultVal ); /* Check to see whether the type is a string - * if it is then assume that this is a dictionary key linking to the root dictionary */ if ( returnVal ) { Dictionary_Entry_Key rootDictKey = Dictionary_Entry_Value_AsString( returnVal ); Dictionary* rootDict = self->rootDict; /* Check if the number really is a string or not */ if ( Stg_StringIsNumeric( rootDictKey ) ) return returnVal; Journal_PrintfL( stream, 2, "Key '%s' points to key '%s' in the root dictionary: ", key, rootDictKey ); Journal_Firewall( rootDict != NULL, errorStream, "Root Dictionary NULL in component factory.\n" ); /* Get Value from dictionary */ returnVal = Dictionary_Get( rootDict, rootDictKey ); if ( !returnVal && defaultVal ) { returnVal = Dictionary_GetDefault( rootDict, rootDictKey, defaultVal ); usedDefault = True; } /* Print Stuff */ if ( usedDefault ) { Journal_PrintfL( stream, 2, "Using default value = " ); if ( Stream_IsPrintableLevel( stream, 2 ) ) Dictionary_Entry_Value_Print( returnVal, stream ); Journal_PrintfL( stream, 2, "\n" ); return returnVal; } else if ( returnVal ) { Journal_PrintfL( stream, 2, "Found - Value = " ); if ( Stream_IsPrintableLevel( stream, 2 ) ) Dictionary_Entry_Value_Print( returnVal, stream ); Journal_PrintfL( stream, 2, "\n" ); } else Journal_PrintfL( stream, 2, "Not found.\n" ); } return returnVal; }
void _PeriodicBoundariesManager_Build( void* periodicBCsManager, void* data ) { PeriodicBoundariesManager* self = (PeriodicBoundariesManager*)periodicBCsManager; Dictionary_Entry_Value* periodicBCsList = NULL; Stg_Component_Build( self->swarm, data, False ); Stg_Component_Build( self->mesh, data, False ); self->size = 4; self->boundaries = Memory_Alloc_Array( PeriodicBoundary, self->size, "PeriodicBoundariesManager->boundaries" ); if ( self->dictionary ) { periodicBCsList = Dictionary_Get( self->dictionary, (Dictionary_Entry_Key)"PeriodicBoundaries" ); /* Dictionary entry is optional - users may prefer to enter in code */ if ( periodicBCsList ) { Index numPeriodicBCs = 0; Index periodicBC_I = 0; Dictionary_Entry_Value* periodicBC = NULL; char* perBCAxis = NULL; numPeriodicBCs = Dictionary_Entry_Value_GetCount( periodicBCsList ); for ( periodicBC_I = 0; periodicBC_I < numPeriodicBCs; periodicBC_I++ ) { periodicBC = Dictionary_Entry_Value_GetElement( periodicBCsList, periodicBC_I ); perBCAxis = Dictionary_Entry_Value_AsString( periodicBC ); if ( 0 == strcmp( perBCAxis, "I_AXIS" ) ) { PeriodicBoundariesManager_AddPeriodicBoundary( self, I_AXIS ); } else if ( 0 == strcmp( perBCAxis, "J_AXIS" ) ) { PeriodicBoundariesManager_AddPeriodicBoundary( self, J_AXIS ); } else if ( 0 == strcmp( perBCAxis, "K_AXIS" ) ) { PeriodicBoundariesManager_AddPeriodicBoundary( self, K_AXIS ); } } } } /* Test if mesh is periodic */ else if ( Stg_Class_IsInstance( self->mesh->generator, CartesianGenerator_Type ) ) { CartesianGenerator* cartesianGenerator = (CartesianGenerator*) self->mesh->generator; Dimension_Index dim_I; for ( dim_I = 0 ; dim_I < self->swarm->dim ; dim_I++ ) { /* Add boundaries straight from mesh generator */ if ( cartesianGenerator->periodic[ dim_I ] ) PeriodicBoundariesManager_AddPeriodicBoundary( self, dim_I ); } } }
Dictionary_Entry_Value* _Stg_ComponentFactory_GetDictionaryValue( void* cf, Name componentName, Dictionary_Entry_Key key, Dictionary_Entry_Value* defaultVal ) { Stg_ComponentFactory* self = (Stg_ComponentFactory*) cf; Dictionary* componentDict = NULL; Dictionary* thisComponentDict = NULL; Dictionary_Entry_Value* returnVal; Bool usedDefault = False; Stream* errorStream = Journal_Register( Error_Type, Stg_Component_Type ); Stream* stream = self->infoStream; Journal_Firewall( self != NULL, errorStream, "In func %s: Stg_ComponentFactory is NULL.\n", __func__ ); Journal_PrintfL( stream, 2, "Getting parameter '%s': ", key ); /* Get this Stg_Component's Dictionary */ componentDict = self->componentDict; Journal_Firewall( componentDict != NULL, errorStream, "In func %s: Stg_Component Factory's dictionary is NULL.\n", __func__ ); thisComponentDict = Dictionary_GetDictionary( componentDict, componentName ); if( thisComponentDict == NULL ) return defaultVal; /* Get Value from dictionary */ returnVal = Dictionary_Get( thisComponentDict, key ); if ( !returnVal && defaultVal ) { returnVal = Dictionary_GetDefault( thisComponentDict, key, defaultVal ); usedDefault = True; } /* Print Stuff */ if ( usedDefault ) { Journal_PrintfL( stream, 2, "Using default value = " ); if ( Stream_IsPrintableLevel( stream, 2 ) ) Dictionary_Entry_Value_Print( returnVal, stream ); Journal_PrintfL( stream, 2, "\n" ); return returnVal; } else if ( returnVal ) { Journal_PrintfL( stream, 2, "Found - Value = " ); if ( Stream_IsPrintableLevel( stream, 2 ) ) Dictionary_Entry_Value_Print( returnVal, stream ); Journal_PrintfL( stream, 2, "\n" ); } else Journal_PrintfL( stream, 2, "Not found.\n" ); return returnVal; }
void _ConvexHull_AssignFromXML( void* convexHull, Stg_ComponentFactory* cf, void* data ) { ConvexHull* self = (ConvexHull*)convexHull; Index vertexCount; Index vertex_I; Coord_List vertexList; double* coord; Dictionary_Entry_Value* optionSet; Dictionary_Entry_Value* optionsList; Dictionary* dictionary = Dictionary_GetDictionary( cf->componentDict, self->name ); Stream* stream = cf->infoStream; _Stg_Shape_AssignFromXML( self, cf, data ); optionsList = Dictionary_Get( dictionary, (Dictionary_Entry_Key)"vertices" ); Journal_Firewall( optionsList != NULL, Journal_Register( Error_Type, (Name)self->type ), "In func %s: The list 'vertices' specifying the convexHull is NULL.\n", __func__); vertexCount = Dictionary_Entry_Value_GetCount(optionsList); Journal_Firewall( ( self->dim == 2 && vertexCount < 4 ) || ( self->dim == 3 && vertexCount < 5 ), Journal_Register( Error_Type, (Name)self->type ), "In func %s: Sorry, but we got lazy, you can only specify 3 (2D) or 4 (3D) points. " "Please feel free to hassle developers for this feature.\n", __func__); /* Allocate space */ vertexList = Memory_Alloc_Array( Coord , vertexCount, "Vertex Array" ); memset( vertexList, 0, vertexCount * sizeof(Coord) ); Stream_Indent( stream ); for ( vertex_I = 0 ; vertex_I < vertexCount ; vertex_I++) { optionSet = Dictionary_Entry_Value_GetElement(optionsList, vertex_I ); coord = vertexList[vertex_I]; /* Read Vertex */ coord[ I_AXIS ] = Dictionary_Entry_Value_AsDouble( Dictionary_Entry_Value_GetMember( optionSet, (Dictionary_Entry_Key)"x") ); coord[ J_AXIS ] = Dictionary_Entry_Value_AsDouble( Dictionary_Entry_Value_GetMember( optionSet, (Dictionary_Entry_Key)"y") ); coord[ K_AXIS ] = Dictionary_Entry_Value_AsDouble( Dictionary_Entry_Value_GetMember( optionSet, (Dictionary_Entry_Key)"z")); optionSet = optionSet->next; } Stream_UnIndent( stream ); _ConvexHull_Init( self, vertexList, vertexCount); }
void _Ppc_a_Vector_AssignFromXML( void* _self, Stg_ComponentFactory* cf, void* data ) { Ppc_a_Vector* self = (Ppc_a_Vector*)_self; Dictionary* theDictionary; /* Construct parent */ _Ppc_AssignFromXML( self, cf, data ); /* The dictionary */ theDictionary = Dictionary_Entry_Value_AsDictionary( Dictionary_Get( cf->componentDict, (Dictionary_Entry_Key)self->name ) ); _Ppc_a_Vector_Init( self, PpcManager_GetPpcFromDict( self->manager, cf, self->name, (Dictionary_Entry_Key)"Alpha", "" ), PpcManager_GetPpcFromDict( self->manager, cf, self->name, (Dictionary_Entry_Key)"Vector", "" ), Stg_ComponentFactory_GetDouble( cf, self->name, (Dictionary_Entry_Key)"vi", 0.0 ), Stg_ComponentFactory_GetDouble( cf, self->name, (Dictionary_Entry_Key)"vj", 1.0 ), Stg_ComponentFactory_GetDouble( cf, self->name, (Dictionary_Entry_Key)"vk", 0.0 ) ); }
Dictionary* Codelet_GetPluginDictionary( void* codelet, Dictionary* rootDict ) { Codelet* self = (Codelet*)codelet; Dictionary_Entry_Value* pluginsDEV = Dictionary_Get( rootDict, "plugins" ); Dictionary* pluginDict; unsigned pluginIndex; Name pluginType; for( pluginIndex = 0; pluginIndex < Dictionary_Entry_Value_GetCount( pluginsDEV ); pluginIndex++ ) { pluginDict = Dictionary_Entry_Value_AsDictionary( Dictionary_Entry_Value_GetElement( pluginsDEV, pluginIndex ) ); pluginType = Dictionary_GetString( pluginDict, "Type" ); if( !strcmp( self->type, pluginType ) ) return pluginDict; } return NULL; }
Stg_Component* _Stg_ComponentFactory_ConstructByKey( void* cf, Name parentComponentName, Dictionary_Entry_Key componentKey, Type type, Bool isEssential, void* data ) { Stg_ComponentFactory* self = (Stg_ComponentFactory*)cf; Dictionary* thisComponentDict = NULL; Dictionary* componentDict = NULL; Name componentName, redirect; Dictionary_Entry_Value* componentEntryVal; Stream* errorStream = Journal_Register( Error_Type, self->type ); Journal_Firewall( self != NULL, errorStream, "In func %s: Stg_Component is NULL.\n", __func__ ); /* Get this Stg_Component's Dictionary */ componentDict = self->componentDict; Journal_Firewall( componentDict != NULL, errorStream, "In func %s: Stg_Component Factory's dictionary is NULL.\n", __func__ ); thisComponentDict = Dictionary_GetDictionary( componentDict, parentComponentName ); /* Get Dependency's Name */ componentEntryVal = Dictionary_Get( thisComponentDict, componentKey ); if ( componentEntryVal == NULL ) { Journal_Firewall( !isEssential, errorStream, "Stg_Component '%s' cannot find essential component with key '%s'.\n", parentComponentName, componentKey ); Journal_PrintfL( self->infoStream, 2, "Stg_Component '%s' cannot find non-essential component with key '%s'.\n", parentComponentName, componentKey ); return NULL; } componentName = Dictionary_Entry_Value_AsString( componentEntryVal ); /* If we can find the component's name in the root dictionary, use that value instead. */ if( self->rootDict ) { redirect = Dictionary_GetString_WithDefault( self->rootDict, componentName, "" ); if( strcmp( redirect, "" ) ) componentName = redirect; } return self->constructByName( self, componentName, type, isEssential, data ); }
void _ManualParticleLayout_InitialiseParticle( void* manualParticleLayout, void* _swarm, Particle_Index newParticle_I, void* _particle ) { ManualParticleLayout* self = (ManualParticleLayout*)manualParticleLayout; Dictionary_Entry_Value* manualParticlePositions = NULL; Dictionary_Entry_Value* particlePositionEntry = NULL; Dictionary* particlePositionDict = NULL; GlobalParticle* particle = (GlobalParticle*)_particle; manualParticlePositions = Dictionary_Get( self->dictionary, (Dictionary_Entry_Key)"manualParticlePositions" ); particlePositionEntry = Dictionary_Entry_Value_GetElement( manualParticlePositions, newParticle_I ); particlePositionDict = Dictionary_Entry_Value_AsDictionary( particlePositionEntry ); particle->coord[I_AXIS] = Dictionary_GetDouble_WithDefault( particlePositionDict, (Dictionary_Entry_Key)"x", 0.0 ); particle->coord[J_AXIS] = Dictionary_GetDouble_WithDefault( particlePositionDict, (Dictionary_Entry_Key)"y", 0.0 ); particle->coord[K_AXIS] = Dictionary_GetDouble_WithDefault( particlePositionDict, (Dictionary_Entry_Key)"z", 0.0 ); }
PyObject* Dictionary_Python_AddStringToList( PyObject* self, PyObject* args ) { PyObject* pyDictionary; Dictionary* dictionary; char* name; char* value; Dictionary_Entry_Value* list; /* Obtain arguements */ if( !PyArg_ParseTuple( args, "Oss:", &pyDictionary, &name, &value ) ) { return NULL; } dictionary = (Dictionary*)( PyCObject_AsVoidPtr( pyDictionary ) ); /* Run function */ list = Dictionary_Get( dictionary, name ); Dictionary_Entry_Value_AddElement( list, Dictionary_Entry_Value_FromString( value ) ); /* Return */ Py_INCREF( Py_None ); return Py_None; }
void DictionarySuite_TestAddElement( DictionarySuiteData* data ) { Dictionary_Entry_Value* yValue; Dictionary_Entry_Value* testStruct; Dictionary_Entry_Value* currValue; double newVal = -45.0; DictionarySuite_PopulateDictWithTestValues( data->dict, data->testDD ); /* turning the starty value into a list using add element */ testStruct = Dictionary_Get( data->dict, (Dictionary_Entry_Key)"test_struct" ); yValue = Dictionary_Entry_Value_GetMember( Dictionary_Entry_Value_GetMember(testStruct, (Dictionary_Entry_Key)"geom" ), "starty"); Dictionary_Entry_Value_AddElement( yValue, Dictionary_Entry_Value_FromDouble(newVal) ); pcu_check_true( Dictionary_Entry_Value_Type_List == yValue->type ); pcu_check_true( 2 == Dictionary_Entry_Value_GetCount( yValue ) ); currValue = Dictionary_Entry_Value_GetFirstElement( yValue ); pcu_check_le( fabs( data->testDD->testStruct->geom.starty - Dictionary_Entry_Value_AsDouble( currValue )), 0.01 ); currValue = currValue->next; pcu_check_le( fabs( newVal - Dictionary_Entry_Value_AsDouble( currValue )), 0.01 ); }
void DictionarySuite_TestShortcuts( DictionarySuiteData* data ) { DictionarySuite_PopulateDictWithTestValues( data->dict, data->testDD ); /* Testing GetString_WithDefault. If an entry with that key already exists, then * the value of the existing key should be returned, and the default passed in * ignored. However if the given key _doesn't_ exist, the default should be * returned, and a new entry with the given key added to the dict. */ pcu_check_streq( data->testDD->testString, Dictionary_GetString_WithDefault( data->dict, "test_cstring", "heya" ) ); pcu_check_streq( "heya", Dictionary_GetString_WithDefault( data->dict, "test_cstring2", "heya" ) ); pcu_check_true( NULL != Dictionary_Get( data->dict, (Dictionary_Entry_Key)"test_cstring2" ) ); data->testDD->testDouble = Dictionary_GetDouble_WithDefault( data->dict, (Dictionary_Entry_Key)"test_double", 2.8 ); pcu_check_true( data->testDD->testDouble ); pcu_check_true( 2.8 == Dictionary_GetDouble_WithDefault( data->dict, (Dictionary_Entry_Key)"test_double2", 2.8 ) ); /* test_placeholder refers to test_double which equals 45.567 */ pcu_check_true( 45.567 == Dictionary_GetDouble_WithScopeDefault( data->dict, (Dictionary_Entry_Key)"test_placeholder", -1 ) ); pcu_check_true( NULL != Dictionary_Get( data->dict, (Dictionary_Entry_Key)"test_double2" ) ); data->testDD->testUint = Dictionary_GetUnsignedInt_WithDefault( data->dict, "test_uint", 33 ); pcu_check_true( data->testDD->testUint ); pcu_check_true( 33 == Dictionary_GetUnsignedInt_WithDefault( data->dict, "test_uint2", 33 ) ); pcu_check_true( NULL != Dictionary_Get( data->dict, (Dictionary_Entry_Key)"test_uint2" ) ); data->testDD->testInt = Dictionary_GetInt_WithDefault( data->dict, (Dictionary_Entry_Key)"test_int", -24 ); pcu_check_true( data->testDD->testInt ); pcu_check_true( -24 == Dictionary_GetInt_WithDefault( data->dict, (Dictionary_Entry_Key)"test_int2", -24 ) ); pcu_check_true( NULL != Dictionary_Get( data->dict, (Dictionary_Entry_Key)"test_int2" ) ); data->testDD->testUnsignedlong = Dictionary_GetUnsignedLong_WithDefault( data->dict, "test_unsignedlong", 32433 ); pcu_check_true( data->testDD->testUnsignedlong ); pcu_check_true( 32433 == Dictionary_GetUnsignedLong_WithDefault( data->dict, "test_unsignedlong2", 32433 ) ); pcu_check_true( NULL != Dictionary_Get( data->dict, (Dictionary_Entry_Key)"test_unsignedlong2" ) ); data->testDD->testBool = Dictionary_GetBool_WithDefault( data->dict, (Dictionary_Entry_Key)"test_bool", False ); pcu_check_true( data->testDD->testBool ); pcu_check_true( False == Dictionary_GetBool_WithDefault( data->dict, (Dictionary_Entry_Key)"test_bool2", False ) ); pcu_check_true( NULL != Dictionary_Get( data->dict, (Dictionary_Entry_Key)"test_bool2" ) ); pcu_check_streq( data->testDD->testString, Dictionary_GetString_WithPrintfDefault( data->dict, "test_cstring", "heya%s%u", "hey", 3 ) ); pcu_check_streq( "heyahey3", Dictionary_GetString_WithPrintfDefault( data->dict, "test_cstring3", "heya%s%u", "hey", 3 ) ); pcu_check_true( NULL != Dictionary_Get( data->dict, (Dictionary_Entry_Key)"test_cstring3" ) ); }
/*---------------------------------------------------------------------------------------------------------- ** Virtual functions */ void _LinearSpaceAdaptor_AssignFromXML( void* _self, Stg_ComponentFactory* cf, void* data ) { LinearSpaceAdaptor* self = (LinearSpaceAdaptor*)_self; Dictionary* dictionary = Dictionary_GetDictionary( cf->componentDict, self->name ); Dictionary_Entry_Value* optionsList = NULL; Dictionary_Entry_Value* optionSet = NULL; linearSpaceAdaptor_Segment* seg = NULL; Index segmentCount; Index segment_I; AbstractContext* context; assert( self ); assert( cf ); /* Call parent construct. */ _MeshAdaptor_AssignFromXML( self, cf, data ); context = (AbstractContext*)Stg_ComponentFactory_ConstructByKey( cf, self->name, (Dictionary_Entry_Key)"Context", AbstractContext, False, data ); if( !context ) context = Stg_ComponentFactory_ConstructByName( cf, (Name)"context", AbstractContext, True, data ); self->loadFromCheckPoint = context->loadFromCheckPoint; if( self->loadFromCheckPoint ) return; self->minX = Dictionary_Entry_Value_AsDouble( Dictionary_Get( cf->rootDict, (Dictionary_Entry_Key)"minX" ) ); self->maxX = Dictionary_Entry_Value_AsDouble( Dictionary_Get( cf->rootDict, (Dictionary_Entry_Key)"maxX" ) ); self->minY = Dictionary_Entry_Value_AsDouble( Dictionary_Get( cf->rootDict, (Dictionary_Entry_Key)"minY" ) ); self->maxY = Dictionary_Entry_Value_AsDouble( Dictionary_Get( cf->rootDict, (Dictionary_Entry_Key)"maxY" ) ); self->minZ = Dictionary_Entry_Value_AsDouble( Dictionary_Get( cf->rootDict, (Dictionary_Entry_Key)"minZ" ) ); self->maxZ = Dictionary_Entry_Value_AsDouble( Dictionary_Get( cf->rootDict, (Dictionary_Entry_Key)"maxZ" ) ); /* Read mapping functions - X axis*/ optionsList = Dictionary_Get( dictionary, (Dictionary_Entry_Key)"mappingFunctionX" ); if( optionsList ) { segmentCount = Dictionary_Entry_Value_GetCount(optionsList ); self->nSegmentsx = segmentCount; self->tablex = Memory_Alloc_Array( linearSpaceAdaptor_Segment , segmentCount, "mapping table x" ); memset( self->tablex, 0, segmentCount * sizeof(linearSpaceAdaptor_Segment) ); for ( segment_I = 0 ; segment_I < segmentCount ; segment_I++) { optionSet = Dictionary_Entry_Value_GetElement(optionsList, segment_I ); seg = &(self->tablex[segment_I]); seg->x = Dictionary_Entry_Value_AsDouble( Dictionary_Entry_Value_GetMember( optionSet, (Dictionary_Entry_Key)"point" ) ); seg->y = Dictionary_Entry_Value_AsDouble( Dictionary_Entry_Value_GetMember( optionSet, (Dictionary_Entry_Key)"mappedTo" ) ); } } else { self->nSegmentsx = 0; } /* Read mapping functions - Y axis*/ optionsList = Dictionary_Get( dictionary, (Dictionary_Entry_Key)"mappingFunctionY" ); if( optionsList ) { segmentCount = Dictionary_Entry_Value_GetCount(optionsList ); self->nSegmentsy = segmentCount; self->tabley = Memory_Alloc_Array( linearSpaceAdaptor_Segment , segmentCount, "mapping table y" ); memset( self->tabley, 0, segmentCount * sizeof(linearSpaceAdaptor_Segment) ); for ( segment_I = 0; segment_I < segmentCount; segment_I++) { optionSet = Dictionary_Entry_Value_GetElement(optionsList, segment_I ); seg = &(self->tabley[segment_I]); seg->x = Dictionary_Entry_Value_AsDouble( Dictionary_Entry_Value_GetMember( optionSet, (Dictionary_Entry_Key)"point" ) ); seg->y = Dictionary_Entry_Value_AsDouble( Dictionary_Entry_Value_GetMember( optionSet, (Dictionary_Entry_Key)"mappedTo" ) ); } } else { self->nSegmentsy = 0; } /* Read mapping functions - Z axis*/ optionsList = Dictionary_Get( dictionary, (Dictionary_Entry_Key)"mappingFunctionZ" ); if( optionsList && ((DomainContext*)context)->dim==3 ) { segmentCount = Dictionary_Entry_Value_GetCount(optionsList ); self->nSegmentsz = segmentCount; self->tablez = Memory_Alloc_Array( linearSpaceAdaptor_Segment , segmentCount, "mapping table z" ); memset( self->tablez, 0, segmentCount * sizeof(linearSpaceAdaptor_Segment) ); for ( segment_I = 0 ; segment_I < segmentCount ; segment_I++) { optionSet = Dictionary_Entry_Value_GetElement(optionsList, segment_I ); seg = &(self->tablez[segment_I]); seg->x = Dictionary_Entry_Value_AsDouble( Dictionary_Entry_Value_GetMember( optionSet, (Dictionary_Entry_Key)"point" ) ); seg->y = Dictionary_Entry_Value_AsDouble( Dictionary_Entry_Value_GetMember( optionSet, (Dictionary_Entry_Key)"mappedTo" ) ); } } else { self->nSegmentsz = 0; } _LinearSpaceAdaptor_Init( self ); }
void _VariableAllVC_ReadDictionary( void* variableCondition, void* dictionary ) { VariableAllVC* self = (VariableAllVC*)variableCondition; Dictionary_Entry_Value* vcDictVal; Dictionary_Entry_Value _vcDictVal; Dictionary_Entry_Value* varsVal; VariableAllVC_Entry_Index entry_I; /* Find dictionary entry */ if (self->_dictionaryEntryName) vcDictVal = Dictionary_Get( dictionary, self->_dictionaryEntryName ); else { vcDictVal = &_vcDictVal; Dictionary_Entry_Value_InitFromStruct( vcDictVal, dictionary ); } if (vcDictVal) { /* Obtain the variable entries */ self->_entryCount = Dictionary_Entry_Value_GetCount(Dictionary_Entry_Value_GetMember(vcDictVal, "variables")); self->_entryTbl = Memory_Alloc_Array( VariableAllVC_Entry, self->_entryCount, "VariableAllVC->_entryTbl" ); varsVal = Dictionary_Entry_Value_GetMember(vcDictVal, "variables"); for (entry_I = 0; entry_I < self->_entryCount; entry_I++) { char* valType; Dictionary_Entry_Value* valueEntry; Dictionary_Entry_Value* varDictListVal; varDictListVal = Dictionary_Entry_Value_GetElement(varsVal, entry_I); valueEntry = Dictionary_Entry_Value_GetMember(varDictListVal, "value"); self->_entryTbl[entry_I].varName = Dictionary_Entry_Value_AsString( Dictionary_Entry_Value_GetMember(varDictListVal, "name")); valType = Dictionary_Entry_Value_AsString(Dictionary_Entry_Value_GetMember(varDictListVal, "type")); if (!strcasecmp(valType, "func")) { char* funcName = Dictionary_Entry_Value_AsString(valueEntry); self->_entryTbl[entry_I].value.type = VC_ValueType_CFIndex; self->_entryTbl[entry_I].value.as.typeCFIndex = ConditionFunction_Register_GetIndex( self->conFunc_Register, funcName); } else if (!strcasecmp(valType, "array")) { Dictionary_Entry_Value* valueElement; Index i; self->_entryTbl[entry_I].value.type = VC_ValueType_DoubleArray; self->_entryTbl[entry_I].value.as.typeArray.size = Dictionary_Entry_Value_GetCount(valueEntry); self->_entryTbl[entry_I].value.as.typeArray.array = Memory_Alloc_Array( double, self->_entryTbl[entry_I].value.as.typeArray.size,"VariableAllVC->_entryTbl[].value.as.typeArray.array" ); for (i = 0; i < self->_entryTbl[entry_I].value.as.typeArray.size; i++) { valueElement = Dictionary_Entry_Value_GetElement(valueEntry, i); self->_entryTbl[entry_I].value.as.typeArray.array[i] = Dictionary_Entry_Value_AsDouble(valueElement); } } else if( !strcasecmp( valType, "double" ) || !strcasecmp( valType, "d" ) || !strcasecmp( valType, "float" ) || !strcasecmp( valType, "f" ) ) { self->_entryTbl[entry_I].value.type = VC_ValueType_Double; self->_entryTbl[entry_I].value.as.typeDouble = Dictionary_Entry_Value_AsDouble( valueEntry ); } else if( !strcasecmp( valType, "integer" ) || !strcasecmp( valType, "int" ) || !strcasecmp( valType, "i" ) ) { self->_entryTbl[entry_I].value.type = VC_ValueType_Int; self->_entryTbl[entry_I].value.as.typeInt = Dictionary_Entry_Value_AsUnsignedInt( valueEntry ); } else if( !strcasecmp( valType, "short" ) || !strcasecmp( valType, "s" ) ) { self->_entryTbl[entry_I].value.type = VC_ValueType_Short; self->_entryTbl[entry_I].value.as.typeShort = Dictionary_Entry_Value_AsUnsignedInt( valueEntry ); } else if( !strcasecmp( valType, "char" ) || !strcasecmp( valType, "c" ) ) { self->_entryTbl[entry_I].value.type = VC_ValueType_Char; self->_entryTbl[entry_I].value.as.typeChar = Dictionary_Entry_Value_AsUnsignedInt( valueEntry ); } else if( !strcasecmp( valType, "pointer" ) || !strcasecmp( valType, "ptr" ) || !strcasecmp( valType, "p" ) ) { self->_entryTbl[entry_I].value.type = VC_ValueType_Ptr; self->_entryTbl[entry_I].value.as.typePtr = (void*) ( (ArithPointer) Dictionary_Entry_Value_AsUnsignedInt( valueEntry )); } else { /* Assume double */ Journal_DPrintf( Journal_Register( InfoStream_Type, "myStream" ), "Type to variable on variable condition not given, assuming double\n" ); self->_entryTbl[entry_I].value.type = VC_ValueType_Double; self->_entryTbl[entry_I].value.as.typeDouble = Dictionary_Entry_Value_AsDouble( valueEntry ); } }
void _FrictionVC_ReadDictionary( void* variableCondition, void* dictionary ) { FrictionVC* self = (FrictionVC*)variableCondition; Dictionary_Entry_Value* vcDictVal; Dictionary_Entry_Value _vcDictVal; Dictionary_Entry_Value* varsVal; FrictionVC_Entry_Index entry_I; /* Find dictionary entry */ if (self->_dictionaryEntryName) vcDictVal = Dictionary_Get(dictionary, self->_dictionaryEntryName); else { vcDictVal = &_vcDictVal; Dictionary_Entry_Value_InitFromStruct(vcDictVal, dictionary); } if (vcDictVal) { char* wallStr; /* Obtain which wall */ wallStr = Dictionary_Entry_Value_AsString(Dictionary_Entry_Value_GetMember(vcDictVal, "wall" )); if (!strcasecmp(wallStr, "back")) self->_wall = FrictionVC_Wall_Back; else if (!strcasecmp(wallStr, "left")) self->_wall = FrictionVC_Wall_Left; else if (!strcasecmp(wallStr, "bottom")) self->_wall = FrictionVC_Wall_Bottom; else if (!strcasecmp(wallStr, "right")) self->_wall = FrictionVC_Wall_Right; else if (!strcasecmp(wallStr, "top")) self->_wall = FrictionVC_Wall_Top; else if (!strcasecmp(wallStr, "front")) self->_wall = FrictionVC_Wall_Front; else { assert( 0 ); self->_wall = FrictionVC_Wall_Size; /* invalid entry */ } /* Obtain the variable entries */ self->_entryCount = 0; self->_entryCount = Dictionary_Entry_Value_GetCount(Dictionary_Entry_Value_GetMember(vcDictVal, "variables")); self->_entryTbl = Memory_Alloc_Array( FrictionVC_Entry, self->_entryCount, "FrictionVC->_entryTbl" ); varsVal = Dictionary_Entry_Value_GetMember(vcDictVal, "variables"); for (entry_I = 0; entry_I < self->_entryCount; entry_I++) { char* valType; Dictionary_Entry_Value* valueEntry; Dictionary_Entry_Value* varDictListVal; varDictListVal = Dictionary_Entry_Value_GetElement(varsVal, entry_I); valueEntry = Dictionary_Entry_Value_GetMember(varDictListVal, "value"); self->_entryTbl[entry_I].varName = Dictionary_Entry_Value_AsString( Dictionary_Entry_Value_GetMember(varDictListVal, "name")); valType = Dictionary_Entry_Value_AsString(Dictionary_Entry_Value_GetMember(varDictListVal, "type")); if (0 == strcasecmp(valType, "func")) { char* funcName = Dictionary_Entry_Value_AsString(valueEntry); Index cfIndex; self->_entryTbl[entry_I].value.type = VC_ValueType_CFIndex; cfIndex = ConditionFunction_Register_GetIndex( self->conFunc_Register, funcName); if ( cfIndex == (unsigned)-1 ) { Stream* errorStr = Journal_Register( Error_Type, self->type ); Journal_Printf( errorStr, "Error- in %s: While parsing " "definition of wallVC \"%s\" (applies to wall \"%s\"), the cond. func. applied to " "variable \"%s\" - \"%s\" - wasn't found in the c.f. register.\n", __func__, self->_dictionaryEntryName, FrictionVC_WallEnumToStr[self->_wall], self->_entryTbl[entry_I].varName, funcName ); Journal_Printf( errorStr, "(Available functions in the C.F. register are: "); ConditionFunction_Register_PrintNameOfEachFunc( self->conFunc_Register, errorStr ); Journal_Printf( errorStr, ")\n"); assert(0); } self->_entryTbl[entry_I].value.as.typeCFIndex = cfIndex; } else if (0 == strcasecmp(valType, "array")) { Dictionary_Entry_Value* valueElement; Index i; self->_entryTbl[entry_I].value.type = VC_ValueType_DoubleArray; self->_entryTbl[entry_I].value.as.typeArray.size = Dictionary_Entry_Value_GetCount(valueEntry); self->_entryTbl[entry_I].value.as.typeArray.array = Memory_Alloc_Array( double, self->_entryTbl[entry_I].value.as.typeArray.size, "FrictionVC->_entryTbl[].value.as.typeArray.array" ); for (i = 0; i < self->_entryTbl[entry_I].value.as.typeArray.size; i++) { valueElement = Dictionary_Entry_Value_GetElement(valueEntry, i); self->_entryTbl[entry_I].value.as.typeArray.array[i] = Dictionary_Entry_Value_AsDouble(valueElement); } } else if( 0 == strcasecmp( valType, "double" ) || 0 == strcasecmp( valType, "d" ) || 0 == strcasecmp( valType, "float" ) || 0 == strcasecmp( valType, "f" ) ) { self->_entryTbl[entry_I].value.type = VC_ValueType_Double; self->_entryTbl[entry_I].value.as.typeDouble = Dictionary_Entry_Value_AsDouble( valueEntry ); } else if( 0 == strcasecmp( valType, "integer" ) || 0 == strcasecmp( valType, "int" ) || 0 == strcasecmp( valType, "i" ) ) { self->_entryTbl[entry_I].value.type = VC_ValueType_Int; self->_entryTbl[entry_I].value.as.typeInt = Dictionary_Entry_Value_AsUnsignedInt( valueEntry ); } else if( 0 == strcasecmp( valType, "short" ) || 0 == strcasecmp( valType, "s" ) ) { self->_entryTbl[entry_I].value.type = VC_ValueType_Short; self->_entryTbl[entry_I].value.as.typeShort = Dictionary_Entry_Value_AsUnsignedInt( valueEntry ); } else if( 0 == strcasecmp( valType, "char" ) || 0 == strcasecmp( valType, "c" ) ) { self->_entryTbl[entry_I].value.type = VC_ValueType_Char; self->_entryTbl[entry_I].value.as.typeChar = Dictionary_Entry_Value_AsUnsignedInt( valueEntry ); } else if( 0 == strcasecmp( valType, "pointer" ) || 0 == strcasecmp( valType, "ptr" ) || 0 == strcasecmp( valType, "p" ) ) { self->_entryTbl[entry_I].value.type = VC_ValueType_Ptr; self->_entryTbl[entry_I].value.as.typePtr = (void*) ( (ArithPointer)Dictionary_Entry_Value_AsUnsignedInt( valueEntry )); } else { /* Assume double */ Journal_DPrintf( Journal_Register( InfoStream_Type, "myStream" ), "Type to variable on variable condition not given, assuming double\n" ); self->_entryTbl[entry_I].value.type = VC_ValueType_Double; self->_entryTbl[entry_I].value.as.typeDouble = Dictionary_Entry_Value_AsDouble( valueEntry ); } }
void _SnacTemperature_ConstructExtensions( void* _context, void* data ) { Snac_Context* context = (Snac_Context*)_context; SnacTemperature_Context* contextExt = ExtensionManager_Get( context->extensionMgr, context, SnacTemperature_ContextHandle ); Snac_Node tmpNode; SnacTemperature_Node* tmpNodeExt = ExtensionManager_Get( context->mesh->nodeExtensionMgr, &tmpNode, SnacTemperature_NodeHandle ); Dictionary* temperatureBCsDict; char tmpBuf[PATH_MAX]; /* Because temperature is not an array by itself, we must the "complex" constructor for Variable... the info needs to be * wrapped this generic way... */ Index temperatureOffsetCount = 1; SizeT temperatureOffsets[] = { /*GetOffsetOfMember( *tmpNodeExt, temperature ) };*/ (SizeT)((char*)&tmpNodeExt->temperature - (char*)&tmpNode) }; Variable_DataType temperatureDataTypes[] = { Variable_DataType_Double }; Index temperatureDataTypeCounts[] = { 1 }; #if DEBUG printf( "In %s()\n", __func__ ); #endif /* Create the StGermain variable temperature, which is stored on a node extension */ Variable_New( "temperature", temperatureOffsetCount, temperatureOffsets, temperatureDataTypes, temperatureDataTypeCounts, 0, &ExtensionManager_GetFinalSize( context->mesh->nodeExtensionMgr ), &context->mesh->layout->decomp->nodeDomainCount, (void**)&context->mesh->node, context->variable_Register ); /* Register these functions for use in VCs */ ConditionFunction_Register_Add( context->condFunc_Register, ConditionFunction_New( _SnacTemperature_Top2BottomSweep, "SnacTemperature_Top2BottomSweep" ) ); ConditionFunction_Register_Add( context->condFunc_Register, ConditionFunction_New( _SnacTemperature_Top2BottomSweep_Spherical, "SnacTemperature_Top2BottomSweep_Spherical" ) ); ConditionFunction_Register_Add( context->condFunc_Register, ConditionFunction_New( _SnacTemperature_Citcom_Compatible, "SnacTemperature_Citcom_Compatible" ) ); /* Temperature variables */ contextExt->topTemp = Dictionary_Entry_Value_AsDouble( Dictionary_GetDefault( context->dictionary, "topTemp", Dictionary_Entry_Value_FromDouble( 0.0f ) ) ); contextExt->bottomTemp = Dictionary_Entry_Value_AsDouble( Dictionary_GetDefault( context->dictionary, "bottomTemp", Dictionary_Entry_Value_FromDouble( 1300.0f ) ) ); /* Build the temperature IC and BC managers */ temperatureBCsDict = Dictionary_Entry_Value_AsDictionary( Dictionary_Get( context->dictionary, "temperatureBCs" ) ); contextExt->temperatureBCs = CompositeVC_New("tempBC", context->variable_Register, context->condFunc_Register, temperatureBCsDict, context->mesh ); /* Prepare the dump and checkpoint file */ sprintf( tmpBuf, "%s/temperature.%u", context->outputPath, context->rank ); if( (contextExt->temperatureOut = fopen( tmpBuf, "w+" )) == NULL ) { assert( contextExt->temperatureOut /* failed to open file for writing */ ); abort(); } sprintf( tmpBuf, "%s/temperatureCP.%u", context->outputPath, context->rank ); if( (contextExt->temperatureCheckpoint = fopen( tmpBuf, "w+" )) == NULL ) { assert( contextExt->temperatureCheckpoint /* failed to open file for writing */ ); abort(); } }
void ModulesManager_Load( void* modulesManager, void* _dictionary, Name contextName ) { ModulesManager* self = (ModulesManager*)modulesManager; Dictionary* dictionary = (Dictionary*)_dictionary; unsigned int entryCount; unsigned int entry_I; Dictionary_Entry_Value* modulesVal; /* * First add the directory list onto LD_LIBRARY_PATH so that it can potentially * resolve the unknown symbols */ #ifndef NOSHARED char* curEnvPath; char* newEnvPath; Index newEnvPathLength; Index dir_I; Index i, count; char* dir; newEnvPathLength = 0; if( dictionary ) { Dictionary_Entry_Value* localLibDirList = Dictionary_Get( dictionary, "LD_LIBRARY_PATH" ); if( localLibDirList ) { count = Dictionary_Entry_Value_GetCount( localLibDirList ); for( i = 0; i < count; ++i ) { dir = Dictionary_Entry_Value_AsString( Dictionary_Entry_Value_GetElement( localLibDirList, i ) ); ModulesManager_AddDirectory( "FromDictionary", dir ); } } } for( dir_I = 0; dir_I < moduleDirectories->count; ++dir_I ) { newEnvPathLength += strlen( (char*)Stg_ObjectList_ObjectAt( moduleDirectories, dir_I ) ); /* Add one make space for the ':' inbetween the directories */ newEnvPathLength += 1; } curEnvPath = getenv("LD_LIBRARY_PATH"); if( curEnvPath ) { newEnvPathLength += strlen( curEnvPath ); } if( newEnvPathLength > 0 ) { /* Add one to make space for the Null Terminator '\0' */ newEnvPathLength += 1; newEnvPath = Memory_Alloc_Array( char, newEnvPathLength, "LD_LIBRARY_PATH" ); newEnvPath[0] = '\0'; for( dir_I = 0; dir_I < moduleDirectories->count; ++dir_I ) { strcat( newEnvPath, (char*)Stg_ObjectList_ObjectAt( moduleDirectories, dir_I ) ); strcat( newEnvPath, ":" ); } if( curEnvPath ) { strcat( newEnvPath, curEnvPath ); } setenv( "LD_LIBRARY_PATH", newEnvPath, 1 ); Journal_Printf( Journal_Register( Debug_Type, self->type ), "Using LD_LIBRARY_PATH=%s\n", newEnvPath ); Memory_Free( newEnvPath ); }
Dictionary_Entry_Value* _Stg_ComponentFactory_PluginGetDictionaryValue( void* cf, void *codelet, Dictionary_Entry_Key key, Dictionary_Entry_Value* defaultVal ) { Stg_ComponentFactory* self = (Stg_ComponentFactory*) cf; Stg_Component* plugin = (Stg_Component*)codelet; Dictionary* thisPluginDict = NULL; Dictionary* pluginDict = (Dictionary*)Dictionary_Get( self->rootDict, "plugins" ); Name pluginType; Index pluginIndex; Dictionary_Entry_Value* returnVal; Bool usedDefault = False; Stream* errorStream = Journal_Register( Error_Type, Stg_Component_Type ); Stream* stream = self->infoStream; Journal_Firewall( self != NULL, errorStream, "In func %s: Stg_ComponentFactory is NULL.\n", __func__ ); Journal_PrintfL( stream, 2, "Getting parameter '%s': ", key ); Journal_Firewall( pluginDict != NULL, errorStream, "In func %s: Stg_Component Factory's dictionary is NULL.\n", __func__ ); /* Get this plugins Dictionary */ for( pluginIndex = 0; pluginIndex < Dictionary_Entry_Value_GetCount( (Dictionary_Entry_Value*)pluginDict ); pluginIndex++ ) { thisPluginDict = Dictionary_Entry_Value_AsDictionary( Dictionary_Entry_Value_GetElement( (Dictionary_Entry_Value*)pluginDict, pluginIndex ) ); pluginType = StG_Strdup( Dictionary_GetString( thisPluginDict, "Type" ) ); if( !strcmp( plugin->type, pluginType ) ){ Memory_Free( pluginType ); break; } Memory_Free( pluginType ); } /* Get this Stg_Component's Dictionary */ Journal_Firewall( thisPluginDict != NULL, errorStream, "In func %s: Can't find sub-dictionary for component '%s'.\n", __func__, plugin->name ); /* Get Value from dictionary */ returnVal = Dictionary_Get( thisPluginDict, key ); if ( !returnVal && defaultVal ) { returnVal = Dictionary_GetDefault( thisPluginDict, key, defaultVal ); usedDefault = True; } /* Print Stuff */ if ( usedDefault ) { Journal_PrintfL( stream, 2, "Using default value = " ); if ( Stream_IsPrintableLevel( stream, 2 ) ) Dictionary_Entry_Value_Print( returnVal, stream ); Journal_PrintfL( stream, 2, "\n" ); return returnVal; } else if ( returnVal ) { Journal_PrintfL( stream, 2, "Found - Value = " ); if ( Stream_IsPrintableLevel( stream, 2 ) ) Dictionary_Entry_Value_Print( returnVal, stream ); Journal_PrintfL( stream, 2, "\n" ); } else Journal_PrintfL( stream, 2, "Not found.\n" ); return returnVal; }
void _Geothermal_FieldMaps_AssignFromXML( void* component, Stg_ComponentFactory* cf, void* data ) { Geothermal_FieldMaps* self = (Geothermal_FieldMaps*)component; Dictionary* dict = Codelet_GetPluginDictionary( component, cf->rootDict ); Dictionary_Entry_Value* mapList; unsigned map_i; Stream* errorStream = Journal_Register( ErrorStream_Type, Geothermal_FieldMaps_Type ); Stream_SetPrintingRank( errorStream, 0 ); /* Plugin-wide stuff */ self->context = (AbstractContext*)Stg_ComponentFactory_ConstructByName( cf, "context", UnderworldContext, True, data ); /*self->swarm = Stg_ComponentFactory_ConstructByName( cf, Dictionary_GetString( dict, "Swarm" ), Swarm, True, data );*/ mapList = Dictionary_Get( dict, (Dictionary_Entry_Key)"maps" ); if( mapList ) { self->numMaps = Dictionary_Entry_Value_GetCount( mapList ); self->maps = malloc( self->numMaps * sizeof(Map*) ); } else { self->numMaps = 0; self->maps = NULL; } /* Per map stuff */ for( map_i = 0; map_i < self->numMaps; map_i++ ) { self->maps[map_i] = malloc( sizeof(Map) ); Dictionary* mapEntryDict = Dictionary_Entry_Value_AsDictionary( Dictionary_Entry_Value_GetElement( mapList, map_i ) ); char* tmpStr; #define SDEK Dictionary_Entry_Key #define SDGDWD Dictionary_GetDouble_WithDefault #define SDGSWD Dictionary_GetString_WithDefault #define SDGBWD Dictionary_GetBool_WithDefault #define SCFCBN Stg_ComponentFactory_ConstructByName strncpy( self->maps[map_i]->name, Dictionary_GetString( mapEntryDict, "name" ), FILENAME_MAX ); strncpy( self->maps[map_i]->outputPath, SDGSWD( mapEntryDict, (SDEK)"outputPath", self->context->outputPath ), FILENAME_MAX); self->maps[map_i]->field = SCFCBN( cf, Dictionary_GetString( mapEntryDict, "Field" ), FeVariable, True, data ); self->maps[map_i]->depth = SDGDWD( mapEntryDict, (SDEK)"depthFromSurface", 0.0 ); /* Type of map */ self->maps[map_i]->outputAllNodes = False; self->maps[map_i]->outputTopNodes = False; self->maps[map_i]->outputDepth = False; self->maps[map_i]->depth = 0.0; self->maps[map_i]->heightField = NULL; tmpStr = Dictionary_GetString( mapEntryDict, "of" ); if( strcmp( "surface", tmpStr ) == 0 ) { self->maps[map_i]->outputTopNodes = True; } else if( strcmp( "volume", tmpStr ) == 0 ) { self->maps[map_i]->outputAllNodes = True; } else if( strcmp( "depth", tmpStr ) == 0 ) { self->maps[map_i]->outputDepth = True; self->maps[map_i]->depth = SDGDWD( mapEntryDict, (SDEK)"depthFromSurface", 0.0 ); /* TODO: firewall if depth not given!!!*/ } else if( strcmp( "height", tmpStr ) == 0 ) { self->maps[map_i]->outputDepth = True; self->maps[map_i]->heightField = SCFCBN( cf, Dictionary_GetString( mapEntryDict, "HeightField" ), FieldVariable, True, data ); /* TODO: firewall if HeightField not given!!!*/ } Journal_Firewall( self->maps[map_i]->outputTopNodes || self->maps[map_i]->outputAllNodes || self->maps[map_i]->outputDepth, errorStream, "Error: On FieldMaps plugin entry %u (named: \"%s\"), the \"of\" parameter must be either \"surface\", \"volume\", " "\"depth\", or \"height\" (\"%s\" was given).\n", map_i, self->maps[map_i]->name, tmpStr ); /* Formats */ self->maps[map_i]->gocadOutput = SDGBWD( mapEntryDict, (SDEK)"GOCADOutput", True ); self->maps[map_i]->nodeValues = 0; self->maps[map_i]->nodeCoords = 0; self->maps[map_i]->topNodesCount = 0; } ContextEP_Append( self->context, AbstractContext_EP_Dump, Geothermal_FieldMaps_Dump ); }
void _GALEDivergenceForce_AssignFromXML( void* forceTerm, Stg_ComponentFactory* cf, void* data ) { GALEDivergenceForce* self = (GALEDivergenceForce*)forceTerm; Dictionary* dict; Stg_Shape* domainShape=NULL; FeMesh* geometryMesh=NULL; GALEStressBC_Entry force; char *type; /* Construct Parent */ _ForceTerm_AssignFromXML( self, cf, data ); dict = Dictionary_Entry_Value_AsDictionary( Dictionary_Get( cf->componentDict, self->name ) ); domainShape = Stg_ComponentFactory_ConstructByKey( cf, self->name, "DomainShape", Stg_Shape, True, data ) ; type = Stg_ComponentFactory_GetString( cf, self->name, "force_type", "" ); if(!strcasecmp(type,"double") || !strcasecmp(type,"float")) { force.type = GALEStressBC_Double; force.DoubleValue = Stg_ComponentFactory_GetDouble( cf, self->name, "force_value", 0.0 ); } else if(!strcasecmp(type,"func")) { char *funcName = Stg_ComponentFactory_GetString( cf, self->name, "force_value", "" ); Index cfIndex; cfIndex = ConditionFunction_Register_GetIndex ( condFunc_Register, funcName); force.type = GALEStressBC_ConditionFunction; if ( cfIndex == (unsigned)-1 ) { Stream* errorStr = Journal_Register( Error_Type, self->type ); Journal_Printf( errorStr, "Error- in %s: While parsing " "definition of GALEDivergenceForce, the cond. func. " " \"%s\" - wasn't found in the c.f. register.\n", __func__, funcName ); Journal_Printf( errorStr, "(Available functions in the C.F. register are: "); ConditionFunction_Register_PrintNameOfEachFunc ( condFunc_Register, errorStr ); Journal_Printf( errorStr, ")\n"); assert(0); } force.CFIndex = cfIndex; } else if(strlen(type)==0) { Stream* errorStr = Journal_Register( Error_Type, self->type ); Journal_Printf( errorStr, "Error- in %s: While parsing " "definition of GALEDivergenceForce, force_type is not specified.\nSupported types are \"double\" and \"function\".\n", __func__); assert(0); } else { Stream* errorStr = Journal_Register( Error_Type, self->type ); Journal_Printf( errorStr, "Error- in %s: While parsing " "definition of GALEDivergenceForce, the type of condition \"%s\"\nis not supported. Supported types are \"double\" and \"function\".\n", __func__, type ); assert(0); } geometryMesh=Stg_ComponentFactory_ConstructByKey( cf, self->name, "GeometryMesh", FeMesh, True, data ) ; _GALEDivergenceForce_Init( self, domainShape, geometryMesh, force); }
void _MeshGenerator_AssignFromXML( void* meshGenerator, Stg_ComponentFactory* cf, void* data ) { MeshGenerator* self = (MeshGenerator*)meshGenerator; Dictionary* dict; unsigned nDims; Dictionary_Entry_Value* meshList; Dictionary_Entry_Value *enabledDimsList, *enabledIncList; Mesh* mesh; Bool partitioned; assert( self ); assert( cf ); /* Rip out the components structure as a dictionary. */ dict = Dictionary_Entry_Value_AsDictionary( Dictionary_Get( cf->componentDict, (Dictionary_Entry_Key)self->name ) ); /* Set the communicator to a default. */ partitioned = Stg_ComponentFactory_GetBool( cf, self->name, (Dictionary_Entry_Key)"partitioned", 1 ); if( partitioned ) { MeshGenerator_SetMPIComm( self, MPI_COMM_WORLD ); } else { MeshGenerator_SetMPIComm( self, MPI_COMM_SELF ); } self->context = Stg_ComponentFactory_ConstructByKey( cf, self->name, (Dictionary_Entry_Key)"Context", AbstractContext, False, data ); if( !self->context ) self->context = Stg_ComponentFactory_ConstructByName( cf, (Name)"context", AbstractContext, False, data ); /* Read the individual mesh if specified. */ mesh = Stg_ComponentFactory_ConstructByKey( cf, self->name, (Dictionary_Entry_Key)"mesh", Mesh, False, data ); if( mesh ) MeshGenerator_AddMesh( self, mesh ); /* Read the mesh list, if it's there. */ meshList = Dictionary_Get( dict, (Dictionary_Entry_Key)"meshes" ); if( meshList ) { unsigned nMeshes; char* name; unsigned m_i; nMeshes = Dictionary_Entry_Value_GetCount( meshList ); for( m_i = 0; m_i < nMeshes; m_i++ ) { Mesh* mesh; name = Dictionary_Entry_Value_AsString( Dictionary_Entry_Value_GetElement( meshList, m_i ) ); mesh = Stg_ComponentFactory_ConstructByName( cf, (Name)name, Mesh, True, data ); MeshGenerator_AddMesh( self, mesh ); } } /* Read dimensions and state. */ nDims = Stg_ComponentFactory_GetUnsignedInt( cf, self->name, (Dictionary_Entry_Key)"dim", 2 ); nDims = Stg_ComponentFactory_GetUnsignedInt( cf, self->name, (Dictionary_Entry_Key)"dims", nDims ); MeshGenerator_SetDimSize( self, nDims ); enabledDimsList = Dictionary_Get( dict, (Dictionary_Entry_Key)"enabledDims" ); enabledIncList = Dictionary_Get( dict, (Dictionary_Entry_Key)"enabledIncidence" ); /* Clear dims/incidence flags */ unsigned d_i; memset( self->enabledDims, 0, (nDims + 1) * sizeof(Bool) ); for( d_i = 0; d_i <= nDims; d_i++ ) memset( self->enabledInc[d_i], 0, (nDims + 1) * sizeof(Bool) ); if( enabledDimsList ) { unsigned dim; unsigned nEnabledDims; nEnabledDims = Dictionary_Entry_Value_GetCount( enabledDimsList ); for( d_i = 0; d_i < nEnabledDims; d_i++ ) { dim = Dictionary_Entry_Value_AsUnsignedInt( Dictionary_Entry_Value_GetElement( enabledDimsList, d_i ) ); if (dim > nDims) Journal_Printf(Mesh_Warning, "Warning - in %s: *** Skipping out of range dimension: %d\n", __func__, dim); else MeshGenerator_SetDimState( self, dim, True ); } } else { /* Default to all dimensions enabled */ for( d_i = 0; d_i < nDims + 1; d_i++ ) MeshGenerator_SetDimState( self, d_i, True ); } if( enabledIncList ) { unsigned nEnabledInc; unsigned fromDim, toDim; nEnabledInc = Dictionary_Entry_Value_GetCount( enabledIncList ); assert( nEnabledInc % 2 == 0 ); for( d_i = 0; d_i < nEnabledInc; d_i += 2 ) { fromDim = Dictionary_Entry_Value_AsUnsignedInt( Dictionary_Entry_Value_GetElement( enabledIncList, d_i ) ); toDim = Dictionary_Entry_Value_AsUnsignedInt( Dictionary_Entry_Value_GetElement( enabledIncList, d_i + 1 ) ); if (fromDim > nDims || toDim > nDims) Journal_Printf( Mesh_Warning, "Warning - in %s: *** Skipping out of range incidence: %d to %d\n", __func__ , fromDim, toDim); else MeshGenerator_SetIncidenceState( self, fromDim, toDim, True ); } } else { /* Default incidence setup 0->1,2,3 1->0,2 2->0,1 3->0,3 */ MeshGenerator_SetIncidenceState( self, 0, 0, True ); for( d_i = 1; d_i <= nDims; d_i ++ ) { MeshGenerator_SetIncidenceState( self, 0, d_i, True ); MeshGenerator_SetIncidenceState( self, d_i, 0, True ); } if (nDims == 2) { MeshGenerator_SetIncidenceState( self, 1, 2, True ); MeshGenerator_SetIncidenceState( self, 2, 1, True ); MeshGenerator_SetIncidenceState( self, 2, 2, True ); } if( nDims == 3 ) MeshGenerator_SetIncidenceState( self, 3, 3, True ); } }
/* TODO: Need to find a way to add different communicators for different contexts. */ Stg_ComponentFactory* stgMainConstruct( Dictionary* dictionary, Dictionary* sources, MPI_Comm communicator, void* _context ) { Stg_ComponentFactory* cf; Dictionary* componentDict; Stg_Component* component; AbstractContext* context=NULL; unsigned component_I; char* timeStamp; time_t currTime; struct tm* timeInfo; int adjustedYear; int adjustedMonth; unsigned rank; MPI_Comm_rank( communicator, &rank ); currTime = time( NULL ); timeInfo = localtime( &currTime ); /* See man localtime() for why to adjust these. */ adjustedYear = 1900 + timeInfo->tm_year; adjustedMonth = 1 + timeInfo->tm_mon; Stg_asprintf( &timeStamp, "%.4d.%.2d.%.2d-%.2d.%.2d.%.2d", adjustedYear, adjustedMonth, timeInfo->tm_mday, timeInfo->tm_hour, timeInfo->tm_min, timeInfo->tm_sec ); if( ( componentDict = Dictionary_Entry_Value_AsDictionary( Dictionary_Get( dictionary, (Dictionary_Entry_Key)"components" ) ) ) == NULL ) componentDict = Dictionary_New(); CheckDictionaryKeys( componentDict, "Component dictionary must have unique names\n" ); /* lets go right ahead and delete the component register. */ /* this is mainly required for the pcu tests which pass through here a number of times without calling StGermain_Finalise */ LiveComponentRegister_Delete(); cf = Stg_ComponentFactory_New( dictionary, componentDict ); if( _context ) { context = (AbstractContext*)_context; context->CF = cf; context->dictionary = dictionary; context->communicator = communicator; context->timeStamp = timeStamp; LiveComponentRegister_Add( cf->LCRegister, (Stg_Component*)context ); } /* Instantion phase. */ Stg_ComponentFactory_CreateComponents( cf ); /* * Assign the dictionary, componentFactory & the communicator for the contexts. * TODO: if different contexts require different communicators, * then StG. components will be required for these, and they should be passed in from the XML * Also, this is a little hacky, as nothing is known about the other * layers of StG or their associated contexts here. */ for( component_I = 0; component_I < LiveComponentRegister_GetCount( cf->LCRegister ); component_I++ ) { component = LiveComponentRegister_At( cf->LCRegister, component_I ); if( Stg_CompareType( component, AbstractContext ) ) { Journal_Firewall( dictionary->count, Journal_Register( Error_Type, "Error Stream" ), "Error in %s: The dictionary is empty, " "meaning no input parameters have been feed into your program. " "Perhaps you've forgot to pass any input files ( or command-line arguments ) in.\n", __func__ ); context = (AbstractContext*)component; context->dictionary = dictionary; context->CF = cf; context->timeStamp = timeStamp; //context->communicator = communicator; } } /* generate the Flattened xml file last once Scaling has occured */ if( rank==0 ) stgGenerateFlattenedXML( dictionary, sources, timeStamp ); /* Construction phase. */ Stg_ComponentFactory_ConstructComponents( cf, NULL ); return cf; }
void _FieldVariable_AssignFromXML( void* fieldVariable, Stg_ComponentFactory* cf, void* data ) { FieldVariable* self = (FieldVariable*)fieldVariable; FieldVariable_Register* fV_Register=NULL; Dimension_Index dim; Index fieldComponentCount; Bool isCheckpointedAndReloaded, isCheckpointedAndReloaded2; Dictionary_Entry_Value* feVarsList = NULL; char* o_units = NULL; DomainContext* context; Bool useCacheMaxMin; context = Stg_ComponentFactory_ConstructByKey( cf, self->name, (Dictionary_Entry_Key)"Context", DomainContext, False, data ); if( !context ) context = Stg_ComponentFactory_ConstructByName( cf, (Name)"context", DomainContext, False, data ); if (context) { fV_Register = context->fieldVariable_Register; assert( fV_Register ); } dim = Stg_ComponentFactory_GetRootDictUnsignedInt( cf, (Dictionary_Entry_Key)"dim", 0 ); /* allow this to be overwritten by the component dub dict */ dim = Stg_ComponentFactory_GetUnsignedInt( cf, self->name, (Dictionary_Entry_Key)"dim", dim ); fieldComponentCount = Stg_ComponentFactory_GetUnsignedInt( cf, self->name, (Dictionary_Entry_Key)"fieldComponentCount", 0 ); useCacheMaxMin = Stg_ComponentFactory_GetBool( cf, self->name, (Dictionary_Entry_Key)"useCacheMaxMin", False ); o_units = Stg_ComponentFactory_GetString( cf, self->name, (Dictionary_Entry_Key)"outputUnits", NULL ); /* * Decide whether this FieldVariable will be checkpointed & reloaded, based on the dictionary list * "fieldVariableToCheckpoint". NB may want to put this in the XML component definintion of a * FieldVariable itself, but for now prefer list so it can be centrally set. * -- Pat, Jules, Kath - 29 November 2006 */ isCheckpointedAndReloaded2 = Stg_ComponentFactory_GetBool( cf, self->name, (Dictionary_Entry_Key)"isCheckpointedAndReloaded", False ); /* Case insensitive search */ feVarsList = Dictionary_Get( cf->rootDict, (Dictionary_Entry_Key)"fieldVariablesToCheckpoint" ); if( NULL == feVarsList ) { feVarsList = Dictionary_Get( cf->rootDict, (Dictionary_Entry_Key)"FieldVariablesToCheckpoint" ); } if( feVarsList != NULL ) { Index listLength = Dictionary_Entry_Value_GetCount( feVarsList ); Index var_I = 0; Dictionary_Entry_Value* feVarDictValue = NULL; char* fieldVariableName; /* if the 'fieldVariablesToCheckpoint' list is empty (but exists) * checkpoint every field * else selectively checkpoint based on list entries */ if( listLength == 0 ) { isCheckpointedAndReloaded = True; } else { isCheckpointedAndReloaded = False; for ( var_I = 0; var_I < listLength; var_I++ ) { feVarDictValue = Dictionary_Entry_Value_GetElement( feVarsList, var_I ); fieldVariableName = Dictionary_Entry_Value_AsString( feVarDictValue ); if ( 0 == strcmp( self->name, fieldVariableName ) ) { isCheckpointedAndReloaded = True; break; } } } } else { /* If there's no special list, just checkpoint/reload everything. */ isCheckpointedAndReloaded = True; } isCheckpointedAndReloaded = (isCheckpointedAndReloaded || isCheckpointedAndReloaded2 ); feVarsList = NULL; /* also include check to see if this fevariable should be saved for analysis purposes */ feVarsList = Dictionary_Get( cf->rootDict, (Dictionary_Entry_Key)"fieldVariablesToSave" ); if( NULL == feVarsList ) { feVarsList = Dictionary_Get( cf->rootDict, (Dictionary_Entry_Key)"FieldVariablesToSave" ); } if( feVarsList != NULL ) { Index listLength = Dictionary_Entry_Value_GetCount( feVarsList ); Index var_I = 0; Dictionary_Entry_Value* feVarDictValue = NULL; char* fieldVariableName; for( var_I = 0; var_I < listLength; var_I++ ) { feVarDictValue = Dictionary_Entry_Value_GetElement( feVarsList, var_I ); fieldVariableName = Dictionary_Entry_Value_AsString( feVarDictValue ); if( 0 == strcmp( self->name, fieldVariableName ) ) { self->isSavedData = True; break; } } } _FieldVariable_Init( self, context, fieldComponentCount, dim, isCheckpointedAndReloaded, o_units, MPI_COMM_WORLD, fV_Register, useCacheMaxMin ); }
void _MeshVariable_AssignFromXML( void* meshVariable, Stg_ComponentFactory* cf, void* data ) { MeshVariable* self = (MeshVariable*)meshVariable; SizeT dataOffsets[] = { 0 }; StgVariable_DataType dataTypes[] = { 0 }; /* Init value later */ Index dataTypeCounts[] = { 1 }; Dictionary* componentDict = NULL; Dictionary* thisComponentDict = NULL; Name dataTypeName = NULL; Name rankName = NULL; void* variableRegister = NULL; Name* names = NULL; Stream* error = Journal_Register( Error_Type, (Name)self->type ); Mesh* mesh; AbstractContext* context; assert( self ); componentDict = cf->componentDict; assert( componentDict ); thisComponentDict = Dictionary_GetDictionary( componentDict, self->name ); assert( thisComponentDict ); context = Stg_ComponentFactory_ConstructByKey( cf, self->name, (Dictionary_Entry_Key)"Context", AbstractContext, False, data ); if( !context ) context = Stg_ComponentFactory_ConstructByName( cf, (Name)"context", AbstractContext, False, data ); /* Grab Registers */ if(context) variableRegister = context->variable_Register; /* Construct the mesh. */ mesh = Stg_ComponentFactory_ConstructByKey( cf, self->name, (Dictionary_Entry_Key)"mesh", Mesh, True, data ); MeshVariable_SetMesh( self, mesh ); /* Get the topological element we're intereseted in. */ self->topoDim = Stg_ComponentFactory_GetUnsignedInt( cf, self->name, (Dictionary_Entry_Key)"topologicalDim", 0 ); /* Get Type of Variable */ dataTypeName = Dictionary_GetString( thisComponentDict, (Dictionary_Entry_Key)"DataType" ); if ( !strcasecmp( dataTypeName, "Double" ) ) dataTypes[0] = StgVariable_DataType_Double; else if ( !strcasecmp( dataTypeName, "Float" ) ) dataTypes[0] = StgVariable_DataType_Float; else if ( !strcasecmp( dataTypeName, "Int" ) ) dataTypes[0] = StgVariable_DataType_Int; else if ( !strcasecmp( dataTypeName, "Char" ) ) dataTypes[0] = StgVariable_DataType_Char; else if ( !strcasecmp( dataTypeName, "Short" ) ) dataTypes[0] = StgVariable_DataType_Short; else Journal_Firewall( False, error, "Variable '%s' cannot understand data type '%s'\n", self->name, dataTypeName ); /* Get Rank of Variable - i.e. Scalar or Vector */ rankName = Dictionary_GetString( thisComponentDict, (Dictionary_Entry_Key)"Rank" ); if( !strcasecmp( rankName, "Scalar" ) ){ dataTypeCounts[0] = 1; } else if ( !strcasecmp( rankName, "Vector" ) ){ Dictionary_Entry_Value* list; Index nameCount = 0; dataTypeCounts[0] = Stg_ComponentFactory_GetUnsignedInt( cf, self->name, (Dictionary_Entry_Key)"VectorComponentCount", nameCount ); /* Get Names from list */ if (( list = Dictionary_Get( thisComponentDict, (Dictionary_Entry_Key)"names" ) )) { Index entry_I; nameCount = Dictionary_Entry_Value_GetCount( list ); names = Memory_Alloc_Array( Name, nameCount, "Variable Names" ); for ( entry_I = 0 ; entry_I < nameCount ; entry_I++ ) names[ entry_I ] = Dictionary_Entry_Value_AsString( Dictionary_Entry_Value_GetElement(list, entry_I ) ); Journal_Firewall( nameCount >= dataTypeCounts[0], error, "Variable '%s' has too few names in list for %d vector components.\n", self->name, dataTypeCounts[0] ); } } else Journal_Firewall( False, error, "Variable '%s' cannot understand rank '%s'\n", self->name, rankName ); _StgVariable_Init( (StgVariable*)self, context, 1, dataOffsets, dataTypes, dataTypeCounts, names, 0, NULL, _MeshVariable_GetMeshArraySize, (void**)&self->arrayPtr, True, variableRegister ); /* Clean Up */ if (names) Memory_Free(names); }
void _SnacRemesher_ConstructExtensions( void* _context, void* data ) { Snac_Context* context = (Snac_Context*)_context; SnacRemesher_Context* contextExt = ExtensionManager_Get( context->extensionMgr, context, SnacRemesher_ContextHandle ); Mesh* mesh = context->mesh; SnacRemesher_Mesh* meshExt = ExtensionManager_Get( context->meshExtensionMgr, mesh, SnacRemesher_MeshHandle ); char* conditionStr; Dictionary_Entry_Value* conditionCriterion; Dictionary* meshDict; Stream* error = Journal_Register( Error_Type, "Remesher" ); char tmpBuf[PATH_MAX]; Journal_Printf( context->debug, "In: %s\n", __func__ ); contextExt->debugIC = Journal_Register( Debug_Type, "Remesher-ICs" ); contextExt->debugCoords = Journal_Register( Debug_Type, "Remesher-Coords" ); contextExt->debugNodes = Journal_Register( Debug_Type, "Remesher-Nodes" ); contextExt->debugElements = Journal_Register( Debug_Type, "Remesher-Elements" ); contextExt->debugSync = Journal_Register( Debug_Type, "Remesher-Sync" ); /* Additional tables required over the nodeElementTbl already required by core Snac */ Mesh_ActivateNodeNeighbourTbl( mesh ); Mesh_ActivateElementNeighbourTbl( mesh ); /* Work out condition to remesh on */ if( !Dictionary_Get( context->dictionary, CONDITION_STR ) ) { Journal_Printf( error, "Warning: No \"%s\" entry in dictionary... will default to \"%s\"\n", CONDITION_STR, OFF_STR ); } conditionStr = Dictionary_Entry_Value_AsString( Dictionary_GetDefault( context->dictionary, CONDITION_STR, Dictionary_Entry_Value_FromString( OFF_STR ) ) ); contextExt->OnTimeStep = 0; contextExt->onMinLengthScale = 0; if( !strcmp( conditionStr, OFF_STR ) ) { contextExt->condition = SnacRemesher_Off; Journal_Printf( context->snacInfo, "Remesher is off\n" ); } else if( !strcmp( conditionStr, ONTIMESTEP_STR ) ) { contextExt->condition = SnacRemesher_OnTimeStep; conditionCriterion = Dictionary_Get( context->dictionary, TIMESTEPCRITERION_STR ); Journal_Printf( context->snacInfo, "Remesher is on... activated based on timeStep\n" ); if( conditionCriterion ) { contextExt->OnTimeStep = Dictionary_Entry_Value_AsUnsignedInt( conditionCriterion ); } else { } Journal_Printf( context->snacInfo, "Remeshing every %u timeSteps\n", contextExt->OnTimeStep ); } else if( !strcmp( conditionStr, ONMINLENGTHSCALE_STR ) ) { contextExt->condition = SnacRemesher_OnMinLengthScale; conditionCriterion = Dictionary_Get( context->dictionary, LENGTHCRITERION_STR ); Journal_Printf( context->snacInfo, "Remesher is on... activated by minLengthScale\n" ); if( conditionCriterion ) { contextExt->onMinLengthScale = Dictionary_Entry_Value_AsDouble( conditionCriterion ); } else { } Journal_Printf( context->snacInfo, "Remesh when minLengthScale < %g\n", contextExt->onMinLengthScale ); } else if( !strcmp( conditionStr, ONBOTHTIMESTEPLENGTH_STR ) ) { contextExt->condition = SnacRemesher_OnBothTimeStepLength; conditionCriterion = Dictionary_Get( context->dictionary, TIMESTEPCRITERION_STR ); Journal_Printf( context->snacInfo, "Remesher is on... activated by both timeStep and minLengthScale\n" ); if( conditionCriterion ) { contextExt->OnTimeStep = Dictionary_Entry_Value_AsUnsignedInt( conditionCriterion ); conditionCriterion = Dictionary_Get( context->dictionary, LENGTHCRITERION_STR ); contextExt->onMinLengthScale = Dictionary_Entry_Value_AsDouble( conditionCriterion ); } else { } Journal_Printf( context->snacInfo, "Remesh every %u timeSteps or wheen minLengthScale < %g\n", contextExt->OnTimeStep, contextExt->onMinLengthScale ); } else { contextExt->condition = SnacRemesher_Off; Journal_Printf( context->snacInfo, "Remesher is defaulting to off\n" ); Journal_Printf( error, "Provided remesh condition \"%s\" unrecognised\n", conditionStr ); } /* Work out the mesh type */ meshDict = Dictionary_Entry_Value_AsDictionary( Dictionary_Get( context->dictionary, MESH_STR ) ); if( meshDict ) { char* meshTypeStr; if( !Dictionary_Get( meshDict, MESHTYPE_STR ) ) { Journal_Printf( error, "Warning: No \"%s\" entry in \"%s\"... will default to \"%s\"\n", MESHTYPE_STR, MESH_STR, CARTESIAN_STR ); } meshTypeStr = Dictionary_Entry_Value_AsString( Dictionary_GetDefault( meshDict, MESHTYPE_STR, Dictionary_Entry_Value_FromString( CARTESIAN_STR ) ) ); if( !strcmp( meshTypeStr, SPHERICAL_STR ) ) { meshExt->meshType = SnacRemesher_Spherical; Journal_Printf( context->snacInfo, "Remesher knows mesh as a spherical mesh\n" ); } else if( !strcmp( meshTypeStr, CARTESIAN_STR ) ) { meshExt->meshType = SnacRemesher_Cartesian; Journal_Printf( context->snacInfo, "Remesher knows mesh as a cartesian mesh\n" ); } else { meshExt->meshType = SnacRemesher_Cartesian; Journal_Printf( context->snacInfo, "Remesher assuming mesh as a cartesian mesh\n" ); Journal_Printf( error, "Provided mesh type \"%s\" unrecognised!\n", meshTypeStr ); } } else { meshExt->meshType = SnacRemesher_Cartesian; Journal_Printf( context->snacInfo, "Remesher assuming mesh as a cartesian mesh\n" ); Journal_Printf( error, "No \"%s\" entry in dictionary!\n", MESH_STR ); } /* Decide whether to restore the bottom surface */ contextExt->bottomRestore = 0; if( !strcmp( Dictionary_Entry_Value_AsString( Dictionary_GetDefault( context->dictionary, "bottomRestore", Dictionary_Entry_Value_FromString( OFF_STR ) ) ), ON_STR) ) contextExt->bottomRestore = 1; /* Register these functions for use in VCs */ ConditionFunction_Register_Add( context->condFunc_Register, ConditionFunction_New( _SnacRemesher_TestCondFunc, "SnacRemesher_TestCondFunc" ) ); /* Register these functions for use in VCs */ ConditionFunction_Register_Add( context->condFunc_Register, ConditionFunction_New( _SnacRemesher_XFunc, "SnacRemesher_XFunc" ) ); /* Register these functions for use in VCs */ ConditionFunction_Register_Add( context->condFunc_Register, ConditionFunction_New( _SnacRemesher_YFunc, "SnacRemesher_YFunc" ) ); /* Obtain the keys for the our new entry points... having the keys saves doing a string compare at run time */ contextExt->recoverNodeK = EntryPoint_Register_GetHandle( context->entryPoint_Register, SnacRemesher_EP_RecoverNode ); contextExt->interpolateNodeK = EntryPoint_Register_GetHandle( context->entryPoint_Register, SnacRemesher_EP_InterpolateNode ); contextExt->interpolateElementK = EntryPoint_Register_GetHandle( context->entryPoint_Register, SnacRemesher_EP_InterpolateElement ); /* Prepare the dump file */ if( context->rank == 0) { sprintf( tmpBuf, "%s/remeshInfo.%u", context->outputPath, context->rank ); if( (contextExt->remesherOut = fopen( tmpBuf, "w+" )) == NULL ) { assert( contextExt->remesherOut /* failed to open file for writing */ ); } } /* initialize remeshing counter */ contextExt->remeshingCount = 0; }