Loading examples/navier-stokes/navierStokesSolver_impl.h +21 −19 Original line number Diff line number Diff line Loading @@ -134,10 +134,9 @@ bool navierStokesSolver< Mesh, EulerScheme > :: init( const tnlParameterContaine * Set-up model coefficients */ this->p_0 = parameters. GetParameter< double >( "p0" ); this->mu = ; this->T = parameters. GetParameter< double >( "T" ); this->R = parameters. GetParameter< double >( "R" ); navierStokesScheme.setMu( parameters. GetParameter< double >( "mu") ); navierStokesScheme.setT( parameters. GetParameter< double >( "T") ); navierStokesScheme.setR( parameters. GetParameter< double >( "R") ); navierStokesScheme.setGravity( parameters. GetParameter< double >( "gravity") ); if( ! this->boundaryConditions.init( parameters ) ) return false; Loading Loading @@ -226,7 +225,7 @@ bool navierStokesSolver< Mesh, EulerScheme > :: makeSnapshot( const RealType& t, navierStokesScheme.updatePhysicalQuantities( rho, rho_u1, rho_u2 ); tnlVector< RealType, DeviceType, IndexType > u; u. setLike( navierStokesScheme.getU1() ); for( IndexType i = 0; i < this -> u1. getSize(); i ++ ) for( IndexType i = 0; i < navierStokesScheme.getU1().getSize(); i ++ ) { const RealType& u1 = navierStokesScheme.getU1()[ i ]; const RealType& u2 = navierStokesScheme.getU2()[ i ]; Loading Loading @@ -329,7 +328,10 @@ void navierStokesSolver< Mesh, EulerScheme > :: GetExplicitRHS( const RealType& if( DeviceType :: getDevice() == tnlHostDevice ) { this->boundaryConditions.apply( time, this->rho, this->u1, this->u2 ); this->boundaryConditions.apply( time, this->navierStokesScheme.getRho(), this->navierStokesScheme.getU1(), this->navierStokesScheme.getU2() ); for( IndexType i = 0; i < xSize; i ++ ) { const IndexType c1 = mesh.getElementIndex( i, 0 ); Loading @@ -337,12 +339,12 @@ void navierStokesSolver< Mesh, EulerScheme > :: GetExplicitRHS( const RealType& const IndexType c3 = mesh.getElementIndex( i, ySize - 1 ); const IndexType c4 = mesh.getElementIndex( i, ySize - 2 ); dofs_rho[ c1 ] = this->rho[ c1 ]; rho_u1[ c1 ] = this->rho[ c1 ] * this->u1[ c1 ]; rho_u2[ c1 ] = this->rho[ c1 ] * this->u2[ c1 ]; dofs_rho[ c3 ] = this->rho[ c3 ]; rho_u1[ c3 ] = this->rho[ c3 ] * this->u1[ c3 ]; rho_u2[ c3 ] = this->rho[ c3 ] * this->u2[ c3 ]; dofs_rho[ c1 ] = this->navierStokesScheme.getRho()[ c1 ]; rho_u1[ c1 ] = this->navierStokesScheme.getRho()[ c1 ] * this->navierStokesScheme.getU1()[ c1 ]; rho_u2[ c1 ] = this->navierStokesScheme.getRho()[ c1 ] * this->navierStokesScheme.getU2()[ c1 ]; dofs_rho[ c3 ] = this->navierStokesScheme.getRho()[ c3 ]; rho_u1[ c3 ] = this->navierStokesScheme.getRho()[ c3 ] * this->navierStokesScheme.getU1()[ c3 ]; rho_u2[ c3 ] = this->navierStokesScheme.getRho()[ c3 ] * this->navierStokesScheme.getU2()[ c3 ]; } for( IndexType j = 0; j < ySize; j ++ ) { Loading @@ -351,12 +353,12 @@ void navierStokesSolver< Mesh, EulerScheme > :: GetExplicitRHS( const RealType& const IndexType c3 = mesh.getElementIndex( xSize - 1, j ); const IndexType c4 = mesh.getElementIndex( xSize - 2, j ); dofs_rho[ c1 ] = this->rho[ c1 ]; rho_u1[ c1 ] = this->rho[ c1 ] * this -> u1[ c1 ]; rho_u2[ c1 ] = this->rho[ c1 ] * this -> u2[ c1 ]; dofs_rho[ c3 ] = this->rho[ c3 ]; rho_u1[ c3 ] = this->rho[ c3 ] * this -> u1[ c3 ]; rho_u2[ c3 ] = this->rho[ c3 ] * this -> u2[ c3 ]; dofs_rho[ c1 ] = this->navierStokesScheme.getRho()[ c1 ]; rho_u1[ c1 ] = this->navierStokesScheme.getRho()[ c1 ] * this->navierStokesScheme.getU1()[ c1 ]; rho_u2[ c1 ] = this->navierStokesScheme.getRho()[ c1 ] * this->navierStokesScheme.getU2()[ c1 ]; dofs_rho[ c3 ] = this->navierStokesScheme.getRho()[ c3 ]; rho_u1[ c3 ] = this->navierStokesScheme.getRho()[ c3 ] * this->navierStokesScheme.getU1()[ c3 ]; rho_u2[ c3 ] = this->navierStokesScheme.getRho()[ c3 ] * this->navierStokesScheme.getU2()[ c3 ]; } Loading Loading @@ -386,8 +388,8 @@ void navierStokesSolver< Mesh, EulerScheme > :: GetExplicitRHS( const RealType& /*** * Add the viscosity term */ rho_u1_t[ c ] += this -> mu * u1Viscosity. getDiffusion( c ); rho_u2_t[ c ] += this -> mu * u2Viscosity. getDiffusion( c ); rho_u1_t[ c ] += this->navierStokesScheme.getMu() * u1Viscosity. getDiffusion( c ); rho_u2_t[ c ] += this->navierStokesScheme.getMu() * u2Viscosity. getDiffusion( c ); } } Loading src/implementation/schemes/navier-stokes/tnlNavierStokes_impl.h +39 −3 Original line number Diff line number Diff line Loading @@ -27,7 +27,9 @@ tnlNavierStokes< AdvectionScheme, DiffusionScheme, BoundaryConditions >::tnlNavi : advection( 0 ), diffusion( 0 ), mu( 0.0 ), gravity( 0.0 ) gravity( 0.0 ), R( 0.0 ), T( 0.0 ) { this->rho.setName( "navier-stokes-rho" ); this->u1.setName( "navier-stokes-u1"); Loading Loading @@ -98,6 +100,40 @@ const typename tnlNavierStokes< AdvectionScheme, DiffusionScheme, BoundaryCondit return this->mu; } template< typename AdvectionScheme, typename DiffusionScheme, typename BoundaryConditions > void tnlNavierStokes< AdvectionScheme, DiffusionScheme, BoundaryConditions >::setR( const RealType& R ) { this->R = R; } template< typename AdvectionScheme, typename DiffusionScheme, typename BoundaryConditions > const typename tnlNavierStokes< AdvectionScheme, DiffusionScheme, BoundaryConditions >::RealType& tnlNavierStokes< AdvectionScheme, DiffusionScheme, BoundaryConditions >::getR() const { return this->R; } template< typename AdvectionScheme, typename DiffusionScheme, typename BoundaryConditions > void tnlNavierStokes< AdvectionScheme, DiffusionScheme, BoundaryConditions >::setT( const RealType& T ) { this->T = T; } template< typename AdvectionScheme, typename DiffusionScheme, typename BoundaryConditions > const typename tnlNavierStokes< AdvectionScheme, DiffusionScheme, BoundaryConditions >::RealType& tnlNavierStokes< AdvectionScheme, DiffusionScheme, BoundaryConditions >::getT() const { return this->T; } template< typename AdvectionScheme, typename DiffusionScheme, typename BoundaryConditions > Loading @@ -110,9 +146,9 @@ template< typename AdvectionScheme, typename DiffusionScheme, typename BoundaryConditions > const typename tnlNavierStokes< AdvectionScheme, DiffusionScheme, BoundaryConditions >::RealType& tnlNavierStokes< AdvectionScheme, DiffusionScheme, BoundaryConditions >::getMu() const tnlNavierStokes< AdvectionScheme, DiffusionScheme, BoundaryConditions >::getGravity() const { return this->mu; return this->gravity; } template< typename AdvectionScheme, Loading src/schemes/navier-stokes/tnlNavierStokes.h +9 −1 Original line number Diff line number Diff line Loading @@ -54,6 +54,14 @@ class tnlNavierStokes const RealType& getMu() const; void setR( const RealType& R ); const RealType& getR() const; void setT( const RealType& T ); const RealType& getT() const; void setGravity( const RealType& gravity ); const RealType& getGravity() const; Loading Loading @@ -97,7 +105,7 @@ class tnlNavierStokes VectorType rho, u1, u2, p; RealType mu, gravity; RealType mu, gravity, R, T; }; Loading Loading
examples/navier-stokes/navierStokesSolver_impl.h +21 −19 Original line number Diff line number Diff line Loading @@ -134,10 +134,9 @@ bool navierStokesSolver< Mesh, EulerScheme > :: init( const tnlParameterContaine * Set-up model coefficients */ this->p_0 = parameters. GetParameter< double >( "p0" ); this->mu = ; this->T = parameters. GetParameter< double >( "T" ); this->R = parameters. GetParameter< double >( "R" ); navierStokesScheme.setMu( parameters. GetParameter< double >( "mu") ); navierStokesScheme.setT( parameters. GetParameter< double >( "T") ); navierStokesScheme.setR( parameters. GetParameter< double >( "R") ); navierStokesScheme.setGravity( parameters. GetParameter< double >( "gravity") ); if( ! this->boundaryConditions.init( parameters ) ) return false; Loading Loading @@ -226,7 +225,7 @@ bool navierStokesSolver< Mesh, EulerScheme > :: makeSnapshot( const RealType& t, navierStokesScheme.updatePhysicalQuantities( rho, rho_u1, rho_u2 ); tnlVector< RealType, DeviceType, IndexType > u; u. setLike( navierStokesScheme.getU1() ); for( IndexType i = 0; i < this -> u1. getSize(); i ++ ) for( IndexType i = 0; i < navierStokesScheme.getU1().getSize(); i ++ ) { const RealType& u1 = navierStokesScheme.getU1()[ i ]; const RealType& u2 = navierStokesScheme.getU2()[ i ]; Loading Loading @@ -329,7 +328,10 @@ void navierStokesSolver< Mesh, EulerScheme > :: GetExplicitRHS( const RealType& if( DeviceType :: getDevice() == tnlHostDevice ) { this->boundaryConditions.apply( time, this->rho, this->u1, this->u2 ); this->boundaryConditions.apply( time, this->navierStokesScheme.getRho(), this->navierStokesScheme.getU1(), this->navierStokesScheme.getU2() ); for( IndexType i = 0; i < xSize; i ++ ) { const IndexType c1 = mesh.getElementIndex( i, 0 ); Loading @@ -337,12 +339,12 @@ void navierStokesSolver< Mesh, EulerScheme > :: GetExplicitRHS( const RealType& const IndexType c3 = mesh.getElementIndex( i, ySize - 1 ); const IndexType c4 = mesh.getElementIndex( i, ySize - 2 ); dofs_rho[ c1 ] = this->rho[ c1 ]; rho_u1[ c1 ] = this->rho[ c1 ] * this->u1[ c1 ]; rho_u2[ c1 ] = this->rho[ c1 ] * this->u2[ c1 ]; dofs_rho[ c3 ] = this->rho[ c3 ]; rho_u1[ c3 ] = this->rho[ c3 ] * this->u1[ c3 ]; rho_u2[ c3 ] = this->rho[ c3 ] * this->u2[ c3 ]; dofs_rho[ c1 ] = this->navierStokesScheme.getRho()[ c1 ]; rho_u1[ c1 ] = this->navierStokesScheme.getRho()[ c1 ] * this->navierStokesScheme.getU1()[ c1 ]; rho_u2[ c1 ] = this->navierStokesScheme.getRho()[ c1 ] * this->navierStokesScheme.getU2()[ c1 ]; dofs_rho[ c3 ] = this->navierStokesScheme.getRho()[ c3 ]; rho_u1[ c3 ] = this->navierStokesScheme.getRho()[ c3 ] * this->navierStokesScheme.getU1()[ c3 ]; rho_u2[ c3 ] = this->navierStokesScheme.getRho()[ c3 ] * this->navierStokesScheme.getU2()[ c3 ]; } for( IndexType j = 0; j < ySize; j ++ ) { Loading @@ -351,12 +353,12 @@ void navierStokesSolver< Mesh, EulerScheme > :: GetExplicitRHS( const RealType& const IndexType c3 = mesh.getElementIndex( xSize - 1, j ); const IndexType c4 = mesh.getElementIndex( xSize - 2, j ); dofs_rho[ c1 ] = this->rho[ c1 ]; rho_u1[ c1 ] = this->rho[ c1 ] * this -> u1[ c1 ]; rho_u2[ c1 ] = this->rho[ c1 ] * this -> u2[ c1 ]; dofs_rho[ c3 ] = this->rho[ c3 ]; rho_u1[ c3 ] = this->rho[ c3 ] * this -> u1[ c3 ]; rho_u2[ c3 ] = this->rho[ c3 ] * this -> u2[ c3 ]; dofs_rho[ c1 ] = this->navierStokesScheme.getRho()[ c1 ]; rho_u1[ c1 ] = this->navierStokesScheme.getRho()[ c1 ] * this->navierStokesScheme.getU1()[ c1 ]; rho_u2[ c1 ] = this->navierStokesScheme.getRho()[ c1 ] * this->navierStokesScheme.getU2()[ c1 ]; dofs_rho[ c3 ] = this->navierStokesScheme.getRho()[ c3 ]; rho_u1[ c3 ] = this->navierStokesScheme.getRho()[ c3 ] * this->navierStokesScheme.getU1()[ c3 ]; rho_u2[ c3 ] = this->navierStokesScheme.getRho()[ c3 ] * this->navierStokesScheme.getU2()[ c3 ]; } Loading Loading @@ -386,8 +388,8 @@ void navierStokesSolver< Mesh, EulerScheme > :: GetExplicitRHS( const RealType& /*** * Add the viscosity term */ rho_u1_t[ c ] += this -> mu * u1Viscosity. getDiffusion( c ); rho_u2_t[ c ] += this -> mu * u2Viscosity. getDiffusion( c ); rho_u1_t[ c ] += this->navierStokesScheme.getMu() * u1Viscosity. getDiffusion( c ); rho_u2_t[ c ] += this->navierStokesScheme.getMu() * u2Viscosity. getDiffusion( c ); } } Loading
src/implementation/schemes/navier-stokes/tnlNavierStokes_impl.h +39 −3 Original line number Diff line number Diff line Loading @@ -27,7 +27,9 @@ tnlNavierStokes< AdvectionScheme, DiffusionScheme, BoundaryConditions >::tnlNavi : advection( 0 ), diffusion( 0 ), mu( 0.0 ), gravity( 0.0 ) gravity( 0.0 ), R( 0.0 ), T( 0.0 ) { this->rho.setName( "navier-stokes-rho" ); this->u1.setName( "navier-stokes-u1"); Loading Loading @@ -98,6 +100,40 @@ const typename tnlNavierStokes< AdvectionScheme, DiffusionScheme, BoundaryCondit return this->mu; } template< typename AdvectionScheme, typename DiffusionScheme, typename BoundaryConditions > void tnlNavierStokes< AdvectionScheme, DiffusionScheme, BoundaryConditions >::setR( const RealType& R ) { this->R = R; } template< typename AdvectionScheme, typename DiffusionScheme, typename BoundaryConditions > const typename tnlNavierStokes< AdvectionScheme, DiffusionScheme, BoundaryConditions >::RealType& tnlNavierStokes< AdvectionScheme, DiffusionScheme, BoundaryConditions >::getR() const { return this->R; } template< typename AdvectionScheme, typename DiffusionScheme, typename BoundaryConditions > void tnlNavierStokes< AdvectionScheme, DiffusionScheme, BoundaryConditions >::setT( const RealType& T ) { this->T = T; } template< typename AdvectionScheme, typename DiffusionScheme, typename BoundaryConditions > const typename tnlNavierStokes< AdvectionScheme, DiffusionScheme, BoundaryConditions >::RealType& tnlNavierStokes< AdvectionScheme, DiffusionScheme, BoundaryConditions >::getT() const { return this->T; } template< typename AdvectionScheme, typename DiffusionScheme, typename BoundaryConditions > Loading @@ -110,9 +146,9 @@ template< typename AdvectionScheme, typename DiffusionScheme, typename BoundaryConditions > const typename tnlNavierStokes< AdvectionScheme, DiffusionScheme, BoundaryConditions >::RealType& tnlNavierStokes< AdvectionScheme, DiffusionScheme, BoundaryConditions >::getMu() const tnlNavierStokes< AdvectionScheme, DiffusionScheme, BoundaryConditions >::getGravity() const { return this->mu; return this->gravity; } template< typename AdvectionScheme, Loading
src/schemes/navier-stokes/tnlNavierStokes.h +9 −1 Original line number Diff line number Diff line Loading @@ -54,6 +54,14 @@ class tnlNavierStokes const RealType& getMu() const; void setR( const RealType& R ); const RealType& getR() const; void setT( const RealType& T ); const RealType& getT() const; void setGravity( const RealType& gravity ); const RealType& getGravity() const; Loading Loading @@ -97,7 +105,7 @@ class tnlNavierStokes VectorType rho, u1, u2, p; RealType mu, gravity; RealType mu, gravity, R, T; }; Loading