From dd9518700c88116639543bc8a53f9b8c3d25a982 Mon Sep 17 00:00:00 2001
From: Tomas Oberhuber <tomas.oberhuber@fjfi.cvut.cz>
Date: Fri, 12 Sep 2014 22:18:53 +0200
Subject: [PATCH] Writing heat equation EOC test script.

---
 .../tnl-run-heat-equation-eoc-test            | 215 ++++++++++++------
 1 file changed, 141 insertions(+), 74 deletions(-)

diff --git a/examples/heat-equation/tnl-run-heat-equation-eoc-test b/examples/heat-equation/tnl-run-heat-equation-eoc-test
index 2f71cca49f..cec1fa19dd 100644
--- a/examples/heat-equation/tnl-run-heat-equation-eoc-test
+++ b/examples/heat-equation/tnl-run-heat-equation-eoc-test
@@ -1,84 +1,151 @@
 #!/bin/bash
 
-dofSize=64
-dimension=2 
-proportions=1
+solverName="tnl-heat-equation-eoc-test"
+device="host"
+dimensions="1D 2D 3D"
+sizes1D="16 32 64 128 256 512"
+sizes2D="16 32 64 128 256 512"
+sizes3D="16 32 64 128"
+testFunctions="exp-bump"
+snapshotPeriod=0.1
+finalTime=1
 
-analyticFunction="exp-bump"
-timeFunction="cosinus"
+setupTestFunction()
+{
+   testFunction=$1
+   if test x${testFunction} = "xexp-bump";
+   then
+      origin=-1.0
+      proportions=2.0
+      amplitude=1.0
+      waveLength=1.0
+      waveLengthX=1.0
+      waveLengthY=1.0
+      waveLengthZ=1.0
+      wavesNumber=0.0
+      wavesNumberX=0.0
+      wavesNumberY=0.0
+      wavesNumberZ=0.0
+      phase=0.0
+      phaseX=0.0
+      phaseY=0.0
+      phaseZ=0.0
+      sigma=0.5
+   fi
+}
 
-amplitude=1.0
-waveLength=1.0
-waveLengthX=1.0
-waveLengthY=1.0
-waveLengthZ=1.0
-wavesNumber=0.0
-wavesNumberX=0.0
-wavesNumberY=0.0
-wavesNumberZ=0.0
-phase=0.0
-phaseX=0.0
-phaseY=0.0
-phaseZ=0.0
-sigma=1.0
+setupGrid()
+{
+   dimensions=$1
+   gridSize=$2
+   tnl-grid-setup --dimensions ${dimensions} \
+                  --origin-x ${origin} \
+                  --origin-y ${origin} \
+                  --origin-z ${origin} \
+                  --proportions-x ${proportions} \
+                  --proportions-y ${proportions} \
+                  --proportions-z ${proportions} \
+                  --size-x ${gridSize} \
+                  --size-y ${gridSize} \
+                  --size-z ${gridSize} 
+}
 
-tnl-grid-setup --dimensions ${dimension} \
-               --proportions-x ${proportions} \
-               --proportions-y ${proportions} \
-               --proportions-z ${proportions} \
-               --origin-x 0 \
-               --origin-y 0 \
-               --origin-z 0 \
-               --size-x ${dofSize} \
-               --size-y ${dofSize} \
-               --size-z ${dofSize} \
+setInitialCondition()
+{
+   testFunction=$1
+   tnl-init --function ${testFunction} \
+            --output-file init.tnl \
+            --amplitude ${amplitude} \
+            --wave-length ${waveLength} \
+            --wave-length-x ${waveLengthX} \
+            --wave-length-y ${waveLengthY} \
+            --wave-length-z ${waveLengthZ} \
+            --waves-number ${wavesNumber} \
+            --waves-number-x ${wavesNumberX} \
+            --waves-number-y ${wavesNumberY} \
+            --waves-number-z ${wavesNumberZ} \
+            --phase ${phase} \
+            --phase-x ${phaseX} \
+            --phase-y ${phaseY} \
+            --phase-z ${phaseZ} \
+            --sigma ${sigma}           
+}
+
+solve()
+{
+   timeDiscretisation=$1
+   discreteSolver=$2
+   ${solverName} --mesh mesh.tnl \
+                 --time-discretisation ${timeDiscretisation} \
+                 --discrete-solver ${discreteSolver} \
+                 --test-function ${testFunction}\
+                 --amplitude ${amplitude} \
+                 --wave-length ${waveLength} \
+                 --wave-length-x ${waveLengthX} \
+                 --wave-length-y ${waveLengthY} \
+                 --wave-length-z ${waveLengthZ} \
+                 --waves-number ${wavesNumber} \
+                 --waves-number-x ${wavesNumberX} \
+                 --waves-number-y ${wavesNumberY} \
+                 --waves-number-z ${wavesNumberZ} \
+                 --phase ${phase} \
+                 --phase-x ${phaseX} \
+                 --phase-y ${phaseY} \
+                 --phase-z ${phaseZ} \
+                 --sigma ${sigma} \
+                 --snapshot-period ${snapshotPeriod} \
+                 --final-time ${finalTime}
+}
                
-tnl-discrete --mesh mesh.tnl \
-             --function ${analyticFunction} \
-             --output-file u-ini.tnl \
-             --amplitude ${amplitude} \
-             --wave-length ${waveLength} \
-             --wave-length-x ${waveLengthX} \
-             --wave-length-y ${waveLengthY} \
-             --wave-length-z ${waveLengthZ} \
-             --waves-number ${wavesNumber} \
-             --waves-number-x ${wavesNumberX} \
-             --waves-number-y ${wavesNumberY} \
-             --waves-number-z ${wavesNumberZ} \
-             --phase ${phase} \
-             --phase-x ${phaseX} \
-             --phase-y ${phaseY} \
-             --phase-z ${phaseZ} \
-             --sigma ${sigma} \
+computeError()
+{
+
+   tnl-diff --mesh mesh.tnl \
+            --input-files numericalSolution-*.tnl analyticSolution-*.tnl \
+            --mode halves \
+            --output-file ${dofSize}-dofs 
+}
 
-./heat-equation --dimensions ${dimension} \
-                --time-discretisation explicit \
-                --discrete-solver merson \
-                --time-function ${timeFunction}\
-                --analytic-space-function ${analyticFunction}\
-                --amplitude ${amplitude} \
-                --wave-length ${waveLength} \
-                --wave-length-x ${waveLengthX} \
-                --wave-length-y ${waveLengthY} \
-                --wave-length-z ${waveLengthZ} \
-                --waves-number ${wavesNumber} \
-                --waves-number-x ${wavesNumberX} \
-                --waves-number-y ${wavesNumberY} \
-                --waves-number-z ${wavesNumberZ} \
-                --phase ${phase} \
-                --phase-x ${phaseX} \
-                --phase-y ${phaseY} \
-                --phase-z ${phaseZ} \
-                --sigma ${sigma} \
-                --snapshot-period 0.05 \
-                --final-time 1.0 \
-                --solution-convergence-test 1 \
+runTest()
+{
+   for testFunction in ${testFunctions};
+   do
+      mkdir -p ${testFunction}
+      cd ${testFunction}
+      setupTestFunction ${testFunction}
+      
+      for dim in ${dimensions};
+      do
+         mkdir -p $dim
+         cd ${dim}
+         if test $dim = 1D;
+         then 
+            sizes=$sizes1D
+         fi
+         if test $dim = 2D;
+         then 
+            sizes=$sizes2D
+         fi
+         if test $dim = 3D;
+         then 
+            sizes=$sizes3D
+         fi
+         
+         for size in $sizes;
+         do
+            mkdir -p $size
+            cd $size
+               setupGrid $dim $size 
+               setInitialCondition $testFunction
+               solve explicit merson
+            cd ..
+         done
 
-rm u-ini.tnl
+         cd ..
+      done
+      cd ..
+   done
+}
 
-tnl-diff --mesh mesh.tnl \
-         --input-files numericalSolution-*.tnl analyticSolution-*.tnl \
-         --mode halves \
-         --output-file ${dofSize}-dofs \
+runTest
 
-rm *.tnl     
-- 
GitLab