diff --git a/src/implementation/mesh/tnlGrid2D_impl.h b/src/implementation/mesh/tnlGrid2D_impl.h index 497793165958aeaa10258a45bdd14b254765b1db..f626a05f1e364d5d5cf9a598348c31b4bbfcfbac 100644 --- a/src/implementation/mesh/tnlGrid2D_impl.h +++ b/src/implementation/mesh/tnlGrid2D_impl.h @@ -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; diff --git a/src/solvers/ode/tnlEulerSolver.h b/src/solvers/ode/tnlEulerSolver.h index 2ae57afd7f418b0d3833afe3d254c8a04d2881b7..baf60a9467a633d9799176b084085461a42f039d 100644 --- a/src/solvers/ode/tnlEulerSolver.h +++ b/src/solvers/ode/tnlEulerSolver.h @@ -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; } };