[cig-commits] r5512 - in long/3D/Gale/trunk/src/Underworld: . Utils/src

walter at geodynamics.org walter at geodynamics.org
Thu Dec 7 14:14:51 PST 2006


Author: walter
Date: 2006-12-07 14:14:50 -0800 (Thu, 07 Dec 2006)
New Revision: 5512

Added:
   long/3D/Gale/trunk/src/Underworld/Utils/src/DensityField.c
   long/3D/Gale/trunk/src/Underworld/Utils/src/DensityField.h
   long/3D/Gale/trunk/src/Underworld/Utils/src/DensityField.meta
Modified:
   long/3D/Gale/trunk/src/Underworld/
   long/3D/Gale/trunk/src/Underworld/Utils/src/Init.c
   long/3D/Gale/trunk/src/Underworld/Utils/src/Utils.h
   long/3D/Gale/trunk/src/Underworld/Utils/src/types.h
Log:
 r765 at earth:  boo | 2006-12-07 14:13:24 -0800
  r744 at earth (orig r386):  EinatLev | 2006-11-21 14:46:12 -0800
  Adding a new DensityField component, which can be used to plot density as 
  a field in gLucifer, instead of just on the particle dots. Note that we 
  really should come up with a way of plotting SwarmVariables in general 
  via XML, rather than coding up a whole new component each time. Shouldn't
  be too hard but may require changing a few function prototypes.
  
  -- Pat.
  
  
 



Property changes on: long/3D/Gale/trunk/src/Underworld
___________________________________________________________________
Name: svk:merge
   - 9570c393-cf10-0410-b476-9a651db1e55a:/cig:764
c24a034b-ab11-0410-afe6-cfe714e2959e:/trunk:385
   + 9570c393-cf10-0410-b476-9a651db1e55a:/cig:765
c24a034b-ab11-0410-afe6-cfe714e2959e:/trunk:386

Added: long/3D/Gale/trunk/src/Underworld/Utils/src/DensityField.c
===================================================================
--- long/3D/Gale/trunk/src/Underworld/Utils/src/DensityField.c	2006-12-07 22:14:47 UTC (rev 5511)
+++ long/3D/Gale/trunk/src/Underworld/Utils/src/DensityField.c	2006-12-07 22:14:50 UTC (rev 5512)
@@ -0,0 +1,217 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+**
+** Monash Cluster Computing, Australia
+** (C) 2003-2004 All Rights Reserved
+**
+** Primary Authors:
+** Robert Turnbull, MCC
+**
+**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+
+
+#include <mpi.h>
+#include <StGermain/StGermain.h>
+#include <StgFEM/StgFEM.h>
+#include <PICellerator/PICellerator.h>
+
+#include <Underworld/Rheology/Rheology.h>
+
+#include "types.h"
+#include "DensityField.h"
+#include <assert.h>
+
+const Type DensityField_Type = "DensityField";
+
+DensityField* _DensityField_New(
+ 		SizeT                                             _sizeOfSelf,
+		Type                                              type,
+		Stg_Class_DeleteFunction*                         _delete,
+		Stg_Class_PrintFunction*                          _print,
+		Stg_Class_CopyFunction*                           _copy, 
+		Stg_Component_DefaultConstructorFunction*         _defaultConstructor,
+		Stg_Component_ConstructFunction*                  _construct,
+		Stg_Component_BuildFunction*                      _build,
+		Stg_Component_InitialiseFunction*                 _initialise,
+		Stg_Component_ExecuteFunction*                    _execute,
+		Stg_Component_DestroyFunction*                    _destroy,
+		FieldVariable_InterpolateValueAtFunction*         _interpolateValueAt,
+		FieldVariable_GetValueFunction*	                  _getMinGlobalFeMagnitude,
+		FieldVariable_GetValueFunction*                   _getMaxGlobalFeMagnitude,
+		FieldVariable_GetCoordFunction*                   _getMinAndMaxLocalCoords,
+		FieldVariable_GetCoordFunction*                   _getMinAndMaxGlobalCoords,		
+		FeVariable_InterpolateWithinElementFunction*      _interpolateWithinElement,	
+		FeVariable_GetValueAtNodeFunction*                _getValueAtNode,
+		ParticleFeVariable_ValueAtParticleFunction*       _valueAtParticle,
+		Name                                              name )
+{
+	DensityField*		self;
+	
+	/* Call private constructor of parent - this will set virtual functions of parent and continue up the hierarchy tree. At the beginning of the tree it will allocate memory of the size of object and initialise all the memory to zero. */
+	assert( _sizeOfSelf >= sizeof(DensityField) );
+	self = (DensityField*)
+		_ParticleFeVariable_New(
+			_sizeOfSelf, 
+			type, 
+			_delete,
+			_print,
+			_copy,
+			_defaultConstructor,
+			_construct,
+			_build,
+			_initialise,
+			_execute, 
+			_destroy,
+			_interpolateValueAt,
+			_getMinGlobalFeMagnitude, 
+			_getMaxGlobalFeMagnitude,
+			_getMinAndMaxLocalCoords, 
+			_getMinAndMaxGlobalCoords,
+			_interpolateWithinElement,
+			_getValueAtNode,
+			_valueAtParticle,
+			name );
+	
+	return self;
+}
+
+void _DensityField_Init( 
+		DensityField*                                   self,
+		BuoyancyForceTerm*                               buoyancyForceTerm,
+		Variable_Register*                                variable_Register )
+{
+	Name              tmpName;
+
+	/* Assign Pointers */
+	self->buoyancyForceTerm = buoyancyForceTerm;
+
+	/* Create Dof Layout */
+	tmpName = Stg_Object_AppendSuffix( self, "DataVariable" );
+	self->dataVariable = Variable_NewScalar( 	
+			tmpName,
+			Variable_DataType_Double, 
+			&self->feMesh->nodeDomainCount, 
+			(void**)&self->data, 
+			variable_Register );
+	Memory_Free( tmpName );
+	self->fieldComponentCount = 1;
+	
+	tmpName = Stg_Object_AppendSuffix( self, "DofLayout" );
+	self->dofLayout = DofLayout_New( tmpName, variable_Register, self->feMesh->layout->decomp->nodeDomainCount );
+	DofLayout_AddAllFromVariableArray( self->dofLayout, 1, &self->dataVariable );
+	Memory_Free( tmpName );
+	self->eqNum->dofLayout = self->dofLayout;
+	
+	
+	/* Set pointers to swarm to be the same as the one on the constitutive matrix */
+	self->assemblyTerm->integrationSwarm = self->buoyancyForceTerm->integrationSwarm;
+	self->massMatrixForceTerm->integrationSwarm = self->buoyancyForceTerm->integrationSwarm;	
+}
+
+/* --- Virtual Function Implementations --- */
+void _DensityField_Delete( void* densityField ) {
+	DensityField* self = (DensityField*) densityField;
+
+	Stg_Class_Delete( self->assemblyVector );
+	Memory_Free( self->assemblyVectorName );
+
+	_FeVariable_Delete( self );
+}
+
+void _DensityField_Print( void* densityField, Stream* stream ) {
+	DensityField* self = (DensityField*) densityField;
+	
+	/* General info */
+	Journal_Printf( stream, "DensityField (ptr): %p\n", self );
+	
+	/* Print parent */
+	_FeVariable_Print( self, stream );
+	
+	/* DensityField info */
+	Journal_PrintPointer( stream, self->buoyancyForceTerm );
+}
+
+
+void* _DensityField_Copy( void* feVariable, void* dest, Bool deep, Name nameExt, PtrMap* ptrMap ) {
+	DensityField*	self = (DensityField*)feVariable;
+	DensityField*	newDensityField;
+	
+	newDensityField = (DensityField*) _FeVariable_Copy( feVariable, dest, deep, nameExt, ptrMap );
+
+	newDensityField->buoyancyForceTerm = self->buoyancyForceTerm;
+	
+	return (void*)newDensityField;
+}
+
+void* _DensityField_DefaultNew( Name name ) {
+	return (void*) _DensityField_New(
+		sizeof(DensityField),
+		DensityField_Type,
+		_DensityField_Delete,
+		_DensityField_Print,
+		_DensityField_Copy,
+		_DensityField_DefaultNew,
+		_DensityField_Construct,
+		_DensityField_Build, 
+		_DensityField_Initialise,
+		_DensityField_Execute,
+		_DensityField_Destroy,
+		_FeVariable_InterpolateValueAt,
+		_FeVariable_GetMinGlobalFieldMagnitude,
+		_FeVariable_GetMaxGlobalFieldMagnitude,
+		_FeVariable_GetMinAndMaxLocalCoords,
+		_FeVariable_GetMinAndMaxGlobalCoords,
+		_FeVariable_InterpolateNodeValuesToElLocalCoord,
+		_FeVariable_GetValueAtNode,
+		_DensityField_ValueAtParticle,
+		name );
+}
+
+void _DensityField_Construct( void* densityField, Stg_ComponentFactory* cf, void* data ){
+	DensityField*          self              = (DensityField*) densityField;
+	BuoyancyForceTerm*   buoyancyForceTerm;
+	Variable_Register*    variable_Register;
+
+	/* Construct Parent */
+	_ParticleFeVariable_Construct( self, cf, data );
+
+	/*_FieldVariable_Construct( self, cf, data );*/
+
+	buoyancyForceTerm = Stg_ComponentFactory_ConstructByKey( cf, self->name, "BuoyancyForceTerm", BuoyancyForceTerm, True, data );
+	variable_Register      = (Variable_Register*) Stg_ObjectList_Get( cf->registerRegister, "Variable_Register" );
+	assert( variable_Register );
+
+	_DensityField_Init( self, buoyancyForceTerm, variable_Register );
+}
+
+void _DensityField_Build( void* densityField, void* data ) {
+	DensityField* self = (DensityField*) densityField;
+
+	_ParticleFeVariable_Build( self, data );
+}
+void _DensityField_Initialise( void* densityField, void* data ) {
+	DensityField* self = (DensityField*) densityField;
+
+	_ParticleFeVariable_Initialise( self, data );
+}
+void _DensityField_Execute( void* densityField, void* data ) {
+	DensityField* self = (DensityField*) densityField;
+
+	_ParticleFeVariable_Execute( self, data );
+}
+void _DensityField_Destroy( void* densityField, void* data ) {
+	DensityField* self = (DensityField*) densityField;
+
+	_ParticleFeVariable_Destroy( self, data );
+}
+void _DensityField_ValueAtParticle( void* densityField, IntegrationPointsSwarm* swarm, Element_LocalIndex lElement_I, void* _particle, double* density ) {
+	DensityField*                    self         = (DensityField*) densityField;
+	IntegrationPoint*                particle     = (IntegrationPoint*) _particle;
+	Material*                        material = NULL;
+	BuoyancyForceTerm_MaterialExt*   materialExt;
+	
+	/* Calculate density from particle material */
+	material = IntegrationPointsSwarm_GetMaterialOn( (IntegrationPointsSwarm*)swarm, particle );
+	materialExt = ExtensionManager_Get( material->extensionMgr, material, self->buoyancyForceTerm->materialExtHandle );
+	*density = materialExt->density;
+}
+


Property changes on: long/3D/Gale/trunk/src/Underworld/Utils/src/DensityField.c
___________________________________________________________________
Name: svn:eol-style
   + native

Added: long/3D/Gale/trunk/src/Underworld/Utils/src/DensityField.h
===================================================================
--- long/3D/Gale/trunk/src/Underworld/Utils/src/DensityField.h	2006-12-07 22:14:47 UTC (rev 5511)
+++ long/3D/Gale/trunk/src/Underworld/Utils/src/DensityField.h	2006-12-07 22:14:50 UTC (rev 5512)
@@ -0,0 +1,66 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+**
+** Monash Cluster Computing, Australia
+** (C) 2003-2004 All Rights Reserved
+**
+** Primary Authors:
+** Robert Turnbull, MCC
+**
+**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+
+#ifndef __Underworld_MaterialPoints_DensityField_h__
+#define __Underworld_MaterialPoints_DensityField_h__
+	
+	/** Textual name of this class - This is a global pointer which is used for times when you need to refer to class and not a particular instance of a class */
+	extern const Type DensityField_Type;
+
+	/** DensityField class contents - this is defined as a macro so that sub-classes of this class can use this macro at the start of the definition of their struct */
+	#define __DensityField \
+		/* Macro defining parent goes here - This means you can cast this class as its parent */ \
+		__ParticleFeVariable \
+		\
+		/* Virtual functions go here */ \
+		\
+		/* Passed in parameters */ \
+		BuoyancyForceTerm*       buoyancyForceTerm;
+		
+	struct DensityField { __DensityField };
+	
+	/* --- Contstructors / Destructors --- */
+	DensityField* _DensityField_New(
+ 		SizeT                                             _sizeOfSelf,
+		Type                                              type,
+		Stg_Class_DeleteFunction*                         _delete,
+		Stg_Class_PrintFunction*                          _print,
+		Stg_Class_CopyFunction*                           _copy, 
+		Stg_Component_DefaultConstructorFunction*         _defaultConstructor,
+		Stg_Component_ConstructFunction*                  _construct,
+		Stg_Component_BuildFunction*                      _build,
+		Stg_Component_InitialiseFunction*                 _initialise,
+		Stg_Component_ExecuteFunction*                    _execute,
+		Stg_Component_DestroyFunction*                    _destroy,
+		FieldVariable_InterpolateValueAtFunction*         _interpolateValueAt,
+		FieldVariable_GetValueFunction*	                  _getMinGlobalFeMagnitude,
+		FieldVariable_GetValueFunction*                   _getMaxGlobalFeMagnitude,
+		FieldVariable_GetCoordFunction*                   _getMinAndMaxLocalCoords,
+		FieldVariable_GetCoordFunction*                   _getMinAndMaxGlobalCoords,		
+		FeVariable_InterpolateWithinElementFunction*      _interpolateWithinElement,	
+		FeVariable_GetValueAtNodeFunction*                _getValueAtNode,
+		ParticleFeVariable_ValueAtParticleFunction*       _valueAtParticle,
+		Name                                              name );
+	
+	/** Print the contents of an DensityField construct */
+	void* _DensityField_DefaultNew( Name name );
+	void _DensityField_Delete( void* variable );
+	void _DensityField_Print( void* variable, Stream* stream );
+	void* _DensityField_Copy( void* feVariable, void* dest, Bool deep, Name nameExt, PtrMap* ptrMap );
+
+	void _DensityField_Construct( void* variable, Stg_ComponentFactory* cf, void* data ) ;
+	void _DensityField_Build( void* variable, void* data ) ;
+	void _DensityField_Initialise( void* variable, void* data ) ;
+	void _DensityField_Execute( void* variable, void* data ) ;
+	void _DensityField_Destroy( void* variable, void* data ) ;
+	void _DensityField_ValueAtParticle( void* viscosityField, IntegrationPointsSwarm* swarm, Element_LocalIndex lElement_I, void* particle, double* viscosity ) ;
+	
+
+#endif 


Property changes on: long/3D/Gale/trunk/src/Underworld/Utils/src/DensityField.h
___________________________________________________________________
Name: svn:eol-style
   + native

Added: long/3D/Gale/trunk/src/Underworld/Utils/src/DensityField.meta
===================================================================
--- long/3D/Gale/trunk/src/Underworld/Utils/src/DensityField.meta	2006-12-07 22:14:47 UTC (rev 5511)
+++ long/3D/Gale/trunk/src/Underworld/Utils/src/DensityField.meta	2006-12-07 22:14:50 UTC (rev 5512)
@@ -0,0 +1,24 @@
+<?xml version="1.0"?>
+<!DOCTYPE StGermainData SYSTEM "stgermain.dtd">
+<StGermainData xmlns="http://www.vpac.org/StGermain/XML_IO_Handler/Jun2003">
+
+<param name="Name">DensityField</param>
+<param name="Organisation">MCC</param>
+<param name="Project">Underworld</param>
+<param name="Location">./Underworld/Utils/src/</param>
+<param name="Project Web">http://mcc.monash.edu.au/Underworld</param>
+<param name="Copyright">Copyright (C) 2006 Monash Cluster Computing.</param>
+<param name="License">http://www.opensource.org/licenses/bsd-license.php</param>
+<param name="Parent">WeightsCalculator</param>
+<param name="Description">Calculates PIC integration weights in 3D and 2D using a Voronoi diagram. The integration points are set to the centroid of a Voronoi cell and
+ the weight is the volume of the cell.</param>
+
+
+<list name="Params">
+
+</list>
+
+<list name="Dependencies">
+
+</list>
+</StGermainData>

Modified: long/3D/Gale/trunk/src/Underworld/Utils/src/Init.c
===================================================================
--- long/3D/Gale/trunk/src/Underworld/Utils/src/Init.c	2006-12-07 22:14:47 UTC (rev 5511)
+++ long/3D/Gale/trunk/src/Underworld/Utils/src/Init.c	2006-12-07 22:14:50 UTC (rev 5512)
@@ -67,6 +67,7 @@
 	Stg_ComponentRegister_Add( componentRegister, RadiogenicHeatingTerm_Type,     "0", _RadiogenicHeatingTerm_DefaultNew );
 	Stg_ComponentRegister_Add( componentRegister, StressField_Type ,              "0", _StressField_DefaultNew );
 	Stg_ComponentRegister_Add( componentRegister, ViscosityField_Type ,           "0", _ViscosityField_DefaultNew );
+	Stg_ComponentRegister_Add( componentRegister, DensityField_Type ,           "0", _DensityField_DefaultNew );
        	Stg_ComponentRegister_Add( componentRegister, DVCWeights_Type,          "0", _DVCWeights_DefaultNew );
 
 	RegisterParent( UnderworldContext_Type,             PICelleratorContext_Type );
@@ -74,6 +75,7 @@
 	RegisterParent( RadiogenicHeatingTerm_Type,         ForceTerm_Type );
 	RegisterParent( StressField_Type,                   ParticleFeVariable_Type );
 	RegisterParent( ViscosityField_Type,                ParticleFeVariable_Type );
+	RegisterParent( DensityField_Type,                  ParticleFeVariable_Type );
         RegisterParent( DVCWeights_Type,        WeightsCalculator_Type );
 
 	return True;

Modified: long/3D/Gale/trunk/src/Underworld/Utils/src/Utils.h
===================================================================
--- long/3D/Gale/trunk/src/Underworld/Utils/src/Utils.h	2006-12-07 22:14:47 UTC (rev 5511)
+++ long/3D/Gale/trunk/src/Underworld/Utils/src/Utils.h	2006-12-07 22:14:50 UTC (rev 5512)
@@ -50,6 +50,7 @@
 	#include "Context.h"
 	#include "StressField.h"
 	#include "ViscosityField.h"
+	#include "DensityField.h"
         #include "DVCWeights.h"
 	#include "PressureTemperatureOutput.h"
 	#include "RadiogenicHeatingTerm.h"

Modified: long/3D/Gale/trunk/src/Underworld/Utils/src/types.h
===================================================================
--- long/3D/Gale/trunk/src/Underworld/Utils/src/types.h	2006-12-07 22:14:47 UTC (rev 5511)
+++ long/3D/Gale/trunk/src/Underworld/Utils/src/types.h	2006-12-07 22:14:50 UTC (rev 5512)
@@ -51,6 +51,7 @@
 	typedef struct RadiogenicHeatingTerm         RadiogenicHeatingTerm;
 	typedef struct StressField                   StressField;
 	typedef struct ViscosityField                ViscosityField;
+	typedef struct DensityField                  DensityField;
 	typedef struct DVCWeights                    DVCWeights;
 
 #endif 



More information about the cig-commits mailing list