[cig-commits] r3899 - in long/3D/Gale/trunk/src/StgFEM: . Apps/Components Apps/StokesMomentumUzawa Apps/StokesMomentumUzawa/tests/LidDrivenIsoviscousAnalytic Apps/ThermalConvection Apps/ThermalConvection/tests Apps/ThermalConvection/tests/expected Discretisation/src Discretisation/tests Discretisation/tests/expected SLE/ProvidedSystems/AdvectionDiffusion/src SLE/ProvidedSystems/StokesFlow/src SLE/SystemSetup/src SLE/SystemSetup/tests SLE/SystemSetup/tests/expected SLE/SystemSetup/tests/output plugins plugins/Application plugins/CompareFeVariableAgainstReferenceSolution plugins/StandardConditionFunctions plugins/VelicAnalyticSolutions plugins/VelicAnalyticSolutions/Velic_solA plugins/VelicAnalyticSolutions/Velic_solB plugins/VelicAnalyticSolutions/Velic_solD plugins/VelicAnalyticSolutions/Velic_solKx src

walter at geodynamics.org walter at geodynamics.org
Wed Jun 28 03:01:43 PDT 2006


Author: walter
Date: 2006-06-28 03:01:38 -0700 (Wed, 28 Jun 2006)
New Revision: 3899

Added:
   long/3D/Gale/trunk/src/StgFEM/Apps/ThermalConvection/AnalyticPressureVP.xml
   long/3D/Gale/trunk/src/StgFEM/Apps/ThermalConvection/PressureAndVelocityArrowsVP.xml
   long/3D/Gale/trunk/src/StgFEM/Apps/ThermalConvection/tests/testAnalyticHyperbolic.xml
   long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/tests/expected/testContext.0of1.expected
   long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/tests/expected/testContext.0of2.expected
   long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/tests/testContext.0of1.sh
   long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/tests/testContext.0of2.sh
   long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/tests/testContext.c
   long/3D/Gale/trunk/src/StgFEM/plugins/CompareFeVariableAgainstReferenceSolution/
   long/3D/Gale/trunk/src/StgFEM/plugins/CompareFeVariableAgainstReferenceSolution/CompareFeVariableAgainstReferenceSolution.c
   long/3D/Gale/trunk/src/StgFEM/plugins/CompareFeVariableAgainstReferenceSolution/makefile
   long/3D/Gale/trunk/src/StgFEM/plugins/VelicAnalyticSolutions/
   long/3D/Gale/trunk/src/StgFEM/plugins/VelicAnalyticSolutions/Velic_solA/
   long/3D/Gale/trunk/src/StgFEM/plugins/VelicAnalyticSolutions/Velic_solA/makefile
   long/3D/Gale/trunk/src/StgFEM/plugins/VelicAnalyticSolutions/Velic_solA/solA.c
   long/3D/Gale/trunk/src/StgFEM/plugins/VelicAnalyticSolutions/Velic_solA/solA.tex
   long/3D/Gale/trunk/src/StgFEM/plugins/VelicAnalyticSolutions/Velic_solA/solA_main.tex
   long/3D/Gale/trunk/src/StgFEM/plugins/VelicAnalyticSolutions/Velic_solB/
   long/3D/Gale/trunk/src/StgFEM/plugins/VelicAnalyticSolutions/Velic_solB/makefile
   long/3D/Gale/trunk/src/StgFEM/plugins/VelicAnalyticSolutions/Velic_solB/solB.c
   long/3D/Gale/trunk/src/StgFEM/plugins/VelicAnalyticSolutions/Velic_solB/solB.tex
   long/3D/Gale/trunk/src/StgFEM/plugins/VelicAnalyticSolutions/Velic_solB/solB_main.tex
   long/3D/Gale/trunk/src/StgFEM/plugins/VelicAnalyticSolutions/Velic_solD/
   long/3D/Gale/trunk/src/StgFEM/plugins/VelicAnalyticSolutions/Velic_solD/makefile
   long/3D/Gale/trunk/src/StgFEM/plugins/VelicAnalyticSolutions/Velic_solD/solD.c
   long/3D/Gale/trunk/src/StgFEM/plugins/VelicAnalyticSolutions/Velic_solD/solD.tex
   long/3D/Gale/trunk/src/StgFEM/plugins/VelicAnalyticSolutions/Velic_solD/solD_main.tex
   long/3D/Gale/trunk/src/StgFEM/plugins/VelicAnalyticSolutions/Velic_solKx/
   long/3D/Gale/trunk/src/StgFEM/plugins/VelicAnalyticSolutions/Velic_solKx/makefile
   long/3D/Gale/trunk/src/StgFEM/plugins/VelicAnalyticSolutions/Velic_solKx/solKx.c
   long/3D/Gale/trunk/src/StgFEM/plugins/VelicAnalyticSolutions/Velic_solKx/solKx.h
   long/3D/Gale/trunk/src/StgFEM/plugins/VelicAnalyticSolutions/makefile
Modified:
   long/3D/Gale/trunk/src/StgFEM/
   long/3D/Gale/trunk/src/StgFEM/Apps/Components/TimeIntegratorSimultaneous.xml
   long/3D/Gale/trunk/src/StgFEM/Apps/StokesMomentumUzawa/AnalyticPressureVP.xml
   long/3D/Gale/trunk/src/StgFEM/Apps/StokesMomentumUzawa/tests/LidDrivenIsoviscousAnalytic/LidDrivenIsoviscousAnalytic.c
   long/3D/Gale/trunk/src/StgFEM/Apps/ThermalConvection/AnalyticVelocityMagnitudeVP.xml
   long/3D/Gale/trunk/src/StgFEM/Apps/ThermalConvection/TemperatureAndVelocityArrowsVP.xml
   long/3D/Gale/trunk/src/StgFEM/Apps/ThermalConvection/demo.xml
   long/3D/Gale/trunk/src/StgFEM/Apps/ThermalConvection/tests/expected/testThermalConvection-Analytic-2D.0of1.PressureField-ErrorFile.expected
   long/3D/Gale/trunk/src/StgFEM/Apps/ThermalConvection/tests/expected/testThermalConvection-Analytic-2D.0of2.PressureField-ErrorFile.expected
   long/3D/Gale/trunk/src/StgFEM/Apps/ThermalConvection/tests/testAnalytic.xml
   long/3D/Gale/trunk/src/StgFEM/Discretisation/src/AnalyticSolution.c
   long/3D/Gale/trunk/src/StgFEM/Discretisation/src/AnalyticSolution.h
   long/3D/Gale/trunk/src/StgFEM/Discretisation/src/FeVariable.c
   long/3D/Gale/trunk/src/StgFEM/Discretisation/src/FeVariable.h
   long/3D/Gale/trunk/src/StgFEM/Discretisation/tests/expected/testFeVariable.0of1.expected
   long/3D/Gale/trunk/src/StgFEM/Discretisation/tests/expected/testFeVariable.0of2.expected
   long/3D/Gale/trunk/src/StgFEM/Discretisation/tests/expected/testFeVariable.1of2.expected
   long/3D/Gale/trunk/src/StgFEM/Discretisation/tests/testFeEquationNumber-LinkedDofs.c
   long/3D/Gale/trunk/src/StgFEM/SLE/ProvidedSystems/AdvectionDiffusion/src/AdvectionDiffusionSLE.c
   long/3D/Gale/trunk/src/StgFEM/SLE/ProvidedSystems/AdvectionDiffusion/src/LumpedMassMatrixForceTerm.h
   long/3D/Gale/trunk/src/StgFEM/SLE/ProvidedSystems/StokesFlow/src/Stokes_SLE.c
   long/3D/Gale/trunk/src/StgFEM/SLE/ProvidedSystems/StokesFlow/src/Stokes_SLE_UzawaSolver.c
   long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/src/Context.c
   long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/src/Context.h
   long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/src/SolutionVector.c
   long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/src/SystemLinearEquations.c
   long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/tests/output/
   long/3D/Gale/trunk/src/StgFEM/plugins/Application/Application.c
   long/3D/Gale/trunk/src/StgFEM/plugins/Application/Application.h
   long/3D/Gale/trunk/src/StgFEM/plugins/StandardConditionFunctions/StandardConditionFunctions.c
   long/3D/Gale/trunk/src/StgFEM/plugins/StandardConditionFunctions/StandardConditionFunctions.h
   long/3D/Gale/trunk/src/StgFEM/src/main.c
Log:
Update to latest from VPAC


Property changes on: long/3D/Gale/trunk/src/StgFEM
___________________________________________________________________
Name: svk:merge
   - 38867592-cf10-0410-9e16-a142ea72ac34:/cig:620
db209038-57f2-0310-97fa-b160e0ae9d04:/trunk:560
   + 38867592-cf10-0410-9e16-a142ea72ac34:/cig:655
db209038-57f2-0310-97fa-b160e0ae9d04:/trunk:596

Modified: long/3D/Gale/trunk/src/StgFEM/Apps/Components/TimeIntegratorSimultaneous.xml
===================================================================
--- long/3D/Gale/trunk/src/StgFEM/Apps/Components/TimeIntegratorSimultaneous.xml	2006-06-28 09:59:25 UTC (rev 3898)
+++ long/3D/Gale/trunk/src/StgFEM/Apps/Components/TimeIntegratorSimultaneous.xml	2006-06-28 10:01:38 UTC (rev 3899)
@@ -7,7 +7,9 @@
 	<struct name="components" mergeType="merge">
 		<struct name="timeIntegrator" mergeType="replace">
 			<param name="Type">TimeIntegrator</param>
-			<param name="order">timeIntegratorOrder</param>
+			<!-- TODO : only use order 1 until someone fixes 2nd order simultaneous -->
+			<!--<param name="order">timeIntegratorOrder</param>-->
+			<param name="order">1</param>
 			<param name="simultaneous">t</param>
 			<param name="Context">context</param>
 		</struct>		

Modified: long/3D/Gale/trunk/src/StgFEM/Apps/StokesMomentumUzawa/AnalyticPressureVP.xml
===================================================================
--- long/3D/Gale/trunk/src/StgFEM/Apps/StokesMomentumUzawa/AnalyticPressureVP.xml	2006-06-28 09:59:25 UTC (rev 3898)
+++ long/3D/Gale/trunk/src/StgFEM/Apps/StokesMomentumUzawa/AnalyticPressureVP.xml	2006-06-28 10:01:38 UTC (rev 3899)
@@ -9,7 +9,7 @@
 			<param name="CentreFieldVariable">PressureField</param>
 			<param name="coordZ">1.5</param>
 		</struct>
-		<struct name="pressureColourMap" mergeType="replace">
+		<struct name="analyticPressureColourMap" mergeType="replace">
 			<param name="Type">lucColourMap</param>
 			<param name="colours">Black Purple DarkRed Orange Yellow</param>
 			<param name="dynamicRange">true</param>
@@ -18,15 +18,15 @@
 		<struct name="analyticPressureMap">
 			<param name="Type">lucScalarField</param>
 			<param name="FieldVariable">PressureField-Analytic</param>
-			<param name="ColourMap">pressureColourMap</param>
+			<param name="ColourMap">analyticPressureColourMap</param>
 		</struct>
 		<struct name="border" mergeType="replace">
 			<param name="Type">lucFieldVariableBorder</param>
 			<param name="FieldVariable">PressureField</param>
 		</struct>
-		<struct name="pressureColourBar" mergeType="replace">
+		<struct name="analyticPressureColourBar" mergeType="replace">
 			<param name="Type">lucColourBar</param>
-			<param name="ColourMap">pressureColourMap</param>
+			<param name="ColourMap">analyticPressureColourMap</param>
 		</struct>
 		<!-- Put these althogether in a viewport -->
 		<struct name="AnalyticPressureVP">
@@ -35,7 +35,7 @@
 			<list name="DrawingObject">
 				<param>analyticPressureMap</param>
 				<param>border</param>
-				<param>pressureColourBar</param>
+				<param>analyticPressureColourBar</param>
 			</list>
 		</struct>
 	</struct>

Modified: long/3D/Gale/trunk/src/StgFEM/Apps/StokesMomentumUzawa/tests/LidDrivenIsoviscousAnalytic/LidDrivenIsoviscousAnalytic.c
===================================================================
--- long/3D/Gale/trunk/src/StgFEM/Apps/StokesMomentumUzawa/tests/LidDrivenIsoviscousAnalytic/LidDrivenIsoviscousAnalytic.c	2006-06-28 09:59:25 UTC (rev 3898)
+++ long/3D/Gale/trunk/src/StgFEM/Apps/StokesMomentumUzawa/tests/LidDrivenIsoviscousAnalytic/LidDrivenIsoviscousAnalytic.c	2006-06-28 10:01:38 UTC (rev 3899)
@@ -129,7 +129,7 @@
 	_AnalyticSolution_Construct( self, cf );
 
 	velocityField = Stg_ComponentFactory_ConstructByName( cf, "VelocityField", FeVariable, True );
-	AnalyticSolution_CreateAnalyticFieldWithMagnitude( self, velocityField, LidDrivenIsoviscousAnalytic_VelocityFunction );
+	AnalyticSolution_CreateAnalyticVectorField( self, velocityField, LidDrivenIsoviscousAnalytic_VelocityFunction );
 
 	pressureField = Stg_ComponentFactory_ConstructByName( cf, "PressureField", FeVariable, True );
 	AnalyticSolution_CreateAnalyticField( self, pressureField, LidDrivenIsoviscousAnalytic_PressureFunction );

Added: long/3D/Gale/trunk/src/StgFEM/Apps/ThermalConvection/AnalyticPressureVP.xml
===================================================================
--- long/3D/Gale/trunk/src/StgFEM/Apps/ThermalConvection/AnalyticPressureVP.xml	2006-06-28 09:59:25 UTC (rev 3898)
+++ long/3D/Gale/trunk/src/StgFEM/Apps/ThermalConvection/AnalyticPressureVP.xml	2006-06-28 10:01:38 UTC (rev 3899)
@@ -0,0 +1,42 @@
+<?xml version="1.0"?>
+<!DOCTYPE StGermainData SYSTEM "stgermain.dtd">
+
+<StGermainData xmlns="http://www.vpac.org/StGermain/XML_IO_Handler/Jun2003">
+
+	<struct name="components" mergeType="merge">
+		<struct name="camera" mergeType="replace">
+			<param name="Type">lucCamera</param>
+			<param name="CentreFieldVariable">PressureField</param>
+			<param name="coordZ">1.5</param>
+		</struct>
+		<struct name="analyticPressureColourMap" mergeType="replace">
+			<param name="Type">lucColourMap</param>
+			<param name="colours">Black Purple DarkRed Orange Yellow</param>
+			<param name="dynamicRange">true</param>
+		</struct>
+		<!-- Drawing Objects -->
+		<struct name="analyticPressureMap">
+			<param name="Type">lucScalarField</param>
+			<param name="FieldVariable">PressureField-Analytic</param>
+			<param name="ColourMap">analyticPressureColourMap</param>
+		</struct>
+		<struct name="border" mergeType="replace">
+			<param name="Type">lucFieldVariableBorder</param>
+			<param name="FieldVariable">PressureField</param>
+		</struct>
+		<struct name="analyticPressureColourBar" mergeType="replace">
+			<param name="Type">lucColourBar</param>
+			<param name="ColourMap">analyticPressureColourMap</param>
+		</struct>
+		<!-- Put these althogether in a viewport -->
+		<struct name="AnalyticPressureVP">
+			<param name="Type">lucViewport</param>
+			<param name="Camera">camera</param>
+			<list name="DrawingObject">
+				<param>analyticPressureMap</param>
+				<param>border</param>
+				<param>analyticPressureColourBar</param>
+			</list>
+		</struct>
+	</struct>
+</StGermainData>

Modified: long/3D/Gale/trunk/src/StgFEM/Apps/ThermalConvection/AnalyticVelocityMagnitudeVP.xml
===================================================================
--- long/3D/Gale/trunk/src/StgFEM/Apps/ThermalConvection/AnalyticVelocityMagnitudeVP.xml	2006-06-28 09:59:25 UTC (rev 3898)
+++ long/3D/Gale/trunk/src/StgFEM/Apps/ThermalConvection/AnalyticVelocityMagnitudeVP.xml	2006-06-28 10:01:38 UTC (rev 3899)
@@ -4,28 +4,28 @@
 <StGermainData xmlns="http://www.vpac.org/StGermain/XML_IO_Handler/Jun2003">
 
 	<struct name="components" mergeType="merge">
-		<struct name="analyticVelocityMagnitudeColourMap">
+		<struct name="camera" mergeType="replace">
+			<param name="Type">lucCamera</param>
+			<param name="CentreFieldVariable">VelocityMagnitudeField</param>
+			<param name="coordZ">1.5</param>
+		</struct>
+		<struct name="analyticVelocityMagnitudeColourMap" mergeType="replace">
 			<param name="Type">lucColourMap</param>
 			<param name="colours">Purple Blue Green Yellow Orange Red Black</param>
 			<param name="dynamicRange">true</param>
 		</struct>
 		<!-- Drawing Objects -->
-		<!--
 		<struct name="analyticVelocityMagnitudeMap">
 			<param name="Type">lucScalarField</param>
 			<param name="FieldVariable">VelocityField-Analytic-Magnitude</param>
 			<param name="ColourMap">analyticVelocityMagnitudeColourMap</param>
 			<param name="resolution">128</param>
 		</struct>
-		-->
-		<struct name="analyticVelocityArrows">
-			<param name="Type">lucVectorArrows</param>
-			<param name="VectorVariable">VelocityField-Analytic</param>
-			<param name="Colour">black</param>
-			<param name="arrowHeadSize">0.15</param>	
-			<param name="lengthScale">0.15</param>	
+		<struct name="border" mergeType="replace">
+			<param name="Type">lucFieldVariableBorder</param>
+			<param name="FieldVariable">VelocityMagnitudeField</param>
 		</struct>
-		<struct name="analyticVelocityMagnitudeColourBar">
+		<struct name="analyticVelocityMagnitudeColourBar" mergeType="replace">
 			<param name="Type">lucColourBar</param>
 			<param name="ColourMap">analyticVelocityMagnitudeColourMap</param>
 		</struct>
@@ -34,9 +34,8 @@
 			<param name="Type">lucViewport</param>
 			<param name="Camera">camera</param>
 			<list name="DrawingObject">
-				<!--param>analyticVelocityMagnitudeMap</param-->
+				<param>analyticVelocityMagnitudeMap</param>
 				<param>border</param>
-				<param>analyticVelocityArrows</param>
 				<param>analyticVelocityMagnitudeColourBar</param>
 			</list>
 		</struct>

Added: long/3D/Gale/trunk/src/StgFEM/Apps/ThermalConvection/PressureAndVelocityArrowsVP.xml
===================================================================
--- long/3D/Gale/trunk/src/StgFEM/Apps/ThermalConvection/PressureAndVelocityArrowsVP.xml	2006-06-28 09:59:25 UTC (rev 3898)
+++ long/3D/Gale/trunk/src/StgFEM/Apps/ThermalConvection/PressureAndVelocityArrowsVP.xml	2006-06-28 10:01:38 UTC (rev 3899)
@@ -0,0 +1,50 @@
+<?xml version="1.0"?>
+<!DOCTYPE StGermainData SYSTEM "stgermain.dtd">
+
+<StGermainData xmlns="http://www.vpac.org/StGermain/XML_IO_Handler/Jun2003">
+
+	<struct name="components" mergeType="merge">
+		<struct name="camera" mergeType="replace">
+			<param name="Type">lucCamera</param>
+			<param name="CentreFieldVariable">PressureField</param>
+			<param name="coordZ">1.5</param>
+		</struct>
+		<struct name="pressureColourMap">
+			<param name="Type">lucColourMap</param>
+			<param name="colours">Black Purple DarkRed Orange Yellow</param>
+			<param name="dynamicRange">true</param>
+		</struct>
+		<struct name="velocityArrows" mergeType="replace">
+			<param name="Type">lucVectorArrows</param>
+			<param name="VectorVariable">VelocityField</param>
+			<param name="Colour">black</param>
+			<param name="arrowHeadSize">0.15</param>	
+			<param name="lengthScale">0.15</param>	
+		</struct>		
+		<!-- Drawing Objects -->
+		<struct name="pressureMap">
+			<param name="Type">lucScalarField</param>
+			<param name="FieldVariable">PressureField</param>
+			<param name="ColourMap">pressureColourMap</param>
+		</struct>
+		<struct name="border" mergeType="replace">
+			<param name="Type">lucFieldVariableBorder</param>
+			<param name="FieldVariable">PressureField</param>
+		</struct>
+		<struct name="pressureColourBar">
+			<param name="Type">lucColourBar</param>
+			<param name="ColourMap">pressureColourMap</param>
+		</struct>
+		<!-- Put these althogether in a viewport -->
+		<struct name="PressureAndVelocityArrowsVP">
+			<param name="Type">lucViewport</param>
+			<param name="Camera">camera</param>
+			<list name="DrawingObject">
+				<param>pressureMap</param>
+				<param>border</param>
+				<param>velocityArrows</param>
+				<param>pressureColourBar</param>
+			</list>
+		</struct>
+	</struct>
+</StGermainData>

Modified: long/3D/Gale/trunk/src/StgFEM/Apps/ThermalConvection/TemperatureAndVelocityArrowsVP.xml
===================================================================
--- long/3D/Gale/trunk/src/StgFEM/Apps/ThermalConvection/TemperatureAndVelocityArrowsVP.xml	2006-06-28 09:59:25 UTC (rev 3898)
+++ long/3D/Gale/trunk/src/StgFEM/Apps/ThermalConvection/TemperatureAndVelocityArrowsVP.xml	2006-06-28 10:01:38 UTC (rev 3899)
@@ -4,30 +4,31 @@
 <StGermainData xmlns="http://www.vpac.org/StGermain/XML_IO_Handler/Jun2003">
 
 	<struct name="components" mergeType="merge">
-		<struct name="temperatureVPCamera">
+		<struct name="camera" mergeType="replace">
 			<param name="Type">lucCamera</param>
 			<param name="CentreFieldVariable">TemperatureField</param>
 			<param name="coordZ">1.5</param>
 		</struct>
 		<struct name="temperatureColourMap">
 			<param name="Type">lucColourMap</param>
-			<param name="colours">Blue White Red</param>
-			<param name="dynamicRange">true</param>
+			<param name="colours">#0B0133 White #B7210B</param>
+			<param name="dynamicRange">True</param>
 		</struct>
 		<!-- Drawing Objects -->
 		<struct name="temperatureMap">
 			<param name="Type">lucScalarField</param>
 			<param name="FieldVariable">TemperatureField</param>
 			<param name="ColourMap">temperatureColourMap</param>
+			<param name="resolution">128</param>
 		</struct>
-		<struct name="velocityArrows"  mergeType="replace">
+		<struct name="velocityArrows" mergeType="replace">
 			<param name="Type">lucVectorArrows</param>
 			<param name="VectorVariable">VelocityField</param>
 			<param name="Colour">black</param>
 			<param name="arrowHeadSize">0.15</param>	
 			<param name="lengthScale">0.15</param>	
 		</struct>
-		<struct name="temperatureBorder">
+		<struct name="border" mergeType="replace">
 			<param name="Type">lucFieldVariableBorder</param>
 			<param name="FieldVariable">TemperatureField</param>
 		</struct>
@@ -38,10 +39,11 @@
 		<!-- Put these althogether in a viewport -->
 		<struct name="TemperatureAndVelocityArrowsVP">
 			<param name="Type">lucViewport</param>
-			<param name="Camera">temperatureVPCamera</param>
+			<param name="Camera">camera</param>
+			<param name="compositeEachObject">t</param>
 			<list name="DrawingObject">
 				<param>temperatureMap</param>
-				<param>temperatureBorder</param>
+				<param>border</param>
 				<param>velocityArrows</param>
 				<param>temperatureColourBar</param>
 			</list>

Modified: long/3D/Gale/trunk/src/StgFEM/Apps/ThermalConvection/demo.xml
===================================================================
--- long/3D/Gale/trunk/src/StgFEM/Apps/ThermalConvection/demo.xml	2006-06-28 09:59:25 UTC (rev 3898)
+++ long/3D/Gale/trunk/src/StgFEM/Apps/ThermalConvection/demo.xml	2006-06-28 10:01:38 UTC (rev 3899)
@@ -3,12 +3,20 @@
 
 <StGermainData xmlns="http://www.vpac.org/StGermain/XML_IO_Handler/Jun2003">
  	
-	<include>./ThermalConvection.xml</include>
+	<include>./tests/testAnalyticHyperbolic.xml</include>
+
 	<include>./TemperatureAndVelocityArrowsVP.xml</include>
+	<include>./VelocityMagnitudeVP.xml</include>
+	<include>./AnalyticVelocityMagnitudeVP.xml</include>
+	<include>./PressureAndVelocityArrowsVP.xml</include>
+	<include>./AnalyticPressureVP.xml</include>
 	<include>./window.xml</include>
 	<struct name="components" mergeType="merge">
 		<struct name="window" mergeType="merge">
-			<param name="Viewport">TemperatureAndVelocityArrowsVP</param>
+			<list name="Viewport">
+				<param>TemperatureAndVelocityArrowsVP VelocityMagnitudeVP AnalyticVelocityMagnitudeVP</param>
+				<param>PressureAndVelocityArrowsVP AnalyticPressureVP</param>
+			</list>
 		</struct>
 	</struct>
 	<param name="outputPath">./output</param>

Modified: long/3D/Gale/trunk/src/StgFEM/Apps/ThermalConvection/tests/expected/testThermalConvection-Analytic-2D.0of1.PressureField-ErrorFile.expected
===================================================================
--- long/3D/Gale/trunk/src/StgFEM/Apps/ThermalConvection/tests/expected/testThermalConvection-Analytic-2D.0of1.PressureField-ErrorFile.expected	2006-06-28 09:59:25 UTC (rev 3898)
+++ long/3D/Gale/trunk/src/StgFEM/Apps/ThermalConvection/tests/expected/testThermalConvection-Analytic-2D.0of1.PressureField-ErrorFile.expected	2006-06-28 10:01:38 UTC (rev 3899)
@@ -1,2 +1,2 @@
-Timestep 0: Total integrated value of 'PressureField-ErrorMagnitudeField' is within a tolerance 0.035.
-Timestep 1: Total integrated value of 'PressureField-ErrorMagnitudeField' is within a tolerance 0.035.
+Timestep 0: Total integrated value of 'PressureField-ErrorMagnitudeField' is outside a tolerance 0.0005.
+Timestep 1: Total integrated value of 'PressureField-ErrorMagnitudeField' is within a tolerance 0.0005.

Modified: long/3D/Gale/trunk/src/StgFEM/Apps/ThermalConvection/tests/expected/testThermalConvection-Analytic-2D.0of2.PressureField-ErrorFile.expected
===================================================================
--- long/3D/Gale/trunk/src/StgFEM/Apps/ThermalConvection/tests/expected/testThermalConvection-Analytic-2D.0of2.PressureField-ErrorFile.expected	2006-06-28 09:59:25 UTC (rev 3898)
+++ long/3D/Gale/trunk/src/StgFEM/Apps/ThermalConvection/tests/expected/testThermalConvection-Analytic-2D.0of2.PressureField-ErrorFile.expected	2006-06-28 10:01:38 UTC (rev 3899)
@@ -1,2 +1,2 @@
-Timestep 0: Total integrated value of 'PressureField-ErrorMagnitudeField' is within a tolerance 0.035.
-Timestep 1: Total integrated value of 'PressureField-ErrorMagnitudeField' is within a tolerance 0.035.
+Timestep 0: Total integrated value of 'PressureField-ErrorMagnitudeField' is outside a tolerance 0.0005.
+Timestep 1: Total integrated value of 'PressureField-ErrorMagnitudeField' is within a tolerance 0.0005.

Modified: long/3D/Gale/trunk/src/StgFEM/Apps/ThermalConvection/tests/testAnalytic.xml
===================================================================
--- long/3D/Gale/trunk/src/StgFEM/Apps/ThermalConvection/tests/testAnalytic.xml	2006-06-28 09:59:25 UTC (rev 3898)
+++ long/3D/Gale/trunk/src/StgFEM/Apps/ThermalConvection/tests/testAnalytic.xml	2006-06-28 10:01:38 UTC (rev 3899)
@@ -8,11 +8,11 @@
 	<param name="Ra">1.0</param>
 
 	<list name="plugins" mergeType="merge">
-		<param>StG_FEM_ColumnViscosityAnalytic</param>
+		<param>Velic_solA</param>
 	</list>
 
 	<param name="VelocityField-Tolerance">1.0e-4</param>
-	<param name="PressureField-Tolerance">0.035</param>
+	<param name="PressureField-Tolerance">0.0005</param>
 
 	<struct name="temperatureICs" mergeType="replace">
 		<param name="type">CompositeVC</param>
@@ -23,7 +23,7 @@
 					<struct>
 						<param name="name">temperature</param>
 						<param name="type">func</param>
-						<param name="value"> ColumnViscosityAnalytic_TemperatureIC </param>
+						<param name="value"> VelicTemperatureIC </param>
 					</struct>
 				</list>
 			</struct>

Added: long/3D/Gale/trunk/src/StgFEM/Apps/ThermalConvection/tests/testAnalyticHyperbolic.xml
===================================================================
--- long/3D/Gale/trunk/src/StgFEM/Apps/ThermalConvection/tests/testAnalyticHyperbolic.xml	2006-06-28 09:59:25 UTC (rev 3898)
+++ long/3D/Gale/trunk/src/StgFEM/Apps/ThermalConvection/tests/testAnalyticHyperbolic.xml	2006-06-28 10:01:38 UTC (rev 3899)
@@ -0,0 +1,35 @@
+<!-- Rayleigh-Taylor app input file -->
+
+<!-- DTD to validate against -->
+<StGermainData xmlns="http://www.vpac.org/StGermain/XML_IO_Handler/Jun2003">
+	
+	<include>../ThermalConvection.xml</include>
+
+	<param name="Ra">1.0</param>
+
+	<list name="plugins" mergeType="merge">
+		<param>Velic_solB</param>
+	</list>
+
+	<param name="VelocityField-Tolerance">1.0e-4</param>
+	<param name="PressureField-Tolerance">0.0005</param>
+
+	<struct name="temperatureICs" mergeType="replace">
+		<param name="type">CompositeVC</param>
+		<list name="vcList">
+			<struct>
+				<param name="type"> AllNodesVC </param>
+				<list name="variables">
+					<struct>
+						<param name="name">temperature</param>
+						<param name="type">func</param>
+						<param name="value"> VelicTemperatureIC_Hyperbolic </param>
+					</struct>
+				</list>
+			</struct>
+		</list>
+	</struct>	
+	<struct name="temperatureBCs" mergeType="replace">
+	</struct>	
+
+</StGermainData>	

Modified: long/3D/Gale/trunk/src/StgFEM/Discretisation/src/AnalyticSolution.c
===================================================================
--- long/3D/Gale/trunk/src/StgFEM/Discretisation/src/AnalyticSolution.c	2006-06-28 09:59:25 UTC (rev 3898)
+++ long/3D/Gale/trunk/src/StgFEM/Discretisation/src/AnalyticSolution.c	2006-06-28 10:01:38 UTC (rev 3899)
@@ -114,6 +114,7 @@
 	self->context = context;
 
 	/* Create Lists */
+	self->feVariableList             = Stg_ObjectList_New();
 	self->analyticFeVariableList     = Stg_ObjectList_New();
 	self->analyticFeVariableFuncList = Stg_ObjectList_New();
 	self->errorMagnitudeFieldList    = Stg_ObjectList_New();
@@ -129,6 +130,7 @@
 void _AnalyticSolution_Delete( void* analyticSolution ) {
 	AnalyticSolution* self = (AnalyticSolution*)analyticSolution;
 	
+	Stg_Class_Delete( self->feVariableList );
 	Stg_Class_Delete( self->analyticFeVariableList );
 	Stg_Class_Delete( self->analyticFeVariableFuncList );
 	Stg_Class_Delete( self->errorMagnitudeFieldList );
@@ -167,6 +169,17 @@
 }
 
 void _AnalyticSolution_Build( void* analyticSolution, void* data ) {
+	AnalyticSolution* self = (AnalyticSolution*) analyticSolution;
+	Index             analyticFeVariableCount = Stg_ObjectList_Count( self->analyticFeVariableList );
+	Index             analyticFeVariable_I;
+	
+	assert( analyticFeVariableCount == Stg_ObjectList_Count( self->analyticFeVariableFuncList ) );
+
+	for ( analyticFeVariable_I = 0 ; analyticFeVariable_I < analyticFeVariableCount ; analyticFeVariable_I++ ) {
+		Stg_Component_Build( Stg_ObjectList_At( self->feVariableList, analyticFeVariable_I ), data, False ) ;
+		Stg_Component_Build( Stg_ObjectList_At( self->analyticFeVariableList, analyticFeVariable_I ), data, False ) ;
+		Stg_Component_Build( Stg_ObjectList_At( self->errorMagnitudeFieldList, analyticFeVariable_I ), data, False ) ;
+	}
 }
 
 void _AnalyticSolution_Initialise( void* analyticSolution, void* data ) {
@@ -178,6 +191,10 @@
 
 	/* Assign values to all analytic fields */
 	for ( analyticFeVariable_I = 0 ; analyticFeVariable_I < analyticFeVariableCount ; analyticFeVariable_I++ ) {
+		Stg_Component_Initialise( Stg_ObjectList_At( self->feVariableList, analyticFeVariable_I ), data, False ) ;
+		Stg_Component_Initialise( Stg_ObjectList_At( self->analyticFeVariableList, analyticFeVariable_I ), data, False ) ;
+		Stg_Component_Initialise( Stg_ObjectList_At( self->errorMagnitudeFieldList, analyticFeVariable_I ), data, False ) ;
+
 		AnalyticSolution_PutAnalyticSolutionOntoNodes( self, analyticFeVariable_I );
 	}
 }
@@ -272,7 +289,7 @@
 	FeVariable*                                  analyticFeVariable;
 	Variable*                                    dataVariable;
 	DofLayout*                                   dofLayout;
-	Variable_Register*                           variable_Register = feVariable->dofLayout->_variableRegister;
+	Variable_Register*                           variable_Register = self->context->variable_Register;
 	Dof_Index                                    componentsCount   = feVariable->fieldComponentCount;
 	Name                                         variableName[9];
 	Variable_Index                               variable_I;
@@ -347,6 +364,7 @@
 	analyticFeVariable = FeVariable_New( tmpName, feVariable->feMesh, feVariable->geometryMesh, dofLayout, NULL, NULL, NULL, feVariable->dim, feVariable->fieldVariable_Register );
 
 	/* Add new FeVariable to list */
+	Stg_ObjectList_Append( self->feVariableList,         feVariable );
 	Stg_ObjectList_Append( self->analyticFeVariableList, analyticFeVariable );
 
 	/* Add function to list */
@@ -391,7 +409,7 @@
 	return analyticFeVariable;
 }
 
-FeVariable* AnalyticSolution_CreateAnalyticFieldWithMagnitude( void* analyticSolution, FeVariable* vectorField, AnalyticSolution_FeVariableSolutionFunction* solutionFunction ) {
+FeVariable* AnalyticSolution_CreateAnalyticVectorField( void* analyticSolution, FeVariable* vectorField, AnalyticSolution_FeVariableSolutionFunction* solutionFunction ) {
 	AnalyticSolution*                            self = (AnalyticSolution*) analyticSolution;
 	FeVariable*                                  analyticVectorField;
 	OperatorFeVariable*                          analyticVectorMagField;
@@ -408,3 +426,49 @@
 
 	return analyticVectorField;
 }
+
+FeVariable* AnalyticSolution_CreateAnalyticSymmetricTensorField( void* analyticSolution, FeVariable* vectorField, AnalyticSolution_FeVariableSolutionFunction* solutionFunction ) {
+	AnalyticSolution*                            self = (AnalyticSolution*) analyticSolution;
+	FeVariable*                                  analyticVectorField;
+	OperatorFeVariable*                          analyticVectorInvField;
+	Name                                         tmpName;
+
+	analyticVectorField = AnalyticSolution_CreateAnalyticField( self, vectorField, solutionFunction );
+
+	/* Create Invariant Field */
+	tmpName = Stg_Object_AppendSuffix( analyticVectorField, "Invariant" );
+	analyticVectorInvField = OperatorFeVariable_NewUnary( tmpName, analyticVectorField, "SymmetricTensor_Invariant" );
+	Memory_Free( tmpName );
+
+	LiveComponentRegister_Add( self->LC_Register, (Stg_Component*) analyticVectorInvField );
+
+	return analyticVectorField;
+}
+
+FeVariable* AnalyticSolution_GetFeVariableFromAnalyticFeVariable( void* analyticSolution, FeVariable* analyticFeVariable ) {
+	AnalyticSolution* self = (AnalyticSolution*) analyticSolution;
+	Index             analyticFeVariableCount = Stg_ObjectList_Count( self->analyticFeVariableList );
+	Index             analyticFeVariable_I;
+
+	assert( analyticFeVariableCount == Stg_ObjectList_Count( self->feVariableList ) );
+
+	for ( analyticFeVariable_I = 0 ; analyticFeVariable_I < analyticFeVariableCount ; analyticFeVariable_I++ ) {
+		/* find the index of analytic feVariable and then return the corresponding feVariable */
+		if ( analyticFeVariable == (FeVariable*) Stg_ObjectList_At( self->analyticFeVariableList, analyticFeVariable_I ) )
+			return (FeVariable*) Stg_ObjectList_At( self->feVariableList, analyticFeVariable_I );
+	}
+
+	return NULL;
+}
+	
+InterpolationResult AnalyticSolution_InterpolateValueFromNormalFeVariable( void* analyticSolution, FeVariable* analyticFeVariable, double* coord, double* value ) {
+	AnalyticSolution*                            self = (AnalyticSolution*) analyticSolution;
+	FeVariable*       normalFeVariable;
+
+	normalFeVariable = AnalyticSolution_GetFeVariableFromAnalyticFeVariable( self, analyticFeVariable );
+
+	return FieldVariable_InterpolateValueAt( normalFeVariable, coord, value );
+}
+
+
+

Modified: long/3D/Gale/trunk/src/StgFEM/Discretisation/src/AnalyticSolution.h
===================================================================
--- long/3D/Gale/trunk/src/StgFEM/Discretisation/src/AnalyticSolution.h	2006-06-28 09:59:25 UTC (rev 3898)
+++ long/3D/Gale/trunk/src/StgFEM/Discretisation/src/AnalyticSolution.h	2006-06-28 10:01:38 UTC (rev 3899)
@@ -61,6 +61,7 @@
 		__Stg_Component \
 		/* Virtual info */ \
 		/* AnalyticSolution info */ \
+		Stg_ObjectList*        feVariableList;             \
 		Stg_ObjectList*        analyticFeVariableList;     \
 		Stg_ObjectList*        analyticFeVariableFuncList; \
 		Stg_ObjectList*        errorMagnitudeFieldList;    \
@@ -132,7 +133,10 @@
 	
 	void AnalyticSolution_PutAnalyticSolutionOntoNodes( void* analyticSolution, Index analyticFeVariable_I ) ;
 	FeVariable* AnalyticSolution_CreateAnalyticField( void* analyticSolution, FeVariable* feVariable, AnalyticSolution_FeVariableSolutionFunction* solutionFunction ) ;
-	FeVariable* AnalyticSolution_CreateAnalyticFieldWithMagnitude( void* analyticSolution, FeVariable* vectorField, AnalyticSolution_FeVariableSolutionFunction* solutionFunction ) ;
+	FeVariable* AnalyticSolution_CreateAnalyticVectorField( void* analyticSolution, FeVariable* vectorField, AnalyticSolution_FeVariableSolutionFunction* solutionFunction ) ;
+	FeVariable* AnalyticSolution_CreateAnalyticSymmetricTensorField( void* analyticSolution, FeVariable* vectorField, AnalyticSolution_FeVariableSolutionFunction* solutionFunction ) ;
 
+	FeVariable* AnalyticSolution_GetFeVariableFromAnalyticFeVariable( void* analyticSolution, FeVariable* analyticFeVariable ) ;
+	InterpolationResult AnalyticSolution_InterpolateValueFromNormalFeVariable( void* analyticSolution, FeVariable* analyticFeVariable, double* coord, double* value ) ;
 	
 #endif /* __StG_FEM_Discretisation_AnalyticSolution_h__ */

Modified: long/3D/Gale/trunk/src/StgFEM/Discretisation/src/FeVariable.c
===================================================================
--- long/3D/Gale/trunk/src/StgFEM/Discretisation/src/FeVariable.c	2006-06-28 09:59:25 UTC (rev 3898)
+++ long/3D/Gale/trunk/src/StgFEM/Discretisation/src/FeVariable.c	2006-06-28 10:01:38 UTC (rev 3899)
@@ -445,6 +445,7 @@
 
 void _FeVariable_Build( void* variable, void* data ) {
 	FeVariable* self = (FeVariable*)variable;
+	DiscretisationContext*   context = (DiscretisationContext*)data;
 	
 	if ( False == self->isBuilt ) {
 		self->isBuilt = True;
@@ -458,7 +459,9 @@
 		if ( self->bcs ){
 			Build( self->bcs, data, False );
 		}
-		if ( self->ics ) {
+		/* only bother building the ics specified via XML/construct if we are not in restart mode
+		  - otherwise, we will use the checkpointed values anyway */
+		if ( self->ics && !(context && (True == context->loadFromCheckPoint) ) ) {
 			Build( self->ics, data, False );
 		}
 		if ( self->linkedDofInfo ) {
@@ -507,41 +510,56 @@
 	/* do basic mesh initialisation */
 	Initialise( self->feMesh, data, False );
 	Initialise( self->dofLayout, data, False );
-	if ( self->ics ) {
-		Journal_DPrintf( self->debug, "applying the I.C.s for this Variable.\n" ); 
-		VariableCondition_Apply( self->ics, data );
-	}
-	if ( self->bcs ) {
-		Initialise( self->bcs, data, False );
-		Journal_DPrintf( self->debug, "applying the B.C.s for this Variable.\n" ); 
-		VariableCondition_Apply( self->bcs, data );
-	}
+
 	if ( self->linkedDofInfo ) {
 		Initialise( self->linkedDofInfo, data, False );
 	}
 	
 	FeEquationNumber_Initialise( self->eqNum );
 
-	if ( context && ( True == context->loadFromCheckPoint ) ) {
-		char*                  inputPathString = NULL;
-		Index                  inputStrLen = 0;
-
-		inputStrLen = strlen(context->outputPath) + 1 + 1;
-		if ( strlen(context->checkPointPrefixString) > 0 ) {
-			inputStrLen += strlen(context->checkPointPrefixString) + 1;
+	if ( self->ics || (context && (True == context->loadFromCheckPoint) ) ) {
+		Journal_DPrintf( self->debug, "applying the I.C.s for this Variable:\n" ); 
+		Stream_Indent( self->debug );
+	
+		if ( self->ics && !(context && (True == context->loadFromCheckPoint) ) ) {
+			Journal_DPrintf( self->debug, "regular (non-restart) mode -> applying ICs specified in XML/constructor\n" );
+			Initialise( self->ics, data, False );
+			VariableCondition_Apply( self->ics, data );
 		}
-		inputPathString = Memory_Alloc_Array( char, inputStrLen, "inputPathString" );
-
-		if ( strlen(context->checkPointPrefixString) > 0 ) {
-			sprintf( inputPathString, "%s/%s.", context->outputPath, context->checkPointPrefixString );
-		}
 		else {
-			sprintf( inputPathString, "%s/", context->outputPath );
-		}
+			char*                  inputPathString = NULL;
+			Index                  inputStrLen = 0;
 
-		FeVariable_ReadFromFile( self, inputPathString, context->restartTimestep );
+			Journal_DPrintf( self->debug, "restart from checkpoint mode -> loading checkpointed "
+				"nodal values as initial conditions, ignoring ics specified via XML/constructor\n" );
+
+			inputStrLen = strlen(context->outputPath) + 1 + 1;
+			if ( strlen(context->checkPointPrefixString) > 0 ) {
+				inputStrLen += strlen(context->checkPointPrefixString) + 1;
+			}
+			inputPathString = Memory_Alloc_Array( char, inputStrLen, "inputPathString" );
+
+			if ( strlen(context->checkPointPrefixString) > 0 ) {
+				sprintf( inputPathString, "%s/%s.", context->outputPath, context->checkPointPrefixString );
+			}
+			else {
+				sprintf( inputPathString, "%s/", context->outputPath );
+			}
+
+			FeVariable_ReadFromFile( self, inputPathString, context->restartTimestep );
+		
+			/* TODO: maybe we want a mechanism in future to over-ride the checkpointed ICs in certain regions too
+			so the user can introduce new phenomena into the model */
+		}	
 	}
+	Stream_UnIndent( self->debug );
 
+	if ( self->bcs ) {
+		Initialise( self->bcs, data, False );
+		Journal_DPrintf( self->debug, "applying the B.C.s for this Variable.\n" ); 
+		VariableCondition_Apply( self->bcs, data );
+	}
+
 	Stream_UnIndentBranch( StG_FEM_Debug );
 }
 
@@ -631,93 +649,29 @@
 
 InterpolationResult _FeVariable_InterpolateValueAt( void* variable, Coord globalCoord, double* value ) {
 	FeVariable*		self = (FeVariable*)variable;
-	MeshLayout*		mLayout = self->feMesh->layout;
-	ElementLayout*		eLayout = mLayout->elementLayout;
 	Element_DomainIndex	elementCoordIn = (unsigned)-1;
-	Node_LocalIndex		currElementNodeCount=0;
-	Coord**			globalNodeCoordPtrs=NULL;
-	ElementType*		elementType = NULL;
 	Coord			elLocalCoord={0,0,0};
 	InterpolationResult	retValue;
 
-	/* locate which mesh element given coord is in : use inclusive upper boundaries to save
-		the need to use shadow space if possible */
-	if( eLayout->type == ParallelPipedHexaEL_Type ) {
-		elementCoordIn = eLayout->elementWithPoint( eLayout, mLayout->decomp, globalCoord,
-							    INCLUSIVE_UPPER_BOUNDARY, 0, NULL );
-	}
-	else {
-		unsigned	cNode;
 
-		/* Find closest node to point. */
-		cNode = _FeVariable_ClosestNode( self, globalCoord );
-
-		/* Find with hint of incident elements. */
-		elementCoordIn = eLayout->elementWithPoint( eLayout, mLayout->decomp, globalCoord,
-							    INCLUSIVE_UPPER_BOUNDARY, 
-							    self->feMesh->nodeElementCountTbl[cNode], self->feMesh->nodeElementTbl[cNode] );
-
-		/* If still no cigar, brute force. */
-		if ( elementCoordIn >= self->feMesh->elementDomainCount ) {
-			elementCoordIn = eLayout->elementWithPoint( eLayout, mLayout->decomp, globalCoord,
-								    INCLUSIVE_UPPER_BOUNDARY, 0, NULL );
-		}
+	retValue = FeVariable_GetElementLocalCoordAtGlobalCoord( self, globalCoord, elLocalCoord, &elementCoordIn );
+	
+	if ( retValue == LOCAL ) {
+		/* Now interpolate the value at that coordinate, using shape functions */
+		self->_interpolateWithinElement( self, elementCoordIn, elLocalCoord, value );
 	}
-
-	if ( elementCoordIn >= self->feMesh->elementDomainCount ) {
-		Bool			outsideGlobal = False;
-		Coord			min, max;
-		Dimension_Index		dim_I=0;
-		Bool			checkResult;
-		Stream*			errorStr = Journal_Register( Error_Type, self->type );
-
-		checkResult = ElementLayout_GetStaticMinAndMaxGlobalCoords( mLayout->elementLayout, min, max );
-		Journal_Firewall( True == checkResult, errorStr, "Error - in %s: current mesh doesn't"
-			"know how to calculate global max and min values.\n", __func__ );
-		
-		for ( dim_I = 0; dim_I < self->dim; dim_I++ ) {
-			if ( ( globalCoord[dim_I] < min[dim_I] ) || (globalCoord[dim_I] > max[dim_I] ) ) {
-				outsideGlobal = True;
-			}
+	else if ( retValue == SHADOW ) {
+		if ( False == self->shadowValuesSynchronised ) {
+			Stream* warningStr = Journal_Register( Error_Type, self->type );
+			Journal_Printf( warningStr, "Warning - in %s: user asking to interpolate a value at "
+				"coord (%g,%g,%g), which is in shadow space, but "
+				"FeVariable_SyncShadowValues() hasn't been called yet.\n", 
+				__func__, globalCoord[0], globalCoord[1], globalCoord[2] );
+			return retValue;		
 		}
-
-		if ( outsideGlobal == True ) {
-			return OUTSIDE_GLOBAL;
-		}
-		else {
-			return OTHER_PROC;
-		}	
-	}	
-	else /* We found the coord is within a local or shadow element */ {
-	
-		if ( elementCoordIn < self->feMesh->elementLocalCount ) {
-			retValue = LOCAL;
-		}
-		else {
-			retValue = SHADOW;
-			if ( False == self->shadowValuesSynchronised ) {
-				Stream* warningStr = Journal_Register( Error_Type, self->type );
-				Journal_Printf( warningStr, "Warning - in %s: user asking to interpolate to "
-					"coord (%g,%g,%g), which is in shadow space, but "
-					"FeVariable_SyncShadowValues() hasn't been called yet.\n", 
-					__func__, globalCoord[0], globalCoord[1], globalCoord[2] );
-				return retValue;		
-			}
-		}
-
-		/* convert global coordinate to local co-ordinates of element the coord is in */
-		currElementNodeCount = self->feMesh->elementNodeCountTbl[elementCoordIn];
-		globalNodeCoordPtrs = Memory_Alloc_Array( Coord*, currElementNodeCount, "globalNodeCoordPtrs" );
-		Mesh_GetNodeCoordPtrsOfElement( self->feMesh, elementCoordIn, globalNodeCoordPtrs );
-
-		elementType = FeMesh_ElementTypeAt( self->feMesh, elementCoordIn );
-		ElementType_ConvertGlobalCoordToElLocal( elementType, eLayout,
-			(const Coord**) globalNodeCoordPtrs, globalCoord, elLocalCoord );
-
 		/* Now interpolate the value at that coordinate, using shape functions */
 		self->_interpolateWithinElement( self, elementCoordIn, elLocalCoord, value );
-		Memory_Free( globalNodeCoordPtrs );
-	}	
+	}
 	
 	return retValue;
 }
@@ -865,6 +819,92 @@
 
 /* --- Public Functions --- */
 
+InterpolationResult FeVariable_GetElementLocalCoordAtGlobalCoord( void* feVariable, Coord globalCoord, Coord elLocalCoord,
+		Element_DomainIndex* elementCoordInPtr )
+{
+	FeVariable*		self = (FeVariable*)feVariable;
+	MeshLayout*		mLayout = self->feMesh->layout;
+	ElementLayout*		eLayout = mLayout->elementLayout;
+	InterpolationResult	retValue;
+
+	(*elementCoordInPtr) = (unsigned)-1;
+	
+	/* locate which mesh element given coord is in : use inclusive upper boundaries to save
+		the need to use shadow space if possible */
+	if( eLayout->type == ParallelPipedHexaEL_Type ) {
+		(*elementCoordInPtr) = eLayout->elementWithPoint( eLayout, mLayout->decomp, globalCoord,
+							    INCLUSIVE_UPPER_BOUNDARY, 0, NULL );
+	}
+	else {
+		unsigned	cNode;
+
+		/* Find closest node to point. */
+		cNode = _FeVariable_ClosestNode( self, globalCoord );
+
+		/* Find with hint of incident elements. */
+		(*elementCoordInPtr) = eLayout->elementWithPoint( eLayout, mLayout->decomp, globalCoord,
+							    INCLUSIVE_UPPER_BOUNDARY, 
+							    self->feMesh->nodeElementCountTbl[cNode], self->feMesh->nodeElementTbl[cNode] );
+
+		/* If still no cigar, brute force. */
+		if ( (*elementCoordInPtr) >= self->feMesh->elementDomainCount ) {
+			(*elementCoordInPtr) = eLayout->elementWithPoint( eLayout, mLayout->decomp, globalCoord,
+								    INCLUSIVE_UPPER_BOUNDARY, 0, NULL );
+		}
+	}
+
+	if ( (*elementCoordInPtr) >= self->feMesh->elementDomainCount ) {
+		Bool			outsideGlobal = False;
+		Coord			min, max;
+		Dimension_Index		dim_I=0;
+		Bool			checkResult;
+		Stream*			errorStr = Journal_Register( Error_Type, self->type );
+
+		checkResult = ElementLayout_GetStaticMinAndMaxGlobalCoords( mLayout->elementLayout, min, max );
+		Journal_Firewall( True == checkResult, errorStr, "Error - in %s: current mesh doesn't"
+			"know how to calculate global max and min values.\n", __func__ );
+		
+		for ( dim_I = 0; dim_I < self->dim; dim_I++ ) {
+			if ( ( globalCoord[dim_I] < min[dim_I] ) || (globalCoord[dim_I] > max[dim_I] ) ) {
+				outsideGlobal = True;
+			}
+		}
+
+		if ( outsideGlobal == True ) {
+			return OUTSIDE_GLOBAL;
+		}
+		else {
+			return OTHER_PROC;
+		}	
+	}	
+	else /* We found the coord is within a local or shadow element */ {
+		Node_LocalIndex		currElementNodeCount=0;
+		Coord**			globalNodeCoordPtrs=NULL;
+		ElementType*		elementType = NULL;
+	
+		if ( (*elementCoordInPtr) < self->feMesh->elementLocalCount ) {
+			retValue = LOCAL;
+		}
+		else {
+			retValue = SHADOW;
+		}
+
+		/* convert global coordinate to local co-ordinates of element the coord is in */
+		currElementNodeCount = self->feMesh->elementNodeCountTbl[(*elementCoordInPtr)];
+		globalNodeCoordPtrs = Memory_Alloc_Array( Coord*, currElementNodeCount, "globalNodeCoordPtrs" );
+		Mesh_GetNodeCoordPtrsOfElement( self->feMesh, (*elementCoordInPtr), globalNodeCoordPtrs );
+
+		elementType = FeMesh_ElementTypeAt( self->feMesh, (*elementCoordInPtr) );
+		ElementType_ConvertGlobalCoordToElLocal( elementType, eLayout,
+			(const Coord**) globalNodeCoordPtrs, globalCoord, elLocalCoord );
+
+		Memory_Free( globalNodeCoordPtrs );
+	}	
+
+	return retValue;
+}
+
+
 void FeVariable_SetValueAtNode( void* feVariable, Node_DomainIndex dNode_I, double* componentValues ) {
 	FeVariable*	self = (FeVariable*)feVariable;
 	Dof_Index	dofCountThisNode = 0;
@@ -1880,6 +1920,11 @@
 }
 
 
+/* Note: if we wish to support changing grid resolution half way through, then we'll need to make this function smarter,
+and probably save some mesh info as part of the CP so we can work out how to subsample (probably can then just create
+a temporary feVariable using the old size mesh, then keep calling InterpolateValueAt on it whereever our nodes are
+located, though this may not work easily in parallel ),. - PatrickSunter 9 Jun 2006
+*/
 void FeVariable_ReadFromFile( void* feVariable, const char* prefixStr, unsigned int timeStep ) {
 	FeVariable*        self = (FeVariable*)feVariable;
 	char*              filename;
@@ -1891,12 +1936,28 @@
 	double             variableVal;
 	char               lineString[100];
 	const char         MAX_LINE_LENGTH = 100;
+	Processor_Index    proc_I=0;
+	Dimension_Index    dim_I=0;
+	BlockGeometry*     geometry = (BlockGeometry*)self->feMesh->layout->elementLayout->geometry;
 	
+	/* Necessary for now since we need to update the geometry min and max - see comment below */
+	Stg_CheckType( geometry, BlockGeometry );
+
 	/*                                                prefix            self->name        . 00000 .  dat \0 */
 	filename = Memory_Alloc_Array_Unnamed( char, strlen(prefixStr) + strlen(self->name) + 1 + 5 + 1 + 3 + 1 );
 	sprintf( filename, "%s%s.%.5u.dat", prefixStr, self->name, timeStep );
-	inputFile = fopen( filename, "r" );
 
+	/* TODO May need/want to change to MPI file stuff */
+	
+	/* This loop used to stop 2 processors trying to open the file at the same time, which
+	  * seems to cause problems */
+	for ( proc_I = 0; proc_I < self->feMesh->layout->decomp->nproc; proc_I++ ) {
+		MPI_Barrier( self->feMesh->layout->decomp->communicator );
+		if ( proc_I == self->feMesh->layout->decomp->rank ) {	
+			inputFile = fopen( filename, "r" );
+		}
+	}
+
 	if ( False == inputFile ) {
 		Stream*    errorStr = Journal_Register( Error_Type, self->type );
 		Journal_Printf( errorStr, "Error- in %s(), for feVariable \"%s\": Couldn't find checkpoint file with "
@@ -1905,14 +1966,26 @@
 		exit(EXIT_FAILURE);	
 	}
 
-	dofAtEachNodeCount = self->dofLayout->dofCounts[0];
+	dofAtEachNodeCount = self->fieldComponentCount;
 
 	while ( !feof(inputFile) ) {
 		fscanf( inputFile, "%u ", &gNode_I );
 		lNode_I = Mesh_NodeMapGlobalToLocal( self->feMesh, gNode_I );
 		if ( lNode_I != Mesh_Node_Invalid( self->feMesh ) ) {
+			/* Note: until we have proper mesh geometry, topology etc checkpointing, we re-load the 
+			node co-ords from the feVariable file - and also update the geometry */
 			fscanf( inputFile, "%lg %lg %lg ", &self->feMesh->nodeCoord[lNode_I][0], &self->feMesh->nodeCoord[lNode_I][1],
 				&self->feMesh->nodeCoord[lNode_I][2] );
+
+			for ( dim_I = 0; dim_I < 3; dim_I++ ) {
+				if ( self->feMesh->nodeCoord[lNode_I][dim_I] < geometry->min[dim_I] ) {
+					geometry->min[dim_I] = self->feMesh->nodeCoord[lNode_I][dim_I];
+				}
+				else if ( self->feMesh->nodeCoord[lNode_I][dim_I] > geometry->max[dim_I] ) {
+					geometry->max[dim_I] = self->feMesh->nodeCoord[lNode_I][dim_I];
+				}
+			}
+			
 			for ( dof_I = 0; dof_I < dofAtEachNodeCount; dof_I++ ) {
 				fscanf( inputFile, "%lg ", &variableVal );
 				DofLayout_SetValueDouble( self->dofLayout, lNode_I, dof_I, variableVal );
@@ -1923,4 +1996,8 @@
 		}	
 	}			
 	fclose( inputFile );
+
+	if ( Stg_Class_IsInstance( self->feMesh->layout->elementLayout, ParallelPipedHexaEL_Type ) ) {
+		ParallelPipedHexaEL_UpdateGeometryPartitionInfo( self->feMesh->layout->elementLayout, self->feMesh->layout->decomp );
+	}
 }				

Modified: long/3D/Gale/trunk/src/StgFEM/Discretisation/src/FeVariable.h
===================================================================
--- long/3D/Gale/trunk/src/StgFEM/Discretisation/src/FeVariable.h	2006-06-28 09:59:25 UTC (rev 3898)
+++ long/3D/Gale/trunk/src/StgFEM/Discretisation/src/FeVariable.h	2006-06-28 10:01:38 UTC (rev 3899)
@@ -241,6 +241,11 @@
 
 	/* --- Public Functions --- */
 
+	/** Calculates the domain element & element local coord that a particular global coord lives in.
+		Same return status conventions as for the InterpolateValueAt function. */
+	InterpolationResult FeVariable_GetElementLocalCoordAtGlobalCoord( void* feVariable, Coord globalCoord,
+		Coord elLocalCoord, Element_DomainIndex* elementCoordInPtr );
+
 	/** Updates a single component of the value at a certain node */
 	#define FeVariable_SetComponentAtNode( feVariable, dNode_I, dof_I, componentVal ) \
 		DofLayout_SetValueDouble( (feVariable)->dofLayout, dNode_I, dof_I, componentVal );

Modified: long/3D/Gale/trunk/src/StgFEM/Discretisation/tests/expected/testFeVariable.0of1.expected
===================================================================
--- long/3D/Gale/trunk/src/StgFEM/Discretisation/tests/expected/testFeVariable.0of1.expected	2006-06-28 09:59:25 UTC (rev 3898)
+++ long/3D/Gale/trunk/src/StgFEM/Discretisation/tests/expected/testFeVariable.0of1.expected	2006-06-28 10:01:38 UTC (rev 3899)
@@ -1,55 +1,60 @@
-StGermain Framework revision 0. Copyright (C) 2003-2005 VPAC.
-StGermain Discretisation Library revision 0. Copyright (C) 2003-2005 VPAC.
-StGermain FEM Discretisation Framework revision 0. Copyright (C) 2003-2005 VPAC.
+StGermain Framework revision 3605. Copyright (C) 2003-2005 VPAC.
+StGermain Discretisation Library revision 3605. Copyright (C) 2003-2005 VPAC.
+StGermain FEM Discretisation Framework revision 566. Copyright (C) 2003-2005 VPAC.
 Watching rank: 0
-WallVC (ptr): 0x806aa10
-	dictionary (ptr): 0x8060580
-	_dictionaryEntryName (ptr): 0x804b041
+WallVC (ptr): 0x806b5d8
+	dictionary (ptr): 0x8060610
+	_dictionaryEntryName (ptr): 0x804b039
 		_dictionaryEntryName: boundaryCondition
 	_wall: Left
 	_entryCount: 1
-	_entryTbl (ptr): 0x806b4f0
+	_entryTbl (ptr): 0x806c7d8
 		_entryTbl[0]:
-			varName (ptr): 0x80603f0
+			varName (ptr): 0x8060480
 				varName: vx
 			value:
 				type: VC_ValueType_Double
 				asDouble: -1
-	_mesh (ptr): 0x80677a0
-VariableCondition (ptr): 0x806aa10
-Stg_Component (ptr): 0x806aa10
-Stg_Object (ptr): 0x806aa10
-	Stg_Class (ptr): 0x806aa10
-		sizeOfSelf: 172
+	_mesh (ptr): 0x8068ff0
+VariableCondition (ptr): 0x806b5d8
+Stg_Component (ptr): 0x806b5d8
+Stg_Object (ptr): 0x806b5d8
+	Stg_Class (ptr): 0x806b5d8
+		sizeOfSelf: 192
 		_deleteSelf: Yes
 		type: WallVC
-		_delete (func ptr): 0x40154246
-		_print (func ptr): 0x4015428c
-		_copy (func ptr): 0x4015483c
+		_delete (func ptr): 0xb7dfff77
+		_print (func ptr): 0xb7dfffbd
+		_copy (func ptr): 0xb7e0056e
 	name: WallVC
 	nameAllocationType: NON_GLOBAL
-	_defaultConstructor (func ptr): 0x401534f0
-	_construct (func ptr): 0x40154a51
-	_build (func ptr): 0x40154a0f
-	_initialise (func ptr): 0x400853d1
-	_execute (func ptr): 0x40085495
-	_destroy (func ptr): 0x400854c5
+	_defaultConstructor (func ptr): 0xb7dff248
+	_construct (func ptr): 0xb7e00783
+	_build (func ptr): 0xb7e00741
+	_initialise (func ptr): 0xb7ea9de2
+	_execute (func ptr): 0xb7ea9ea6
+	_destroy (func ptr): 0xb7ea9ed6
 	isConstructed: True
 	isBuilt: True
 	isInitialised: False
 	hasExecuted: False
 	isDestroyed: False
-	_getSet (func ptr): 0x40154aa0
-	_getVariableCount (func ptr): 0x40154e36
-	_getVariableIndex (func ptr): 0x40154e4d
-	_getValueIndex (func ptr): 0x40154f1f
-	_getValueCount (func ptr): 0x40154f27
-	_getValue (func ptr): 0x40154f3e
-	variable_Register (ptr): 0x80686f8
+	constructor function name: WallVC-Construct
+	build function name: WallVC-Build
+	initialise function name: WallVC-Initialise
+	execute function name: WallVC-Execute
+	destroy function name: WallVC-Destroy
+	_getSet (func ptr): 0xb7e007d2
+	_getVariableCount (func ptr): 0xb7e00b68
+	_getVariableIndex (func ptr): 0xb7e00b7f
+	_getValueIndex (func ptr): 0xb7e00c5a
+	_getValueCount (func ptr): 0xb7e00c62
+	_getValue (func ptr): 0xb7e00c79
+	variable_Register (ptr): 0x8061c80
 	conFunc_Register (ptr): (nil)
-	_set (ptr): 0x806b6b0
+	_set (ptr): 0x806c998
 	indexCount: 7
-	indexTbl (ptr): 0x806b6f0
+	indexTbl (ptr): 0x806c9d8
 		indexTbl[0]: 0
 		indexTbl[1]: 7
 		indexTbl[2]: 14
@@ -57,7 +62,7 @@
 		indexTbl[4]: 28
 		indexTbl[5]: 35
 		indexTbl[6]: 42
-	vcVarCountTbl (ptr): 0x806b718
+	vcVarCountTbl (ptr): 0x806ca00
 		vcVarCountTbl[0]: 1
 		vcVarCountTbl[1]: 1
 		vcVarCountTbl[2]: 1
@@ -65,7 +70,7 @@
 		vcVarCountTbl[4]: 1
 		vcVarCountTbl[5]: 1
 		vcVarCountTbl[6]: 1
-	vcTbl (ptr): 0x806b740
+	vcTbl (ptr): 0x806ca28
 		vcTbl[0][0]:
 			varIndex: 1
 			valIndex: 0
@@ -88,7 +93,7 @@
 			varIndex: 1
 			valIndex: 0
 	valueCount: 1
-	valueTbl (ptr): 0x806b7a0
+	valueTbl (ptr): 0x806ca88
 		valueTbl[0]:
 			type: VC_ValueType_Double
 			asDouble: -1

Modified: long/3D/Gale/trunk/src/StgFEM/Discretisation/tests/expected/testFeVariable.0of2.expected
===================================================================
--- long/3D/Gale/trunk/src/StgFEM/Discretisation/tests/expected/testFeVariable.0of2.expected	2006-06-28 09:59:25 UTC (rev 3898)
+++ long/3D/Gale/trunk/src/StgFEM/Discretisation/tests/expected/testFeVariable.0of2.expected	2006-06-28 10:01:38 UTC (rev 3899)
@@ -1,55 +1,60 @@
-StGermain Framework revision 0. Copyright (C) 2003-2005 VPAC.
-StGermain Discretisation Library revision 0. Copyright (C) 2003-2005 VPAC.
-StGermain FEM Discretisation Framework revision 0. Copyright (C) 2003-2005 VPAC.
+StGermain Framework revision 3605. Copyright (C) 2003-2005 VPAC.
+StGermain Discretisation Library revision 3605. Copyright (C) 2003-2005 VPAC.
+StGermain FEM Discretisation Framework revision 566. Copyright (C) 2003-2005 VPAC.
 Watching rank: 0
-WallVC (ptr): 0x806af80
-	dictionary (ptr): 0x8060800
-	_dictionaryEntryName (ptr): 0x804b041
+WallVC (ptr): 0x806b970
+	dictionary (ptr): 0x8060708
+	_dictionaryEntryName (ptr): 0x804b039
 		_dictionaryEntryName: boundaryCondition
 	_wall: Left
 	_entryCount: 1
-	_entryTbl (ptr): 0x806bab0
+	_entryTbl (ptr): 0x806cb80
 		_entryTbl[0]:
-			varName (ptr): 0x8060680
+			varName (ptr): 0x8060588
 				varName: vx
 			value:
 				type: VC_ValueType_Double
 				asDouble: -1
-	_mesh (ptr): 0x8067e00
-VariableCondition (ptr): 0x806af80
-Stg_Component (ptr): 0x806af80
-Stg_Object (ptr): 0x806af80
-	Stg_Class (ptr): 0x806af80
-		sizeOfSelf: 172
+	_mesh (ptr): 0x8069288
+VariableCondition (ptr): 0x806b970
+Stg_Component (ptr): 0x806b970
+Stg_Object (ptr): 0x806b970
+	Stg_Class (ptr): 0x806b970
+		sizeOfSelf: 192
 		_deleteSelf: Yes
 		type: WallVC
-		_delete (func ptr): 0x40154246
-		_print (func ptr): 0x4015428c
-		_copy (func ptr): 0x4015483c
+		_delete (func ptr): 0xb7e26f77
+		_print (func ptr): 0xb7e26fbd
+		_copy (func ptr): 0xb7e2756e
 	name: WallVC
 	nameAllocationType: NON_GLOBAL
-	_defaultConstructor (func ptr): 0x401534f0
-	_construct (func ptr): 0x40154a51
-	_build (func ptr): 0x40154a0f
-	_initialise (func ptr): 0x400853d1
-	_execute (func ptr): 0x40085495
-	_destroy (func ptr): 0x400854c5
+	_defaultConstructor (func ptr): 0xb7e26248
+	_construct (func ptr): 0xb7e27783
+	_build (func ptr): 0xb7e27741
+	_initialise (func ptr): 0xb7ed0de2
+	_execute (func ptr): 0xb7ed0ea6
+	_destroy (func ptr): 0xb7ed0ed6
 	isConstructed: True
 	isBuilt: True
 	isInitialised: False
 	hasExecuted: False
 	isDestroyed: False
-	_getSet (func ptr): 0x40154aa0
-	_getVariableCount (func ptr): 0x40154e36
-	_getVariableIndex (func ptr): 0x40154e4d
-	_getValueIndex (func ptr): 0x40154f1f
-	_getValueCount (func ptr): 0x40154f27
-	_getValue (func ptr): 0x40154f3e
-	variable_Register (ptr): 0x8069e90
+	constructor function name: WallVC-Construct
+	build function name: WallVC-Build
+	initialise function name: WallVC-Initialise
+	execute function name: WallVC-Execute
+	destroy function name: WallVC-Destroy
+	_getSet (func ptr): 0xb7e277d2
+	_getVariableCount (func ptr): 0xb7e27b68
+	_getVariableIndex (func ptr): 0xb7e27b7f
+	_getValueIndex (func ptr): 0xb7e27c5a
+	_getValueCount (func ptr): 0xb7e27c62
+	_getValue (func ptr): 0xb7e27c79
+	variable_Register (ptr): 0x80630a0
 	conFunc_Register (ptr): (nil)
-	_set (ptr): 0x806bc80
+	_set (ptr): 0x806cd50
 	indexCount: 7
-	indexTbl (ptr): 0x806bcc0
+	indexTbl (ptr): 0x806cd90
 		indexTbl[0]: 0
 		indexTbl[1]: 4
 		indexTbl[2]: 8
@@ -57,7 +62,7 @@
 		indexTbl[4]: 16
 		indexTbl[5]: 20
 		indexTbl[6]: 24
-	vcVarCountTbl (ptr): 0x806bce8
+	vcVarCountTbl (ptr): 0x806cdb8
 		vcVarCountTbl[0]: 1
 		vcVarCountTbl[1]: 1
 		vcVarCountTbl[2]: 1
@@ -65,7 +70,7 @@
 		vcVarCountTbl[4]: 1
 		vcVarCountTbl[5]: 1
 		vcVarCountTbl[6]: 1
-	vcTbl (ptr): 0x806bd10
+	vcTbl (ptr): 0x806cde0
 		vcTbl[0][0]:
 			varIndex: 1
 			valIndex: 0
@@ -88,7 +93,7 @@
 			varIndex: 1
 			valIndex: 0
 	valueCount: 1
-	valueTbl (ptr): 0x806bd70
+	valueTbl (ptr): 0x806ce40
 		valueTbl[0]:
 			type: VC_ValueType_Double
 			asDouble: -1

Modified: long/3D/Gale/trunk/src/StgFEM/Discretisation/tests/expected/testFeVariable.1of2.expected
===================================================================
--- long/3D/Gale/trunk/src/StgFEM/Discretisation/tests/expected/testFeVariable.1of2.expected	2006-06-28 09:59:25 UTC (rev 3898)
+++ long/3D/Gale/trunk/src/StgFEM/Discretisation/tests/expected/testFeVariable.1of2.expected	2006-06-28 10:01:38 UTC (rev 3899)
@@ -1,59 +1,64 @@
-StGermain Framework revision 0. Copyright (C) 2003-2005 VPAC.
-StGermain Discretisation Library revision 0. Copyright (C) 2003-2005 VPAC.
-StGermain FEM Discretisation Framework revision 0. Copyright (C) 2003-2005 VPAC.
+StGermain Framework revision 3605. Copyright (C) 2003-2005 VPAC.
+StGermain Discretisation Library revision 3605. Copyright (C) 2003-2005 VPAC.
+StGermain FEM Discretisation Framework revision 566. Copyright (C) 2003-2005 VPAC.
 Watching rank: 1
-WallVC (ptr): 0x80679c8
-	dictionary (ptr): 0x805fa68
-	_dictionaryEntryName (ptr): 0x804b041
+WallVC (ptr): 0x806b570
+	dictionary (ptr): 0x80606e8
+	_dictionaryEntryName (ptr): 0x804b039
 		_dictionaryEntryName: boundaryCondition
 	_wall: Left
 	_entryCount: 1
-	_entryTbl (ptr): 0x80684f8
+	_entryTbl (ptr): 0x806c780
 		_entryTbl[0]:
-			varName (ptr): 0x805f8e8
+			varName (ptr): 0x8060568
 				varName: vx
 			value:
 				type: VC_ValueType_Double
 				asDouble: -1
-	_mesh (ptr): 0x8064848
-VariableCondition (ptr): 0x80679c8
-Stg_Component (ptr): 0x80679c8
-Stg_Object (ptr): 0x80679c8
-	Stg_Class (ptr): 0x80679c8
-		sizeOfSelf: 172
+	_mesh (ptr): 0x8067840
+VariableCondition (ptr): 0x806b570
+Stg_Component (ptr): 0x806b570
+Stg_Object (ptr): 0x806b570
+	Stg_Class (ptr): 0x806b570
+		sizeOfSelf: 192
 		_deleteSelf: Yes
 		type: WallVC
-		_delete (func ptr): 0x40154246
-		_print (func ptr): 0x4015428c
-		_copy (func ptr): 0x4015483c
+		_delete (func ptr): 0xb7e03f77
+		_print (func ptr): 0xb7e03fbd
+		_copy (func ptr): 0xb7e0456e
 	name: WallVC
 	nameAllocationType: NON_GLOBAL
-	_defaultConstructor (func ptr): 0x401534f0
-	_construct (func ptr): 0x40154a51
-	_build (func ptr): 0x40154a0f
-	_initialise (func ptr): 0x400853d1
-	_execute (func ptr): 0x40085495
-	_destroy (func ptr): 0x400854c5
+	_defaultConstructor (func ptr): 0xb7e03248
+	_construct (func ptr): 0xb7e04783
+	_build (func ptr): 0xb7e04741
+	_initialise (func ptr): 0xb7eadde2
+	_execute (func ptr): 0xb7eadea6
+	_destroy (func ptr): 0xb7eaded6
 	isConstructed: True
 	isBuilt: True
 	isInitialised: False
 	hasExecuted: False
 	isDestroyed: False
-	_getSet (func ptr): 0x40154aa0
-	_getVariableCount (func ptr): 0x40154e36
-	_getVariableIndex (func ptr): 0x40154e4d
-	_getValueIndex (func ptr): 0x40154f1f
-	_getValueCount (func ptr): 0x40154f27
-	_getValue (func ptr): 0x40154f3e
-	variable_Register (ptr): 0x80668d8
+	constructor function name: WallVC-Construct
+	build function name: WallVC-Build
+	initialise function name: WallVC-Initialise
+	execute function name: WallVC-Execute
+	destroy function name: WallVC-Destroy
+	_getSet (func ptr): 0xb7e047d2
+	_getVariableCount (func ptr): 0xb7e04b68
+	_getVariableIndex (func ptr): 0xb7e04b7f
+	_getValueIndex (func ptr): 0xb7e04c5a
+	_getValueCount (func ptr): 0xb7e04c62
+	_getValue (func ptr): 0xb7e04c79
+	variable_Register (ptr): 0x8069538
 	conFunc_Register (ptr): (nil)
-	_set (ptr): 0x80686c8
+	_set (ptr): 0x806c950
 	indexCount: 0
 	indexTbl (ptr): (nil)
 	vcVarCountTbl (ptr): (nil)
 	vcTbl (ptr): (nil)
 	valueCount: 1
-	valueTbl (ptr): 0x8068708
+	valueTbl (ptr): 0x806c990
 		valueTbl[0]:
 			type: VC_ValueType_Double
 			asDouble: -1

Modified: long/3D/Gale/trunk/src/StgFEM/Discretisation/tests/testFeEquationNumber-LinkedDofs.c
===================================================================
--- long/3D/Gale/trunk/src/StgFEM/Discretisation/tests/testFeEquationNumber-LinkedDofs.c	2006-06-28 09:59:25 UTC (rev 3898)
+++ long/3D/Gale/trunk/src/StgFEM/Discretisation/tests/testFeEquationNumber-LinkedDofs.c	2006-06-28 10:01:38 UTC (rev 3899)
@@ -118,10 +118,10 @@
 		NULL,
 		NULL,
 		NULL,
-		_DiscretisationContext_Build,
-		_DiscretisationContext_Initialise,
-		_DiscretisationContext_Execute,
-		_DiscretisationContext_Destroy,
+		_AbstractContext_Build,
+		_AbstractContext_Initialise,
+		_AbstractContext_Execute,
+		_AbstractContext_Destroy,
 		"context",
 		True,
 		_SetDt,
@@ -310,4 +310,4 @@
 	Stg_Class_Delete( nLayout );
 	Stg_Class_Delete( eLayout );
 	Stg_Class_Delete( nTopology );
-}	
+}

Modified: long/3D/Gale/trunk/src/StgFEM/SLE/ProvidedSystems/AdvectionDiffusion/src/AdvectionDiffusionSLE.c
===================================================================
--- long/3D/Gale/trunk/src/StgFEM/SLE/ProvidedSystems/AdvectionDiffusion/src/AdvectionDiffusionSLE.c	2006-06-28 09:59:25 UTC (rev 3898)
+++ long/3D/Gale/trunk/src/StgFEM/SLE/ProvidedSystems/AdvectionDiffusion/src/AdvectionDiffusionSLE.c	2006-06-28 10:01:38 UTC (rev 3899)
@@ -215,7 +215,7 @@
 	}
 
 	if ( self->context ) 
-		EP_AppendClassHook( self->context->setDtEP, AdvectionDiffusionSLE_CalculateDt, self );
+		EP_AppendClassHook( self->context->calcDtEP, AdvectionDiffusionSLE_CalculateDt, self );
 }	
 
 void AdvectionDiffusionSLE_InitAll(

Modified: long/3D/Gale/trunk/src/StgFEM/SLE/ProvidedSystems/AdvectionDiffusion/src/LumpedMassMatrixForceTerm.h
===================================================================
--- long/3D/Gale/trunk/src/StgFEM/SLE/ProvidedSystems/AdvectionDiffusion/src/LumpedMassMatrixForceTerm.h	2006-06-28 09:59:25 UTC (rev 3898)
+++ long/3D/Gale/trunk/src/StgFEM/SLE/ProvidedSystems/AdvectionDiffusion/src/LumpedMassMatrixForceTerm.h	2006-06-28 10:01:38 UTC (rev 3899)
@@ -72,7 +72,7 @@
 		Stg_Component_InitialiseFunction*                   _initialise,
 		Stg_Component_ExecuteFunction*                      _execute,
 		Stg_Component_DestroyFunction*                      _destroy,
-		ForceTerm_AssembleElementFunction*                   _assembleElement,
+		ForceTerm_AssembleElementFunction*                  _assembleElement,
 		Name                                                name );
 	
 	void LumpedMassMatrixForceTerm_InitAll( 

Modified: long/3D/Gale/trunk/src/StgFEM/SLE/ProvidedSystems/StokesFlow/src/Stokes_SLE.c
===================================================================
--- long/3D/Gale/trunk/src/StgFEM/SLE/ProvidedSystems/StokesFlow/src/Stokes_SLE.c	2006-06-28 09:59:25 UTC (rev 3898)
+++ long/3D/Gale/trunk/src/StgFEM/SLE/ProvidedSystems/StokesFlow/src/Stokes_SLE.c	2006-06-28 10:01:38 UTC (rev 3899)
@@ -186,7 +186,7 @@
 
 	/* Put timestep function onto entry point */
 	if ( self->context )
-		EP_AppendClassHook( self->context->setDtEP, Stokes_SLE_UpdateDt, self );
+		EP_AppendClassHook( self->context->calcDtEP, Stokes_SLE_UpdateDt, self );
 }
 
 void Stokes_SLE_InitAll( 

Modified: long/3D/Gale/trunk/src/StgFEM/SLE/ProvidedSystems/StokesFlow/src/Stokes_SLE_UzawaSolver.c
===================================================================
--- long/3D/Gale/trunk/src/StgFEM/SLE/ProvidedSystems/StokesFlow/src/Stokes_SLE_UzawaSolver.c	2006-06-28 09:59:25 UTC (rev 3898)
+++ long/3D/Gale/trunk/src/StgFEM/SLE/ProvidedSystems/StokesFlow/src/Stokes_SLE_UzawaSolver.c	2006-06-28 10:01:38 UTC (rev 3899)
@@ -396,10 +396,22 @@
 	*/ 
 
 	
-	Journal_Firewall( 
-			Vector_L2_Norm( fVec ) / sqrt((double) Vector_GlobalSize( fVec )) > 1e-99, errorStream,
-			"Error in func %s: The force vector is zero - Please check values for building the force vector.\n",
-			__func__ );
+	if ( Vector_L2_Norm( fVec ) / sqrt((double) Vector_GlobalSize( fVec )) <= 1e-99 ) {
+		Journal_Printf( errorStream,
+			"Error in func %s: The momentum force vector \"%s\" is zero. "
+			"The force vector should be non-zero either because of your chosen boundary "
+			"conditions, or because of the element force vector assembly. You have %d "
+			"element force vectors attached.\n",
+			__func__, sle->fForceVec->name, sle->fForceVec->assembleForceVector->hooks->count );
+		if ( sle->fForceVec->assembleForceVector->hooks->count > 0 ) {
+			Journal_Printf( errorStream, "You used the following force vector assembly terms:\n" );
+			EntryPoint_PrintConcise( sle->fForceVec->assembleForceVector, errorStream );
+			// TODO : need to print the elementForceVector assembly, not the global guy!!
+		}	
+		Journal_Printf( errorStream,
+			"Please check values for building the force vector.\n" );
+		Journal_Firewall( 0, errorStream, "Exiting.\n" ); 	
+	}
 	
 					
  	Journal_DPrintf( self->debug, "In %s:\n", __func__ );

Modified: long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/src/Context.c
===================================================================
--- long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/src/Context.c	2006-06-28 09:59:25 UTC (rev 3898)
+++ long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/src/Context.c	2006-06-28 10:01:38 UTC (rev 3899)
@@ -58,7 +58,7 @@
 /* Textual name of this class */
 const Type FiniteElementContext_Type = "FiniteElementContext";
 const Name defaultFiniteElementContextETypeRegisterName = "defaultFiniteElementContextETypeRegisterName";
-const Name FiniteElementContext_EP_SetDt = "FiniteElementContext_EP_SetDt";
+const Name FiniteElementContext_EP_CalcDt = "FiniteElementContext_EP_CalcDt";
 
 
 /* Constructors ------------------------------------------------------------------------------------------------------------------*/
@@ -73,10 +73,10 @@
 		NULL,
 		FiniteElementContext_DefaultNew,
 		_FiniteElementContext_ComponentConstruct,
-		_FiniteElementContext_ComponentBuild,
-		_FiniteElementContext_ComponentInitialise,
-		_FiniteElementContext_ComponentExecute,
-		_FiniteElementContext_ComponentDestroy,
+		_AbstractContext_Build,
+		_AbstractContext_Initialise,
+		_AbstractContext_Execute,
+		_AbstractContext_Destroy,
 		name,
 		False,
 		_FiniteElementContext_SetDt,
@@ -101,10 +101,10 @@
 		NULL,
 		FiniteElementContext_DefaultNew,
 		_FiniteElementContext_ComponentConstruct,
-		_FiniteElementContext_ComponentBuild,
-		_FiniteElementContext_ComponentInitialise,
-		_FiniteElementContext_ComponentExecute,
-		_FiniteElementContext_ComponentDestroy,
+		_AbstractContext_Build,
+		_AbstractContext_Initialise,
+		_AbstractContext_Execute,
+		_AbstractContext_Destroy,
 		name,
 		True,
 		_FiniteElementContext_SetDt,
@@ -171,6 +171,7 @@
 
 
 void _FiniteElementContext_Init( FiniteElementContext* self ) {
+	Stream*  errorStream = Journal_Register( Error_Type, self->type );
 
 	/* Set up stream preferences */
 	Journal_Enable_NamedStream( InfoStream_Type, "StG_FEM_VerboseConfig", False );
@@ -184,6 +185,12 @@
 	self->debug = Stream_RegisterChild( StG_FEM_Debug, FiniteElementContext_Type );
 	
 	self->dt = 0.0f;
+	self->prevTimestepDt = 0.0;
+	self->limitTimeStepIncreaseRate = Dictionary_GetBool_WithDefault( self->dictionary, "limitTimeStepIncreaseRate", False );
+	self->maxTimeStepIncreasePercentage = Dictionary_GetDouble_WithDefault( self->dictionary,
+		"maxTimeStepIncreasePercentage", 10.0 );
+	Journal_Firewall( self->maxTimeStepIncreasePercentage >= 0, errorStream,
+		"Error - in %s(): maxTimeStepIncreasePercentage must be >= 0\n", __func__ );
 	
 	/* set up s.l.e list */
 	self->slEquations = Stg_ObjectList_New();
@@ -197,8 +204,8 @@
 	Stg_ObjectList_ClassAppend( self->register_Register, (void*)self->elementType_Register, "ElementType_Register" );
 
 	/* Create Entry Point for Calculating timestep */
-	self->setDtEP = EntryPoint_New( FiniteElementContext_EP_SetDt, EntryPoint_Minimum_VoidPtr_CastType );
-	EntryPoint_Register_Add( self->entryPoint_Register, self->setDtEP );
+	self->calcDtEP = EntryPoint_New( FiniteElementContext_EP_CalcDt, EntryPoint_Minimum_VoidPtr_CastType );
+	EntryPoint_Register_Add( self->entryPoint_Register, self->calcDtEP );
 	
 	/* Add hooks to existing entry points... use name "default" so that plugin, etc can exert same behaviour on other contexts*/
 	EntryPoint_Prepend( 
@@ -232,6 +239,14 @@
 		"saveFeVariables",
 		_FiniteElementContext_SaveFeVariables,
 		FiniteElementContext_Type );
+	/* The FEM context needs to save gauss swarms so they can be re-loaded for restart later.
+	   This will automatically save material point swarms too if PICellerator is used.
+	 */
+	EntryPoint_Append(
+		Context_GetEntryPoint( self, AbstractContext_EP_Save ),
+		"saveSwarms",
+		_FiniteElementContext_SaveSwarms,
+		FiniteElementContext_Type );
 
 }
 
@@ -365,7 +380,7 @@
 	Journal_DPrintf( self->debug, "In: %s()\n", __func__ );
 	Stream_IndentBranch( StG_FEM_Debug );
 
-	FiniteElementContext_SetDt( self ) ;
+	FiniteElementContext_CalcNewDt( self ) ;
 
 	Stream_UnIndentBranch( StG_FEM_Debug );
 }
@@ -376,14 +391,41 @@
 	return self->dt;
 }
 
-double FiniteElementContext_SetDt( void* context ) {
+double FiniteElementContext_CalcNewDt( void* context ) {
 	FiniteElementContext* self = (FiniteElementContext*)context;
 
-	if ( self->setDtEP->hooks->count == 0 )
+	self->prevTimestepDt = self->dt;
+	
+	if ( self->calcDtEP->hooks->count == 0 ) {
 		self->dt = 0.0;
-	else
-		self->dt = _EntryPoint_Run_Class_Minimum_VoidPtr( self->setDtEP, self );
+	}
+	else {
+		self->dt = _EntryPoint_Run_Class_Minimum_VoidPtr( self->calcDtEP, self );
+	}	
+		
+	if ( ( self->timeStep > 1 ) && ( self->limitTimeStepIncreaseRate == True ) ) {
+		double  maxAllowedDt = self->prevTimestepDt * ( 1 + self->maxTimeStepIncreasePercentage / 100 );
 
+		if ( self->dt > maxAllowedDt ) {
+			int prevContextPrintingRank = Stream_GetPrintingRank( self->info );
+			/* We assume the dt calculation will be the same across all procs since its a global
+			  operation, so only print this once */
+			Stream_SetPrintingRank( self->info, 0 );
+			Journal_Printf( 
+				self->info, 
+				"In %s(): dt calculated was %g (time), but prev timestep's dt\n"
+				"was %g (time) and max allowed increase percentage is %.2f\%, thus limiting current\n"
+				"dt to %g (time).\n", 
+				__func__, 
+				self->dt, 
+				self->prevTimestepDt,
+				self->maxTimeStepIncreasePercentage, 
+				maxAllowedDt );
+			self->dt = maxAllowedDt;
+			Stream_SetPrintingRank( self->info, prevContextPrintingRank );
+		}
+	}
+	
 	return self->dt;
 }
 
@@ -405,24 +447,8 @@
 	self->CF = cf;
 	self->CF->registerRegister = self->register_Register;
 }
-	
-void	_FiniteElementContext_ComponentBuild( void* context, void* data ){
-	
-}
-	
-void	_FiniteElementContext_ComponentInitialise( void* context, void* data ){
-	
-}
-	
-void	_FiniteElementContext_ComponentExecute( void* context, void* data ){
-	
-}
 
-void	_FiniteElementContext_ComponentDestroy( void* context, void* data ){
-	
-}
 
-
 void _FiniteElementContext_SaveFeVariables( void* context ) {
 	FiniteElementContext*     self = (FiniteElementContext*) context;
 	Index                     var_I = 0;
@@ -485,4 +511,11 @@
 	}
 
 	Memory_Free( outputPathString );
-}	
+}
+
+void _FiniteElementContext_SaveSwarms( void* context ) {
+	
+	Swarm_Register_SaveAllRegisteredSwarms( 
+		Swarm_Register_GetSwarm_Register(), context );
+}
+

Modified: long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/src/Context.h
===================================================================
--- long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/src/Context.h	2006-06-28 09:59:25 UTC (rev 3898)
+++ long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/src/Context.h	2006-06-28 10:01:38 UTC (rev 3899)
@@ -57,7 +57,7 @@
 	/* Textual name of this class */
 	extern const Type FiniteElementContext_Type;
 
-	extern const Name FiniteElementContext_EP_SetDt;
+	extern const Name FiniteElementContext_EP_CalcDt;
 	
 	#define __FiniteElementContext \
 		/* General info */ \
@@ -69,7 +69,10 @@
 		SystemLinearEquationList*           slEquations;             \
 		ElementType_Register*               elementType_Register;    \
 		double                              dt;                      \
-		EntryPoint*                         setDtEP;                 \
+		double                              prevTimestepDt;          \
+		Bool                                limitTimeStepIncreaseRate; \
+		double                              maxTimeStepIncreasePercentage; \
+		EntryPoint*                         calcDtEP;                 \
 		
 	struct FiniteElementContext { __FiniteElementContext };
 	
@@ -108,35 +111,53 @@
 		Dictionary*					dictionary );
 	
 	/** Initialisation implementation */
-	void 						_FiniteElementContext_Init( FiniteElementContext* self );
+	void  _FiniteElementContext_Init( FiniteElementContext* self );
 
 	/* Virtual Functions -----------------------------------------------------------------------------------------------------*/
 	
 	/* Stg_Class_Delete implementation */
-	void						_FiniteElementContext_Delete( void* context );
+	void _FiniteElementContext_Delete( void* context );
 	
 	/* Print implementation */
-	void						_FiniteElementContext_Print( void* context, Stream* stream );
+	void _FiniteElementContext_Print( void* context, Stream* stream );
 
-	void						_FiniteElementContext_ComponentConstruct( void* context, Stg_ComponentFactory* cf );
+	void _FiniteElementContext_ComponentConstruct( void* context, Stg_ComponentFactory* cf );
 	
-	void						_FiniteElementContext_ComponentBuild( void* context, void* data );
+	/* Set the dt */
+	void _FiniteElementContext_CalcNewDt( void* context, double dt );
+
+	/* Build EntryPoint hook */
+	void _FiniteElementContext_Build( void* context );
 	
-	void						_FiniteElementContext_ComponentInitialise( void* context, void* data );
+	/* Initialise EntryPoint hook */
+	void _FiniteElementContext_Initialise( void* context );
 	
-	void						_FiniteElementContext_ComponentExecute( void* context, void* data );
+	/* Solve EntryPoint hook */
+	void _FiniteElementContext_Solve( void* context );
 
-	void						_FiniteElementContext_ComponentDestroy( void* context, void* data );
+	/* Step EntryPoint hook */
+	void _FiniteElementContext_Step( void* context ) ;
 	
-	/* Set the dt */
-	void						_FiniteElementContext_SetDt( void* context, double dt );
+	/* Dt related functions */
+	/** Function to assign the dt mediated by the abstract context to use for time integration
+		in the current step - usually just the last timestep's dt */
+	void _FiniteElementContext_SetDt( void* context, double dt );
+	/** Function to pass the last-calculated dt back to the context. If loading from checkpoint,
+		will load the dt from timeInfo file */
+	double _FiniteElementContext_GetDt( void* context );
 
+	/** Function to calculate the new dt based on the solution just obtained, which
+	  * will be used next timestep. Calls as entry point of a corresponding name,
+	  * which each SLE can add a hook to based on its own criterion */
+	double FiniteElementContext_CalcNewDt( void* context ) ;
+
 	/* Public functions ------------------------------------------------------------------------------------------------------*/
 	
-	/* AddVariable function */
-	void						FiniteElementContext_AddSLE_Func( void* context, void* sle );
-	#define						FiniteElementContext_AddSLE_Macro( self, sle ) \
-								Stg_ObjectList_Append( (self)->slEquations, sle )
+	void FiniteElementContext_AddSLE_Func( void* context, void* sle );
+
+	#define FiniteElementContext_AddSLE_Macro( self, sle ) \
+		Stg_ObjectList_Append( (self)->slEquations, sle )
+
 	#ifdef MACRO_AS_FUNC
 		#define FiniteElementContext_AddSLE FiniteElementContext_AddSLE_Func
 	#else
@@ -144,10 +165,9 @@
 	#endif
 	#define AddSLE FiniteElementContext_AddSLE
 	
-	/* Get Variable function - can be slow, should use index keys and get directly */
-	SystemLinearEquations*				FiniteElementContext_GetSLE_Func( void* context, Name sleName );
-	#define						FiniteElementContext_GetSLE_Macro( self, sleName ) \
-								((SystemLinearEquations*)Stg_ObjectList_Get( (self)->slEquations, sleName ))
+	SystemLinearEquations* FiniteElementContext_GetSLE_Func( void* context, Name sleName );
+	#define FiniteElementContext_GetSLE_Macro( self, sleName ) \
+		((SystemLinearEquations*)Stg_ObjectList_Get( (self)->slEquations, sleName ))
 	#ifdef MACRO_AS_FUNC
 		#define FiniteElementContext_GetSLE FiniteElementContext_GetSLE_Func
 	#else
@@ -155,25 +175,13 @@
 	#endif
 	#define GetSLE FiniteElementContext_GetSLE
 
-	/* EntryPoint Hooks ------------------------------------------------------------------------------------------------------*/
-	
-	/* Build EntryPoint hook */
-	void						_FiniteElementContext_Build( void* context );
-	
-	/* Initialise EntryPoint hook */
-	void						_FiniteElementContext_Initialise( void* context );
-	
-	/* Solve EntryPoint hook */
-	void						_FiniteElementContext_Solve( void* context );
+	/* Private functions -----------------------------------------------------------------------------------------------------*/
 
-	/* Step EntryPoint hook */
-	void 						_FiniteElementContext_Step( void* context ) ;
-	
-	/* Obtain the Dt EntryPoint hook */
-	double						_FiniteElementContext_GetDt( void* context );
-	double 						FiniteElementContext_SetDt( void* context ) ;
-
-	/* Saves all FeVariables known about by the context to file */
+	/** Saves all FeVariables known about by the context to file */
 	void _FiniteElementContext_SaveFeVariables( void* context );
 
+	/** Saves all Swarms known about by the context to file (necessary to put this here since 
+	gauss integration swarms may need to be saved and reloaded) */
+	void _FiniteElementContext_SaveSwarms( void* context );
+
 #endif /* __StG_FEM_SLE_SystemSetup_Context_h__ */

Modified: long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/src/SolutionVector.c
===================================================================
--- long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/src/SolutionVector.c	2006-06-28 09:59:25 UTC (rev 3898)
+++ long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/src/SolutionVector.c	2006-06-28 10:01:38 UTC (rev 3899)
@@ -476,7 +476,9 @@
 	double**		reqValuesFromOthers;
 	MPI_Request**		reqValuesFromOthersHandles;
 	Bool*			reqValuesFromOthersReceived;
-	Partition_Index		reqValueSetsFromOthersNotYetReceivedCount;
+	Partition_Index	     reqValueSetsFromOthersNotYetReceivedCount;
+	Dof_EquationNumber   totalRequestedFromOthers = 0;
+	Dof_EquationNumber   totalRequestedFromMe = 0;
 
 	Journal_DPrintf( self->debug, "In %s - for \"%s\"\n", __func__, self->name );
 	Stream_IndentBranch( StG_FEM_Debug );
@@ -509,57 +511,115 @@
 	MPI_Alltoall( reqFromOthersCounts, 1, MPI_UNSIGNED,
 		reqFromMeCounts, 1, MPI_UNSIGNED, meshDecomp->communicator );
 
-	/* start non-blocking sends of my requests to others */
+	Journal_DPrintf( self->debug, "After MPI_Alltoall- counts are:\n" );
+	totalRequestedFromOthers = 0;
+	totalRequestedFromMe = 0;
+	Stream_Indent( self->debug );
+	Journal_DPrintf( self->debug, "reqFromOthersCounts: " );
+	for ( proc_I=0; proc_I < nProc; proc_I++ ) {
+		if ( proc_I == myRank ) continue;
+		Journal_DPrintf( self->debug, "\tp%d:%d, ", proc_I, reqFromOthersCounts[proc_I] );
+		totalRequestedFromOthers += reqFromOthersCounts[proc_I];
+	}
+	Journal_DPrintf( self->debug, "\n" );
+	Journal_DPrintf( self->debug, "reqFromMeCounts: " );
+	for ( proc_I=0; proc_I < nProc; proc_I++ ) {
+		if ( proc_I == myRank ) continue;
+		Journal_DPrintf( self->debug, "\tp%d:%d, ", proc_I, reqFromMeCounts[proc_I] );
+		totalRequestedFromMe += reqFromMeCounts[proc_I];
+	}
+	Journal_DPrintf( self->debug, "\n" );
+	Stream_UnIndent( self->debug );
+
+	if ( ( totalRequestedFromOthers == 0) && (totalRequestedFromMe == 0) ) 
+	{	
+		Journal_DPrintf( self->debug, "No vector values either required from others or "
+			"required by others from me, therefore cleaning up memory and returning.\n" );
+		Memory_Free( reqFromMeCounts );
+		Memory_Free( reqFromOthersHandles );
+		Memory_Free( reqValuesFromOthersHandles );
+		Memory_Free( reqValuesFromMeHandles );
+		Memory_Free( reqValuesFromOthers ); 
+		Memory_Free( reqValuesFromOthersReceived );
+		Stream_UnIndentBranch( StG_FEM_Debug );
+		return;
+	}
+
+	Journal_DPrintfL( self->debug, 2, "Starting non-blocking sends of my lists of vector entry indices I want from others:\n" );
+	Stream_Indent( self->debug );
 	for( proc_I=0; proc_I < nProc; proc_I++) {
 		if ( proc_I == myRank ) continue; 
+//Journal_Printf( Journal_Register( Info_Type, "mpi" ),  "!!! line %d, proc_I %d: count = %u\n", __LINE__, proc_I, reqFromOthersCounts[proc_I] );
 		if ( reqFromOthersCounts[proc_I] > 0 ) {
+			Journal_DPrintfL( self->debug, 2, "Sending to proc %d the list of %d vector entry indices I want from it:\n"
+				"\t(tracking via reqFromOthersHandles[%d], tag %d)\n", proc_I,
+				reqFromOthersCounts[proc_I], proc_I, VALUE_REQUEST_TAG );
+
 			reqFromOthersHandles[proc_I] = Memory_Alloc_Unnamed( MPI_Request );
 			MPI_Isend( reqFromOthers[proc_I], reqFromOthersCounts[proc_I], MPI_UNSIGNED,
 				proc_I, VALUE_REQUEST_TAG, meshDecomp->communicator, reqFromOthersHandles[proc_I] );
 		}	
 	}
+	Stream_UnIndent( self->debug );
 
-	/* start non-blocking receive of the values I want */
+
+	Journal_DPrintfL( self->debug, 2, "Starting non-blocking receive of the vector entries I want from others:\n" );
+	Stream_Indent( self->debug );
 	for( proc_I=0; proc_I < nProc; proc_I++) {
 		if ( proc_I == myRank ) continue; 
 		if ( reqFromOthersCounts[proc_I] > 0 ) {
+			Journal_DPrintfL( self->debug, 2, "Posting recv reqst from proc %d for the %d vector entries I want from it:\n"
+				"\t(tracking via reqValuesFromOthersHandles[%d], tag %d)\n", proc_I,
+				reqFromOthersCounts[proc_I], proc_I, VALUE_TAG );
 			reqValuesFromOthersHandles[proc_I] = Memory_Alloc_Unnamed( MPI_Request );
 			MPI_Irecv( reqValuesFromOthers[proc_I], reqFromOthersCounts[proc_I], MPI_DOUBLE,
 				proc_I, VALUE_TAG, meshDecomp->communicator, reqValuesFromOthersHandles[proc_I] );
 		}	
 	}
+	Stream_UnIndent( self->debug );
 
-	/* blocking receive the lists of requested eqNums by others from me */
+	Journal_DPrintfL( self->debug, 2, "Starting blocking receive of the lists of vector entry indices "
+		"others want from me:\n" );
+	Stream_Indent( self->debug );
 	reqFromMe = Memory_Alloc_2DComplex( Dof_EquationNumber, nProc, reqFromMeCounts, "reqFromMe" );
 	reqValuesFromMe = Memory_Alloc_2DComplex( double, nProc, reqFromMeCounts, "reqValuesFromMe" );
 	for( proc_I=0; proc_I < nProc; proc_I++) {
 		if ( proc_I == myRank ) continue; 
+///Journal_Printf( Journal_Register( Info_Type, "mpi" ),  "!!! line %d, proc_I %d: count = %u\n", __LINE__, proc_I, reqFromMeCounts[proc_I] );
 		if ( reqFromMeCounts[proc_I] > 0 ) {
 			MPI_Recv( reqFromMe[proc_I], reqFromMeCounts[proc_I], MPI_UNSIGNED,
 				proc_I, VALUE_REQUEST_TAG, meshDecomp->communicator, &status );
+			Journal_DPrintfL( self->debug, 3, "Received a list of %u requested vector entry indices from proc %u, "
+				"with tag %d\n", reqFromMeCounts[proc_I], proc_I, status.MPI_TAG );
 		}	
 	}
+	Stream_UnIndent( self->debug );
 	
 	#if DEBUG
 	if ( Stream_IsPrintableLevel( self->debug, 2 ) ) {
-		Journal_DPrintf( self->debug, "Received list of eqNums from vec other procs want from me:\n" );
+		Journal_DPrintf( self->debug, "Final lists of vector entry indices other procs want from me are:\n" );
+		Stream_Indent( self->debug );
 		for ( proc_I=0; proc_I < nProc; proc_I++ ) {
 			if ( proc_I == myRank ) continue;
-			Journal_DPrintf( self->debug, "\t%d[0-%d]: ", proc_I, reqFromMeCounts[proc_I] );
-			for ( req_I=0; req_I < reqFromMeCounts[proc_I]; req_I++ ) {
-				Journal_DPrintf( self->debug, "(eqNum %d), ", reqFromMe[proc_I][req_I] );
+			if ( reqFromMeCounts[proc_I] > 0 ) {
+				Journal_DPrintf( self->debug, "%d[0-%d]: ", proc_I, reqFromMeCounts[proc_I] );
+				for ( req_I=0; req_I < reqFromMeCounts[proc_I]; req_I++ ) {
+					Journal_DPrintf( self->debug, "(eqNum %d), ", reqFromMe[proc_I][req_I] );
+				}
+				Journal_DPrintf( self->debug, "\n" );
 			}
-			Journal_DPrintf( self->debug, "\n" );
 		}
+		Stream_UnIndent( self->debug );
 	}	
 	#endif
 	
 	/* for all those requested from me, non-blocking send out values */
-	Journal_DPrintfL( self->debug, 2, "Sending out requested values:\n" );
+	Journal_DPrintfL( self->debug, 2, "Beginning non-blocking send out of vector entry lists requested by others:\n" );
+	Stream_Indent( self->debug );
 	for( proc_I=0; proc_I < nProc; proc_I++) {
 		if ( proc_I == myRank ) continue; 
 		if ( reqFromMeCounts[proc_I] > 0 ) {
-			Journal_DPrintfL( self->debug, 3, "\tto proc %d: ", proc_I );
+			Journal_DPrintfL( self->debug, 3, "list to proc %d is: ", proc_I );
 			for ( req_I=0; req_I < reqFromMeCounts[proc_I]; req_I++ ) {
 				/* look up and fill in correct value in array */
 				indexIntoLocalSolnVecValues = reqFromMe[proc_I][req_I] - eqNum->firstOwnedEqNum;
@@ -570,13 +630,19 @@
 			Journal_DPrintfL( self->debug, 3, "\n" );
 			/* Non-blocking send out the now-complete list to this processor */
 			reqValuesFromMeHandles[proc_I] = Memory_Alloc_Unnamed( MPI_Request );
+			Journal_DPrintfL( self->debug, 2, "Sending to proc %d the list of %d vector entries they want:\n"
+				"\t(tracking via reqValuesFromMe[%d], tag %d)\n", proc_I,
+				reqFromMeCounts[proc_I], proc_I, VALUE_TAG );
 			MPI_Isend( reqValuesFromMe[proc_I], reqFromMeCounts[proc_I], MPI_DOUBLE,
 				proc_I, VALUE_TAG, meshDecomp->communicator, reqValuesFromMeHandles[proc_I] );
 		}	
 	}
+	Stream_UnIndent( self->debug );
 	
-	Journal_DPrintfL( self->debug, 2, "Receiving the values I requested:\n" );
-	/* now update the values at nodes that I requested from others, as they come in */
+	Journal_DPrintfL( self->debug, 1, "Starting iterative-test receive of the vector entries I "
+		"requested from others:\n" );
+	/* Set up an array for keeping track of who we've received things from
+	 * already */
 	reqValueSetsFromOthersNotYetReceivedCount = nProc-1;
 	for( proc_I=0; proc_I < nProc; proc_I++) {
 		if ( proc_I == myRank ) continue; 
@@ -586,7 +652,20 @@
 		}	
 	}	
 
-	
+	#if DEBUG
+	Journal_DPrintfL( self->debug, 2, "(Expecting %d receives from procs: ",
+		reqValueSetsFromOthersNotYetReceivedCount );
+	for( proc_I=0; proc_I < nProc; proc_I++) {
+		if ( proc_I == myRank ) continue; 
+		if ( reqFromOthersCounts[proc_I] > 0 ) {
+			Journal_DPrintfL( self->debug, 2, "%d, ", proc_I );
+		}	
+	}	
+	Journal_DPrintfL( self->debug, 2, ")\n" );
+	#endif
+
+	Stream_Indent( self->debug );
+	/* now update the values at nodes that I requested from others, as they come in */
 	while ( reqValueSetsFromOthersNotYetReceivedCount ) {	
 		int flag = 0;
 
@@ -602,7 +681,9 @@
 				}
 				else {
 					RequestInfo* reqInfo;
-					Journal_DPrintfL( self->debug, 3, "received some values from proc %d:", proc_I );
+					Journal_DPrintfL( self->debug, 2, "received some requested "
+						"values (using reqValuesFromOthersHandles) from proc %d "
+						"(with tag %d, exp %d):", proc_I, status.MPI_TAG, VALUE_TAG );
 					/* go through each value received from that proc & update onto node */
 					for ( req_I=0; req_I < reqFromOthersCounts[proc_I]; req_I++ ) {
 						reqInfo = &reqFromOthersInfos[proc_I][req_I];
@@ -612,32 +693,53 @@
 						DofLayout_SetValueDouble( feVar->dofLayout, reqInfo->lNode_I, reqInfo->nodeLocalDof_I,
 							reqValuesFromOthers[proc_I][req_I] );
 					}
-					Journal_DPrintfL( self->debug, 3, "\n" );
+					Journal_DPrintfL( self->debug, 2, "\n" );
 					reqValuesFromOthersReceived[proc_I] = True;
 					reqValueSetsFromOthersNotYetReceivedCount--;
-				Memory_Free( reqValuesFromOthersHandles[proc_I] );
+					Memory_Free( reqValuesFromOthersHandles[proc_I] );
 				}	
 			}	
 		}
 	}	
+	Stream_UnIndent( self->debug );
 
 	/* MPI_Wait to be sure all sends to others have completed */
 	Journal_DPrintfL( self->debug, 2, "Making sure all comms of this function finished:...\n" );
+	Stream_Indent( self->debug );
+
+	Journal_DPrintfL( self->debug, 2, "Confirming completion of my sends of "
+		"vector entry index lists I wanted from others were received:\n" );
+	Stream_Indent( self->debug );
 	for( proc_I=0; proc_I < nProc; proc_I++) {
 		if ( proc_I == myRank ) continue; 
 		if ( reqFromOthersCounts[proc_I] > 0 ) {
-			if ( reqFromMeCounts[proc_I] > 0 ) {
-				MPI_Wait( reqValuesFromMeHandles[proc_I], &status );
-				Memory_Free( reqValuesFromMeHandles[proc_I] );
-			}
-			if ( reqFromOthersCounts[proc_I] > 0 ) {
-				MPI_Wait( reqFromOthersHandles[proc_I], &status ); 
-				Memory_Free( reqFromOthersHandles[proc_I] );
-			}	
+			MPI_Wait( reqFromOthersHandles[proc_I], MPI_STATUS_IGNORE ); 
+			Journal_DPrintfL( self->debug, 2, "Confirmed wait on reqFromOthersHandles[%u]"
+				"\n", proc_I );
+			Memory_Free( reqFromOthersHandles[proc_I] );
+		}	
+	}	
+	Stream_UnIndent( self->debug );
+	Journal_DPrintfL( self->debug, 2, "done.\n" );
+
+	Journal_DPrintfL( self->debug, 2, "Confirming completion of my sends of "
+		"vector entry values requested by others were received:\n" );
+	Stream_Indent( self->debug );
+	for( proc_I=0; proc_I < nProc; proc_I++) {
+		if ( proc_I == myRank ) continue; 
+		if ( reqFromMeCounts[proc_I] > 0 ) {
+			MPI_Wait( reqValuesFromMeHandles[proc_I], MPI_STATUS_IGNORE );
+			Journal_DPrintfL( self->debug, 2, "Confirmed wait on reqValuesFromMeHandles[%u]"
+				"\n", proc_I );
+			Memory_Free( reqValuesFromMeHandles[proc_I] );
 		}
 	}	
-	Journal_DPrintfL( self->debug, 2, "\tdone.\n" );
+	Stream_UnIndent( self->debug );
+	Journal_DPrintfL( self->debug, 2, "done.\n" );
 
+	Stream_UnIndent( self->debug );
+	Journal_DPrintfL( self->debug, 2, "done.\n" );
+
 	Memory_Free( reqFromMeCounts );
 	Memory_Free( reqFromMe );
 	Memory_Free( reqValuesFromMe );
@@ -648,6 +750,7 @@
 	Memory_Free( reqValuesFromMeHandles );
 
 	Stream_UnIndentBranch( StG_FEM_Debug );
+	return;
 }
 
 

Modified: long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/src/SystemLinearEquations.c
===================================================================
--- long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/src/SystemLinearEquations.c	2006-06-28 09:59:25 UTC (rev 3898)
+++ long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/src/SystemLinearEquations.c	2006-06-28 10:01:38 UTC (rev 3899)
@@ -236,7 +236,7 @@
 	
 	Memory_Free( self->executeEPName );
 	
-	_Stg_Component_Delete( self->extensionManager );
+	Stg_Class_Delete( self->extensionManager );
 
 	Stg_Class_Delete( self->stiffnessMatrices ); 
 	Stg_Class_Delete( self->forceVectors ); 

Added: long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/tests/expected/testContext.0of1.expected
===================================================================
--- long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/tests/expected/testContext.0of1.expected	2006-06-28 09:59:25 UTC (rev 3898)
+++ long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/tests/expected/testContext.0of1.expected	2006-06-28 10:01:38 UTC (rev 3899)
@@ -0,0 +1,42 @@
+StGermain Framework revision 3641. Copyright (C) 2003-2005 VPAC.
+StGermain Discretisation Library revision 3641. Copyright (C) 2003-2005 VPAC.
+StGermain FEM Discretisation Framework revision 586. Copyright (C) 2003-2005 VPAC.
+StGermain PETSc-LinearAlgebra Interface revision 586. Copyright (C) 2003-2005 VPAC.
+Running with no timestep braking, using  dt that increases 50% each step:
+Run until 10 timeSteps have been run
+TimeStep = 1, Start time = 0 + 0 prev timeStep dt
+TimeStep = 2, Start time = 0 + 1 prev timeStep dt
+TimeStep = 3, Start time = 1 + 1.5 prev timeStep dt
+TimeStep = 4, Start time = 2.5 + 2.25 prev timeStep dt
+TimeStep = 5, Start time = 4.75 + 3.375 prev timeStep dt
+TimeStep = 6, Start time = 8.125 + 5.0625 prev timeStep dt
+TimeStep = 7, Start time = 13.1875 + 7.59375 prev timeStep dt
+TimeStep = 8, Start time = 20.7812 + 11.3906 prev timeStep dt
+TimeStep = 9, Start time = 32.1719 + 17.0859 prev timeStep dt
+TimeStep = 10, Start time = 49.2578 + 25.6289 prev timeStep dt
+
+Turning on timestep braking, at default level, running again:
+Run until 10 timeSteps have been run
+TimeStep = 1, Start time = 0 + 0 prev timeStep dt
+TimeStep = 2, Start time = 0 + 1 prev timeStep dt
+TimeStep = 3, Start time = 1 + 1.1 prev timeStep dt
+TimeStep = 4, Start time = 2.1 + 1.21 prev timeStep dt
+TimeStep = 5, Start time = 3.31 + 1.331 prev timeStep dt
+TimeStep = 6, Start time = 4.641 + 1.4641 prev timeStep dt
+TimeStep = 7, Start time = 6.1051 + 1.61051 prev timeStep dt
+TimeStep = 8, Start time = 7.71561 + 1.77156 prev timeStep dt
+TimeStep = 9, Start time = 9.48717 + 1.94872 prev timeStep dt
+TimeStep = 10, Start time = 11.4359 + 2.14359 prev timeStep dt
+
+Turning on timestep braking, at 80% level, running again - expect same as original:
+Run until 10 timeSteps have been run
+TimeStep = 1, Start time = 0 + 0 prev timeStep dt
+TimeStep = 2, Start time = 0 + 1 prev timeStep dt
+TimeStep = 3, Start time = 1 + 1.5 prev timeStep dt
+TimeStep = 4, Start time = 2.5 + 2.25 prev timeStep dt
+TimeStep = 5, Start time = 4.75 + 3.375 prev timeStep dt
+TimeStep = 6, Start time = 8.125 + 5.0625 prev timeStep dt
+TimeStep = 7, Start time = 13.1875 + 7.59375 prev timeStep dt
+TimeStep = 8, Start time = 20.7812 + 11.3906 prev timeStep dt
+TimeStep = 9, Start time = 32.1719 + 17.0859 prev timeStep dt
+TimeStep = 10, Start time = 49.2578 + 25.6289 prev timeStep dt

Added: long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/tests/expected/testContext.0of2.expected
===================================================================
--- long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/tests/expected/testContext.0of2.expected	2006-06-28 09:59:25 UTC (rev 3898)
+++ long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/tests/expected/testContext.0of2.expected	2006-06-28 10:01:38 UTC (rev 3899)
@@ -0,0 +1,42 @@
+StGermain Framework revision 3641. Copyright (C) 2003-2005 VPAC.
+StGermain Discretisation Library revision 3641. Copyright (C) 2003-2005 VPAC.
+StGermain FEM Discretisation Framework revision 586. Copyright (C) 2003-2005 VPAC.
+StGermain PETSc-LinearAlgebra Interface revision 586. Copyright (C) 2003-2005 VPAC.
+Running with no timestep braking, using  dt that increases 50% each step:
+Run until 10 timeSteps have been run
+TimeStep = 1, Start time = 0 + 0 prev timeStep dt
+TimeStep = 2, Start time = 0 + 1 prev timeStep dt
+TimeStep = 3, Start time = 1 + 1.5 prev timeStep dt
+TimeStep = 4, Start time = 2.5 + 2.25 prev timeStep dt
+TimeStep = 5, Start time = 4.75 + 3.375 prev timeStep dt
+TimeStep = 6, Start time = 8.125 + 5.0625 prev timeStep dt
+TimeStep = 7, Start time = 13.1875 + 7.59375 prev timeStep dt
+TimeStep = 8, Start time = 20.7812 + 11.3906 prev timeStep dt
+TimeStep = 9, Start time = 32.1719 + 17.0859 prev timeStep dt
+TimeStep = 10, Start time = 49.2578 + 25.6289 prev timeStep dt
+
+Turning on timestep braking, at default level, running again:
+Run until 10 timeSteps have been run
+TimeStep = 1, Start time = 0 + 0 prev timeStep dt
+TimeStep = 2, Start time = 0 + 1 prev timeStep dt
+TimeStep = 3, Start time = 1 + 1.1 prev timeStep dt
+TimeStep = 4, Start time = 2.1 + 1.21 prev timeStep dt
+TimeStep = 5, Start time = 3.31 + 1.331 prev timeStep dt
+TimeStep = 6, Start time = 4.641 + 1.4641 prev timeStep dt
+TimeStep = 7, Start time = 6.1051 + 1.61051 prev timeStep dt
+TimeStep = 8, Start time = 7.71561 + 1.77156 prev timeStep dt
+TimeStep = 9, Start time = 9.48717 + 1.94872 prev timeStep dt
+TimeStep = 10, Start time = 11.4359 + 2.14359 prev timeStep dt
+
+Turning on timestep braking, at 80% level, running again - expect same as original:
+Run until 10 timeSteps have been run
+TimeStep = 1, Start time = 0 + 0 prev timeStep dt
+TimeStep = 2, Start time = 0 + 1 prev timeStep dt
+TimeStep = 3, Start time = 1 + 1.5 prev timeStep dt
+TimeStep = 4, Start time = 2.5 + 2.25 prev timeStep dt
+TimeStep = 5, Start time = 4.75 + 3.375 prev timeStep dt
+TimeStep = 6, Start time = 8.125 + 5.0625 prev timeStep dt
+TimeStep = 7, Start time = 13.1875 + 7.59375 prev timeStep dt
+TimeStep = 8, Start time = 20.7812 + 11.3906 prev timeStep dt
+TimeStep = 9, Start time = 32.1719 + 17.0859 prev timeStep dt
+TimeStep = 10, Start time = 49.2578 + 25.6289 prev timeStep dt


Property changes on: long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/tests/output
___________________________________________________________________
Name: svn:ignore
   + *


Added: long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/tests/testContext.0of1.sh
===================================================================
--- long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/tests/testContext.0of1.sh	2006-06-28 09:59:25 UTC (rev 3898)
+++ long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/tests/testContext.0of1.sh	2006-06-28 10:01:38 UTC (rev 3899)
@@ -0,0 +1,49 @@
+#!/bin/sh
+##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+##
+## Copyright (C), 2003-2006, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street,
+##	Melbourne, 3053, Australia.
+##
+## Primary Contributing Organisations:
+##	Victorian Partnership for Advanced Computing Ltd, Computational Software Development - http://csd.vpac.org
+##	Australian Computational Earth Systems Simulator - http://www.access.edu.au
+##	Monash Cluster Computing - http://www.mcc.monash.edu.au
+##	Computational Infrastructure for Geodynamics - http://www.geodynamics.org
+##
+## Contributors:
+##	Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
+##	Robert Turnbull, Research Assistant, Monash University. (robert.turnbull at sci.monash.edu.au)
+##	Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
+##	David May, PhD Student, Monash University (david.may at sci.monash.edu.au)
+##	Louis Moresi, Associate Professor, Monash University. (louis.moresi at sci.monash.edu.au)
+##	Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
+##	Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
+##	Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
+##	Julian Giordani, Research Assistant, Monash University. (julian.giordani at sci.monash.edu.au)
+##	Vincent Lemiale, Postdoctoral Fellow, Monash University. (vincent.lemiale at sci.monash.edu.au)
+##
+##  This library is free software; you can redistribute it and/or
+##  modify it under the terms of the GNU Lesser General Public
+##  License as published by the Free Software Foundation; either
+##  version 2.1 of the License, or (at your option) any later version.
+##
+##  This library is distributed in the hope that it will be useful,
+##  but WITHOUT ANY WARRANTY; without even the implied warranty of
+##  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+##  Lesser General Public License for more details.
+##
+##  You should have received a copy of the GNU Lesser General Public
+##  License along with this library; if not, write to the Free Software
+##  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+##
+## $Id$
+##
+##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+TEST_SCRIPT=./VMake/executableTester.sh
+until test -r ${TEST_SCRIPT} ; do
+        TEST_SCRIPT=../${TEST_SCRIPT}
+done
+. ${TEST_SCRIPT}
+
+runAndHandleSystemTestStdLocations "testContext " "$0" "$@"


Property changes on: long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/tests/testContext.0of1.sh
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:keywords
   + LastChangedDate Author Id
Name: svn:eol-style
   + native

Added: long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/tests/testContext.0of2.sh
===================================================================
--- long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/tests/testContext.0of2.sh	2006-06-28 09:59:25 UTC (rev 3898)
+++ long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/tests/testContext.0of2.sh	2006-06-28 10:01:38 UTC (rev 3899)
@@ -0,0 +1,49 @@
+#!/bin/sh
+##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+##
+## Copyright (C), 2003-2006, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street,
+##	Melbourne, 3053, Australia.
+##
+## Primary Contributing Organisations:
+##	Victorian Partnership for Advanced Computing Ltd, Computational Software Development - http://csd.vpac.org
+##	Australian Computational Earth Systems Simulator - http://www.access.edu.au
+##	Monash Cluster Computing - http://www.mcc.monash.edu.au
+##	Computational Infrastructure for Geodynamics - http://www.geodynamics.org
+##
+## Contributors:
+##	Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
+##	Robert Turnbull, Research Assistant, Monash University. (robert.turnbull at sci.monash.edu.au)
+##	Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
+##	David May, PhD Student, Monash University (david.may at sci.monash.edu.au)
+##	Louis Moresi, Associate Professor, Monash University. (louis.moresi at sci.monash.edu.au)
+##	Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
+##	Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
+##	Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
+##	Julian Giordani, Research Assistant, Monash University. (julian.giordani at sci.monash.edu.au)
+##	Vincent Lemiale, Postdoctoral Fellow, Monash University. (vincent.lemiale at sci.monash.edu.au)
+##
+##  This library is free software; you can redistribute it and/or
+##  modify it under the terms of the GNU Lesser General Public
+##  License as published by the Free Software Foundation; either
+##  version 2.1 of the License, or (at your option) any later version.
+##
+##  This library is distributed in the hope that it will be useful,
+##  but WITHOUT ANY WARRANTY; without even the implied warranty of
+##  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+##  Lesser General Public License for more details.
+##
+##  You should have received a copy of the GNU Lesser General Public
+##  License along with this library; if not, write to the Free Software
+##  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+##
+## $Id$
+##
+##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+TEST_SCRIPT=./VMake/executableTester.sh
+until test -r ${TEST_SCRIPT} ; do
+        TEST_SCRIPT=../${TEST_SCRIPT}
+done
+. ${TEST_SCRIPT}
+
+runAndHandleSystemTestStdLocations "testContext " "$0" "$@"


Property changes on: long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/tests/testContext.0of2.sh
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:keywords
   + LastChangedDate Author Id
Name: svn:eol-style
   + native

Added: long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/tests/testContext.c
===================================================================
--- long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/tests/testContext.c	2006-06-28 09:59:25 UTC (rev 3898)
+++ long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/tests/testContext.c	2006-06-28 10:01:38 UTC (rev 3899)
@@ -0,0 +1,183 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+**
+** Copyright (C), 2003-2006, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street,
+**	Melbourne, 3053, Australia.
+**
+** Primary Contributing Organisations:
+**	Victorian Partnership for Advanced Computing Ltd, Computational Software Development - http://csd.vpac.org
+**	Australian Computational Earth Systems Simulator - http://www.access.edu.au
+**	Monash Cluster Computing - http://www.mcc.monash.edu.au
+**	Computational Infrastructure for Geodynamics - http://www.geodynamics.org
+**
+** Contributors:
+**	Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
+**	Robert Turnbull, Research Assistant, Monash University. (robert.turnbull at sci.monash.edu.au)
+**	Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
+**	David May, PhD Student, Monash University (david.may at sci.monash.edu.au)
+**	Louis Moresi, Associate Professor, Monash University. (louis.moresi at sci.monash.edu.au)
+**	Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
+**	Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
+**	Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
+**	Julian Giordani, Research Assistant, Monash University. (julian.giordani at sci.monash.edu.au)
+**	Vincent Lemiale, Postdoctoral Fellow, Monash University. (vincent.lemiale at sci.monash.edu.au)
+**
+**  This library is free software; you can redistribute it and/or
+**  modify it under the terms of the GNU Lesser General Public
+**  License as published by the Free Software Foundation; either
+**  version 2.1 of the License, or (at your option) any later version.
+**
+**  This library is distributed in the hope that it will be useful,
+**  but WITHOUT ANY WARRANTY; without even the implied warranty of
+**  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+**  Lesser General Public License for more details.
+**
+**  You should have received a copy of the GNU Lesser General Public
+**  License along with this library; if not, write to the Free Software
+**  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+**
+** $Id$
+**
+** Purpose: primarily in this test we're going to check the timestep
+**	limiting works.
+**
+**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+
+#ifdef HAVE_PYTHON
+	#include <Python.h>
+#endif
+#include <mpi.h>
+#include <StGermain/StGermain.h>
+#include "StG_FEM/Discretisation/Discretisation.h"
+#include "StG_FEM/SLE/LinearAlgebra/LinearAlgebra.h"
+#include "StG_FEM/SLE/SystemSetup/SystemSetup.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+struct _Element {
+	__FiniteElement_Element
+};
+
+struct _Particle {
+	__IntegrationPoint
+};
+
+
+double testCalcDtFunc( FiniteElementContext* context, FiniteElementContext* contextArg2 ) {
+	if ( context->timeStep == 1 ) {
+		return 1.0;
+	}
+	else {
+		return 1.5 * context->dt;
+	}
+}
+
+int main( int argc, char* argv[] ) 
+{
+	/* StGermain standard bits & pieces */
+	MPI_Comm			CommWorld;
+	int				rank;
+	int				numProcessors;
+	Dictionary*			dictionary;
+	Dictionary*			componentDict;
+	XML_IO_Handler*			ioHandler;
+	Stream*                         stream;
+	
+	/* context */
+	FiniteElementContext*		context = NULL;
+	
+	/* Initialise PETSc, get world info */
+	MPI_Init( &argc, &argv );
+	MPI_Comm_dup( MPI_COMM_WORLD, &CommWorld );
+	MPI_Comm_size( CommWorld, &numProcessors );
+	MPI_Comm_rank( CommWorld, &rank );
+	
+	StGermain_Init( &argc, &argv );
+	StG_FEM_Discretisation_Init( &argc, &argv );
+	StG_FEM_SLE_LinearAlgebra_Init( &argc, &argv );
+	StG_FEM_SLE_SystemSetup_Init( &argc, &argv );
+	MPI_Barrier( CommWorld ); /* Ensures copyright info always come first in output */
+	
+	stream = Journal_Register( Info_Type, "test" );
+	Stream_SetPrintingRank( stream, 0 );
+	
+	/* Create the application's dictionary */
+	dictionary = Dictionary_New();
+
+	Dictionary_Add( dictionary, "outputPath", Dictionary_Entry_Value_FromString( "output" ) );
+
+	/* Read input */
+	ioHandler = XML_IO_Handler_New();
+	IO_Handler_ReadAllFromCommandLine( ioHandler, argc, argv, dictionary );
+
+	Journal_ReadFromDictionary( dictionary );
+
+	/* Construction phase ----------------------------------------------------------------------------------------------*/
+	context = FiniteElementContext_New( "context", 0, 0, CommWorld, dictionary );
+	
+	Stream_SetPrintingRank( context->info, 0 );
+
+	componentDict = Dictionary_GetDictionary( dictionary, "components" );
+
+	if ( componentDict == NULL ) {
+		componentDict = Dictionary_New();
+	}
+	context->CF = Stg_ComponentFactory_New( dictionary, componentDict, context->register_Register );
+	
+	/* This is where we'd normally construct components if it was real main.
+		instead, we'll just set the dt function so we can test it */
+	EP_AppendClassHook( context->calcDtEP, testCalcDtFunc, context );
+	
+	if( rank == 0 ) 
+		Context_PrintConcise( context, context->verbose );
+
+	if ( True == Dictionary_GetBool_WithDefault( dictionary, "showJournalStatus", False ) ) {
+		Journal_PrintConcise();	
+	}	
+
+	/* Building phase ---------------------------------------------------------------------------------------------------*/
+	Stg_Component_Build( context, 0 /* dummy */, False );
+	
+	/* Initialisaton phase ----------------------------------------------------------------------------------------------*/
+	Stg_Component_Initialise( context, 0 /* dummy */, False );
+	
+	/* Run (Solve) phase ------------------------------------------------------------------------------------------------*/
+	AbstractContext_Dump( context );
+
+	context->maxTimeSteps = 10;
+
+	Journal_Printf( stream, "Running with no timestep braking, using  "
+		"dt that increases 50%% each step:\n" );
+
+	Stg_Component_Execute( context, 0 /* dummy */, False );
+	context->currentTime=0;
+	context->dt = 0;
+
+	Journal_Printf( stream, "\nTurning on timestep braking, at default "
+		"level, running again:\n" );
+	context->limitTimeStepIncreaseRate = True;
+	Stg_Component_Execute( context, 0 /* dummy */, True );
+	context->currentTime=0;
+	context->dt = 0;
+
+	Journal_Printf( stream, "\nTurning on timestep braking, at 80%% "
+		"level, running again - expect same as original:\n" );
+	context->maxTimeStepIncreasePercentage = 80;
+	Stg_Component_Execute( context, 0 /* dummy */, True );
+
+	/* Destruct phase ---------------------------------------------------------------------------------------------------*/
+	Stg_Component_Destroy( context, 0 /* dummy */, False );
+	Stg_Class_Delete( context );
+	Stg_Class_Delete( dictionary );
+
+	StG_FEM_SLE_SystemSetup_Finalise();
+	StG_FEM_SLE_LinearAlgebra_Finalise();
+	StG_FEM_Discretisation_Finalise();
+	StGermain_Finalise();
+		
+	/* Close off MPI */
+	MPI_Finalize();
+	
+	return 0; /* success */
+}


Property changes on: long/3D/Gale/trunk/src/StgFEM/SLE/SystemSetup/tests/testContext.c
___________________________________________________________________
Name: svn:keywords
   + LastChangedDate Author Id
Name: svn:eol-style
   + native

Modified: long/3D/Gale/trunk/src/StgFEM/plugins/Application/Application.c
===================================================================
--- long/3D/Gale/trunk/src/StgFEM/plugins/Application/Application.c	2006-06-28 09:59:25 UTC (rev 3898)
+++ long/3D/Gale/trunk/src/StgFEM/plugins/Application/Application.c	2006-06-28 10:01:38 UTC (rev 3899)
@@ -42,80 +42,87 @@
 
 #include <mpi.h>
 #include <StGermain/StGermain.h>
+//EP_APPLICATIONS_FINALISE defined in StGermain.h
 #include <StG_FEM/StG_FEM.h>
 #include "Application.h"
 
 #include <stdio.h>
+//For strcmp
+#include <string.h>
 
 const Type StG_FEM_Application_Type = "StG_FEM_Application";
 
-void _StG_FEM_Application_Construct( void* component, Stg_ComponentFactory* cf ) {
+void _StG_FEM_Application_Construct( void* component, Stg_ComponentFactory* cf ) 
+{
 	AbstractContext* currAbstractContext;
 	FiniteElementContext* context;
-        int componentIndex = 0;
 
-	StG_FEM_Init(NULL, NULL);
+	AbstractContext* prevContext;
+        EntryPoint* applicationsFinalise_EP;
 
-	//Get the existing abstract context, as defined by StGermain.
-	currAbstractContext = (AbstractContext*)Stg_ComponentFactory_ConstructByName( cf, "context", AbstractContext, True );
+	//Get the existing context, as defined by StGermain, or an alternative plugin application.
+	prevContext = (AbstractContext*)Stg_ComponentFactory_ConstructByName( cf, "context", AbstractContext, True );
 
-	//Create a new, empty FiniteElementContext.
-	//Yeah, but how do I get to CommWorld & Dictionary???? Is CommWorld, as
-	//the name sounds, global?? Can I access dictionary via the cf?? Yeah,
-	//what about cf->rootDict???
-	context = FiniteElementContext_New( "context", 0, 0, currAbstractContext->communicator, cf->rootDict ); //CommWorld, dictionary );
 
+       //Only need to initialise a new context, and copy all relevant registers over IF this is the first application
+        //plugin to be constructed.
+        //The first application plugin to be constructed is Guaranteed to have the 'largest' context.
+        //                      (ie is an inherited child of ALL other application plugins about to be loaded)
+        if( prevContext->type == AbstractContext_Type )
+        {
+                //Set the existing abstract context.
+                currAbstractContext = prevContext;
 
-	context->dictionary = cf->rootDict;
+		//Create a new, empty FiniteElementContext.
+		context = FiniteElementContext_New( "context", 0, 0, currAbstractContext->communicator, cf->rootDict );
 
-	//Need to somehow get ALL abstractcontext information FROM the existing
-	//abstract context INTO the FiniteElementContext.....this could be
-	//tricky. But what's there so far -> The new Component Factory,
-	//WHICH WE'VE GOT passed to this function AND the context....So, MAYBE
-	//I can just replace it and it doesn't matter!
-	_AbstractContext_Init((AbstractContext*)context, 0, 0, MPI_COMM_WORLD );
-	//Initialise Discretisation parts of FiniteElementContext
-	_DiscretisationContext_Init((DiscretisationContext*)context );
-	//Initialise FiniteElement parts of FiniteElementContext
-	_FiniteElementContext_Init( context );
+                context->dictionary = cf->rootDict;
 
-	
-	//Create a NEW Stg_ComponentFactory -> the old one only has the old 
-	//(now outdated) AbstractContext in it anyway.
-        context->CF = Stg_ComponentFactory_New( cf->rootDict, cf->componentDict, context->register_Register );
-	//Put the new FiniteElementContext into the new Stg_Component_factory.
-	LiveComponentRegister_Add( context->CF->LCRegister, (Stg_Component*) context );
+                //Initialise Abstract parts of FiniteElementContext
+                _AbstractContext_Init((AbstractContext*)context, 0, 0, MPI_COMM_WORLD );
+                //Initialise Discretisation parts of FiniteElementContext
+                _DiscretisationContext_Init((DiscretisationContext*)context );
+                //Initialise FiniteElement parts of FintieElementContext
+                _FiniteElementContext_Init( (FiniteElementContext*)context );
 
-	//Check that context IS the first item in the LCRegister.
-	componentIndex = Stg_ObjectList_GetIndex ( context->CF->LCRegister->componentList, context->name );
-	Journal_Firewall( !componentIndex, Journal_Register( Error_Type, context->type ), "Context should be the first component in the 'components' list..!" );
+               //Need to get the old CF from currAbstractContext, and use that in my new context.
+                //Now I CANNOT delete this currAbstractContext or I'll lose the CF. :(
+                context->CF = currAbstractContext->CF;
 
-	//Should I save a COPY of the cf instead??
-	//context->CF = cf;
-	context->CF->registerRegister = context->register_Register;
+                //Need to get the LCRegister componentList, and replace the existing (abstract) context
+                //with the newly created (PICellerator) context!!!
+                Stg_ObjectList_Replace( context->CF->LCRegister->componentList,
+                                        ((Stg_Component*) currAbstractContext)->name,
+                                        KEEP,
+                                        (Stg_Component*) context);
 
-	//Now need to make the context pointer passed into me, to now point to
-	//the new FiniteElementContext!!!
-	
-	// currAbstractContext = (AbstractContext*) context;
-	//This doesn't work -> currAbstractContext creates a new pointer to 
-	//the data. I need to set the curr pointer to point to new data.
-	cf->LCRegister->componentList->data[0] = (AbstractContext*) context;
+                //Recreate the registerRegister link in CF.
+                context->CF->registerRegister = context->register_Register;
 
+                //Create the EntryPoint for all application plugins' finalise functions to hook into.
+                applicationsFinalise_EP = EntryPoint_New( EP_APPLICATIONS_FINALISE, EntryPoint_VoidPtr_CastType );
+                EntryPoint_Register_Add(context->entryPoint_Register, (void*)applicationsFinalise_EP);
 
-	//Add in a hook to an init function. ie Plugin user must call this....
-	ContextEP_Append(context, AbstractContext_EP_Dump, 
-						StG_FEM_Application_Init);
+        } //close of if( prevContext->type == AbstractContext_Type)
+	else //prevContext was NOT an abstract context -> that is does NOT need to be replaced
+		context = (FiniteElementContext*) prevContext;
+
+	//Change to append -> THESE plugins are now CONSTRUCTED IN REVERSE ORDER!!!
+	EntryPoint_Append( 
+			Context_GetEntryPoint( context, EP_APPLICATIONS_FINALISE ),
+			"StG_FEM App Finalise",
+			StG_FEM_Application_Finalise, 
+			"StG_FEM_App_Construct");
 }
 
-void StG_FEM_Application_Init(void* _context )
+
+//StG_FEM finalise entry point -> needs to be called if this plugin was loaded.
+void StG_FEM_Application_Finalise()
 {
-        Stream* myStream = Journal_Register(Info_Type, "StgFEM_Application");
+	Stream* finaliseStream=Journal_Register(Info_Type,"StgFEM_Application");
+	Journal_Printf(finaliseStream, "Finalised: StGermain FEM Framework.\n");
 
-	// Using the stream myStream, which is an instance of
-	Journal_Printf( myStream, "Testing, testing 123\n");//write_string );
-
-	//StG_FEM_Init(NULL, NULL);
+	StG_FEM_Finalise();
 }
 
 void* _StG_FEM_Application_DefaultNew( Name name ) {
@@ -130,8 +137,11 @@
 			name );
 }
 
-Index StG_FEM_Application_Register( PluginsManager* pluginsManager ) {
-	//Journal_DPrintf( StGermain_Debug, "In: %s( void* )\n", __func__ );
+Index StG_FEM_Application_Register( PluginsManager* pluginsManager ) 
+{
+	//Initialise StG_FEM context.
+	StG_FEM_Init(NULL, NULL);
 
 	return PluginsManager_Submit( pluginsManager, StG_FEM_Application_Type, "0", _StG_FEM_Application_DefaultNew );
 }
+

Modified: long/3D/Gale/trunk/src/StgFEM/plugins/Application/Application.h
===================================================================
--- long/3D/Gale/trunk/src/StgFEM/plugins/Application/Application.h	2006-06-28 09:59:25 UTC (rev 3898)
+++ long/3D/Gale/trunk/src/StgFEM/plugins/Application/Application.h	2006-06-28 10:01:38 UTC (rev 3899)
@@ -59,6 +59,6 @@
 
 Index StG_FEM_Application_Register( PluginsManager* pluginsManager );
 
-void StG_FEM_Application_Init(void* _context );
+void StG_FEM_Application_Finalise();
 
 #endif	

Added: long/3D/Gale/trunk/src/StgFEM/plugins/CompareFeVariableAgainstReferenceSolution/CompareFeVariableAgainstReferenceSolution.c
===================================================================
--- long/3D/Gale/trunk/src/StgFEM/plugins/CompareFeVariableAgainstReferenceSolution/CompareFeVariableAgainstReferenceSolution.c	2006-06-28 09:59:25 UTC (rev 3898)
+++ long/3D/Gale/trunk/src/StgFEM/plugins/CompareFeVariableAgainstReferenceSolution/CompareFeVariableAgainstReferenceSolution.c	2006-06-28 10:01:38 UTC (rev 3899)
@@ -0,0 +1,352 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+** 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:
+*+		Mirko Velic
+*+		Julian Giordani
+*+		Robert Turnbull
+*+		Vincent Lemiale
+*+		Louis Moresi
+*+		David May
+*+		David Stegman
+*+		Patrick Sunter
+** $Id: solA.c 567 2006-05-25 02:10:57Z JulianGiordani $
+**
+**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+
+#include <mpi.h>
+#include <StGermain/StGermain.h>
+#include <StG_FEM/StG_FEM.h>
+
+#include <string.h>
+
+const Type CompareFeVariableAgainstReferenceSolution_Type = "StG_FEM_CompareFeVariableAgainstReferenceSolution";
+
+void CompareFeVariableAgainstReferenceSolution_TestAll( void* compareFeVariable, void* data );
+void CompareFeVariableAgainstReferenceSolution_TestVariable( void* compareFeVariable, FeVariable* var, double tolerance );
+
+typedef struct {
+	__Codelet
+	AbstractContext*         context;
+	Stg_ComponentFactory*    cf;
+
+	char*                    referencePath;
+	Swarm*                   integrationSwarm;
+	
+	Stg_ObjectList*          variables;
+	Stg_ObjectList*          tolerances;
+
+	Index                    timeStepToCompare;
+} CompareFeVariableAgainstReferenceSolution;
+
+void _CompareFeVariableAgainstReferenceSolution_Construct( void* compareFeVariable, Stg_ComponentFactory* cf ) {
+	CompareFeVariableAgainstReferenceSolution* self = (CompareFeVariableAgainstReferenceSolution*) compareFeVariable;
+
+	AbstractContext*         context;
+
+	Dictionary*              dictionary;
+	char*                    referencePath;
+	char*                    integrationSwarmName;
+	
+	char*                    varName;
+	Dictionary_Entry_Value*  varList;
+
+	FeVariable*              var;
+	Index                    var_I;
+	double                   tolerance;
+
+	char*                    tmpName;
+
+	Stream*                  myStream;
+
+	context = (AbstractContext*)Stg_ComponentFactory_ConstructByName( cf, "context", AbstractContext, True );
+	self->context = context;
+	self->cf = cf;
+
+	EP_AppendClassHook( 
+			Context_GetEntryPoint( context, AbstractContext_EP_DumpClass ),
+			CompareFeVariableAgainstReferenceSolution_TestAll, 
+			self );
+
+	dictionary = Dictionary_GetDictionary( cf->rootDict, self->name );
+	Journal_Firewall(
+		dictionary != NULL,
+		Journal_MyStream( Error_Type, self ),
+		"In func %s - Specify FeVariables to compare in struct %s\n", __func__, self->name );
+
+	referencePath = Dictionary_GetString_WithDefault( dictionary, "referencePath", "./" );
+	Journal_Printf(
+		Journal_MyStream( Info_Type, self ),
+		"%s: Using reference path %s\n", self->name, referencePath );
+	self->referencePath = referencePath;
+	
+	integrationSwarmName = Dictionary_GetString_WithDefault( dictionary, "integrationSwarm", "gaussSwarm" );
+	Journal_Printf(
+		Journal_MyStream( Info_Type, self ),
+		"%s: Using integration swarm %s\n", self->name, integrationSwarmName );
+	self->integrationSwarm = Stg_ComponentFactory_ConstructByName( cf, integrationSwarmName, Swarm, True );
+
+	self->variables = Stg_ObjectList_New();
+	self->tolerances = Stg_ObjectList_New();
+
+	varList = Dictionary_Get( dictionary, "variables" );
+	Journal_Firewall(
+		varList != NULL && Dictionary_Entry_Value_GetCount( varList ) > 0,
+		Journal_MyStream( Error_Type, self ),
+		"In func %s - Specify FeVariables to compare in list \"variables\" for %s\n", __func__, self->name );
+
+	for ( var_I = 0; var_I < Dictionary_Entry_Value_GetCount( varList ); ++var_I ) {
+		varName = Dictionary_Entry_Value_AsString( Dictionary_Entry_Value_GetElement( varList, var_I ) );
+		var = Stg_ComponentFactory_ConstructByName( cf, varName, FeVariable, True );
+		Journal_Printf(
+			Journal_MyStream( Info_Type, self ),
+			"%s: Comparing FeVariable %s\n", self->name, varName );
+
+		tmpName = Stg_Object_AppendSuffix( var, "tolerance" );
+		tolerance = Dictionary_GetDouble_WithDefault( dictionary, tmpName, 0.005 );
+		
+		Stg_ObjectList_Append( self->variables, var );
+		Stg_ObjectList_Append( self->tolerances, Stg_PrimitiveObject_New_Double( tolerance, varName ) );
+	}
+
+	/* Default is zero which means every time step */
+	self->timeStepToCompare = Dictionary_GetUnsignedInt_WithDefault( dictionary, "timeStepToCompare", 0 );
+	if ( self->timeStepToCompare == 0 ) {
+		Journal_Printf(
+			Journal_MyStream( Info_Type, self ),
+			"%s: timeStepToCompare is 0 - All time steps will be compared\n",
+			self->type );
+	}
+
+	myStream = Journal_MyStream( Info_Type, self );
+	Stg_asprintf( &tmpName, "%s.dat", self->name );
+        Stream_RedirectFile_WithPrependedPath( myStream, self->context->outputPath, tmpName );
+	Memory_Free( tmpName );
+}
+
+void* _CompareFeVariableAgainstReferenceSolution_DefaultNew( Name name ) {
+	return _Codelet_New(
+			sizeof(CompareFeVariableAgainstReferenceSolution),
+			CompareFeVariableAgainstReferenceSolution_Type,
+			_Codelet_Delete,
+			_Codelet_Print,
+			_Codelet_Copy,
+			_CompareFeVariableAgainstReferenceSolution_DefaultNew,
+			_CompareFeVariableAgainstReferenceSolution_Construct,
+			_Codelet_Build,
+			_Codelet_Initialise,
+			_Codelet_Execute,
+			_Codelet_Destroy,
+			name );
+}
+
+Index _StG_FEM_CompareFeVariableAgainstReferenceSolution_Register( PluginsManager* pluginsManager ) {
+	return PluginsManager_Submit( 
+			pluginsManager, 
+			CompareFeVariableAgainstReferenceSolution_Type, 
+			"0", 
+			_CompareFeVariableAgainstReferenceSolution_DefaultNew );
+}
+
+void CompareFeVariableAgainstReferenceSolution_TestAll( void* compareFeVariable, void* data ) {
+	CompareFeVariableAgainstReferenceSolution* self = (CompareFeVariableAgainstReferenceSolution*) compareFeVariable;
+
+	FeVariable*     var;
+	double          tolerance;
+
+	Index           var_I;
+
+	/* No need to test initial conditions */
+	if ( self->context->timeStep < 1 ) {
+		return;
+	}
+
+	if ( self->timeStepToCompare != 0 && self->context->timeStep != self->timeStepToCompare ) {
+		/* Only compare timesteps that has been selected iff timeStepToCompare is non-zero */
+		return;
+	}
+
+	for ( var_I = 0; var_I < self->variables->count; ++var_I ) {
+		var = (FeVariable*)Stg_ObjectList_At( self->variables, var_I );
+		tolerance = ((Stg_PrimitiveObject*)Stg_ObjectList_At( self->tolerances, var_I ))->value.asDouble;
+		CompareFeVariableAgainstReferenceSolution_TestVariable( self, var, tolerance );
+	}
+}
+
+void CompareFeVariableAgainstReferenceSolution_TestVariable( void* compareFeVariable, FeVariable* var, double tolerance ) {
+	CompareFeVariableAgainstReferenceSolution* self = (CompareFeVariableAgainstReferenceSolution*) compareFeVariable;
+	
+	Variable_Register*       variable_Register;
+
+	FeVariable*              ref;
+	Variable*                dataVariable;
+        Name                     variableName[9];
+	Variable_Index           variable_I;
+	DofLayout*               dofLayout;
+	Node_DomainIndex         node_I;
+
+	OperatorFeVariable*      errorField;
+	OperatorFeVariable*      errorMagnitudeField;
+
+	char*                    tmpName;
+	Bool                     scalar;
+        Dof_Index                componentsCount;
+	
+	char*                    refName;
+
+	char*                    prefix;
+
+	double                   result;
+	
+	variable_Register = self->context->variable_Register;
+
+	componentsCount = var->fieldComponentCount;
+	scalar = componentsCount == 1;
+
+	/* Create a DataVariable for the Reference. This serves as the memory object is is linked to */
+	tmpName = Stg_Object_AppendSuffix( var, "Reference-DataVariable" );
+	if ( scalar == 1 ) {
+		dataVariable = Variable_NewScalar(
+			tmpName,
+			Variable_DataType_Double,
+			&var->feMesh->nodeDomainCount,
+			(void**)NULL,
+			variable_Register );
+	}
+	else {
+		Journal_Firewall( 
+			componentsCount <= 9,
+			Journal_MyStream( Error_Type, self ),
+			"In func %s - Cannot create a variable with more than 9 components (%s)\n",
+			__func__,
+			var->name );
+		for ( variable_I = 0 ; variable_I < componentsCount; variable_I++ ) {
+			Stg_asprintf( 
+				&variableName[ variable_I ], 
+				"%s-Reference-ComponentVariable%d", 
+				var->name, 
+				variable_I );
+		}
+		dataVariable = Variable_NewVector(
+				tmpName,
+				Variable_DataType_Double,
+				componentsCount,
+				&var->feMesh->nodeDomainCount,
+				(void**)NULL,
+				variable_Register,
+				variableName[0],
+				variableName[1],
+				variableName[2],
+				variableName[3],
+				variableName[4],
+				variableName[5],
+				variableName[6],
+				variableName[7],
+				variableName[8] );
+	}
+	Memory_Free( tmpName );
+	
+	dataVariable->allocateSelf = True;
+
+	/* Create Dof layout for this variable based on its own DataVariable */
+	tmpName = Stg_Object_AppendSuffix( var, "Reference-DofLayout" );
+	dofLayout = DofLayout_New( tmpName, variable_Register, var->feMesh->layout->decomp->nodeDomainCount );
+	if ( scalar ) {
+		DofLayout_AddAllFromVariableArray( dofLayout, 1, &dataVariable );
+	}
+	else {
+		for ( variable_I = 0 ; variable_I < componentsCount ; variable_I++ ) {
+
+			/* We have to set the array ptr ptr for these guys manually - this should be fixed */
+			Variable* variable = Variable_Register_GetByName( variable_Register, variableName[ variable_I ] );
+			variable->arrayPtrPtr = &dataVariable->arrayPtr;
+
+			/* Assign variable to each node */
+			for( node_I = 0; node_I < var->feMesh->layout->decomp->nodeDomainCount ; node_I++ ) {
+				DofLayout_AddDof_ByVarName( dofLayout, variableName[variable_I], node_I );
+			}
+			/* Free Name */
+			Memory_Free( variableName[ variable_I ] );
+		}
+	}
+	Memory_Free( tmpName );
+	
+	Build( dofLayout, NULL, False );
+	Build( dataVariable, NULL, False );
+	Initialise( dofLayout, NULL, False );
+	Initialise( dataVariable, NULL, False );
+	
+	dofLayout->dofCounts[0] = var->dofLayout->dofCounts[0];
+
+	/* Instantiate FeVariable, pre-reading reference */
+	refName = Stg_Object_AppendSuffix( var, "Reference" );
+	ref = FeVariable_New( 
+			refName, 
+			var->feMesh, 
+			var->geometryMesh, 
+			dofLayout, 
+			NULL, 
+			NULL, 
+			NULL, 
+			var->dim, 
+			var->fieldVariable_Register );
+
+	Stg_asprintf( &prefix, "%s/", self->referencePath );
+	FeVariable_ReadFromFile( ref, prefix, self->context->timeStep );
+	Memory_Free( prefix );
+
+	tmpName = Stg_Object_AppendSuffix( var, "ErrorField" );
+	errorField = OperatorFeVariable_NewBinary( tmpName, var, ref, "Subtraction" );
+	Memory_Free( tmpName );
+
+	tmpName = Stg_Object_AppendSuffix( var, "ErrorMagnitudeField" );
+	errorMagnitudeField = OperatorFeVariable_NewUnary( tmpName, errorField, "Magnitude" );
+	Memory_Free( tmpName );
+
+
+        result = FeVariable_Integrate( errorMagnitudeField, self->integrationSwarm );
+
+	Journal_Printf( 
+		Journal_MyStream( Info_Type, self ), 
+		"Timestep %u: Total integrated value of '%s' is %s a tolerance %.5g.\n",
+		self->context->timeStep, 
+		errorMagnitudeField->name, 
+		result <= tolerance ? "within" : "outside", 
+		tolerance );
+
+	/*
+	Stg_Class_Delete( dataVariable );
+	Stg_Class_Delete( dofLayout );
+	Stg_Class_Delete( ref );
+	Stg_Class_Delete( errorField );
+	Stg_Class_Delete( errorMagnitudeField );
+	*/
+	
+}

Added: long/3D/Gale/trunk/src/StgFEM/plugins/CompareFeVariableAgainstReferenceSolution/makefile
===================================================================
--- long/3D/Gale/trunk/src/StgFEM/plugins/CompareFeVariableAgainstReferenceSolution/makefile	2006-06-28 09:59:25 UTC (rev 3898)
+++ long/3D/Gale/trunk/src/StgFEM/plugins/CompareFeVariableAgainstReferenceSolution/makefile	2006-06-28 10:01:38 UTC (rev 3899)
@@ -0,0 +1,59 @@
+##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+##
+## Copyright (C), 2003-2006, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street,
+##	Melbourne, 3053, Australia.
+##
+## Primary Contributing Organisations:
+##	Victorian Partnership for Advanced Computing Ltd, Computational Software Development - http://csd.vpac.org
+##	Australian Computational Earth Systems Simulator - http://www.access.edu.au
+##	Monash Cluster Computing - http://www.mcc.monash.edu.au
+##	Computational Infrastructure for Geodynamics - http://www.geodynamics.org
+##
+## Contributors:
+##	Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
+##	Robert Turnbull, Research Assistant, Monash University. (robert.turnbull at sci.monash.edu.au)
+##	Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
+##	David May, PhD Student, Monash University (david.may at sci.monash.edu.au)
+##	Louis Moresi, Associate Professor, Monash University. (louis.moresi at sci.monash.edu.au)
+##	Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
+##	Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
+##	Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
+##	Julian Giordani, Research Assistant, Monash University. (julian.giordani at sci.monash.edu.au)
+##	Vincent Lemiale, Postdoctoral Fellow, Monash University. (vincent.lemiale at sci.monash.edu.au)
+##
+##  This library is free software; you can redistribute it and/or
+##  modify it under the terms of the GNU Lesser General Public
+##  License as published by the Free Software Foundation; either
+##  version 2.1 of the License, or (at your option) any later version.
+##
+##  This library is distributed in the hope that it will be useful,
+##  but WITHOUT ANY WARRANTY; without even the implied warranty of
+##  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+##  Lesser General Public License for more details.
+##
+##  You should have received a copy of the GNU Lesser General Public
+##  License along with this library; if not, write to the Free Software
+##  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+##
+## $Id: makefile 535 2006-04-11 13:07:34Z PatrickSunter $
+##
+##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+SHELL := $(shell which bash)
+PROJ_ROOT := $(shell until test -r ./Makefile.system ; do cd .. ; done ; echo `pwd`)
+
+include ${PROJ_ROOT}/Makefile.system
+
+modName := $(shell basename `pwd` )
+modName := $(shell echo ${modName} | cut -c 1 | tr '[:lower:]' '[:upper:]' )$(shell echo ${modName} | cut -c 2- ) 
+
+mod = ${PROJECT}_${modName}
+includes = ${PROJECT}/${modName}
+
+SRCS = $(wildcard *.c)
+HDRS = $(wildcard *.h)
+
+packages = STGERMAIN PETSC MPI XML
+EXTERNAL_LIBS = -lStG_FEM
+
+include ${PROJ_ROOT}/Makefile.vmake

Modified: long/3D/Gale/trunk/src/StgFEM/plugins/StandardConditionFunctions/StandardConditionFunctions.c
===================================================================
--- long/3D/Gale/trunk/src/StgFEM/plugins/StandardConditionFunctions/StandardConditionFunctions.c	2006-06-28 09:59:25 UTC (rev 3898)
+++ long/3D/Gale/trunk/src/StgFEM/plugins/StandardConditionFunctions/StandardConditionFunctions.c	2006-06-28 10:01:38 UTC (rev 3899)
@@ -42,6 +42,7 @@
 #include <mpi.h>
 #include <StGermain/StGermain.h>
 #include <StG_FEM/StG_FEM.h>
+#include <assert.h>
 #include "StandardConditionFunctions.h"
 
 const Type StG_FEM_StandardConditionFunctions_Type = "StG_FEM_StandardConditionFunctions";
@@ -83,6 +84,11 @@
 
 	condFunc = ConditionFunction_New( StG_FEM_StandardConditionFunctions_AnalyticalTemperatureIC, "AnalyticalTemperatureIC" );
 	ConditionFunction_Register_Add( context->condFunc_Register, condFunc );
+	condFunc = ConditionFunction_New( Stg_FEM_VelicTemperatureIC, "VelicTemperatureIC");
+	ConditionFunction_Register_Add( context->condFunc_Register, condFunc );
+	condFunc = ConditionFunction_New( Stg_FEM_VelicTemperatureIC_SolB, "VelicTemperatureIC_SolB");
+	ConditionFunction_Register_Add( context->condFunc_Register, condFunc );
+	
 	condFunc = ConditionFunction_New( StG_FEM_StandardConditionFunctions_SinusoidalExtension, "SinusoidalExtension");
 	ConditionFunction_Register_Add( context->condFunc_Register, condFunc );
 
@@ -357,18 +363,46 @@
 
 
 void StG_FEM_StandardConditionFunctions_LinearWithSinusoidalPerturbation( Node_LocalIndex node_lI, Variable_Index var_I, void* _context, void* _result ) {
-	DiscretisationContext*	context            = (DiscretisationContext*)_context;
-	FeVariable*             feVariable         = NULL;
-	FiniteElement_Mesh*     mesh               = NULL;
-	double*                 result             = (double*) _result;
+	DiscretisationContext*	context = (DiscretisationContext*)_context;
+	Dictionary*             dictionary         = context->dictionary;
+	FeVariable*             feVariable = NULL;
+	FiniteElement_Mesh*     mesh = NULL;
+	BlockGeometry*          geometry = NULL;
+	double*                 result = (double*) _result;
+	double                  topLayerBC;
+	double                  bottomLayerBC;
+	double                  perturbationAmplitude;
+	double                  horizontalWaveNumber;
+	double                  verticalWaveNumber;
+	double                  scaleFactor;
 	double*                 coord;
+	Dimension_Index         dim_I=0;
+	Coord                   relScaledCoord;
 	
 	feVariable = (FeVariable*)FieldVariable_Register_GetByName( context->fieldVariable_Register, "TemperatureField" );
 	mesh       = feVariable->feMesh;
+	geometry = (BlockGeometry*)mesh->layout->elementLayout->geometry;
 
+	topLayerBC = Dictionary_GetDouble_WithDefault( dictionary, "SinusoidalTempIC_TopLayerBC", 0.0 );
+	bottomLayerBC = Dictionary_GetDouble_WithDefault( dictionary, "SinusoidalTempIC_BottomLayerBC", 1.0 );
+	scaleFactor = bottomLayerBC - topLayerBC;
+	perturbationAmplitude = Dictionary_GetDouble_WithDefault( dictionary, "SinusoidalTempIC_PerturbationAmplitude", 0.1 );
+	/* Note: these are both multiplied by pi, so wavenumber = 1 means the perturbation goes from 0 to pi, which is
+	 * half a full sin or cos cycle. Wavenumber = 3 means the range is 0 -> 3pi, or 1 and a half full cycles. */
+	horizontalWaveNumber = Dictionary_GetDouble_WithDefault( dictionary, "SinusoidalTempIC_HorizontalWaveNumber", 1.0 );
+	verticalWaveNumber = Dictionary_GetDouble_WithDefault( dictionary, "SinusoidalTempIC_VerticalWaveNumber", 1.0 );
+
 	coord = Mesh_CoordAt( mesh, node_lI );
+	/* make coord relative to box bottom left corner, then scale from 0 to 1 between box min & max */
+	for ( dim_I = 0; dim_I < 3; dim_I++ ) {
+		relScaledCoord[dim_I] = ( coord[dim_I] - geometry->min[dim_I] )
+			/ (geometry->max[dim_I] - geometry->min[dim_I]);
+	}
 
-	*result = ( 1.0 - coord[ J_AXIS ] ) + 0.1 * cos( M_PI * coord[ I_AXIS ] ) * sin( M_PI * coord[ J_AXIS ]  );
+	/* Note: ok to use the 1.0 below since we've already scaled the coord to somewhere between 0 to 1 */
+	*result = topLayerBC + scaleFactor * ( 1.0 - relScaledCoord[ J_AXIS ] )
+			+ perturbationAmplitude * ( cos( horizontalWaveNumber * M_PI * coord[ I_AXIS ] )
+							* sin( verticalWaveNumber * M_PI * coord[ J_AXIS ] ) );
 }
 
 void StG_FEM_StandardConditionFunctions_Trigonometry( Node_LocalIndex node_lI, Variable_Index var_I, void* _context, void* _result ) {
@@ -392,6 +426,84 @@
 	*result = 1.0 - 0.5 * M_PI * coord[ J_AXIS ] * sin( M_PI * coord[ I_AXIS ]/width );
 }
 
+#define SMALL 1.0e-5
+void Stg_FEM_VelicTemperatureIC( Node_LocalIndex node_lI, Variable_Index var_I, void* _context, void* _result ) {
+	DiscretisationContext*  context            = (DiscretisationContext*)_context;
+	FeVariable*             temperatureField   = (FeVariable*) FieldVariable_Register_GetByName( context->fieldVariable_Register, "TemperatureField" );
+	FiniteElement_Mesh*     mesh               = temperatureField->feMesh;
+	BlockGeometry*          geometry           = (BlockGeometry*) mesh->layout->elementLayout->geometry;
+	Dictionary*             dictionary         = context->dictionary;
+	double*                 result             = (double*) _result;
+	double*                 coord;
+	double                  x; 
+	double                  y;
+	double                  kx;
+	double                  ky;
+	int                     wavenumberX;
+	int                     wavenumberY;
+	double                  L;
+	
+	/* Find coordinate of node */
+	coord = Mesh_CoordAt( mesh, node_lI );
+
+	/* Make sure that the box has right dimensions */
+	assert( ( geometry->max[ J_AXIS ] - geometry->min[ J_AXIS ] - 1.0 ) < SMALL );
+	L = geometry->max[ I_AXIS ] - geometry->min[ I_AXIS ];
+
+	x = coord[ I_AXIS ] - geometry->min[ I_AXIS ];
+	y = coord[ J_AXIS ] - geometry->min[ J_AXIS ];
+
+	wavenumberX = Dictionary_GetInt_WithDefault( dictionary, "wavenumberX", 1 );
+	wavenumberY = Dictionary_GetInt_WithDefault( dictionary, "wavenumberY", 1 );
+
+	kx = wavenumberX * M_PI/ L;
+	ky = wavenumberY * M_PI;
+
+	*result = sin( ky * y ) * cos( kx * x );
+}
+
+/* IC from Mirko Velic. This is the IC temperature for his solB, from his Analytic Suite. Added 22-May-2006 */
+void Stg_FEM_VelicTemperatureIC_SolB( Node_LocalIndex node_lI, Variable_Index var_I, void* _context, void* _result ) {
+	DiscretisationContext*  context            = (DiscretisationContext*)_context;
+	FeVariable*             temperatureField   = (FeVariable*) FieldVariable_Register_GetByName( context->fieldVariable_Register, "TemperatureField" );
+	FiniteElement_Mesh*     mesh               = temperatureField->feMesh;
+	BlockGeometry*          geometry           = (BlockGeometry*) mesh->layout->elementLayout->geometry;
+	Dictionary*             dictionary         = context->dictionary;
+	double*                 result             = (double*) _result;
+	double*                 coord;
+	double                  x; 
+	double                  y;
+	double                  km; // for y-direction
+	double                  kn; // for x-direction
+	double                  wavenumberX;
+	double                  wavenumberY;
+	double                  L;
+	double                  sigma;
+	
+	/* Find coordinate of node */
+	coord = Mesh_CoordAt( mesh, node_lI );
+
+	/* Make sure that the box has right dimensions */
+	assert( ( geometry->max[ J_AXIS ] - geometry->min[ J_AXIS ] - 1.0 ) < SMALL );
+	L = geometry->max[ I_AXIS ] - geometry->min[ I_AXIS ];
+
+	x = coord[ I_AXIS ] - geometry->min[ I_AXIS ];
+	y = coord[ J_AXIS ] - geometry->min[ J_AXIS ];
+
+	wavenumberX = 1.0; //Dictionary_GetInt_WithDefault( dictionary, "wavenumberX", 2 );
+	wavenumberY = 2.0; //Dictionary_GetInt_WithDefault( dictionary, "wavenumberY", 1 );
+	assert( wavenumberX != wavenumberY );
+	sigma = Dictionary_GetDouble_WithDefault( dictionary, "sigma", 1.0 );
+
+	kn = wavenumberX * M_PI / L;
+	km = wavenumberY * M_PI / L;
+
+	*result = 1 * sigma * sinh( km * y ) * cos( kn * x );
+//	printf("%0.7f %0.7f %0.7f\twaveX = %g waveY = %g M_PIi = %f L = %f \nsigma = %f kn = %g km = %g \n",x,y,*result,wavenumberX,wavenumberY, M_PI, L, sigma, kn, km);
+//	printf("%0.7f %0.7f %0.7f\n",x,y,*result);
+}
+
+
 /* Initial Condition derived from Boundary Layer theory -
 taken from P. E. van Keken, S. D. King, U. R. Schmeling, U. R. Christensen, D. Neumeister, and M.-P. Doin. A comparison of methods for the modeling of thermochemical convection. Journal of Geophysical Research, 102(B10):22477-22496, october 1997. */
 void StG_FEM_StandardConditionFunctions_AnalyticalTemperatureIC( Node_LocalIndex node_lI, Variable_Index var_I, void* _context, void* _result ) {

Modified: long/3D/Gale/trunk/src/StgFEM/plugins/StandardConditionFunctions/StandardConditionFunctions.h
===================================================================
--- long/3D/Gale/trunk/src/StgFEM/plugins/StandardConditionFunctions/StandardConditionFunctions.h	2006-06-28 09:59:25 UTC (rev 3898)
+++ long/3D/Gale/trunk/src/StgFEM/plugins/StandardConditionFunctions/StandardConditionFunctions.h	2006-06-28 10:01:38 UTC (rev 3899)
@@ -72,6 +72,8 @@
 void StG_FEM_StandardConditionFunctions_TemperatureCosineHill( Node_LocalIndex node_lI, Variable_Index var_I, void* _context, void* _result ) ;
 void StG_FEM_StandardConditionFunctions_LinearWithSinusoidalPerturbation( Node_LocalIndex node_lI, Variable_Index var_I, void* _context, void* _result ) ;
 void StG_FEM_StandardConditionFunctions_Trigonometry( Node_LocalIndex node_lI, Variable_Index var_I, void* _context, void* _result ) ;
+void Stg_FEM_VelicTemperatureIC( Node_LocalIndex node_lI, Variable_Index var_I, void* _context, void* _result ) ;
+void Stg_FEM_VelicTemperatureIC_SolB( Node_LocalIndex node_lI, Variable_Index var_I, void* _context, void* _result ) ;
 void StG_FEM_StandardConditionFunctions_AnalyticalTemperatureIC( Node_LocalIndex node_lI, Variable_Index var_I, void* _context, void* _result ) ;
 void StG_FEM_StandardConditionFunctions_SinusoidalExtension( Node_LocalIndex node_lI, Variable_Index var_I, void* _context, void* _result ) ;
 

Added: long/3D/Gale/trunk/src/StgFEM/plugins/VelicAnalyticSolutions/Velic_solA/makefile
===================================================================
--- long/3D/Gale/trunk/src/StgFEM/plugins/VelicAnalyticSolutions/Velic_solA/makefile	2006-06-28 09:59:25 UTC (rev 3898)
+++ long/3D/Gale/trunk/src/StgFEM/plugins/VelicAnalyticSolutions/Velic_solA/makefile	2006-06-28 10:01:38 UTC (rev 3899)
@@ -0,0 +1,59 @@
+##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+##
+## Copyright (C), 2003-2006, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street,
+##	Melbourne, 3053, Australia.
+##
+## Primary Contributing Organisations:
+##	Victorian Partnership for Advanced Computing Ltd, Computational Software Development - http://csd.vpac.org
+##	Australian Computational Earth Systems Simulator - http://www.access.edu.au
+##	Monash Cluster Computing - http://www.mcc.monash.edu.au
+##	Computational Infrastructure for Geodynamics - http://www.geodynamics.org
+##
+## Contributors:
+##	Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
+##	Robert Turnbull, Research Assistant, Monash University. (robert.turnbull at sci.monash.edu.au)
+##	Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
+##	David May, PhD Student, Monash University (david.may at sci.monash.edu.au)
+##	Louis Moresi, Associate Professor, Monash University. (louis.moresi at sci.monash.edu.au)
+##	Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
+##	Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
+##	Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
+##	Julian Giordani, Research Assistant, Monash University. (julian.giordani at sci.monash.edu.au)
+##	Vincent Lemiale, Postdoctoral Fellow, Monash University. (vincent.lemiale at sci.monash.edu.au)
+##
+##  This library is free software; you can redistribute it and/or
+##  modify it under the terms of the GNU Lesser General Public
+##  License as published by the Free Software Foundation; either
+##  version 2.1 of the License, or (at your option) any later version.
+##
+##  This library is distributed in the hope that it will be useful,
+##  but WITHOUT ANY WARRANTY; without even the implied warranty of
+##  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+##  Lesser General Public License for more details.
+##
+##  You should have received a copy of the GNU Lesser General Public
+##  License along with this library; if not, write to the Free Software
+##  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+##
+## $Id: makefile 535 2006-04-11 13:07:34Z PatrickSunter $
+##
+##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+SHELL := $(shell which bash)
+PROJ_ROOT := $(shell until test -r ./Makefile.system ; do cd .. ; done ; echo `pwd`)
+
+include ${PROJ_ROOT}/Makefile.system
+
+modName := $(shell basename `pwd` )
+modName := $(shell echo ${modName} | cut -c 1 | tr '[:lower:]' '[:upper:]' )$(shell echo ${modName} | cut -c 2- ) 
+
+mod = ${modName}
+includes = ${PROJECT}/${modName}
+
+SRCS = $(wildcard *.c)
+HDRS = $(wildcard *.h)
+
+packages = STGERMAIN PETSC MPI XML
+EXTERNAL_LIBS = -lStG_FEM
+
+include ${PROJ_ROOT}/Makefile.vmake

Added: long/3D/Gale/trunk/src/StgFEM/plugins/VelicAnalyticSolutions/Velic_solA/solA.c
===================================================================
--- long/3D/Gale/trunk/src/StgFEM/plugins/VelicAnalyticSolutions/Velic_solA/solA.c	2006-06-28 09:59:25 UTC (rev 3898)
+++ long/3D/Gale/trunk/src/StgFEM/plugins/VelicAnalyticSolutions/Velic_solA/solA.c	2006-06-28 10:01:38 UTC (rev 3899)
@@ -0,0 +1,362 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+** 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:
+*+		Mirko Velic
+*+		Julian Giordani
+*+		Robert Turnbull
+*+		Vincent Lemiale
+*+		Louis Moresi
+*+		David May
+*+		David Stegman
+*+		Patrick Sunter
+** $Id$
+**
+**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+
+#include <mpi.h>
+#include <StGermain/StGermain.h>
+#include <StG_FEM/StG_FEM.h>
+
+const Type Velic_solA_Type = "Velic_solA";
+
+typedef struct {
+	__AnalyticSolution
+	double sigma;
+	double Z;
+} Velic_solA;
+
+
+double Calculate__C1 ( Velic_solA* self, double x, double z, double y, double n ) {
+	double t1, t3, t4, t5, t10, t17, t21, t24;
+	double sigma = self->sigma;
+	double Z = self->Z;
+	double km = M_PI;
+	double kn = n * M_PI;
+
+	t1 = sin(km);
+	t3 = kn * kn;
+	t4 = exp(-kn);
+	t5 = t4 * t4;
+	t10 = km * km;
+	t17 = pow(t10 + t3, 0.2e1);
+	t21 = pow(t4 - 0.1e1, 0.2e1);
+	t24 = pow(t4 + 0.1e1, 0.2e1);
+
+	return t1 * sigma * (t3 * t5 + t3 - 0.2e1 * kn * t5 + 0.2e1 * kn + t10 * t5 + t10) * t4 / Z / t17 / t21 / t24 / 0.2e1;
+}
+
+double Calculate__C2 ( Velic_solA* self, double x, double z, double y, double n ) {
+	double t1, t3, t4, t5, t10, t16, t20, t23;
+	double sigma = self->sigma;
+	double Z = self->Z;
+	double km = M_PI;
+
+	double kn = n * M_PI;
+
+	t1 = sin(km);
+	t3 = kn * kn;
+	t4 = exp(-kn);
+	t5 = t4 * t4;
+	t10 = km * km;
+	t16 = pow(t10 + t3, 0.2e1);
+	t20 = pow(t4 - 0.1e1, 0.2e1);
+	t23 = pow(t4 + 0.1e1, 0.2e1);
+
+	return -t1 * sigma * (t3 * t5 + t3 - 0.2e1 * kn * t5 + 0.2e1 * kn + t10 * t5 + t10) / Z / t16 / t20 / t23 / 0.2e1;
+}
+
+double Calculate__C3 ( Velic_solA* self, double x, double z, double y, double n ) {
+	double t1, t3, t6, t7;
+	double sigma = self->sigma;
+	double Z = self->Z;
+	double km = M_PI;
+
+	double kn = n * M_PI;
+
+	t1 = sin(km);
+	t3 = exp(-kn);
+	t6 = km * km;
+	t7 = kn * kn;
+
+	return -t1 * sigma * t3 / Z / (t6 + t7) / (t3 - 0.1e1) / (t3 + 0.1e1) / 0.2e1;
+}
+
+double Calculate__C4 ( Velic_solA* self, double x, double z, double y, double n ) {
+	double t1, t5, t6, t9;
+	double sigma = self->sigma;
+	double Z = self->Z;
+	double km = M_PI;
+
+	double kn = n * M_PI;
+
+	t1 = sin(km);
+	t5 = km * km;
+	t6 = kn * kn;
+	t9 = exp(-kn);
+
+	return -t1 * sigma / Z / (t5 + t6) / (t9 - 0.1e1) / (t9 + 0.1e1) / 0.2e1;
+}
+
+double Calculate_ss ( Velic_solA* self, double x, double z, double y, double n ) {
+	double t4, t10, t14, t15, t16, t18;
+	double sigma = self->sigma;
+	double Z = self->Z;
+	double km = M_PI;
+
+	double kn = n * M_PI;
+
+	t4 = exp(-kn * z);
+	t10 = exp(kn * (z - 0.1e1));
+	t14 = sin(km * z);
+	t15 = km * km;
+	t16 = kn * kn;
+	t18 = pow(t15 + t16, 0.2e1);
+
+	return (Calculate__C1( self, x, z, y, n ) + z * Calculate__C3( self, x, z, y, n )) * t4 + (Calculate__C2( self, x, z, y, n ) + z * Calculate__C4( self, x, z, y, n )) * t10 + kn * sigma * t14 / t18 / Z;
+}
+
+double Calculate_ss_z ( Velic_solA* self, double x, double z, double y, double n ) {
+	double t6, t14, t18, t20, t21, t23;
+	double sigma = self->sigma;
+	double Z = self->Z;
+	double km = M_PI;
+
+	double kn = n * M_PI;
+
+	t6 = exp(-kn * z);
+	t14 = exp(kn * (z - 0.1e1));
+	t18 = cos(km * z);
+	t20 = km * km;
+	t21 = kn * kn;
+	t23 = pow(t20 + t21, 0.2e1);
+
+	return (-(Calculate__C1( self, x, z, y, n ) + z * Calculate__C3( self, x, z, y, n )) * kn + Calculate__C3( self, x, z, y, n )) * t6 + (Calculate__C4( self, x, z, y, n ) + (Calculate__C2( self, x, z, y, n ) + z * Calculate__C4( self, x, z, y, n )) * kn) * t14 + kn * sigma * t18 * km / t23 / Z;
+}
+
+double Calculate_ss_zz ( Velic_solA* self, double x, double z, double y, double n ) {
+	double t3, t9, t19, t23, t25, t27;
+	double sigma = self->sigma;
+	double Z = self->Z;
+	double km = M_PI;
+
+	double kn = n * M_PI;
+
+	t3 = kn * kn;
+	t9 = exp(-kn * z);
+	t19 = exp(kn * (z - 0.1e1));
+	t23 = sin(km * z);
+	t25 = km * km;
+	t27 = pow(t25 + t3, 0.2e1);
+
+	return ((Calculate__C1( self, x, z, y, n ) + z * Calculate__C3( self, x, z, y, n )) * t3 - 0.2e1 * Calculate__C3( self, x, z, y, n ) * kn) * t9 + (0.2e1 * Calculate__C4( self, x, z, y, n ) * kn + (Calculate__C2( self, x, z, y, n ) + z * Calculate__C4( self, x, z, y, n )) * t3) * t19 - kn * sigma * t23 * t25 / t27 / Z;
+}
+
+double Calculate_ss_zzz ( Velic_solA* self, double x, double z, double y, double n ) {
+	double t3, t4, t10, t20, t24, t26, t29;
+	double sigma = self->sigma;
+	double Z = self->Z;
+	double km = M_PI;
+
+	double kn = n * M_PI;
+
+	t3 = kn * kn;
+	t4 = t3 * kn;
+	t10 = exp(-kn * z);
+	t20 = exp(kn * (z - 0.1e1));
+	t24 = cos(km * z);
+	t26 = km * km;
+	t29 = pow(t26 + t3, 0.2e1);
+
+	return (-(Calculate__C1( self, x, z, y, n ) + z * Calculate__C3( self, x, z, y, n )) * t4 + 0.3e1 * Calculate__C3( self, x, z, y, n ) * t3) * t10 + (0.3e1 * Calculate__C4( self, x, z, y, n ) * t3 + (Calculate__C2( self, x, z, y, n ) + z * Calculate__C4( self, x, z, y, n )) * t4) * t20 - kn * sigma * t24 * t26 * km / t29 / Z;
+}
+
+
+
+
+void Velic_solA_PressureFunction( void* analyticSolution, FeVariable* analyticFeVariable, double* coord, double* pressure ) {
+	Velic_solA* self = (Velic_solA*) analyticSolution;
+	double x    = coord[ I_AXIS ];
+	double z    = coord[ J_AXIS ];
+	double y    = coord[ K_AXIS ];
+	double n    = 1;
+	double kn   = n * M_PI;
+	double ss_zzz, ss_z, pp;
+
+	ss_zzz = Calculate_ss_zzz( self, x, z, y, n );
+	ss_z   = Calculate_ss_z( self, x, z, y, n );
+	pp     = self->Z*(ss_zzz-kn*kn*ss_z)/kn;
+	
+	*pressure = pp * cos(kn * x);
+}
+
+void Velic_solA_VelocityFunction( void* analyticSolution, FeVariable* analyticFeVariable, double* coord, double* velocity ) {
+	Velic_solA* self = (Velic_solA*) analyticSolution;
+	double x    = coord[ I_AXIS ];
+	double z    = coord[ J_AXIS ];
+	double y    = coord[ K_AXIS ];
+	double n    = 1;
+	double u1, u2;
+
+
+	u1 = n * M_PI * Calculate_ss( self, x, z, y, n );
+	u2 = -Calculate_ss_z( self, x, z, y, n );
+
+	u1 *= cos( n * M_PI * x );
+	u2 *= sin( n * M_PI * x );
+
+	velocity[ I_AXIS ] = u2;
+	velocity[ J_AXIS ] = u1;
+	if ( analyticFeVariable->dim == 3 ) 
+		velocity[ K_AXIS ] = 0.0;
+}
+
+void Velic_solA_StressFunction( void* analyticSolution, FeVariable* analyticFeVariable, double* coord, double* stress ) {
+	Velic_solA* self = (Velic_solA*) analyticSolution;
+	double x    = coord[ I_AXIS ];
+	double z    = coord[ J_AXIS ];
+	double y    = coord[ K_AXIS ];
+	double n    = 1;
+	double kn   = n * M_PI;
+	double pp, txx, txz, tzz;
+	double ss_zzz, ss_z, ss;
+
+	ss_zzz = Calculate_ss_zzz( self, x, z, y, n );
+	ss_z   = Calculate_ss_z( self, x, z, y, n );
+	ss     = Calculate_ss( self, x, z, y, n );
+	
+	pp  = self->Z*(ss_zzz-kn*kn*ss_z)/kn;
+	tzz = 2.0*kn*ss_z - pp;
+	txz = -self->Z*(ss_zzz + kn*kn*ss);
+	txx = -2.0*self->Z*kn*ss_z - pp;
+
+	tzz *= cos(n*M_PI*x);
+	txz *= sin(n*M_PI*x);
+	txx *= cos(n*M_PI*x);
+
+	stress[ 0 ] = txx;
+	stress[ 1 ] = tzz;
+	if ( analyticFeVariable->dim == 2 ) {
+		stress[ 2 ] = txz;
+	}
+	else { 
+		stress[ 2 ] = 0.0;
+		stress[ 3 ] = txz;
+		stress[ 4 ] = 0.0;
+		stress[ 5 ] = 0.0;
+	}
+}
+
+
+void Velic_solA_StrainRateFunction( void* analyticSolution, FeVariable* analyticFeVariable, double* coord, double* strainRate ) {
+	Velic_solA* self = (Velic_solA*) analyticSolution;
+	double x    = coord[ I_AXIS ];
+	double z    = coord[ J_AXIS ];
+	double y    = coord[ K_AXIS ];
+	double n    = 1;
+	double kn   = n * M_PI;
+	double e_xx, e_xz, e_zz;
+	double ss_zz, ss_z, ss;
+
+	ss_zz = Calculate_ss_zz( self, x, z, y, n );
+	ss_z   = Calculate_ss_z( self, x, z, y, n );
+	ss     = Calculate_ss( self, x, z, y, n );
+	
+	e_zz = kn*ss_z*cos(kn*x);  /* zz rate of strain */
+	e_xx = -e_zz;  /* xx rate of strain */
+	e_xz = -0.5*(ss_zz+kn*kn*ss)*sin(kn*x); /* xz rate of strain */
+
+	strainRate[ 0 ] = e_xx;
+	strainRate[ 1 ] = e_zz;
+	if ( analyticFeVariable->dim == 2 ) {
+		strainRate[ 2 ] = e_xz;
+	}
+	else { 
+		strainRate[ 2 ] = 0.0;
+		strainRate[ 3 ] = e_xz;
+		strainRate[ 4 ] = 0.0;
+		strainRate[ 5 ] = 0.0;
+	}
+}
+
+void _Velic_solA_Construct( void* analyticSolution, Stg_ComponentFactory* cf ) {
+	Velic_solA* self = (Velic_solA*) analyticSolution;
+	FeVariable*              velocityField;
+	FeVariable*              pressureField;
+	FeVariable*              stressField;
+	FeVariable*              strainRateField;
+	FeVariable*              recoverdStrainRateField;
+
+	/* Construct Parent */
+	_AnalyticSolution_Construct( self, cf );
+
+	/* Create Analytic Fields */
+	velocityField = Stg_ComponentFactory_ConstructByName( cf, "VelocityField", FeVariable, True );
+	AnalyticSolution_CreateAnalyticVectorField( self, velocityField, Velic_solA_VelocityFunction );
+
+	pressureField = Stg_ComponentFactory_ConstructByName( cf, "PressureField", FeVariable, True );
+	AnalyticSolution_CreateAnalyticField( self, pressureField, Velic_solA_PressureFunction );
+
+	stressField = Stg_ComponentFactory_ConstructByName( cf, "StressField", FeVariable, False );
+	if ( stressField )
+		AnalyticSolution_CreateAnalyticSymmetricTensorField( self, stressField, Velic_solA_StressFunction );
+
+	strainRateField = Stg_ComponentFactory_ConstructByName( cf, "StrainRateField", FeVariable, False );
+	if ( strainRateField  ) {
+		AnalyticSolution_CreateAnalyticSymmetricTensorField( self, strainRateField, Velic_solA_StrainRateFunction );
+	}
+
+	recoverdStrainRateField = Stg_ComponentFactory_ConstructByName( cf, "recoveredStrainRate", FeVariable, False );
+	if ( recoverdStrainRateField )
+		AnalyticSolution_CreateAnalyticSymmetricTensorField( self, recoverdStrainRateField, Velic_solA_StrainRateFunction );
+
+	self->sigma = Stg_ComponentFactory_GetRootDictDouble( cf, "sigma", 1.0 );
+	self->Z = Stg_ComponentFactory_GetRootDictDouble( cf, "Z", 1.0 );
+}
+
+void* _Velic_solA_DefaultNew( Name name ) {
+	return _AnalyticSolution_New(
+			sizeof(Velic_solA),
+			Velic_solA_Type,
+			_AnalyticSolution_Delete,
+			_AnalyticSolution_Print,
+			_AnalyticSolution_Copy,
+			_Velic_solA_DefaultNew,
+			_Velic_solA_Construct,
+			_AnalyticSolution_Build,
+			_AnalyticSolution_Initialise,
+			_AnalyticSolution_Execute,
+			_AnalyticSolution_Destroy,
+			name );
+}
+
+Index _Velic_solA_Register( PluginsManager* pluginsManager ) {
+	return PluginsManager_Submit( pluginsManager, Velic_solA_Type, "0", _Velic_solA_DefaultNew );
+}


Property changes on: long/3D/Gale/trunk/src/StgFEM/plugins/VelicAnalyticSolutions/Velic_solA/solA.c
___________________________________________________________________
Name: svn:keywords
   + LastChangedDate Author Id
Name: svn:eol-style
   + native

Added: long/3D/Gale/trunk/src/StgFEM/plugins/VelicAnalyticSolutions/Velic_solA/solA.tex
===================================================================
--- long/3D/Gale/trunk/src/StgFEM/plugins/VelicAnalyticSolutions/Velic_solA/solA.tex	2006-06-28 09:59:25 UTC (rev 3898)
+++ long/3D/Gale/trunk/src/StgFEM/plugins/VelicAnalyticSolutions/Velic_solA/solA.tex	2006-06-28 10:01:38 UTC (rev 3899)
@@ -0,0 +1,30 @@
+\documentclass{article}
+\usepackage{rotating}
+\usepackage{epsfig}
+\usepackage{sidecap}
+\usepackage{bm}
+\oddsidemargin=-1cm
+\evensidemargin=1cm
+\textwidth=17cm
+
+\topmargin=-1.0cm
+\textheight=23.5cm
+\parindent=0cm
+
+\newcommand\fontB{\usefont{T1}{phvv}{b}{n}}
+\DeclareTextFontCommand{\textfontB}{\fontB}
+
+
+\begin{document}
+  \begin{center} 
+    {\Large \fontB Stokes' Flow Analytic Solution: (solA)}
+  \end{center}
+  
+  \input ../Doc/eqs_common.tex
+
+  \input solA_main.tex
+   
+
+\end{document}
+
+

Added: long/3D/Gale/trunk/src/StgFEM/plugins/VelicAnalyticSolutions/Velic_solA/solA_main.tex
===================================================================
--- long/3D/Gale/trunk/src/StgFEM/plugins/VelicAnalyticSolutions/Velic_solA/solA_main.tex	2006-06-28 09:59:25 UTC (rev 3898)
+++ long/3D/Gale/trunk/src/StgFEM/plugins/VelicAnalyticSolutions/Velic_solA/solA_main.tex	2006-06-28 10:01:38 UTC (rev 3899)
@@ -0,0 +1,36 @@
+  {\large \fontB Description:}
+  
+  {\bf solA} is a 2-dimensional analytical solution to the Cauchy equations with the acceleration term set to zero
+  to represent creeping flow. The boundary conditions are free-slip everywhere on a unit domain. The viscosity is constant.
+  The flow is driven by a temperature field represented by the density, $\rho$, as follows:
+  \begin{equation}
+    \rho = -\sigma \sin (k_m z) \cos (k_n x).
+  \end{equation}
+
+ {\large \fontB Parameters:}
+  
+ The variable parameters of this solution are:
+ \begin{itemize}
+   \item{density/temperature parameter: $ \sigma $.}
+   \item{wave number in z domain: $ k_m = m\pi{z} $. ($m$ may be non-integral)}
+   \item{wave number in x domain: $ k_n = n\pi{x} $. ($n$ must be integral)}
+   \item{constant viscosity: $\eta$.}
+ \end{itemize}
+
+  \begin{SCfigure}[][h]
+    \includegraphics[width=6cm,clip]{../figs/figA.eps}
+    \caption[Short caption]{\label{figA} 
+      Solution ({\bf SolA}):
+      This solution has a box of density $\rho = -\sigma \sin (k_m z) \cos (k_n x)$ .
+      It is isoviscous.
+      The Boundary conditions are free slip everywhere on the surfaces of the unit box.}
+  \end{SCfigure} 
+  \vspace{-47mm}
+  {\small
+  \[
+    \hspace{-77mm} \rho = -\sigma \sin (k_m z) \cos (k_n x)
+  \]
+  }
+  \vspace{47mm}
+  
+

Added: long/3D/Gale/trunk/src/StgFEM/plugins/VelicAnalyticSolutions/Velic_solB/makefile
===================================================================
--- long/3D/Gale/trunk/src/StgFEM/plugins/VelicAnalyticSolutions/Velic_solB/makefile	2006-06-28 09:59:25 UTC (rev 3898)
+++ long/3D/Gale/trunk/src/StgFEM/plugins/VelicAnalyticSolutions/Velic_solB/makefile	2006-06-28 10:01:38 UTC (rev 3899)
@@ -0,0 +1,59 @@
+##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+##
+## Copyright (C), 2003-2006, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street,
+##	Melbourne, 3053, Australia.
+##
+## Primary Contributing Organisations:
+##	Victorian Partnership for Advanced Computing Ltd, Computational Software Development - http://csd.vpac.org
+##	Australian Computational Earth Systems Simulator - http://www.access.edu.au
+##	Monash Cluster Computing - http://www.mcc.monash.edu.au
+##	Computational Infrastructure for Geodynamics - http://www.geodynamics.org
+##
+## Contributors:
+##	Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
+##	Robert Turnbull, Research Assistant, Monash University. (robert.turnbull at sci.monash.edu.au)
+##	Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
+##	David May, PhD Student, Monash University (david.may at sci.monash.edu.au)
+##	Louis Moresi, Associate Professor, Monash University. (louis.moresi at sci.monash.edu.au)
+##	Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
+##	Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
+##	Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
+##	Julian Giordani, Research Assistant, Monash University. (julian.giordani at sci.monash.edu.au)
+##	Vincent Lemiale, Postdoctoral Fellow, Monash University. (vincent.lemiale at sci.monash.edu.au)
+##
+##  This library is free software; you can redistribute it and/or
+##  modify it under the terms of the GNU Lesser General Public
+##  License as published by the Free Software Foundation; either
+##  version 2.1 of the License, or (at your option) any later version.
+##
+##  This library is distributed in the hope that it will be useful,
+##  but WITHOUT ANY WARRANTY; without even the implied warranty of
+##  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+##  Lesser General Public License for more details.
+##
+##  You should have received a copy of the GNU Lesser General Public
+##  License along with this library; if not, write to the Free Software
+##  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+##
+## $Id: makefile 535 2006-04-11 13:07:34Z PatrickSunter $
+##
+##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+SHELL := $(shell which bash)
+PROJ_ROOT := $(shell until test -r ./Makefile.system ; do cd .. ; done ; echo `pwd`)
+
+include ${PROJ_ROOT}/Makefile.system
+
+modName := $(shell basename `pwd` )
+modName := $(shell echo ${modName} | cut -c 1 | tr '[:lower:]' '[:upper:]' )$(shell echo ${modName} | cut -c 2- ) 
+
+mod = ${modName}
+includes = ${PROJECT}/${modName}
+
+SRCS = $(wildcard *.c)
+HDRS = $(wildcard *.h)
+
+packages = STGERMAIN PETSC MPI XML
+EXTERNAL_LIBS = -lStG_FEM
+
+include ${PROJ_ROOT}/Makefile.vmake

Added: long/3D/Gale/trunk/src/StgFEM/plugins/VelicAnalyticSolutions/Velic_solB/solB.c
===================================================================
--- long/3D/Gale/trunk/src/StgFEM/plugins/VelicAnalyticSolutions/Velic_solB/solB.c	2006-06-28 09:59:25 UTC (rev 3898)
+++ long/3D/Gale/trunk/src/StgFEM/plugins/VelicAnalyticSolutions/Velic_solB/solB.c	2006-06-28 10:01:38 UTC (rev 3899)
@@ -0,0 +1,331 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+** 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:
+*+		Mirko Velic
+*+		Julian Giordani
+*+		Robert Turnbull
+*+		Vincent Lemiale
+*+		Louis Moresi
+*+		David May
+*+		David Stegman
+*+		Patrick Sunter
+** $Id: solA.c 565 2006-05-19 02:33:01Z RobertTurnbull $
+**
+**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+
+#include <mpi.h>
+#include <StGermain/StGermain.h>
+#include <StG_FEM/StG_FEM.h>
+#include <assert.h>
+
+const Type Velic_solB_Type = "Velic_solB";
+
+typedef struct {
+	__AnalyticSolution
+	double sigma;
+	double Z;
+	int waveNum_n;
+	double waveNum_m;
+} Velic_solB;
+
+
+double Calculate__C1 ( Velic_solB* self, double x, double z, double y ) {
+	double t1, t5, t6, t7, t12, t22, t26, t29, t33;
+	double sigma = self->sigma;
+	double Z = self->Z;
+	double km = self->waveNum_m * M_PI;
+	double kn = self->waveNum_n * M_PI;
+
+	t1 = exp(km);
+	t5 = kn * kn;
+	t6 = exp(-kn);
+	t7 = t6 * t6;
+	t12 = km * km;
+	t22 = pow(-0.1e1 + t6, 0.2e1);
+	t26 = pow(t6 + 0.1e1, 0.2e1);
+	t29 = pow(kn - km, 0.2e1);
+	t33 = pow(kn + km, 0.2e1);
+	return sigma * (-0.1e1 + t1) * (t1 + 0.1e1) * (t5 * t7 + t5 + 0.2e1 * kn - 0.2e1 * kn * t7 - t12 * t7 - t12) * t6 / Z / t1 / t22 / t26 / t29 / t33 / 0.4e1;
+}
+
+double Calculate__C2 ( Velic_solB* self, double x, double z, double y ) {
+	double t1, t2, t3, t8, t11, t21, t25, t28, t32; 
+	double sigma = self->sigma;
+	double Z = self->Z;
+	double km = self->waveNum_m * M_PI;
+	double kn = self->waveNum_n * M_PI;
+
+	t1 = kn * kn;
+	t2 = exp(-kn);
+	t3 = t2 * t2;
+	t8 = km * km;
+	t11 = exp(km);
+	t21 = pow(-0.1e1 + t2, 0.2e1);
+	t25 = pow(t2 + 0.1e1, 0.2e1);
+	t28 = pow(kn - km, 0.2e1);
+	t32 = pow(kn + km, 0.2e1);
+	return -(t1 * t3 + t1 + 0.2e1 * kn - 0.2e1 * kn * t3 - t8 * t3 - t8) * (t11 + 0.1e1) * (-0.1e1 + t11) * sigma / Z / t11 / t21 / t25 / t28 / t32 / 0.4e1;
+
+}
+
+double Calculate__C3 ( Velic_solB* self, double x, double z, double y ) {
+	double t1, t5;
+	double sigma = self->sigma;
+	double Z = self->Z;
+	double km = self->waveNum_m * M_PI;
+	double kn = self->waveNum_n * M_PI;
+
+	t1 = exp(km);
+	t5 = exp(-kn);
+	return -sigma * (-0.1e1 + t1) * (t1 + 0.1e1) * t5 / Z / t1 / (-0.1e1 + t5) / (t5 + 0.1e1) / (kn - km) / (kn + km) / 0.4e1;
+}
+
+double Calculate__C4 ( Velic_solB* self, double x, double z, double y ) {
+	double t1, t9;
+	double sigma = self->sigma;
+	double Z = self->Z;
+	double km = self->waveNum_m * M_PI;
+	double kn = self->waveNum_n * M_PI;
+
+	t1 = exp(km);
+	t9 = exp(-kn);
+	return -(t1 + 0.1e1) * (-0.1e1 + t1) * sigma / Z / t1 / (-0.1e1 + t9) / (t9 + 0.1e1) / (kn - km) / (kn + km) / 0.4e1;
+}
+
+double Calculate_ss ( Velic_solB* self, double x, double z, double y ) {
+	double t4, t10, t14, t15, t16, t18;
+	double sigma = self->sigma;
+	double Z = self->Z;
+	double km = self->waveNum_m * M_PI;
+	double kn = self->waveNum_n * M_PI;
+
+	t4 = exp(-kn * z);
+	t10 = exp(kn * (z - 0.1e1));
+	t14 = sinh(km * z);
+	t15 = km * km;
+	t16 = kn * kn;
+	t18 = pow(t15 - t16, 0.2e1);
+	return (Calculate__C1( self, x, z, y) + z * Calculate__C3( self, x, z, y)) * t4 + (Calculate__C2( self, x, z, y) + z * Calculate__C4( self, x, z, y )) * t10 + kn * sigma * t14 / t18 / Z;
+	
+}
+
+double Calculate_ss_z ( Velic_solB* self, double x, double z, double y ) {
+	double t6, t14, t18, t20, t21, t23;
+	double sigma = self->sigma;
+	double Z = self->Z;
+	double km = self->waveNum_m * M_PI;
+	double kn = self->waveNum_n * M_PI;
+
+	t6 = exp(-kn * z);
+	t14 = exp(kn * (z - 0.1e1));
+	t18 = cosh(km * z);
+	t20 = km * km;
+	t21 = kn * kn;
+	t23 = pow(t20 - t21, 0.2e1);
+	return (-(Calculate__C1( self, x, z, y ) + z * Calculate__C3( self, x, z, y )) * kn + Calculate__C3( self, x, z, y )) * t6 + (Calculate__C4( self, x, z, y ) + (Calculate__C2( self, x, z, y ) + z * Calculate__C4( self, x, z, y )) * kn) * t14 + kn * sigma * t18 * km / t23 / Z;
+	
+}
+
+double Calculate_ss_zz ( Velic_solB* self, double x, double z, double y ) {
+	double t3, t9, t19, t23, t25, t27;
+	double sigma = self->sigma;
+	double Z = self->Z;
+	double km = self->waveNum_m * M_PI;
+	double kn = self->waveNum_n * M_PI;
+
+	t3 = kn * kn;
+	t9 = exp(-kn * z);
+	t19 = exp(kn * (z - 0.1e1));
+	t23 = sinh(km * z);
+	t25 = km * km;
+	t27 = pow(t25 - t3, 0.2e1);
+	return ((Calculate__C1( self, x, z, y ) + z * Calculate__C3( self, x, z, y )) * t3 - 0.2e1 * Calculate__C3( self, x, z, y ) * kn) * t9 + (0.2e1 * Calculate__C4( self, x, z, y ) * kn + (Calculate__C2( self, x, z, y ) + z * Calculate__C4( self, x, z, y )) * t3) * t19 + kn * sigma * t23 * t25 / t27 / Z;
+
+}
+
+double Calculate_ss_zzz ( Velic_solB* self, double x, double z, double y ) {
+	double t3, t4, t10, t20, t24, t26, t29;
+	double sigma = self->sigma;
+	double Z = self->Z;
+	double km = self->waveNum_m * M_PI;
+	double kn = self->waveNum_n * M_PI;
+
+	t3 = kn * kn;
+	t4 = t3 * kn;
+	t10 = exp(-kn * z);
+	t20 = exp(kn * (z - 0.1e1));
+	t24 = cosh(km * z);
+	t26 = km * km;
+	t29 = pow(t26 - t3, 0.2e1);
+	return (-(Calculate__C1( self, x, z, y ) + z * Calculate__C3( self, x, z, y )) * t4 + 0.3e1 * Calculate__C3( self, x, z, y ) * t3) * t10 + (0.3e1 * Calculate__C4( self, x, z, y ) * t3 + (Calculate__C2( self, x, z, y ) + z * Calculate__C4( self, x, z, y )) * t4) * t20 + kn * sigma * t24 * t26 * km / t29 / Z;
+}
+
+void Velic_solB_PressureFunction( void* analyticSolution, FeVariable* analyticFeVariable, double* coord, double* pressure ) {
+	Velic_solB* self = (Velic_solB*) analyticSolution;
+	double x    = coord[ I_AXIS ];
+	double z    = coord[ J_AXIS ];
+	double y    = coord[ K_AXIS ];
+	double n    = self->waveNum_n;
+	double kn   = n * M_PI;
+	double ss_zzz, ss_z, pp;
+
+	ss_zzz = Calculate_ss_zzz( self, x, z, y );
+	ss_z   = Calculate_ss_z( self, x, z, y );
+	pp     = self->Z*(ss_zzz-kn*kn*ss_z)/kn;
+
+	*pressure = pp * cos(kn * x);
+}
+
+void Velic_solB_VelocityFunction( void* analyticSolution, FeVariable* analyticFeVariable, double* coord, double* velocity ) {
+	Velic_solB* self = (Velic_solB*) analyticSolution;
+	double x    = coord[ I_AXIS ];
+	double z    = coord[ J_AXIS ];
+	double y    = coord[ K_AXIS ];
+	double n    = self->waveNum_n;
+	double u1, u2;
+
+
+	u1 = n * M_PI * Calculate_ss( self, x, z, y );
+	u2 = -Calculate_ss_z( self, x, z, y );
+
+	u1 *= cos( n * M_PI * x );
+	u2 *= sin( n * M_PI * x );
+
+	velocity[ I_AXIS ] = u2;
+	velocity[ J_AXIS ] = u1;
+	if ( analyticFeVariable->dim == 3 ) 
+		velocity[ K_AXIS ] = 0.0;
+}
+
+void Velic_solB_StressFunction( void* analyticSolution, FeVariable* analyticFeVariable, double* coord, double* stress ) {
+	Velic_solB* self = (Velic_solB*) analyticSolution;
+	double x    = coord[ I_AXIS ];
+	double z    = coord[ J_AXIS ];
+	double y    = coord[ K_AXIS ];
+	double n    = self->waveNum_n;
+	double Z    = self->Z;
+	double kn   = n * M_PI;
+	double pp, u3, u4, txx;
+	double ss_zzz, ss_z, ss;
+
+	ss_zzz      = Calculate_ss_zzz( self, x, z, y );
+	ss_z        = Calculate_ss_z( self, x, z, y );
+	ss          = Calculate_ss( self, x, z, y );
+
+	pp = Z*(ss_zzz-kn*kn*ss_z)/kn;
+	u3 = 2.0*Z*kn*ss_z - pp;
+	u4 = -Z*(ss_zzz + kn*kn*ss);
+	txx = -2.0*Z*kn*ss_z - pp;
+	 
+	stress[1] = u3 * cos(kn*x); /* zz stress */
+	stress[2] = u4 * sin(kn*x); /* zx stress */
+	stress[0] = txx * cos(kn*x); /* xx stress */
+	
+}
+void Velic_solB_StrainRateFunction( void* analyticSolution, FeVariable* analyticFeVariable, double* coord, double* strainRate ) {
+	Velic_solB* self = (Velic_solB*) analyticSolution;
+	double x    = coord[ I_AXIS ];
+	double z    = coord[ J_AXIS ];
+	double y    = coord[ K_AXIS ];
+	double n    = self->waveNum_n;
+	double kn   = n * M_PI;
+	double ss_zz, ss_z, ss;
+
+	ss_zz       = Calculate_ss_zz( self, x, z, y );
+	ss_z        = Calculate_ss_z( self, x, z, y );
+	ss          = Calculate_ss( self, x, z, y );
+
+	if( analyticFeVariable->dim == 2 ) {
+		strainRate[1] = kn*ss_z*cos(kn*x);                // zz 
+		strainRate[0] = -strainRate[1];                   // xx 
+		strainRate[2] = -0.5*(ss_zz+kn*kn*ss)*sin(kn*x); // xz 
+	}
+
+}
+	
+void _Velic_solB_Construct( void* analyticSolution, Stg_ComponentFactory* cf ) {
+	Velic_solB* self = (Velic_solB*) analyticSolution;
+	FeVariable*              velocityField;
+	FeVariable*              pressureField;
+	FeVariable*              stressField;
+	FeVariable*              strainRateField;
+	FeVariable*              recoverdStrainRateField;
+
+	/* Construct Parent */
+	_AnalyticSolution_Construct( self, cf );
+
+	/* Create Analytic Fields */
+	velocityField = Stg_ComponentFactory_ConstructByName( cf, "VelocityField", FeVariable, True );
+	AnalyticSolution_CreateAnalyticVectorField( self, velocityField, Velic_solB_VelocityFunction );
+
+	pressureField = Stg_ComponentFactory_ConstructByName( cf, "PressureField", FeVariable, True );
+	AnalyticSolution_CreateAnalyticField( self, pressureField, Velic_solB_PressureFunction );
+
+	stressField = Stg_ComponentFactory_ConstructByName( cf, "StressField", FeVariable, False );
+	if ( stressField )
+		AnalyticSolution_CreateAnalyticSymmetricTensorField( self, stressField, Velic_solB_StressFunction );
+
+	strainRateField = Stg_ComponentFactory_ConstructByName( cf, "StrainRateField", FeVariable, False );
+	if ( strainRateField  ) {
+		AnalyticSolution_CreateAnalyticSymmetricTensorField( self, strainRateField, Velic_solB_StrainRateFunction );
+	}
+
+	recoverdStrainRateField = Stg_ComponentFactory_ConstructByName( cf, "recoveredStrainRate", FeVariable, False );
+	if( recoverdStrainRateField ) {
+		AnalyticSolution_CreateAnalyticSymmetricTensorField( self, recoverdStrainRateField, Velic_solB_StrainRateFunction );
+	}
+
+	self->sigma = Stg_ComponentFactory_GetRootDictDouble( cf, "sigma", 1.0 );
+	self->Z = Stg_ComponentFactory_GetRootDictDouble( cf, "Z", 1.0 );
+	self->waveNum_n = Stg_ComponentFactory_GetRootDictInt( cf, "wavenumberX", 1 );
+	self->waveNum_m = Stg_ComponentFactory_GetRootDictDouble( cf, "wavenumberY", 2 );
+	assert( self->waveNum_n != self->waveNum_m );
+}
+
+void* _Velic_solB_DefaultNew( Name name ) {
+	return _AnalyticSolution_New(
+			sizeof(Velic_solB),
+			Velic_solB_Type,
+			_AnalyticSolution_Delete,
+			_AnalyticSolution_Print,
+			_AnalyticSolution_Copy,
+			_Velic_solB_DefaultNew,
+			_Velic_solB_Construct,
+			_AnalyticSolution_Build,
+			_AnalyticSolution_Initialise,
+			_AnalyticSolution_Execute,
+			_AnalyticSolution_Destroy,
+			name );
+}
+
+Index _Velic_solB_Register( PluginsManager* pluginsManager ) {
+	return PluginsManager_Submit( pluginsManager, Velic_solB_Type, "0", _Velic_solB_DefaultNew );
+}

Added: long/3D/Gale/trunk/src/StgFEM/plugins/VelicAnalyticSolutions/Velic_solB/solB.tex
===================================================================
--- long/3D/Gale/trunk/src/StgFEM/plugins/VelicAnalyticSolutions/Velic_solB/solB.tex	2006-06-28 09:59:25 UTC (rev 3898)
+++ long/3D/Gale/trunk/src/StgFEM/plugins/VelicAnalyticSolutions/Velic_solB/solB.tex	2006-06-28 10:01:38 UTC (rev 3899)
@@ -0,0 +1,30 @@
+\documentclass{article}
+\usepackage{rotating}
+\usepackage{epsfig}
+\usepackage{sidecap}
+\usepackage{bm}
+\oddsidemargin=-1cm
+\evensidemargin=1cm
+\textwidth=17cm
+
+\topmargin=-1.0cm
+\textheight=23.5cm
+\parindent=0cm
+
+\newcommand\fontB{\usefont{T1}{phvv}{b}{n}}
+\DeclareTextFontCommand{\textfontB}{\fontB}
+
+
+\begin{document}
+  \begin{center} 
+    {\Large \fontB Stokes' Flow Analytic Solution: (solB)}
+  \end{center}
+  
+  \input ../Doc/eqs_common.tex
+
+  \input solB_main.tex
+   
+
+\end{document}
+
+

Added: long/3D/Gale/trunk/src/StgFEM/plugins/VelicAnalyticSolutions/Velic_solB/solB_main.tex
===================================================================
--- long/3D/Gale/trunk/src/StgFEM/plugins/VelicAnalyticSolutions/Velic_solB/solB_main.tex	2006-06-28 09:59:25 UTC (rev 3898)
+++ long/3D/Gale/trunk/src/StgFEM/plugins/VelicAnalyticSolutions/Velic_solB/solB_main.tex	2006-06-28 10:01:38 UTC (rev 3899)
@@ -0,0 +1,36 @@
+  {\large \fontB Description:}
+  
+  {\bf solB} is a 2-dimensional analytical solution to the Cauchy equations with the acceleration term set to zero
+  to represent creeping flow. The boundary conditions are free-slip everywhere on a unit domain. The viscosity is constant.
+  The flow is driven by a temperature field represented by the density, $\rho$, as follows:
+  \begin{equation}
+    \rho = -\sigma \sinh (k_m z) \cos (k_n x).
+  \end{equation}
+
+ {\large \fontB Parameters:}
+  
+ The variable parameters of this solution are:
+ \begin{itemize}
+   \item{density/temperature parameter: $ \sigma $.}
+   \item{wave number in z domain: $ k_m = m\pi{z} $. ($m$ may be non-integral)}
+   \item{wave number in x domain: $ k_n = n\pi{x} $. ($n$ must be integral and not equal to $m$)}
+   \item{constant viscosity: $\eta$.}
+ \end{itemize}
+
+  \begin{SCfigure}[][h]
+    \includegraphics[width=6cm,clip]{../figs/figA.eps}
+    \caption[Short caption]{\label{figB} 
+      Solution ({\bf SolB}):
+      This solution has a box of density $\rho = -\sigma \sinh (k_m z) \cos (k_n x)$ .
+      It is isoviscous.
+      The Boundary conditions are free slip everywhere on the surfaces of the unit box.}
+  \end{SCfigure} 
+  \vspace{-47mm}
+  {\small
+  \[
+    \hspace{-77mm} \rho = -\sigma \sinh (k_m z) \cos (k_n x)
+  \]
+  }
+  \vspace{47mm}
+  
+

Added: long/3D/Gale/trunk/src/StgFEM/plugins/VelicAnalyticSolutions/Velic_solD/makefile
===================================================================
--- long/3D/Gale/trunk/src/StgFEM/plugins/VelicAnalyticSolutions/Velic_solD/makefile	2006-06-28 09:59:25 UTC (rev 3898)
+++ long/3D/Gale/trunk/src/StgFEM/plugins/VelicAnalyticSolutions/Velic_solD/makefile	2006-06-28 10:01:38 UTC (rev 3899)
@@ -0,0 +1,59 @@
+##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+##
+## Copyright (C), 2003-2006, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street,
+##	Melbourne, 3053, Australia.
+##
+## Primary Contributing Organisations:
+##	Victorian Partnership for Advanced Computing Ltd, Computational Software Development - http://csd.vpac.org
+##	Australian Computational Earth Systems Simulator - http://www.access.edu.au
+##	Monash Cluster Computing - http://www.mcc.monash.edu.au
+##	Computational Infrastructure for Geodynamics - http://www.geodynamics.org
+##
+## Contributors:
+##	Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
+##	Robert Turnbull, Research Assistant, Monash University. (robert.turnbull at sci.monash.edu.au)
+##	Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
+##	David May, PhD Student, Monash University (david.may at sci.monash.edu.au)
+##	Louis Moresi, Associate Professor, Monash University. (louis.moresi at sci.monash.edu.au)
+##	Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
+##	Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
+##	Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
+##	Julian Giordani, Research Assistant, Monash University. (julian.giordani at sci.monash.edu.au)
+##	Vincent Lemiale, Postdoctoral Fellow, Monash University. (vincent.lemiale at sci.monash.edu.au)
+##
+##  This library is free software; you can redistribute it and/or
+##  modify it under the terms of the GNU Lesser General Public
+##  License as published by the Free Software Foundation; either
+##  version 2.1 of the License, or (at your option) any later version.
+##
+##  This library is distributed in the hope that it will be useful,
+##  but WITHOUT ANY WARRANTY; without even the implied warranty of
+##  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+##  Lesser General Public License for more details.
+##
+##  You should have received a copy of the GNU Lesser General Public
+##  License along with this library; if not, write to the Free Software
+##  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+##
+## $Id: makefile 535 2006-04-11 13:07:34Z PatrickSunter $
+##
+##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+SHELL := $(shell which bash)
+PROJ_ROOT := $(shell until test -r ./Makefile.system ; do cd .. ; done ; echo `pwd`)
+
+include ${PROJ_ROOT}/Makefile.system
+
+modName := $(shell basename `pwd` )
+modName := $(shell echo ${modName} | cut -c 1 | tr '[:lower:]' '[:upper:]' )$(shell echo ${modName} | cut -c 2- ) 
+
+mod = ${modName}
+includes = ${PROJECT}/${modName}
+
+SRCS = $(wildcard *.c)
+HDRS = $(wildcard *.h)
+
+packages = STGERMAIN PETSC MPI XML
+EXTERNAL_LIBS = -lStG_FEM
+
+include ${PROJ_ROOT}/Makefile.vmake

Added: long/3D/Gale/trunk/src/StgFEM/plugins/VelicAnalyticSolutions/Velic_solD/solD.c
===================================================================
--- long/3D/Gale/trunk/src/StgFEM/plugins/VelicAnalyticSolutions/Velic_solD/solD.c	2006-06-28 09:59:25 UTC (rev 3898)
+++ long/3D/Gale/trunk/src/StgFEM/plugins/VelicAnalyticSolutions/Velic_solD/solD.c	2006-06-28 10:01:38 UTC (rev 3899)
@@ -0,0 +1,1250 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+** 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:
+*+		Mirko Velic
+*+		Julian Giordani
+*+		Robert Turnbull
+*+		Vincent Lemiale
+*+		Louis Moresi
+*+		David May
+*+		David Stegman
+*+		Patrick Sunter
+** $Id$
+**
+**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+
+#include <mpi.h>
+#include <StGermain/StGermain.h>
+#include <StG_FEM/StG_FEM.h>
+
+const Type Velic_solD_Type = "Velic_solD";
+
+typedef struct {
+	__AnalyticSolution
+	double xc;
+	double sigma;
+	double ZA;
+	double ZB;
+	double zc;
+} Velic_solD;
+
+
+double Calculate__C1A ( Velic_solD* self, double x, double z, double y, double n ) {
+	double t1, t2, t3, t4, t5, t7, t11, t13, t14, t16, t18, t20, t25, t26, t27, t29, t30, t33, t34, t35, t37, t38, t40, t42, t43, t44, t45, t46, t48, t51, t52, t53, t55, t56, t57, t58, t59, t60, t61, t62, t63, t67, t73, t75, t76, t77, t79, t82, t83, t84, t85, t86, t87, t88, t89, t90, t91, t94, t99, t101, t102, t110, t113, t121, t123, t125, t126, t131, t133, t137, t141, t142, t143, t144, t145, t148, t151, t155, t156, t163, t164, t166, t167, t169, t172, t174, t176, t178, t179, t183, t197, t203, t210, t211, t215, t222, t225, t227, t238, t251;
+	double xc = self->xc;
+	double sigma = self->sigma;
+	double ZA = self->ZA;
+	double ZB = self->ZB;
+	double zc = self->zc;
+
+	double kn = n * M_PI;
+	double del_rho = 2.0*sigma*sin(kn*xc)/kn;
+	double del_rhoA = del_rho;
+	double del_rhoB = del_rho;
+
+	t1 = -ZB + ZA;
+	t2 = ZA * kn;
+	t3 = t2 * zc;
+	t4 = 0.2e1 * ZB;
+	t5 = kn * zc;
+	t7 = 0.2e1 * t5 * ZB;
+	t11 = exp(-0.3e1 * t5);
+	t13 = ZA + ZB;
+	t14 = t1 * t13;
+	t16 = pow(-0.1e1 + t5, 0.2e1);
+	t18 = kn * (-0.2e1 + zc);
+	t20 = exp(0.2e1 * t18);
+	t25 = zc - 0.1e1;
+	t26 = t13 * t25;
+	t27 = kn * t25;
+	t29 = exp(0.2e1 * t27);
+	t30 = t26 * t29;
+	t33 = kn * kn;
+	t34 = t33 * kn;
+	t35 = ZA * ZA;
+	t37 = zc * zc;
+	t38 = t37 * zc;
+	t40 = t34 * t37;
+	t42 = ZB * ZB;
+	t43 = t33 * t42;
+	t44 = t43 * t37;
+	t45 = 0.2e1 * t44;
+	t46 = t33 * t35;
+	t48 = 0.2e1 * t46 * zc;
+	t51 = 0.2e1 * t46 * t37;
+	t52 = ZA * ZB;
+	t53 = t33 * ZA;
+	t55 = t53 * t37 * ZB;
+	t56 = 0.4e1 * t55;
+	t57 = kn * t42;
+	t58 = ZB * zc;
+	t59 = t53 * t58;
+	t60 = 0.4e1 * t59;
+	t61 = t43 * zc;
+	t62 = 0.2e1 * t61;
+	t63 = t34 * ZA;
+	t67 = kn * t35;
+	t73 = t2 * t58;
+	t75 = t57 * zc;
+	t76 = t2 * ZB;
+	t77 = t34 * t35 * t38 - t40 * t35 - t45 + t48 - t40 * t42 - t51 + t52 + t56 - t57 - t60 + t62 - 0.2e1 * t63 * ZB * t38 + t67 * zc + 0.2e1 * t40 * t52 + t34 * t42 * t38 - t67 - 0.2e1 * t73 + t75 + t76;
+	t79 = exp(-0.2e1 * kn);
+	t82 = 0.6e1 * t55;
+	t83 = 0.2e1 * t52;
+	t84 = 0.4e1 * t44;
+	t85 = 0.3e1 * t73;
+	t86 = 0.4e1 * t57;
+	t87 = 0.2e1 * t76;
+	t88 = 0.4e1 * t61;
+	t89 = 0.6e1 * t59;
+	t90 = 0.4e1 * t75;
+	t91 = -t82 - t83 + t84 + t51 + t85 + t86 - t87 - t88 + t89 - t48 - t90;
+	t94 = exp(-kn * (zc + 0.2e1));
+	t99 = exp(-t5);
+	t101 = -t82 + t51 + t90 - t86 + t87 - t85 + t84 + t89 - t88 - t83 - t48;
+	t102 = exp(t18);
+	t110 = exp(kn * (0.3e1 * zc - 0.4e1));
+	t113 = exp(-0.2e1 * t5);
+	t121 = exp(kn * (zc - 0.4e1));
+	t123 = t1 * t1;
+	t125 = exp(0.4e1 * t27);
+	t126 = t123 * t125;
+	t131 = t1 * (-t3 + t4 - t7) * t11 + 0.2e1 * t14 * t16 * t20 + 0.8e1 * kn * t1 * t30 - 0.8e1 * t77 * t79 - 0.2e1 * t91 * t94 + t13 * (t3 - t4 - t7) * t99 + 0.2e1 * t101 * t102 + t1 * (-t3 - t4 - t7) * t110 - 0.2e1 * t14 * t16 * t113 + t13 * (t3 + t4 - t7) * t121 - 0.2e1 * t126 + 0.2e1 * t35 + 0.4e1 * t52 + 0.2e1 * t42;
+	t133 = ZA * del_rhoB;
+	t137 = exp(-0.3e1 * kn);
+	t141 = t33 * zc;
+	t142 = 0.2e1 * t141;
+	t143 = 0.4e1 * t5;
+	t144 = t33 * t37;
+	t145 = 0.2e1 * t144;
+	t148 = 0.2e1 * zc;
+	t151 = exp(-kn * (t148 + 0.1e1));
+	t155 = t133 * t5;
+	t156 = 0.2e1 * t133;
+	t163 = 0.3e1 * t2 * zc * del_rhoB * ZB;
+	t164 = t35 * del_rhoB;
+	t166 = 0.2e1 * t144 * t164;
+	t167 = t133 * ZB;
+	t169 = 0.2e1 * t141 * t167;
+	t172 = 0.2e1 * t133 * kn * ZB;
+	t174 = 0.2e1 * t164 * t5;
+	t176 = 0.2e1 * t144 * t167;
+	t178 = 0.2e1 * t141 * t164;
+	t179 = 0.2e1 * t164;
+	t183 = 0.3e1 * t155;
+	t197 = exp(kn * (t148 - 0.3e1));
+	t203 = exp(-kn);
+	t210 = t131 * del_rhoA - 0.2e1 * t133 * (-0.2e1 + kn) * t13 * t137 + 0.2e1 * t133 * (0.2e1 - t142 - t143 + t145 + kn) * t1 * t151 + t13 * (t155 + t156) * t99 + 0.2e1 * (-t163 + t166 + t169 + t172 + t174 - t176 - t178 + t179) * t102 + t1 * (-t156 + t183) * t11 - 0.2e1 * (-t176 + t163 + t166 - t174 - t172 - t178 + t179 + t169) * t94 + t13 * (-t156 + t155) * t121 - 0.2e1 * t133 * (-t142 + t143 + t145 + 0.2e1 - kn) * t1 * t197 - 0.2e1 * t133 * (0.2e1 + kn) * t13 * t203 + t1 * (t183 + t156) * t110;
+	t211 = t63 * zc;
+	t215 = exp(-t143);
+	t222 = t63 * t1;
+	t225 = t13 * t13;
+	t227 = exp(-0.4e1 * kn);
+	t238 = exp(-0.2e1 * kn * (zc + 0.1e1));
+	t251 = -0.8e1 * t211 * t14 * t20 - 0.2e1 * t53 * t123 * t215 + 0.8e1 * t211 * t14 * t113 + 0.8e1 * t222 * t30 + 0.2e1 * t53 * t225 * t227 + 0.16e2 * t53 * (-t62 + t60 - t48 - t52 + t45 + t51 - t56) * t79 - 0.8e1 * t222 * t26 * t238 - 0.2e1 * t53 * t126 + 0.2e1 * t33 * t35 * ZA + 0.2e1 * t53 * t42 + 0.4e1 * t46 * ZB;
+
+	return t210 / t251;
+}
+
+double Calculate__C2A ( Velic_solD* self, double x, double z, double y, double n ) {
+	double t1, t2, t3, t4, t5, t7, t11, t13, t14, t15, t17, t18, t19, t20, t22, t23, t24, t25, t26, t27, t28, t29, t30, t31, t32, t33, t34, t35, t36, t37, t38, t39, t40, t41, t43, t44, t45, t46, t48, t51, t53, t55, t59, t66, t67, t68, t69, t70, t71, t73, t75, t76, t79, t80, t83, t87, t90, t97, t99, t101, t107, t110, t112, t116, t118, t119, t126, t130, t132, t133, t134, t138, t139, t140, t142, t143, t144, t145, t146, t150, t154, t161, t162, t168, t175, t178, t179, t181, t183, t186, t187, t189, t191, t202, t206, t207, t211, t218, t223, t232, t246;
+	double xc = self->xc;
+	double sigma = self->sigma;
+	double ZA = self->ZA;
+	double ZB = self->ZB;
+	double zc = self->zc;
+
+	double kn = n * M_PI;
+	double del_rho = 2.0*sigma*sin(kn*xc)/kn;
+	double del_rhoA = del_rho;
+	double del_rhoB = del_rho;
+
+	t1 = -ZB + ZA;
+	t2 = ZA * kn;
+	t3 = t2 * zc;
+	t4 = 0.2e1 * ZB;
+	t5 = kn * zc;
+	t7 = 0.2e1 * t5 * ZB;
+	t11 = exp(-0.2e1 * t5);
+	t13 = kn * kn;
+	t14 = t13 * ZA;
+	t15 = zc * zc;
+	t17 = t14 * t15 * ZB;
+	t18 = 0.6e1 * t17;
+	t19 = ZA * ZA;
+	t20 = t13 * t19;
+	t22 = 0.2e1 * t20 * t15;
+	t23 = ZB * ZB;
+	t24 = kn * t23;
+	t25 = t24 * zc;
+	t26 = 0.4e1 * t25;
+	t27 = 0.4e1 * t24;
+	t28 = t2 * ZB;
+	t29 = 0.2e1 * t28;
+	t30 = zc * ZB;
+	t31 = t2 * t30;
+	t32 = 0.3e1 * t31;
+	t33 = t13 * t23;
+	t34 = t33 * t15;
+	t35 = 0.4e1 * t34;
+	t36 = t14 * t30;
+	t37 = 0.6e1 * t36;
+	t38 = t33 * zc;
+	t39 = 0.4e1 * t38;
+	t40 = ZA * ZB;
+	t41 = 0.2e1 * t40;
+	t43 = 0.2e1 * t20 * zc;
+	t44 = -t18 + t22 + t26 - t27 + t29 - t32 + t35 + t37 - t39 - t41 - t43;
+	t45 = zc - 0.1e1;
+	t46 = kn * t45;
+	t48 = exp(0.2e1 * t46);
+	t51 = t13 * kn;
+	t53 = t15 * zc;
+	t55 = t51 * t15;
+	t59 = t51 * ZA;
+	t66 = 0.4e1 * t17;
+	t67 = 0.4e1 * t36;
+	t68 = 0.2e1 * t34;
+	t69 = 0.2e1 * t38;
+	t70 = kn * t19;
+	t71 = t70 * zc;
+	t73 = t51 * t19 * t53 - t55 * t19 + 0.2e1 * t55 * t40 - 0.2e1 * t59 * ZB * t53 + t51 * t23 * t53 - t55 * t23 + t22 - t43 - t66 + t67 + t68 - t69 + t71 - t70 + t28 - 0.2e1 * t31 + t25 - t24 - t40;
+	t75 = kn * (-0.2e1 + zc);
+	t76 = exp(t75);
+	t79 = ZA + ZB;
+	t80 = t79 * t79;
+	t83 = exp(kn * (zc - 0.4e1));
+	t87 = t79 * t45;
+	t90 = exp(-kn * (zc + 0.2e1));
+	t97 = exp(0.2e1 * t75);
+	t99 = t1 * t1;
+	t101 = exp(-0.3e1 * t5);
+	t107 = exp(0.4e1 * t46);
+	t110 = -t18 - t41 + t35 + t22 + t32 + t27 - t29 - t39 + t37 - t43 - t26;
+	t112 = exp(-0.2e1 * kn);
+	t116 = t1 * t79;
+	t118 = pow(0.1e1 + t5, 0.2e1);
+	t119 = exp(-t5);
+	t126 = exp(kn * (0.3e1 * zc - 0.4e1));
+	t130 = -t1 * (-t3 + t4 - t7) * t11 - 0.2e1 * t44 * t48 + 0.8e1 * t73 * t76 + 0.2e1 * t80 * t83 - 0.8e1 * kn * t1 * t87 * t90 - t79 * (t3 + t4 - t7) * t97 - 0.2e1 * t99 * t101 - t71 + t31 - t1 * (-t3 - t4 - t7) * t107 + 0.2e1 * t23 + t41 + 0.2e1 * t110 * t112 + 0.2e1 * t25 + 0.2e1 * t116 * t118 * t119 - 0.2e1 * t116 * t118 * t126;
+	t132 = ZA * del_rhoB;
+	t133 = 0.2e1 * t132;
+	t134 = t132 * t5;
+	t138 = t19 * del_rhoB;
+	t139 = 0.2e1 * t138;
+	t140 = t132 * ZB;
+	t142 = t13 * zc;
+	t143 = 0.2e1 * t142;
+	t144 = 0.4e1 * t5;
+	t145 = t13 * t15;
+	t146 = 0.2e1 * t145;
+	t150 = exp(0.3e1 * t46);
+	t154 = 0.3e1 * t134;
+	t161 = kn * (zc + 0.1e1);
+	t162 = exp(-t161);
+	t168 = exp(t46);
+	t175 = t138 * t5;
+	t178 = t2 * zc * del_rhoB * ZB;
+	t179 = 0.3e1 * t178;
+	t181 = 0.2e1 * t145 * t138;
+	t183 = 0.2e1 * t142 * t140;
+	t186 = 0.2e1 * t132 * kn * ZB;
+	t187 = 0.2e1 * t175;
+	t189 = 0.2e1 * t145 * t140;
+	t191 = 0.2e1 * t142 * t138;
+	t202 = exp(kn * (zc - 0.3e1));
+	t206 = t130 * del_rhoA - t79 * (-t133 + t134) * t97 - t139 - 0.2e1 * t140 + 0.2e1 * t132 * (-t143 + t144 + t146 + 0.2e1 - kn) * t1 * t150 - t1 * (t154 + t133) * t107 - 0.2e1 * t132 * (0.2e1 - t143 - t144 + t146 + kn) * t1 * t162 + 0.2e1 * t132 * (0.2e1 + kn) * t79 * t168 - t1 * (-t133 + t154) * t11 - t175 - 0.2e1 * (-t179 + t181 + t183 + t186 + t187 - t189 - t191 + t139) * t48 - t178 + 0.2e1 * (-t189 + t179 + t181 - t187 - t186 - t191 + t139 + t183) * t112 + 0.2e1 * t132 * (-0.2e1 + kn) * t79 * t202;
+	t207 = t59 * zc;
+	t211 = exp(-t144);
+	t218 = t59 * t1;
+	t223 = exp(-0.4e1 * kn);
+	t232 = exp(-0.2e1 * t161);
+	t246 = -0.8e1 * t207 * t116 * t97 - 0.2e1 * t14 * t99 * t211 + 0.8e1 * t207 * t116 * t11 + 0.8e1 * t218 * t87 * t48 + 0.2e1 * t14 * t80 * t223 + 0.16e2 * t14 * (-t69 + t67 - t43 - t40 + t68 + t22 - t66) * t112 - 0.8e1 * t218 * t87 * t232 - 0.2e1 * t14 * t99 * t107 + 0.2e1 * t13 * t19 * ZA + 0.2e1 * t14 * t23 + 0.4e1 * t20 * ZB;
+
+	return t206 / t246;
+}
+
+double Calculate__C3A ( Velic_solD* self, double x, double z, double y, double n ) {
+	double t1, t2, t4, t5, t7, t10, t11, t12, t13, t15, t16, t19, t20, t21, t22, t24, t26, t27, t28, t30, t33, t34, t35, t37, t39, t40, t42, t44, t46, t48, t49, t51, t53, t54, t55, t56, t59, t60, t61, t62, t66, t67, t70, t72, t78, t80, t81, t82, t83, t85, t90, t95, t98, t100, t101, t103, t105, t108, t111, t116, t120, t126, t130, t133, t134, t136, t137, t138, t151, t160, t164, t165, t169, t173, t178, t187, t189, t206;
+	double xc = self->xc;
+	double sigma = self->sigma;
+	double ZA = self->ZA;
+	double ZB = self->ZB;
+	double zc = self->zc;
+
+	double kn = n * M_PI;
+	double del_rho = 2.0*sigma*sin(kn*xc)/kn;
+	double del_rhoA = del_rho;
+	double del_rhoB = del_rho;
+
+	t1 = -ZB + ZA;
+	t2 = 0.2e1 * ZB;
+	t4 = t1 * (-ZA - t2);
+	t5 = kn * zc;
+	t7 = exp(-0.3e1 * t5);
+	t10 = ZA + ZB;
+	t11 = zc - 0.1e1;
+	t12 = t10 * t11;
+	t13 = kn * t11;
+	t15 = exp(0.2e1 * t13);
+	t16 = t12 * t15;
+	t19 = kn * kn;
+	t20 = ZA * ZA;
+	t21 = t19 * t20;
+	t22 = zc * zc;
+	t24 = 0.2e1 * t21 * t22;
+	t26 = 0.2e1 * t21 * zc;
+	t27 = t19 * ZA;
+	t28 = zc * ZB;
+	t30 = 0.4e1 * t27 * t28;
+	t33 = 0.4e1 * t27 * t22 * ZB;
+	t34 = ZB * ZB;
+	t35 = t19 * t34;
+	t37 = 0.2e1 * t35 * t22;
+	t39 = 0.2e1 * t35 * zc;
+	t40 = kn * t20;
+	t42 = t40 * zc;
+	t44 = ZA * kn;
+	t46 = 0.6e1 * t44 * t28;
+	t48 = 0.6e1 * t44 * ZB;
+	t49 = kn * t34;
+	t51 = t49 * zc;
+	t53 = ZA * ZB;
+	t54 = t24 - t26 + t30 - t33 + t37 - t39 + 0.3e1 * t40 - 0.3e1 * t42 + t46 - t48 + 0.3e1 * t49 - 0.3e1 * t51 - t53;
+	t55 = 0.2e1 * kn;
+	t56 = exp(-t55);
+	t59 = t1 * t10;
+	t60 = 0.2e1 * t5;
+	t61 = t60 - 0.3e1;
+	t62 = exp(-t60);
+	t66 = t10 * (ZA - t2);
+	t67 = exp(-t5);
+	t70 = kn * (-0.2e1 + zc);
+	t72 = exp(0.2e1 * t70);
+	t78 = exp(kn * (0.3e1 * zc - 0.4e1));
+	t80 = 0.2e1 * t40;
+	t81 = 0.2e1 * t42;
+	t82 = 0.4e1 * t49;
+	t83 = 0.4e1 * t51;
+	t85 = exp(t70);
+	t90 = exp(kn * (zc - 0.4e1));
+	t95 = exp(-kn * (zc + 0.2e1));
+	t98 = t1 * t1;
+	t100 = exp(0.4e1 * t13);
+	t101 = t98 * t100;
+	t103 = -t4 * t7 + 0.4e1 * kn * t1 * t16 + 0.4e1 * t54 * t56 + t59 * t61 * t62 + t66 * t67 - t59 * t61 * t72 + t4 * t78 + 0.2e1 * (-t80 + t48 + t81 - t82 - t53 - t46 + t83) * t85 - t66 * t90 + 0.2e1 * (-t80 + t48 + t81 - t82 + t53 - t46 + t83) * t95 - t101 + t34 + t20 + 0.2e1 * t53;
+	t105 = ZA * del_rhoB;
+	t108 = 0.2e1 * zc;
+	t111 = exp(-kn * (t108 + 0.1e1));
+	t116 = exp(-0.3e1 * kn);
+	t120 = t1 * ZA;
+	t126 = 0.2e1 * del_rhoB * kn * t20;
+	t130 = 0.2e1 * t44 * zc * del_rhoB * ZB;
+	t133 = 0.2e1 * t105 * kn * ZB;
+	t134 = t20 * del_rhoB;
+	t136 = 0.2e1 * t134 * t5;
+	t137 = 0.2e1 * t134;
+	t138 = t105 * ZB;
+	t151 = exp(kn * (t108 - 0.3e1));
+	t160 = exp(-kn);
+	t164 = t103 * del_rhoA - 0.2e1 * t105 * t1 * (-0.3e1 - t55 + t60) * t111 + 0.2e1 * t105 * t10 * t116 + 0.3e1 * t120 * del_rhoB * t78 + 0.2e1 * (-t126 - t130 + t133 + t136 + t137 - t138) * t85 - t105 * t10 * t90 + 0.2e1 * (-t126 - t130 + t133 + t136 + t138 - t137) * t95 - 0.2e1 * t105 * t1 * (-t55 + 0.3e1 + t60) * t151 - 0.3e1 * t120 * del_rhoB * t7 + t105 * t10 * t67 - 0.2e1 * t105 * t10 * t160;
+	t165 = t27 * zc;
+	t169 = t27 * t1;
+	t173 = exp(-0.2e1 * kn * (zc + 0.1e1));
+	t178 = exp(-0.4e1 * t5);
+	t187 = t10 * t10;
+	t189 = exp(-0.4e1 * kn);
+	t206 = -0.8e1 * t165 * t59 * t72 - 0.8e1 * t169 * t12 * t173 - 0.2e1 * t44 * t98 * t178 + 0.8e1 * t165 * t59 * t62 + 0.8e1 * t169 * t16 + 0.2e1 * t44 * t187 * t189 + 0.16e2 * t44 * (-t39 + t30 - t26 - t53 + t37 + t24 - t33) * t56 - 0.2e1 * t44 * t101 + 0.4e1 * t40 * ZB + 0.2e1 * kn * t20 * ZA + 0.2e1 * t44 * t34;
+
+	return t164 / t206;
+}
+
+double Calculate__C4A ( Velic_solD* self, double x, double z, double y, double n ) {
+	double t1, t2, t3, t5, t6, t8, t9, t11, t12, t13, t15, t16, t18, t19, t21, t22, t25, t27, t28, t30, t32, t35, t36, t38, t39, t42, t43, t45, t46, t47, t48, t50, t51, t52, t53, t55, t56, t59, t61, t63, t67, t69, t70, t71, t74, t77, t82, t85, t86, t88, t93, t97, t100, t104, t106, t110, t111, t120, t126, t132, t136, t139, t140, t142, t143, t144, t148, t152, t162, t163, t167, t169, t174, t185, t203;
+	double xc = self->xc;
+	double sigma = self->sigma;
+	double ZA = self->ZA;
+	double ZB = self->ZB;
+	double zc = self->zc;
+
+	double kn = n * M_PI;
+	double del_rho = 2.0*sigma*sin(kn*xc)/kn;
+	double del_rhoA = del_rho;
+	double del_rhoB = del_rho;
+
+	t1 = ZB * ZB;
+	t2 = kn * t1;
+	t3 = t2 * zc;
+	t5 = ZA * ZA;
+	t6 = kn * t5;
+	t8 = kn * kn;
+	t9 = t8 * t1;
+	t11 = 0.2e1 * t9 * zc;
+	t12 = t8 * t5;
+	t13 = zc * zc;
+	t15 = 0.2e1 * t12 * t13;
+	t16 = ZA * ZB;
+	t18 = 0.2e1 * t12 * zc;
+	t19 = ZA * kn;
+	t21 = 0.6e1 * t19 * ZB;
+	t22 = t8 * ZA;
+	t25 = 0.4e1 * t22 * t13 * ZB;
+	t27 = 0.2e1 * t9 * t13;
+	t28 = zc * ZB;
+	t30 = 0.6e1 * t19 * t28;
+	t32 = t6 * zc;
+	t35 = 0.4e1 * t22 * t28;
+	t36 = 0.3e1 * t3 - 0.3e1 * t6 - t11 + t15 - t16 - t18 + t21 - t25 + t27 - t30 - 0.3e1 * t2 + 0.3e1 * t32 + t35;
+	t38 = kn * (-0.2e1 + zc);
+	t39 = exp(t38);
+	t42 = -ZB + ZA;
+	t43 = 0.2e1 * ZB;
+	t45 = t42 * (-ZA - t43);
+	t46 = kn * zc;
+	t47 = 0.2e1 * t46;
+	t48 = exp(-t47);
+	t50 = 0.2e1 * t6;
+	t51 = 0.2e1 * t32;
+	t52 = 0.4e1 * t2;
+	t53 = 0.4e1 * t3;
+	t55 = 0.2e1 * kn;
+	t56 = exp(-t55);
+	t59 = t42 * t42;
+	t61 = exp(-0.3e1 * t46);
+	t63 = ZA + ZB;
+	t67 = exp(0.2e1 * t38);
+	t69 = t42 * t63;
+	t70 = t47 + 0.3e1;
+	t71 = exp(-t46);
+	t74 = t63 * t63;
+	t77 = exp(kn * (zc - 0.4e1));
+	t82 = exp(kn * (0.3e1 * zc - 0.4e1));
+	t85 = zc - 0.1e1;
+	t86 = kn * t85;
+	t88 = exp(0.4e1 * t86);
+	t93 = exp(0.2e1 * t86);
+	t97 = t63 * t85;
+	t100 = exp(-kn * (zc + 0.2e1));
+	t104 = -0.4e1 * t36 * t39 - t45 * t48 + 0.2e1 * (-t50 + t21 + t51 - t52 + t16 - t30 + t53) * t56 + t59 * t61 - t63 * (ZA - t43) * t67 - t69 * t70 * t71 - t74 * t77 + t69 * t70 * t82 + t45 * t88 - t16 - 0.2e1 * t1 + t5 + 0.2e1 * (-t50 + t21 + t51 - t52 - t16 - t30 + t53) * t93 + 0.4e1 * kn * t42 * t97 * t100;
+	t106 = ZA * del_rhoB;
+	t110 = kn * (zc + 0.1e1);
+	t111 = exp(-t110);
+	t120 = exp(0.3e1 * t86);
+	t126 = exp(kn * (zc - 0.3e1));
+	t132 = 0.2e1 * del_rhoB * kn * t5;
+	t136 = 0.2e1 * t19 * zc * del_rhoB * ZB;
+	t139 = 0.2e1 * t106 * kn * ZB;
+	t140 = t5 * del_rhoB;
+	t142 = 0.2e1 * t140 * t46;
+	t143 = t106 * ZB;
+	t144 = 0.2e1 * t140;
+	t148 = exp(t86);
+	t152 = t42 * ZA;
+	t162 = t104 * del_rhoA - 0.2e1 * t106 * t42 * (-0.3e1 - t55 + t47) * t111 - t106 * t63 * t67 - 0.2e1 * t106 * t42 * (-t55 + 0.3e1 + t47) * t120 + 0.2e1 * t106 * t63 * t126 + 0.2e1 * (-t132 - t136 + t139 + t142 + t143 - t144) * t56 - 0.2e1 * t106 * t63 * t148 + t143 - 0.3e1 * t152 * del_rhoB * t48 + 0.2e1 * (-t132 - t136 + t139 + t142 + t144 - t143) * t93 + 0.3e1 * t152 * del_rhoB * t88 + t140;
+	t163 = t22 * zc;
+	t167 = t22 * t42;
+	t169 = exp(-0.2e1 * t110);
+	t174 = exp(-0.4e1 * t46);
+	t185 = exp(-0.4e1 * kn);
+	t203 = -0.8e1 * t163 * t69 * t67 - 0.8e1 * t167 * t97 * t169 - 0.2e1 * t19 * t59 * t174 + 0.8e1 * t163 * t69 * t48 + 0.8e1 * t167 * t97 * t93 + 0.2e1 * t19 * t74 * t185 + 0.16e2 * t19 * (-t11 + t35 - t18 - t16 + t27 + t15 - t25) * t56 - 0.2e1 * t19 * t59 * t88 + 0.4e1 * t6 * ZB + 0.2e1 * kn * t5 * ZA + 0.2e1 * t19 * t1;
+
+	return t162 / t203;
+}
+
+double Calculate__C1B ( Velic_solD* self, double x, double z, double y, double n ) {
+	double t1, t2, t3, t4, t6, t7, t8, t9, t10, t12, t14, t15, t16, t17, t18, t21, t22, t25, t35, t36, t37, t39, t40, t41, t43, t44, t47, t48, t51, t53, t54, t57, t58, t59, t60, t62, t63, t64, t67, t69, t70, t71, t72, t73, t74, t77, t78, t80, t82, t83, t85, t86, t87, t89, t90, t93, t94, t98, t100, t103, t107, t115, t122, t128, t134, t138, t141, t143, t144, t145, t153, t154, t159, t162, t165, t166, t167, t168, t170, t171, t172, t178, t180, t181, t186, t189, t196, t200, t210, t218, t219, t221, t225, t226, t228, t238, t239, t244, t267;
+	double xc = self->xc;
+	double sigma = self->sigma;
+	double ZA = self->ZA;
+	double ZB = self->ZB;
+	double zc = self->zc;
+
+	double kn = n * M_PI;
+	double del_rho = 2.0*sigma*sin(kn*xc)/kn;
+	double del_rhoA = del_rho;
+	double del_rhoB = del_rho;
+
+	t1 = ZA * kn;
+	t2 = t1 * ZB;
+	t3 = zc * ZB;
+	t4 = t1 * t3;
+	t6 = kn * kn;
+	t7 = ZB * ZB;
+	t8 = t6 * t7;
+	t9 = zc * zc;
+	t10 = t8 * t9;
+	t12 = ZA * ZA;
+	t14 = kn * t12 * zc;
+	t15 = 0.2e1 * t14;
+	t16 = t8 * zc;
+	t17 = t6 * kn;
+	t18 = t17 * t9;
+	t21 = kn * t7;
+	t22 = t21 * zc;
+	t25 = t9 * zc;
+	t35 = t6 * ZA;
+	t36 = t9 * ZB;
+	t37 = t35 * t36;
+	t39 = t6 * t12;
+	t40 = t39 * zc;
+	t41 = t35 * t3;
+	t43 = t39 * t9;
+	t44 = 0.4e1 * t43;
+	t47 = ZA * ZB;
+	t48 = 0.2e1 * t47;
+	t51 = t2 - 0.4e1 * t4 - 0.4e1 * t10 + t15 + t16 - 0.2e1 * t18 * t12 + 0.2e1 * t22 + 0.2e1 * t17 * t7 * t25 - 0.4e1 * t17 * ZA * ZB * t25 + 0.2e1 * t17 * t12 * t25 + 0.8e1 * t37 + t40 - 0.2e1 * t41 - t44 - 0.2e1 * t18 * t7 + t48 + 0.4e1 * t18 * t47;
+	t53 = kn * (zc + 0.1e1);
+	t54 = exp(-t53);
+	t57 = 0.6e1 * t37;
+	t58 = 0.2e1 * t10;
+	t59 = 0.4e1 * t14;
+	t60 = 0.3e1 * t4;
+	t62 = kn * zc;
+	t63 = 0.2e1 * t62;
+	t64 = exp(-t63);
+	t67 = -ZB + ZA;
+	t69 = 0.2e1 * t1 * zc;
+	t70 = 0.4e1 * t1;
+	t71 = 0.2e1 * ZA;
+	t72 = t62 * ZB;
+	t73 = kn * ZB;
+	t74 = 0.2e1 * t73;
+	t77 = zc - 0.1e1;
+	t78 = kn * t77;
+	t80 = exp(0.2e1 * t78);
+	t82 = ZA + ZB;
+	t83 = t67 * t82;
+	t85 = 0.2e1 * t6 * zc;
+	t86 = 0.4e1 * t62;
+	t87 = t6 * t9;
+	t89 = 0.2e1 - t85 - t86 + 0.2e1 * t87 + kn;
+	t90 = exp(t78);
+	t93 = t82 * t82;
+	t94 = -0.2e1 + kn;
+	t98 = exp(-kn * (0.3e1 + zc));
+	t100 = t67 * t67;
+	t103 = exp(0.3e1 * t78);
+	t107 = exp(-t86);
+	t115 = exp(-0.2e1 * kn);
+	t122 = exp(-kn * (0.3e1 * zc + 0.1e1));
+	t128 = exp(-0.2e1 * t53);
+	t134 = exp(kn * (zc - 0.3e1));
+	t138 = -0.4e1 * t51 * t54 - 0.2e1 * (-t57 + t58 - t59 + t60 + t44 - t48) * t64 + t67 * (t69 - t70 + t71 + t72 - t74) * t80 - t83 * t89 * t90 - t93 * t94 * t98 + t100 * t94 * t103 + t67 * (-t71 + t69 + t72) * t107 + 0.2e1 * (0.12e2 * t41 - t48 - t57 - 0.4e1 * t16 + t59 - t60 + t58 + t44 + 0.2e1 * t2 - 0.8e1 * t40) * t115 - t15 - t4 + 0.2e1 * t12 + t22 + t48 + t83 * t89 * t122 - t82 * (-t70 + t71 + t69 + t74 - t72) * t128 + 0.4e1 * t62 * t67 * t82 * t94 * t134;
+	t141 = del_rhoA * kn * ZB;
+	t143 = del_rhoA * ZB;
+	t144 = 0.2e1 * t143;
+	t145 = t62 * t143;
+	t153 = kn * (-0.2e1 + zc);
+	t154 = exp(t153);
+	t159 = t6 * del_rhoA;
+	t162 = del_rhoA * ZA;
+	t165 = zc * del_rhoA;
+	t166 = t21 * t165;
+	t167 = 0.2e1 * t166;
+	t168 = t159 * ZA;
+	t170 = 0.2e1 * t36 * t168;
+	t171 = t7 * del_rhoA;
+	t172 = 0.2e1 * t171;
+	t178 = 0.2e1 * t87 * t171;
+	t180 = t1 * t165 * ZB;
+	t181 = 0.3e1 * t180;
+	t186 = pow(-0.1e1 + t62, 0.2e1);
+	t189 = exp(-0.3e1 * t62);
+	t196 = 0.3e1 * t145;
+	t200 = exp(-t62);
+	t210 = exp(-kn * (zc + 0.2e1));
+	t218 = t138 * del_rhoB - t82 * (0.2e1 * t141 - t144 - t145) * t128 + 0.4e1 * t143 * (0.1e1 - 0.3e1 * kn + t87 - t85 + t63) * t67 * t154 + 0.2e1 * (-0.4e1 * t7 * zc * t159 + 0.2e1 * t162 * t73 + t167 - t170 + t172 + 0.4e1 * t3 * t168 - 0.4e1 * t21 * del_rhoA + t178 - t181) * t115 - 0.4e1 * t143 * t186 * t67 * t189 - 0.2e1 * (t181 + t172 - t170 - t167 + t178) * t64 + t67 * (-t196 + t144) * t107 + 0.4e1 * t143 * t82 * t200 - 0.2e1 * t162 * ZB + 0.4e1 * t143 * (kn - 0.1e1) * t82 * t210 + t166 + t67 * (0.6e1 * t141 - t196 - t144) * t80 + t180 - t172;
+	t219 = t6 * ZB;
+	t221 = exp(0.4e1 * t78);
+	t225 = t17 * ZB;
+	t226 = t225 * zc;
+	t228 = exp(0.2e1 * t153);
+	t238 = t225 * t67;
+	t239 = t82 * t77;
+	t244 = exp(-0.4e1 * kn);
+	t267 = -0.2e1 * t219 * t100 * t221 - 0.8e1 * t226 * t83 * t228 - 0.2e1 * t219 * t100 * t107 + 0.8e1 * t226 * t83 * t64 + 0.8e1 * t238 * t239 * t80 + 0.2e1 * t219 * t93 * t244 - 0.8e1 * t238 * t239 * t128 + 0.16e2 * t219 * (-0.2e1 * t16 + 0.4e1 * t41 - 0.2e1 * t40 - t47 + t58 + 0.2e1 * t43 - 0.4e1 * t37) * t115 + 0.4e1 * t35 * t7 + 0.2e1 * t39 * ZB + 0.2e1 * t6 * t7 * ZB;
+
+	return t218 / t267;
+}
+
+double Calculate__C2B ( Velic_solD* self, double x, double z, double y, double n ) {
+	double t1, t2, t3, t4, t5, t6, t7, t9, t10, t11, t13, t14, t15, t16, t17, t18, t19, t20, t22, t23, t24, t25, t26, t27, t28, t29, t30, t31, t34, t35, t38, t39, t41, t42, t43, t44, t45, t46, t49, t50, t51, t53, t55, t57, t58, t67, t69, t71, t72, t73, t75, t77, t80, t82, t84, t86, t89, t108, t111, t113, t117, t124, t129, t135, t140, t142, t143, t145, t147, t148, t152, t154, t155, t156, t158, t159, t161, t164, t165, t169, t172, t175, t180, t184, t188, t217, t221, t222, t224, t228, t229, t233, t243, t244, t248, t250, t273;
+	double xc = self->xc;
+	double sigma = self->sigma;
+	double ZA = self->ZA;
+	double ZB = self->ZB;
+	double zc = self->zc;
+
+	double kn = n * M_PI;
+	double del_rho = 2.0*sigma*sin(kn*xc)/kn;
+	double del_rhoA = del_rho;
+	double del_rhoB = del_rho;
+
+	t1 = kn * kn;
+	t2 = ZA * ZA;
+	t3 = t1 * t2;
+	t4 = zc * zc;
+	t5 = t3 * t4;
+	t6 = 0.4e1 * t5;
+	t7 = t3 * zc;
+	t9 = t1 * ZA;
+	t10 = zc * ZB;
+	t11 = t9 * t10;
+	t13 = t4 * ZB;
+	t14 = t9 * t13;
+	t15 = 0.6e1 * t14;
+	t16 = ZB * ZB;
+	t17 = t1 * t16;
+	t18 = t17 * t4;
+	t19 = 0.2e1 * t18;
+	t20 = t17 * zc;
+	t22 = kn * t2;
+	t23 = t22 * zc;
+	t24 = 0.4e1 * t23;
+	t25 = ZA * kn;
+	t26 = t25 * ZB;
+	t27 = 0.2e1 * t26;
+	t28 = t25 * t10;
+	t29 = 0.3e1 * t28;
+	t30 = ZA * ZB;
+	t31 = 0.2e1 * t30;
+	t34 = kn * (zc + 0.1e1);
+	t35 = exp(-t34);
+	t38 = ZA + ZB;
+	t39 = 0.2e1 * ZA;
+	t41 = 0.2e1 * t25 * zc;
+	t42 = 0.4e1 * t25;
+	t43 = kn * ZB;
+	t44 = 0.2e1 * t43;
+	t45 = kn * zc;
+	t46 = t45 * ZB;
+	t49 = zc - 0.1e1;
+	t50 = kn * t49;
+	t51 = exp(t50);
+	t53 = -ZB + ZA;
+	t55 = 0.2e1 + kn;
+	t57 = 0.2e1 * t45;
+	t58 = exp(-t57);
+	t67 = exp(-kn * (0.3e1 * zc + 0.1e1));
+	t69 = t53 * t38;
+	t71 = 0.2e1 * t1 * zc;
+	t72 = 0.4e1 * t45;
+	t73 = t1 * t4;
+	t75 = -t71 + t72 + 0.2e1 * t73 + 0.2e1 - kn;
+	t77 = exp(-0.2e1 * t34);
+	t80 = t53 * t53;
+	t82 = exp(-t72);
+	t84 = t1 * kn;
+	t86 = t4 * zc;
+	t89 = t84 * t4;
+	t108 = kn * t16;
+	t111 = 0.2e1 * t84 * t2 * t86 - 0.2e1 * t89 * t2 + 0.4e1 * t89 * t30 - 0.4e1 * t84 * ZA * ZB * t86 + 0.2e1 * t84 * t16 * t86 - 0.2e1 * t89 * t16 - t7 + t6 + 0.2e1 * t11 - 0.8e1 * t14 - t20 + 0.4e1 * t18 + 0.2e1 * t23 + t26 - 0.4e1 * t28 + 0.2e1 * t108 * zc - t31;
+	t113 = exp(-0.2e1 * kn);
+	t117 = exp(0.2e1 * t50);
+	t124 = exp(-kn * (0.3e1 + zc));
+	t129 = exp(kn * (zc - 0.3e1));
+	t135 = exp(0.3e1 * t50);
+	t140 = 0.2e1 * (t6 - 0.8e1 * t7 + 0.12e2 * t11 - t15 + t19 - 0.4e1 * t20 - t24 - t27 + t29 - t31) * t35 + t38 * (-t39 + t41 - t42 + t44 - t46) * t51 + 0.4e1 * t45 * t53 * t38 * t55 * t58 - t53 * (-t39 - t42 + t41 - t44 + t46) * t67 - t69 * t75 * t77 - t80 * t55 * t82 + 0.4e1 * t111 * t113 + t69 * t75 * t117 + t38 * (t41 + t39 - t46) * t124 - 0.2e1 * (t6 + t19 - t15 - t29 + t24 - t31) * t129 - t53 * (t39 + t46 + t41) * t135 + t27 + 0.2e1 * t16 + t108 + t22 + 0.4e1 * t30 + 0.2e1 * t2;
+	t142 = del_rhoA * ZB;
+	t143 = 0.2e1 * t142;
+	t145 = del_rhoA * kn * ZB;
+	t147 = t45 * t142;
+	t148 = 0.3e1 * t147;
+	t152 = t16 * del_rhoA;
+	t154 = 0.2e1 * t73 * t152;
+	t155 = t1 * del_rhoA;
+	t156 = t155 * ZA;
+	t158 = 0.2e1 * t13 * t156;
+	t159 = zc * del_rhoA;
+	t161 = 0.2e1 * t108 * t159;
+	t164 = 0.3e1 * t25 * t159 * ZB;
+	t165 = 0.2e1 * t152;
+	t169 = 0.3e1 * kn;
+	t172 = 0.2e1 * zc;
+	t175 = exp(-kn * (t172 + 0.1e1));
+	t180 = pow(0.1e1 + t45, 0.2e1);
+	t184 = exp(kn * (t172 - 0.3e1));
+	t188 = exp(-t169);
+	t217 = exp(-kn);
+	t221 = t140 * del_rhoB - t53 * (t143 + 0.6e1 * t145 - t148) * t67 - 0.2e1 * (t154 - t158 + t161 - t164 + t165) * t129 + 0.4e1 * t142 * (t169 - t57 + t73 - t71 + 0.1e1) * t53 * t175 - 0.4e1 * t142 * t180 * t53 * t184 + 0.4e1 * t142 * t38 * t188 + t38 * (0.2e1 * t145 + t143 - t147) * t51 - t53 * (-t148 - t143) * t135 + 0.2e1 * (0.4e1 * t10 * t156 - t158 + t154 - 0.4e1 * t16 * zc * t155 - 0.2e1 * del_rhoA * ZA * t43 + t164 + 0.4e1 * t108 * del_rhoA - t161 + t165) * t35 + t38 * (-t147 - t143) * t124 - 0.4e1 * t142 * (kn + 0.1e1) * t38 * t217;
+	t222 = t1 * ZB;
+	t224 = exp(0.4e1 * t50);
+	t228 = t84 * ZB;
+	t229 = t228 * zc;
+	t233 = exp(0.2e1 * kn * (-0.2e1 + zc));
+	t243 = t228 * t53;
+	t244 = t38 * t49;
+	t248 = t38 * t38;
+	t250 = exp(-0.4e1 * kn);
+	t273 = -0.2e1 * t222 * t80 * t224 - 0.8e1 * t229 * t69 * t233 - 0.2e1 * t222 * t80 * t82 + 0.8e1 * t229 * t69 * t58 + 0.8e1 * t243 * t244 * t117 + 0.2e1 * t222 * t248 * t250 - 0.8e1 * t243 * t244 * t77 + 0.16e2 * t222 * (-0.2e1 * t20 + 0.4e1 * t11 - 0.2e1 * t7 - t30 + t19 + 0.2e1 * t5 - 0.4e1 * t14) * t113 + 0.4e1 * t9 * t16 + 0.2e1 * t3 * ZB + 0.2e1 * t1 * t16 * ZB;
+
+	return t221 / t273;
+}
+
+double Calculate__C3B ( Velic_solD* self, double x, double z, double y, double n ) {
+	double t1, t2, t3, t4, t6, t8, t9, t10, t12, t15, t16, t17, t19, t21, t22, t23, t25, t27, t28, t29, t31, t34, t35, t38, t39, t41, t42, t43, t45, t47, t48, t50, t51, t52, t55, t59, t61, t64, t68, t69, t70, t76, t79, t81, t84, t87, t90, t93, t96, t98, t104, t105, t109, t112, t114, t115, t116, t118, t125, t132, t136, t142, t149, t150, t151, t153, t157, t159, t169, t170, t175, t193;
+	double xc = self->xc;
+	double sigma = self->sigma;
+	double ZA = self->ZA;
+	double ZB = self->ZB;
+	double zc = self->zc;
+
+	double kn = n * M_PI;
+	double del_rho = 2.0*sigma*sin(kn*xc)/kn;
+	double del_rhoA = del_rho;
+	double del_rhoB = del_rho;
+
+	t1 = kn * kn;
+	t2 = ZA * ZA;
+	t3 = t1 * t2;
+	t4 = zc * zc;
+	t6 = 0.2e1 * t3 * t4;
+	t8 = 0.2e1 * t3 * zc;
+	t9 = t1 * ZA;
+	t10 = zc * ZB;
+	t12 = 0.4e1 * t9 * t10;
+	t15 = 0.4e1 * t9 * t4 * ZB;
+	t16 = ZB * ZB;
+	t17 = t1 * t16;
+	t19 = 0.2e1 * t17 * t4;
+	t21 = 0.2e1 * t17 * zc;
+	t22 = kn * t16;
+	t23 = t22 * zc;
+	t25 = ZA * kn;
+	t27 = 0.6e1 * t25 * t10;
+	t28 = kn * t2;
+	t29 = t28 * zc;
+	t31 = ZA * ZB;
+	t34 = kn * (zc + 0.1e1);
+	t35 = exp(-t34);
+	t38 = -ZB + ZA;
+	t39 = 0.2e1 * ZA;
+	t41 = t38 * (t39 + ZB);
+	t42 = zc - 0.1e1;
+	t43 = kn * t42;
+	t45 = exp(0.2e1 * t43);
+	t47 = 0.4e1 * t29;
+	t48 = 0.2e1 * t23;
+	t50 = kn * zc;
+	t51 = 0.2e1 * t50;
+	t52 = exp(-t51);
+	t55 = ZA + ZB;
+	t59 = exp(-0.2e1 * t34);
+	t61 = t38 * t55;
+	t64 = exp(kn * (zc - 0.3e1));
+	t68 = 0.2e1 * kn;
+	t69 = -0.3e1 - t68 + t51;
+	t70 = exp(t43);
+	t76 = exp(-kn * (0.3e1 * zc + 0.1e1));
+	t79 = t38 * t38;
+	t81 = exp(0.3e1 * t43);
+	t84 = exp(-0.4e1 * t50);
+	t87 = exp(-t68);
+	t90 = t55 * t55;
+	t93 = exp(-kn * (0.3e1 + zc));
+	t96 = 0.4e1 * (t6 - t8 + t12 - t15 + t19 - t21 - 0.3e1 * t23 + t27 - 0.3e1 * t29 - t31) * t35 + t41 * t45 + 0.2e1 * (t47 - t27 + t48 + t31) * t52 - t55 * (t39 - ZB) * t59 - 0.4e1 * t50 * t61 * t64 + t61 * t69 * t70 - t61 * t69 * t76 - t79 * t81 - t41 * t84 + 0.2e1 * (t47 - t27 + t48 - t31) * t87 + t90 * t93 + 0.2e1 * t2 + t31 - t16;
+	t98 = del_rhoA * ZB;
+	t104 = kn * (-0.2e1 + zc);
+	t105 = exp(t104);
+	t109 = zc * del_rhoA;
+	t112 = 0.2e1 * t25 * t109 * ZB;
+	t114 = 0.2e1 * t22 * t109;
+	t115 = t16 * del_rhoA;
+	t116 = 0.2e1 * t115;
+	t118 = del_rhoA * ZA * ZB;
+	t125 = exp(-0.3e1 * t50);
+	t132 = t38 * del_rhoA;
+	t136 = exp(-t50);
+	t142 = exp(-kn * (zc + 0.2e1));
+	t149 = t96 * del_rhoB + t98 * t55 * t59 + 0.2e1 * t98 * t38 * (t51 + 0.3e1) * t105 + 0.2e1 * (-t112 + t114 + t116 - t118) * t87 + 0.2e1 * t98 * t38 * (t51 - 0.3e1) * t125 + 0.2e1 * (-t112 + t114 + t118 - t116) * t52 + 0.3e1 * t132 * ZB * t84 + 0.2e1 * t98 * t55 * t136 - 0.2e1 * t98 * t55 * t142 - t115 - 0.3e1 * t132 * ZB * t45 - t118;
+	t150 = t1 * ZB;
+	t151 = t150 * zc;
+	t153 = exp(0.2e1 * t104);
+	t157 = kn * ZB;
+	t159 = exp(0.4e1 * t43);
+	t169 = t150 * t38;
+	t170 = t55 * t42;
+	t175 = exp(-0.4e1 * kn);
+	t193 = -0.8e1 * t151 * t61 * t153 - 0.2e1 * t157 * t79 * t159 - 0.2e1 * t157 * t79 * t84 + 0.8e1 * t151 * t61 * t52 + 0.8e1 * t169 * t170 * t45 + 0.2e1 * t157 * t90 * t175 - 0.8e1 * t169 * t170 * t59 + 0.16e2 * t157 * (-t21 + t12 - t8 - t31 + t19 + t6 - t15) * t87 + 0.4e1 * t25 * t16 + 0.2e1 * kn * t16 * ZB + 0.2e1 * t28 * ZB;
+
+	return t149 / t193;
+}
+
+double Calculate__C4B ( Velic_solD* self, double x, double z, double y, double n ) {
+	double t1, t2, t3, t5, t6, t7, t8, t9, t10, t11, t14, t15, t16, t17, t18, t19, t21, t22, t23, t24, t25, t26, t30, t33, t34, t36, t38, t42, t45, t46, t48, t49, t50, t52, t55, t57, t59, t61, t64, t66, t69, t71, t72, t73, t74, t78, t81, t85, t88, t91, t95, t97, t101, t102, t107, t111, t114, t116, t118, t120, t131, t134, t144, t151, t152, t153, t157, t161, t163, t171, t172, t176, t178, t196;
+	double xc = self->xc;
+	double sigma = self->sigma;
+	double ZA = self->ZA;
+	double ZB = self->ZB;
+	double zc = self->zc;
+
+	double kn = n * M_PI;
+	double del_rho = 2.0*sigma*sin(kn*xc)/kn;
+	double del_rhoA = del_rho;
+	double del_rhoB = del_rho;
+
+	t1 = -ZB + ZA;
+	t2 = t1 * t1;
+	t3 = kn * zc;
+	t5 = exp(-0.4e1 * t3);
+	t6 = t2 * t5;
+	t7 = ZA + ZB;
+	t8 = t1 * t7;
+	t9 = 0.2e1 * t3;
+	t10 = exp(-t9);
+	t11 = t8 * t10;
+	t14 = ZA * ZA;
+	t15 = kn * t14;
+	t16 = t15 * zc;
+	t17 = 0.4e1 * t16;
+	t18 = ZA * kn;
+	t19 = zc * ZB;
+	t21 = 0.6e1 * t18 * t19;
+	t22 = ZB * ZB;
+	t23 = kn * t22;
+	t24 = t23 * zc;
+	t25 = 0.2e1 * t24;
+	t26 = ZA * ZB;
+	t30 = exp(kn * (zc - 0.3e1));
+	t33 = 0.2e1 * kn;
+	t34 = -t33 + 0.3e1 + t9;
+	t36 = kn * (zc + 0.1e1);
+	t38 = exp(-0.2e1 * t36);
+	t42 = exp(-t36);
+	t45 = kn * kn;
+	t46 = t45 * ZA;
+	t48 = 0.4e1 * t46 * t19;
+	t49 = t45 * t22;
+	t50 = zc * zc;
+	t52 = 0.2e1 * t49 * t50;
+	t55 = 0.2e1 * t49 * zc;
+	t57 = t45 * t14;
+	t59 = 0.2e1 * t57 * t50;
+	t61 = 0.2e1 * t57 * zc;
+	t64 = 0.4e1 * t46 * t50 * ZB;
+	t66 = exp(-t33);
+	t69 = 0.2e1 * ZA;
+	t71 = t7 * (t69 - ZB);
+	t72 = zc - 0.1e1;
+	t73 = kn * t72;
+	t74 = exp(t73);
+	t78 = exp(-kn * (0.3e1 + zc));
+	t81 = t1 * (t69 + ZB);
+	t85 = exp(-kn * (0.3e1 * zc + 0.1e1));
+	t88 = exp(0.3e1 * t73);
+	t91 = exp(0.2e1 * t73);
+	t95 = t6 - 0.4e1 * t3 * t11 + 0.2e1 * (t17 - t21 + t25 - t26) * t30 + t8 * t34 * t38 + 0.2e1 * (t17 - t21 + t25 + t26) * t42 - 0.4e1 * (t48 + t52 + 0.3e1 * t24 - t55 + 0.3e1 * t16 - t21 + t59 - t61 - t26 - t64) * t66 + t71 * t74 - t71 * t78 - t81 * t85 + t81 * t88 - t8 * t34 * t91 - t22 - 0.2e1 * t26 - t14;
+	t97 = t1 * del_rhoA;
+	t101 = del_rhoA * ZB;
+	t102 = exp(-kn);
+	t107 = exp(-0.3e1 * kn);
+	t111 = zc * del_rhoA;
+	t114 = 0.2e1 * t18 * t111 * ZB;
+	t116 = 0.2e1 * t23 * t111;
+	t118 = 0.2e1 * t22 * del_rhoA;
+	t120 = del_rhoA * ZA * ZB;
+	t131 = 0.2e1 * zc;
+	t134 = exp(-kn * (t131 + 0.1e1));
+	t144 = exp(kn * (t131 - 0.3e1));
+	t151 = t95 * del_rhoB + 0.3e1 * t97 * ZB * t85 + 0.2e1 * t101 * t7 * t102 - 0.2e1 * t101 * t7 * t107 + 0.2e1 * (-t114 + t116 + t118 - t120) * t30 + t101 * t7 * t78 + 0.2e1 * (-t114 + t116 + t120 - t118) * t42 + 0.2e1 * t101 * t1 * (t9 - 0.3e1) * t134 - t101 * t7 * t74 + 0.2e1 * t101 * t1 * (t9 + 0.3e1) * t144 - 0.3e1 * t97 * ZB * t88;
+	t152 = t45 * ZB;
+	t153 = t152 * zc;
+	t157 = exp(0.2e1 * kn * (-0.2e1 + zc));
+	t161 = kn * ZB;
+	t163 = exp(0.4e1 * t73);
+	t171 = t152 * t1;
+	t172 = t7 * t72;
+	t176 = t7 * t7;
+	t178 = exp(-0.4e1 * kn);
+	t196 = -0.8e1 * t153 * t8 * t157 - 0.2e1 * t161 * t2 * t163 - 0.2e1 * t161 * t6 + 0.8e1 * t153 * t11 + 0.8e1 * t171 * t172 * t91 + 0.2e1 * t161 * t176 * t178 - 0.8e1 * t171 * t172 * t38 + 0.16e2 * t161 * (-t55 + t48 - t61 - t26 + t52 + t59 - t64) * t66 + 0.4e1 * t18 * t22 + 0.2e1 * kn * t22 * ZB + 0.2e1 * t15 * ZB;
+
+	return t151 / t196;
+}
+
+double Calculate_u1a ( Velic_solD* self, double x, double z, double y, double n ) {
+	double t4, t10, t14;
+	double xc = self->xc;
+	double sigma = self->sigma;
+	double ZA = self->ZA;
+	
+	double zc = self->zc;
+
+	double kn = n * M_PI;
+	double del_rho = 2.0*sigma*sin(kn*xc)/kn;
+	double del_rhoA = del_rho;
+	
+
+	t4 = exp(-kn * z);
+	t10 = exp(kn * (z - zc));
+	t14 = kn * kn;
+
+	return (Calculate__C1A( self, x, z, y, n ) + z * Calculate__C3A( self, x, z, y, n )) * t4 + (Calculate__C2A( self, x, z, y, n ) + z * Calculate__C4A( self, x, z, y, n )) * t10 - del_rhoA / ZA / t14;
+}
+
+double Calculate_u2a ( Velic_solD* self, double x, double z, double y, double n ) {
+	double t1, t2, t6, t10;
+	
+	
+	
+	
+	double zc = self->zc;
+
+	double kn = n * M_PI;
+	
+	
+	
+
+	t1 = kn * z;
+	t2 = exp(-t1);
+	t6 = exp(kn * (z - zc));
+	t10 = 0.1e1 / kn;
+
+	return t2 * Calculate__C1A( self, x, z, y, n ) - t6 * Calculate__C2A( self, x, z, y, n ) + t2 * (-0.1e1 + t1) * Calculate__C3A( self, x, z, y, n ) * t10 - t6 * (0.1e1 + t1) * Calculate__C4A( self, x, z, y, n ) * t10;
+}
+
+double Calculate_u3a ( Velic_solD* self, double x, double z, double y, double n ) {
+	double t1, t3, t8;
+	
+	
+	double ZA = self->ZA;
+	
+	double zc = self->zc;
+
+	double kn = n * M_PI;
+	
+	
+	
+
+	t1 = ZA * kn;
+	t3 = exp(-kn * z);
+	t8 = exp(kn * (z - zc));
+
+	return -0.2e1 * t1 * t3 * Calculate__C1A( self, x, z, y, n ) + 0.2e1 * t1 * t8 * Calculate__C2A( self, x, z, y, n ) - 0.2e1 * t1 * t3 * z * Calculate__C3A( self, x, z, y, n ) + 0.2e1 * t1 * t8 * z * Calculate__C4A( self, x, z, y, n );
+}
+
+double Calculate_u4a ( Velic_solD* self, double x, double z, double y, double n ) {
+	double t2, t6, t15;
+	double xc = self->xc;
+	double sigma = self->sigma;
+	double ZA = self->ZA;
+	
+	double zc = self->zc;
+
+	double kn = n * M_PI;
+	double del_rho = 2.0*sigma*sin(kn*xc)/kn;
+	double del_rhoA = del_rho;
+	
+
+	t2 = kn * z;
+	t6 = exp(-t2);
+	t15 = exp(kn * (z - zc));
+
+	return -0.2e1 * ZA * (-Calculate__C3A( self, x, z, y, n ) + kn * Calculate__C1A( self, x, z, y, n ) + t2 * Calculate__C3A( self, x, z, y, n )) * t6 - 0.2e1 * ZA * (Calculate__C4A( self, x, z, y, n ) + kn * Calculate__C2A( self, x, z, y, n ) + t2 * Calculate__C4A( self, x, z, y, n )) * t15 + 0.1e1 / kn * del_rhoA;
+}
+
+double Calculate_u1b ( Velic_solD* self, double x, double z, double y, double n ) {
+	double t5, t11, t15;
+	double xc = self->xc;
+	double sigma = self->sigma;
+	
+	double ZB = self->ZB;
+	double zc = self->zc;
+
+	double kn = n * M_PI;
+	double del_rho = 2.0*sigma*sin(kn*xc)/kn;
+	
+	double del_rhoB = del_rho;
+	
+
+	t5 = exp(kn * (zc - z));
+	t11 = exp(kn * (z - 0.1e1));
+	t15 = kn * kn;
+
+	return (Calculate__C1B( self, x, z, y, n ) + z * Calculate__C3B( self, x, z, y, n )) * t5 + (Calculate__C2B( self, x, z, y, n ) + z * Calculate__C4B( self, x, z, y, n )) * t11 - del_rhoB / ZB / t15;
+}
+
+double Calculate_u2b ( Velic_solD* self, double x, double z, double y, double n ) {
+	double t3, t7, t9, t12;
+	
+	
+	
+	
+	double zc = self->zc;
+
+	double kn = n * M_PI;
+	
+	
+	
+	
+
+	t3 = exp(kn * (zc - z));
+	t7 = exp(kn * (z - 0.1e1));
+	t9 = kn * z;
+	t12 = 0.1e1 / kn;
+
+	return t3 * Calculate__C1B( self, x, z, y, n ) - t7 * Calculate__C2B( self, x, z, y, n ) + t3 * (-0.1e1 + t9) * Calculate__C3B( self, x, z, y, n ) * t12 - t7 * (0.1e1 + t9) * Calculate__C4B( self, x, z, y, n ) * t12;
+}
+
+double Calculate_u3b ( Velic_solD* self, double x, double z, double y, double n ) {
+	double t1, t4, t9;
+	
+	
+	
+	double ZB = self->ZB;
+	double zc = self->zc;
+
+	double kn = n * M_PI;
+	
+	
+	
+	
+
+	t1 = kn * ZB;
+	t4 = exp(kn * (zc - z));
+	t9 = exp(kn * (z - 0.1e1));
+
+	return -0.2e1 * t1 * t4 * Calculate__C1B( self, x, z, y, n ) + 0.2e1 * t1 * t9 * Calculate__C2B( self, x, z, y, n ) - 0.2e1 * t1 * t4 * z * Calculate__C3B( self, x, z, y, n ) + 0.2e1 * t1 * t9 * z * Calculate__C4B( self, x, z, y, n );
+}
+
+double Calculate_u4b ( Velic_solD* self, double x, double z, double y, double n ) {
+	double t2, t8, t17;
+	double xc = self->xc;
+	double sigma = self->sigma;
+	
+	double ZB = self->ZB;
+	double zc = self->zc;
+
+	double kn = n * M_PI;
+	double del_rho = 2.0*sigma*sin(kn*xc)/kn;
+	
+	double del_rhoB = del_rho;
+	
+
+	t2 = kn * z;
+	t8 = exp(kn * (zc - z));
+	t17 = exp(kn * (z - 0.1e1));
+
+	return -0.2e1 * ZB * (-Calculate__C3B( self, x, z, y, n ) + kn * Calculate__C1B( self, x, z, y, n ) + t2 * Calculate__C3B( self, x, z, y, n )) * t8 - 0.2e1 * ZB * (Calculate__C4B( self, x, z, y, n ) + kn * Calculate__C2B( self, x, z, y, n ) + t2 * Calculate__C4B( self, x, z, y, n )) * t17 + 0.1e1 / kn * del_rhoB;
+}
+
+
+double Calculate_u1( Velic_solD* self, double x, double z, double y, double n ) {
+	if ( z < self->zc ) 
+		return Calculate_u1a( self, x, z, y, n );
+	else 
+		return Calculate_u1b( self, x, z, y, n );
+}
+
+double Calculate_u2( Velic_solD* self, double x, double z, double y, double n ) {
+	if ( z < self->zc ) 
+		return Calculate_u2a( self, x, z, y, n );
+	else 
+		return Calculate_u2b( self, x, z, y, n );
+}
+double Calculate_u3( Velic_solD* self, double x, double z, double y, double n ) {
+	if ( z < self->zc ) 
+		return Calculate_u3a( self, x, z, y, n );
+	else 
+		return Calculate_u3b( self, x, z, y, n );
+}
+double Calculate_u4( Velic_solD* self, double x, double z, double y, double n ) {
+	if ( z < self->zc ) 
+		return Calculate_u4a( self, x, z, y, n );
+	else 
+		return Calculate_u4b( self, x, z, y, n );
+}
+
+double Calculate_Z( Velic_solD* self, double x, double z, double y, double n ) {
+	if ( z < self->zc ) 
+		return self->ZA;
+	else 
+		return self->ZB;
+}
+
+void Velic_solD_PressureFunction( void* analyticSolution, FeVariable* analyticFeVariable, double* coord, double* pressure ) {
+	Velic_solD* self = (Velic_solD*) analyticSolution;
+	double x    = coord[ I_AXIS ];
+	double z    = coord[ J_AXIS ];
+	double y    = coord[ K_AXIS ];
+	double n;
+	double u2, u3, Z;
+	double del_rho;
+	
+	for ( n = 1 ; n <= 75 ; n++ ) {
+		u2 = Calculate_u2( self, x, z, y, n );
+		u3 = Calculate_u3( self, x, z, y, n );
+		Z  = Calculate_Z ( self, x, z, y, n );
+
+		*pressure += (double)-(u3 + 2.0*n*M_PI*Z*u2)*cos(n*M_PI*x);
+	}
+	/* Add in n = 0 term now */
+	del_rho = self->sigma*self->xc;
+	u3 = del_rho*(z-self->zc);
+	*pressure += -u3;
+}
+
+void Velic_solD_VelocityFunction( void* analyticSolution, FeVariable* analyticFeVariable, double* coord, double* velocity ) {
+	Velic_solD* self = (Velic_solD*) analyticSolution;
+	double x    = coord[ I_AXIS ];
+	double z    = coord[ J_AXIS ];
+	double y    = coord[ K_AXIS ];
+	double n;
+	double u1, u2;
+
+	for ( n = 1 ; n <= 75 ; n++ ) {
+		u1 = Calculate_u1( self, x, z, y, n );
+		u2 = Calculate_u2( self, x, z, y, n );
+
+		u1 *= cos( n * M_PI * x );
+		u2 *= sin( n * M_PI * x );
+
+		velocity[ I_AXIS ] += u2;
+		velocity[ J_AXIS ] += u1;
+		if ( analyticFeVariable->dim == 3 ) 
+			velocity[ K_AXIS ] += 0.0;
+	}
+}
+
+void Velic_solD_StressFunction( void* analyticSolution, FeVariable* analyticFeVariable, double* coord, double* stress ) {
+	Velic_solD* self = (Velic_solD*) analyticSolution;
+	double x    = coord[ I_AXIS ];
+	double z    = coord[ J_AXIS ];
+	double y    = coord[ K_AXIS ];
+	double n;
+	double u6, u2, u3, u4, Z, del_rho;
+
+	for ( n = 1 ; n <= 75 ; n++ ) {
+		Z = Calculate_Z( self, x, z, y, n );
+		u2 = Calculate_u2( self, x, z, y, n );
+		u3 = Calculate_u3( self, x, z, y, n );
+		u4 = Calculate_u4( self, x, z, y, n );
+		u6 = (double)(u3 + 4*Z*n*M_PI*u2);
+
+		u6 *= cos(n*M_PI*x);
+		u3 *= 2*n*M_PI*cos(n*M_PI*x);
+		u4 *= 2*n*M_PI*sin(n*M_PI*x);
+
+		stress[ 0 ] += u6;
+		stress[ 1 ] += u3;
+		if ( analyticFeVariable->dim == 2 ) {
+			stress[ 2 ] += u4;
+		}
+		else { 
+			stress[ 2 ] += 0.0;
+			stress[ 3 ] += u4;
+			stress[ 4 ] += 0.0;
+			stress[ 5 ] += 0.0;
+		}
+	}
+	/* Add in n = 0 term now */
+	del_rho = self->sigma * self->xc;
+	u3 = del_rho*(z-self->zc); /* zz stress */
+	stress[ 0 ] += u3;	
+	stress[ 1 ] += u3;	
+}
+
+void Velic_solD_StrainRateFunction( void* analyticSolution, FeVariable* analyticFeVariable, double* coord, double* strainRate ) {
+//	Velic_solD* self = (Velic_solD*) analyticSolution;
+	
+	
+	
+	double n;
+
+	for ( n = 1 ; n <= 75 ; n++ ) {
+
+		strainRate[ 0 ] += 0.0;
+		strainRate[ 1 ] += 0.0;
+		if ( analyticFeVariable->dim == 2 ) {
+			strainRate[ 2 ] += 0.0;
+		}
+		else { 
+			strainRate[ 2 ] += 0.0;
+			strainRate[ 3 ] += 0.0;
+			strainRate[ 4 ] += 0.0;
+			strainRate[ 5 ] += 0.0;
+		}
+	}
+}
+
+void _Velic_solD_Construct( void* analyticSolution, Stg_ComponentFactory* cf ) {
+	Velic_solD* self = (Velic_solD*) analyticSolution;
+	FeVariable*              velocityField;
+	FeVariable*              pressureField;
+	FeVariable*              stressField;
+	//FeVariable*              strainRateField;
+
+	/* Construct Parent */
+	_AnalyticSolution_Construct( self, cf );
+
+	/* Create Analytic Fields */
+	velocityField = Stg_ComponentFactory_ConstructByName( cf, "VelocityField", FeVariable, True );
+	AnalyticSolution_CreateAnalyticVectorField( self, velocityField, Velic_solD_VelocityFunction );
+
+	pressureField = Stg_ComponentFactory_ConstructByName( cf, "PressureField", FeVariable, True );
+	AnalyticSolution_CreateAnalyticField( self, pressureField, Velic_solD_PressureFunction );
+
+	stressField = Stg_ComponentFactory_ConstructByName( cf, "StressField", FeVariable, False );
+	if ( stressField )
+		AnalyticSolution_CreateAnalyticSymmetricTensorField( self, stressField, Velic_solD_StressFunction );
+		
+#if 0
+	strainRateField = Stg_ComponentFactory_ConstructByName( cf, "StrainRateField", FeVariable, False );
+	if ( strainRateField )
+		AnalyticSolution_CreateAnalyticSymmetricTensorField( self, strainRateField, Velic_solD_StrainRateFunction );
+#endif
+
+	self->xc = Stg_ComponentFactory_GetRootDictDouble( cf, "xc", 0.0 );
+	self->sigma = Stg_ComponentFactory_GetRootDictDouble( cf, "sigma", 0.0 );
+	self->ZA = Stg_ComponentFactory_GetRootDictDouble( cf, "ZA", 0.0 );
+	self->ZB = Stg_ComponentFactory_GetRootDictDouble( cf, "ZB", 0.0 );
+	self->zc = Stg_ComponentFactory_GetRootDictDouble( cf, "zc", 0.0 );
+
+}
+
+void* _Velic_solD_DefaultNew( Name name ) {
+	return _AnalyticSolution_New(
+			sizeof(Velic_solD),
+			Velic_solD_Type,
+			_AnalyticSolution_Delete,
+			_AnalyticSolution_Print,
+			_AnalyticSolution_Copy,
+			_Velic_solD_DefaultNew,
+			_Velic_solD_Construct,
+			_AnalyticSolution_Build,
+			_AnalyticSolution_Initialise,
+			_AnalyticSolution_Execute,
+			_AnalyticSolution_Destroy,
+			name );
+}
+
+Index _Velic_solD_Register( PluginsManager* pluginsManager ) {
+	return PluginsManager_Submit( pluginsManager, Velic_solD_Type, "0", _Velic_solD_DefaultNew );
+}


Property changes on: long/3D/Gale/trunk/src/StgFEM/plugins/VelicAnalyticSolutions/Velic_solD/solD.c
___________________________________________________________________
Name: svn:keywords
   + LastChangedDate Author Id
Name: svn:eol-style
   + native

Added: long/3D/Gale/trunk/src/StgFEM/plugins/VelicAnalyticSolutions/Velic_solD/solD.tex
===================================================================
--- long/3D/Gale/trunk/src/StgFEM/plugins/VelicAnalyticSolutions/Velic_solD/solD.tex	2006-06-28 09:59:25 UTC (rev 3898)
+++ long/3D/Gale/trunk/src/StgFEM/plugins/VelicAnalyticSolutions/Velic_solD/solD.tex	2006-06-28 10:01:38 UTC (rev 3899)
@@ -0,0 +1,30 @@
+\documentclass{article}
+\usepackage{rotating}
+\usepackage{epsfig}
+\usepackage{sidecap}
+\usepackage{bm}
+\oddsidemargin=-1cm
+\evensidemargin=1cm
+\textwidth=17cm
+
+\topmargin=-1.0cm
+\textheight=23.5cm
+\parindent=0cm
+
+\newcommand\fontB{\usefont{T1}{phvv}{b}{n}}
+\DeclareTextFontCommand{\textfontB}{\fontB}
+
+
+\begin{document}
+  \begin{center} 
+    {\Large \fontB Stokes' Flow Analytic Solution: (solD)}
+  \end{center}
+  
+  \input ../Doc/eqs_common.tex
+
+  \input solD_main.tex
+   
+
+\end{document}
+
+

Added: long/3D/Gale/trunk/src/StgFEM/plugins/VelicAnalyticSolutions/Velic_solD/solD_main.tex
===================================================================
--- long/3D/Gale/trunk/src/StgFEM/plugins/VelicAnalyticSolutions/Velic_solD/solD_main.tex	2006-06-28 09:59:25 UTC (rev 3898)
+++ long/3D/Gale/trunk/src/StgFEM/plugins/VelicAnalyticSolutions/Velic_solD/solD_main.tex	2006-06-28 10:01:38 UTC (rev 3899)
@@ -0,0 +1,28 @@
+  {\large \fontB Description:}
+  
+  {\bf solD} is a 2-dimensional analytical solution to the Cauchy equations with the acceleration term set to zero
+  to represent creeping flow. The boundary conditions are free-slip everywhere on a unit domain.
+  The viscosity is layered with a jump at $ z=z_c $.
+  The flow is driven by a density jump in the x direction.
+  \\
+  
+ {\large \fontB Parameters:}
+  
+ The variable parameters of this solution are:
+ \begin{itemize}
+   \item{density parameter: $ \sigma $.}
+   \item{viscosities: $\eta_A$ and $\eta_B$.}
+   \item{viscosity jump location: $z_c$.}
+   \item{width of dense column: $x_c$.}
+ \end{itemize}
+
+  \begin{SCfigure}[][h]
+    \includegraphics[width=6cm,clip]{../figs/figD.eps}
+    \caption[Short caption]{\label{figD} 
+      Solution ({\bf SolD}):
+      This solution has a column of density $\rho = \sigma$ from $0 < x < x_c$.
+      The viscosity is layered with a jump at $ z=z_c $.
+      The boundary conditions are free slip everywhere on the surfaces of the unit box.}
+  \end{SCfigure} 
+  
+

Added: long/3D/Gale/trunk/src/StgFEM/plugins/VelicAnalyticSolutions/Velic_solKx/makefile
===================================================================
--- long/3D/Gale/trunk/src/StgFEM/plugins/VelicAnalyticSolutions/Velic_solKx/makefile	2006-06-28 09:59:25 UTC (rev 3898)
+++ long/3D/Gale/trunk/src/StgFEM/plugins/VelicAnalyticSolutions/Velic_solKx/makefile	2006-06-28 10:01:38 UTC (rev 3899)
@@ -0,0 +1,59 @@
+##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+##
+## Copyright (C), 2003-2006, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street,
+##	Melbourne, 3053, Australia.
+##
+## Primary Contributing Organisations:
+##	Victorian Partnership for Advanced Computing Ltd, Computational Software Development - http://csd.vpac.org
+##	Australian Computational Earth Systems Simulator - http://www.access.edu.au
+##	Monash Cluster Computing - http://www.mcc.monash.edu.au
+##	Computational Infrastructure for Geodynamics - http://www.geodynamics.org
+##
+## Contributors:
+##	Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
+##	Robert Turnbull, Research Assistant, Monash University. (robert.turnbull at sci.monash.edu.au)
+##	Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
+##	David May, PhD Student, Monash University (david.may at sci.monash.edu.au)
+##	Louis Moresi, Associate Professor, Monash University. (louis.moresi at sci.monash.edu.au)
+##	Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
+##	Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
+##	Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
+##	Julian Giordani, Research Assistant, Monash University. (julian.giordani at sci.monash.edu.au)
+##	Vincent Lemiale, Postdoctoral Fellow, Monash University. (vincent.lemiale at sci.monash.edu.au)
+##
+##  This library is free software; you can redistribute it and/or
+##  modify it under the terms of the GNU Lesser General Public
+##  License as published by the Free Software Foundation; either
+##  version 2.1 of the License, or (at your option) any later version.
+##
+##  This library is distributed in the hope that it will be useful,
+##  but WITHOUT ANY WARRANTY; without even the implied warranty of
+##  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+##  Lesser General Public License for more details.
+##
+##  You should have received a copy of the GNU Lesser General Public
+##  License along with this library; if not, write to the Free Software
+##  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+##
+## $Id: makefile 535 2006-04-11 13:07:34Z PatrickSunter $
+##
+##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+SHELL := $(shell which bash)
+PROJ_ROOT := $(shell until test -r ./Makefile.system ; do cd .. ; done ; echo `pwd`)
+
+include ${PROJ_ROOT}/Makefile.system
+
+modName := $(shell basename `pwd` )
+modName := $(shell echo ${modName} | cut -c 1 | tr '[:lower:]' '[:upper:]' )$(shell echo ${modName} | cut -c 2- ) 
+
+mod = ${modName}
+includes = ${PROJECT}/${modName}
+
+SRCS = $(wildcard *.c)
+HDRS = $(wildcard *.h)
+
+packages = STGERMAIN PETSC MPI XML
+EXTERNAL_LIBS = -lStG_FEM
+
+include ${PROJ_ROOT}/Makefile.vmake

Added: long/3D/Gale/trunk/src/StgFEM/plugins/VelicAnalyticSolutions/Velic_solKx/solKx.c
===================================================================
--- long/3D/Gale/trunk/src/StgFEM/plugins/VelicAnalyticSolutions/Velic_solKx/solKx.c	2006-06-28 09:59:25 UTC (rev 3898)
+++ long/3D/Gale/trunk/src/StgFEM/plugins/VelicAnalyticSolutions/Velic_solKx/solKx.c	2006-06-28 10:01:38 UTC (rev 3899)
@@ -0,0 +1,696 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+** 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:
+*+		Mirko Velic
+*+		Julian Giordani
+*+		Robert Turnbull
+*+		Vincent Lemiale
+*+		Louis Moresi
+*+		David May
+*+		David Stegman
+*+		Patrick Sunter
+** $Id: solA.c 565 2006-05-19 02:33:01Z RobertTurnbull $
+**
+**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+
+#include <mpi.h>
+#include <StGermain/StGermain.h>
+#include <StG_FEM/StG_FEM.h>
+#include <assert.h>
+#include "solKx.h"
+
+const Type Velic_solKx_Type = "Velic_solKx";
+
+double Calculate_AA( Velic_solKx* self ) {
+	double t1, t4, t6, t7, t9, t12, t14, t16, t17; 
+	
+	double    sigma    = self->sigma;
+	double    kn       = M_PI * self->kn;
+	double    km       = M_PI * self->km;
+	double    B        = self->B;
+
+	t1 = kn * kn;
+	t4 = km * km;
+	t6 = t4 * t4;
+	t7 = B * B;
+	t9 = 0.4e1 * t7 * t4;
+	t12 = 0.8e1 * t7 * kn * km;
+	t14 = 0.4e1 * t7 * t1;
+	t16 = 0.2e1 * t4 * t1;
+	t17 = t1 * t1;
+	return -0.4e1 * B * t1 * sigma * (t4 + t1) / (t6 + t9 + t12 + t14 + t16 + t17) / (t6 + t9 - t12 + t14 + t16 + t17);
+}
+
+double Calculate_BB( Velic_solKx* self ) {
+	double t2, t3, t4, t6, t7, t9, t10, t12, t16; 
+
+	double    sigma    = self->sigma;
+	double    kn       = M_PI * self->kn;
+	double    km       = M_PI * self->km;
+	double    B        = self->B;
+
+	t2 = kn * kn;
+	t3 = t2 * t2;
+	t4 = B * B;
+	t6 = 0.4e1 * t4 * t2;
+	t7 = km * km;
+	t9 = 0.4e1 * t7 * t4;
+	t10 = t7 * t7;
+	t12 = 0.2e1 * t7 * t2;
+	t16 = 0.8e1 * t4 * kn * km;
+	return sigma * kn * (t3 - t6 + t9 + t10 + t12) / (t10 + t9 + t16 + t6 + t12 + t3) / (t10 + t9 - t16 + t6 + t12 + t3);
+}
+
+double Calculate__C1( Velic_solKx* self, double x, double z, double y ) {
+	double t1, t2, t3, t4, t6, t7, t11, t13, t14, t15, t16, t17, t18, t20, t22, t23, t25, t30, t31, t34, t39, t45, t50, t52, t53, t54, t58, t60, t63, t70, t83, t85, t86, t88, t93, t101, t103, t104, t117, t130, t135, t146, t150;
+
+	double    kn       = M_PI * self->kn;
+	double    km       = M_PI * self->km;
+	double    B        = self->B;
+
+	double a  = B*B + km*km;
+	double b  = 2.0*km*B;
+	double r  = sqrt(a*a + b*b);
+	double Rp = sqrt( (r+a)/2.0 );
+	double Rm = sqrt( (r-a)/2.0 );
+
+	t1 = -B + Rp;
+	t2 = Rm * t1;
+	t3 = Rm * Rp;
+	t4 = Rm * B;
+	t6 = 0.2e1 * B * kn;
+	t7 = t3 + t4 + t6;
+	t11 = Rp * Rp;
+	t13 = 0.2e1 * B * Rp;
+	t14 = B * B;
+	t15 = 0.3e1 * t14;
+	t16 = kn * kn;
+	t17 = Rm * Rm;
+	t18 = t11 + t13 - t15 + t16 - t17;
+	t20 = t2 * t18 * Calculate_BB( self );
+	t22 = -Rm + kn;
+	t23 = cos(t22);
+	t25 = t3 + t4 - t6;
+	t30 = Rm + kn;
+	t31 = cos(t30);
+	t34 = t2 * t18 * Calculate_AA( self );
+	t39 = sin(t30);
+	t45 = sin(t22);
+	t50 = exp(-0.3e1 * Rp - B);
+	t52 = Rp + B;
+	t53 = Rm * t52;
+	t54 = t3 - t4 - t6;
+	t58 = t11 - t13 - t17 - t15 + t16;
+	t60 = t53 * t58 * Calculate_BB( self );
+	t63 = t3 - t4 + t6;
+	t70 = t53 * t58 * Calculate_AA( self );
+	t83 = exp(-t52);
+	t85 = t11 * B;
+	t86 = t14 * Rp;
+	t88 = t17 * Rp;
+	t93 = t17 * B;
+	t101 = 0.8e1 * t14 * Calculate_BB( self ) * kn * Rp;
+	t103 = 0.2e1 * Rm;
+	t104 = cos(t103);
+	t117 = sin(t103);
+	t130 = exp(-0.2e1 * Rp);
+	t135 = exp(-0.4e1 * Rp);
+	t146 = t17 * t14;
+	t150 = t17 * t11;
+	return (((-0.2e1 * t2 * t7 * Calculate_AA( self ) + t20) * t23 + (-0.2e1 * t2 * t25 * Calculate_AA( self ) - t20) * t31 + (t34 - 0.2e1 * t2 * t25 * Calculate_BB( self )) * t39 + (-t34 - 0.2e1 * t2 * t7 * Calculate_BB( self )) * t45) * t50 + ((0.2e1 * t53 * t54 * Calculate_AA( self ) + t60) * t23 + (0.2e1 * t53 * t63 * Calculate_AA( self ) - t60) * t31 + (t70 + 0.2e1 * t53 * t63 * Calculate_BB( self )) * t39 + (-t70 + 0.2e1 * t53 * t54 * Calculate_BB( self )) * t45) * t83 + ((-0.2e1 * Rp * (t85 + 0.2e1 * t86 + 0.2e1 * t88 - 0.3e1 * t14 * B + t16 * B + t93) * Calculate_AA( self ) - t101) * t104 + (-0.2e1 * t3 * (t11 - 0.5e1 * t14 + t16 - t17) * Calculate_AA( self ) - 0.8e1 * B * Calculate_BB( self ) * kn * Rm * Rp) * t117 + 0.2e1 * B * (t11 * Rp + 0.2e1 * t85 - 0.3e1 * t86 + t88 + t16 * Rp + 0.2e1 * t93) * Calculate_AA( self ) + t101) * t130 + 0.4e1 * t17 * t1 * t52 * Calculate_AA( self ) * t135) / (((0.8e1 * t14 + 0.8e1 * t17) * t11 * t104 - 0.8e1 * t11 * t14 - 0.8e1 * t146) * t130 + (-0.4e1 * t150 + 0.4e1 * t146) * t135 - 0.4e1 * t150 + 0.4e1 * t146);
+}
+
+double Calculate__C2( Velic_solKx* self, double x, double z, double y ) {
+	double t1, t2, t4, t5, t6, t7, t8, t10, t11, t12, t13, t14, t15, t16, t17, t18, t20, t21, t22, t24, t25, t28, t30, t31, t32, t33, t34, t35, t36, t37, t38, t39, t41, t42, t43, t47, t48, t50, t52, t56, t57, t63, t69, t74, t76, t77, t80, t81, t83, t84, t85, t86, t92, t102, t112, t120, t125, t126, t137, t142, t152, t160; 
+
+	double    kn       = M_PI * self->kn;
+	double    km       = M_PI * self->km;
+	double    B        = self->B;
+
+	double a  = B*B + km*km;
+	double b  = 2.0*km*B;
+	double r  = sqrt(a*a + b*b);
+	double Rp = sqrt( (r+a)/2.0 );
+	double Rm = sqrt( (r-a)/2.0 );
+
+	t1 = B * B;
+	t2 = t1 * kn;
+	t4 = 0.8e1 * t2 * Rp;
+	t5 = Rp * Rp;
+	t6 = t5 * Rp;
+	t7 = Rm * t6;
+	t8 = Rp * t1;
+	t10 = 0.5e1 * t8 * Rm;
+	t11 = kn * kn;
+	t12 = t11 * Rp;
+	t13 = t12 * Rm;
+	t14 = t11 * B;
+	t15 = t14 * Rm;
+	t16 = Rm * Rm;
+	t17 = t16 * Rm;
+	t18 = t17 * Rp;
+	t20 = Rm * t5 * B;
+	t21 = t17 * B;
+	t22 = t1 * B;
+	t24 = 0.3e1 * t22 * Rm;
+	t25 = -t4 + t7 - t10 + t13 + t15 - t18 - t20 - t21 - t24;
+	t28 = 0.3e1 * t22 * Rp;
+	t30 = 0.2e1 * t2 * Rm;
+	t31 = t16 * t1;
+	t32 = t16 * t5;
+	t33 = t6 * B;
+	t34 = t16 * Rp;
+	t35 = t34 * B;
+	t36 = t5 * t1;
+	t37 = 0.2e1 * t36;
+	t38 = B * kn;
+	t39 = Rm * Rp;
+	t41 = 0.2e1 * t38 * t39;
+	t42 = t12 * B;
+	t43 = -t28 + t30 + t31 + t32 + t33 + t35 + t37 + t41 + t42;
+	t47 = -Rm + kn;
+	t48 = cos(t47);
+	t50 = t13 + t15 - t18 - t24 - t20 - t21 + t7 - t10 + t4;
+	t52 = -t30 + t37 + t33 - t28 + t31 + t35 - t41 + t32 + t42;
+	t56 = Rm + kn;
+	t57 = cos(t56);
+	t63 = sin(t56);
+	t69 = sin(t47);
+	t74 = exp(-0.3e1 * Rp - B);
+	t76 = Rp + B;
+	t77 = Rm * t76;
+	t80 = 0.3e1 * t1;
+	t81 = t5 - 0.2e1 * B * Rp - t16 - t80 + t11;
+	t83 = t77 * t81 * Calculate_AA( self );
+	t84 = Rm * B;
+	t85 = 0.2e1 * t38;
+	t86 = t39 - t84 - t85;
+	t92 = t39 - t84 + t85;
+	t102 = t77 * t81 * Calculate_BB( self );
+	t112 = exp(-t76);
+	t120 = kn * Rm;
+	t125 = 0.2e1 * Rm;
+	t126 = cos(t125);
+	t137 = t1 * Calculate_BB( self );
+	t142 = sin(t125);
+	t152 = exp(-0.2e1 * Rp);
+	t160 = exp(-0.4e1 * Rp);
+	return (((t25 * Calculate_AA( self ) + 0.2e1 * t43 * Calculate_BB( self )) * t48 + (t50 * Calculate_AA( self ) - 0.2e1 * t52 * Calculate_BB( self )) * t57 + (0.2e1 * t52 * Calculate_AA( self ) + t50 * Calculate_BB( self )) * t63 + (-0.2e1 * t43 * Calculate_AA( self ) + t25 * Calculate_BB( self )) * t69) * t74 + ((-t83 + 0.2e1 * t77 * t86 * Calculate_BB( self )) * t48 + (-t83 - 0.2e1 * t77 * t92 * Calculate_BB( self )) * t57 + (0.2e1 * t77 * t92 * Calculate_AA( self ) - t102) * t63 + (-0.2e1 * t77 * t86 * Calculate_AA( self ) - t102) * t69) * t112 + ((0.2e1 * t39 * (t5 - 0.5e1 * t1 + t11 - t16) * Calculate_AA( self ) + 0.8e1 * B * Calculate_BB( self ) * t120 * Rp) * t126 + (-0.2e1 * Rp * (t5 * B + 0.2e1 * t8 + 0.2e1 * t34 - 0.3e1 * t22 + t14 + t16 * B) * Calculate_AA( self ) - 0.8e1 * t137 * kn * Rp) * t142 - 0.2e1 * t84 * (t5 + t80 + t16 - t11) * Calculate_AA( self ) + 0.8e1 * t137 * t120) * t152 + (-0.2e1 * t83 - 0.8e1 * t38 * t77 * Calculate_BB( self )) * t160) / (((0.8e1 * t1 + 0.8e1 * t16) * t5 * t126 - 0.8e1 * t36 - 0.8e1 * t31) * t152 + (-0.4e1 * t32 + 0.4e1 * t31) * t160 - 0.4e1 * t32 + 0.4e1 * t31);	
+}
+
+double Calculate__C3( Velic_solKx* self, double x, double z, double y ) {
+	double t1, t2, t3, t4, t6, t7, t11, t13, t14, t15, t16, t17, t18, t20, t22, t23, t25, t30, t31, t34, t39, t45, t50, t52, t53, t54, t58, t60, t63, t70, t83, t85, t86, t91, t92, t101, t103, t104, t117, t130, t143, t147, t151; 
+	
+	double    kn       = M_PI * self->kn;
+	double    km       = M_PI * self->km;
+	double    B        = self->B;
+
+	double a  = B*B + km*km;
+	double b  = 2.0*km*B;
+	double r  = sqrt(a*a + b*b);
+	double Rp = sqrt( (r+a)/2.0 );
+	double Rm = sqrt( (r-a)/2.0 );
+
+	t1 = -B + Rp;
+	t2 = Rm * t1;
+	t3 = Rm * Rp;
+	t4 = Rm * B;
+	t6 = 0.2e1 * B * kn;
+	t7 = t3 + t4 + t6;
+	t11 = Rp * Rp;
+	t13 = 0.2e1 * B * Rp;
+	t14 = B * B;
+	t15 = 0.3e1 * t14;
+	t16 = kn * kn;
+	t17 = Rm * Rm;
+	t18 = t11 + t13 - t15 + t16 - t17;
+	t20 = t2 * t18 * Calculate_BB( self );
+	t22 = -Rm + kn;
+	t23 = cos(t22);
+	t25 = t3 + t4 - t6;
+	t30 = Rm + kn;
+	t31 = cos(t30);
+	t34 = t2 * t18 * Calculate_AA( self );
+	t39 = sin(t30);
+	t45 = sin(t22);
+	t50 = exp(-0.3e1 * Rp - B);
+	t52 = Rp + B;
+	t53 = Rm * t52;
+	t54 = t3 - t4 - t6;
+	t58 = t11 - t13 - t17 - t15 + t16;
+	t60 = t53 * t58 * Calculate_BB( self );
+	t63 = t3 - t4 + t6;
+	t70 = t53 * t58 * Calculate_AA( self );
+	t83 = exp(-t52);
+	t85 = t17 * B;
+	t86 = t17 * Rp;
+	t91 = t11 * B;
+	t92 = t14 * Rp;
+	t101 = 0.8e1 * t14 * Calculate_BB( self ) * kn * Rp;
+	t103 = 0.2e1 * Rm;
+	t104 = cos(t103);
+	t117 = sin(t103);
+	t130 = exp(-0.2e1 * Rp);
+	t143 = t17 * t14;
+	t147 = t17 * t11;
+	t151 = exp(-0.4e1 * Rp);
+	return (((0.2e1 * t2 * t7 * Calculate_AA( self ) - t20) * t23 + (0.2e1 * t2 * t25 * Calculate_AA( self ) + t20) * t31 + (-t34 + 0.2e1 * t2 * t25 * Calculate_BB( self )) * t39 + (t34 + 0.2e1 * t2 * t7 * Calculate_BB( self )) * t45) * t50 + ((-0.2e1 * t53 * t54 * Calculate_AA( self ) - t60) * t23 + (-0.2e1 * t53 * t63 * Calculate_AA( self ) + t60) * t31 + (-t70 - 0.2e1 * t53 * t63 * Calculate_BB( self )) * t39 + (t70 - 0.2e1 * t53 * t54 * Calculate_BB( self )) * t45) * t83 + ((0.2e1 * Rp * (t85 - 0.2e1 * t86 - 0.3e1 * t14 * B + t16 * B + t91 - 0.2e1 * t92) * Calculate_AA( self ) + t101) * t104 + (0.2e1 * t3 * (t11 - 0.5e1 * t14 + t16 - t17) * Calculate_AA( self ) + 0.8e1 * B * Calculate_BB( self ) * kn * Rm * Rp) * t117 - 0.2e1 * B * (t11 * Rp - 0.2e1 * t91 - 0.3e1 * t92 + t86 + t16 * Rp - 0.2e1 * t85) * Calculate_AA( self ) - t101) * t130 + 0.4e1 * t17 * t1 * t52 * Calculate_AA( self )) / (((0.8e1 * t14 + 0.8e1 * t17) * t11 * t104 - 0.8e1 * t11 * t14 - 0.8e1 * t143) * t130 + (-0.4e1 * t147 + 0.4e1 * t143) * t151 - 0.4e1 * t147 + 0.4e1 * t143);
+			
+}
+
+double Calculate__C4( Velic_solKx* self, double x, double z, double y ) {
+	double t2, t3, t6, t7, t8, t9, t10, t12, t13, t14, t15, t16, t17, t22, t23, t25, t30, t31, t37, t39, t45, t50, t52, t54, t56, t57, t59, t60, t62, t63, t64, t65, t66, t67, t68, t69, t70, t71, t72, t74, t75, t76, t77, t79, t81, t82, t83, t84, t85, t87, t88, t93, t95, t112, t120, t125, t126, t137, t142, t152, t170;
+	
+	double    kn       = M_PI * self->kn;
+	double    km       = M_PI * self->km;
+	double    B        = self->B;
+
+	double a  = B*B + km*km;
+	double b  = 2.0*km*B;
+	double r  = sqrt(a*a + b*b);
+	double Rp = sqrt( (r+a)/2.0 );
+	double Rm = sqrt( (r-a)/2.0 );
+
+	t2 = Rm * (-B + Rp);
+	t3 = Rp * Rp;
+	t6 = B * B;
+	t7 = 0.3e1 * t6;
+	t8 = kn * kn;
+	t9 = Rm * Rm;
+	t10 = t3 + 0.2e1 * B * Rp - t7 + t8 - t9;
+	t12 = t2 * t10 * Calculate_AA( self );
+	t13 = Rm * Rp;
+	t14 = Rm * B;
+	t15 = B * kn;
+	t16 = 0.2e1 * t15;
+	t17 = t13 + t14 + t16;
+	t22 = -Rm + kn;
+	t23 = cos(t22);
+	t25 = t13 + t14 - t16;
+	t30 = Rm + kn;
+	t31 = cos(t30);
+	t37 = t2 * t10 * Calculate_BB( self );
+	t39 = sin(t30);
+	t45 = sin(t22);
+	t50 = exp(-0.3e1 * Rp - B);
+	t52 = Rp * t6;
+	t54 = 0.5e1 * Rm * t52;
+	t56 = Rm * t3 * B;
+	t57 = t6 * B;
+	t59 = 0.3e1 * t57 * Rm;
+	t60 = t6 * kn;
+	t62 = 0.8e1 * t60 * Rp;
+	t63 = t9 * Rm;
+	t64 = Rp * t63;
+	t65 = B * t8;
+	t66 = t65 * Rm;
+	t67 = B * t63;
+	t68 = Rp * t8;
+	t69 = t68 * Rm;
+	t70 = t3 * Rp;
+	t71 = Rm * t70;
+	t72 = -t54 + t56 + t59 - t62 - t64 - t66 + t67 + t69 + t71;
+	t74 = t70 * B;
+	t75 = t9 * t3;
+	t76 = t3 * t6;
+	t77 = 0.2e1 * t76;
+	t79 = 0.3e1 * t57 * Rp;
+	t81 = 0.2e1 * t15 * t13;
+	t82 = t9 * Rp;
+	t83 = t82 * B;
+	t84 = t68 * B;
+	t85 = t9 * t6;
+	t87 = 0.2e1 * t60 * Rm;
+	t88 = t74 - t75 - t77 - t79 + t81 + t83 + t84 - t85 - t87;
+	t93 = -t66 + t69 - t64 + t59 - t54 + t62 + t56 + t71 + t67;
+	t95 = -t77 + t74 + t87 - t85 - t79 + t84 - t75 + t83 - t81;
+	t112 = exp(-Rp - B);
+	t120 = kn * Rm;
+	t125 = 0.2e1 * Rm;
+	t126 = cos(t125);
+	t137 = t6 * Calculate_BB( self );
+	t142 = sin(t125);
+	t152 = exp(-0.2e1 * Rp);
+	t170 = exp(-0.4e1 * Rp);
+	return (((t12 + 0.2e1 * t2 * t17 * Calculate_BB( self )) * t23 + (t12 - 0.2e1 * t2 * t25 * Calculate_BB( self )) * t31 + (0.2e1 * t2 * t25 * Calculate_AA( self ) + t37) * t39 + (-0.2e1 * t2 * t17 * Calculate_AA( self ) + t37) * t45) * t50 + ((-t72 * Calculate_AA( self ) - 0.2e1 * t88 * Calculate_BB( self )) * t23 + (-t93 * Calculate_AA( self ) + 0.2e1 * t95 * Calculate_BB( self )) * t31 + (-0.2e1 * t95 * Calculate_AA( self ) - t93 * Calculate_BB( self )) * t39 + (0.2e1 * t88 * Calculate_AA( self ) - t72 * Calculate_BB( self )) * t45) * t112 + ((-0.2e1 * t13 * (t3 - 0.5e1 * t6 + t8 - t9) * Calculate_AA( self ) - 0.8e1 * B * Calculate_BB( self ) * t120 * Rp) * t126 + (0.2e1 * Rp * (t9 * B - 0.2e1 * t82 - 0.3e1 * t57 + t65 + t3 * B - 0.2e1 * t52) * Calculate_AA( self ) + 0.8e1 * t137 * kn * Rp) * t142 - 0.2e1 * t14 * (t3 + t7 + t9 - t8) * Calculate_AA( self ) + 0.8e1 * t137 * t120) * t152 + 0.2e1 * t12 + 0.8e1 * t15 * t2 * Calculate_BB( self )) / (((0.8e1 * t6 + 0.8e1 * t9) * t3 * t126 - 0.8e1 * t76 - 0.8e1 * t85) * t152 + (-0.4e1 * t75 + 0.4e1 * t85) * t170 - 0.4e1 * t75 + 0.4e1 * t85);
+	
+}
+
+
+double Calculate_u1( Velic_solKx* self, double x, double z, double y ) {
+	double t2, t3, t4, t6, t11, t18, t19, t20, t22;
+	
+	double    kn       = M_PI * self->kn;
+	double    km       = M_PI * self->km;
+	double    B        = self->B;
+
+	double a  = B*B + km*km;
+	double b  = 2.0*km*B;
+	double r  = sqrt(a*a + b*b);
+	double Rp = sqrt( (r+a)/2.0 );
+	double Rm = sqrt( (r-a)/2.0 );
+	double UU = Rp - B;
+	double VV = Rp + B;
+
+	t2 = exp(UU * x);
+	t3 = Rm * x;
+	t4 = cos(t3);
+	t6 = sin(t3);
+	t11 = exp(-VV * x);
+	t18 = exp(-0.2e1 * x * B);
+	t19 = kn * x;
+	t20 = cos(t19);
+	t22 = sin(t19);
+	return -km * (t2 * (Calculate__C1( self, x, y, z ) * t4 + Calculate__C2( self, x, y, z ) * t6) + t11 * (Calculate__C3( self, x, y, z ) * t4 + Calculate__C4( self, x, y, z ) * t6) + t18 * (Calculate_AA( self ) * t20 + Calculate_BB( self ) * t22));
+
+}
+
+double Calculate_u2( Velic_solKx* self, double x, double z, double y ) {
+	double t2, t4, t5, t7, t18, t32, t34, t35, t37;
+	
+	double    kn       = M_PI * self->kn;
+	double    km       = M_PI * self->km;
+	double    B        = self->B;
+
+	double a  = B*B + km*km;
+	double b  = 2.0*km*B;
+	double r  = sqrt(a*a + b*b);
+	double Rp = sqrt( (r+a)/2.0 );
+	double Rm = sqrt( (r-a)/2.0 );
+	double UU = Rp - B;
+	double VV = Rp + B;
+
+	t2 = exp(UU * x);
+	t4 = Rm * x;
+	t5 = cos(t4);
+	t7 = sin(t4);
+	t18 = exp(-VV * x);
+	t32 = exp(-0.2e1 * x * B);
+	t34 = kn * x;
+	t35 = cos(t34);
+	t37 = sin(t34);
+	return UU * t2 * (Calculate__C1( self, x, y, z ) * t5 + Calculate__C2( self, x, y, z ) * t7) + t2 * (-Calculate__C1( self, x, y, z ) * t7 * Rm + Calculate__C2( self, x, y, z ) * t5 * Rm) - VV * t18 * (Calculate__C3( self, x, y, z ) * t5 + Calculate__C4( self, x, y, z ) * t7) + t18 * (-Calculate__C3( self, x, y, z ) * t7 * Rm + Calculate__C4( self, x, y, z ) * t5 * Rm) - 0.2e1 * B * t32 * (Calculate_AA( self ) * t35 + Calculate_BB( self ) * t37) + t32 * (-Calculate_AA( self ) * t37 * kn + Calculate_BB( self ) * t35 * kn);
+	
+}
+
+double Calculate_u3( Velic_solKx* self, double x, double z, double y ) {
+	double t2, t3, t6, t8, t9, t11, t22, t34, t36, t37, t39;
+
+	double    kn       = M_PI * self->kn;
+	double    km       = M_PI * self->km;
+	double    B        = self->B;
+
+	double a  = B*B + km*km;
+	double b  = 2.0*km*B;
+	double r  = sqrt(a*a + b*b);
+	double Rp = sqrt( (r+a)/2.0 );
+	double Rm = sqrt( (r-a)/2.0 );
+	double UU = Rp - B;
+	double VV = Rp + B;
+
+	t2 = 0.2e1 * x * B;
+	t3 = exp(t2);
+	t6 = exp(UU * x);
+	t8 = Rm * x;
+	t9 = cos(t8);
+	t11 = sin(t8);
+	t22 = exp(-VV * x);
+	t34 = exp(-t2);
+	t36 = kn * x;
+	t37 = cos(t36);
+	t39 = sin(t36);
+	return -0.2e1 * t3 * km * (UU * t6 * (Calculate__C1( self, x, y, z ) * t9 + Calculate__C2( self, x, y, z ) * t11) + t6 * (-Calculate__C1( self, x, y, z ) * t11 * Rm + Calculate__C2( self, x, y, z ) * t9 * Rm) - VV * t22 * (Calculate__C3( self, x, y, z ) * t9 + Calculate__C4( self, x, y, z ) * t11) + t22 * (-Calculate__C3( self, x, y, z ) * t11 * Rm + Calculate__C4( self, x, y, z ) * t9 * Rm) - 0.2e1 * B * t34 * (Calculate_AA( self ) * t37 + Calculate_BB( self ) * t39) + t34 * (-Calculate_AA( self ) * t39 * kn + Calculate_BB( self ) * t37 * kn));
+}
+
+double Calculate_u4( Velic_solKx* self, double x, double z, double y ) {
+	double t2, t3, t4, t6, t7, t8, t9, t10, t11, t12, t15, t16, t17, t18, t20, t21, t22, t23, t24, t25, t26, t30, t41, t46, t61, t73;
+	
+	double    kn       = M_PI * self->kn;
+	double    km       = M_PI * self->km;
+	double    B        = self->B;
+
+	double a  = B*B + km*km;
+	double b  = 2.0*km*B;
+	double r  = sqrt(a*a + b*b);
+	double Rp = sqrt( (r+a)/2.0 );
+	double Rm = sqrt( (r-a)/2.0 );
+	double UU = Rp - B;
+	double VV = Rp + B;
+
+	t2 = 0.2e1 * x * B;
+	t3 = exp(t2);
+	t4 = km * km;
+	t6 = exp(UU * x);
+	t7 = Rm * x;
+	t8 = cos(t7);
+	t9 = Calculate__C1( self, x, y, z ) * t8;
+	t10 = sin(t7);
+	t11 = Calculate__C2( self, x, y, z ) * t10;
+	t12 = t9 + t11;
+	t15 = exp(-VV * x);
+	t16 = Calculate__C3( self, x, y, z ) * t8;
+	t17 = Calculate__C4( self, x, y, z ) * t10;
+	t18 = t16 + t17;
+	t20 = exp(-t2);
+	t21 = kn * x;
+	t22 = cos(t21);
+	t23 = Calculate_AA( self ) * t22;
+	t24 = sin(t21);
+	t25 = Calculate_BB( self ) * t24;
+	t26 = t23 + t25;
+	t30 = UU * UU;
+	t41 = Rm * Rm;
+	t46 = VV * VV;
+	t61 = B * B;
+	t73 = kn * kn;
+	return t3 * (t4 * (t6 * t12 + t15 * t18 + t20 * t26) + t30 * t6 * t12 + 0.2e1 * UU * t6 * (-Calculate__C1( self, x, y, z ) * t10 * Rm + Calculate__C2( self, x, y, z ) * t8 * Rm) + t6 * (-t9 * t41 - t11 * t41) + t46 * t15 * t18 - 0.2e1 * VV * t15 * (-Calculate__C3( self, x, y, z ) * t10 * Rm + Calculate__C4( self, x, y, z ) * t8 * Rm) + t15 * (-t16 * t41 - t17 * t41) + 0.4e1 * t61 * t20 * t26 - 0.4e1 * B * t20 * (-Calculate_AA( self ) * t24 * kn + Calculate_BB( self ) * t22 * kn) + t20 * (-t23 * t73 - t25 * t73));
+}
+
+double Calculate_u5( Velic_solKx* self, double x, double z, double y ) {
+	double t2, t3, t4, t7, t9, t10, t11, t12, t13, t14, t16, t17, t19, t21, t24, t25, t28, t31, t36, t39, t41, t42, t43, t45, t46, t48, t50, t53, t56, t63, t65, t67, t68, t69, t70, t71, t72, t75, t76, t78, t80, t83, t84, t87, t90, t111, t128; 
+
+	double    kn       = M_PI * self->kn;
+	double    km       = M_PI * self->km;
+	double    B        = self->B;
+
+	double a  = B*B + km*km;
+	double b  = 2.0*km*B;
+	double r  = sqrt(a*a + b*b);
+	double Rp = sqrt( (r+a)/2.0 );
+	double Rm = sqrt( (r-a)/2.0 );
+	double UU = Rp - B;
+	double VV = Rp + B;
+
+	t2 = 0.2e1 * x * B;
+	t3 = exp(t2);
+	t4 = UU * UU;
+	t7 = exp(UU * x);
+	t9 = Rm * x;
+	t10 = cos(t9);
+	t11 = Calculate__C1( self, x, y, z ) * t10;
+	t12 = sin(t9);
+	t13 = Calculate__C2( self, x, y, z ) * t12;
+	t14 = t11 + t13;
+	t16 = t4 * t7;
+	t17 = Calculate__C1( self, x, y, z ) * t12;
+	t19 = Calculate__C2( self, x, y, z ) * t10;
+	t21 = -t17 * Rm + t19 * Rm;
+	t24 = UU * t7;
+	t25 = Rm * Rm;
+	t28 = -t11 * t25 - t13 * t25;
+	t31 = t25 * Rm;
+	t36 = VV * VV;
+	t39 = exp(-VV * x);
+	t41 = Calculate__C3( self, x, y, z ) * t10;
+	t42 = Calculate__C4( self, x, y, z ) * t12;
+	t43 = t41 + t42;
+	t45 = t36 * t39;
+	t46 = Calculate__C3( self, x, y, z ) * t12;
+	t48 = Calculate__C4( self, x, y, z ) * t10;
+	t50 = -t46 * Rm + t48 * Rm;
+	t53 = VV * t39;
+	t56 = -t41 * t25 - t42 * t25;
+	t63 = B * B;
+	t65 = exp(-t2);
+	t67 = kn * x;
+	t68 = cos(t67);
+	t69 = Calculate_AA( self ) * t68;
+	t70 = sin(t67);
+	t71 = Calculate_BB( self ) * t70;
+	t72 = t69 + t71;
+	t75 = t63 * t65;
+	t76 = Calculate_AA( self ) * t70;
+	t78 = Calculate_BB( self ) * t68;
+	t80 = -t76 * kn + t78 * kn;
+	t83 = B * t65;
+	t84 = kn * kn;
+	t87 = -t69 * t84 - t71 * t84;
+	t90 = t84 * kn;
+	t111 = km * km;
+	t128 = t4 * UU * t7 * t14 + 0.3e1 * t16 * t21 + 0.3e1 * t24 * t28 + t7 * (t17 * t31 - t19 * t31) - t36 * VV * t39 * t43 + 0.3e1 * t45 * t50 - 0.3e1 * t53 * t56 + t39 * (t46 * t31 - t48 * t31) - 0.8e1 * t63 * B * t65 * t72 + 0.12e2 * t75 * t80 - 0.6e1 * t83 * t87 + t65 * (t76 * t90 - t78 * t90) + 0.2e1 * B * (t16 * t14 + 0.2e1 * t24 * t21 + t7 * t28 + t45 * t43 - 0.2e1 * t53 * t50 + t39 * t56 + 0.4e1 * t75 * t72 - 0.4e1 * t83 * t80 + t65 * t87) - t111 * (t24 * t14 + t7 * t21 - t53 * t43 + t39 * t50 - 0.2e1 * t83 * t72 + t65 * t80) + 0.2e1 * B * t111 * (t7 * t14 + t39 * t43 + t65 * t72);
+	 return -t3 * t128 / km;
+}
+
+double Calculate_u6( Velic_solKx* self, double x, double z, double y ) {
+	double t2, t3, t6, t8, t9, t11, t22, t34, t36, t37, t39;
+	
+	double    kn       = M_PI * self->kn;
+	double    km       = M_PI * self->km;
+	double    B        = self->B;
+
+	double a  = B*B + km*km;
+	double b  = 2.0*km*B;
+	double r  = sqrt(a*a + b*b);
+	double Rp = sqrt( (r+a)/2.0 );
+	double Rm = sqrt( (r-a)/2.0 );
+	double UU = Rp - B;
+	double VV = Rp + B;
+
+	t2 = 0.2e1 * x * B;
+	t3 = exp(t2);
+	t6 = exp(UU * x);
+	t8 = Rm * x;
+	t9 = cos(t8);
+	t11 = sin(t8);
+	t22 = exp(-VV * x);
+	t34 = exp(-t2);
+	t36 = kn * x;
+	t37 = cos(t36);
+	t39 = sin(t36);
+	return 0.2e1 * t3 * km * (UU * t6 * (Calculate__C1( self, x, y, z ) * t9 + Calculate__C2( self, x, y, z ) * t11) + t6 * (-Calculate__C1( self, x, y, z ) * t11 * Rm + Calculate__C2( self, x, y, z ) * t9 * Rm) - VV * t22 * (Calculate__C3( self, x, y, z ) * t9 + Calculate__C4( self, x, y, z ) * t11) + t22 * (-Calculate__C3( self, x, y, z ) * t11 * Rm + Calculate__C4( self, x, y, z ) * t9 * Rm) - 0.2e1 * B * t34 * (Calculate_AA( self ) * t37 + Calculate_BB( self ) * t39) + t34 * (-Calculate_AA( self ) * t39 * kn + Calculate_BB( self ) * t37 * kn));
+}
+
+double Calculate_SS( Velic_solKx* self, double x, double z, double y ) {
+	
+	double    kn       = M_PI * self->kn;
+	double    km       = M_PI * self->km;
+	double    B        = self->B;
+
+	double a  = B*B + km*km;
+	double b  = 2.0*km*B;
+	double r  = sqrt(a*a + b*b);
+	double Rp = sqrt( (r+a)/2.0 );
+	double Rm = sqrt( (r-a)/2.0 );
+	double UU = Rp - B;
+	double VV = Rp + B;
+
+	return sin(km*z)*(exp(UU*x)*(Calculate__C1( self, x, y, z )*cos(Rm*x)+Calculate__C2( self, x, y, z )*sin(Rm*x)) + exp(-VV*x)*(Calculate__C3( self, x, y, z )*cos(Rm*x)+Calculate__C4( self, x, y, z )*sin(Rm*x)) + exp(-2*x*B)*(Calculate_AA( self )*cos(kn*x)+Calculate_BB( self )*sin(kn*x)));
+
+}
+void Velic_solKx_PressureFunction( void* analyticSolution, FeVariable* analyticFeVariable, double* coord, double* pressure ) {
+	Velic_solKx* self = (Velic_solKx*) analyticSolution;
+	double x    = coord[ I_AXIS ];
+	double z    = coord[ J_AXIS ];
+	double y    = coord[ K_AXIS ];
+
+	double    km       = M_PI * self->km;
+	
+	*pressure = Calculate_u5( self, x, y, z )*cos(km*z);
+}
+
+void Velic_solKx_VelocityFunction( void* analyticSolution, FeVariable* analyticFeVariable, double* coord, double* velocity ) {
+	Velic_solKx* self = (Velic_solKx*) analyticSolution;
+	double x    = coord[ I_AXIS ];
+	double z    = coord[ J_AXIS ];
+	double y    = coord[ K_AXIS ];
+	
+	double    km       = M_PI * self->km;
+
+	velocity[ I_AXIS ] = Calculate_u1( self, x, y, z ) * cos(km*z);
+	velocity[ J_AXIS ] = Calculate_u2( self, x, y, z ) * sin(km*z);
+	if ( analyticFeVariable->dim == 3 ) 
+		velocity[ K_AXIS ] = 0.0;
+	printf("%0.7f %0.7f %0.7f %0.7f \n",x,z,velocity[ I_AXIS ],velocity[ J_AXIS ]);
+}
+
+void Velic_solKx_StressFunction( void* analyticSolution, FeVariable* analyticFeVariable, double* coord, double* stress ) {
+	Velic_solKx* self = (Velic_solKx*) analyticSolution;
+	double x    = coord[ I_AXIS ];
+	double z    = coord[ J_AXIS ];
+	double y    = coord[ K_AXIS ];
+
+	double    km       = M_PI * self->km;
+	double tmp;
+	double U5   = Calculate_u5( self, x, y, z );
+	tmp = Calculate_u6( self, x, y, z ) - U5; 
+	stress[0] = tmp*cos(km*z); /* xx stress */
+	tmp = Calculate_u3( self, x, y, z ) - U5;
+	stress[1] = Calculate_u3( self, x, y, z ) * cos(km*z); /* zz stress */
+	stress[2] = Calculate_u4( self, x, y, z ) * sin(km*z); /* zx stress */
+	
+}
+	
+void _Velic_solKx_Construct( void* analyticSolution, Stg_ComponentFactory* cf ) {
+	Velic_solKx* self = (Velic_solKx*) analyticSolution;
+	FeVariable*              velocityField;
+	FeVariable*              pressureField;
+	FeVariable*              stressField;
+
+	/* Construct Parent */
+	_AnalyticSolution_Construct( self, cf );
+
+	/* Create Analytic Fields */
+	velocityField = Stg_ComponentFactory_ConstructByName( cf, "VelocityField", FeVariable, True );
+	AnalyticSolution_CreateAnalyticVectorField( self, velocityField, Velic_solKx_VelocityFunction );
+
+	pressureField = Stg_ComponentFactory_ConstructByName( cf, "PressureField", FeVariable, True );
+	AnalyticSolution_CreateAnalyticField( self, pressureField, Velic_solKx_PressureFunction );
+
+	stressField = Stg_ComponentFactory_ConstructByName( cf, "StressField", FeVariable, False );
+	if ( stressField )
+		AnalyticSolution_CreateAnalyticSymmetricTensorField( self, stressField, Velic_solKx_StressFunction );
+
+	
+	self->sigma = Stg_ComponentFactory_GetRootDictDouble( cf, "sigma", 1.0 );
+	self->B = Stg_ComponentFactory_GetRootDictDouble( cf, "B", log(100.0)/2.0 );
+	self->kn = Stg_ComponentFactory_GetRootDictDouble( cf, "kn", 1.0 );
+	self->km = Stg_ComponentFactory_GetRootDictDouble( cf, "km", 1.0 );
+}
+
+void* _Velic_solKx_DefaultNew( Name name ) {
+	return _AnalyticSolution_New(
+			sizeof(Velic_solKx),
+			Velic_solKx_Type,
+			_AnalyticSolution_Delete,
+			_AnalyticSolution_Print,
+			_AnalyticSolution_Copy,
+			_Velic_solKx_DefaultNew,
+			_Velic_solKx_Construct,
+			_AnalyticSolution_Build,
+			_AnalyticSolution_Initialise,
+			_AnalyticSolution_Execute,
+			_AnalyticSolution_Destroy,
+			name );
+}
+
+Index _Velic_solKx_Register( PluginsManager* pluginsManager ) {
+	return PluginsManager_Submit( pluginsManager, Velic_solKx_Type, "0", _Velic_solKx_DefaultNew );
+}

Added: long/3D/Gale/trunk/src/StgFEM/plugins/VelicAnalyticSolutions/Velic_solKx/solKx.h
===================================================================
--- long/3D/Gale/trunk/src/StgFEM/plugins/VelicAnalyticSolutions/Velic_solKx/solKx.h	2006-06-28 09:59:25 UTC (rev 3898)
+++ long/3D/Gale/trunk/src/StgFEM/plugins/VelicAnalyticSolutions/Velic_solKx/solKx.h	2006-06-28 10:01:38 UTC (rev 3899)
@@ -0,0 +1,60 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+** 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:
+*+		Mirko Velic
+*+		Julian Giordani
+*+		Robert Turnbull
+*+		Vincent Lemiale
+*+		Louis Moresi
+*+		David May
+*+		David Stegman
+*+		Patrick Sunter
+** $Id: solA.c 565 2006-05-19 02:33:01Z RobertTurnbull $
+**
+**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+#ifndef __StG_FEM_Velic_solKx_h__
+#define __StG_FEM_Velic_solKx_h__
+
+	extern const Type Velic_solKx_Type;
+
+	typedef struct {
+		__AnalyticSolution
+		double sigma;
+		double kn;
+		double km;
+		double B;
+	} Velic_solKx;
+
+	void Velic_solKx_PressureFunction( void* analyticSolution, FeVariable* analyticFeVariable, double* coord, double* pressure );
+	void Velic_solKx_VelocityFunction( void* analyticSolution, FeVariable* analyticFeVariable, double* coord, double* velocity );
+	void Velic_solKx_StressFunction( void* analyticSolution, FeVariable* analyticFeVariable, double* coord, double* stress );
+
+#endif

Added: long/3D/Gale/trunk/src/StgFEM/plugins/VelicAnalyticSolutions/makefile
===================================================================
--- long/3D/Gale/trunk/src/StgFEM/plugins/VelicAnalyticSolutions/makefile	2006-06-28 09:59:25 UTC (rev 3898)
+++ long/3D/Gale/trunk/src/StgFEM/plugins/VelicAnalyticSolutions/makefile	2006-06-28 10:01:38 UTC (rev 3899)
@@ -0,0 +1,49 @@
+##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+##
+## Copyright (C), 2003-2006, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street,
+##	Melbourne, 3053, Australia.
+##
+## Primary Contributing Organisations:
+##	Victorian Partnership for Advanced Computing Ltd, Computational Software Development - http://csd.vpac.org
+##	Australian Computational Earth Systems Simulator - http://www.access.edu.au
+##	Monash Cluster Computing - http://www.mcc.monash.edu.au
+##	Computational Infrastructure for Geodynamics - http://www.geodynamics.org
+##
+## Contributors:
+##	Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
+##	Robert Turnbull, Research Assistant, Monash University. (robert.turnbull at sci.monash.edu.au)
+##	Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
+##	David May, PhD Student, Monash University (david.may at sci.monash.edu.au)
+##	Louis Moresi, Associate Professor, Monash University. (louis.moresi at sci.monash.edu.au)
+##	Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
+##	Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
+##	Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
+##	Julian Giordani, Research Assistant, Monash University. (julian.giordani at sci.monash.edu.au)
+##	Vincent Lemiale, Postdoctoral Fellow, Monash University. (vincent.lemiale at sci.monash.edu.au)
+##
+##  This library is free software; you can redistribute it and/or
+##  modify it under the terms of the GNU Lesser General Public
+##  License as published by the Free Software Foundation; either
+##  version 2.1 of the License, or (at your option) any later version.
+##
+##  This library is distributed in the hope that it will be useful,
+##  but WITHOUT ANY WARRANTY; without even the implied warranty of
+##  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+##  Lesser General Public License for more details.
+##
+##  You should have received a copy of the GNU Lesser General Public
+##  License along with this library; if not, write to the Free Software
+##  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+##
+## $Id: makefile 537 2006-04-24 07:30:45Z RobertTurnbull $
+##
+##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+subdirs = $(shell find * -type d -follow -prune ! -name .svn )
+
+# obtain defaults for required variables according to system and project location, and then run the build.
+SHELL := $(shell which bash)
+PROJ_ROOT:= $(shell until test -r ./Makefile.system ; do cd .. ; done ; echo `pwd`)
+
+include ${PROJ_ROOT}/Makefile.system
+include ${PROJ_ROOT}/Makefile.vmake

Modified: long/3D/Gale/trunk/src/StgFEM/src/main.c
===================================================================
--- long/3D/Gale/trunk/src/StgFEM/src/main.c	2006-06-28 09:59:25 UTC (rev 3898)
+++ long/3D/Gale/trunk/src/StgFEM/src/main.c	2006-06-28 10:01:38 UTC (rev 3899)
@@ -116,6 +116,10 @@
 	}
 	context->CF = Stg_ComponentFactory_New( dictionary, componentDict, context->register_Register );
 
+	/*check components dictionary for double entries */
+	char* errMessage = "Component dictionary must have unique names\n";
+	CheckDictionaryKeys(componentDict, errMessage);
+	
 	LiveComponentRegister_Add( context->CF->LCRegister, (Stg_Component*) context );
 	PluginsManager_Load( context->plugins, context, dictionary );
 
@@ -133,16 +137,18 @@
 	}	
 
 	/* Building phase ---------------------------------------------------------------------------------------------------*/
-	KeyCall( context, context->buildK, EntryPoint_VoidPtr_CallCast* )( KeyHandle(context,context->buildK), context );
+	//KeyCall( context, context->buildK, EntryPoint_VoidPtr_CallCast* )( KeyHandle(context,context->buildK), context );
+	Stg_Component_Build( context, 0 /* dummy */, False );
 	
 	/* Initialisaton phase ----------------------------------------------------------------------------------------------*/
-	Context_Initialise( context );
+	Stg_Component_Initialise( context, 0 /* dummy */, False );
 	
 	/* Run (Solve) phase ------------------------------------------------------------------------------------------------*/
 	AbstractContext_Dump( context );
-	Context_Run( context );		
+	Stg_Component_Execute( context, 0 /* dummy */, False );
 
 	/* Destruct phase ---------------------------------------------------------------------------------------------------*/
+	Stg_Component_Destroy( context, 0 /* dummy */, False );
 	Stg_Class_Delete( context );
 	Stg_Class_Delete( dictionary );
 



More information about the Cig-commits mailing list