void _ImportersToolbox_SurfaceProcessCoupler_AssignFromXML( void* component, Stg_ComponentFactory* cf, void* data ) {
   ImportersToolbox_SurfaceProcessCoupler* self = (ImportersToolbox_SurfaceProcessCoupler*) component;
   UnderworldContext* uw_context=NULL;

   uw_context              = (UnderworldContext*)  Stg_ComponentFactory_PluginConstructByKey( cf, self, (Name)"Context", AbstractContext, True, data  ); 
   self->ms                = (MaterialPointsSwarm*)Stg_ComponentFactory_PluginConstructByKey( cf, self, (Name)"MaterialPointsSwarm", MaterialPointsSwarm, True, data  ); 
   self->pts               = (MaterialPointsSwarm*)Stg_ComponentFactory_PluginConstructByKey( cf, self, (Name)"UWDeformationTrackingSwarm", MaterialPointsSwarm, True, data  ); 
   self->belowSurfaceShape = (BelowHeightField*)   Stg_ComponentFactory_PluginConstructByKey( cf, self, (Name)"BelowSurfaceShape", BelowHeightField, True, data  ); 
   self->air_material      = (RheologyMaterial*)   Stg_ComponentFactory_PluginConstructByKey( cf, self, (Name)"air_material", RheologyMaterial, True, data  ); 
   self->sediment_material = (RheologyMaterial*)   Stg_ComponentFactory_PluginConstructByKey( cf, self, (Name)"sediment_material", RheologyMaterial, True, data  ); 
   self->sync_folder       = Stg_ComponentFactory_PluginGetString(      cf, self, (Dictionary_Entry_Key)"sync_folder", "./" );
   self->sleep_interval    = Stg_ComponentFactory_PluginGetUnsignedInt( cf, self, (Dictionary_Entry_Key)"sleep_interval", 5 );
   self->sync_time         = Stg_ComponentFactory_PluginGetDouble(      cf, self, (Dictionary_Entry_Key)"sync_time", -1 );
   self->vertAxis          = Stg_ComponentFactory_PluginGetInt(         cf, self, (Dictionary_Entry_Key)"VerticalAxis", 1 );
   self->SP_tracer_height  = Stg_ComponentFactory_PluginGetDouble(      cf, self, (Dictionary_Entry_Key)"SP_tracer_vertical_coord", 0 );
   self->SP_globalid_var   = Stg_ComponentFactory_PluginConstructByKey( cf, self, (Dictionary_Entry_Key)"SP_globalid_SwarmVariable", SwarmVariable, True, data );

   if( self->sync_time < 0 ) {
      Journal_Printf( NULL, "Error in function %s\n. The 'sync_time' input parameters is invalid\n" );
      abort();
   }

   global_self = self;
   self->context = (AbstractContext*)uw_context;
   self->start_time = self->context->currentTime;
   self->absolute_sync_time = self->start_time + self->sync_time;
   self->poll_maestro=1;

   /* create hooks on entry points */
   // hook for waiting for SP 
   EP_AppendClassHook( AbstractContext_GetEntryPoint( self->context, AbstractContext_EP_PreSolveClass),
         _ImportersToolbox_SurfaceProcessCoupler_wait_for_SP, self );

   assert( uw_context->calcDtEP );
   EP_AppendClassHook( uw_context->calcDtEP, _ImportersToolbox_SurfaceProcessCoupler_dt_limiter, self );

   // hook for generating I/O for SP 
   EP_AppendClassHook( Context_GetEntryPoint( self->context, AbstractContext_EP_UpdateClass), 
         _ImportersToolbox_SurfaceProcessCoupler_write_for_SP, self);


   /* setup path for maestro file */
   self->maestro_path=Memory_Alloc_Array( char, sizeof(char)*( strlen(self->sync_folder)+8 ), Name_Invalid );
   assert( self->maestro_path );
   sprintf( self->maestro_path, "%s/maestro", self->sync_folder );

   /* setup path for ascii file */
   self->ascii_path=Memory_Alloc_Array( char, sizeof(char)*( strlen(self->sync_folder)+16 ), Name_Invalid );
   assert( self->ascii_path );
   sprintf( self->ascii_path, "%s/uw_output.ascii", self->sync_folder );

}
void _TimeIntegrator_Init( 
	void*						timeIntegrator, 
	unsigned int			order, 
	Bool						simultaneous, 
	EntryPoint_Register*	entryPoint_Register,
	AbstractContext*		context )
{
	TimeIntegrator* self = (TimeIntegrator*)timeIntegrator;

	self->context = (DomainContext*)context;
	self->debug = Journal_Register( Debug_Type, (Name)self->type  );
	self->info = Journal_Register( Info_Type, (Name)self->type );
		
	self->integrandRegister = NamedObject_Register_New( );
	self->order = order;
	self->simultaneous = simultaneous;

	/* Entry Point Stuff */
	Stg_asprintf( &self->_setupEPName, "%s-Setup", self->name );
	Stg_asprintf( &self->_finishEPName, "%s-Finish", self->name );
	self->setupEP  = EntryPoint_New( self->_setupEPName,  EntryPoint_VoidPtr_CastType );
	self->finishEP = EntryPoint_New( self->_finishEPName, EntryPoint_VoidPtr_CastType );

	if ( entryPoint_Register ) {
		EntryPoint_Register_Add( entryPoint_Register, self->setupEP );
		EntryPoint_Register_Add( entryPoint_Register, self->finishEP );
	}

	self->setupData = Stg_ObjectList_New();
	self->finishData = Stg_ObjectList_New();

	if ( context ) {
		EP_AppendClassHook( Context_GetEntryPoint( context, AbstractContext_EP_UpdateClass ), TimeIntegrator_UpdateClass, self );
	}
}
Beispiel #3
0
void _SwarmDump_Init( 
		SwarmDump*                                         self,
		void*                                              context,
		Swarm**                                            swarmList,
		Index                                              swarmCount,
		Bool                                               newFileEachTime )
{
	self->isConstructed = True;

	self->swarmList = Memory_Alloc_Array( Swarm*, swarmCount, "swarmList" );
	memcpy( self->swarmList, swarmList, swarmCount * sizeof(Swarm*) );
	self->swarmCount = swarmCount;

	self->newFileEachTime = newFileEachTime;
		
	/* Only append hook to context's save EP if context is given */
	if ( context ) {
		EP_AppendClassHook( Context_GetEntryPoint( context, AbstractContext_EP_SaveClass ), SwarmDump_Execute, self );
	}
}