Ejemplo n.º 1
0
void _SnacRestartOld_Construct( void* component, Stg_ComponentFactory* cf, void* data ) {
	Snac_Context*	context;
	char fname[PATH_MAX];
	FILE *fp;

	/* Retrieve context. */
	context = (Snac_Context*)Stg_ComponentFactory_ConstructByName( cf, "context", Snac_Context, True, data ); 

#ifdef DEBUG
	printf( "In: _SnacRestartOld_Register( void* )\n" );
#endif

	if( context->rank == 0 ) {
		sprintf( fname, "%s/coord.%d", context->outputPath, context->rank );
		Journal_Firewall( ( ( fp = fopen( fname, "r") ) == NULL ), 
				  context->snacError, 
				  "\n\n ###### RESTARTER ERROR ######\n Do NOT restart in %s!!\n All the existing outputs will be overwritten !!\n If absolutely sure, remove the existing outputs first.\n #############################\n\n", 
				  context->outputPath );
	}

	/*
	 *  Shift the time step range to start from the restart time step
	 *    - this doesn't seem to work since the changes don't appear to propagate into StGermain
	 *     far enough to cause the maxTimeSteps to stop the simulation when desired
	 */
/* 	context->timeStep += context->restartStep; */
/* 	context->maxTimeSteps += context->restartStep; */

	EntryPoint_InsertBefore(
		Context_GetEntryPoint( context, AbstractContext_EP_Initialise ),
		"SnacTimeStepZero",
		SnacRestartOld_Type,
		_SnacRestartOld_resetMinLengthScale,
		SnacRestartOld_Type );
	EntryPoint_InsertBefore(
		Context_GetEntryPoint( context, AbstractContext_EP_Initialise ),
		"SnacTimeStepZero",
		SnacRestartOld_Type,
		_SnacRestartOld_InitialCoords,
		SnacRestartOld_Type );
	EntryPoint_InsertBefore(
		Context_GetEntryPoint( context, AbstractContext_EP_Initialise ),
		"SnacTimeStepZero",
		SnacRestartOld_Type,
		_SnacRestartOld_InitialVelocities,
		SnacRestartOld_Type );
	EntryPoint_InsertBefore(
		Context_GetEntryPoint( context, AbstractContext_EP_Initialise ),
		"SnacTimeStepZero",
		SnacRestartOld_Type,
		_SnacRestartOld_InitialStress,
		SnacRestartOld_Type );

/* 	_SnacRestartOld_resetMinLengthScale(context,data); */
/* 	_SnacRestartOld_InitialCoords(context,data); */
/* 	_SnacRestartOld_InitialVelocities(context,data); */
/* 	_SnacRestartOld_InitialStress(context,data); */
}
Ejemplo n.º 2
0
void _SnacPlastic_Construct( void* component, Stg_ComponentFactory* cf, void* data ) {
	Snac_Context*	context;
	EntryPoint* 	interpolateElementEP;

	/* Retrieve context. */
	context = (Snac_Context*)Stg_ComponentFactory_ConstructByName( cf, "context", Snac_Context, True, data ); 

	#ifdef DEBUG
		printf( "In: _SnacPlastic_Register( void*, void* )\n" );
	#endif
	
	/* Add extensions to nodes, elements and the context */
	SnacPlastic_ElementHandle = ExtensionManager_Add( context->mesh->elementExtensionMgr, SnacPlastic_Type, sizeof(SnacPlastic_Element) );
	SnacPlastic_ContextHandle = ExtensionManager_Add( context->extensionMgr, SnacPlastic_Type, sizeof(SnacPlastic_Context) );
	
	#ifdef DEBUG
		printf( "\tcontext extension handle: %u\n", SnacPlastic_ContextHandle );
		printf( "\telement extension handle: %u\n", SnacPlastic_ElementHandle );
	#endif
	
	/* Add extensions to the entry points */
	EntryPoint_Append( 
		Context_GetEntryPoint( context,	Snac_EP_Constitutive ),
		SnacPlastic_Type, 
		SnacPlastic_Constitutive, 
		SnacPlastic_Type );
	EntryPoint_InsertBefore( 
		Context_GetEntryPoint( context,	AbstractContext_EP_Initialise ),
		"SnacTimeStepZero",
		SnacPlastic_Type, 
		SnacPlastic_InitialConditions,
		SnacPlastic_Type );
	EntryPoint_Prepend( /* Dump the initial plastic strain */
		Context_GetEntryPoint( context, AbstractContext_EP_Execute ),
		"SnacPlastic_Write",
		_SnacPlastic_WritePlasticStrain,
		SnacPlastic_Type );
	EntryPoint_Append( /* and dump each loop */
		Context_GetEntryPoint( context, Snac_EP_CalcStresses ),
		"SnacPlastic_Write",
		_SnacPlastic_WritePlasticStrain,
		SnacPlastic_Type );
	
	/* Add extensions to the interpolate element entry point, but it will only exist if the remesher is loaded. */
	interpolateElementEP = Context_GetEntryPoint( context,	"SnacRemesher_EP_InterpolateElement" );
	if( interpolateElementEP ) {
		EntryPoint_Append( 
			interpolateElementEP,
			SnacPlastic_Type, 
			_SnacPlastic_InterpolateElement, 
			SnacPlastic_Type );
	}


	/* Construct. */
	_SnacPlastic_ConstructExtensions( context, data );
}
Ejemplo n.º 3
0
void _SnacHetero_Construct( void* component, Stg_ComponentFactory* cf, void* data ) {
	Snac_Context*	context;
	context = (Snac_Context*)Stg_ComponentFactory_ConstructByName( cf, "context", Snac_Context, True, data ); 
        Journal_Printf( context->snacInfo, "In: %s\n", __func__ );

       EntryPoint_InsertBefore(
                Context_GetEntryPoint( context, AbstractContext_EP_Initialise ),
                "SnacTimeStepZero",
                SnacHetero_Type,
                _SnacHetero_InitialCondition,
                SnacHetero_Type );

       /* ConditionFunction_Register_Add(
               context->condFunc_Register,
               ConditionFunction_New(_SnacHetero_node,"SnacHeteroNode" ) );
        ConditionFunction_Register_Add(
               context->condFunc_Register,
               ConditionFunction_New( _SnacHetero_element,"SnacHeteroElement" ) );*/
}
void TimeIntegrator_InsertBeforeFinishEP( 
	void* timeIntegrator, 
	Name hookToInsertBefore,
	Name name, 
	Func_Ptr funcPtr, 
	char* addedBy, 
	void* data ) 
{
	TimeIntegrator*        self            = (TimeIntegrator*)timeIntegrator;

	if ( Stg_ObjectList_GetIndex( self->finishEP->hooks, hookToInsertBefore ) != (unsigned int)-1 ) {
		EntryPoint_InsertBefore( self->finishEP, hookToInsertBefore, name, funcPtr, addedBy );
		Stg_ObjectList_InsertAtIndex( 
				self->finishData,
				Stg_ObjectList_GetIndex( self->finishEP->hooks, name ),
				data );
	}
	else {
		TimeIntegrator_AppendFinishEP( self, name, funcPtr, addedBy, data );
	}
}
Ejemplo n.º 5
0
void _SnacTemperature_Construct( void* component, Stg_ComponentFactory* cf, void* data ) {
	Snac_Context*	context;
	EntryPoint* 	interpolateNodeEP;

	/* Retrieve context. */
	context = (Snac_Context*)Stg_ComponentFactory_ConstructByName( cf, "context", Snac_Context, True, data ); 

	#ifdef DEBUG
		printf( "In: _SnacTemperature_Register( void*, void* )\n" );
	#endif

	/* Add extensions to nodes, elements and the context */
	SnacTemperature_NodeHandle = ExtensionManager_Add( context->mesh->nodeExtensionMgr, SnacTemperature_Type, sizeof(SnacTemperature_Node) );
	SnacTemperature_ElementHandle = ExtensionManager_Add( context->mesh->elementExtensionMgr, SnacTemperature_Type, sizeof(SnacTemperature_Element) );
	SnacTemperature_ContextHandle = ExtensionManager_Add( context->extensionMgr, SnacTemperature_Type, sizeof(SnacTemperature_Context) );

	#ifdef DEBUG
		printf( "\tcontext extension handle: %u\n", SnacTemperature_ContextHandle );
		printf( "\telement extension handle: %u\n", SnacTemperature_ElementHandle );
		printf( "\tnode extension handle: %u\n", SnacTemperature_NodeHandle );
	#endif


	/* Add extensions to the entry points */
	EntryPoint_Append(
		Context_GetEntryPoint( context, AbstractContext_EP_Build ),
		SnacTemperature_Type,
		_SnacTemperature_Build,
		SnacTemperature_Type );
	EntryPoint_InsertBefore(
		Context_GetEntryPoint( context, AbstractContext_EP_Initialise ),
		"SnacTimeStepZero",
		SnacTemperature_Type,
		_SnacTemperature_InitialConditions,
		SnacTemperature_Type );
	EntryPoint_Append(
		Context_GetEntryPoint( context, Snac_EP_LoopNodesEnergy ),
		SnacTemperature_Type,
		SnacTemperature_LoopNodes,
		SnacTemperature_Type );
	EntryPoint_Append(
		Context_GetEntryPoint( context, Snac_EP_LoopElementsEnergy ),
		SnacTemperature_Type,
		SnacTemperature_LoopElements,
		SnacTemperature_Type );
	EntryPoint_Prepend( /* Dump the initial temperature */
		Context_GetEntryPoint( context, AbstractContext_EP_Execute ),
		"SnacTemperature_Write",
		_SnacTemperature_WriteTemp,
		SnacTemperature_Type );
	EntryPoint_Append( /* and dump each loop */
		Context_GetEntryPoint( context, Snac_EP_LoopNodesEnergy ),
		"SnacTemperature_Write",
		_SnacTemperature_WriteTemp,
		SnacTemperature_Type );
	EntryPoint_Append(
		Context_GetEntryPoint( context, AbstractContext_EP_DestroyExtensions ),
		SnacTemperature_Type,
		_SnacTemperature_DeleteExtensions,
		SnacTemperature_Type );

	/* Add extensions to the interpolate element entry point, but it will only exist if the remesher is loaded. */
	interpolateNodeEP = Context_GetEntryPoint( context, "SnacRemesher_EP_InterpolateNode" );
	if( interpolateNodeEP ) {
		EntryPoint_Append(
			interpolateNodeEP,
			SnacTemperature_Type,
			_SnacTemperature_InterpolateNode,
			SnacTemperature_Type );
	}

	/* Construct. */
	_SnacTemperature_ConstructExtensions( context, data );
}