void _Stokes_SLE_UzawaSolver_AssignFromXML( void* solver, Stg_ComponentFactory* cf, void* data ) { Stokes_SLE_UzawaSolver* self = (Stokes_SLE_UzawaSolver*) solver; double tolerance; Iteration_Index maxUzawaIterations, minUzawaIterations; StiffnessMatrix* preconditioner; Bool useAbsoluteTolerance; Bool monitor; _SLE_Solver_AssignFromXML( self, cf, data ); tolerance = Stg_ComponentFactory_GetDouble( cf, self->name, (Dictionary_Entry_Key)"tolerance", 1.0e-5 ); maxUzawaIterations = Stg_ComponentFactory_GetUnsignedInt( cf, self->name, (Dictionary_Entry_Key)"maxIterations", 1000 ); minUzawaIterations = Stg_ComponentFactory_GetUnsignedInt( cf, self->name, (Dictionary_Entry_Key)"minIterations", 1 ); useAbsoluteTolerance = Stg_ComponentFactory_GetBool( cf, self->name, (Dictionary_Entry_Key)"useAbsoluteTolerance", False ); monitor = Stg_ComponentFactory_GetBool( cf, self->name, (Dictionary_Entry_Key)"monitor", False ); preconditioner = Stg_ComponentFactory_ConstructByKey( cf, self->name, (Dictionary_Entry_Key)"Preconditioner", StiffnessMatrix, False, data ); _Stokes_SLE_UzawaSolver_Init( self, preconditioner, maxUzawaIterations, minUzawaIterations, tolerance, useAbsoluteTolerance, monitor ); if( self->velSolver == PETSC_NULL ) { //KSPCreate( MPI_COMM_WORLD, &self->velSolver ); //KSPSetOptionsPrefix( self->pcSolver, "Uzawa_velSolver_" ); } }
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 _SwarmDump_Construct( void* swarmDump, Stg_ComponentFactory* cf, void* data ) { SwarmDump* self = (SwarmDump*)swarmDump; Swarm** swarmList; AbstractContext* context; Bool newFileEachTime; Index swarmCount; context = Stg_ComponentFactory_ConstructByName( cf, "context", AbstractContext, True, data ) ; swarmList = Stg_ComponentFactory_ConstructByList( cf, self->name, "Swarm", Stg_ComponentFactory_Unlimited, Swarm, True, &swarmCount, data ) ; newFileEachTime = Stg_ComponentFactory_GetBool( cf, self->name, "newFileEachTime", True ); _SwarmDump_Init( self, context, swarmList, swarmCount, newFileEachTime ); Memory_Free( swarmList ); }
void _SphericalGenerator_AssignFromXML( void* meshGenerator, Stg_ComponentFactory* cf, void* data ) { SphericalGenerator* self = (SphericalGenerator*)meshGenerator; _CartesianGenerator_AssignFromXML( meshGenerator, cf, data ); // check domain size is valid Journal_Firewall( !(self->crdMin[0] <= 0 || self->crdMax[0] < self->crdMin[0]), global_error_stream, "Error in %s: Radius definition is wrong. Ensure maxX > minX & minX > 0\n", __func__ ); // theta = [-180,180], Journal_Firewall(!(self->crdMin[1] < -180 || self->crdMax[1] > 180 || self->crdMax[1] < self->crdMin[1] ), global_error_stream, "Error in %s: Theta definition is wrong. Ensure -180 <= minY < maxY < 180\n", __func__ ); if( self->nDims > 2 ) { // phi = (pi/2, pi) Journal_Firewall( !(self->crdMin[2] < -90 || self->crdMin[2] > 90 || self->crdMax[2] < self->crdMin[2]), global_error_stream, "\nError in %s: Phi definition is wrong. Ensure -90 < minZ < maxZ < 90\n", __func__); } self->fullAnnulus = Stg_ComponentFactory_GetBool( cf, self->name, (Dictionary_Entry_Key)"FullAnnulus", False ); if( self->fullAnnulus ) { self->crdMin[1] = -180; self->crdMax[1] = 180; } }
void _PETScMGSolver_AssignFromXML( void* matrixSolver, Stg_ComponentFactory* cf, void* data ) { PETScMGSolver* self = (PETScMGSolver*)matrixSolver; Bool pure; unsigned nLevels; unsigned nCycles; unsigned nDownIts, nUpIts; assert( self && Stg_CheckType( self, PETScMGSolver ) ); assert( cf ); //_PETScMatrixSolver_AssignFromXML( self, cf, data ); pure = Stg_ComponentFactory_GetBool( cf, self->name, (Dictionary_Entry_Key)"pure", False ); nLevels = Stg_ComponentFactory_GetUnsignedInt( cf, self->name, (Dictionary_Entry_Key)"levels", 1 ); nCycles = Stg_ComponentFactory_GetUnsignedInt( cf, self->name, (Dictionary_Entry_Key)"cycles", 1 ); nDownIts = Stg_ComponentFactory_GetUnsignedInt( cf, self->name, (Dictionary_Entry_Key)"downIterations", 1 ); nUpIts = Stg_ComponentFactory_GetUnsignedInt( cf, self->name, (Dictionary_Entry_Key)"upIterations", 1 ); Journal_Firewall( nLevels>1, NULL, "In func %s: Multigrid required mgLevels>1", __func__ ); self->pure = pure; PETScMGSolver_SetLevels( self, nLevels ); PETScMGSolver_SetLevelCycles( self, nLevels - 1, nCycles ); PETScMGSolver_SetAllDownIterations( self, nDownIts ); PETScMGSolver_SetAllUpIterations( self, nUpIts ); self->opGen = Stg_ComponentFactory_ConstructByKey( cf, self->name, (Dictionary_Entry_Key)"opGenerator", MGOpGenerator, True, data ); MGOpGenerator_SetMatrixSolver( self->opGen, self ); MGOpGenerator_SetNumLevels( self->opGen, nLevels ); }
void _lucIsosurface_AssignFromXML( void* drawingObject, Stg_ComponentFactory* cf, void* data ) { lucIsosurface* self = (lucIsosurface*)drawingObject; Index defaultRes; IJK resolution; double isovalue; lucDrawingObjectMask mask; /* Construct Parent */ _lucDrawingObject_AssignFromXML( self, cf, data ); self->elementRes[I_AXIS] = Dictionary_GetInt( cf->rootDict, (Dictionary_Entry_Key)"elementResI" ); self->elementRes[J_AXIS] = Dictionary_GetInt( cf->rootDict, (Dictionary_Entry_Key)"elementResJ" ); self->elementRes[K_AXIS] = Dictionary_GetInt( cf->rootDict, (Dictionary_Entry_Key)"elementResK" ); defaultRes = Stg_ComponentFactory_GetUnsignedInt( cf, self->name, (Dictionary_Entry_Key)"resolution", 1.0); resolution[ I_AXIS ] = Stg_ComponentFactory_GetUnsignedInt( cf, self->name, (Dictionary_Entry_Key)"resolutionX", defaultRes); resolution[ J_AXIS ] = Stg_ComponentFactory_GetUnsignedInt( cf, self->name, (Dictionary_Entry_Key)"resolutionY", defaultRes); resolution[ K_AXIS ] = Stg_ComponentFactory_GetUnsignedInt( cf, self->name, (Dictionary_Entry_Key)"resolutionZ", defaultRes); /* Get fields */ self->isosurfaceField = Stg_ComponentFactory_ConstructByKey( cf, self->name, (Dictionary_Entry_Key)"IsosurfaceField", FieldVariable, True, data ); self->colourField = Stg_ComponentFactory_ConstructByKey( cf, self->name, (Dictionary_Entry_Key)"ColourField", FieldVariable, False, data ); self->maskField = Stg_ComponentFactory_ConstructByKey( cf, self->name, (Dictionary_Entry_Key)"MaskField", FieldVariable, False, data ); if (defaultRes == 1 && (resolution[I_AXIS] > 2 || resolution[J_AXIS] > 2 || resolution[K_AXIS] > 2)) { Journal_Printf( lucInfo, "** WARNING ** excessive isosurface resolution: samples per element reduced to 2,2,2 - was %d,%d,%d\n", resolution[I_AXIS], resolution[J_AXIS], resolution[K_AXIS]); resolution[I_AXIS] = resolution[J_AXIS] = resolution[K_AXIS] = 2; } lucDrawingObjectMask_Construct( &mask, self->name, cf, data ); isovalue = Stg_ComponentFactory_GetDouble( cf, self->name, (Dictionary_Entry_Key)"isovalue", 0.0 ); _lucIsosurface_Init( self, isovalue, resolution, Stg_ComponentFactory_GetBool( cf, self->name, (Dictionary_Entry_Key)"drawWalls", False ), Stg_ComponentFactory_GetBool( cf, self->name, (Dictionary_Entry_Key)"sampleGlobal", False ), &mask ); }
void _Ppc_VecDotVec_AssignFromXML( void* _self, Stg_ComponentFactory* cf, void* data ) { Ppc_VecDotVec* self = (Ppc_VecDotVec*)_self; /* Construct parent */ _Ppc_AssignFromXML( self, cf, data ); self->vec1 = PpcManager_GetPpcFromDict( self->manager, cf, (Name)self->name, "Vector1", "" ); self->vec2 = PpcManager_GetPpcFromDict( self->manager, cf, (Name)self->name, "Vector2", "" ); self->transformv1 = Stg_ComponentFactory_GetBool( cf, (Name)self->name, "TransformVec1", False ); }
void _lucContourCrossSection_AssignFromXML( void* drawingObject, Stg_ComponentFactory* cf, void* data ) { lucContourCrossSection* self = (lucContourCrossSection*)drawingObject; /* Construct Parent */ self->defaultResolution = 8; /* Default sampling res */ _lucCrossSection_AssignFromXML( self, cf, data ); _lucContourCrossSection_Init( self, Stg_ComponentFactory_GetBool( cf, self->name, (Dictionary_Entry_Key)"showValues", True ), Stg_ComponentFactory_GetBool( cf, self->name, (Dictionary_Entry_Key)"printUnits", False ), Stg_ComponentFactory_GetDouble( cf, self->name, (Dictionary_Entry_Key)"minIsovalue", 0 ), Stg_ComponentFactory_GetDouble( cf, self->name, (Dictionary_Entry_Key)"maxIsovalue", 0 ), Stg_ComponentFactory_GetDouble( cf, self->name, (Dictionary_Entry_Key)"interval", 0.33 ) ) ; /* Drawing settings for this component */ //TODO: Set via python properties //self->lit = False; }
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 _ViscousPenaltyConstMatrixCartesian_AssembleFromXML( void* constitutiveMatrix, Stg_ComponentFactory* cf, void* data ) { ViscousPenaltyConstMatrixCartesian* self = (ViscousPenaltyConstMatrixCartesian*)constitutiveMatrix; double incompressibility_Penalty; Bool viscosityWeighting; /* Construct Parent */ _ConstitutiveMatrix_AssignFromXML( self, cf, data ); incompressibility_Penalty = Stg_ComponentFactory_GetDouble( cf, self->name, (Dictionary_Entry_Key)"incompressibility_Penalty", 0.0 ); viscosityWeighting = Stg_ComponentFactory_GetBool( cf, self->name, (Dictionary_Entry_Key)"viscosity_weighting", True ); _ViscousPenaltyConstMatrixCartesian_Init( self, incompressibility_Penalty, viscosityWeighting ); }
void _SLE_Solver_AssignFromXML( void* sleSolver, Stg_ComponentFactory* cf, void* data ) { SLE_Solver* self = (SLE_Solver*)sleSolver; Bool useStatSolve; int nStatReps; self->context = Stg_ComponentFactory_ConstructByKey( cf, self->name, (Dictionary_Entry_Key)"Context", FiniteElementContext, False, data ); if( !self->context ) self->context = Stg_ComponentFactory_ConstructByName( cf, (Name)"context", FiniteElementContext, True, data ); useStatSolve = Stg_ComponentFactory_GetBool( cf, self->name, (Dictionary_Entry_Key)"statSolve", False ); nStatReps = Stg_ComponentFactory_GetInt( cf, self->name, (Dictionary_Entry_Key)"statReps", 0 ); _SLE_Solver_Init( self, useStatSolve, nStatReps ); }
void _ParticleMelting_AssignFromXML( void* _self, Stg_ComponentFactory* cf, void* data ){ ParticleMelting* self = (ParticleMelting*) _self; self->context = Stg_ComponentFactory_ConstructByKey( cf, self->name, (Dictionary_Entry_Key)"Context", PICelleratorContext, False, data ); if( !self->context ) self->context = Stg_ComponentFactory_ConstructByName( cf, (Name)"context", PICelleratorContext, True, data ); _ParticleMelting_Init( self, Stg_ComponentFactory_GetBool( cf, self->name, (Dictionary_Entry_Key)"ExtractMelt", False ), Stg_ComponentFactory_ConstructByKey( cf, self->name, (Dictionary_Entry_Key)"TemperatureField", FeVariable, True, data ), Stg_ComponentFactory_ConstructByKey( cf, self->name, (Dictionary_Entry_Key)"PressureField", FeVariable, False, data ), Stg_ComponentFactory_ConstructByKey( cf, self->name, (Dictionary_Entry_Key)"MaterialPointsSwarm", MaterialPointsSwarm, True, data), Stg_ComponentFactory_ConstructByKey( cf, self->name, (Dictionary_Entry_Key)"Scaling", Scaling, True, data) ); }
void _JAMBoxExampleComponent_AssignFromXML( void* _self, Stg_ComponentFactory* cf, void* data ) { JAMBoxExampleComponent* self = (JAMBoxExampleComponent*) _self; Bool someParameter; 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 ); /** add the parameters and dependencies here */ someParameter = Stg_ComponentFactory_GetBool( cf, self->name, (Dictionary_Entry_Key)"SomeParameter", True ); _JAMBoxExampleComponent_Init( self, someParameter ); }
void _SingleCellLayout_Construct( void* singleCellLayout, Stg_ComponentFactory* cf, void* data ){ SingleCellLayout* self = (SingleCellLayout*)singleCellLayout; Bool dimExists[] = { False, False, False }; Dimension_Index dim; XYZ min; XYZ max; dim = Stg_ComponentFactory_GetRootDictUnsignedInt( cf, "dim", 0 ); dimExists[ I_AXIS ] = Stg_ComponentFactory_GetBool( cf, self->name, "dimExistsI", True ); dimExists[ J_AXIS ] = Stg_ComponentFactory_GetBool( cf, self->name, "dimExistsJ", True ); dimExists[ K_AXIS ] = Stg_ComponentFactory_GetBool( cf, self->name, "dimExistsK", (dim == 3) ); min[ I_AXIS ] = Stg_ComponentFactory_GetDouble( cf, self->name, "minX", -1.0 ); min[ J_AXIS ] = Stg_ComponentFactory_GetDouble( cf, self->name, "minY", -1.0 ); min[ K_AXIS ] = Stg_ComponentFactory_GetDouble( cf, self->name, "minZ", -1.0 ); max[ I_AXIS ] = Stg_ComponentFactory_GetDouble( cf, self->name, "maxX", 1.0 ); max[ J_AXIS ] = Stg_ComponentFactory_GetDouble( cf, self->name, "maxY", 1.0 ); max[ K_AXIS ] = Stg_ComponentFactory_GetDouble( cf, self->name, "maxZ", 1.0 ); _CellLayout_Init( (CellLayout*)self ); _SingleCellLayout_Init( self, dimExists, min, max ); }
void _VonMises_AssignFromXML( void* rheology, Stg_ComponentFactory* cf, void* data ){ VonMises* self = (VonMises*)rheology; int strainRate_id; /* Construct Parent */ _YieldRheology_AssignFromXML( self, cf, data ); /* PpcManager_GetField_TestForFeVariable */ strainRate_id = PpcManager_GetField( self->mgr, cf, (Stg_Component*)self, "StrainRateField", True ); _VonMises_Init( self, strainRate_id, Stg_ComponentFactory_GetDouble( cf, self->name, (Dictionary_Entry_Key)"cohesion", 0.0 ), Stg_ComponentFactory_GetDouble( cf, self->name, (Dictionary_Entry_Key)"cohesionAfterSoftening", 0.0 ), Stg_ComponentFactory_GetBool( cf, self->name, (Dictionary_Entry_Key)"strainRateSoftening", False ) ); }
void _lucVectorArrowCrossSection_AssignFromXML( void* drawingObject, Stg_ComponentFactory* cf, void* data ) { lucVectorArrowCrossSection* self = (lucVectorArrowCrossSection*)drawingObject; /* Construct Parent */ self->defaultResolution = 8; /* Default sampling res */ _lucCrossSection_AssignFromXML( self, cf, data ); self->gatherData = False; /* Drawn in parallel */ strcpy(self->fieldVariableName, "VectorVariable"); _lucVectorArrowCrossSection_Init( self, Stg_ComponentFactory_GetDouble( cf, self->name, (Dictionary_Entry_Key)"arrowHeadSize", 0.3 ), Stg_ComponentFactory_GetDouble( cf, self->name, (Dictionary_Entry_Key)"maximum", 1.0 ), Stg_ComponentFactory_GetBool( cf, self->name, (Dictionary_Entry_Key)"dynamicRange", True ), Stg_ComponentFactory_GetDouble( cf, self->name, (Dictionary_Entry_Key)"lengthScale", 0.3 ), Stg_ComponentFactory_GetUnsignedInt( cf, self->name, (Dictionary_Entry_Key)"glyphs", 3)); }
void _IntegrationPointsSwarm_AssignFromXML( void* integrationPoints, Stg_ComponentFactory* cf, void* data ) { IntegrationPointsSwarm* self = (IntegrationPointsSwarm*) integrationPoints; FeMesh* mesh; TimeIntegrator* timeIntegrator; WeightsCalculator* weights; IntegrationPointMapper* mapper; Materials_Register* materials_Register; Bool recalculateWeights; PICelleratorContext* context; /* This will also call _Swarm_Init */ _Swarm_AssignFromXML( self, cf, data ); mesh = Stg_ComponentFactory_ConstructByKey( cf, self->name, (Dictionary_Entry_Key)"FeMesh", FeMesh, True, data ); timeIntegrator = Stg_ComponentFactory_ConstructByKey( cf, self->name, (Dictionary_Entry_Key)"TimeIntegrator", TimeIntegrator, False, data ); weights = Stg_ComponentFactory_ConstructByKey( cf, self->name, (Dictionary_Entry_Key)"WeightsCalculator", WeightsCalculator, False, data ); mapper = Stg_ComponentFactory_ConstructByKey( cf, self->name, (Dictionary_Entry_Key)"IntegrationPointMapper", IntegrationPointMapper, False, data ); recalculateWeights = Stg_ComponentFactory_GetBool( cf, self->name, (Dictionary_Entry_Key)"recalculateWeights", True ); if( mapper !=NULL ) { Journal_Firewall ( weights != NULL || (weights == NULL && (Stg_Class_IsInstance( mapper, GaussMapper_Type ) || Stg_Class_IsInstance( mapper, GaussCoincidentMapper_Type) || !strcmp( mapper->type, "PCDVCGaussMapper"))), Journal_MyStream( Error_Type, self ), "In func %s, %s which is a %s must either have a %s or use %s\n", __func__, self->name, self->type, WeightsCalculator_Type, GaussMapper_Type ); } context = (PICelleratorContext*)self->context; assert( Stg_CheckType( context, PICelleratorContext ) ); materials_Register = context->materials_Register; assert( materials_Register ); _IntegrationPointsSwarm_Init( self, mesh, timeIntegrator, weights, mapper, materials_Register, recalculateWeights ); }
void _TimeIntegrator_AssignFromXML( void* timeIntegrator, Stg_ComponentFactory* cf, void* data ) { TimeIntegrator* self = (TimeIntegrator*)timeIntegrator; unsigned int order; Bool simultaneous; EntryPoint_Register* entryPoint_Register=NULL; /** Default for order changed to 2nd order (was 1st order) by Pat Sunter, 10 May 2006 */ order = Stg_ComponentFactory_GetUnsignedInt( cf, self->name, (Dictionary_Entry_Key)"order", 2 ); simultaneous = Stg_ComponentFactory_GetBool( cf, self->name, (Dictionary_Entry_Key)"simultaneous", False ); self->context = Stg_ComponentFactory_ConstructByKey( cf, self->name, (Dictionary_Entry_Key)"Context", DomainContext, False, data ); if( !self->context ) self->context = Stg_ComponentFactory_ConstructByName( cf, (Name)"context", DomainContext, False, data ); if ( self->context ) { entryPoint_Register = self->context->entryPoint_Register; assert( entryPoint_Register ); } _TimeIntegrator_Init( self, order, simultaneous, entryPoint_Register, (AbstractContext*)self->context ); }
void _TimeIntegrand_AssignFromXML( void* timeIntegrand, Stg_ComponentFactory* cf, void* data ) { TimeIntegrand* self = (TimeIntegrand*)timeIntegrand; Index dataCount = 0; Stg_Component** initData = NULL; Variable* variable = NULL; TimeIntegrator* timeIntegrator = NULL; Bool allowFallbackToFirstOrder = False; DomainContext* context; context = Stg_ComponentFactory_ConstructByKey( cf, self->name, (Dictionary_Entry_Key)"Context", DomainContext, False, data ); if( !self->context ) context = Stg_ComponentFactory_ConstructByName( cf, (Name)"context", DomainContext, False, data ); variable = Stg_ComponentFactory_ConstructByKey( cf, self->name, (Dictionary_Entry_Key)Variable_Type, Variable, False, data ) ; timeIntegrator = Stg_ComponentFactory_ConstructByKey( cf, self->name, (Dictionary_Entry_Key)TimeIntegrator_Type, TimeIntegrator, True, data ) ; initData = Stg_ComponentFactory_ConstructByList( cf, self->name, (Dictionary_Entry_Key)"data", Stg_ComponentFactory_Unlimited, Stg_Component, False, &dataCount, data ); allowFallbackToFirstOrder = Stg_ComponentFactory_GetBool( cf, self->name, (Dictionary_Entry_Key)"allowFallbackToFirstOrder", False ); _TimeIntegrand_Init( self, context, timeIntegrator, variable, dataCount, initData, allowFallbackToFirstOrder ); if( initData != NULL ) Memory_Free( initData ); }
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 _GALEDruckerPrager_AssignFromXML( void* druckerPrager, Stg_ComponentFactory* cf, void* data ){ GALEDruckerPrager* self = (GALEDruckerPrager*)druckerPrager; FeVariable* pressureField = NULL; SwarmVariable* swarmPressure = NULL; MaterialPointsSwarm* materialPointsSwarm = NULL; /* Construct Parent */ _GALEVonMises_AssignFromXML( self, cf, data ); pressureField = (FeVariable *) Stg_ComponentFactory_ConstructByKey( cf, self->name, (Dictionary_Entry_Key)"PressureField", FeVariable, False, data ); swarmPressure = Stg_ComponentFactory_ConstructByKey( cf, self->name, (Dictionary_Entry_Key)"swarmPressure", SwarmVariable, False, data ); Journal_Firewall( ( pressureField || swarmPressure ), Journal_Register( Error_Type, (Name)self->type ), "\n Error in component type %s, name '%s'.\n Must specify a PressureField OR a swarmPressure, but not both. \n", self->type, self->name ); materialPointsSwarm = (MaterialPointsSwarm*) Stg_ComponentFactory_ConstructByKey( cf, self->name, (Dictionary_Entry_Key)"MaterialPointsSwarm", MaterialPointsSwarm, True, data ); _GALEDruckerPrager_Init( self, pressureField, swarmPressure, materialPointsSwarm, Stg_ComponentFactory_GetDouble( cf, self->name, (Dictionary_Entry_Key)"frictionCoefficient", 0.0 ), Stg_ComponentFactory_GetDouble( cf, self->name, (Dictionary_Entry_Key)"frictionCoefficientAfterSoftening", 0.0 ), Stg_ComponentFactory_GetDouble( cf, self->name, (Dictionary_Entry_Key)"boundaryCohesion", 0.0 ), Stg_ComponentFactory_GetDouble( cf, self->name, (Dictionary_Entry_Key)"boundaryCohesionAfterSoftening", 0.0 ), Stg_ComponentFactory_GetDouble( cf, self->name, (Dictionary_Entry_Key)"boundaryFrictionCoefficient", 0.0 ), Stg_ComponentFactory_GetDouble( cf, self->name, (Dictionary_Entry_Key)"boundaryFrictionCoefficientAfterSoftening", 0.0 ), Stg_ComponentFactory_GetBool( cf, self->name, (Dictionary_Entry_Key)"boundaryBottom", False ), Stg_ComponentFactory_GetBool( cf, self->name, (Dictionary_Entry_Key)"boundaryTop", False ), Stg_ComponentFactory_GetBool( cf, self->name, (Dictionary_Entry_Key)"boundaryLeft", False ), Stg_ComponentFactory_GetBool( cf, self->name, (Dictionary_Entry_Key)"boundaryRight", False ), Stg_ComponentFactory_GetBool( cf, self->name, (Dictionary_Entry_Key)"boundaryFront", False ), Stg_ComponentFactory_GetBool( cf, self->name, (Dictionary_Entry_Key)"boundaryBack", False ), Stg_ComponentFactory_GetDouble( cf, self->name, (Dictionary_Entry_Key)"minimumYieldStress", 0.0 ), Stg_ComponentFactory_GetDouble( cf, self->name, (Dictionary_Entry_Key)"minimumViscosity", 0.0), Stg_ComponentFactory_ConstructByKey( cf, self->name, (Dictionary_Entry_Key)"HydrostaticTerm", HydrostaticTerm, False, data ) ); }
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 _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 ); } }