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

Fixing FDM Lax-Fridrichs scheme.

parent a0767279
Loading
Loading
Loading
Loading
+12 −12
Original line number Diff line number Diff line
@@ -81,7 +81,7 @@ tnlString :: ~tnlString()
{
   if( string ) delete[] string;
}
//---------------------------------------------------------------------------

void tnlString :: setString( const char* c, int prefix_cut_off, int sufix_cut_off )
{
   if( ! c )
@@ -111,27 +111,27 @@ void tnlString :: setString( const char* c, int prefix_cut_off, int sufix_cut_of
   memcpy( string, c + Min( c_len, prefix_cut_off ), sizeof( char ) * ( _length ) );
   string[ _length ] = 0;
}
//---------------------------------------------------------------------------

const char& tnlString :: operator[]( int i ) const
{
   tnlAssert( i >= 0 && i < length,
              cerr << "Accessing char outside the string." );
   return string[ i ];
}
//---------------------------------------------------------------------------

char& tnlString :: operator[]( int i )
{
   tnlAssert( i >= 0 && i < length,
              cerr << "Accessing char outside the string." );
   return string[ i ];
}
//---------------------------------------------------------------------------

tnlString& tnlString :: operator = ( const tnlString& str )
{
   setString( str. getString() );
   return * this;
}
//---------------------------------------------------------------------------

tnlString& tnlString :: operator += ( const char* str )
{
   if( str )
@@ -151,7 +151,7 @@ tnlString& tnlString :: operator += ( const char* str )
   }
   return * this;
}
//---------------------------------------------------------------------------

tnlString& tnlString :: operator += ( const char str )
{
   int len1 = strlen( string );
@@ -172,22 +172,22 @@ tnlString& tnlString :: operator += ( const char str )

   return * this;
}
//---------------------------------------------------------------------------

tnlString& tnlString :: operator += ( const tnlString& str )
{
   return operator += ( str. getString() );
}
//---------------------------------------------------------------------------

tnlString tnlString :: operator + ( const tnlString& str )
{
   return tnlString( *this ) += str;
}
//---------------------------------------------------------------------------

tnlString tnlString :: operator + ( const char* str )
{
   return tnlString( *this ) += str;
}
//---------------------------------------------------------------------------

bool tnlString :: operator == ( const tnlString& str ) const
{
   assert( string && str. string );
@@ -197,12 +197,12 @@ bool tnlString :: operator == ( const tnlString& str ) const
      return true;
   return false;
}
//---------------------------------------------------------------------------

bool tnlString :: operator != ( const tnlString& str ) const
{
   return ! operator == ( str );
}
//---------------------------------------------------------------------------

bool tnlString :: operator == ( const char* str ) const
{
   //cout << ( void* ) string << " " << ( void* ) str << endl;
+7 −6
Original line number Diff line number Diff line
@@ -368,7 +368,8 @@ template< typename Real,
void tnlLaxFridrichs< tnlGrid< 2, Real, Device, Index, tnlIdenticalGridGeometry >, PressureGradient  > :: getExplicitRhs( const IndexType centralVolume,
                                                                                                                          RealType& rho_t,
                                                                                                                          RealType& rho_u1_t,
                                                                                                RealType& rho_u2_t ) const
                                                                                                                          RealType& rho_u2_t,
                                                                                                                          const RealType& tau ) const
{
   tnlAssert( mesh, cerr << "No mesh has been binded with the Lax-Fridrichs scheme." );
   tnlAssert( pressureGradient, cerr << "No pressure gradient was set in the the Lax-Fridrichs scheme." )
@@ -391,7 +392,7 @@ void tnlLaxFridrichs< tnlGrid< 2, Real, Device, Index, tnlIdenticalGridGeometry
   const RealType u1_w = rho_u1[ w ] / regularize( rho[ w ] );
   const RealType u2_n = rho_u2[ n ] / regularize( rho[ n ] );
   const RealType u2_s = rho_u2[ s ] / regularize( rho[ s ] );
   rho_t = this -> viscosityCoefficient * 0.25 * ( rho[ e ] + rho[ w ] + rho[ s ] + rho[ n ] - 4.0 * rho[ c ] )
   rho_t = this -> viscosityCoefficient / tau * 0.25 * ( rho[ e ] + rho[ w ] + rho[ s ] + rho[ n ] - 4.0 * rho[ c ] )
               - ( rho[ e ] * u1_e - rho[ w ] * u1_w ) / ( 2.0 * hx )
               - ( rho[ n ] * u2_n - rho[ s ] * u2_s ) / ( 2.0 * hy );

@@ -404,14 +405,14 @@ void tnlLaxFridrichs< tnlGrid< 2, Real, Device, Index, tnlIdenticalGridGeometry
   /****
    * ( rho * u1 )_t + ( rho * u1 * u1 )_x + ( rho * u1 * u2 )_y - p_x =  0
    */
   rho_u1_t = this -> viscosityCoefficient * 0.25 * ( rho_u1[ e ] + rho_u1[ w ] + rho_u1[ s ] + rho_u1[ n ] - 4.0 * rho_u1[ c ] )
   rho_u1_t = this -> viscosityCoefficient / tau * 0.25 * ( rho_u1[ e ] + rho_u1[ w ] + rho_u1[ s ] + rho_u1[ n ] - 4.0 * rho_u1[ c ] )
                   - ( rho_u1[ e ] * u1_e - rho_u1[ w ] * u1_w ) / ( 2.0 * hx )
                   - ( rho_u1[ n ] * u2_n - rho_u1[ s ] * u2_s ) / ( 2.0 * hy )
                   - grad_p. x();
   /****
    * ( rho * u2 )_t + ( rho * u2 * u1 )_x + ( rho * u2 * u2 )_y - p_y =  0
    */
   rho_u2_t = this -> viscosityCoefficient * 0.25 * ( rho_u2[ e ] + rho_u2[ w ] + rho_u2[ s ] + rho_u2[ n ] - 4.0 * rho_u2[ c ] )
   rho_u2_t = this -> viscosityCoefficient / tau * 0.25 * ( rho_u2[ e ] + rho_u2[ w ] + rho_u2[ s ] + rho_u2[ n ] - 4.0 * rho_u2[ c ] )
                   - ( rho_u2[ e ] * u1_e - rho_u2[ w ] * u1_w ) / ( 2.0 * hx )
                   - ( rho_u2[ n ] * u2_n - rho_u2[ s ] * u2_s ) / ( 2.0 * hy )
                   - grad_p. y();