void _SwarmAdvector_Build( void* swarmAdvector, void* data ) { SwarmAdvector* self = (SwarmAdvector*) swarmAdvector; GeneralSwarm *swarm=NULL; Stg_Component_Build( self->velocityField, data, False ); Stg_Component_Build( self->swarm, data, False ); swarm=self->swarm; /* Test if mesh is periodic and a periodic boundaries manager hasn't been given */ if ( !self->periodicBCsManager && Stg_Class_IsInstance( ((ElementCellLayout*)swarm->cellLayout)->mesh->generator, CartesianGenerator_Type ) ) { CartesianGenerator* cartesianGenerator = (CartesianGenerator*) ((ElementCellLayout*)swarm->cellLayout)->mesh->generator; if ( cartesianGenerator->periodic[ I_AXIS ] || cartesianGenerator->periodic[ J_AXIS ] || cartesianGenerator->periodic[ K_AXIS ] ) { /* Create a periodicBCsManager if there isn't one already */ self->periodicBCsManager = PeriodicBoundariesManager_New( "periodicBCsManager", (PICelleratorContext*)self->context, (Mesh*)((ElementCellLayout*)swarm->cellLayout)->mesh, (Swarm*)swarm, NULL ); } } if ( self->periodicBCsManager ) Stg_Component_Build( self->periodicBCsManager, data, False ); _TimeIntegrand_Build( self, data ); }
void _RateFieldTimeIntegrator_Build( void* rateFieldTimeIntegrator, void* data ) { RateFieldTimeIntegrator* self = (RateFieldTimeIntegrator*) rateFieldTimeIntegrator; ExtensionInfo_Index handle; Stg_Component_Build( self->swarm, data, False ); Stg_Component_Build( self->rateField, data, False ); handle = ExtensionManager_GetHandle( self->swarm->particleExtensionMgr, (Name)self->name ); if ( handle == (ExtensionInfo_Index) -1 ) { ArithPointer offset; handle = ExtensionManager_Add( self->swarm->particleExtensionMgr, (Name)RateFieldTimeIntegrator_Type, self->rateField->fieldComponentCount*sizeof(double) ); /* Adding required increment variable */ offset = (ArithPointer ) ExtensionManager_Get( self->swarm->particleExtensionMgr, NULL, handle ); /* Add variables for vizualization / analysis purposes */ self->particleTimeIntegral = Swarm_NewVectorVariable( self->swarm, self->name, offset, Variable_DataType_Double, self->rateField->fieldComponentCount, "STG_AUTONAME" ); LiveComponentRegister_Add( LiveComponentRegister_GetLiveComponentRegister(), (Stg_Component*)self->particleTimeIntegral->variable ); LiveComponentRegister_Add( LiveComponentRegister_GetLiveComponentRegister(), (Stg_Component*)self->particleTimeIntegral ); /* The RateFieldTimeIntegrator class inherits from the TimeIntegrand class - this class needs a 'Variable' to * integrate through time. */ self->variable = self->particleTimeIntegral->variable; } else Journal_Firewall(False, Journal_Register( Error_Type, (Name)"RateFieldTimeIntegrator" ), "\n\nError in '%s' - Extension with name %s should not already exists.\n" "An error has occurred. Please contact developers.", __func__, self->name); /* Build parent. Note that this needs to go last because it assumes that a variable has been set, which only just happens above */ /* Another example where the build/init/etc phases don't work */ _TimeIntegrand_Build( self, data ); Stg_Component_Build( self->particleTimeIntegral, data, False ); }