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

Fixed solver monitor.

parent dcc60b21
Loading
Loading
Loading
Loading
+163 −81
Original line number Diff line number Diff line
#!/bin/bash

dofSize=64
dimension=2;
proportions=1

analyticFunction="exp-bump"
timeFunction="cosinus"
device="host"
threadsNumbers="1 2 4 6"
dimensions="1D 2D 3D"
#dimensions="2D"
sizes1D="16 32 64 128 256 512"
#sizes1D="256"
sizes2D="16 32 64 128 256 512"
#sizes2D="8"
sizes3D="16 32 64 128"
testFunction="exp-bump"
snapshotPeriod=0.5
finalTime=0.5
#solverName="tnl-heat-equation"
solverName="tnl-heat-equation-dbg"
#

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 +36,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-init --mesh mesh.tnl \
         --test-function ${analyticFunction} \
         --output-file initial.tnl \
setInitialCondition()
{
   testFunction=$1
   tnl-init --test-function ${testFunction} \
            --output-file exact-u.tnl \
            --amplitude ${amplitude} \
            --wave-length ${waveLength} \
            --wave-length-x ${waveLengthX} \
@@ -49,42 +74,99 @@ tnl-init --mesh mesh.tnl \
            --phase-x ${phaseX} \
            --phase-y ${phaseY} \
            --phase-z ${phaseZ} \
             --sigma ${sigma} \
            --sigma ${sigma}
}

solve()
{
   timeDiscretisation=$1
   discreteSolver=$2
   threadsNumber=$3
   ${solverName} --device ${device} \
                 --mesh mesh.tnl \
                 --initial-condition exact-u.tnl \
                 --boundary-conditions-file exact-u.tnl \
                 --time-discretisation ${timeDiscretisation} \
                 --time-step 10 \
                 --time-step-order 2 \
                 --discrete-solver ${discreteSolver} \
                 --merson-adaptivity 1.0e-5 \
                 --sor-omega 1.95 \
                 --gmres-restarting 10 \
                 --min-iterations 20 \
                 --convergence-residue 1.0e-12 \
                 --snapshot-period ${snapshotPeriod} \
                 --final-time ${finalTime} \
                 --refresh-rate 50 \
                 --openmp-enabled true \
                 --openmp-max-threads ${threadsNumber}
}
               
tnl-heat-equation --time-discretisation explicit \
                  --boundary-conditions-type dirichlet \
                  --boundary-conditions-constant 0.5 \
                  --discrete-solver merson \
                  --snapshot-period 0.0005 \
                  --final-time 0.1 \
runTest()
{
   for threadsNumber in ${threadsNumbers};
   do
      mkdir -p threads-${threadsNumber}
      cd threads-${threadsNumber}
      setupTestFunction ${testFunction}
     
tnl-view --mesh mesh.tnl \
         --input-files *.tnl \ 
      
seznam=`ls u-*.gplt`
      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 fname in $seznam ; do
   echo "Drawing $fname"
gnuplot << EOF
    set terminal unknown
    #set view 33,33 #3D
    #unset xtics 
    #unset ytics
    #unset ztics
    unset border
    set output '$fname.png'
    set yrange [-1.2:1.2]
    set zrange [0.4:1.1]    
    set terminal png
    set title "Numerical solution" 
    splot '$fname' with line 
EOF
         lastSize=""
         for size in $sizes;
         do
            mkdir -p $size
            cd $size
            echo ""
            echo ""
            echo ""
            if test ! -f computation-done;
            then
               touch computation-in-progress
               echo "========================================================================="
               echo "===                   SETTING UP THE GRID                             ==="
               echo "========================================================================="
               setupGrid $dim $size 
               echo "========================================================================="
               echo "===                WRITING THE EXACT SOLUTION                         ==="
               echo "========================================================================="
               setInitialCondition $testFunction
               echo "========================================================================="
               echo "===                   STARTING THE SOLVER                             ==="
               echo "========================================================================="
               solve explicit merson ${threadsNumber}
               #solve semi-implicit gmres ${threadsNumber}
               mv computation-in-progress computation-done
            fi            
            echo "========================================================================="
            echo "===                     COMPUTATION DONE                              ==="            
            echo "========================================================================="
            cd ..
            lastSize=$size
         done

         cd ..
      done
      cd ..
   done
}

mencoder "mf://u-*.png" -mf fps=22 -o diffusion.avi -ovc lavc -lavcopts vcodec=mpeg4
runTest
 
#rm *.png
#rm *.tnl         
#rm *.gplt      
+0 −4
Original line number Diff line number Diff line
@@ -220,10 +220,6 @@ getExplicitRHS( const RealType& time,
    * You may use supporting vectors again if you need.
    */
   
   //cout << "u = " << u << endl;
   //std::cerr << "==========================================================================================" << std::endl;
   //std::cerr << "==========================================================================================" << std::endl;
   //std::cerr << "==========================================================================================" << std::endl;
   this->bindDofs( meshPointer, uDofs );
   MeshFunctionPointer fuPointer( meshPointer, fuDofs );   
   explicitUpdater.template update< typename Mesh::Cell >(
+3 −3
Original line number Diff line number Diff line
@@ -83,7 +83,7 @@ void IterativeSolverMonitor< Real, Index > :: refresh( bool force )

      // FIXME: std::setw sets only minimum width, so free should be adjusted dynamically if more chars are actually written
      std::cout << std::setprecision( 5 );
      std::cout << " ELA:" << std::setw( 8 ) << this->getElapsedTime()
      std::cout << "\33[2K\r ELA:" << std::setw( 8 ) << this->getElapsedTime()
                << " T:"   << std::setw( 8 ) << this->time;
      free -= 24;
      if( this->timeStep > 0 ) {
@@ -112,8 +112,8 @@ void IterativeSolverMonitor< Real, Index > :: refresh( bool force )
      }

      // fill the rest of the line with spaces to clear previous content
      while( line_width && free-- > 0 )
         std::cout << " ";
      //while( line_width && free-- > 8 )
      //   std::cout << " ";
      std::cout << "\r" << std::flush;
   }
}
+1 −1
Original line number Diff line number Diff line
@@ -23,7 +23,7 @@ class SolverMonitor
   public:

   SolverMonitor()
      : timeout_milliseconds(1),
      : timeout_milliseconds(500),
        stopped(true)
   {};