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

Implementing tnlEllpackMatrix.

Adding solver monitor to the navier-stokes example.
parent d1eeb489
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -38,6 +38,7 @@ class navierStokesBoundaryConditions

   template< typename Vector >
   void apply( const RealType& time,
               const RealType& tau,
               Vector& rho,
               Vector& u1,
               Vector& u2,
@@ -47,7 +48,7 @@ class navierStokesBoundaryConditions

   const MeshType* mesh;

   RealType maxInflowVelocity, startUp, T, p0;
   RealType maxInflowVelocity, startUp, T, R, p0;
};

#include "navierStokesBoundaryConditions_impl.h"
+8 −9
Original line number Diff line number Diff line
@@ -34,7 +34,8 @@ bool navierStokesBoundaryConditions< Mesh >::init( const tnlParameterContainer&
   this -> maxInflowVelocity = parameters. GetParameter< double >( "max-inflow-velocity" );
   //this -> maxOutflowVelocity = parameters. GetParameter< double >( "max-outflow-velocity" );
   this -> startUp = parameters. GetParameter< double >( "start-up" );
   //this -> T = parameters. GetParameter< double >( "T" );
   this -> T = parameters. GetParameter< double >( "T" );
   this -> R = parameters. GetParameter< double >( "R" );
   this->p0 = parameters. GetParameter< double >( "p0" );
   return true;
}
@@ -48,6 +49,7 @@ void navierStokesBoundaryConditions< Mesh >::setMesh( const MeshType& mesh )
template< typename Mesh >
   template< typename Vector >
void navierStokesBoundaryConditions< Mesh >::apply( const RealType& time,
                                                    const RealType& tau,
                                                    Vector& rho,
                                                    Vector& u1,
                                                    Vector& u2,
@@ -92,11 +94,6 @@ void navierStokesBoundaryConditions< Mesh >::apply( const RealType& time,
         energy[ c3 ] = energy[ c4 ];
          //rho[ c3 ] = this -> p_0 / ( this -> R * this -> T );
      }

      /*rho_u1[ c1 ] = rho[ c1 ] * this -> u1[ c1 ];
      rho_u2[ c1 ] = rho[ c1 ] * this -> u2[ c1 ];
      rho_u1[ c3 ] = rho[ c3 ] * this -> u1[ c3 ];
      rho_u2[ c3 ] = rho[ c3 ] * this -> u2[ c3 ];*/
   }
   for( IndexType j = 0; j < ySize; j ++ )
   {
@@ -104,9 +101,11 @@ void navierStokesBoundaryConditions< Mesh >::apply( const RealType& time,
      const IndexType c2 = this->mesh->getElementIndex( 1, j );
      const IndexType c3 = this->mesh->getElementIndex( xSize - 1, j );
      const IndexType c4 = this->mesh->getElementIndex( xSize - 2, j );

      const IndexType c5 = this->mesh->getElementIndex( 2, j );
      const IndexType c6 = this->mesh->getElementIndex( xSize - 3, j );
      RealType y = j * hy / this->mesh->getProportions().y();


      /****
       * Boundary conditions on the left and right
       */
@@ -119,8 +118,8 @@ void navierStokesBoundaryConditions< Mesh >::apply( const RealType& time,

         rho[ c1 ] = rho[ c2 ];
         rho[ c3 ] = rho[ c4 ];
         energy[ c1 ] = energy[ c2 ];
         energy[ c3 ] = energy[ c4 ];
         energy[ c1 ] = energy[ c2 ];// - tau*( energy[ c2 ] - energy[ c1 ] ) / hx;
         energy[ c3 ] = energy[ c4 ];// - tau*( energy[ c3 ] - energy[ c4 ] ) / hx;
      }
      /*rho_u1[ c1 ] = rho[ c1 ] * this -> u1[ c1 ];
      rho_u2[ c1 ] = rho[ c1 ] * this -> u2[ c1 ];
+1 −32
Original line number Diff line number Diff line
@@ -29,39 +29,8 @@ class navierStokesSolverMonitor : public tnlODESolverMonitor< Real, Index >

   void refresh();

   void setBetaMax( const Real& betaMax );
   Real uMax, uAvg, rhoMax, rhoAvg, rhoUMax, rhoUAvg, eMax, eAvg;

   void setEpsSMax( const Real& epsSMax );

   void setUSMax( const Real& u_s_max );

   void setUGMax( const Real& u_g_max );

   void setEps_rho_g_max( const Real& eps_rho_g_max );
   void setEps_rho_u1_g_max( const Real& eps_rho_u1_g_max );
   void setEps_rho_u2_g_max( const Real& eps_rho_u2_g_max );
   void setEps_rho_g_t_max( const Real& eps_rho_g_t_max );
   void setEps_rho_u1_g_t_max( const Real& eps_rho_u1_g_t_max );
   void setEps_rho_u2_g_t_max( const Real& eps_rho_u2_g_t_max );
   void setEps_rho_s_max( const Real& eps_rho_s_max );
   void setEps_rho_u1_s_max( const Real& eps_rho_u1_s_max );
   void setEps_rho_u2_s_max( const Real& eps_rho_u2_s_max );
   void setEps_rho_s_t_max( const Real& eps_rho_s_t_max );
   void setEps_rho_u1_s_t_max( const Real& eps_rho_u1_s_t_max );
   void setEps_rho_u2_s_t_max( const Real& eps_rho_u2_s_t_max );

   protected:

   public:

   Real beta_max, eps_s_max, u_s_max, u_g_max, G_max;
   Real eps_rho_g_max, eps_rho_u1_g_max, eps_rho_u2_g_max,
        eps_rho_g_t_max, eps_rho_u1_g_t_max, eps_rho_u2_g_t_max,
        eps_rho_s_max, eps_rho_u1_s_max, eps_rho_u2_s_max,
        eps_rho_s_t_max, eps_rho_u1_s_t_max, eps_rho_u2_s_t_max;

   public:
   Index u_s_max_i, u_s_max_j;
};

#include "navierStokesSolverMonitor_impl.h"
+4 −218
Original line number Diff line number Diff line
@@ -24,234 +24,20 @@ using namespace std;

template< typename Real, typename Index >
navierStokesSolverMonitor< Real, Index > :: navierStokesSolverMonitor()
: beta_max( 0.0 ),
  eps_s_max( 0.0 ),
  u_s_max( 0.0 ),
  u_g_max( 0.0 ),
  G_max( 0.0 ),
  eps_rho_g_max( 0.0 ),
  eps_rho_u1_g_max( 0.0 ),
  eps_rho_u2_g_max( 0.0 ),
  eps_rho_g_t_max( 0.0 ),
  eps_rho_u1_g_t_max( 0.0 ),
  eps_rho_u2_g_t_max( 0.0 ),
  eps_rho_s_max( 0.0 ),
  eps_rho_u1_s_max( 0.0 ),
  eps_rho_u2_s_max( 0.0 ),
  eps_rho_s_t_max( 0.0 ),
  eps_rho_u1_s_t_max( 0.0 ),
  eps_rho_u2_s_t_max( 0.0 )
{
   /****
    * Reset statistics files
    */
   fstream file;
   file. open( "tau.txt", ios :: out );
   file. close();
   file. open( "beta-max.txt", ios :: out );
   file. close();
   file. open( "eps-s-max.txt", ios :: out );
   file. close();
   file. open( "u-s-max.txt", ios :: out );
   file. close();
   file. open( "u-g-max.txt", ios :: out );
   file. close();
   file. open( "eps-rho-g-max.txt", ios :: out );
   file. close();
   file. open( "eps-rho-u1-g-max.txt", ios :: out );
   file. close();
   file. open( "eps-rho-u2-g-max.txt", ios :: out );
   file. close();
   file. open( "eps-rho-g-t-max.txt", ios :: out );
   file. close();
   file. open( "eps-rho-u1-g-t-max.txt", ios :: out );
   file. close();
   file. open( "eps-rho-u2-g-t-max.txt", ios :: out );
   file. close();
   file. open( "eps-rho-s-max.txt", ios :: out );
   file. close();
   file. open( "eps-rho-u1-s-max.txt", ios :: out );
   file. close();
   file. open( "eps-rho-u2-s-max.txt", ios :: out );
   file. close();
   file. open( "eps-rho-s-t-max.txt", ios :: out );
   file. close();
   file. open( "eps-rho-u1-s-t-max.txt", ios :: out );
   file. close();
   file. open( "eps-rho-u2-s-t-max.txt", ios :: out );
   file. close();
}

template< typename Real, typename Index >
void navierStokesSolverMonitor< Real, Index > :: refresh()
{
   /****
    * Write to statistics files
    */
   fstream file;
   file. open( "tau.txt", ios :: out | ios :: app );
   file << this -> getTime() << " " << log10( this -> getTimeStep()  ) << endl;
   file. close();
   file. open( "beta-max.txt", ios :: out | ios :: app );
   file << this -> getTime() << " " << log10( this -> beta_max ) << endl;
   file. close();
   file. open( "eps-s-max.txt", ios :: out | ios :: app );
   file << this -> getTime() << " " << this -> eps_s_max << endl;
   file. close();
   file. open( "u-s-max.txt", ios :: out | ios :: app );
   file << this -> getTime() << " " << this -> u_s_max << endl;
   file. close();
   file. open( "u-g-max.txt", ios :: out | ios :: app );
   file << this -> getTime() << " " << this -> u_g_max << endl;
   file. close();
   file. open( "eps-rho-g-max.txt", ios :: out | ios :: app );
   file << this -> getTime() << " " << this -> eps_rho_g_max << endl;
   file. close();
   file. open( "eps-rho-u1-g-max.txt", ios :: out | ios :: app );
   file << this -> getTime() << " " << this -> eps_rho_u1_g_max << endl;
   file. close();
   file. open( "eps-rho-u2-g-max.txt", ios :: out | ios :: app );
   file << this -> getTime() << " " << this -> eps_rho_u2_g_max << endl;
   file. close();
   file. open( "eps-rho-g-t-max.txt", ios :: out | ios :: app );
   file << this -> getTime() << " " << this -> eps_rho_g_t_max << endl;
   file. close();
   file. open( "eps-rho-u1-g-t-max.txt", ios :: out | ios :: app );
   file << this -> getTime() << " " << this -> eps_rho_u1_g_t_max << endl;
   file. close();
   file. open( "eps-rho-u2-g-t-max.txt", ios :: out | ios :: app );
   file << this -> getTime() << " " << this -> eps_rho_u2_g_t_max << endl;
   file. close();
   file. open( "eps-rho-s-max.txt", ios :: out | ios :: app );
   file << this -> getTime() << " " << this -> eps_rho_s_max << endl;
   file. close();
   file. open( "eps-rho-u1-s-max.txt", ios :: out | ios :: app );
   file << this -> getTime() << " " << this -> eps_rho_u1_s_max << endl;
   file. close();
   file. open( "eps-rho-u2-s-max.txt", ios :: out | ios :: app );
   file << this -> getTime() << " " << this -> eps_rho_u2_s_max << endl;
   file. close();
   file. open( "eps-rho-s-t-max.txt", ios :: out | ios :: app );
   file << this -> getTime() << " " << this -> eps_rho_s_t_max << endl;
   file. close();
   file. open( "eps-rho-u1-s-t-max.txt", ios :: out  | ios :: app);
   file << this -> getTime() << " " << this -> eps_rho_u1_s_t_max << endl;
   file. close();
   file. open( "eps-rho-u2-s-t-max.txt", ios :: out | ios :: app );
   file << this -> getTime() << " " << this -> eps_rho_u2_s_t_max << endl;
   file. close();



   if( this -> verbose > 0 && this -> refreshing % this -> outputPeriod == 0 )
   {
      /*cout << "u-max I: "<< setw( 3 ) << this -> u_s_max_i
           << " J: "<< setw( 3 ) << this -> u_s_max_j
           << " G_max: " << setw( 6 ) << this -> G_max;*/
      //cout << setprecision( 5 )
      //     << "betaMax: " << setw( 8 ) << this -> beta_max
      //     << " epsSMax: " << setw( 8 ) << this -> eps_s_max;
      cout << "V=( " << uMax
           << " , " << uAvg
           << " ) E=( " << eMax
           << ", " << eAvg << " ) ";
   }
   tnlODESolverMonitor< Real, Index > :: refresh();
}

template< typename Real, typename Index >
void navierStokesSolverMonitor< Real, Index > :: setBetaMax( const Real& beta_max )
{
   this -> beta_max = beta_max;
}

template< typename Real, typename Index >
void navierStokesSolverMonitor< Real, Index > :: setEpsSMax( const Real& eps_s_max )
{
   this -> eps_s_max = eps_s_max;
}

template< typename Real, typename Index >
void navierStokesSolverMonitor< Real, Index > :: setUSMax( const Real& u_s_max )
{
   this -> u_s_max = u_s_max;
}

template< typename Real, typename Index >
void navierStokesSolverMonitor< Real, Index > :: setUGMax( const Real& u_g_max )
{
   this -> u_g_max = u_g_max;
}

template< typename Real, typename Index >
void navierStokesSolverMonitor< Real, Index > :: setEps_rho_g_max( const Real& eps_rho_g_max )
{
   this -> eps_rho_g_max = eps_rho_g_max;
}

template< typename Real, typename Index >
void navierStokesSolverMonitor< Real, Index > :: setEps_rho_u1_g_max( const Real& eps_rho_u1_g_max )
{
   this -> eps_rho_u1_g_max = eps_rho_u1_g_max;
}

template< typename Real, typename Index >
void navierStokesSolverMonitor< Real, Index > :: setEps_rho_u2_g_max( const Real& eps_rho_u2_g_max )
{
   this -> eps_rho_u2_g_max = eps_rho_u2_g_max;
}

template< typename Real, typename Index >
void navierStokesSolverMonitor< Real, Index > :: setEps_rho_g_t_max( const Real& eps_rho_g_t_max )
{
   this -> eps_rho_g_t_max = eps_rho_g_t_max;
}

template< typename Real, typename Index >
void navierStokesSolverMonitor< Real, Index > :: setEps_rho_u1_g_t_max( const Real& eps_rho_u1_g_t_max )
{
   this -> eps_rho_u1_g_t_max = eps_rho_u1_g_t_max;
}

template< typename Real, typename Index >
void navierStokesSolverMonitor< Real, Index > :: setEps_rho_u2_g_t_max( const Real& eps_rho_u2_g_t_max )
{
   this -> eps_rho_u2_g_t_max = eps_rho_u2_g_t_max;
}

template< typename Real, typename Index >
void navierStokesSolverMonitor< Real, Index > :: setEps_rho_s_max( const Real& eps_rho_s_max )
{
   this -> eps_rho_s_max = eps_rho_s_max;
}

template< typename Real, typename Index >
void navierStokesSolverMonitor< Real, Index > :: setEps_rho_u1_s_max( const Real& eps_rho_u1_s_max )
{
   this -> eps_rho_u1_s_max = eps_rho_u1_s_max;
}

template< typename Real, typename Index >
void navierStokesSolverMonitor< Real, Index > :: setEps_rho_u2_s_max( const Real& eps_rho_u2_s_max )
{
   this -> eps_rho_u2_s_max = eps_rho_u2_s_max;
}

template< typename Real, typename Index >
void navierStokesSolverMonitor< Real, Index > :: setEps_rho_s_t_max( const Real& eps_rho_s_t_max )
{
   this -> eps_rho_s_t_max = eps_rho_s_t_max;
}

template< typename Real, typename Index >
void navierStokesSolverMonitor< Real, Index > :: setEps_rho_u1_s_t_max( const Real& eps_rho_u1_s_t_max )
{
   this -> eps_rho_u1_s_t_max = eps_rho_u1_s_t_max;
}

template< typename Real, typename Index >
void navierStokesSolverMonitor< Real, Index > :: setEps_rho_u2_s_t_max( const Real& eps_rho_u2_s_t_max )
{
   this -> eps_rho_u2_s_t_max = eps_rho_u2_s_t_max;
}




#endif /* TNLNAVIERSTOKESSOLVERMONITOR_IMPL_H_ */
+4 −0
Original line number Diff line number Diff line
@@ -267,6 +267,10 @@ void navierStokesSolver< Mesh, EulerScheme > :: GetExplicitRHS( const RealType&
                                                                 DofVectorType& fu )
{
   nsSolver.getExplicitRhs( time, tau, u, fu );
   solverMonitor.uMax = this->mesh.getAbsMax( nsSolver.getU() );
   solverMonitor.uAvg = this->mesh.getLpNorm( nsSolver.getU(), 1.0 );
   solverMonitor.eMax = this->mesh.getAbsMax( nsSolver.getEnergy() );
   solverMonitor.eAvg = this->mesh.getLpNorm( nsSolver.getEnergy(), 1.0 );
}

template< typename Mesh, typename EulerScheme >
Loading