Example #1
0
Stg_ComponentFactory* stgMainInitFromXML( char* xmlInputFilename, MPI_Comm communicator, void* _context ) {
   Dictionary*           dictionary = NULL;
   Dictionary*           sources = NULL;
   Bool                  result;
   XML_IO_Handler*       ioHandler;
   Stg_ComponentFactory* cf;

   dictionary = Dictionary_New();
   sources = Dictionary_New();
   ioHandler = XML_IO_Handler_New();
   result = IO_Handler_ReadAllFromFile( ioHandler, xmlInputFilename, dictionary, sources );

   /* In case the user has put any journal configuration in the XML, read here. */
   Journal_ReadFromDictionary( dictionary );
   cf = stgMainConstruct( dictionary, sources, communicator, _context );

   /* now dereference aliases */
   DictionaryUtils_AliasDereferenceDictionary( dictionary );
   /* 
    * We don't need the XML IO handler again (however don't delete the dictionary as it's 
    * 'owned' by the context from hereon.
    */
   Stg_Class_Delete( ioHandler );
   Stg_Class_Delete( sources );

   return cf;
}
void _ModulesManager_Delete( void* modulesManager ) {
   ModulesManager*        self = (ModulesManager*)modulesManager;
   LiveComponentRegister* lcRegister = NULL;

   /* 
    * Note: We have to delete the codelets here rather than let the 
    * component factory do it as they refer to static data inside the
    * loaded module dlls, which are no longer available once we delete
    * all in self->modules. -- Main.PatrickSunter 18 May 2006 
    */
   if( ( lcRegister = LiveComponentRegister_GetLiveComponentRegister() ) ) {
      /* sweep through codelets list and delete each from the lcRegister */
      Index codelet_I;
      
      for( codelet_I = 0; codelet_I < self->codelets->count; ++codelet_I ) {
         LiveComponentRegister_RemoveOneComponentsEntry( lcRegister,
            ((Stg_Object*)self->codelets->data[codelet_I])->name );
      }
   }
   Stg_ObjectList_DeleteAllObjects( self->codelets );
   Stg_Class_Delete( self->codelets );
   ModulesManager_Unload( self ); 
   Stg_Class_Delete( self->modules );
   
   /* Delete parent */
   _Stg_Class_Delete( self );
}
Bool BaseIO_Finalise( void )
{
	Stream* stream;
	if ( stJournal->flushCount > 0 ) {
		stream = Journal_Register( Debug_Type, (char*)__func__ );
		Journal_Printf( stream, "StGermain IO Report - File Flush called %d times.\n", stJournal->flushCount );
	}
	Journal_Delete();
	stJournal = NULL;
	/* Now clean up the special memory streams seeing as these aren't in the journal */
	Stg_Class_Delete( stgMemory->infoStream );
	stgMemory->infoStream = NULL;
	Stg_Class_Delete( stgMemory->debugStream );
	stgMemory->debugStream = NULL;
	Stg_Class_Delete( stgMemory->errorStream );
	stgMemory->errorStream = NULL;
	StreamFormatter_Buffer_Delete( stgStreamFormatter_Buffer );
	stgStreamFormatter_Buffer = NULL;
	Stg_Class_Delete( _stgFilePaths );
	_stgFilePaths = NULL;
	Stg_Class_Delete( Project_XMLSearchPaths );
	Project_XMLSearchPaths = NULL;
	
	return True;
}
int main( int argc, char* argv[] ) {
	MPI_Comm CommWorld;
	int rank;
	int numProcessors;
	int procToWatch;
	
	/* Initialise MPI, get world info */
	MPI_Init( &argc, &argv );
	MPI_Comm_dup( MPI_COMM_WORLD, &CommWorld );
	MPI_Comm_size( CommWorld, &numProcessors );
	MPI_Comm_rank( CommWorld, &rank );
	
	BaseFoundation_Init( &argc, &argv );
	BaseIO_Init( &argc, &argv );
	
	if( argc >= 2 ) {
		procToWatch = atoi( argv[1] );
	}
	else {
		procToWatch = 0;
	}
	if( rank == procToWatch ) {
		XML_IO_Handler*		io_handler = XML_IO_Handler_New();
		Dictionary*		dictionary = Dictionary_New();
		Dictionary_Index 	index;
		Stream*			stream = Journal_Register( InfoStream_Type, XML_IO_Handler_Type );
		
		/* use the base class functions */
		printf( "\ntest of raw data file:\n" );
		IO_Handler_ReadAllFromFile( io_handler, "data/rawdata.xml", dictionary ); 

		printf( "\ndictionary now contains:\n" );
		printf( "Dictionary:\n" );
		printf( "\tsize: %u\n", dictionary->size );
		printf( "\tdelta: %u\n", dictionary->delta );
		printf( "\tcount: %u\n", dictionary->count );
		printf( "\tentryPtr[0-%u]: {\n", dictionary->count );
		for( index = 0; index < dictionary->count; index++ ) {
			printf( "\t\t" );
			Dictionary_Entry_Print( dictionary->entryPtr[index], stream ); 
			printf( "\n" );
		}
		printf( "\t}\n" );


		/* Dictionary_Entry_Value_SetEncoding( Dictionary_Get( dictionary, "boundary_conditions2" ), RawASCII ); */

		IO_Handler_WriteAllToFile( io_handler, "data/newrawdata.xml", dictionary );
		Stg_Class_Delete( io_handler );
		Stg_Class_Delete( dictionary );
	}

	BaseIO_Finalise();
	BaseFoundation_Finalise();

	/* Close off MPI */
	MPI_Finalize();
	
	return EXIT_SUCCESS;
}
Index _Stg_ObjectList_Replace( void* namedObjectList, Name toReplace, ReplacementOption option, void* objectPtr ) {
   Stg_ObjectList* self = (Stg_ObjectList*) namedObjectList;
   Index           objectIndex;

   assert( objectPtr );
   for( objectIndex = 0; objectIndex < self->count; objectIndex++ ) {
      if ( toReplace == self->data[objectIndex]->name ) {
         if ( DELETE == option ) {
            Stg_Class_Delete( self->data[objectIndex] );
         }
         self->data[objectIndex] = (Stg_Object*) objectPtr; 
         return objectIndex;
      }
   }
   for( objectIndex = 0; objectIndex < self->count; objectIndex++ ) {
      if (0 == strcmp( toReplace, self->data[objectIndex]->name ) ) {
         if ( DELETE == option ) {
            Stg_Class_Delete( self->data[objectIndex] );
         }
         self->data[objectIndex] = (Stg_Object*) objectPtr; 
         return objectIndex;
      }
   }

   fprintf( stderr, "Error: %s(): specified object \"%s\" to replace not found.\n",
      __func__, toReplace ); 
   assert( 0 );
   return (Index) -1;
}
void _VariableCondition_Destroy( void* variableCondition, void* data ) {
	VariableCondition* self = (VariableCondition*)variableCondition;

	if (self->mapping) Stg_Class_Delete(self->mapping);
	if (self->_set) Stg_Class_Delete(self->_set);
	if (self->indexTbl) Memory_Free(self->indexTbl);
	if (self->vcVarCountTbl) Memory_Free(self->vcVarCountTbl);
	if (self->vcTbl) Memory_Free(self->vcTbl);
	if (self->valueTbl) Memory_Free(self->valueTbl);
}
Example #7
0
Bool BaseExtensibility_Finalise( void ) {
    Journal_Printf( Journal_Register( DebugStream_Type, "Context" ), "In: %s\n", __func__ );

    Stg_Class_Delete( stgToolboxesManager );
    stgToolboxesManager = NULL;
    Stg_Class_Delete( extensionMgr_Register );
    extensionMgr_Register = NULL;

    return True;
}
void _ToolboxesManager_Delete( void* toolboxesManager ) {
    ToolboxesManager* self = (ToolboxesManager*)toolboxesManager;

    Stg_ObjectList_DeleteAllObjects( self->codelets );
    Stg_Class_Delete( self->codelets );
    ModulesManager_Unload( self );  /* this will unload all toolboxes implicitly */
    Stg_Class_Delete( self->modules );

    /* Delete parent */
    _Stg_Class_Delete( self );
}
void _ForceVector_Destroy( void* forceVector, void* data ) {
	ForceVector* self = (ForceVector*)forceVector;

	Memory_Free( self->_assembleForceVectorEPName );

	/* Don't delete entry point: E.P register will delete it automatically */
	Stg_Class_Delete( self->forceTermList );

	Stg_Class_Delete( self->inc );

	_SolutionVector_Destroy( self, data );
}
void DictionaryCheckSuite_TestCheckKeys( DictionaryCheckSuiteData* data ) {
   Dictionary*       dictionary = Dictionary_New();
   Dictionary*       dictionary2 = Dictionary_New();
   const char*       testFilename1 = "testDictionaryCheck-1.txt";
   const char*       testFilename2 = "testDictionaryCheck-2.txt";
   char              expectedFilename[PCU_PATH_MAX];
   const char*       errMessage = "Component dictionary must have unique names\n";
   
   Stream_RedirectFile( Journal_Register( Error_Type, (Name)"DictionaryCheck" ), testFilename1 );
   Stream_SetPrintingRank( Journal_Register( Error_Type, (Name)"DictionaryCheck" ), 0 );
   Stream_ClearCustomFormatters( Journal_Register( Error_Type, (Name)"DictionaryCheck") );

   /* Create a set of Dictionary entries */
   /* For dictionary */
   Dictionary_Add( dictionary, (Dictionary_Entry_Key)"test_dict_string", Dictionary_Entry_Value_FromString( "hello" ) );
   Dictionary_Add( dictionary, (Dictionary_Entry_Key)"test_dict_double", Dictionary_Entry_Value_FromDouble( 45.567 ) );
   Dictionary_Add( dictionary, (Dictionary_Entry_Key)"test_dict_string", Dictionary_Entry_Value_FromString( "goodbye" ) );   
   Dictionary_Add( dictionary, (Dictionary_Entry_Key)"test_dict_string", Dictionary_Entry_Value_FromString( "hello" ) );
   Dictionary_Add( dictionary, (Dictionary_Entry_Key)"test_dict_string2", Dictionary_Entry_Value_FromString( "hello" ) );
   
   CheckDictionaryKeys( dictionary,  errMessage );

   if ( data->rank==0 ) {
      pcu_filename_expected( testFilename1, expectedFilename );
      pcu_check_fileEq( testFilename1, expectedFilename );
      remove( testFilename1 );
   }

   /* For dictionary2 */
   Dictionary_Add( dictionary2, (Dictionary_Entry_Key)"test_dict_string", Dictionary_Entry_Value_FromString( "hello" ) );
   Dictionary_Add( dictionary2, (Dictionary_Entry_Key)"test_dict_double", Dictionary_Entry_Value_FromDouble( 45.567 ) );
   Dictionary_Add( dictionary2, (Dictionary_Entry_Key)"test_dict_stuff", Dictionary_Entry_Value_FromString( "hello") );

   /* Call DictionaryCheck function */
   Stream_RedirectFile(Journal_Register( Error_Type, (Name)"DictionaryCheck" ), testFilename2 );
   CheckDictionaryKeys(dictionary2, errMessage);

   /* This file expected to be empty */
   if ( data->rank==0 ) {
      pcu_filename_expected( testFilename2, expectedFilename );
      pcu_check_fileEq( testFilename2, expectedFilename );
      remove( testFilename2 );
   }
   
   Stg_Class_Delete( dictionary );
   Stg_Class_Delete( dictionary2 );

   if ( data->rank==0 ) {
      remove( testFilename1 );
      remove( testFilename2 );
   }
}
Bool BaseAutomation_Finalise( void ) {
	Journal_Printf( Journal_Register( DebugStream_Type, "Context" ), "In: %s\n", __func__ ); /* DO NOT CHANGE OR REMOVE */
	
	/* Clean up global variable */
	Stg_Class_Delete( stgComponentRegister );
	stgComponentRegister=NULL;
	Stg_Class_Delete( stgHierarchyTable );
	stgHierarchyTable=NULL;
	Stg_Class_Delete( stgCallGraph );
	stgCallGraph=NULL;

	return True;
}
Example #12
0
int main( int argc, char* argv[] ) {
	MPI_Comm CommWorld;
	int rank;
	int numProcessors;
	Stream* stream;

	Stg_ObjectList* directories;
	PluginLoader* plugin;

	/* Initialise MPI, get world info */
	MPI_Init( &argc, &argv );
	MPI_Comm_dup( MPI_COMM_WORLD, &CommWorld );
	MPI_Comm_size( CommWorld, &numProcessors );
	MPI_Comm_rank( CommWorld, &rank );

	BaseFoundation_Init( &argc, &argv );
	BaseIO_Init( &argc, &argv );
	BaseContainer_Init( &argc, &argv );
	BaseAutomation_Init( &argc, &argv );
	BaseExtensibility_Init( &argc, &argv );

	/* creating a stream */
	stream =  Journal_Register( Info_Type, __FILE__ );

	directories = Stg_ObjectList_New();
	Stg_ObjectList_PointerAppend( directories, StG_Strdup(LIB_DIR), "default dir", 0, 0, 0 );
	
	plugin = PluginLoader_NewLocal( "LocalPlugin", directories );

	Journal_Firewall( plugin != NULL, stream, "Failed!\n" );

	Journal_Printf( stream, "PluginLoader_GetName(): %s\n", PluginLoader_GetName( plugin ) );
	Print( plugin, stream );

	Stg_Class_Delete( plugin );
	Stg_Class_Delete( directories );
	
	BaseExtensibility_Finalise();
	BaseAutomation_Finalise();
	BaseContainer_Finalise();
	BaseIO_Finalise();
	BaseFoundation_Finalise();

	/* Close off MPI */
	MPI_Finalize();
                                                                                                                                    

	return 0;
}
Example #13
0
void* _MeshLayout_Copy( void* meshLayout, void* dest, Bool deep, Name nameExt, PtrMap* ptrMap ) {
	MeshLayout*	self = (MeshLayout*)meshLayout;
	MeshLayout*	newMeshLayout;
	PtrMap*		map = ptrMap;
	Bool		ownMap = False;
	
	if( !map ) {
		map = PtrMap_New( 10 );
		ownMap = True;
	}
	
	newMeshLayout = (MeshLayout*)_Stg_Component_Copy( self, dest, deep, nameExt, map );
	
	if( deep ) {
		newMeshLayout->nodeLayout = (NodeLayout*)Stg_Class_Copy( self->nodeLayout, NULL, deep, nameExt, map );
		newMeshLayout->elementLayout = (ElementLayout*)Stg_Class_Copy( self->elementLayout, NULL, deep, nameExt, map );
		newMeshLayout->decomp = (MeshDecomp*)Stg_Class_Copy( self->decomp, NULL, deep, nameExt, map );
	}
	else {
		newMeshLayout->nodeLayout = self->nodeLayout;
		newMeshLayout->elementLayout = self->elementLayout;
		newMeshLayout->decomp = self->decomp;
	}
	
	if( ownMap ) {
		Stg_Class_Delete( map );
	}
	
	return (void*)newMeshLayout;
}
void* _ElementCellLayout_Copy( void* elementCellLayout, void* dest, Bool deep, Name nameExt, PtrMap* ptrMap ) {
	ElementCellLayout*	self = (ElementCellLayout*)elementCellLayout;
	ElementCellLayout*	newElementCellLayout;
	PtrMap*			map = ptrMap;
	Bool			ownMap = False;
	
	if( !map ) {
		map = PtrMap_New( 10 );
		ownMap = True;
	}
	
	newElementCellLayout = _CellLayout_Copy( self, dest, deep, nameExt, ptrMap );
	
	if( deep ) {
		newElementCellLayout->mesh = (Mesh*)Stg_Class_Copy( self->mesh, NULL, deep, nameExt, map );
	}
	else {
		newElementCellLayout->mesh = self->mesh;
	}
	
	if( ownMap ) {
		Stg_Class_Delete( map );
	}
	
	return (void*)newElementCellLayout;
}
void _IntegrationPointsSwarm_Delete( void* integrationPoints ) {
   IntegrationPointsSwarm* self = (IntegrationPointsSwarm*)integrationPoints;

   Stg_Class_Delete( self->swarmsMappedTo );

   _Swarm_Delete( self );
}
void* _SolutionVector_Copy( void* solutionVector, void* dest, Bool deep, Name nameExt, PtrMap* ptrMap ) {
	SolutionVector*	self = (SolutionVector*)solutionVector;
	SolutionVector*	newSolutionVector;
	PtrMap*		map = ptrMap;
	Bool		ownMap = False;
	
	if( !map ) {
		map = PtrMap_New( 10 );
		ownMap = True;
	}
	
	newSolutionVector = _Stg_Component_Copy( self, dest, deep, nameExt, map );
	
	/* TODO: copy vector? */
	newSolutionVector->vector = self->vector;
	newSolutionVector->comm = self->comm;
	
	if( deep ) {
		newSolutionVector->debug = (Stream*)Stg_Class_Copy( self->debug, NULL, deep, nameExt, map );
		newSolutionVector->feVariable = (FeVariable*)Stg_Class_Copy( self->feVariable, NULL, deep, nameExt, map );
	}
	else {
		newSolutionVector->debug = self->debug;
		newSolutionVector->feVariable = self->feVariable;
	}
	
	if( ownMap ) {
		Stg_Class_Delete( map );
	}
	
	return (void*)newSolutionVector;
}
Bool StgDomainSwarm_Finalise( void ) {
	Journal_Printf( Journal_Register( DebugStream_Type, (Name)"Context"  ), "In: %s\n", __func__ ); /* DO NOT CHANGE OR REMOVE */
	Stg_Class_Delete( stgSwarm_Register );
	stgSwarm_Register = NULL;

	return True;
}
Example #18
0
void* _MeshGenerator_Copy( void* meshGenerator, void* destProc_I, Bool deep, Name nameExt, PtrMap* ptrMap ) {
#if 0
	MeshGenerator*	self = (MeshGenerator*)meshGenerator;
	MeshGenerator*	newMeshGenerator;
	PtrMap*	map = ptrMap;
	Bool	ownMap = False;

	/* Damn me for making copying so difficult... what was I thinking? */
	
	/* We need to create a map if it doesn't already exist. */
	if( !map ) {
		map = PtrMap_New( 10 );
		ownMap = True;
	}
	
	newMeshGenerator = (MeshGenerator*)_Mesh_Copy( self, destProc_I, deep, nameExt, map );
	
	/* Copy the virtual methods here. */

	/* Deep or shallow? */
	if( deep ) {
	}
	else {
	}
	
	/* If we own the map, get rid of it here. */
	if( ownMap ) Stg_Class_Delete( map );
	
	return (void*)newMeshGenerator;
#endif

	return NULL;
}
void* _StiffnessMatrixTerm_Copy( void* stiffnessMatrixTerm, void* dest, Bool deep, Name nameExt, PtrMap* ptrMap ) {
	StiffnessMatrixTerm*	self = (StiffnessMatrixTerm*)stiffnessMatrixTerm;
	StiffnessMatrixTerm*	newStiffnessMatrixTerm;
	PtrMap*		map = ptrMap;
	Bool		ownMap = False;
	
	if( !map ) {
		map = PtrMap_New( 10 );
		ownMap = True;
	}
	
	newStiffnessMatrixTerm = _Stg_Component_Copy( self, dest, deep, nameExt, map );
	
	newStiffnessMatrixTerm->extraInfo = self->extraInfo;
	if( deep ) {
		newStiffnessMatrixTerm->integrationSwarm = (Swarm*)Stg_Class_Copy( self->integrationSwarm, NULL, deep, nameExt, map );
	}
	else {
		newStiffnessMatrixTerm->integrationSwarm = self->integrationSwarm;
	}
	
	if( ownMap ) {
		Stg_Class_Delete( map );
	}
	
	return (void*)newStiffnessMatrixTerm;
}
Example #20
0
void* _IndexMap_Copy( void* indexMap, void* dest, Bool deep, Name nameExt, struct PtrMap* ptrMap ) {
	IndexMap*	self = (IndexMap*)indexMap;
	IndexMap*	newIndexMap;
	PtrMap*		map = ptrMap;
	Bool		ownMap = False;
	
	if( !map ) {
		map = PtrMap_New( 10 );
		ownMap = True;
	}
	
	newIndexMap = _Stg_Class_Copy( self, dest, deep, nameExt, map );
	
	newIndexMap->dictionary = self->dictionary;
	newIndexMap->delta = self->delta;
	newIndexMap->maxTuples = self->maxTuples;
	newIndexMap->tupleCnt = self->tupleCnt;
	
	if( deep ) {
		if( (newIndexMap->tupleTbl = PtrMap_Find( map, self->tupleTbl )) == NULL && self->tupleTbl ) {
			newIndexMap->tupleTbl = Memory_Alloc_Array( IndexMapTuple, self->maxTuples, "IndexMap->tupleTbl" );
			memcpy( newIndexMap->tupleTbl, self->tupleTbl, sizeof(IndexMapTuple) * self->maxTuples );
			PtrMap_Append( map, self->tupleTbl, newIndexMap->tupleTbl );
		}
	}
	else {
		newIndexMap->tupleTbl = self->tupleTbl;
	}
	
	if( ownMap ) {
		Stg_Class_Delete( map );
	}
	
	return (void*)newIndexMap;
}
Example #21
0
void* _SwarmVariable_Copy( void* swarmVariable, void* dest, Bool deep, Name nameExt, PtrMap* ptrMap ) {
	SwarmVariable*	self = (SwarmVariable*)swarmVariable;
	SwarmVariable*	newSwarmVariable;
	PtrMap*			map = ptrMap;
	Bool			ownMap = False;
	
	if( !map ) {
		map = PtrMap_New( 10 );
		ownMap = True;
	}
	
	newSwarmVariable = _Stg_Component_Copy( self, dest, deep, nameExt, map );
	
	newSwarmVariable->_valueAt                   = self->_valueAt;
	newSwarmVariable->_getMinGlobalMagnitude     = self->_getMinGlobalMagnitude  ;
	newSwarmVariable->_getMaxGlobalMagnitude     = self->_getMaxGlobalMagnitude;

	newSwarmVariable->swarm                      = self->swarm;
	newSwarmVariable->variable                   = self->variable;
	newSwarmVariable->dofCount                   = self->dofCount;
	newSwarmVariable->swarmVariable_Register     = self->swarmVariable_Register;

	if( ownMap ) {
		Stg_Class_Delete( map );
	}
				
	return (void*)newSwarmVariable;
}
Example #22
0
void Mesh_Destruct( Mesh* self ) {
	unsigned	et_i/*, v_i*/;

	for( et_i = 0; et_i < self->nElTypes; et_i++ )
		Stg_Class_Delete( self->elTypes[et_i] );
	KillArray( self->elTypes );
	KillArray( self->elTypeMap );
	self->nElTypes = 0;

	KillArray( self->vertices );
    Stg_Component_Destroy(self->verticesVariable, NULL, False);
    self->verticesVariable = NULL;
    KillArray( self->verticesgid );
    Stg_Component_Destroy(self->vGlobalIdsVar, NULL, False);
    self->vGlobalIdsVar = NULL;
    KillArray( self->e_n );
    Stg_Component_Destroy(self->enMapVar, NULL, False);
    self->enMapVar = NULL;
    KillArray( self->elgid );
    Stg_Component_Destroy(self->eGlobalIdsVar, NULL, False);
    self->eGlobalIdsVar = NULL;

	self->generator = NULL;
	self->emReg = NULL;

	/*
	for( v_i = 0; v_i < List_GetSize( self->vars ); v_i++ ) {
		MeshVariable*	var;

		var = *(MeshVariable**)List_GetItem( self->vars, v_i );
		MeshVariable_SetMesh( var, NULL );
	}
	List_Clear( self->vars );
	*/
}
void* _FieldVariable_Copy( void* fieldVariable, void* dest, Bool deep, Name nameExt, PtrMap* ptrMap ) {
   FieldVariable* self = (FieldVariable*)fieldVariable;
   FieldVariable* newFieldVariable;
   PtrMap*        map = ptrMap;
   Bool           ownMap = False;
   
   if( !map ) {
      map = PtrMap_New( 10 );
      ownMap = True;
   }
   
   newFieldVariable = _Stg_Component_Copy( self, dest, deep, nameExt, map );
   newFieldVariable->_interpolateValueAt       = self->_interpolateValueAt;
   newFieldVariable->_getMinAndMaxLocalCoords  = self->_getMinAndMaxLocalCoords;
   newFieldVariable->_getMinAndMaxGlobalCoords = self->_getMinAndMaxGlobalCoords;
   newFieldVariable->fieldComponentCount       = self->fieldComponentCount;
   newFieldVariable->dim                       = self->dim;
   newFieldVariable->isCheckpointedAndReloaded = self->isCheckpointedAndReloaded;
   newFieldVariable->communicator              = self->communicator;
   newFieldVariable->fieldVariable_Register    = self->fieldVariable_Register;
   newFieldVariable->extensionMgr              = Stg_Class_Copy( self->extensionMgr, NULL, deep, nameExt, map );
   
   if( ownMap ) {
      Stg_Class_Delete( map );
   }
            
   return (void*)newFieldVariable;
}
void _TimeIntegrator_Delete( void* timeIntegrator ) {
	TimeIntegrator* self = (TimeIntegrator*)timeIntegrator;
	
	Journal_DPrintf( self->debug, "In %s for %s '%s'\n", __func__, self->type, self->name );
	Memory_Free( self->_setupEPName );
	Memory_Free( self->_finishEPName );
	
	Stg_Class_Delete( self->setupData );
	Stg_Class_Delete( self->finishData );

        // delete register
	Stg_Class_Delete( self->integrandRegister );
	
	/* Stg_Class_Delete parent*/
	_Stg_Component_Delete( self );
}
void Variable_RegisterSuite_TestAddGet( Variable_RegisterSuiteData* data ) {
   Variable*		var[10];
   #define ARRAY_SIZE	4
   #define STRUCT_SIZE	4
   double			array[ARRAY_SIZE];
   Index			   arraySize = ARRAY_SIZE;
   char*			   name[10] = {"testVar0", "testVar1", "testVar2", "testVar3",
                  "testVar4", "testVar5", "testVar6", "testVar7",
                  "testVar8", "testVar9"};
   Index		   	i;

   for (i = 0; i < 10; i++) {
      var[i] = Variable_NewVector( name[i], NULL, Variable_DataType_Double, 4, &arraySize, NULL, (void**)&array, 0 );
   }

   for (i = 0; i < 10; i++)
   {
      Variable_Register_Add(data->reg, var[i]);
   }

   for (i = 0; i < 10; i++) {
      pcu_check_true( i == Variable_Register_GetIndex(data->reg, name[i]));
   }

   for (i = 0; i < 10; i++) {
      pcu_check_true( var[i] == Variable_Register_GetByName(data->reg, name[i]));
   }

   for (i = 0; i < 10; i++) {
      Stg_Class_Delete(var[i]);
   }
}
void MaxHeapSuite_Teardown( MaxHeapSuiteData* data ) {
   Stg_Class_Delete( data->heap );
   Memory_Free( data->dataArray );
   /* Note: _Heap_Delete() (Heap.c:144) already frees the keys array. Not sure this is entirely logical - needs to
    *  be well doco'd at least */
   /*Memory_Free( data->keys );*/
}
static void Dictionary_Entry_Value_DeleteContents( Dictionary_Entry_Value* self ) {
	Dictionary_Entry_Value* cur         = NULL;
	Dictionary_Entry_Value* next        = NULL;
	Stream*                 errorStream = Journal_Register( Error_Type, "Dictionary_Entry_Value" );
	
	switch( self->type ) {
		case Dictionary_Entry_Value_Type_String:
			Journal_Firewall( self->as.typeString != NULL, errorStream, "In func %s: self->as.typeString is NULL.\n", __func__ );
			Memory_Free( self->as.typeString );
			break;
		case Dictionary_Entry_Value_Type_Struct:
			Journal_Firewall( self->as.typeStruct != NULL, errorStream, "In func %s: self->as.typeStruct is NULL.\n", __func__ );
			Stg_Class_Delete( self->as.typeStruct );
			break;
		case Dictionary_Entry_Value_Type_List:
			cur = self->as.typeList->first;
			while ( cur ) {
				next = cur->next;
				Dictionary_Entry_Value_Delete( cur );
				cur = next;
			}	
			Memory_Free( self->as.typeList );
			break;
		case Dictionary_Entry_Value_Type_Double:
		case Dictionary_Entry_Value_Type_UnsignedInt:
		case Dictionary_Entry_Value_Type_Int:
		case Dictionary_Entry_Value_Type_UnsignedLong:
		case Dictionary_Entry_Value_Type_Bool:
			break;
		default:
			Journal_Firewall( False, errorStream, "In func %s: self->type '%d' is invalid.\n", __func__, self->type );
	};
}
Example #28
0
void _MeshDecomp_Delete( void* meshDecomp ) {
	MeshDecomp* self = (MeshDecomp*)meshDecomp;
	
	if( self->procTopology ) {
		Stg_Class_Delete( self->procTopology );
		self->procTopology = NULL;
	}
	
	if( self->localElementSets ) {
		Partition_Index proc_I;
		for( proc_I = 0; proc_I < self->procsInUse; proc_I++ )
			if( self->localElementSets[proc_I] )
				Stg_Class_Delete( self->localElementSets[proc_I] );
		Memory_Free( self->localElementSets );
		self->localElementSets = NULL;
	}
	
	if( self->shadowElementSets ) {
		Partition_Index proc_I;	
		for( proc_I = 0; proc_I < self->procsInUse; proc_I++ )
			if( self->shadowElementSets[proc_I] )
				Stg_Class_Delete( self->shadowElementSets[proc_I] );
		Memory_Free( self->shadowElementSets );
		self->shadowElementSets = NULL;
	}
	
	if( self->localNodeSets ) {
		Partition_Index proc_I;
		for( proc_I = 0; proc_I < self->procsInUse; proc_I++ )
			if( self->localNodeSets[proc_I] )
				Stg_Class_Delete( self->localNodeSets[proc_I] );
		Memory_Free( self->localNodeSets );
		self->localNodeSets = NULL;
	}
	
	if( self->shadowNodeSets ) {
		Partition_Index proc_I;
		for( proc_I = 0; proc_I < self->procsInUse; proc_I++ )
			if( self->shadowNodeSets[proc_I] )
				Stg_Class_Delete( self->shadowNodeSets[proc_I] );
		Memory_Free( self->shadowNodeSets );
		self->shadowNodeSets = NULL;
	}
	
	/* Stg_Class_Delete parent */
	_Stg_Component_Delete( self );
}
void* _SLE_Solver_Copy( void* sleSolver, void* dest, Bool deep, Name nameExt, PtrMap* ptrMap ) {
	SLE_Solver*		self = (SLE_Solver*)sleSolver;
	SLE_Solver*		newSleSolver;
	PtrMap*			map = ptrMap;
	Bool			ownMap = False;
	
	if( !map ) {
		map = PtrMap_New( 10 );
		ownMap = True;
	}
	
	newSleSolver = _Stg_Component_Copy( self, dest, deep, nameExt, map );
	
	/* virtual functions */
	newSleSolver->_solverSetup  = self->_solverSetup;
	newSleSolver->_solve        = self->_solve;
	newSleSolver->maxIterations = self->maxIterations;

	newSleSolver->inneritsinitialtime = self->inneritsinitialtime;
	newSleSolver->outeritsinitialtime = self->outeritsinitialtime;
	newSleSolver->nonlinearitsinitialtime = self->nonlinearitsinitialtime;
	newSleSolver->inneritsendtime = self->inneritsendtime;
	newSleSolver->outeritsendtime = self->outeritsendtime;
	newSleSolver->nonlinearitsendtime = self->nonlinearitsendtime;
	newSleSolver->totalinneritstime = self->totalinneritstime;
	newSleSolver->totalouteritstime = self->totalouteritstime;
	newSleSolver->totalnonlinearitstime = self->totalnonlinearitstime;
	newSleSolver->totalnuminnerits = self->totalnuminnerits; 
	newSleSolver->totalnumouterits = self->totalnumouterits; 
	newSleSolver->totalnumnonlinearits = self->totalnumnonlinearits; 	
	newSleSolver->avgnuminnerits = self->avgnuminnerits;
    newSleSolver->avgnumouterits = self->avgnumouterits;
	newSleSolver->avgtimeinnerits = self->avgtimeinnerits; 
	newSleSolver->avgtimeouterits = self->avgtimeouterits; 
	newSleSolver->avgtimenonlinearits = self->avgtimenonlinearits; 
	newSleSolver->currenttimestep = self->currenttimestep; 
	newSleSolver->previoustimestep = self->previoustimestep;
	
	if( deep ) {
		if( (newSleSolver->debug = PtrMap_Find( map, self->debug )) == NULL ) {
			newSleSolver->debug = Stg_Class_Copy( self->debug, NULL, deep, nameExt, map );
			PtrMap_Append( map, self->debug, newSleSolver->debug );
		}
		if( (newSleSolver->extensionManager = PtrMap_Find( map, self->extensionManager )) == NULL ) {
			newSleSolver->extensionManager = Stg_Class_Copy( self->extensionManager, NULL, deep, nameExt, map );
			PtrMap_Append( map, self->extensionManager, newSleSolver->extensionManager );
		}
	}
	else {
		newSleSolver->debug = self->debug;
		newSleSolver->extensionManager = Stg_Class_Copy( self->extensionManager, NULL, deep, nameExt, map );
	}
	
	if( ownMap ) {
		Stg_Class_Delete( map );
	}
	
	return (void*)newSleSolver;
}
void LinkedListSuite_Teardown( LinkedListSuiteData* data ) {
   Index          ii = 0;

   Stg_Class_Delete( data->numList );
   for(ii=0; ii < NUM_DATA; ii++){
      Memory_Free( data->array[ii] );
   }
}