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;
}
Esempio n. 2
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* _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* _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* _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* _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;
}
void* _ExtensionInfo_Copy( void* extensionInfo, void* dest, Bool deep, Name nameExt, struct PtrMap* ptrMap  ) {
	ExtensionInfo*		self = (ExtensionInfo*)extensionInfo;
	ExtensionInfo*		newExtensionInfo;
	
	/* Copy parent */
	newExtensionInfo = (ExtensionInfo*)_Stg_Object_Copy( self, dest, deep, nameExt, ptrMap );
	
	newExtensionInfo->_dataCopy = self->_dataCopy;
	newExtensionInfo->key = self->key;
	newExtensionInfo->originalSize = self->originalSize;
	newExtensionInfo->size = self->size;
	newExtensionInfo->isRegistered = self->isRegistered;
	newExtensionInfo->itemSize = self->itemSize;
	newExtensionInfo->count = self->count;
	newExtensionInfo->offset = self->offset;
	newExtensionInfo->handle = self->handle;	

	newExtensionInfo->extensionManager = (ExtensionManager*)Stg_Class_Copy( self->extensionManager, NULL, deep, nameExt, ptrMap );

	if ( self->data ) {
		newExtensionInfo->data = PtrMap_Find( ptrMap, self->data );
		Journal_Firewall(
			newExtensionInfo->data != NULL ,
			Journal_Register( Error_Type, __FILE__ ),
			"Copy Error: Attempting to copy ExtensionInfo before data\n" );
	}
	else {
		newExtensionInfo->data = NULL;
	}
	
	return newExtensionInfo;
}
void* _OneToOneMapper_Copy( void* mapper, void* dest, Bool deep, Name nameExt, PtrMap* ptrMap ) {
	OneToOneMapper* self = (OneToOneMapper*)mapper;
	OneToOneMapper* newCopy;
	
	newCopy = (OneToOneMapper*)_IntegrationPointMapper_Copy( self, dest, deep, nameExt, ptrMap );
	newCopy->materialSwarm = (MaterialPointsSwarm*)Stg_Class_Copy( self->materialSwarm, NULL, deep, nameExt, ptrMap );

	return newCopy;
}
Esempio n. 9
0
void* _ClassHook_Copy( void* hook, void* dest, Bool deep, Name nameExt, PtrMap* ptrMap ) {
	ClassHook*	self = (ClassHook*)hook;
	ClassHook*	newClassHook;
	
	newClassHook = _Hook_Copy( self, dest, deep, nameExt, ptrMap );

	newClassHook->reference = Stg_Class_Copy( self->reference, dest, deep, nameExt, ptrMap );
	
	return (void*)newClassHook;
}
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 );
		}
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* _Stg_ObjectList_Copy( void* namedObjectList, void* dest, Bool deep, Name nameExt, struct PtrMap* ptrMap ) {
   Stg_ObjectList* self = (Stg_ObjectList*) namedObjectList;
   Stg_ObjectList* newObjectList;
   
   newObjectList = (Stg_ObjectList*)_Stg_Class_Copy( self, dest, deep, nameExt, ptrMap );
   
   newObjectList->_append = self->_append;
   newObjectList->_prepend = self->_prepend;
   newObjectList->_append = self->_append;
   newObjectList->_replaceAll = self->_replaceAll;
   newObjectList->_replace = self->_replace;
   newObjectList->_insertBefore = self->_insertBefore;
   newObjectList->_insertAfter = self->_insertAfter;
   newObjectList->_remove = self->_remove;
   newObjectList->_getIndex = self->_getIndex;
   newObjectList->_get = self->_get;
   newObjectList->_allocMoreMemory = self->_allocMoreMemory;
   newObjectList->_insertAtIndex = self->_insertAtIndex;
   newObjectList->_removeByIndex = self->_removeByIndex;
   newObjectList->_deleteAllObjects = self->_deleteAllObjects;
   newObjectList->count = self->count;
   newObjectList->_size = self->_size;
   newObjectList->_delta = self->_delta;
   newObjectList->_noJournalingInCopy = self->_noJournalingInCopy;
   
   /*
    * As this class is used by the Journal backend, making Journal calls when used in the Journal backend,
    * is problematic...  in this case work around it. It seems to only be an issue for copying. 
    */
   if( self->_noJournalingInCopy ) {
      assert( deep );
   }
   else {
      Journal_Firewall( deep, Journal_Register( Error_Type, Stg_ObjectList_Type ), "Shallow copy not yet implemented\n");
   }
   if( deep ) {
      unsigned obj_I;
      
      newObjectList->data = (Stg_ObjectPtr*)Memory_Alloc_Array( 
         Stg_ObjectPtr, 
         newObjectList->_size, 
         "ObjectList->data" );
      
      for( obj_I = 0; obj_I < newObjectList->count; obj_I++ ) {
         newObjectList->data[obj_I] = (Stg_ObjectPtr)Stg_Class_Copy( self->data[obj_I], NULL, deep, nameExt, ptrMap );
      }
   }
   
   return newObjectList;
}
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* _IntegrationPointsSwarm_Copy( void* integrationPoints, void* dest, Bool deep, Name nameExt, PtrMap* ptrMap ) {
   IntegrationPointsSwarm* self = (IntegrationPointsSwarm*)integrationPoints;
   IntegrationPointsSwarm* newIntegrationPointsSwarm;
   
   newIntegrationPointsSwarm = (IntegrationPointsSwarm*)_Swarm_Copy( self, dest, deep, nameExt, ptrMap );

   newIntegrationPointsSwarm->mesh = (FeMesh*)Stg_Class_Copy(
      self->mesh,
      NULL,
      deep,
      nameExt,
      ptrMap );

   if ( self->weights != NULL ) {
      newIntegrationPointsSwarm->weights = (WeightsCalculator*)Stg_Class_Copy(
         self->weights,
         NULL,
         deep,
         nameExt,
         ptrMap );
   }
   newIntegrationPointsSwarm->mapper = (IntegrationPointMapper*)Stg_Class_Copy(
      self->mapper,
      NULL,
      deep,
      nameExt,
      ptrMap );
   newIntegrationPointsSwarm->materials_Register = self->materials_Register;
   newIntegrationPointsSwarm->weightVariable = (SwarmVariable*)Stg_Class_Copy(
      self->weightVariable,
      NULL,
      deep,
      nameExt,
      ptrMap );
   
   return (void*)newIntegrationPointsSwarm;
}
void* _MaterialPointsSwarm_Copy( void* swarm, void* dest, Bool deep, Name nameExt, PtrMap* ptrMap ) {
	MaterialPointsSwarm*	self = (MaterialPointsSwarm*)swarm;
	MaterialPointsSwarm*	newMaterialPointsSwarm;
	
	newMaterialPointsSwarm = (MaterialPointsSwarm*)_Swarm_Copy( self, dest, deep, nameExt, ptrMap );

	newMaterialPointsSwarm->materialIndexVariable = (SwarmVariable*)Stg_Class_Copy(
				self->materialIndexVariable,
				NULL,
				deep,
				nameExt,
				ptrMap );
	
	return (void*)newMaterialPointsSwarm;
}
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;
}
Esempio n. 17
0
void* _NamedObject_Register_Copy( void* namedObjectRegister, void* dest, Bool deep, Name nameExt, struct PtrMap* ptrMap ) {
	NamedObject_Register*	self = (NamedObject_Register*)namedObjectRegister;
	NamedObject_Register*	newNamedObjectRegister;
	
	newNamedObjectRegister = _Stg_Class_Copy( self, dest, deep, nameExt, ptrMap );
	
	Journal_Firewall( 
		deep, 
		Journal_Register( Error_Type, NamedObject_Register_Type ), 
		"Shallow copy not yet implemented\n" );
	if( deep ) {
		newNamedObjectRegister->objects = Stg_Class_Copy( self->objects, NULL, deep, nameExt, ptrMap );
	}
	
	return newNamedObjectRegister;
}
Esempio n. 18
0
void* _Stg_ObjectAdaptor_Copy( void* objectAdaptor, void* dest, Bool deep, Name nameExt, struct PtrMap* ptrMap ) {
	Stg_ObjectAdaptor* self = (Stg_ObjectAdaptor*)objectAdaptor;
	Stg_ObjectAdaptor* newTuple;

	newTuple = _Stg_Object_Copy( self, dest, deep, nameExt, ptrMap );
	
	newTuple->isGlobal = self->isGlobal;
	newTuple->isStgClass = self->isStgClass;
	
	Journal_Firewall( deep, Journal_Register( Error_Type, Stg_ObjectAdaptor_Type ), "Shallow copy not yet implemented\n" );
	if( deep ) {
		if( self->isGlobal ) {
			newTuple->iOwn = False;
			newTuple->dataPtr = self->dataPtr;
		}
		else {
			newTuple->iOwn = True;
			
			Journal_Firewall( 
				self->iOwn, 
				Journal_Register( Error_Type, Stg_ObjectAdaptor_Type ), 
				"Deep copy for Stg_ObjectAdaptors that do not own the non-global data is not yet implemented\n" );
			
			/* TODO: DOES NOT check if the object has already been copied (i.e. use ptrMap). Beacuse if we assume
			   ownership, we could not do so without an instance count machanism. */
			/* if not in ptr map */
			if( self->isStgClass ) {
				newTuple->dataPtr = Stg_Class_Copy( self->dataPtr, 0, deep, nameExt, ptrMap );
			}
			else {
				Journal_Firewall( 
					self->ptrCopy != NULL, 
					Journal_Register( Error_Type, Stg_ObjectAdaptor_Type ), 
					"Deep copy for pointer based Stg_ObjectAdaptors requires a copy function attached... not provided!\n" );
				newTuple->dataPtr = self->ptrCopy( self->dataPtr, 0, deep, nameExt, ptrMap );
			}
			/* else if in ptr map ... copy ptr value from there. */
		}
	}
	
	return newTuple;
}
void* _Variable_Register_Copy( void* vr, void* dest, Bool deep, Name nameExt, PtrMap* ptrMap ) {

	Variable_Register* self = (Variable_Register*)vr;
	Variable_Register* newVariableRegister;
	int ii;

	newVariableRegister = (Variable_Register*)_Stg_Class_Copy( self, dest, deep, nameExt, ptrMap );
	PtrMap_Append( ptrMap, self, newVariableRegister );

	newVariableRegister->count = self->count;
	newVariableRegister->_size = self->_size;
	newVariableRegister->_variable = Memory_Alloc_Array( Variable*, self->_size, "Variable_Register->_variable" );
	memset(newVariableRegister->_variable, 0, sizeof(Variable*)*self->_size);

	for ( ii = 0; ii < self->count; ++ii ) {
		if ( (newVariableRegister->_variable[ii] = (Variable*)PtrMap_Find( ptrMap, self->_variable[ii] )) == NULL ) {
			newVariableRegister->_variable[ii] = (Variable*)Stg_Class_Copy( self->_variable[ii], NULL, deep, nameExt, ptrMap );
		}
	}

	return newVariableRegister;
}
Esempio n. 20
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;
}
Dictionary_Entry_Value* Dictionary_Entry_Value_Copy(
		Dictionary_Entry_Value*  self,
		Bool deep )
{
	Dictionary_Entry_Value* copy = NULL;
	
	switch (self->type) {
		case Dictionary_Entry_Value_Type_String:
			copy = Dictionary_Entry_Value_FromString( self->as.typeString );
			break;
		case Dictionary_Entry_Value_Type_Double:
			copy = Dictionary_Entry_Value_FromDouble( self->as.typeDouble );
			break;
		case Dictionary_Entry_Value_Type_UnsignedInt:
			copy = Dictionary_Entry_Value_FromUnsignedInt( self->as.typeUnsignedInt );
			break;
		case Dictionary_Entry_Value_Type_Int:
			copy = Dictionary_Entry_Value_FromInt( self->as.typeInt );
			break;
		case Dictionary_Entry_Value_Type_UnsignedLong:
			copy = Dictionary_Entry_Value_FromUnsignedLong( self->as.typeUnsignedLong );
			break;
		case Dictionary_Entry_Value_Type_Bool:
			copy = Dictionary_Entry_Value_FromBool( self->as.typeBool );
			break;
		case Dictionary_Entry_Value_Type_List:
			if ( False == deep ) {
				Stream* errorStream = Journal_Register( Error_Type, "Dictionary_Entry_Value" );
				Journal_Firewall( False, errorStream, "In func %s: Shallow copy operation of list DEV not supported.\n", __func__ );
			}
			else {
				Dictionary_Entry_Value* cur = self->as.typeList->first;
				Dictionary_Entry_Value* copiedEntry = NULL;

				copy = Dictionary_Entry_Value_NewList();
				while ( cur ) {
					copiedEntry = Dictionary_Entry_Value_Copy( cur, True );
					Dictionary_Entry_Value_AddElement( copy, copiedEntry );
					cur = cur->next;
				}	
			}
			break;
		case Dictionary_Entry_Value_Type_Struct:
			if ( False == deep ) {
				copy = Dictionary_Entry_Value_FromStruct( self->as.typeStruct );
			}
			else {
				Dictionary* copiedDict;
				copiedDict = (Dictionary*)Stg_Class_Copy( self->as.typeStruct,
					NULL, True, NULL, NULL );
				copy = Dictionary_Entry_Value_FromStruct( copiedDict );
			}
			break;
		default: {
			Stream* errorStream = Journal_Register( Error_Type, "Dictionary_Entry_Value" );
			Journal_Firewall( False, errorStream, "In func %s: self->type '%d' is invalid.\n", __func__, self->type );
		}
	}

	return copy;
}
Esempio n. 23
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 );
			}
		}