示例#1
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* _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;
}
示例#3
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;
}
示例#4
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* _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* _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;
}
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;
}
示例#8
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;
}
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* _DofLayout_Copy( void* dofLayout, void* dest, Bool deep, Name nameExt, PtrMap* ptrMap ) {
	DofLayout*	self = (DofLayout*)dofLayout;
	DofLayout*	newDofLayout;
	PtrMap*		map = ptrMap;
	Bool			ownMap = False;
	
	if( !map ) {
		map = PtrMap_New( 10 );
		ownMap = True;
	}
	
	newDofLayout = (DofLayout*)_Stg_Component_Copy( self, dest, deep, nameExt, map );
	
	newDofLayout->_variableRegister = self->_variableRegister;
	newDofLayout->_numItemsInLayout = self->_numItemsInLayout;
	newDofLayout->_totalVarCount = self->_totalVarCount;
	
	if( deep ) {
		if( (newDofLayout->_variableEnabledSets = PtrMap_Find( map, self->_variableEnabledSets )) == NULL && self->_variableEnabledSets ) {
			Index	set_I;
			
			newDofLayout->_variableEnabledSets = Memory_Alloc_Array( IndexSet*, newDofLayout->_totalVarCount, "DofLayout->_variableEnabledSets" );
			for( set_I = 0; set_I < newDofLayout->_totalVarCount; set_I++ ) {
				newDofLayout->_variableEnabledSets[set_I] = (IndexSet*)Stg_Class_Copy( self->_variableEnabledSets[set_I], NULL, deep, nameExt, map );
			}
			PtrMap_Append( map, self->_variableEnabledSets, newDofLayout->_variableEnabledSets );
		}
		
		if( (newDofLayout->_varIndicesMapping = PtrMap_Find( map, self->_varIndicesMapping )) == NULL && self->_varIndicesMapping ) {
			newDofLayout->_varIndicesMapping = Memory_Alloc_Array( Variable_Index, newDofLayout->_totalVarCount, "DofLayout->_varIndicesMapping" );
			memcpy( newDofLayout->_varIndicesMapping, self->_varIndicesMapping, sizeof(Variable_Index) * newDofLayout->_totalVarCount );
			PtrMap_Append( map, self->_varIndicesMapping, newDofLayout->_varIndicesMapping );
		}
		
		if( (newDofLayout->dofCounts = PtrMap_Find( map, self->dofCounts )) == NULL && self->dofCounts ) {
			newDofLayout->dofCounts = Memory_Alloc_Array( Index, newDofLayout->_numItemsInLayout, "DofLayout->dofCounts" );
			memcpy( newDofLayout->dofCounts, self->dofCounts, sizeof(Index) * newDofLayout->_numItemsInLayout );
			PtrMap_Append( map, self->dofCounts, newDofLayout->dofCounts );
		}
		
		if( (newDofLayout->varIndices = PtrMap_Find( map, self->varIndices )) == NULL && self->varIndices ) {
			Index	idx_I;
			
			newDofLayout->varIndices = Memory_Alloc_2DComplex( Variable_Index, newDofLayout->_numItemsInLayout, self->dofCounts, "DofLayout->varIndices" );
			for( idx_I = 0; idx_I < newDofLayout->_numItemsInLayout; idx_I++ ) {
				memcpy( newDofLayout->varIndices[idx_I], self->varIndices[idx_I], sizeof(Variable_Index) * newDofLayout->dofCounts[idx_I] );
			}
			PtrMap_Append( map, self->varIndices, newDofLayout->varIndices );
		}
	}
void* _ForceVector_Copy( void* forceVector, void* dest, Bool deep, Name nameExt, PtrMap* ptrMap ) {
	ForceVector*	self = (ForceVector*)forceVector;
	ForceVector*	newForceVector;
	PtrMap*		map = ptrMap;
	Bool		ownMap = False;
	
	if( !map ) {
		map = PtrMap_New( 10 );
		ownMap = True;
	}
	
	newForceVector = _SolutionVector_Copy( self, dest, deep, nameExt, map );
	
	/* TODO: copy vector? */
	newForceVector->entryPoint_Register = self->entryPoint_Register;
	newForceVector->localSize = self->localSize;
	
	if( deep ) {
		newForceVector->assembleForceVector = (FeEntryPoint*)Stg_Class_Copy( self->assembleForceVector, NULL, deep, nameExt, map );
		if( self->_assembleForceVectorEPName ) {
			if( nameExt ) {
				unsigned	nameLen = strlen( self->_assembleForceVectorEPName );
				
				newForceVector->_assembleForceVectorEPName = Memory_Alloc_Bytes_Unnamed( nameLen + strlen( nameExt ) + 1, "FV->vecEPName" );
				memcpy( newForceVector->_assembleForceVectorEPName, self->_assembleForceVectorEPName, nameLen );
				strcpy( newForceVector->_assembleForceVectorEPName + nameLen, nameExt );
			}
			else {
				newForceVector->_assembleForceVectorEPName = StG_Strdup( self->_assembleForceVectorEPName );
			}
		}
		else {
			newForceVector->_assembleForceVectorEPName = NULL;
		}

	}
	else {
		newForceVector->debug = self->debug;
		newForceVector->_assembleForceVectorEPName = self->_assembleForceVectorEPName;
		newForceVector->assembleForceVector = self->assembleForceVector;
	}
	
	if( ownMap ) {
		Stg_Class_Delete( map );
	}
	
	return (void*)newForceVector;
}
示例#12
0
void* Stg_Generic_Copy( 
	Stg_Class_CopyFunction* copyFunc,
	void* obj, 
	void* dest, 
	Bool deep, 
	Name nameExt, 
	struct PtrMap* ptrMap ) 
{
	void*		newObj;
	Bool		ownPtrMap = False;

	if ( obj == NULL ) {
		return NULL;
	}

	if ( copyFunc == NULL ) {
		/* TODO: change to Journal */
		printf( "Warning: attempting to copy a class with no copy method, return 'self'.\n" );
		return obj;
	}

	if( !ptrMap ) {
		ptrMap = PtrMap_New( 1 );
		ownPtrMap = True;
	}
	
	if ( (newObj = PtrMap_Find( ptrMap, obj )) == NULL ) {
		newObj = copyFunc( obj, dest, deep, nameExt, ptrMap );
	}

	if ( newObj != dest ) {
		/* Whether this is a new instance existing ptr map fetch, inc the counter because its being used again */
		/* But only do it when its not a destination copy because we can't assume that it is a single dynamic obj */
		Memory_CountInc( newObj );
	}

	if ( ownPtrMap && ptrMap ) {
		Stg_Class_Delete( ptrMap );
	}
	
	return (void*)newObj;
}
示例#13
0
void* _SingleCellLayout_Copy( void* singleCellLayout, void* dest, Bool deep, Name nameExt, PtrMap* ptrMap ) {
	SingleCellLayout*	self = (SingleCellLayout*)singleCellLayout;
	SingleCellLayout*	newSingleCellLayout;
	PtrMap*			map = ptrMap;
	Bool			ownMap = False;
	
	if( !map ) {
		map = PtrMap_New( 10 );
		ownMap = True;
	}
	
	newSingleCellLayout = _CellLayout_Copy( self, dest, deep, nameExt, ptrMap );
	
	newSingleCellLayout->dimExists[0] = self->dimExists[0];
	newSingleCellLayout->dimExists[1] = self->dimExists[1];
	newSingleCellLayout->dimExists[2] = self->dimExists[2];
	newSingleCellLayout->min[0] = self->min[0];
	newSingleCellLayout->min[1] = self->min[1];
	newSingleCellLayout->min[2] = self->min[2];
	newSingleCellLayout->max[0] = self->max[0];
	newSingleCellLayout->max[1] = self->max[1];
	newSingleCellLayout->max[2] = self->max[2];
	newSingleCellLayout->pointCount = self->pointCount;
	
	if( deep ) {
		if( (newSingleCellLayout->cellPointCoords = PtrMap_Find( map, self->cellPointCoords )) == NULL && self->cellPointCoords ) {
			newSingleCellLayout->cellPointCoords = Memory_Alloc_Array( Coord, newSingleCellLayout->pointCount, "SingleCellLayout->cellPoints" );
			memcpy( newSingleCellLayout->cellPointCoords, self->cellPointCoords, sizeof(Coord) * newSingleCellLayout->pointCount );
			PtrMap_Append( map, self->cellPointCoords, newSingleCellLayout->cellPointCoords );
		}
	}
	else {
		newSingleCellLayout->cellPointCoords = self->cellPointCoords;
	}
	
	if( ownMap ) {
		Stg_Class_Delete( map );
	}
	
	return (void*)newSingleCellLayout;
}
示例#14
0
void* _SwarmDump_Copy( void* swarmDump, void* dest, Bool deep, Name nameExt, PtrMap* ptrMap ) {
	SwarmDump*	self = (SwarmDump*)swarmDump;
	SwarmDump*	newSwarmDump;
	PtrMap*			map = ptrMap;
	Bool			ownMap = False;
	
	if( !map ) {
		map = PtrMap_New( 10 );
		ownMap = True;
	}
	
	newSwarmDump = _Stg_Component_Copy( self, dest, deep, nameExt, map );
	memcpy( newSwarmDump->swarmList, self->swarmList, self->swarmCount * sizeof(Swarm*) );
	newSwarmDump->swarmCount = self->swarmCount;

	if( ownMap ) {
		Stg_Class_Delete( map );
	}
				
	return (void*)newSwarmDump;
}
void* _PeriodicBoundariesManager_Copy( void* periodicBCsManager, void* dest, Bool deep, Name nameExt, PtrMap* ptrMap ) {
	PeriodicBoundariesManager*	self = (PeriodicBoundariesManager*)periodicBCsManager;
	PeriodicBoundariesManager*	newPeriodicBCsManager;
	PtrMap*							map = ptrMap;
	Bool								ownMap = False;
	
	if( !map ) {
		map = PtrMap_New( 10 );
		ownMap = True;
	}

	newPeriodicBCsManager = _Stg_Class_Copy( self, dest, deep, nameExt, map );

	newPeriodicBCsManager->count = self->count;
	newPeriodicBCsManager->size = self->size;
	newPeriodicBCsManager->delta = self->delta;

	if ( deep ) {
		newPeriodicBCsManager->dictionary = (Dictionary*)Stg_Class_Copy( self->dictionary, NULL, deep, nameExt, map );
		newPeriodicBCsManager->mesh = (Mesh*)Stg_Class_Copy( self->mesh, NULL, deep, nameExt, map );
		newPeriodicBCsManager->swarm = (Swarm*)Stg_Class_Copy( self->swarm, NULL, deep, nameExt, map );
		newPeriodicBCsManager->debug = self->debug;
		newPeriodicBCsManager->boundaries = Memory_Alloc_Array( PeriodicBoundary, self->size, "PeriodicBoundaries" );
		memcpy( newPeriodicBCsManager->boundaries, self->boundaries, sizeof(PeriodicBoundary)*self->count );	
	}
	else {
		newPeriodicBCsManager->dictionary = self->dictionary;
		newPeriodicBCsManager->mesh = self->mesh;
		newPeriodicBCsManager->swarm = self->swarm;
		newPeriodicBCsManager->boundaries = self->boundaries;
		newPeriodicBCsManager->debug = self->debug;
	}
	
	if( ownMap ) {
		Stg_Class_Delete( map );
	}
	
	return (void*)newPeriodicBCsManager;
}
void* _LinkedDofInfo_Copy( void* linkedDofInfo, void* dest, Bool deep, Name nameExt, PtrMap* ptrMap ) {
	LinkedDofInfo*	self = (LinkedDofInfo*)linkedDofInfo;
	LinkedDofInfo*	newLinkedDofInfo;
	PtrMap*			map = ptrMap;
	Bool				ownMap = False;
	
	if( !map ) {
		map = PtrMap_New( 10 );
		ownMap = True;
	}
	
	newLinkedDofInfo = _Stg_Class_Copy( self, dest, deep, nameExt, map );
	
	/* Virtual methods */
	newLinkedDofInfo->linkedDofSetsCount = self->linkedDofSetsCount;
	newLinkedDofInfo->linkedDofSetsSize = self->linkedDofSetsSize;
	newLinkedDofInfo->linkedDofSetsDelta = self->linkedDofSetsDelta;
	
	if ( deep ) {
		newLinkedDofInfo->dofLayout = (DofLayout*)Stg_Class_Copy( self->dofLayout, NULL, deep, nameExt, map );
		newLinkedDofInfo->mesh = (Mesh*)Stg_Class_Copy( self->mesh, NULL, deep, nameExt, map );

		if ( (newLinkedDofInfo->linkedDofTbl = PtrMap_Find( map, self->linkedDofTbl )) == NULL && self->linkedDofTbl ) {
			Node_Index	node_I;
			Dof_Index	dof_I;
			newLinkedDofInfo->linkedDofTbl = Memory_Alloc_2DComplex( int, self->dofLayout->_numItemsInLayout, self->dofLayout->dofCounts, "linkedDofInfo->linkedDofTbl" );
			for ( node_I = 0; node_I < self->dofLayout->_numItemsInLayout; node_I++ ) {
				for ( dof_I = 0; dof_I < self->dofLayout->dofCounts[node_I]; dof_I++ ) {
					newLinkedDofInfo->linkedDofTbl[node_I][dof_I] =
						self->linkedDofTbl[node_I][dof_I];
				}
			}
			PtrMap_Append( map, self->linkedDofTbl, newLinkedDofInfo->linkedDofTbl );
		}
		if ( (newLinkedDofInfo->eqNumsOfLinkedDofs = PtrMap_Find( map, self->eqNumsOfLinkedDofs )) == NULL && self->eqNumsOfLinkedDofs ) {	
			newLinkedDofInfo->eqNumsOfLinkedDofs = Memory_Alloc_Array( int, self->linkedDofSetsCount, "linkedDofInfo->eqNumsOfLinkedDofs" );
			memcpy( newLinkedDofInfo->eqNumsOfLinkedDofs, self->eqNumsOfLinkedDofs, self->linkedDofSetsCount * sizeof(int) );
			PtrMap_Append( map, self->eqNumsOfLinkedDofs, newLinkedDofInfo->eqNumsOfLinkedDofs );
		}
示例#17
0
void* Stg_Generic_Copy( 
	Stg_Class_CopyFunction* copyFunc,
	void* obj, 
	void* dest, 
	Bool deep, 
	Name nameExt, 
	struct PtrMap* ptrMap ) 
{
	void*		newObj;
	Bool		ownPtrMap = False;

	if ( obj == NULL ) {
		return NULL;
	}

	if ( copyFunc == NULL ) {
		/* TODO: change to Journal */
		printf( "Warning: attempting to copy a class with no copy method, return 'self'.\n" );
		return obj;
	}

	if( !ptrMap ) {
		ptrMap = PtrMap_New( 1 );
		ownPtrMap = True;
	}
	
	if ( (newObj = PtrMap_Find( ptrMap, obj )) == NULL ) {
		newObj = copyFunc( obj, dest, deep, nameExt, ptrMap );
	}

	if ( ownPtrMap && ptrMap ) {
		Stg_Class_Delete( ptrMap );
	}
	
	return (void*)newObj;
}
示例#18
0
void* _EntryPoint_Copy( void* entryPoint, void* dest, Bool deep, Name nameExt, PtrMap* ptrMap ) {
   EntryPoint* self = (EntryPoint*)entryPoint;
   EntryPoint* newEntryPoint;
   PtrMap*     map = ptrMap;
   Bool        ownMap = False;
   
   if( !map ) {
      map = PtrMap_New( 10 );
      ownMap = True;
   }
   
   newEntryPoint = (EntryPoint*)_Stg_Object_Copy( self, dest, deep, nameExt, map );
   
   /* Virtual methods */
   newEntryPoint->_getRun = self->_getRun;
   
   newEntryPoint->castType = self->castType;
   newEntryPoint->run = self->run;
   
   if( deep ) {
      newEntryPoint->hooks = (HookList*)Stg_Class_Copy( self->hooks, NULL, deep, nameExt, map );
      
      if( newEntryPoint->hooks ) {
         if( self->alwaysFirstHook ) {
            if( nameExt ) {
               Name tmpName;
               
               tmpName = Memory_Alloc_Array(
                  char,
                  strlen( Stg_Object_GetName( self->alwaysFirstHook ) ) + strlen( nameExt ) + 1,
                  "tmpName" );

               strcpy( tmpName, Stg_Object_GetName( self->alwaysFirstHook ) );
               strcpy( &tmpName[strlen( Stg_Object_GetName( self->alwaysFirstHook ) )], nameExt );
               
               newEntryPoint->alwaysFirstHook = (Hook*)Stg_ObjectList_Get( newEntryPoint->hooks, tmpName );
               Memory_Free( tmpName );
            }
            else {
               newEntryPoint->alwaysFirstHook = (Hook*)Stg_ObjectList_Get(
                  newEntryPoint->hooks,
                  Stg_Object_GetName( self->alwaysFirstHook ) );
            }
         }
         else {
            self->alwaysFirstHook = NULL;
         }
         
         if( self->alwaysLastHook ) {
            if( nameExt ) {
               Name tmpName;
               
               tmpName = Memory_Alloc_Array(
                  char,
                  strlen( Stg_Object_GetName( self->alwaysLastHook ) ) + strlen( nameExt ) + 1,
                  "tmpName" );

               strcpy( tmpName, Stg_Object_GetName( self->alwaysLastHook ) );
               strcpy( &tmpName[strlen( Stg_Object_GetName( self->alwaysLastHook ) )], nameExt );
               
               newEntryPoint->alwaysLastHook = (Hook*)Stg_ObjectList_Get( newEntryPoint->hooks, tmpName );
               Memory_Free( tmpName );
            }
            else {
               newEntryPoint->alwaysLastHook = (Hook*)Stg_ObjectList_Get(
                  newEntryPoint->hooks,
                  Stg_Object_GetName( self->alwaysLastHook ) );
            }
         }
void* _VariableCondition_Copy( void* variableCondition, void* dest, Bool deep, Name nameExt, struct PtrMap* ptrMap ) {
	VariableCondition*	self = (VariableCondition*)variableCondition;
	VariableCondition*	newVariableCondition;
	PtrMap*			map = ptrMap;
	Bool			ownMap = False;
	
	if( !map ) {
		map = PtrMap_New( 10 );
		ownMap = True;
	}
	
	newVariableCondition = (VariableCondition*)_Stg_Component_Copy( self, dest, deep, nameExt, map );
	
	/* Virtual methods */
	newVariableCondition->_buildSelf = self->_buildSelf;
	newVariableCondition->_printConcise = self->_printConcise;
	newVariableCondition->_readDictionary = self->_readDictionary;
	newVariableCondition->_getSet = self->_getSet;
	newVariableCondition->_getVariableCount = self->_getVariableCount;
	newVariableCondition->_getVariableIndex = self->_getVariableIndex;
	newVariableCondition->_getValueIndex = self->_getValueIndex;
	newVariableCondition->_getValueCount = self->_getValueCount;
	newVariableCondition->_getValue = self->_getValue;
	
	newVariableCondition->variable_Register = self->variable_Register;
	newVariableCondition->conFunc_Register = self->conFunc_Register;
	newVariableCondition->dictionary = self->dictionary;
	newVariableCondition->indexCount = self->indexCount;
	newVariableCondition->valueCount = self->valueCount;
	
	if( deep ) {
		newVariableCondition->_set = (IndexSet*)Stg_Class_Copy( self->_set, NULL, deep, nameExt, map );
		
		if( (newVariableCondition->indexTbl = (Index*)PtrMap_Find( map, self->indexTbl )) == NULL && self->indexTbl ) {
			newVariableCondition->indexTbl = (Index*)Memory_Alloc_Array( Index, newVariableCondition->indexCount, "VariableCondition->indexTbl" );
			memcpy( newVariableCondition->indexTbl, self->indexTbl, sizeof(Index) * newVariableCondition->indexCount );
			PtrMap_Append( map, newVariableCondition->indexTbl, self->indexTbl );
		}
		
		if( (newVariableCondition->vcVarCountTbl = (VariableCondition_VariableIndex*)PtrMap_Find( map, self->vcVarCountTbl )) == NULL && self->vcVarCountTbl ) {
			newVariableCondition->vcVarCountTbl = Memory_Alloc_Array( VariableCondition_VariableIndex, newVariableCondition->indexCount, "VC->vcVarCountTbl" );
			memcpy( newVariableCondition->vcVarCountTbl, self->vcVarCountTbl, sizeof(VariableCondition_VariableIndex) * newVariableCondition->indexCount );
			PtrMap_Append( map, newVariableCondition->vcVarCountTbl, self->vcVarCountTbl );
		}
		
		if( (newVariableCondition->vcTbl = (VariableCondition_Tuple**)PtrMap_Find( map, self->vcTbl )) == NULL && self->vcTbl ) {
			Index	idx_I;
			
			newVariableCondition->vcTbl = Memory_Alloc_2DComplex( VariableCondition_Tuple, newVariableCondition->indexCount, newVariableCondition->vcVarCountTbl, "VC->vcTbl" );
			for( idx_I = 0; idx_I < newVariableCondition->indexCount; idx_I++ ) {
				memcpy( newVariableCondition->vcTbl[idx_I], self->vcTbl[idx_I], sizeof(VariableCondition_Tuple) * newVariableCondition->vcVarCountTbl[idx_I] );
			}
			PtrMap_Append( map, newVariableCondition->vcTbl, self->vcTbl );
		}
		
		if( (newVariableCondition->valueTbl = (VariableCondition_Value*)PtrMap_Find( map, self->valueTbl )) == NULL && self->valueTbl ) {
			newVariableCondition->valueTbl = Memory_Alloc_Array( VariableCondition_Value, newVariableCondition->valueCount, "VC->valueTbl" );
			memcpy( newVariableCondition->valueTbl, self->valueTbl, sizeof(VariableCondition_Value) * newVariableCondition->indexCount );
			PtrMap_Append( map, newVariableCondition->valueTbl, self->valueTbl );
		}
	}
	else {
		newVariableCondition->_set = self->_set;
		newVariableCondition->indexTbl = self->indexTbl;
		newVariableCondition->vcVarCountTbl = self->vcVarCountTbl;
		newVariableCondition->vcTbl = self->vcTbl;
		newVariableCondition->valueTbl = self->valueTbl;
	}
	
	if( ownMap ) {
		Stg_Class_Delete( map );
	}
	
	return (void*)newVariableCondition;
}
void PtrMapSuite_Setup( PtrMapSuiteData* data ) {
   data->map = PtrMap_New( 10 );
}
示例#21
0
void* _MeshDecomp_Copy( void* meshDecomp, void* dest, Bool deep, Name nameExt, PtrMap* ptrMap ) {
	MeshDecomp*	self = (MeshDecomp*)meshDecomp;
	MeshDecomp*	newMeshDecomp;
	PtrMap*		map = ptrMap;
	Bool		ownMap = False;
	
	if( !map ) {
		map = PtrMap_New( 10 );
		ownMap = True;
	}
	
	newMeshDecomp = (MeshDecomp*)_Stg_Component_Copy( self, dest, deep, nameExt, map );
	
	/* Virtual methods */
	newMeshDecomp->nodeMapLocalToGlobal = self->nodeMapLocalToGlobal;
	newMeshDecomp->nodeMapDomainToGlobal = self->nodeMapDomainToGlobal;
	newMeshDecomp->nodeMapShadowToGlobal = self->nodeMapShadowToGlobal;
	newMeshDecomp->nodeMapGlobalToLocal = self->nodeMapGlobalToLocal;
	newMeshDecomp->nodeMapGlobalToDomain = self->nodeMapGlobalToDomain;
	newMeshDecomp->nodeMapGlobalToShadow = self->nodeMapGlobalToShadow;
	newMeshDecomp->elementMapLocalToGlobal = self->elementMapLocalToGlobal;
	newMeshDecomp->elementMapDomainToGlobal = self->elementMapDomainToGlobal;
	newMeshDecomp->elementMapShadowToGlobal = self->elementMapShadowToGlobal;
	newMeshDecomp->elementMapGlobalToLocal = self->elementMapGlobalToLocal;
	newMeshDecomp->elementMapGlobalToDomain = self->elementMapGlobalToDomain;
	newMeshDecomp->elementMapGlobalToShadow = self->elementMapGlobalToShadow;
	newMeshDecomp->shadowProcCount = self->shadowProcCount;
	newMeshDecomp->shadowBuildProcs = self->shadowBuildProcs;
	newMeshDecomp->shadowProcElementCount = self->shadowProcElementCount;
	newMeshDecomp->procWithElement = self->procWithElement;
	
	newMeshDecomp->dictionary = self->dictionary;
	newMeshDecomp->communicator = self->communicator;
	newMeshDecomp->rank = self->rank;
	newMeshDecomp->nproc = self->nproc;
	newMeshDecomp->procsInUse = self->procsInUse;
	newMeshDecomp->allowUnusedCPUs = self->allowUnusedCPUs;
	newMeshDecomp->allowPartitionOnNode = self->allowPartitionOnNode;
	newMeshDecomp->allowPartitionOnElement = self->allowPartitionOnElement;
	newMeshDecomp->allowUnbalancing = self->allowUnbalancing;
	newMeshDecomp->storage = self->storage;
	newMeshDecomp->shadowDepth = self->shadowDepth;
	newMeshDecomp->nodeGlobalCount = self->nodeGlobalCount;
	newMeshDecomp->nodeLocalCount = self->nodeLocalCount;
	newMeshDecomp->nodeShadowCount = self->nodeShadowCount;
	newMeshDecomp->nodeDomainCount = self->nodeDomainCount;
	newMeshDecomp->elementGlobalCount = self->elementGlobalCount;
	newMeshDecomp->elementLocalCount = self->elementLocalCount;
	newMeshDecomp->elementShadowCount = self->elementShadowCount;
	newMeshDecomp->elementDomainCount = self->elementDomainCount;
	
	if( deep ) {
		newMeshDecomp->procTopology = (Topology*)Stg_Class_Copy( self->procTopology, NULL, deep, nameExt, map );
		newMeshDecomp->elementLayout = (ElementLayout*)Stg_Class_Copy( self->elementLayout, NULL, deep, nameExt, map );
		newMeshDecomp->nodeLayout = (NodeLayout*)Stg_Class_Copy( self->nodeLayout, NULL, deep, nameExt, map );
		
		if( (newMeshDecomp->localNodeSets = PtrMap_Find( map, self->localNodeSets )) == NULL && self->localNodeSets ) {
			Partition_Index		proc_I;
			
			newMeshDecomp->localNodeSets = Memory_Alloc_Array( IndexSet*, newMeshDecomp->procsInUse, "MeshDecomp->localNodeSets" );
			for( proc_I = 0; proc_I < newMeshDecomp->procsInUse; proc_I++ ) {
				newMeshDecomp->localNodeSets[proc_I] = (IndexSet*)Stg_Class_Copy( self->localNodeSets[proc_I], NULL, deep, nameExt, map );
			}
		}
		
		if( (newMeshDecomp->shadowNodeSets = PtrMap_Find( map, self->shadowNodeSets )) == NULL && self->shadowNodeSets ) {
			Partition_Index		proc_I;
			
			newMeshDecomp->shadowNodeSets = Memory_Alloc_Array( IndexSet*, newMeshDecomp->procsInUse, "MeshDecomp->shadowNodeSets" );
			for( proc_I = 0; proc_I < newMeshDecomp->procsInUse; proc_I++ ) {
				newMeshDecomp->shadowNodeSets[proc_I] = (IndexSet*)Stg_Class_Copy( self->shadowNodeSets[proc_I], NULL, deep, nameExt, map );
			}
		}