void _Geothermal_DepthMap_AssignFromXML( void* component, Stg_ComponentFactory* cf, void* data ) { Geothermal_DepthMap* self = (Geothermal_DepthMap*)component; Dictionary* dictionary = Codelet_GetPluginDictionary( component, cf->rootDict ); Stream* errorStream = Journal_Register( ErrorStream_Type, Geothermal_DepthMap_Type ); Stream_SetPrintingRank( errorStream, 0 ); Journal_Printf( errorStream, "WARNING: \"DepthMap\" plugin is depricated, use \"FieldMap\" plugin instead" ); self->swarm = Stg_ComponentFactory_ConstructByName( cf, Dictionary_GetString( dictionary, "Swarm" ), Swarm, True, data ); self->context = (AbstractContext*)Stg_ComponentFactory_ConstructByName( cf, "context", UnderworldContext, True, data ); self->depth = Dictionary_GetDouble_WithDefault( dictionary, (Dictionary_Entry_Key)"DepthFromSurface", 0.0 ); self->outputPath = Dictionary_GetString_WithDefault( dictionary, (Dictionary_Entry_Key)"outputPath", "./output" ); self->outputAllNodes = Dictionary_GetBool_WithDefault( dictionary, (Dictionary_Entry_Key)"OutputAllNodes", False ); self->outputTopNodes = Dictionary_GetBool_WithDefault( dictionary, (Dictionary_Entry_Key)"OutputTopNodes", False ); self->gocadOutput = Dictionary_GetBool_WithDefault( dictionary, (Dictionary_Entry_Key)"GOCADOutput", True ); self->outputPath = Dictionary_Entry_Value_AsString( Dictionary_Get( dictionary, "outputPath" ) ); self->field = Stg_ComponentFactory_ConstructByName( cf, Dictionary_GetString( dictionary, "Field" ), FeVariable, True, data ); ContextEP_Append( self->context, AbstractContext_EP_Dump, Geothermal_DepthMap_Dump ); }
Bool _Stg_ComponentFactory_GetRootDictBool( void* cf, Dictionary_Entry_Key key, const Bool defaultVal ) { Stg_ComponentFactory* self = (Stg_ComponentFactory*)cf; Journal_PrintfL( self->infoStream, 2, "Getting Bool from root dictionary with key '%s' and default value '%s'\n", key, defaultVal ? "True" : "False" ); assert( self->rootDict ); return Dictionary_GetBool_WithDefault( self->rootDict, key, defaultVal ); }
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" ) ); }
void _MaterialPointsSwarm_AssignFromXML( void* swarm, Stg_ComponentFactory* cf, void* data ) { MaterialPointsSwarm* self = (MaterialPointsSwarm*) swarm; EscapedRoutine* escapedRoutine; Material* material; Materials_Register* materials_Register; PICelleratorContext* context; _GeneralSwarm_AssignFromXML( self, cf, data ); material = Stg_ComponentFactory_ConstructByKey( cf, self->name, (Dictionary_Entry_Key)"Material", Material, False, data ); context = (PICelleratorContext* )self->context; assert( Stg_CheckType( context, PICelleratorContext ) ); materials_Register = context->materials_Register; assert( materials_Register ); _MaterialPointsSwarm_Init( self, material, materials_Register ); self->overrideMaterialCheck = Stg_ComponentFactory_GetBool( cf, self->name, (Dictionary_Entry_Key)"overrideMaterialCheck", False ); self->geomodHack = Dictionary_GetBool_WithDefault( cf->rootDict, (Dictionary_Entry_Key)"geomodHacks", False ); }
void _ParticleMelting_Build( void* _self, void* data ) { ParticleMelting* self = (ParticleMelting*) _self; Materials_Register* matReg = self->materialSwarm->materials_Register; ParticleMelting_MatExt *matExt = NULL; unsigned materialCount, mat_i; Material* material = NULL; Stg_Component_Build( self->temperatureField, data, False ); Stg_Component_Build( self->materialSwarm, data, False ); if( self->pressureField ) Stg_Component_Build( self->pressureField, data, False ); if( self->scaling ) { Stg_Component_Build( self->scaling, data, False ); self->refRho = Scaling_Scale( self->scaling, 3400, sDensity ); self->gravity = Scaling_Scale( self->scaling, 9.81, sAcceleration ); } else { self->refRho = 1.0; self->gravity = 1.0; } /* now we extend the materials with ParticleMelting_MatExt */ self->materialExtHandle = Materials_Register_AddMaterialExtension( matReg, self->type, sizeof(ParticleMelting_MatExt) ); materialCount = Materials_Register_GetCount( matReg ); for( mat_i = 0 ; mat_i < materialCount ; mat_i++ ) { material = Materials_Register_GetByIndex( matReg, mat_i ); matExt = ExtensionManager_Get( material->extensionMgr, material, self->materialExtHandle ); /* get latent heat and specific heat from the material dictionary */ matExt->lhf = Dictionary_GetDouble_WithDefault( material->dictionary, (Dictionary_Entry_Key)"latentHeat_Fusion", 0.0 ); matExt->Cp = Dictionary_GetDouble_WithDefault( material->dictionary, (Dictionary_Entry_Key)"Cp", 1.0 ); matExt->TurnMeltOn = Dictionary_GetBool_WithDefault( material->dictionary, (Dictionary_Entry_Key)"TurnMeltOn", 0.0 ); /* read in values from xml file for solidus polynomial */ matExt->sCoeff[0] = Dictionary_GetDouble_WithDefault( material->dictionary, (Dictionary_Entry_Key)"solidus_coeff0", 0.0 ); matExt->sCoeff[1] = Dictionary_GetDouble_WithDefault( material->dictionary, (Dictionary_Entry_Key)"solidus_coeff1", 0.0 ); matExt->sCoeff[2] = Dictionary_GetDouble_WithDefault( material->dictionary, (Dictionary_Entry_Key)"solidus_coeff2", 0.0 ); matExt->sCoeff[3] = Dictionary_GetDouble_WithDefault( material->dictionary, (Dictionary_Entry_Key)"solidus_coeff3", 0.0 ); /* read in values from xml file for liquidus polynomial */ matExt->lCoeff[0] = Dictionary_GetDouble_WithDefault( material->dictionary, (Dictionary_Entry_Key)"liquidus_coeff0", 0.0 ); matExt->lCoeff[1] = Dictionary_GetDouble_WithDefault( material->dictionary, (Dictionary_Entry_Key)"liquidus_coeff1", 0.0 ); matExt->lCoeff[2] = Dictionary_GetDouble_WithDefault( material->dictionary, (Dictionary_Entry_Key)"liquidus_coeff2", 0.0 ); matExt->lCoeff[3] = Dictionary_GetDouble_WithDefault( material->dictionary, (Dictionary_Entry_Key)"liquidus_coeff3", 0.0 ); matExt->deepPressure = Dictionary_GetDouble_WithDefault( material->dictionary, (Dictionary_Entry_Key)"deepPressure", 0.0 ); /* read in values from xml file for solidus polynomial (deep)*/ matExt->sCoeffDeep[0] = Dictionary_GetDouble_WithDefault( material->dictionary, (Dictionary_Entry_Key)"solidus_coeff0_deep", matExt->sCoeff[0] ); matExt->sCoeffDeep[1] = Dictionary_GetDouble_WithDefault( material->dictionary, (Dictionary_Entry_Key)"solidus_coeff1_deep", matExt->sCoeff[1] ); matExt->sCoeffDeep[2] = Dictionary_GetDouble_WithDefault( material->dictionary, (Dictionary_Entry_Key)"solidus_coeff2_deep", matExt->sCoeff[2] ); matExt->sCoeffDeep[3] = Dictionary_GetDouble_WithDefault( material->dictionary, (Dictionary_Entry_Key)"solidus_coeff3_deep", matExt->sCoeff[3] ); /* read in values from xml file for liquidus polynomial */ matExt->lCoeffDeep[0] = Dictionary_GetDouble_WithDefault( material->dictionary, (Dictionary_Entry_Key)"liquidus_coeff0_deep", matExt->lCoeff[0] ); matExt->lCoeffDeep[1] = Dictionary_GetDouble_WithDefault( material->dictionary, (Dictionary_Entry_Key)"liquidus_coeff1_deep", matExt->lCoeff[1] ); matExt->lCoeffDeep[2] = Dictionary_GetDouble_WithDefault( material->dictionary, (Dictionary_Entry_Key)"liquidus_coeff2_deep", matExt->lCoeff[2] ); matExt->lCoeffDeep[3] = Dictionary_GetDouble_WithDefault( material->dictionary, (Dictionary_Entry_Key)"liquidus_coeff3_deep", matExt->lCoeff[3] ); } EP_PrependClassHook_AlwaysFirst( Context_GetEntryPoint( self->context, AbstractContext_EP_UpdateClass ), ParticleMelting_MeltFrationUpdate, self ); /* EP_InsertClassHookBefore( Context_GetEntryPoint( self->context, AbstractContext_EP_UpdateClass ), "_ParticleFeVariable_Execute", ParticleMelting_MeltFrationUpdate, self ); */ }
void _MeshDecomp_Init( MeshDecomp* self, MPI_Comm communicator, ElementLayout* elementLayout, NodeLayout* nodeLayout, Stg_ObjectList* pointer_Register ) { /* General and Virtual info should already be set */ /* MeshDecomp info */ char* storageStr; self->isConstructed = True; self->communicator = communicator; MPI_Comm_rank( self->communicator, (int*)&self->rank ); MPI_Comm_size( self->communicator, (int*)&self->nproc ); self->procsInUse = 0; self->allowUnusedCPUs = Dictionary_GetBool_WithDefault( self->dictionary, "allowUnusedCPUs", False ) ; self->allowPartitionOnNode = Dictionary_GetBool_WithDefault( self->dictionary, "allowPartitionOnNode", True ); self->allowPartitionOnElement = Dictionary_GetBool_WithDefault( self->dictionary, "allowPartitionOnElement", False ); assert( self->allowPartitionOnNode || self->allowPartitionOnElement ); self->allowUnbalancing = Dictionary_GetBool_WithDefault( self->dictionary, "allowUnbalancing", False ); self->procTopology = NULL; /* Determine IndexSet storage type */ storageStr = Dictionary_GetString_WithDefault( self->dictionary, "selfStorage", "storeNeighbours" ); if( !strcmp( storageStr, "storeAll" ) ) { self->storage = StoreAll; } else if( !strcmp( storageStr, "storeSelf" ) ) { self->storage = StoreSelf; } else { /* !strcmp( storageStr, "storeNeighbours" ) */ self->storage = StoreNeighbours; } self->elementLayout = elementLayout; self->nodeLayout = nodeLayout; self->localElementSets = NULL; self->shadowElementSets = NULL; self->localNodeSets = NULL; self->shadowNodeSets = NULL; self->nodeGlobalCount = 0; self->nodeLocalCount = 0; self->nodeShadowCount = 0; self->nodeDomainCount = 0; self->elementGlobalCount = 0; self->elementLocalCount = 0; self->elementShadowCount = 0; self->elementDomainCount = 0; /* TODO - Hack: Registering pointer to node domain count */ if (pointer_Register) { Name nodeDomainCountName; Stg_asprintf( &nodeDomainCountName, "%s-nodeDomainCount", self->name ); /* Need to free memory somewhere! */ Stg_ObjectList_GlobalPointerAppend( pointer_Register, &self->nodeDomainCount, nodeDomainCountName ); } }