Loading examples/navier-stokes/CMakeLists.txt +0 −9 Original line number Diff line number Diff line add_subdirectory( share ) INSTALL( FILES Makefile main.cpp navierStokesSolver.h navierStokesSolver_impl.h navierStokesSetter.h navierStokesSetter_impl.h navier-stokes.cfg.desc DESTINATION share/tnl-${tnlVersion}/examples/navier-stokes ) No newline at end of file examples/navier-stokes/navierStokesSolver.h +3 −0 Original line number Diff line number Diff line Loading @@ -28,6 +28,7 @@ #include "navierStokesSolverMonitor.h" #include <schemes/euler/fvm/tnlLaxFridrichs.h> #include <schemes/gradient/tnlCentralFDMGradient.h> #include <schemes/diffusion/tnlLinearDiffusion.h> template< typename Mesh, typename EulerScheme > Loading Loading @@ -97,6 +98,8 @@ class navierStokesSolver EulerScheme eulerScheme; tnlLinearDiffusion< MeshType > u1Viscosity, u2Viscosity; tnlCentralFDMGradient< MeshType > pressureGradient; navierStokesSolverMonitor< RealType, IndexType > solverMonitor; Loading examples/navier-stokes/navierStokesSolver_impl.h +8 −19 Original line number Diff line number Diff line Loading @@ -148,7 +148,10 @@ bool navierStokesSolver< Mesh, EulerScheme > :: init( const tnlParameterContaine pressureGradient. bindMesh( this -> mesh ); this -> eulerScheme. bindMesh( this -> mesh ); this -> eulerScheme. setPressureGradient( this -> pressureGradient ); this -> u1Viscosity. bindMesh( this -> mesh ); this -> u1Viscosity. setFunction( this -> u1 ); this -> u2Viscosity. bindMesh( this -> mesh ); this -> u2Viscosity. setFunction( this -> u2 ); return true; } Loading Loading @@ -427,33 +430,19 @@ void navierStokesSolver< Mesh, EulerScheme > :: GetExplicitRHS( const RealType& continue; } IndexType e = mesh. getElementIndex( j, i + 1 ); IndexType w = mesh. getElementIndex( j, i - 1 ); IndexType n = mesh. getElementIndex( j + 1, i ); IndexType s = mesh. getElementIndex( j - 1, i ); //const RealType& u = this -> u1[ c ]; //const RealType& v = this -> u2[ c ]; //const RealType u_sqr = u * u; //const RealType v_sqr = v * v; eulerScheme. getExplicitRhs( c, rho_t[ c ], rho_u1_t[ c ], rho_u2_t[ c ] ); //rho_u1_t[ c ] += -( p[ e ] - p[ w ] ) / ( 2.0 * hx ); //rho_u2_t[ c ] += -( p[ n ] - p[ s ] ) / ( 2.0 * hy ); //- startUpCoefficient * this -> gravity * this -> rho[ c ]; //rho_u1_t[ c ] += ; rho_u2_t[ c ] -= startUpCoefficient * this -> gravity * this -> rho[ c ]; /*** * Add the viscosity term */ rho_u1_t[ c ] += this -> mu * ( ( u1[ e ] - 2.0 * u1[ c ] + u1[ w ] ) / ( hx * hx ) + ( u1[ n ] - 2.0 * u1[ c ] + u1[ s ] ) / ( hy * hy ) ); rho_u2_t[ c ] += this -> mu * ( ( u2[ e ] - 2.0 * u2[ c ] + u2[ w ] ) / ( hx * hx ) + ( u2[ n ] - 2.0 * u2[ c ] + u2[ s ] ) / ( hy * hy ) ); rho_u1_t[ c ] += this -> mu * u1Viscosity. getDiffusion( c ); rho_u2_t[ c ] += this -> mu * u2Viscosity. getDiffusion( c ); } } Loading src/implementation/mesh/CMakeLists.txt +3 −2 Original line number Diff line number Diff line SET( headers tnlGrid1D_impl.h tnlGrid2D_impl.h tnlGrid3D_impl.h ) tnlGrid3D_impl.h tnlIdenticalGridGeometry_impl.h ) SET( CURRENT_DIR ${CMAKE_SOURCE_DIR}/src/implementation/mesh ) set( tnl_implementation_mesh_SOURCES SET( tnl_implementation_mesh_SOURCES ${CURRENT_DIR}/tnlGrid_impl.cpp PARENT_SCOPE ) Loading src/implementation/mesh/tnlGrid2D_impl.h +70 −17 Original line number Diff line number Diff line Loading @@ -68,6 +68,10 @@ void tnlGrid< 2, Real, Device, Index, Geometry > :: setDimensions( const Index y this -> dimensions. x() = xSize; this -> dimensions. y() = ySize; dofs = ySize * xSize; tnlTuple< 2, Real > parametricStep; parametricStep. x() = proportions. x() / ( xSize - 1 ); parametricStep. y() = proportions. y() / ( ySize - 1 ); geometry. setParametricStep( parametricStep ); } template< typename Real, Loading @@ -76,13 +80,7 @@ template< typename Real, template< int, typename, typename, typename > class Geometry > void tnlGrid< 2, Real, Device, Index, Geometry > :: setDimensions( const tnlTuple< 2, Index >& dimensions ) { tnlAssert( dimensions. x() > 1, cerr << "The number of Elements along x-axis must be larger than 1." ); tnlAssert( dimensions. y() > 1, cerr << "The number of Elements along y-axis must be larger than 1." ); this -> dimensions = dimensions; dofs = this -> dimensions. x() * this -> dimensions. y(); this -> setDimensions( dimensions. y(), dimensions. x() ); } template< typename Real, Loading Loading @@ -119,6 +117,10 @@ template< typename Real, void tnlGrid< 2, Real, Device, Index, Geometry > :: setProportions( const tnlTuple< 2, Real >& proportions ) { this -> proportions = proportions; tnlTuple< 2, Real > parametricStep; parametricStep. x() = proportions. x() / ( this -> dimensions. x() - 1 ); parametricStep. y() = proportions. y() / ( this -> dimensions. y() - 1 ); geometry. setParametricStep( parametricStep ); } template< typename Real, Loading @@ -134,20 +136,19 @@ template< typename Real, typename Device, typename Index, template< int, typename, typename, typename > class Geometry > void tnlGrid< 2, Real, Device, Index, Geometry > :: setSpaceStep( const tnlTuple< 2, Real >& spaceStep ) void tnlGrid< 2, Real, Device, Index, Geometry > :: setParametricStep( const tnlTuple< 2, Real >& spaceStep ) { this -> proportions. x() = this -> dimensions. x() * spaceStep. x(); parametricStep. x(); this -> proportions. y() = this -> dimensions. y() * spaceStep. y(); parametricStep. y(); } template< typename Real, typename Device, typename Index, template< int, typename, typename, typename > class Geometry > tnlTuple< 2, Real > tnlGrid< 2, Real, Device, Index, Geometry > :: getSpaceStep() const tnlTuple< 2, Real > tnlGrid< 2, Real, Device, Index, Geometry > :: getParametricStep() const { tnlAssert( dimensions. x() > 0, cerr << "Cannot get the space step hx since number of Elements along the x axis is not known in tnlGrid " Loading @@ -156,12 +157,12 @@ tnlTuple< 2, Real > tnlGrid< 2, Real, Device, Index, Geometry > :: getSpaceStep( cerr << "Cannot get the space step hy since number of Elements along the y axis is not known in tnlGrid " << this -> getName() ); tnlTuple< 2, RealType > spaceStep; spaceStep. x() = tnlTuple< 2, RealType > parametricStep; parametricStep. x() = this -> proportions. x() / ( Real ) ( this -> dimensions. x() - 1 ); spaceStep. y() = parametricStep. y() = this -> proportions. y() / ( Real ) ( this -> dimensions. y() - 1 ); return spaceStep; return parametricStep; } template< typename Real, Loading Loading @@ -208,6 +209,50 @@ Index tnlGrid< 2, Real, Device, Index, Geometry > :: getDofs() const return this -> dofs; }; template< typename Real, typename Device, typename Index, template< int, typename, typename, typename > class Geometry > Real tnlGrid< 2, Real, Device, Index, Geometry > :: getElementMeasure( const Index j, const Index i ) const { return geometry. getElementMeasure( j, i ); } template< typename Real, typename Device, typename Index, template< int, typename, typename, typename > class Geometry > Real tnlGrid< 2, Real, Device, Index, Geometry > :: getElementsDistance( const Index j, const Index i, const Index dy, const Index dx ) const { return geometry. getElementsDistance( j, i, dy, dx ); } template< typename Real, typename Device, typename Index, template< int, typename, typename, typename > class Geometry > template< int dy, int dx > Real tnlGrid< 2, Real, Device, Index, Geometry > :: getEdgeLength( const Index j, const Index i ) const { return geometry. getEdgeLength< dy, dx >( j, i ); } template< typename Real, typename Device, typename Index, template< int, typename, typename, typename > class Geometry > template< int dy, int dx > tnlTuple< 2, Real > tnlGrid< 2, Real, Device, Index, Geometry > :: getEdgeNormal( const Index j, const Index i ) const { return geometry. getEdgeNormal< dy, dx >( j, i ); } template< typename Real, typename Device, typename Index, Loading @@ -224,6 +269,8 @@ bool tnlGrid< 2, Real, Device, Index, Geometry > :: save( tnlFile& file ) const << this -> getName() << endl; return false; } if( ! geometry. save( file ) ) return false; return true; }; Loading @@ -243,8 +290,14 @@ bool tnlGrid< 2, Real, Device, Index, Geometry > :: load( tnlFile& file ) << this -> getName() << endl; return false; } if( ! geometry. load( file ) ) return false; this -> dofs = this -> getDimensions(). x() * this -> getDimensions(). y(); tnlTuple< 2, Real > parametricStep; parametricStep. x() = proportions. x() / ( this -> dimensions. x() - 1 ); parametricStep. y() = proportions. y() / ( this -> dimensions. y() - 1 ); geometry. setParametricStep( parametricStep ); return true; }; Loading Loading
examples/navier-stokes/CMakeLists.txt +0 −9 Original line number Diff line number Diff line add_subdirectory( share ) INSTALL( FILES Makefile main.cpp navierStokesSolver.h navierStokesSolver_impl.h navierStokesSetter.h navierStokesSetter_impl.h navier-stokes.cfg.desc DESTINATION share/tnl-${tnlVersion}/examples/navier-stokes ) No newline at end of file
examples/navier-stokes/navierStokesSolver.h +3 −0 Original line number Diff line number Diff line Loading @@ -28,6 +28,7 @@ #include "navierStokesSolverMonitor.h" #include <schemes/euler/fvm/tnlLaxFridrichs.h> #include <schemes/gradient/tnlCentralFDMGradient.h> #include <schemes/diffusion/tnlLinearDiffusion.h> template< typename Mesh, typename EulerScheme > Loading Loading @@ -97,6 +98,8 @@ class navierStokesSolver EulerScheme eulerScheme; tnlLinearDiffusion< MeshType > u1Viscosity, u2Viscosity; tnlCentralFDMGradient< MeshType > pressureGradient; navierStokesSolverMonitor< RealType, IndexType > solverMonitor; Loading
examples/navier-stokes/navierStokesSolver_impl.h +8 −19 Original line number Diff line number Diff line Loading @@ -148,7 +148,10 @@ bool navierStokesSolver< Mesh, EulerScheme > :: init( const tnlParameterContaine pressureGradient. bindMesh( this -> mesh ); this -> eulerScheme. bindMesh( this -> mesh ); this -> eulerScheme. setPressureGradient( this -> pressureGradient ); this -> u1Viscosity. bindMesh( this -> mesh ); this -> u1Viscosity. setFunction( this -> u1 ); this -> u2Viscosity. bindMesh( this -> mesh ); this -> u2Viscosity. setFunction( this -> u2 ); return true; } Loading Loading @@ -427,33 +430,19 @@ void navierStokesSolver< Mesh, EulerScheme > :: GetExplicitRHS( const RealType& continue; } IndexType e = mesh. getElementIndex( j, i + 1 ); IndexType w = mesh. getElementIndex( j, i - 1 ); IndexType n = mesh. getElementIndex( j + 1, i ); IndexType s = mesh. getElementIndex( j - 1, i ); //const RealType& u = this -> u1[ c ]; //const RealType& v = this -> u2[ c ]; //const RealType u_sqr = u * u; //const RealType v_sqr = v * v; eulerScheme. getExplicitRhs( c, rho_t[ c ], rho_u1_t[ c ], rho_u2_t[ c ] ); //rho_u1_t[ c ] += -( p[ e ] - p[ w ] ) / ( 2.0 * hx ); //rho_u2_t[ c ] += -( p[ n ] - p[ s ] ) / ( 2.0 * hy ); //- startUpCoefficient * this -> gravity * this -> rho[ c ]; //rho_u1_t[ c ] += ; rho_u2_t[ c ] -= startUpCoefficient * this -> gravity * this -> rho[ c ]; /*** * Add the viscosity term */ rho_u1_t[ c ] += this -> mu * ( ( u1[ e ] - 2.0 * u1[ c ] + u1[ w ] ) / ( hx * hx ) + ( u1[ n ] - 2.0 * u1[ c ] + u1[ s ] ) / ( hy * hy ) ); rho_u2_t[ c ] += this -> mu * ( ( u2[ e ] - 2.0 * u2[ c ] + u2[ w ] ) / ( hx * hx ) + ( u2[ n ] - 2.0 * u2[ c ] + u2[ s ] ) / ( hy * hy ) ); rho_u1_t[ c ] += this -> mu * u1Viscosity. getDiffusion( c ); rho_u2_t[ c ] += this -> mu * u2Viscosity. getDiffusion( c ); } } Loading
src/implementation/mesh/CMakeLists.txt +3 −2 Original line number Diff line number Diff line SET( headers tnlGrid1D_impl.h tnlGrid2D_impl.h tnlGrid3D_impl.h ) tnlGrid3D_impl.h tnlIdenticalGridGeometry_impl.h ) SET( CURRENT_DIR ${CMAKE_SOURCE_DIR}/src/implementation/mesh ) set( tnl_implementation_mesh_SOURCES SET( tnl_implementation_mesh_SOURCES ${CURRENT_DIR}/tnlGrid_impl.cpp PARENT_SCOPE ) Loading
src/implementation/mesh/tnlGrid2D_impl.h +70 −17 Original line number Diff line number Diff line Loading @@ -68,6 +68,10 @@ void tnlGrid< 2, Real, Device, Index, Geometry > :: setDimensions( const Index y this -> dimensions. x() = xSize; this -> dimensions. y() = ySize; dofs = ySize * xSize; tnlTuple< 2, Real > parametricStep; parametricStep. x() = proportions. x() / ( xSize - 1 ); parametricStep. y() = proportions. y() / ( ySize - 1 ); geometry. setParametricStep( parametricStep ); } template< typename Real, Loading @@ -76,13 +80,7 @@ template< typename Real, template< int, typename, typename, typename > class Geometry > void tnlGrid< 2, Real, Device, Index, Geometry > :: setDimensions( const tnlTuple< 2, Index >& dimensions ) { tnlAssert( dimensions. x() > 1, cerr << "The number of Elements along x-axis must be larger than 1." ); tnlAssert( dimensions. y() > 1, cerr << "The number of Elements along y-axis must be larger than 1." ); this -> dimensions = dimensions; dofs = this -> dimensions. x() * this -> dimensions. y(); this -> setDimensions( dimensions. y(), dimensions. x() ); } template< typename Real, Loading Loading @@ -119,6 +117,10 @@ template< typename Real, void tnlGrid< 2, Real, Device, Index, Geometry > :: setProportions( const tnlTuple< 2, Real >& proportions ) { this -> proportions = proportions; tnlTuple< 2, Real > parametricStep; parametricStep. x() = proportions. x() / ( this -> dimensions. x() - 1 ); parametricStep. y() = proportions. y() / ( this -> dimensions. y() - 1 ); geometry. setParametricStep( parametricStep ); } template< typename Real, Loading @@ -134,20 +136,19 @@ template< typename Real, typename Device, typename Index, template< int, typename, typename, typename > class Geometry > void tnlGrid< 2, Real, Device, Index, Geometry > :: setSpaceStep( const tnlTuple< 2, Real >& spaceStep ) void tnlGrid< 2, Real, Device, Index, Geometry > :: setParametricStep( const tnlTuple< 2, Real >& spaceStep ) { this -> proportions. x() = this -> dimensions. x() * spaceStep. x(); parametricStep. x(); this -> proportions. y() = this -> dimensions. y() * spaceStep. y(); parametricStep. y(); } template< typename Real, typename Device, typename Index, template< int, typename, typename, typename > class Geometry > tnlTuple< 2, Real > tnlGrid< 2, Real, Device, Index, Geometry > :: getSpaceStep() const tnlTuple< 2, Real > tnlGrid< 2, Real, Device, Index, Geometry > :: getParametricStep() const { tnlAssert( dimensions. x() > 0, cerr << "Cannot get the space step hx since number of Elements along the x axis is not known in tnlGrid " Loading @@ -156,12 +157,12 @@ tnlTuple< 2, Real > tnlGrid< 2, Real, Device, Index, Geometry > :: getSpaceStep( cerr << "Cannot get the space step hy since number of Elements along the y axis is not known in tnlGrid " << this -> getName() ); tnlTuple< 2, RealType > spaceStep; spaceStep. x() = tnlTuple< 2, RealType > parametricStep; parametricStep. x() = this -> proportions. x() / ( Real ) ( this -> dimensions. x() - 1 ); spaceStep. y() = parametricStep. y() = this -> proportions. y() / ( Real ) ( this -> dimensions. y() - 1 ); return spaceStep; return parametricStep; } template< typename Real, Loading Loading @@ -208,6 +209,50 @@ Index tnlGrid< 2, Real, Device, Index, Geometry > :: getDofs() const return this -> dofs; }; template< typename Real, typename Device, typename Index, template< int, typename, typename, typename > class Geometry > Real tnlGrid< 2, Real, Device, Index, Geometry > :: getElementMeasure( const Index j, const Index i ) const { return geometry. getElementMeasure( j, i ); } template< typename Real, typename Device, typename Index, template< int, typename, typename, typename > class Geometry > Real tnlGrid< 2, Real, Device, Index, Geometry > :: getElementsDistance( const Index j, const Index i, const Index dy, const Index dx ) const { return geometry. getElementsDistance( j, i, dy, dx ); } template< typename Real, typename Device, typename Index, template< int, typename, typename, typename > class Geometry > template< int dy, int dx > Real tnlGrid< 2, Real, Device, Index, Geometry > :: getEdgeLength( const Index j, const Index i ) const { return geometry. getEdgeLength< dy, dx >( j, i ); } template< typename Real, typename Device, typename Index, template< int, typename, typename, typename > class Geometry > template< int dy, int dx > tnlTuple< 2, Real > tnlGrid< 2, Real, Device, Index, Geometry > :: getEdgeNormal( const Index j, const Index i ) const { return geometry. getEdgeNormal< dy, dx >( j, i ); } template< typename Real, typename Device, typename Index, Loading @@ -224,6 +269,8 @@ bool tnlGrid< 2, Real, Device, Index, Geometry > :: save( tnlFile& file ) const << this -> getName() << endl; return false; } if( ! geometry. save( file ) ) return false; return true; }; Loading @@ -243,8 +290,14 @@ bool tnlGrid< 2, Real, Device, Index, Geometry > :: load( tnlFile& file ) << this -> getName() << endl; return false; } if( ! geometry. load( file ) ) return false; this -> dofs = this -> getDimensions(). x() * this -> getDimensions(). y(); tnlTuple< 2, Real > parametricStep; parametricStep. x() = proportions. x() / ( this -> dimensions. x() - 1 ); parametricStep. y() = proportions. y() / ( this -> dimensions. y() - 1 ); geometry. setParametricStep( parametricStep ); return true; }; Loading