void _SUPGAdvDiffTermPpc_AssignFromXML( void* residual, Stg_ComponentFactory* cf, void* data ) { SUPGAdvDiffTermPpc* self = (SUPGAdvDiffTermPpc*)residual; PpcManager* mgr = NULL; /* Construct Parent */ _ForceTerm_AssignFromXML( self, cf, data ); /* The PpcManager */ mgr = Stg_ComponentFactory_ConstructByKey( cf, self->name, (Dictionary_Entry_Key)"Manager", PpcManager, False, data ); if ( !mgr ) mgr = Stg_ComponentFactory_ConstructByName( cf, (Name)"default_ppcManager", PpcManager, True, data ); _SUPGAdvDiffTermPpc_Init( self, mgr, Stg_ComponentFactory_ConstructByNameWithKeyFallback( cf, self->name, (Dictionary_Entry_Key)"default_EnergyEqn", (Dictionary_Entry_Key)"EnergyEqn", AdvectionDiffusionSLE, True, data ), Stg_ComponentFactory_ConstructByKey( cf, self->name, (Dictionary_Entry_Key)"VelocityField", FeVariable, True, data ), Stg_ComponentFactory_ConstructByKey( cf, self->name, (Dictionary_Entry_Key)"PhiField", FeVariable, True, data ), Stg_ComponentFactory_GetString( cf, self->name, (Dictionary_Entry_Key)"UpwindXiFunction", "Exact" ), PpcManager_GetPpcFromDict( mgr, cf, self->name, (Dictionary_Entry_Key)"DiffusivityLabel", "DiffusivityLabel" ) ); }
void _lucSwarmVectors_AssignFromXML( void* drawingObject, Stg_ComponentFactory* cf, void* data ) { lucSwarmVectors* self = (lucSwarmVectors*)drawingObject; /* Construct Parent */ _lucSwarmViewer_AssignFromXML( self, cf, data ); _lucSwarmVectors_Init( self, Stg_ComponentFactory_GetString( cf, self->name, (Dictionary_Entry_Key)"DirectionVariable", "" ), Stg_ComponentFactory_GetDouble( cf, self->name, (Dictionary_Entry_Key)"arrowHeadSize", 2.0 ), Stg_ComponentFactory_GetString( cf, self->name, (Dictionary_Entry_Key)"ThicknessVariable", "" ), Stg_ComponentFactory_GetDouble( cf, self->name, (Dictionary_Entry_Key)"thickness", 0.0 ), Stg_ComponentFactory_GetString( cf, self->name, (Dictionary_Entry_Key)"LengthVariable", "" ), Stg_ComponentFactory_GetDouble( cf, self->name, (Dictionary_Entry_Key)"length", 1.0 ) ); }
void _Ppc_Switch_AssignFromXML( void* _self, Stg_ComponentFactory* cf, void* data ) { Ppc_Switch* self = (Ppc_Switch*)_self; Dictionary* theDictionary = NULL; Dictionary_Entry_Value* caseEntry = NULL; Dictionary_Entry_Value* tagList = NULL; Index case_I; char* ppcName; /* Construct parent */ _Ppc_AssignFromXML( self, cf, data ); /* The dictionary */ theDictionary = Dictionary_Entry_Value_AsDictionary( Dictionary_Get( cf->componentDict, (Dictionary_Entry_Key)self->name ) ); /* Read the properties list */ tagList = Dictionary_Get( theDictionary, (Dictionary_Entry_Key)"CaseList" ); assert( tagList ); self->caseCount = Dictionary_Entry_Value_GetCount( tagList ); self->caseList = Memory_Alloc_Array( Ppc_Switch_Case, self->caseCount, "Ppc_Switch_caseList" ); for( case_I = 0; case_I < self->caseCount; case_I++ ){ caseEntry = Dictionary_Entry_Value_GetElement( tagList, case_I ); /* get case value */ self->caseList[case_I].constant = Dictionary_Entry_Value_AsDouble( Dictionary_Entry_Value_GetMember( caseEntry, (Dictionary_Entry_Key)"Case") ); /* get ppc associated with the case*/ ppcName = Dictionary_Entry_Value_AsString( Dictionary_Entry_Value_GetMember( caseEntry, (Dictionary_Entry_Key)"Value") ); self->caseList[case_I].valueTag = PpcManager_GetPpcByName( self->manager, cf, (Name)ppcName ); } /* Init */ _Ppc_Switch_Init( self, Stg_ComponentFactory_GetString( cf, self->name, (Dictionary_Entry_Key)"Interpolate", "" ), PpcManager_GetPpcFromDict( self->manager, cf, self->name, (Dictionary_Entry_Key)"Field", "" ) ); }
void _FileParticleLayout_Construct( void* particleLayout, Stg_ComponentFactory *cf, void* data ) { FileParticleLayout* self = (FileParticleLayout*) particleLayout; Name filename; filename = Stg_ComponentFactory_GetString( cf, self->name, "filename", "Swarm.dat" ); _FileParticleLayout_Init( self, filename ); }
void _lucAxis_AssignFromXML( void* axis, Stg_ComponentFactory* cf, void* data ) { lucAxis* self = (lucAxis*) axis; Name colourNameX; Name colourNameY; Name colourNameZ; Coord origin; /* Construct Parent */ _lucDrawingObject_AssignFromXML( self, cf, data ); colourNameX = Stg_ComponentFactory_GetString( cf, self->name, (Dictionary_Entry_Key)"colourX", "Red" ) ; colourNameY = Stg_ComponentFactory_GetString( cf, self->name, (Dictionary_Entry_Key)"colourY", "Green" ) ; colourNameZ = Stg_ComponentFactory_GetString( cf, self->name, (Dictionary_Entry_Key)"colourZ", "Blue" ) ; lucColour_FromString( &self->colours[0], colourNameX ); lucColour_FromString( &self->colours[1], colourNameY ); lucColour_FromString( &self->colours[2], colourNameZ ); origin[I_AXIS] = Stg_ComponentFactory_GetDouble( cf, self->name, (Dictionary_Entry_Key)"originX", 32.0 ); origin[J_AXIS] = Stg_ComponentFactory_GetDouble( cf, self->name, (Dictionary_Entry_Key)"originY", 32.0 ); origin[K_AXIS] = Stg_ComponentFactory_GetDouble( cf, self->name, (Dictionary_Entry_Key)"originZ", 0.25 ); _lucAxis_Init( self, origin, Stg_ComponentFactory_GetDouble( cf, self->name, (Dictionary_Entry_Key)"length", 0.2 ), Stg_ComponentFactory_GetString( cf, self->name, (Dictionary_Entry_Key)"axes", "xyz" ), Stg_ComponentFactory_GetString( cf, self->name, (Dictionary_Entry_Key)"labelX", "X" ), Stg_ComponentFactory_GetString( cf, self->name, (Dictionary_Entry_Key)"labelY", "Y" ), Stg_ComponentFactory_GetString( cf, self->name, (Dictionary_Entry_Key)"labelZ", "Z" ), self->colours[0], self->colours[1], self->colours[2]); }
void _lucScalarField_AssignFromXML( void* drawingObject, Stg_ComponentFactory* cf, void* data ) { lucScalarField* self = (lucScalarField*)drawingObject; /* Construct Parent */ _lucScalarFieldCrossSection_AssignFromXML( self, cf, data ); _lucScalarField_Init(self, Stg_ComponentFactory_GetString( cf, self->name, (Dictionary_Entry_Key)"drawSides", "xyzXYZ")); }
void _Remesher_Construct( void* remesher, Stg_ComponentFactory* cf, void* data ) { Remesher* self = (Remesher*)remesher; char* meshName; assert( self ); assert( cf ); assert( cf->componentDict ); meshName = Stg_ComponentFactory_GetString( cf, self->name, "mesh", "" ); if( !strcmp( meshName, "" ) ) { return; } self->mesh = Stg_ComponentFactory_ConstructByName( cf, meshName, Mesh, True, data ); self->meshType = Stg_ComponentFactory_GetString( cf, self->name, "meshType", "unknown" ); if( !strcmp( self->meshType, "unknown" ) ) { fprintf( stderr, "Remesher: Unknown mesh type.\n" ); assert( 0 ); } }
void _lucEigenvectorsCrossSection_AssignFromXML( void* drawingObject, Stg_ComponentFactory* cf, void* data ) { lucEigenvectorsCrossSection* self = (lucEigenvectorsCrossSection*)drawingObject; /* Construct Parent */ self->defaultResolution = 8; /* Default sampling res */ _lucCrossSection_AssignFromXML( self, cf, data ); self->gatherData = False; /* Drawn in parallel */ strcpy(self->fieldVariableName, "TensorField"); _lucEigenvectorsCrossSection_Init( self, Stg_ComponentFactory_GetRootDictUnsignedInt( cf, (Dictionary_Entry_Key)"dim", 2 ), Stg_ComponentFactory_GetString( cf, self->name, (Dictionary_Entry_Key)"leastColour", "black" ), Stg_ComponentFactory_GetString( cf, self->name, (Dictionary_Entry_Key)"middleColour", "black" ), Stg_ComponentFactory_GetString( cf, self->name, (Dictionary_Entry_Key)"greatestColour", "black" ), Stg_ComponentFactory_GetDouble( cf, self->name, (Dictionary_Entry_Key)"arrowHeadSize", 0.3 ), Stg_ComponentFactory_GetDouble( cf, self->name, (Dictionary_Entry_Key)"lengthScale", 1.0 ), Stg_ComponentFactory_GetUnsignedInt( cf, self->name, (Dictionary_Entry_Key)"glyphs", 3), Stg_ComponentFactory_GetBool( cf, self->name, (Dictionary_Entry_Key)"useEigenValue", True ), Stg_ComponentFactory_GetBool( cf, self->name, (Dictionary_Entry_Key)"plotEigenVector", True ), Stg_ComponentFactory_GetBool( cf, self->name, (Dictionary_Entry_Key)"plotEigenValue", False ), Stg_ComponentFactory_GetString( cf, self->name, (Dictionary_Entry_Key)"leastColourForNegative", "black" ), Stg_ComponentFactory_GetString( cf, self->name, (Dictionary_Entry_Key)"middleColourForNegative", "black" ), Stg_ComponentFactory_GetString( cf, self->name, (Dictionary_Entry_Key)"greatestColourForNegative", "black" ) ); }
void _lucViewport_AssignFromXML( void* viewport, Stg_ComponentFactory* cf, void* data ) { lucViewport* self = (lucViewport*) viewport; DrawingObject_Index drawingObjectCount; lucDrawingObject** drawingObjectList; lucCamera* camera; /* TODO Construct Parent */ 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, True, data ); camera = Stg_ComponentFactory_ConstructByKey( cf, self->name, (Dictionary_Entry_Key)"Camera", lucCamera, True, data ) ; drawingObjectList = Stg_ComponentFactory_ConstructByList( cf, self->name, (Dictionary_Entry_Key)"DrawingObject", Stg_ComponentFactory_Unlimited, lucDrawingObject, True, &drawingObjectCount, data ); _lucViewport_Init( self, camera, drawingObjectList, drawingObjectCount, Stg_ComponentFactory_GetString( cf, self->name, (Dictionary_Entry_Key)"title", ""), Stg_ComponentFactory_GetBool( cf, self->name, (Dictionary_Entry_Key)"axis", False ), Stg_ComponentFactory_GetDouble( cf, self->name, (Dictionary_Entry_Key)"axisLength", 0.2 ), Stg_ComponentFactory_GetBool( cf, self->name, (Dictionary_Entry_Key)"antialias", True ), Stg_ComponentFactory_GetBool( cf, self->name, (Dictionary_Entry_Key)"rulers", False ), Stg_ComponentFactory_GetBool( cf, self->name, (Dictionary_Entry_Key)"timestep", False ), Stg_ComponentFactory_GetInt( cf, self->name, (Dictionary_Entry_Key)"border", 0), Stg_ComponentFactory_GetString( cf, self->name, (Dictionary_Entry_Key)"borderColour", "#888888" ), Stg_ComponentFactory_GetBool( cf, self->name, (Dictionary_Entry_Key)"disable", False ), Stg_ComponentFactory_GetInt( cf, self->name, (Dictionary_Entry_Key)"margin", 32), Stg_ComponentFactory_GetDouble( cf, self->name, (Dictionary_Entry_Key)"nearClipPlane", 0 ), Stg_ComponentFactory_GetDouble( cf, self->name, (Dictionary_Entry_Key)"farClipPlane", 0 ), Stg_ComponentFactory_GetDouble( cf, self->name, (Dictionary_Entry_Key)"scaleX", 1.0 ), Stg_ComponentFactory_GetDouble( cf, self->name, (Dictionary_Entry_Key)"scaleY", 1.0 ), Stg_ComponentFactory_GetDouble( cf, self->name, (Dictionary_Entry_Key)"scaleZ", 1.0 )); Memory_Free( drawingObjectList ); }
void _SurfaceAdaptor_Construct( void* adaptor, Stg_ComponentFactory* cf, void* data ) { SurfaceAdaptor* self = (SurfaceAdaptor*)adaptor; Dictionary* dict; char* surfaceType; assert( self ); assert( cf ); /* Call parent construct. */ _MeshAdaptor_Construct( self, cf, data ); /* Rip out the components structure as a dictionary. */ dict = Dictionary_Entry_Value_AsDictionary( Dictionary_Get( cf->componentDict, self->name ) ); /* What kind of surface do we want? */ surfaceType = Stg_ComponentFactory_GetString( cf, self->name, "surfaceType", "" ); if( !strcmp( surfaceType, "wedge" ) ) { self->surfaceType = SurfaceAdaptor_SurfaceType_Wedge; self->info.wedge.offs = Stg_ComponentFactory_GetDouble( cf, self->name, "offset", 0.0 ); self->info.wedge.grad = Stg_ComponentFactory_GetDouble( cf, self->name, "gradient", 0.5 ); } else if( !strcmp( surfaceType, "sine" ) || !strcmp( surfaceType, "cosine" ) ) { Dictionary_Entry_Value* originList; if( !strcmp( surfaceType, "sine" ) ) self->surfaceType = SurfaceAdaptor_SurfaceType_Sine; else self->surfaceType = SurfaceAdaptor_SurfaceType_Cosine; originList = Dictionary_Get( dict, "origin" ); if( originList ) { unsigned nDims; unsigned d_i; nDims = Dictionary_Entry_Value_GetCount( originList ); for( d_i = 0; d_i < nDims; d_i++ ) { Dictionary_Entry_Value* val; val = Dictionary_Entry_Value_GetElement( originList, d_i ); self->info.trig.origin[d_i] = Dictionary_Entry_Value_AsDouble( val ); } } else memset( self->info.trig.origin, 0, sizeof(double) * 2 ); self->info.trig.amp = Stg_ComponentFactory_GetDouble( cf, self->name, "amplitude", 1.0 ); self->info.trig.freq = Stg_ComponentFactory_GetDouble( cf, self->name, "frequency", 1.0 ); } else _SurfaceAdaptor_Init( self ); }
void _lucSwarmRGBColourViewer_AssignFromXML( void* drawingObject, Stg_ComponentFactory* cf, void* data ) { lucSwarmRGBColourViewer* self = (lucSwarmRGBColourViewer*)drawingObject; Name colourRedVariableName; Name colourGreenVariableName; Name colourBlueVariableName; /* Construct Parent */ _lucSwarmViewer_AssignFromXML( self, cf, data ); colourRedVariableName = Stg_ComponentFactory_GetString( cf, self->name, (Dictionary_Entry_Key)"ColourRedVariable", "" ); colourGreenVariableName = Stg_ComponentFactory_GetString( cf, self->name, (Dictionary_Entry_Key)"ColourGreenVariable", "" ); colourBlueVariableName = Stg_ComponentFactory_GetString( cf, self->name, (Dictionary_Entry_Key)"ColourBlueVariable", "" ); _lucSwarmRGBColourViewer_Init( self, Stg_ComponentFactory_ConstructByKey( cf, self->name, (Dictionary_Entry_Key)"RedColourMap", lucColourMap, False, data), Stg_ComponentFactory_ConstructByKey( cf, self->name, (Dictionary_Entry_Key)"GreenColourMap", lucColourMap, False, data), Stg_ComponentFactory_ConstructByKey( cf, self->name, (Dictionary_Entry_Key)"BlueColourMap", lucColourMap, False, data), colourRedVariableName, colourGreenVariableName, colourBlueVariableName); }
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 _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 ); }