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

Implementing solver monitors.

parent 78658845
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -2,7 +2,8 @@ ADD_SUBDIRECTORY( linear )
ADD_SUBDIRECTORY( pde )
ADD_SUBDIRECTORY( ode )

SET( headers tnlSolver_impl.h
SET( headers tnlIterativeSolverMonitor_impl.h
             tnlSolver_impl.h
             tnlSolverStarter_impl.h
             tnlSolverInitiator_impl.h )

+2 −1
Original line number Diff line number Diff line
SET( headers tnlEulerSolver_impl.h
             tnlMersonSolver_impl.h )
             tnlMersonSolver_impl.h 
             tnlODESolverMonitor_impl.h )

INSTALL( FILES ${headers} DESTINATION include/tnl-${tnlVersion}/implementation/solvers/ode )
+4 −13
Original line number Diff line number Diff line
@@ -71,11 +71,7 @@ bool tnlEulerSolver< Problem > :: solve( DofVectorType& u )
   if( currentTau == 0.0 ) return true;
   iteration = 0;

   /****
    * Do a printout ...
    */
   if( this -> verbosity > 0 )
      this -> printOut();
   this -> refreshSolverMonitor();

   /****
    * Start the main loop
@@ -115,11 +111,7 @@ bool tnlEulerSolver< Problem > :: solve( DofVectorType& u )
         currentTau = this -> getStopTime() - time; //we don't want to keep such tau
      else this -> tau = currentTau;

      /****
       * Do printouts if verbosity is on
       */
      if( this -> verbosity > 1 )
          this ->  printOut();
      this -> refreshSolverMonitor();

      /****
       * Check stop conditions.
@@ -127,8 +119,7 @@ bool tnlEulerSolver< Problem > :: solve( DofVectorType& u )
      if( time >= this -> getStopTime() ||
          ( this -> getMaxResidue() != 0.0 && residue < this -> getMaxResidue() ) )
       {
         if( this -> verbosity > 0 )
            this -> printOut();
         this -> refreshSolverMonitor();
         return true;
       }
      if( iteration == this -> getMaxIterationsNumber() ) return false;
+4 −13
Original line number Diff line number Diff line
@@ -142,11 +142,7 @@ bool tnlMersonSolver< Problem > :: solve( DofVectorType& u )
   if( currentTau == 0.0 ) return true;
   iteration = 0;

   /****
    * Do a printout ...
    */
   if( this -> verbosity > 0 )
      this -> printOut();
   this -> refreshSolverMonitor();

   /****
    * Start the main loop
@@ -178,6 +174,7 @@ bool tnlMersonSolver< Problem > :: solve( DofVectorType& u )
         if( currentTau + time == this -> stopTime ) residue = lastResidue;
         time += currentTau;
         iteration ++;
         this -> refreshSolverMonitor();
      }

      /****
@@ -192,11 +189,6 @@ bool tnlMersonSolver< Problem > :: solve( DofVectorType& u )
         currentTau = this -> getStopTime() - time; //we don't want to keep such tau
      else this -> tau = currentTau;

      /****
       * Do printouts if verbosity is on
       */
      if( this -> verbosity > 1 )
          this ->  printOut();

      /****
       * Check stop conditions.
@@ -204,8 +196,7 @@ bool tnlMersonSolver< Problem > :: solve( DofVectorType& u )
      if( time >= this -> getStopTime() ||
          ( this -> getMaxResidue() != 0.0 && residue < this -> getMaxResidue() ) )
       {
         if( this -> verbosity > 0 )
            this -> printOut();
         this -> refreshSolverMonitor();
         return true;
       }
      if( iteration == this -> getMaxIterationsNumber() ) return false;
+75 −0
Original line number Diff line number Diff line
/***************************************************************************
                          tnlODESolverMonitor_impl.h  -  description
                             -------------------
    begin                : Mar 12, 2013
    copyright            : (C) 2013 by Tomas Oberhuber
    email                : tomas.oberhuber@fjfi.cvut.cz
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#ifndef TNLODESOLVERMONITOR_IMPL_H_
#define TNLODESOLVERMONITOR_IMPL_H_

template< typename RealType, typename IndexType >
tnlODESolverMonitor< RealType, IndexType> :: tnlODESolverMonitor()
: timeStep( 0.0 ),
  time( 0.0 )
{
}

template< typename RealType, typename IndexType >
void tnlODESolverMonitor< RealType, IndexType> :: refresh()
{
   if( this -> verbose > 0 && this -> refreshing % this -> outputPeriod == 0 )
   {
      // TODO: add EST
      //cout << " EST: " << estimated;
      cout << " ITER:" << setw( 8 ) << this -> getIterations()
           << " TAU:" << setprecision( 5 ) << setw( 12 ) << this -> getTimeStep()
           << " T:" << setprecision( 5 ) << setw( 12 ) << this -> getTime()
           << " RES:" << setprecision( 5 ) << setw( 12 ) << this -> getResidue()
           << " CPU: " << setw( 8 ) << this -> getCPUTime()
           << " ELA: " << setw( 8 ) << this -> getRealTime();
       /*double flops = ( double ) tnl_flops_counter. getFlops();
       if( flops )
       {
         cout << " GFLOPS:  " << setw( 8 ) << 1.0e-9 * flops / rt_timer -> GetTime();
       }*/
       cout << "   \r" << flush;
    }
   this -> refreshing ++;
}

template< typename RealType, typename IndexType >
void tnlODESolverMonitor< RealType, IndexType> :: setTimeStep( const RealType& timeStep )
{
   this -> timeStep = timeStep;
}

template< typename RealType, typename IndexType >
const RealType& tnlODESolverMonitor< RealType, IndexType> :: getTimeStep() const
{
   return this -> timeStep;
}

template< typename RealType, typename IndexType >
void tnlODESolverMonitor< RealType, IndexType> :: setTime( const RealType& time )
{
   this -> time = time;
}

template< typename RealType, typename IndexType >
const RealType& tnlODESolverMonitor< RealType, IndexType> :: getTime() const
{
   return this -> time;
}

#endif /* TNLODESOLVERMONITOR_IMPL_H_ */
Loading