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

Adding CFL condtant to the Euler explicit ODE solver.

parent 8ba02696
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -250,7 +250,7 @@ bool tnlGrid< 2, Real, Device, Index> :: write( const MeshFunction& function,
         for( IndexType i = 0; i < getDimensions(). x(); i++ )
         {
            const RealType x = this -> getLowerCorner(). x() + i * hx;
            const RealType y = this -> getLowerCorner(). y() + i * hy;
            const RealType y = this -> getLowerCorner(). y() + j * hy;
            file << x << " " << " " << y << " " << function[ this -> getNodeIndex( j, i ) ] << endl;
         }
         file << endl;
+33 −1
Original line number Diff line number Diff line
@@ -37,6 +37,10 @@ class tnlEulerSolver : public tnlExplicitSolver< Problem >

   tnlString getType() const;

   void setCFLCondition( const RealType& cfl );

   const RealType& getCFLCondition() const;

   bool solve( DofVectorType& u );

   protected:
@@ -46,11 +50,14 @@ class tnlEulerSolver : public tnlExplicitSolver< Problem >

   
   DofVectorType k1;

   RealType cflCondition;
};

template< typename Problem >
tnlEulerSolver< Problem > :: tnlEulerSolver()
: k1( "tnlEulerSolver:k1" )
: k1( "tnlEulerSolver:k1" ),
  cflCondition( 0.0 )
{
};

@@ -62,6 +69,18 @@ tnlString tnlEulerSolver< Problem > :: getType() const
          tnlString( " >" );
};

template< typename Problem >
void tnlEulerSolver< Problem > :: setCFLCondition( const RealType& cfl )
{
   this -> cflCondition = cfl;
}

template< typename Problem >
const typename Problem :: RealType& tnlEulerSolver< Problem > :: getCFLCondition() const
{
   return this -> cflCondition;
}

template< typename Problem >
bool tnlEulerSolver< Problem > :: solve( DofVectorType& u )
{
@@ -104,6 +123,16 @@ bool tnlEulerSolver< Problem > :: solve( DofVectorType& u )
      this -> problem -> GetExplicitRHS( time, currentTau, u, k1 );

      RealType lastResidue = residue;
      RealType maxResidue( 0.0 );
      if( this -> cflCondition != 0.0 )
      {
         maxResidue = k1. absMax();
         if( currentTau * maxResidue > this -> cflCondition )
         {
            currentTau *= 0.9;
            continue;
         }
      }
      computeNewTimeLevel( u, currentTau, residue );

      /****
@@ -138,6 +167,9 @@ bool tnlEulerSolver< Problem > :: solve( DofVectorType& u )
          return true;
       }
      if( iteration == this -> getMaxIterationsNumber() ) return false;

      if( this -> cflCondition != 0.0 )
         currentTau /= 0.95;
   }
};