Loading examples/navier-stokes/navierStokesSolver_impl.h +8 −8 Original line number Diff line number Diff line Loading @@ -112,8 +112,8 @@ bool navierStokesSolver< Mesh, EulerScheme > :: init( const tnlParameterContaine return false; } this -> mesh. setDimensions( meshes. y(), meshes. x() ); RealType hx = this -> mesh. getSpaceStep(). x(); RealType hy = this -> mesh. getSpaceStep(). y(); RealType hx = this -> mesh. getParametricStep(). x(); RealType hy = this -> mesh. getParametricStep(). y(); mesh. save( tnlString( "mesh.tnl" ) ); /**** Loading Loading @@ -170,8 +170,8 @@ bool navierStokesSolver< Mesh, EulerScheme > :: setInitialCondition( const tnlPa const IndexType& xSize = mesh. getDimensions(). x(); const IndexType& ySize = mesh. getDimensions(). y(); const RealType hx = mesh. getSpaceStep(). x(); const RealType hy = mesh. getSpaceStep(). y(); const RealType hx = mesh. getParametricStep(). x(); const RealType hy = mesh. getParametricStep(). y(); for( IndexType j = 0; j < ySize; j ++ ) for( IndexType i = 0; i < xSize; i ++ ) Loading Loading @@ -344,8 +344,8 @@ void navierStokesSolver< Mesh, EulerScheme > :: GetExplicitRHS( const RealType& */ const IndexType& xSize = mesh. getDimensions(). x(); const IndexType& ySize = mesh. getDimensions(). y(); const RealType hx = mesh. getSpaceStep(). x(); const RealType hy = mesh. getSpaceStep(). y(); const RealType hx = mesh. getParametricStep(). x(); const RealType hy = mesh. getParametricStep(). y(); RealType startUpCoefficient( 1.0 ); if( this -> startUp != 0.0 ) startUpCoefficient = Min( ( RealType ) 1.0, time / this -> startUp ); Loading Loading @@ -553,8 +553,8 @@ void navierStokesSolver< Mesh, EulerScheme > :: writeProlog( tnlLogger& logger, logger. WriteParameter< tnlString >( "Space discretisation:", "scheme", parameters ); logger. WriteParameter< int >( "Meshes along x:", mesh. getDimensions(). x() ); logger. WriteParameter< int >( "Meshes along y:", mesh. getDimensions(). y() ); logger. WriteParameter< double >( "Space step along x:", mesh. getSpaceStep(). x() ); logger. WriteParameter< double >( "Space step along y:", mesh. getSpaceStep(). y() ); logger. WriteParameter< double >( "Space step along x:", mesh. getParametricStep(). x() ); logger. WriteParameter< double >( "Space step along y:", mesh. getParametricStep(). y() ); } #endif /* NAVIERSTOKESSOLVER_IMPL_H_ */ src/implementation/mesh/tnlGrid1D_impl.h +15 −20 Original line number Diff line number Diff line Loading @@ -61,10 +61,14 @@ template< typename Real, template< int, typename, typename, typename > class Geometry > void tnlGrid< 1, Real, Device, Index, Geometry > :: setDimensions( const Index xSize ) { tnlAssert( xSize > 1, cerr << "The number of Elements along x-axis must be larger than 1." ); tnlAssert( xSize > 0, cerr << "The number of Elements along x-axis must be larger than 0." ); this -> dimensions. x() = xSize; dofs = xSize; tnlTuple< 1, Real > parametricStep; parametricStep. x() = proportions. x() / xSize; geometry. setParametricStep( parametricStep ); } template< typename Real, Loading @@ -73,10 +77,7 @@ template< typename Real, template< int, typename, typename, typename > class Geometry > void tnlGrid< 1, Real, Device, Index, Geometry > :: setDimensions( const tnlTuple< 1, Index >& dimensions ) { tnlAssert( dimensions. x() > 1, cerr << "The number of Elements along x-axis must be larger than 1." ); this -> dimensions = dimensions; dofs = this -> dimensions. x(); this -> setDimensions( dimensions. x() ); } template< typename Real, Loading Loading @@ -113,6 +114,7 @@ template< typename Real, void tnlGrid< 1, Real, Device, Index, Geometry > :: setProportions( const tnlTuple< 1, Real >& proportions ) { this -> proportions = proportions; this -> setDimensions( this -> dimensions ); } template< typename Real, Loading @@ -128,26 +130,19 @@ template< typename Real, typename Device, typename Index, template< int, typename, typename, typename > class Geometry > void tnlGrid< 1, Real, Device, Index, Geometry > :: setSpaceStep( const tnlTuple< 1, Real >& spaceStep ) void tnlGrid< 1, Real, Device, Index, Geometry > :: setParametricStep( const tnlTuple< 1, Real >& parametricStep ) { this -> proportions. x() = this -> dimensions. x() * spaceStep. x(); this -> proportions. x() = this -> dimensions. x() * parametricStep. x(); geometry. setParametricStep( parametricStep ); } template< typename Real, typename Device, typename Index, template< int, typename, typename, typename > class Geometry > tnlTuple< 1, Real > tnlGrid< 1, Real, Device, Index, Geometry > :: getSpaceStep() const const tnlTuple< 1, Real >& tnlGrid< 1, 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 " << this -> getName() ); tnlTuple< 1, RealType > spaceStep; spaceStep. x() = ( this -> proportions. x() ) / ( Real ) ( this -> dimensions. x() - 1 ); return spaceStep; return geometry. getParametricStep(); } template< typename Real, Loading Loading @@ -251,8 +246,8 @@ bool tnlGrid< 1, Real, Device, Index, Geometry > :: write( const MeshFunction& f cerr << "I am not able to open the file " << fileName << "." << endl; return false; } const RealType hx = getSpaceStep(). x(); const RealType hy = getSpaceStep(). y(); const RealType hx = getParametricStep(). x(); const RealType hy = getParametricStep(). y(); if( format == "gnuplot" ) for( IndexType i = 0; i < getDimensions(). x(); i++ ) { Loading src/implementation/mesh/tnlGrid2D_impl.h +17 −18 Original line number Diff line number Diff line Loading @@ -60,17 +60,17 @@ template< typename Real, template< int, typename, typename, typename > class Geometry > void tnlGrid< 2, Real, Device, Index, Geometry > :: setDimensions( const Index ySize, const Index xSize ) { tnlAssert( xSize > 1, cerr << "The number of Elements along x-axis must be larger than 1." ); tnlAssert( ySize > 1, cerr << "The number of Elements along y-axis must be larger than 1." ); tnlAssert( xSize > 0, cerr << "The number of Elements along x-axis must be larger than 0." ); tnlAssert( ySize > 0, cerr << "The number of Elements along y-axis must be larger than 0." ); 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 ); parametricStep. x() = proportions. x() / xSize; parametricStep. y() = proportions. y() / ySize; geometry. setParametricStep( parametricStep ); } Loading Loading @@ -139,18 +139,18 @@ template< typename Real, void tnlGrid< 2, Real, Device, Index, Geometry > :: setParametricStep( const tnlTuple< 2, Real >& spaceStep ) { this -> proportions. x() = this -> dimensions. x() * parametricStep. x(); geometry. getParametricStep(). x(); this -> proportions. y() = this -> dimensions. y() * parametricStep. y(); geometry. getParametricStep(). y(); } template< typename Real, typename Device, typename Index, template< int, typename, typename, typename > class Geometry > tnlTuple< 2, Real > tnlGrid< 2, Real, Device, Index, Geometry > :: getParametricStep() const const tnlTuple< 2, Real >& tnlGrid< 2, Real, Device, Index, Geometry > :: getParametricStep() const { tnlAssert( dimensions. x() > 0, /*tnlAssert( dimensions. x() > 0, cerr << "Cannot get the space step hx since number of Elements along the x axis is not known in tnlGrid " << this -> getName() ); tnlAssert( dimensions. y() > 0, Loading @@ -161,8 +161,8 @@ tnlTuple< 2, Real > tnlGrid< 2, Real, Device, Index, Geometry > :: getParametric parametricStep. x() = this -> proportions. x() / ( Real ) ( this -> dimensions. x() - 1 ); parametricStep. y() = this -> proportions. y() / ( Real ) ( this -> dimensions. y() - 1 ); return parametricStep; this -> proportions. y() / ( Real ) ( this -> dimensions. y() - 1 );*/ return geometry. getParametricStep(); } template< typename Real, Loading Loading @@ -223,12 +223,11 @@ template< typename Real, typename Device, typename Index, template< int, typename, typename, typename > class Geometry > template< Index dy, Index dx > Real tnlGrid< 2, Real, Device, Index, Geometry > :: getElementsDistance( const Index j, const Index i, const Index dy, const Index dx ) const const Index i ) const { return geometry. getElementsDistance( j, i, dy, dx ); return geometry. getElementsDistance< dy, dx >( j, i ); } template< typename Real, Loading Loading @@ -341,8 +340,8 @@ bool tnlGrid< 2, Real, Device, Index, Geometry > :: write( const MeshFunction& f cerr << "I am not able to open the file " << fileName << "." << endl; return false; } const RealType hx = getSpaceStep(). x(); const RealType hy = getSpaceStep(). y(); const RealType hx = getParametricStep(). x(); const RealType hy = getParametricStep(). y(); if( format == "gnuplot" ) for( IndexType j = 0; j < getDimensions(). y(); j++ ) { Loading src/implementation/mesh/tnlGrid3D_impl.h +4 −4 Original line number Diff line number Diff line Loading @@ -136,7 +136,7 @@ template< typename Real, typename Device, typename Index, template< int, typename, typename, typename > class Geometry > void tnlGrid< 3, Real, Device, Index, Geometry > :: setSpaceStep( const tnlTuple< 3, Real >& spaceStep ) void tnlGrid< 3, Real, Device, Index, Geometry > :: setParametricStep( const tnlTuple< 3, Real >& spaceStep ) { this -> proportions. x() = this -> dimensions. x() * spaceStep. x(); Loading @@ -150,7 +150,7 @@ template< typename Real, typename Device, typename Index, template< int, typename, typename, typename > class Geometry > tnlTuple< 3, Real > tnlGrid< 3, Real, Device, Index, Geometry > :: getSpaceStep() const tnlTuple< 3, Real > tnlGrid< 3, 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 Loading @@ -286,8 +286,8 @@ bool tnlGrid< 3, Real, Device, Index, Geometry > :: write( const MeshFunction& f cerr << "I am not able to open the file " << fileName << "." << endl; return false; } const RealType hx = getSpaceStep(). x(); const RealType hy = getSpaceStep(). y(); const RealType hx = getParametricStep(). x(); const RealType hy = getParametricStep(). y(); if( format == "gnuplot" ) { tnlAssert( false, cerr << "TODO"); Loading src/implementation/mesh/tnlIdenticalGridGeometry_impl.h +124 −5 Original line number Diff line number Diff line Loading @@ -21,13 +21,125 @@ #include <core/tnlFile.h> #include <core/tnlAssert.h> /**** * Identical geometry for 1D */ template< typename Real, typename Device, typename Index > void tnlIdenticalGridGeometry< 1, Real, Device, Index > :: setParametricStep( const tnlTuple< 1, Real >& parametricStep ) { this -> parametricStep = parametricStep; this -> elementMeasure = this -> parametricStep. x(); } template< typename Real, typename Device, typename Index > const tnlTuple< 1, Real >& tnlIdenticalGridGeometry< 1, Real, Device, Index > :: getParametricStep() const { return this -> parametricStep; } template< typename Real, typename Device, typename Index > void tnlIdenticalGridGeometry< 1, Real, Device, Index > :: getElementCoordinates( const Index i, const tnlTuple< 1, Real >& origin, tnlTuple< 1, Real >& coordinates ) const { coordinates. x() = ( i + 0.5 ) * parametricStep. x(); } template< typename Real, typename Device, typename Index > Real tnlIdenticalGridGeometry< 1, Real, Device, Index > :: getElementMeasure( const Index i ) const { return elementMeasure; } template< typename Real, typename Device, typename Index > template< Index dx > Real tnlIdenticalGridGeometry< 1, Real, Device, Index > :: getElementsDistance( const Index i ) const { return dx * parametricStep. x(); } template< typename Real, typename Device, typename Index > template< Index dx > void tnlIdenticalGridGeometry< 1, Real, Device, Index > :: getEdgeCoordinates( const Index i, const tnlTuple< 1, Real >& origin, tnlTuple< 1, Real >& coordinates ) const { coordinates. x() = origin. x() + ( i + 0.5 * ( 1.0 + dx ) ) * parametricStep. x(); } template< typename Real, typename Device, typename Index > template< Index dx > Real tnlIdenticalGridGeometry< 1, Real, Device, Index > :: getEdgeLength( const Index i ) const { return 0.0; } template< typename Real, typename Device, typename Index > template< Index dx > void tnlIdenticalGridGeometry< 1, Real, Device, Index > :: getEdgeNormal( const Index i, tnlTuple< 1, Real >& normal ) const { tnlAssert( dx == 1 || dx == -1, cerr << " dx = " << dx << " dy = " << dy << endl ); normal. x() = dx; } template< typename Real, typename Device, typename Index > bool tnlIdenticalGridGeometry< 1, Real, Device, Index > :: save( tnlFile& file ) const { if( ! this -> parametricStep. save( file ) ) return false; return true; }; template< typename Real, typename Device, typename Index > bool tnlIdenticalGridGeometry< 1, Real, Device, Index > :: load( tnlFile& file ) { if( ! this -> parametricStep. load( file ) ) return false; this -> elementMeasure = this -> parametricStep. x(); return true; }; /**** * Identical geometry for 2D */ template< typename Real, typename Device, typename Index > void tnlIdenticalGridGeometry< 2, Real, Device, Index > :: setParametricStep( const tnlTuple< 2, Real >& parametricStep ) { this -> parametricStep = parametricStep; this -> elementMeasure - this -> parametricStep. x() * this -> parametricStep. y(); this -> elementMeasure = this -> parametricStep. x() * this -> parametricStep. y(); } template< typename Real, typename Device, typename Index > const tnlTuple< 2, Real >& tnlIdenticalGridGeometry< 2, Real, Device, Index > :: getParametricStep() const { return this -> parametricStep; } template< typename Real, Loading @@ -35,10 +147,11 @@ template< typename Real, typename Index > void tnlIdenticalGridGeometry< 2, Real, Device, Index > :: getElementCoordinates( const Index j, const Index i, const tnlTuple< 2, Real >& origin, tnlTuple< 2, Real >& coordinates ) const { coordinates. x() = i * parametricStep. x(); coordinates. y() = j * parametricStep. y(); coordinates. x() = ( i + 0.5 ) * parametricStep. x(); coordinates. y() = ( j + 0.5 ) * parametricStep. y(); } template< typename Real, Loading Loading @@ -72,6 +185,7 @@ template< typename Real, template< Index dy, Index dx > void tnlIdenticalGridGeometry< 2, Real, Device, Index > :: getEdgeCoordinates( const Index j, const Index i, const tnlTuple< 2, Real >& origin, tnlTuple< 2, Real >& coordinates ) const { coordinates. x() = origin. x() + ( i + 0.5 * ( 1.0 + dx ) ) * parametricStep. x(); Loading @@ -81,7 +195,7 @@ void tnlIdenticalGridGeometry< 2, Real, Device, Index > :: getEdgeCoordinates( c template< typename Real, typename Device, typename Index > template< int dy, int dx > template< Index dy, Index dx > Real tnlIdenticalGridGeometry< 2, Real, Device, Index > :: getEdgeLength( const Index j, const Index i ) const { Loading @@ -95,7 +209,7 @@ Real tnlIdenticalGridGeometry< 2, Real, Device, Index > :: getEdgeLength( const template< typename Real, typename Device, typename Index > template< int dy, int dx > template< Index dy, Index dx > void tnlIdenticalGridGeometry< 2, Real, Device, Index > :: getEdgeNormal( const Index j, const Index i, tnlTuple< 2, Real >& normal ) const Loading @@ -112,6 +226,8 @@ template< typename Real, typename Index > bool tnlIdenticalGridGeometry< 2, Real, Device, Index > :: save( tnlFile& file ) const { if( ! this -> parametricStep. save( file ) ) return false; return true; }; Loading @@ -120,6 +236,9 @@ template< typename Real, typename Index > bool tnlIdenticalGridGeometry< 2, Real, Device, Index > :: load( tnlFile& file ) { if( ! this -> parametricStep. load( file ) ) return false; this -> elementMeasure = this -> parametricStep. x() * this -> parametricStep. y(); return true; }; Loading Loading
examples/navier-stokes/navierStokesSolver_impl.h +8 −8 Original line number Diff line number Diff line Loading @@ -112,8 +112,8 @@ bool navierStokesSolver< Mesh, EulerScheme > :: init( const tnlParameterContaine return false; } this -> mesh. setDimensions( meshes. y(), meshes. x() ); RealType hx = this -> mesh. getSpaceStep(). x(); RealType hy = this -> mesh. getSpaceStep(). y(); RealType hx = this -> mesh. getParametricStep(). x(); RealType hy = this -> mesh. getParametricStep(). y(); mesh. save( tnlString( "mesh.tnl" ) ); /**** Loading Loading @@ -170,8 +170,8 @@ bool navierStokesSolver< Mesh, EulerScheme > :: setInitialCondition( const tnlPa const IndexType& xSize = mesh. getDimensions(). x(); const IndexType& ySize = mesh. getDimensions(). y(); const RealType hx = mesh. getSpaceStep(). x(); const RealType hy = mesh. getSpaceStep(). y(); const RealType hx = mesh. getParametricStep(). x(); const RealType hy = mesh. getParametricStep(). y(); for( IndexType j = 0; j < ySize; j ++ ) for( IndexType i = 0; i < xSize; i ++ ) Loading Loading @@ -344,8 +344,8 @@ void navierStokesSolver< Mesh, EulerScheme > :: GetExplicitRHS( const RealType& */ const IndexType& xSize = mesh. getDimensions(). x(); const IndexType& ySize = mesh. getDimensions(). y(); const RealType hx = mesh. getSpaceStep(). x(); const RealType hy = mesh. getSpaceStep(). y(); const RealType hx = mesh. getParametricStep(). x(); const RealType hy = mesh. getParametricStep(). y(); RealType startUpCoefficient( 1.0 ); if( this -> startUp != 0.0 ) startUpCoefficient = Min( ( RealType ) 1.0, time / this -> startUp ); Loading Loading @@ -553,8 +553,8 @@ void navierStokesSolver< Mesh, EulerScheme > :: writeProlog( tnlLogger& logger, logger. WriteParameter< tnlString >( "Space discretisation:", "scheme", parameters ); logger. WriteParameter< int >( "Meshes along x:", mesh. getDimensions(). x() ); logger. WriteParameter< int >( "Meshes along y:", mesh. getDimensions(). y() ); logger. WriteParameter< double >( "Space step along x:", mesh. getSpaceStep(). x() ); logger. WriteParameter< double >( "Space step along y:", mesh. getSpaceStep(). y() ); logger. WriteParameter< double >( "Space step along x:", mesh. getParametricStep(). x() ); logger. WriteParameter< double >( "Space step along y:", mesh. getParametricStep(). y() ); } #endif /* NAVIERSTOKESSOLVER_IMPL_H_ */
src/implementation/mesh/tnlGrid1D_impl.h +15 −20 Original line number Diff line number Diff line Loading @@ -61,10 +61,14 @@ template< typename Real, template< int, typename, typename, typename > class Geometry > void tnlGrid< 1, Real, Device, Index, Geometry > :: setDimensions( const Index xSize ) { tnlAssert( xSize > 1, cerr << "The number of Elements along x-axis must be larger than 1." ); tnlAssert( xSize > 0, cerr << "The number of Elements along x-axis must be larger than 0." ); this -> dimensions. x() = xSize; dofs = xSize; tnlTuple< 1, Real > parametricStep; parametricStep. x() = proportions. x() / xSize; geometry. setParametricStep( parametricStep ); } template< typename Real, Loading @@ -73,10 +77,7 @@ template< typename Real, template< int, typename, typename, typename > class Geometry > void tnlGrid< 1, Real, Device, Index, Geometry > :: setDimensions( const tnlTuple< 1, Index >& dimensions ) { tnlAssert( dimensions. x() > 1, cerr << "The number of Elements along x-axis must be larger than 1." ); this -> dimensions = dimensions; dofs = this -> dimensions. x(); this -> setDimensions( dimensions. x() ); } template< typename Real, Loading Loading @@ -113,6 +114,7 @@ template< typename Real, void tnlGrid< 1, Real, Device, Index, Geometry > :: setProportions( const tnlTuple< 1, Real >& proportions ) { this -> proportions = proportions; this -> setDimensions( this -> dimensions ); } template< typename Real, Loading @@ -128,26 +130,19 @@ template< typename Real, typename Device, typename Index, template< int, typename, typename, typename > class Geometry > void tnlGrid< 1, Real, Device, Index, Geometry > :: setSpaceStep( const tnlTuple< 1, Real >& spaceStep ) void tnlGrid< 1, Real, Device, Index, Geometry > :: setParametricStep( const tnlTuple< 1, Real >& parametricStep ) { this -> proportions. x() = this -> dimensions. x() * spaceStep. x(); this -> proportions. x() = this -> dimensions. x() * parametricStep. x(); geometry. setParametricStep( parametricStep ); } template< typename Real, typename Device, typename Index, template< int, typename, typename, typename > class Geometry > tnlTuple< 1, Real > tnlGrid< 1, Real, Device, Index, Geometry > :: getSpaceStep() const const tnlTuple< 1, Real >& tnlGrid< 1, 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 " << this -> getName() ); tnlTuple< 1, RealType > spaceStep; spaceStep. x() = ( this -> proportions. x() ) / ( Real ) ( this -> dimensions. x() - 1 ); return spaceStep; return geometry. getParametricStep(); } template< typename Real, Loading Loading @@ -251,8 +246,8 @@ bool tnlGrid< 1, Real, Device, Index, Geometry > :: write( const MeshFunction& f cerr << "I am not able to open the file " << fileName << "." << endl; return false; } const RealType hx = getSpaceStep(). x(); const RealType hy = getSpaceStep(). y(); const RealType hx = getParametricStep(). x(); const RealType hy = getParametricStep(). y(); if( format == "gnuplot" ) for( IndexType i = 0; i < getDimensions(). x(); i++ ) { Loading
src/implementation/mesh/tnlGrid2D_impl.h +17 −18 Original line number Diff line number Diff line Loading @@ -60,17 +60,17 @@ template< typename Real, template< int, typename, typename, typename > class Geometry > void tnlGrid< 2, Real, Device, Index, Geometry > :: setDimensions( const Index ySize, const Index xSize ) { tnlAssert( xSize > 1, cerr << "The number of Elements along x-axis must be larger than 1." ); tnlAssert( ySize > 1, cerr << "The number of Elements along y-axis must be larger than 1." ); tnlAssert( xSize > 0, cerr << "The number of Elements along x-axis must be larger than 0." ); tnlAssert( ySize > 0, cerr << "The number of Elements along y-axis must be larger than 0." ); 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 ); parametricStep. x() = proportions. x() / xSize; parametricStep. y() = proportions. y() / ySize; geometry. setParametricStep( parametricStep ); } Loading Loading @@ -139,18 +139,18 @@ template< typename Real, void tnlGrid< 2, Real, Device, Index, Geometry > :: setParametricStep( const tnlTuple< 2, Real >& spaceStep ) { this -> proportions. x() = this -> dimensions. x() * parametricStep. x(); geometry. getParametricStep(). x(); this -> proportions. y() = this -> dimensions. y() * parametricStep. y(); geometry. getParametricStep(). y(); } template< typename Real, typename Device, typename Index, template< int, typename, typename, typename > class Geometry > tnlTuple< 2, Real > tnlGrid< 2, Real, Device, Index, Geometry > :: getParametricStep() const const tnlTuple< 2, Real >& tnlGrid< 2, Real, Device, Index, Geometry > :: getParametricStep() const { tnlAssert( dimensions. x() > 0, /*tnlAssert( dimensions. x() > 0, cerr << "Cannot get the space step hx since number of Elements along the x axis is not known in tnlGrid " << this -> getName() ); tnlAssert( dimensions. y() > 0, Loading @@ -161,8 +161,8 @@ tnlTuple< 2, Real > tnlGrid< 2, Real, Device, Index, Geometry > :: getParametric parametricStep. x() = this -> proportions. x() / ( Real ) ( this -> dimensions. x() - 1 ); parametricStep. y() = this -> proportions. y() / ( Real ) ( this -> dimensions. y() - 1 ); return parametricStep; this -> proportions. y() / ( Real ) ( this -> dimensions. y() - 1 );*/ return geometry. getParametricStep(); } template< typename Real, Loading Loading @@ -223,12 +223,11 @@ template< typename Real, typename Device, typename Index, template< int, typename, typename, typename > class Geometry > template< Index dy, Index dx > Real tnlGrid< 2, Real, Device, Index, Geometry > :: getElementsDistance( const Index j, const Index i, const Index dy, const Index dx ) const const Index i ) const { return geometry. getElementsDistance( j, i, dy, dx ); return geometry. getElementsDistance< dy, dx >( j, i ); } template< typename Real, Loading Loading @@ -341,8 +340,8 @@ bool tnlGrid< 2, Real, Device, Index, Geometry > :: write( const MeshFunction& f cerr << "I am not able to open the file " << fileName << "." << endl; return false; } const RealType hx = getSpaceStep(). x(); const RealType hy = getSpaceStep(). y(); const RealType hx = getParametricStep(). x(); const RealType hy = getParametricStep(). y(); if( format == "gnuplot" ) for( IndexType j = 0; j < getDimensions(). y(); j++ ) { Loading
src/implementation/mesh/tnlGrid3D_impl.h +4 −4 Original line number Diff line number Diff line Loading @@ -136,7 +136,7 @@ template< typename Real, typename Device, typename Index, template< int, typename, typename, typename > class Geometry > void tnlGrid< 3, Real, Device, Index, Geometry > :: setSpaceStep( const tnlTuple< 3, Real >& spaceStep ) void tnlGrid< 3, Real, Device, Index, Geometry > :: setParametricStep( const tnlTuple< 3, Real >& spaceStep ) { this -> proportions. x() = this -> dimensions. x() * spaceStep. x(); Loading @@ -150,7 +150,7 @@ template< typename Real, typename Device, typename Index, template< int, typename, typename, typename > class Geometry > tnlTuple< 3, Real > tnlGrid< 3, Real, Device, Index, Geometry > :: getSpaceStep() const tnlTuple< 3, Real > tnlGrid< 3, 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 Loading @@ -286,8 +286,8 @@ bool tnlGrid< 3, Real, Device, Index, Geometry > :: write( const MeshFunction& f cerr << "I am not able to open the file " << fileName << "." << endl; return false; } const RealType hx = getSpaceStep(). x(); const RealType hy = getSpaceStep(). y(); const RealType hx = getParametricStep(). x(); const RealType hy = getParametricStep(). y(); if( format == "gnuplot" ) { tnlAssert( false, cerr << "TODO"); Loading
src/implementation/mesh/tnlIdenticalGridGeometry_impl.h +124 −5 Original line number Diff line number Diff line Loading @@ -21,13 +21,125 @@ #include <core/tnlFile.h> #include <core/tnlAssert.h> /**** * Identical geometry for 1D */ template< typename Real, typename Device, typename Index > void tnlIdenticalGridGeometry< 1, Real, Device, Index > :: setParametricStep( const tnlTuple< 1, Real >& parametricStep ) { this -> parametricStep = parametricStep; this -> elementMeasure = this -> parametricStep. x(); } template< typename Real, typename Device, typename Index > const tnlTuple< 1, Real >& tnlIdenticalGridGeometry< 1, Real, Device, Index > :: getParametricStep() const { return this -> parametricStep; } template< typename Real, typename Device, typename Index > void tnlIdenticalGridGeometry< 1, Real, Device, Index > :: getElementCoordinates( const Index i, const tnlTuple< 1, Real >& origin, tnlTuple< 1, Real >& coordinates ) const { coordinates. x() = ( i + 0.5 ) * parametricStep. x(); } template< typename Real, typename Device, typename Index > Real tnlIdenticalGridGeometry< 1, Real, Device, Index > :: getElementMeasure( const Index i ) const { return elementMeasure; } template< typename Real, typename Device, typename Index > template< Index dx > Real tnlIdenticalGridGeometry< 1, Real, Device, Index > :: getElementsDistance( const Index i ) const { return dx * parametricStep. x(); } template< typename Real, typename Device, typename Index > template< Index dx > void tnlIdenticalGridGeometry< 1, Real, Device, Index > :: getEdgeCoordinates( const Index i, const tnlTuple< 1, Real >& origin, tnlTuple< 1, Real >& coordinates ) const { coordinates. x() = origin. x() + ( i + 0.5 * ( 1.0 + dx ) ) * parametricStep. x(); } template< typename Real, typename Device, typename Index > template< Index dx > Real tnlIdenticalGridGeometry< 1, Real, Device, Index > :: getEdgeLength( const Index i ) const { return 0.0; } template< typename Real, typename Device, typename Index > template< Index dx > void tnlIdenticalGridGeometry< 1, Real, Device, Index > :: getEdgeNormal( const Index i, tnlTuple< 1, Real >& normal ) const { tnlAssert( dx == 1 || dx == -1, cerr << " dx = " << dx << " dy = " << dy << endl ); normal. x() = dx; } template< typename Real, typename Device, typename Index > bool tnlIdenticalGridGeometry< 1, Real, Device, Index > :: save( tnlFile& file ) const { if( ! this -> parametricStep. save( file ) ) return false; return true; }; template< typename Real, typename Device, typename Index > bool tnlIdenticalGridGeometry< 1, Real, Device, Index > :: load( tnlFile& file ) { if( ! this -> parametricStep. load( file ) ) return false; this -> elementMeasure = this -> parametricStep. x(); return true; }; /**** * Identical geometry for 2D */ template< typename Real, typename Device, typename Index > void tnlIdenticalGridGeometry< 2, Real, Device, Index > :: setParametricStep( const tnlTuple< 2, Real >& parametricStep ) { this -> parametricStep = parametricStep; this -> elementMeasure - this -> parametricStep. x() * this -> parametricStep. y(); this -> elementMeasure = this -> parametricStep. x() * this -> parametricStep. y(); } template< typename Real, typename Device, typename Index > const tnlTuple< 2, Real >& tnlIdenticalGridGeometry< 2, Real, Device, Index > :: getParametricStep() const { return this -> parametricStep; } template< typename Real, Loading @@ -35,10 +147,11 @@ template< typename Real, typename Index > void tnlIdenticalGridGeometry< 2, Real, Device, Index > :: getElementCoordinates( const Index j, const Index i, const tnlTuple< 2, Real >& origin, tnlTuple< 2, Real >& coordinates ) const { coordinates. x() = i * parametricStep. x(); coordinates. y() = j * parametricStep. y(); coordinates. x() = ( i + 0.5 ) * parametricStep. x(); coordinates. y() = ( j + 0.5 ) * parametricStep. y(); } template< typename Real, Loading Loading @@ -72,6 +185,7 @@ template< typename Real, template< Index dy, Index dx > void tnlIdenticalGridGeometry< 2, Real, Device, Index > :: getEdgeCoordinates( const Index j, const Index i, const tnlTuple< 2, Real >& origin, tnlTuple< 2, Real >& coordinates ) const { coordinates. x() = origin. x() + ( i + 0.5 * ( 1.0 + dx ) ) * parametricStep. x(); Loading @@ -81,7 +195,7 @@ void tnlIdenticalGridGeometry< 2, Real, Device, Index > :: getEdgeCoordinates( c template< typename Real, typename Device, typename Index > template< int dy, int dx > template< Index dy, Index dx > Real tnlIdenticalGridGeometry< 2, Real, Device, Index > :: getEdgeLength( const Index j, const Index i ) const { Loading @@ -95,7 +209,7 @@ Real tnlIdenticalGridGeometry< 2, Real, Device, Index > :: getEdgeLength( const template< typename Real, typename Device, typename Index > template< int dy, int dx > template< Index dy, Index dx > void tnlIdenticalGridGeometry< 2, Real, Device, Index > :: getEdgeNormal( const Index j, const Index i, tnlTuple< 2, Real >& normal ) const Loading @@ -112,6 +226,8 @@ template< typename Real, typename Index > bool tnlIdenticalGridGeometry< 2, Real, Device, Index > :: save( tnlFile& file ) const { if( ! this -> parametricStep. save( file ) ) return false; return true; }; Loading @@ -120,6 +236,9 @@ template< typename Real, typename Index > bool tnlIdenticalGridGeometry< 2, Real, Device, Index > :: load( tnlFile& file ) { if( ! this -> parametricStep. load( file ) ) return false; this -> elementMeasure = this -> parametricStep. x() * this -> parametricStep. y(); return true; }; Loading