void _MaterialFeVariable_Build( void* materialFeVariable, void* data ) { MaterialFeVariable* self = (MaterialFeVariable*) materialFeVariable; IntegrationPointsSwarm* swarm; Name tmpName; Variable_Register* variable_Register = NULL; Stg_Component_Build( self->feMesh, data, False ); /* Create Dof Layout */ swarm = self->picIntegrationPoints; if ( swarm->swarmVariable_Register ) variable_Register = swarm->swarmVariable_Register->variable_Register; tmpName = Stg_Object_AppendSuffix( self, (Name)"DataVariable" ); self->dataVariable = Variable_NewScalar( tmpName, (AbstractContext*)self->context, Variable_DataType_Double, &((IGraph*)self->feMesh->topo)->remotes[MT_VERTEX]->nDomains, NULL, (void**)&self->data, variable_Register ); Memory_Free( tmpName ); self->fieldComponentCount = 1; tmpName = Stg_Object_AppendSuffix( self, (Name)"DofLayout" ); self->dofLayout = DofLayout_New( tmpName, self->context, variable_Register, ((IGraph*)self->feMesh->topo)->remotes[MT_VERTEX]->nDomains, NULL ); DofLayout_AddAllFromVariableArray( self->dofLayout, 1, &self->dataVariable ); Memory_Free( tmpName ); self->eqNum->dofLayout = self->dofLayout; _ParticleFeVariable_Build( self, data ); }
void Stg_TimeMonitor_Delete( Stg_TimeMonitor* tm ) { if( tm->tag ) { Memory_Free( tm->tag ); } Memory_Free( tm ); }
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 ); }; }
/* Journal_Printf( stream, "\tNodeCount\t\t - %d\n", self->nodeCount ); Journal_Printf( stream, "\tLinkedList Order\t - %s\n", (self->listOrder == LINKEDLIST_SORTED)?"SORTED":"UNSORTED" ); Journal_Printf( stream, "\tLinkedList data\t - \n"); if (self->dataPrintFunction) LinkedList_ParseList( self, (LinkedList_parseFunction*)self->dataPrintFunction, (void*)stream ); } */ int LinkedList_DeleteAllNodes( LinkedList *list ) { LinkedList *self = NULL; LinkedListNode *curr = NULL, *temp = NULL; self = (LinkedList*)list; assert (self); curr = self->head; while (curr != NULL){ temp = curr->next; if (self->dataDeleteFunction){ self->dataDeleteFunction( curr->data ); } else{ Memory_Free(curr->data); } Memory_Free( curr ); /** Freeing the Node without calling the Stg_Class_Delete function, because LinkedList_Node does not inherit __Stg_Class */ curr = temp; --self->nodeCount; } self->head = NULL; return 0; }
void _ConstitutiveMatrixCartesian_Destroy( void* constitutiveMatrix, void* data ) { ConstitutiveMatrixCartesian* self = (ConstitutiveMatrixCartesian*)constitutiveMatrix; Memory_Free( self->Dtilda_B ); Memory_Free( self->Ni ); _ConstitutiveMatrix_Destroy( constitutiveMatrix, data ); }
void _ViscousPenaltyConstMatrixCartesian_Destroy( void* constitutiveMatrix, void* data ) { ViscousPenaltyConstMatrixCartesian* self = (ViscousPenaltyConstMatrixCartesian*)constitutiveMatrix; _ConstitutiveMatrix_Destroy( constitutiveMatrix, data ); Memory_Free( self->Dtilda_B ); Memory_Free( self->Ni ); }
void _Matrix_NaiNbj_Destroy( void* constitutiveMatrix, void* data ) { Matrix_NaiNbj* self = (Matrix_NaiNbj*)constitutiveMatrix; _ConstitutiveMatrix_Destroy( constitutiveMatrix, data ); Memory_Free( self->Dtilda_B ); Memory_Free( self->Ni ); }
void _Biquadratic_Destroy( void* elementType, void* data ) { Biquadratic* self = (Biquadratic*)elementType; Memory_Free( self->faceNodes ); Memory_Free( self->evaluatedShapeFunc ); Memory_Free( self->GNi ); _ElementType_Destroy( elementType, data ); }
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); }
void StreamFormatter_Buffer_Delete( StreamFormatter_Buffer* buffer ) { if ( buffer->buffer1 != NULL ) { Memory_Free( buffer->buffer1 ); } if ( buffer->buffer2 != NULL ) { Memory_Free( buffer->buffer2 ); } Memory_Free( buffer ); }
void _ConvexHull_Destroy( void* convexHull, void* data ) { ConvexHull* self = (ConvexHull*)convexHull; Coord_List vertexList = self->vertexList; XYZ* facesList = self->facesList; Memory_Free( vertexList ); Memory_Free( facesList ); _Stg_Shape_Destroy( self, data ); }
void _TrilinearElementType_Destroy( void* elementType, void *data ){ TrilinearElementType* self = (TrilinearElementType*)elementType; Memory_Free( self->faceNodes ); Memory_Free( self->evaluatedShapeFunc ); Memory_Free( self->GNi ); FreeArray( self->tetInds ); _ElementType_Destroy( self, data ); }
void _LinearSpaceAdaptor_Destroy( void* _self, void* data ) { LinearSpaceAdaptor* self = (LinearSpaceAdaptor*)_self; if( self->nSegmentsx > 0 ) Memory_Free( self->tablex ); if( self->nSegmentsy > 0 ) Memory_Free( self->tabley ); if( self->nSegmentsz > 0 ) Memory_Free( self->tablez ); _MeshAdaptor_Destroy( self, data ); }
void _MemoryPool_DeleteFunc( void *memPool ) { MemoryPool *self = NULL; self = (MemoryPool*)memPool; assert (self); Memory_Free( self->elements ); Memory_Free( self->pool ); _Stg_Class_Delete( self ); }
void VariableSuite_Teardown( VariableSuiteData* data ) { Variable_Index var_I; /* manually delete all the created Variables */ for( var_I = 0; var_I < data->vr->count; var_I++ ) { Stg_Class_Delete( data->vr->_variable[var_I] ); } Memory_Free( data->particle ); Memory_Free( data->velocity ); Memory_Free( data->temperature ); }
void _Geothermal_FieldMaps_Destroy( void* component, void* data ) { Geothermal_FieldMaps* self = (Geothermal_FieldMaps*)component; unsigned map_i; for( map_i = 0; map_i < self->numMaps; map_i++ ) { Memory_Free( self->maps[map_i]->nodeValues ); Memory_Free( self->maps[map_i]->nodeCoords ); free( self->maps[map_i] ); } if( self->maps ) { free( self->maps ); } }
Stg_Component* _Stg_ComponentFactory_PluginConstructByKey( void* cf, void* codelet, Dictionary_Entry_Key componentKey, Type type, Bool isEssential, void* data ) { Stg_ComponentFactory* self = (Stg_ComponentFactory*)cf; Stg_Component* plugin = (Stg_Component*)codelet; Dictionary* thisPluginDict = NULL; Dictionary* pluginDict = (Dictionary*)Dictionary_Get( self->rootDict, "plugins" ); Name componentName, redirect, pluginType; Dictionary_Entry_Value* componentEntryVal; Index pluginIndex; Stream* errorStream = Journal_Register( Error_Type, self->type ); Journal_Firewall( self != NULL, errorStream, "In func %s: Stg_Component is NULL.\n", __func__ ); /* Get this plugins Dictionary */ for( pluginIndex = 0; pluginIndex < Dictionary_Entry_Value_GetCount( (Dictionary_Entry_Value*)pluginDict ); pluginIndex++ ) { thisPluginDict = Dictionary_Entry_Value_AsDictionary( Dictionary_Entry_Value_GetElement( (Dictionary_Entry_Value*)pluginDict, pluginIndex ) ); pluginType = StG_Strdup( Dictionary_GetString( thisPluginDict, "Type" ) ); if( !strcmp( plugin->type, pluginType ) ){ Memory_Free( pluginType ); break; } Memory_Free( pluginType ); } /* Get Dependency's Name */ componentEntryVal = Dictionary_Get( thisPluginDict, componentKey ); if ( componentEntryVal == NULL ) { Journal_Firewall( !isEssential, errorStream, "plugin '%s' cannot find essential component with key '%s'.\n", plugin->type, componentKey ); Journal_PrintfL( self->infoStream, 2, "plugin '%s' cannot find non-essential component with key '%s'.\n", plugin->type, componentKey ); return NULL; } componentName = Dictionary_Entry_Value_AsString( componentEntryVal ); /* If we can find the component's name in the root dictionary, use that value instead. */ if( self->rootDict ) { redirect = Dictionary_GetString_WithDefault( self->rootDict, componentName, "" ); if( strcmp( redirect, "" ) ) componentName = redirect; } return self->constructByName( self, componentName, type, isEssential, data ); }
void GUI_FreeNode( TGUINode * node ) { if( node->button ) { GUI_FreeNode( node->button->text ); GUI_FreeNode( node->button->background ); Memory_Free( node->button ); } if( node->text ) { Memory_Free( node->text ); } if( node->rect ) { Memory_Free( node->rect ); } Memory_Free( node ); }
Bool StGermainBase_Init( int* argc, char** argv[] ) { char* directory; int tmp; /* Initialise enough bits and pieces to get IO going */ BaseFoundation_Init( argc, argv ); BaseIO_Init( argc, argv ); /* Write out the copyright message */ Journal_Printf( Journal_Register( DebugStream_Type, "Context" ), "In: %s\n", __func__ ); tmp = Stream_GetPrintingRank( Journal_Register( InfoStream_Type, "Context" ) ); Stream_SetPrintingRank( Journal_Register( InfoStream_Type, "Context" ), 0 ); Stream_Flush( Journal_Register( InfoStream_Type, "Context" ) ); Stream_SetPrintingRank( Journal_Register( InfoStream_Type, "Context" ), tmp ); /* Initialise the remaining bits and pieces */ BaseContainer_Init( argc, argv ); BaseAutomation_Init( argc, argv ); BaseExtensibility_Init( argc, argv ); BaseContext_Init( argc, argv ); /* Add the StGermain path to the global xml path dictionary */ directory = Memory_Alloc_Array( char, 200, "xmlDirectory" ) ; sprintf( directory, "%s%s", LIB_DIR, "/StGermain" ); XML_IO_Handler_AddDirectory( "StGermain", directory ); Memory_Free( directory ); /* Add the plugin path to the global plugin list */ ModulesManager_AddDirectory( "StGermain", LIB_DIR ); return True; }
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 );*/ }
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 Stg_ObjectList_PrintSimilar( void* objectList, Name name, void* _stream, unsigned int number ) { Stg_ObjectList* self = (Stg_ObjectList*)objectList; Stream* stream = (Stream*)_stream; Stg_ObjectList_SimilarityObject* similarityArray; float stringLength = (float) strlen( name ); float objectStringLength; Index object_I; unsigned int substringLength; similarityArray = Memory_Alloc_Array( Stg_ObjectList_SimilarityObject, self->count, "similarityArray"); for ( object_I = 0 ; object_I < self->count ; object_I++ ) { substringLength = Stg_LongestMatchingSubsequenceLength( self->data[object_I]->name, name, False ); objectStringLength = (float) strlen( self->data[object_I]->name ); similarityArray[ object_I ].objectPtr = self->data[object_I]; similarityArray[ object_I ].percentageSimilar = (float) substringLength * 100.0 / MAX( objectStringLength, stringLength ); } qsort( similarityArray, (size_t)self->count, sizeof( Stg_ObjectList_SimilarityObject ), _Stg_ObjectList_SimilarityCompare ); if ( number > self->count ) number = self->count; for ( object_I = 0 ; object_I < number ; object_I++ ) { Journal_Printf( stream, "%s (%.2f%% similar)\n", similarityArray[ object_I ].objectPtr->name, similarityArray[ object_I ].percentageSimilar ); } Memory_Free( similarityArray ); }
Bool lecode_tools_Init( int* argc, char** argv[] ) { /* This init function tells StGermain of all the component types, etc this module contributes. Because it can be linked at compile time or linked in by a toolbox at runtime, we need to make sure it isn't run twice (compiled in and loaded through a toolbox.*/ if( !ToolboxesManager_IsInitialised( stgToolboxesManager, "lecode_tools" ) ) { int tmp; char* directory; lecode_tools_Base_Init(argc, argv); Journal_Printf( Journal_Register( DebugStream_Type, (Name)"Context" ), "In: %s\n", __func__ ); /* DO NOT CHANGE OR REMOVE */ tmp = Stream_GetPrintingRank( Journal_Register( InfoStream_Type, (Name)"Context" ) ); Stream_SetPrintingRank( Journal_Register( InfoStream_Type, (Name)"Context" ), 0 ); Journal_Printf( /* DO NOT CHANGE OR REMOVE */ Journal_Register( InfoStream_Type, (Name)"Context" ), "lecode_tools. Copyright (C) 2012 Monash University.\n" ); Stream_Flush( Journal_Register( InfoStream_Type, (Name)"Context" ) ); Stream_SetPrintingRank( Journal_Register( InfoStream_Type, (Name)"Context" ), tmp ); /* Add the lecode_tools path to the global xml path dictionary */ directory = Memory_Alloc_Array( char, 200, "xmlDirectory" ) ; sprintf(directory, "%s%s", LIB_DIR, "/StGermain" ); XML_IO_Handler_AddDirectory( "lecode_tools", directory ); Memory_Free(directory); /* Add the plugin path to the global plugin list */ ModulesManager_AddDirectory( "lecode_tools", LIB_DIR ); return True; }
void IndexMap_Append( void* indexMap, Index key, Index idx ) { IndexMap* self = (IndexMap*)indexMap; unsigned newTupleCnt; assert( self && key != -1 && idx != -1 ); if( IndexMap_Find( self, key ) != -1 ) { return; } newTupleCnt = self->tupleCnt + 1; if( newTupleCnt >= self->maxTuples ) { unsigned factor; IndexMapTuple* newTuples; factor = ceil( (float)(newTupleCnt - self->maxTuples) / (float)self->delta ); self->maxTuples += factor * self->delta; newTuples = Memory_Alloc_Array( IndexMapTuple, self->maxTuples, "IndexMap->tupleTbl" ); assert( newTuples ); /* TODO change this */ if( self->tupleTbl ) { memcpy( newTuples, self->tupleTbl, sizeof(IndexMapTuple) * self->tupleCnt ); Memory_Free( self->tupleTbl ); } self->tupleTbl = newTuples; } self->tupleTbl[self->tupleCnt].key = key; self->tupleTbl[self->tupleCnt].idx = idx; self->tupleCnt = newTupleCnt; }
void MemoryPool_Extend( MemoryPool *memPool ) { int i = 0; char **newPool; assert( memPool ); memPool->numMemChunks++; memPool->chunks = (MemChunk*)Memory_Realloc( memPool->chunks, sizeof(MemChunk)*memPool->numMemChunks ); assert( memPool->chunks ); memPool->chunks[memPool->numMemChunks-1].memory = (char*)Memory_Alloc_Bytes_Unnamed( memPool->elementSize * memPool->delta, "int" ); memset( memPool->chunks[memPool->numMemChunks-1].memory, 0, memPool->elementSize * memPool->delta ); memPool->chunks[memPool->numMemChunks-1].numFree = memPool->delta; memPool->chunks[memPool->numMemChunks-1].maxFree = memPool->delta; newPool = (char**)Memory_Alloc_Bytes_Unnamed( sizeof(char*) * (memPool->numElements+memPool->delta), "char*" ); assert( newPool ); memcpy( newPool+memPool->delta, memPool->pool, sizeof(char*)*memPool->numElements ); for( i=0; i<memPool->delta; i++ ){ newPool[i] = &(memPool->chunks[memPool->numMemChunks-1].memory[i*memPool->elementSize]); } Memory_Free( memPool->pool ); memPool->pool = newPool; memPool->numElements+=memPool->delta; memPool->numElementsFree=memPool->delta; if( memPool->callbackFunc ){ memPool->callbackFunc( memPool->callbackFuncArg ); } }
void _FieldVariableConditionFunctionSecondCopy_Destroy( void* component, void* data ) { FieldVariableConditionFunctionSecondCopy* self = (FieldVariableConditionFunctionSecondCopy*)component; /** our work is done, so we clean up after ourselves */ Stg_Component_Destroy(self->fieldVariable, NULL, False); Memory_Free( self->value ); }
SizeT _MPIStream_Printf( Stream* stream, char *fmt, va_list args ) { MPIStream* self = (MPIStream*)stream; MPI_Status status; char* buffer; SizeT numChars; int writeResult; if ( self->_file == NULL ) { return 0; } numChars = Stg_vasprintf( &buffer, fmt, args ); writeResult = MPI_File_write( *(MPI_File*)(self->_file->fileHandle), buffer, numChars, MPI_BYTE, &status ); if (writeResult != MPI_SUCCESS) { char errorString[2000]; int errorStringLength = 0; Stream* errorStream = Journal_Register( Error_Type, MPIFile_Type ); int myRank = 0; MPI_Comm_rank( MPI_COMM_WORLD, &myRank ); MPI_Error_string( writeResult, errorString, &errorStringLength); Journal_Printf( errorStream, "%3d: %s\n", myRank, errorString ); File_Close( self->_file ); MPI_Abort(MPI_COMM_WORLD, writeResult ); } Memory_Free( buffer ); return 0; }
void TimeIntegrand_Add2TimesTimeDeriv( void* timeIntegrand, Variable* timeDerivVariable ) { TimeIntegrand* self = (TimeIntegrand*)timeIntegrand; Variable* variable = self->variable; double* timeDerivPtr; double* timeDeriv; Index component_I; Index componentCount = *variable->dataTypeCounts; Index array_I; Index arrayCount; timeDeriv = Memory_Alloc_Array( double, componentCount, "Time Deriv" ); memset( timeDeriv, 0, componentCount * sizeof( double ) ); /* Update Variables */ Variable_Update( variable ); Variable_Update( timeDerivVariable ); arrayCount = variable->arraySize; for ( array_I = 0 ; array_I < arrayCount ; array_I++ ) { TimeIntegrand_CalculateTimeDeriv( self, array_I, timeDeriv ); timeDerivPtr = Variable_GetPtrDouble( timeDerivVariable, array_I ); for ( component_I = 0 ; component_I < componentCount ; component_I++ ) { timeDerivPtr[ component_I ] += 2.0 * timeDeriv[ component_I ]; } } Memory_Free( timeDeriv ); }
void ElementCellLayoutSuite_TestElementCellLayout( ElementCellLayoutSuiteData* data ) { int procToWatch = data->nProcs > 1 ? 1 : 0; Cell_Index cell; Element_DomainIndex element; GlobalParticle testParticle; if( data->rank == procToWatch ) { for( element = 0; element < Mesh_GetLocalSize( data->mesh, data->nDims ); element++ ) { Cell_PointIndex count; Cell_Points cellPoints; cell = CellLayout_MapElementIdToCellId( data->elementCellLayout, element ); pcu_check_true( cell == element ); count = data->elementCellLayout->_pointCount( data->elementCellLayout, cell ); cellPoints = Memory_Alloc_Array( Cell_Point, count, "cellPoints" ); /* for the element cell layout, the elements map to cells as 1:1, as such the "points" which define the cell as the * same as the "nodes" which define the element */ data->elementCellLayout->_initialisePoints( data->elementCellLayout, cell, count, cellPoints ); testParticle.coord[0] = ( (cellPoints[0])[0] + (cellPoints[1])[0] ) / 2; testParticle.coord[1] = ( (cellPoints[0])[1] + (cellPoints[2])[1] ) / 2; testParticle.coord[2] = ( (cellPoints[0])[2] + (cellPoints[4])[2] ) / 2; pcu_check_true( CellLayout_IsInCell( data->elementCellLayout, cell, &testParticle ) ); testParticle.coord[0] = (cellPoints[count-2])[0] + 1; testParticle.coord[1] = (cellPoints[count-2])[1] + 1; testParticle.coord[2] = (cellPoints[count-2])[2] + 1; pcu_check_true( !CellLayout_IsInCell( data->elementCellLayout, cell, &testParticle ) ); Memory_Free( cellPoints ); } } }
void _OperatorSwarmVariable_Delete( void* _swarmVariable ) { OperatorSwarmVariable* self = (OperatorSwarmVariable*) _swarmVariable; Memory_Free( self->swarmVariableList ); _SwarmVariable_Delete( self ); }