[cig-commits] r4939 - in long/3D/Gale/trunk/src/Underworld: . plugins/Output plugins/Output/ConvectionData

walter at geodynamics.org walter at geodynamics.org
Wed Oct 11 13:54:28 PDT 2006


Author: walter
Date: 2006-10-11 13:54:27 -0700 (Wed, 11 Oct 2006)
New Revision: 4939

Added:
   long/3D/Gale/trunk/src/Underworld/plugins/Output/ConvectionData/
   long/3D/Gale/trunk/src/Underworld/plugins/Output/ConvectionData/ConvectionData.c
   long/3D/Gale/trunk/src/Underworld/plugins/Output/ConvectionData/makefile
Modified:
   long/3D/Gale/trunk/src/Underworld/
Log:
 r599 at earth:  boo | 2006-10-11 13:52:11 -0700
  r561 at earth (orig r338):  JulianGiordani | 2006-09-27 23:47:37 -0700
  
  New plugin for Dan and Stegman ( maybe Justin too ). It spits out diagnostics regarding velocity rms values, thermal boundary layer thicknesses and surface mobility.
  
  To invoke the plugin add.
  		<param>Underworld_ConvectionData</param>
  
  BUT MAKE SURE these plugins are listed ABOVE the ConvectionData one
  		<param>Underworld_BoundaryLayers</param>
  		<param>Underworld_ConvectionData</param>
  
  Also there is an odd error at the end experiment if you use the Underworld_BoundaryLayers plugin. Very bad, i'll investigate more. 
  
 



Property changes on: long/3D/Gale/trunk/src/Underworld
___________________________________________________________________
Name: svk:merge
   - 9570c393-cf10-0410-b476-9a651db1e55a:/cig:598
c24a034b-ab11-0410-afe6-cfe714e2959e:/trunk:337
   + 9570c393-cf10-0410-b476-9a651db1e55a:/cig:599
c24a034b-ab11-0410-afe6-cfe714e2959e:/trunk:338

Added: long/3D/Gale/trunk/src/Underworld/plugins/Output/ConvectionData/ConvectionData.c
===================================================================
--- long/3D/Gale/trunk/src/Underworld/plugins/Output/ConvectionData/ConvectionData.c	2006-10-11 20:54:25 UTC (rev 4938)
+++ long/3D/Gale/trunk/src/Underworld/plugins/Output/ConvectionData/ConvectionData.c	2006-10-11 20:54:27 UTC (rev 4939)
@@ -0,0 +1,240 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+** Copyright (c) 2005, Monash Cluster Computing 
+** All rights reserved.
+** Redistribution and use in source and binary forms, with or without modification,
+** are permitted provided that the following conditions are met:
+**
+** 		* Redistributions of source code must retain the above copyright notice, 
+** 			this list of conditions and the following disclaimer.
+** 		* Redistributions in binary form must reproduce the above copyright 
+**			notice, this list of conditions and the following disclaimer in the 
+**			documentation and/or other materials provided with the distribution.
+** 		* Neither the name of the Monash University nor the names of its contributors 
+**			may be used to endorse or promote products derived from this software 
+**			without specific prior written permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 
+** THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 
+** PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 
+** BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
+** CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
+** SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+** HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+** LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 
+** OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+**
+**
+** Contact:
+*%		Louis Moresi - Louis.Moresi at sci.monash.edu.au
+*%
+** Contributors:
+*+		Robert Turnbull
+*+		Vincent Lemiale
+*+		Louis Moresi
+*+		David May
+*+		David Stegman
+*+		Mirko Velic
+*+		Patrick Sunter
+*+		Julian Giordani
+*+
+** $Id: ConvectionData.c 182 2006-05-01 12:32:01Z RobertTurnbull $
+** 
+**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+#include <mpi.h>
+#include <StGermain/StGermain.h>
+#include <StG_FEM/StG_FEM.h>
+#include <PICellerator/PICellerator.h>
+#include <Underworld/Underworld.h>
+#include <Underworld/BoundaryLayers/BoundaryLayers.h>
+#include <StG_FEM/FrequentOutput/FrequentOutput.h>
+#include <string.h>
+
+typedef struct {
+	__Codelet
+	OperatorFeVariable*        velocitySquaredField;
+	Underworld_BoundaryLayers* boundaryLayersPlugin;
+	char*                      rheologyName;
+	double                     stressExponent;
+	double                     eta0;
+	double                     Ra;
+	double                     vrms;
+	double                     diffusivity;
+        double                     horizontalDimOfConvecCell;
+} Underworld_ConvectionData;
+
+double Underworld_ConvectionData_XZPlaneVrms( UnderworldContext* context, double yCoord_Of_XZPlane ); 
+
+const Type Underworld_ConvectionData_Type = "Underworld_ConvectionData";
+Stream* dataStream;
+
+void Underworld_ConvectionData_Setup( void* _context ) {
+	UnderworldContext*          context       = (UnderworldContext*) _context;
+	Underworld_ConvectionData*  self;
+	Arrhenius*                  arrhenius;
+	FrankKamenetskii*           frankKamenetskii;
+	Rheology*                   rheology;
+	NonNewtonian*               nonNewtonian;
+	char*  filename;
+
+	dataStream = Journal_Register( Info_Type, "ConvectionData Info Stream" );
+	Stream_SetPrintingRank( dataStream, 0 ); /** Only prints to main proccessor */
+	
+	self = (Underworld_ConvectionData*)LiveComponentRegister_Get(
+					context->CF->LCRegister,
+					Underworld_ConvectionData_Type );
+	
+	rheology = (Rheology*)Stg_ComponentFactory_ConstructByName( context->CF, "temperatureDependence", Rheology, False );	
+	nonNewtonian = (NonNewtonian*)Stg_ComponentFactory_ConstructByName( context->CF, "nonNewtonian", NonNewtonian, True );	
+
+	if( !strcmp( rheology->type, "FrankKamenetskii" ) ) {
+		frankKamenetskii = (FrankKamenetskii*)rheology; 
+		arrhenius=NULL;
+	} else {
+		arrhenius = (Arrhenius*)rheology;
+		frankKamenetskii=NULL;
+	}
+	
+	self->diffusivity = Stg_ComponentFactory_GetRootDictDouble( context->CF, "diffusivity", 1.0 );
+	self->horizontalDimOfConvecCell = Stg_ComponentFactory_GetRootDictDouble( context->CF, "horizontalDimOfConvecCell", 1.0 );
+	self->Ra = Stg_ComponentFactory_GetRootDictDouble( context->CF, "Ra", 1.0 );
+	
+	self->eta0 = ( arrhenius != NULL ? arrhenius->eta0 : frankKamenetskii->eta0 );
+	self->stressExponent = nonNewtonian->stressExponent;
+	self->rheologyName = rheology->type;//( arrhenius != NULL ? StG_Strdup(arrhenius->type) : StG_Strdup(frankKamenetskii->type) );
+	self->boundaryLayersPlugin = (Underworld_BoundaryLayers*)LiveComponentRegister_Get(
+					context->CF->LCRegister,
+					Underworld_BoundaryLayers_Type );
+	Journal_Firewall( self->boundaryLayersPlugin != NULL, Underworld_Error, "Error in %s. Cannot find the BoundaryLayers Plugin. Make sure <param>Underworld_BoundaryLayers</param> is in your plugins list\n");
+
+	Journal_Firewall( 
+			context->gaussSwarm != NULL, 
+			Underworld_Error,
+			"Cannot find gauss swarm. Cannot use %s.\n", CURR_MODULE_NAME );
+	Journal_Firewall( 
+			context->velocityField != NULL, 
+			Underworld_Error,
+			"Cannot find velocityField. Cannot use %s.\n", CURR_MODULE_NAME );
+
+	/* Create new Field Variable */
+	self->velocitySquaredField = OperatorFeVariable_NewUnary( 
+			"VelocitySquaredField", 
+			context->velocityField, 
+			"VectorSquare" );
+
+	Stg_asprintf( &filename, "ConvectionData.dat", context->rank, context->nproc );
+	Stream_RedirectFile_WithPrependedPath( dataStream, context->outputPath, filename );
+	Stream_SetAutoFlush( dataStream, True );
+	Memory_Free( filename );
+
+}
+
+void Underworld_ConvectionData_Dump( void* _context ) {
+	UnderworldContext*         context = (UnderworldContext*) _context;
+	Underworld_ConvectionData* self;
+	BlockGeometry*             geometry;      
+	double                     topVrms;
+	double                     bottomVrms;
+	double                     Upper_tbl_Thinckness;
+	double                     Lower_tbl_Thinckness;
+	double                     surfaceMobility;
+
+	self = (Underworld_ConvectionData*)LiveComponentRegister_Get(
+					context->CF->LCRegister,
+					Underworld_ConvectionData_Type );
+
+	geometry = Stg_CheckType( self->velocitySquaredField->feMesh->layout->elementLayout->geometry, BlockGeometry );
+
+	Journal_Printf( dataStream, "ID = %s_%.3g_%.3g_%.3g\n", self->rheologyName, self->stressExponent, self->eta0, self->Ra ); 
+	
+	// Prints out Surface Vrms 
+	topVrms = Underworld_ConvectionData_XZPlaneVrms( context, geometry->max[ J_AXIS ] );
+	Journal_Printf( dataStream, "Top Surface Vrms = %g\n", topVrms );
+
+	bottomVrms = Underworld_ConvectionData_XZPlaneVrms( context, geometry->min[ J_AXIS ] );
+	Journal_Printf( dataStream, "Bottom Surface Vrms = %g\n", bottomVrms );
+	
+	Upper_tbl_Thinckness = self->boundaryLayersPlugin->hotLayerThickness;
+	Journal_Printf( dataStream, "Delta_0 = %g\n", Upper_tbl_Thinckness );
+
+	Lower_tbl_Thinckness = self->boundaryLayersPlugin->coldLayerThickness;
+	Journal_Printf( dataStream, "Delta_1 = %g\n", Lower_tbl_Thinckness );
+
+	surfaceMobility = ( Upper_tbl_Thinckness * topVrms ) / ( self->diffusivity * self->horizontalDimOfConvecCell );
+	Journal_Printf( dataStream, "Surface Mobility = %g\n", surfaceMobility );
+/*
+*/
+	Journal_Printf( dataStream, "\n" );
+}
+	
+
+double Underworld_ConvectionData_XZPlaneVrms( UnderworldContext* context, double yCoord_Of_XZPlane ) {
+	BlockGeometry*                       geometry;
+	double                               integral;
+	double                               samplingSpace = 0.0;
+	Dimension_Index                      dim           = context->dim;
+
+	Underworld_ConvectionData* self;
+
+	/*
+	TODO:PAT help:
+	   Here I would like to get the VelocitySquareField instead of getting the whole plugin
+	 */
+	self = (Underworld_ConvectionData*)LiveComponentRegister_Get(
+					context->CF->LCRegister,
+					Underworld_ConvectionData_Type );
+	
+	geometry = Stg_CheckType( self->velocitySquaredField->feMesh->layout->elementLayout->geometry, BlockGeometry );
+
+	/* Sum integral */
+	integral = FeVariable_IntegratePlane( self->velocitySquaredField, J_AXIS, yCoord_Of_XZPlane );
+
+	/* Get Volume of Mesh - TODO Make general for irregular meshes */
+	samplingSpace = ( geometry->max[ I_AXIS ] - geometry->min[ I_AXIS ] ); 
+		
+	if ( dim == 3 ) 
+		samplingSpace *= geometry->max[ K_AXIS ] - geometry->min[ K_AXIS ];
+
+	/* Calculate ConvectionData 
+	 * V_{rms} = \sqrt{ \frac{ \int_\Omega \mathbf{u . u} d\Omega }{\Omega} } */
+
+	return ( sqrt( integral / samplingSpace ) ) ;
+
+}
+	
+void _Underworld_ConvectionData_Construct( void* component, Stg_ComponentFactory* cf ) {
+	UnderworldContext*  context;
+
+	context = Stg_ComponentFactory_ConstructByName( cf, "context", UnderworldContext, True );
+
+	ContextEP_Append( context, AbstractContext_EP_ConstructExtensions, Underworld_ConvectionData_Setup );
+	ContextEP_Append( context, AbstractContext_EP_FrequentOutput, Underworld_ConvectionData_Dump );
+}
+
+void _Underworld_ConvectionData_Delete( void* component ) {
+	Underworld_ConvectionData* self = (Underworld_ConvectionData*) component;
+
+	if( self->rheologyName )
+		Memory_Free( self->rheologyName );
+	_Codelet_Delete( self );
+}
+void* _Underworld_ConvectionData_DefaultNew( Name name ) {
+	return _Codelet_New(
+		sizeof(Underworld_ConvectionData),
+		Underworld_ConvectionData_Type,
+		_Underworld_ConvectionData_Delete,
+		//_Codelet_Delete,
+		_Codelet_Print,
+		_Codelet_Copy,
+		_Underworld_ConvectionData_DefaultNew,
+		_Underworld_ConvectionData_Construct,
+		_Codelet_Build,
+		_Codelet_Initialise,
+		_Codelet_Execute,
+		_Codelet_Destroy,
+		name );
+}
+
+Index Underworld_ConvectionData_Register( PluginsManager* pluginsManager ) {
+	return PluginsManager_Submit( pluginsManager, Underworld_ConvectionData_Type, "0", _Underworld_ConvectionData_DefaultNew );
+}

Added: long/3D/Gale/trunk/src/Underworld/plugins/Output/ConvectionData/makefile
===================================================================
--- long/3D/Gale/trunk/src/Underworld/plugins/Output/ConvectionData/makefile	2006-10-11 20:54:25 UTC (rev 4938)
+++ long/3D/Gale/trunk/src/Underworld/plugins/Output/ConvectionData/makefile	2006-10-11 20:54:27 UTC (rev 4939)
@@ -0,0 +1,24 @@
+
+#Finds the Absolute path to the Project Root directory
+SHELL := /bin/bash
+PROJ_ROOT := $(shell until test -r ./Makefile.system ; do cd .. ; done ; echo `pwd`)
+include ${PROJ_ROOT}/Makefile.system
+
+# Subdirectories
+subdirs := $(shell find * -type d -prune ! -name .svn ) 
+
+# Source Code and Header files
+SRCS := $(wildcard *.c)
+HDRS := $(wildcard *.h)
+
+# What to call the plugin
+modName := $(shell basename `pwd`)
+mod = ${PROJECT}_${modName}
+
+# Where to put header files
+includes = ${PROJECT}/${modName}
+
+# External Libraries and Headers
+packages = PICELLERATOR STG_FEM STGERMAIN PETSC MPI XML PYTHON
+
+include ${PROJ_ROOT}/Makefile.vmake



More information about the cig-commits mailing list