Commit dd951870 authored by Tomáš Oberhuber's avatar Tomáš Oberhuber
Browse files

Writing heat equation EOC test script.

parent 46715b6e
Loading
Loading
Loading
Loading
+141 −74
Original line number Diff line number Diff line
#!/bin/bash

dofSize=64
dimension=2 
proportions=1

analyticFunction="exp-bump"
timeFunction="cosinus"
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

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
@@ -20,22 +30,31 @@ phase=0.0
      phaseX=0.0
      phaseY=0.0
      phaseZ=0.0
sigma=1.0
      sigma=0.5
   fi
}

tnl-grid-setup --dimensions ${dimension} \
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} \
               --origin-x 0 \
               --origin-y 0 \
               --origin-z 0 \
               --size-x ${dofSize} \
               --size-y ${dofSize} \
               --size-z ${dofSize} \
                  --size-x ${gridSize} \
                  --size-y ${gridSize} \
                  --size-z ${gridSize} 
}

tnl-discrete --mesh mesh.tnl \
             --function ${analyticFunction} \
             --output-file u-ini.tnl \
setInitialCondition()
{
   testFunction=$1
   tnl-init --function ${testFunction} \
            --output-file init.tnl \
            --amplitude ${amplitude} \
            --wave-length ${waveLength} \
            --wave-length-x ${waveLengthX} \
@@ -49,13 +68,17 @@ tnl-discrete --mesh mesh.tnl \
            --phase-x ${phaseX} \
            --phase-y ${phaseY} \
            --phase-z ${phaseZ} \
             --sigma ${sigma} \
            --sigma ${sigma}           
}

./heat-equation --dimensions ${dimension} \
                --time-discretisation explicit \
                --discrete-solver merson \
                --time-function ${timeFunction}\
                --analytic-space-function ${analyticFunction}\
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} \
@@ -70,15 +93,59 @@ tnl-discrete --mesh mesh.tnl \
                 --phase-y ${phaseY} \
                 --phase-z ${phaseZ} \
                 --sigma ${sigma} \
                --snapshot-period 0.05 \
                --final-time 1.0 \
                --solution-convergence-test 1 \
                 --snapshot-period ${snapshotPeriod} \
                 --final-time ${finalTime}
}
               
rm u-ini.tnl
computeError()
{

   tnl-diff --mesh mesh.tnl \
            --input-files numericalSolution-*.tnl analyticSolution-*.tnl \
            --mode halves \
         --output-file ${dofSize}-dofs \
            --output-file ${dofSize}-dofs 
}

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

         cd ..
      done
      cd ..
   done
}

runTest
rm *.tnl