Loading src/core/CMakeLists.txt +1 −0 Original line number Diff line number Diff line Loading @@ -6,6 +6,7 @@ set (headers tnlArray.h tnlCuda.h tnlDataElement.h tnlDevice.h tnlFeature.h tnlFile.h tnlFlopsCounter.h tnlHost.h Loading src/core/tnlFeature.h 0 → 100644 +30 −0 Original line number Diff line number Diff line /*************************************************************************** tnlFeature.h - description ------------------- begin : May 18, 2013 copyright : (C) 2013 by Tomas Oberhuber email : tomas.oberhuber@fjfi.cvut.cz ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #ifndef TNLFEATURE_H_ #define TNLFEATURE_H_ template< bool featureEnabled > class tnlFeature { public: enum{ enabled = featureEnabled }; }; #endif /* TNLFEATURE_H_ */ src/implementation/mesh/tnlGrid2D_impl.h +91 −39 Original line number Diff line number Diff line Loading @@ -72,6 +72,12 @@ void tnlGrid< 2, Real, Device, Index, Geometry > :: setDimensions( const Index x parametricStep. x() = proportions. x() / xSize; parametricStep. y() = proportions. y() / ySize; geometry. setParametricStep( parametricStep ); if( GeometryType :: ElementMeasureStorage :: enabled ) { elementsMeasure. setSize( this -> getDofs() ); dualElementsMeasure. setSize( this -> getDofs() ); edgeNormals. setSize( this -> getNumberOfEdges() ); } } template< typename Real, Loading Loading @@ -154,18 +160,6 @@ template< typename Real, const typename tnlGrid< 2, Real, Device, Index, Geometry > :: VertexType& 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 " << this -> getName() ); tnlAssert( dimensions. y() > 0, 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 > parametricStep; parametricStep. x() = this -> proportions. x() / ( Real ) ( this -> dimensions. x() - 1 ); parametricStep. y() = this -> proportions. y() / ( Real ) ( this -> dimensions. y() - 1 );*/ return geometry. getParametricStep(); } Loading @@ -178,15 +172,80 @@ Index tnlGrid< 2, Real, Device, Index, Geometry > :: getElementIndex( const Inde tnlAssert( i < dimensions. x(), cerr << "Index i ( " << i << " ) is out of range ( " << dimensions. x() << " ) in tnlGrid " << this -> getName(); ) << " ) in tnlGrid " << this -> getName(); ); tnlAssert( j < dimensions. y(), cerr << "Index j ( " << j << " ) is out of range ( " << dimensions. y() << " ) in tnlGrid " << this -> getName(); ) << " ) in tnlGrid " << this -> getName(); ); return j * this -> dimensions. x() + i; } template< typename Real, typename Device, typename Index, template< int, typename, typename, typename > class Geometry > Index tnlGrid< 2, Real, Device, Index, Geometry > :: getEdgeIndex( const Index i, const Index j, const Index dx, const Index dy ) const { tnlAssert( i < dimensions. x(), cerr << "Index i ( " << i << " ) is out of range ( " << dimensions. x() << " ) in tnlGrid " << this -> getName(); ); tnlAssert( j < dimensions. y(), cerr << "Index j ( " << j << " ) is out of range ( " << dimensions. y() << " ) in tnlGrid " << this -> getName(); ); tnlAssert( dx == 0 && ( dy == 1 || dy == -1 ) || dy == 0 && ( dx == 1 || dx == -1 ), cerr << "dx = " << dx << ", dy = " << dy << endl;); return ( j + dy ) * this -> dimensions. x() + i + dx; } template< typename Real, typename Device, typename Index, template< int, typename, typename, typename > class Geometry > void tnlGrid< 2, Real, Device, Index, Geometry > :: refresh() { if( GeometryType :: ElementMeasureStorage :: enabled ) for( IndexType j = 0; j < dimensions. y(); j ++ ) for( IndexType i = 0; i < dimensions. x(); i ++ ) elementsMeasure[ getElementIndex( i, j ) ] = geometry. getElementMeasure( CoordinatesType( i, j ) ); if( GeometryType :: DualElementMeasureStorage :: enabled ) for( IndexType j = 1; j < dimensions. y() - 1; j ++ ) for( IndexType i = 1; i < dimensions. x() - 1; i ++ ) { dualElementsMeasure[ getElementIndex( i + 1, j ) ] = geometry. getDualElementMeasure< 1, 0 >( CoordinatesType( i, j ) ); dualElementsMeasure[ getElementIndex( i - 1, j ) ] = geometry. getDualElementMeasure< -1, 0 >( CoordinatesType( i, j ) ); dualElementsMeasure[ getElementIndex( i, j + 1 ) ] = geometry. getDualElementMeasure< 0, 1 >( CoordinatesType( i, j ) ); dualElementsMeasure[ getElementIndex( i, j - 1 ) ] = geometry. getDualElementMeasure< 0, -1 >( CoordinatesType( i, j ) ); } if( GeometryType :: EdgeNormalStorage :: enabled ) for( IndexType j = 0; j < dimensions. y(); j ++ ) for( IndexType i = 0; i < dimensions. x(); i ++ ) { geometry. getEdgeNormal< 1, 0 >( CoordinatesType( i, j ), edgeNormals[ getEdgeIndex( i, j, 1, 0 ) ] ); geometry. getEdgeNormal< -1, 0 >( CoordinatesType( i, j ), edgeNormals[ getEdgeIndex( i, j, -1, 0 ) ] ); geometry. getEdgeNormal< 0, 1 >( CoordinatesType( i, j ), edgeNormals[ getEdgeIndex( i, j, 0, 1 ) ] ); geometry. getEdgeNormal< 0, -1 >( CoordinatesType( i, j ), edgeNormals[ getEdgeIndex( i, j, 0, -1 ) ] ); } } template< typename Real, typename Device, typename Index, Loading Loading @@ -218,7 +277,6 @@ Index tnlGrid< 2, Real, Device, Index, Geometry > :: getElementNeighbour( const return Element + dy * this -> dimensions. x() + dx; } template< typename Real, typename Device, typename Index, Loading @@ -232,53 +290,44 @@ template< typename Real, typename Device, typename Index, template< int, typename, typename, typename > class Geometry > void tnlGrid< 2, Real, Device, Index, Geometry > :: getElementCenter( const CoordinatesType& coordinates, VertexType& center ) const Index tnlGrid< 2, Real, Device, Index, Geometry > :: getNumberOfEdges() const { geometry. getElementCenter( origin, coordinates, center ); return ( this -> dimensions. x() + 1 ) * ( this -> dimensions. y() + 1 ); } template< typename Real, typename Device, typename Index, template< int, typename, typename, typename > class Geometry > Real tnlGrid< 2, Real, Device, Index, Geometry > :: getElementMeasure( const CoordinatesType& coordinates ) const void tnlGrid< 2, Real, Device, Index, Geometry > :: getElementCenter( const CoordinatesType& coordinates, VertexType& center ) const { return geometry. getElementMeasure( coordinates ); geometry. getElementCenter( origin, coordinates, center ); } template< typename Real, typename Device, typename Index, template< int, typename, typename, typename > class Geometry > template< int dx, int dy > Real tnlGrid< 2, Real, Device, Index, Geometry > :: getElementCoVolumeMeasure( const CoordinatesType& coordinates ) const Real tnlGrid< 2, Real, Device, Index, Geometry > :: getElementMeasure( const CoordinatesType& coordinates ) const { return geometry. getElementCoVolumeMeasure< dx, dy >( coordinates ); if( GeometryType :: ElementMeasureStorage :: enabled ) return elementsMeasure[ getElementIndex( coordinates. x(), coordinates. y() ) ]; return geometry. getElementMeasure( coordinates ); } template< typename Real, typename Device, typename Index, template< int, typename, typename, typename > class Geometry > Real tnlGrid< 2, Real, Device, Index, Geometry > :: getElementsDistance( const CoordinatesType& c1, const CoordinatesType& c2 ) const template< int dx, int dy > Real tnlGrid< 2, Real, Device, Index, Geometry > :: getDualElementMeasure( const CoordinatesType& coordinates ) const { return geometry. getElementsDistance( c1, c2 ); if( GeometryType :: DualElementMeasureStorage :: enabled ) return dualElementsMeasure[ getElementIndex( coordinates. x() + dx, coordinates. y() + dy ) ]; return geometry. getDualElementMeasure< dx, dy >( coordinates ); } /* 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, Loading @@ -287,6 +336,9 @@ template< int dx, int dy > void tnlGrid< 2, Real, Device, Index, Geometry > :: getEdgeNormal( const CoordinatesType& coordinates, VertexType& normal ) const { //if( GeometryType :: EdgeNormalStorage :: enabled ) // normal = edgeNormals[ getEdgeIndex( coordinates. x(), coordinates. y(), dx, dy ) ]; //else return geometry. getEdgeNormal< dx, dy >( coordinates, normal ); } Loading src/implementation/mesh/tnlIdenticalGridGeometry_impl.h +1 −45 Original line number Diff line number Diff line Loading @@ -167,55 +167,11 @@ template< typename Real, typename Device, typename Index > template< int dx, int dy > Real tnlIdenticalGridGeometry< 2, Real, Device, Index > :: getElementCoVolumeMeasure( const CoordinatesType& coordinates ) const Real tnlIdenticalGridGeometry< 2, Real, Device, Index > :: getDualElementMeasure( const CoordinatesType& coordinates ) const { return 0.5 * elementMeasure; } template< typename Real, typename Device, typename Index > Real tnlIdenticalGridGeometry< 2, Real, Device, Index > :: getElementsDistance( const CoordinatesType& c1, const CoordinatesType& c2 ) const { CoordinatesType c( c2 ); c -= c1; if( c. y() == 0 ) return parametricStep. x() * fabs( c. x() ); if( c. x() == 0 ) return parametricStep. y() * fabs( c. y() ); return sqrt( c. x() * c. x() + c. y() * c. y() ); } /* template< typename Real, typename Device, typename Index > template< Index dx, Index dy > void tnlIdenticalGridGeometry< 2, Real, Device, Index > :: getEdgeCoordinates( const Index i, const Index j, const VertexType& origin, VertexType& coordinates ) const { coordinates. x() = origin. x() + ( i + 0.5 * ( 1.0 + dx ) ) * parametricStep. x(); coordinates. y() = origin. y() + ( j + 0.5 * ( 1.0 + dy ) ) * parametricStep. y(); } template< typename Real, typename Device, typename Index > template< Index dx, Index dy > Real tnlIdenticalGridGeometry< 2, Real, Device, Index > :: getEdgeLength( const Index i, const Index j ) const { if( dy == 0 && dx == 1 ) return parametricStep. y(); if( dy == 1 && dx == 0 ) return parametricStep. x(); tnlAssert( false, cerr << "Bad values of dx and dy - dx = " << dx << " dy = " << dy ); }*/ template< typename Real, typename Device, typename Index > Loading src/implementation/mesh/tnlLinearGridGeometry_impl.h +21 −47 Original line number Diff line number Diff line Loading @@ -175,58 +175,32 @@ template< typename Real, typename Device, typename Index > template< int dx, int dy > Real tnlLinearGridGeometry< 2, Real, Device, Index > :: getElementCoVolumeMeasure( const CoordinatesType& coordinates ) const Real tnlLinearGridGeometry< 2, Real, Device, Index > :: getDualElementMeasure( const CoordinatesType& coordinates ) const { tnlAssert( ( dx == 0 && ( dy == 1 || dy == -1 ) ) || ( dy == 0 && ( dx == 1 || dx == -1 ) ), cerr << " dx = " << dx << " dy = " << dy << endl ); return 0.5 * elementMeasure; } template< typename Real, typename Device, typename Index > Real tnlLinearGridGeometry< 2, Real, Device, Index > :: getElementsDistance( const CoordinatesType& c1, const CoordinatesType& c2 ) const VertexType v0, v1, v2, v3; const VertexType origin( 0.0 ); this -> getElementCenter( origin, coordinates, v0 ); if( dy == 0 ) { CoordinatesType c( c2 ); c -= c1; if( c. y() == 0 ) return parametricStep. x() * fabs( c. x() ); if( c. x() == 0 ) return parametricStep. y() * fabs( c. y() ); return sqrt( c. x() * c. x() + c. y() * c. y() ); this -> template getVertex< dx, -1 >( coordinates, origin, v1 ); this -> template getVertex< dx, 1 >( coordinates, origin, v2 ); CoordinatesType c2( coordinates ); c2. x() += dx; this -> getElementCenter( origin, c2, v3 ); } /* template< typename Real, typename Device, typename Index > template< Index dx, Index dy > void tnlLinearGridGeometry< 2, Real, Device, Index > :: getEdgeCoordinates( const Index i, const Index j, const VertexType& origin, VertexType& coordinates ) const if( dx == 0 ) { coordinates. x() = origin. x() + ( i + 0.5 * ( 1.0 + dx ) ) * parametricStep. x(); coordinates. y() = origin. y() + ( j + 0.5 * ( 1.0 + dy ) ) * parametricStep. y(); this -> template getVertex< -1, dy >( coordinates, origin, v1 ); this -> template getVertex< 1, dy >( coordinates, origin, v2 ); CoordinatesType c2( coordinates ); c2. y() += dy; this -> getElementCenter( origin, c2, v3 ); } return tnlTriangleArea( v0, v1, v3 ) + tnlTriangleArea( v2, v3, v1 ); } template< typename Real, typename Device, typename Index > template< Index dx, Index dy > Real tnlLinearGridGeometry< 2, Real, Device, Index > :: getEdgeLength( const Index i, const Index j ) const { if( dy == 0 && dx == 1 ) return parametricStep. y(); if( dy == 1 && dx == 0 ) return parametricStep. x(); tnlAssert( false, cerr << "Bad values of dx and dy - dx = " << dx << " dy = " << dy ); }*/ template< typename Real, typename Device, Loading Loading
src/core/CMakeLists.txt +1 −0 Original line number Diff line number Diff line Loading @@ -6,6 +6,7 @@ set (headers tnlArray.h tnlCuda.h tnlDataElement.h tnlDevice.h tnlFeature.h tnlFile.h tnlFlopsCounter.h tnlHost.h Loading
src/core/tnlFeature.h 0 → 100644 +30 −0 Original line number Diff line number Diff line /*************************************************************************** tnlFeature.h - description ------------------- begin : May 18, 2013 copyright : (C) 2013 by Tomas Oberhuber email : tomas.oberhuber@fjfi.cvut.cz ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #ifndef TNLFEATURE_H_ #define TNLFEATURE_H_ template< bool featureEnabled > class tnlFeature { public: enum{ enabled = featureEnabled }; }; #endif /* TNLFEATURE_H_ */
src/implementation/mesh/tnlGrid2D_impl.h +91 −39 Original line number Diff line number Diff line Loading @@ -72,6 +72,12 @@ void tnlGrid< 2, Real, Device, Index, Geometry > :: setDimensions( const Index x parametricStep. x() = proportions. x() / xSize; parametricStep. y() = proportions. y() / ySize; geometry. setParametricStep( parametricStep ); if( GeometryType :: ElementMeasureStorage :: enabled ) { elementsMeasure. setSize( this -> getDofs() ); dualElementsMeasure. setSize( this -> getDofs() ); edgeNormals. setSize( this -> getNumberOfEdges() ); } } template< typename Real, Loading Loading @@ -154,18 +160,6 @@ template< typename Real, const typename tnlGrid< 2, Real, Device, Index, Geometry > :: VertexType& 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 " << this -> getName() ); tnlAssert( dimensions. y() > 0, 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 > parametricStep; parametricStep. x() = this -> proportions. x() / ( Real ) ( this -> dimensions. x() - 1 ); parametricStep. y() = this -> proportions. y() / ( Real ) ( this -> dimensions. y() - 1 );*/ return geometry. getParametricStep(); } Loading @@ -178,15 +172,80 @@ Index tnlGrid< 2, Real, Device, Index, Geometry > :: getElementIndex( const Inde tnlAssert( i < dimensions. x(), cerr << "Index i ( " << i << " ) is out of range ( " << dimensions. x() << " ) in tnlGrid " << this -> getName(); ) << " ) in tnlGrid " << this -> getName(); ); tnlAssert( j < dimensions. y(), cerr << "Index j ( " << j << " ) is out of range ( " << dimensions. y() << " ) in tnlGrid " << this -> getName(); ) << " ) in tnlGrid " << this -> getName(); ); return j * this -> dimensions. x() + i; } template< typename Real, typename Device, typename Index, template< int, typename, typename, typename > class Geometry > Index tnlGrid< 2, Real, Device, Index, Geometry > :: getEdgeIndex( const Index i, const Index j, const Index dx, const Index dy ) const { tnlAssert( i < dimensions. x(), cerr << "Index i ( " << i << " ) is out of range ( " << dimensions. x() << " ) in tnlGrid " << this -> getName(); ); tnlAssert( j < dimensions. y(), cerr << "Index j ( " << j << " ) is out of range ( " << dimensions. y() << " ) in tnlGrid " << this -> getName(); ); tnlAssert( dx == 0 && ( dy == 1 || dy == -1 ) || dy == 0 && ( dx == 1 || dx == -1 ), cerr << "dx = " << dx << ", dy = " << dy << endl;); return ( j + dy ) * this -> dimensions. x() + i + dx; } template< typename Real, typename Device, typename Index, template< int, typename, typename, typename > class Geometry > void tnlGrid< 2, Real, Device, Index, Geometry > :: refresh() { if( GeometryType :: ElementMeasureStorage :: enabled ) for( IndexType j = 0; j < dimensions. y(); j ++ ) for( IndexType i = 0; i < dimensions. x(); i ++ ) elementsMeasure[ getElementIndex( i, j ) ] = geometry. getElementMeasure( CoordinatesType( i, j ) ); if( GeometryType :: DualElementMeasureStorage :: enabled ) for( IndexType j = 1; j < dimensions. y() - 1; j ++ ) for( IndexType i = 1; i < dimensions. x() - 1; i ++ ) { dualElementsMeasure[ getElementIndex( i + 1, j ) ] = geometry. getDualElementMeasure< 1, 0 >( CoordinatesType( i, j ) ); dualElementsMeasure[ getElementIndex( i - 1, j ) ] = geometry. getDualElementMeasure< -1, 0 >( CoordinatesType( i, j ) ); dualElementsMeasure[ getElementIndex( i, j + 1 ) ] = geometry. getDualElementMeasure< 0, 1 >( CoordinatesType( i, j ) ); dualElementsMeasure[ getElementIndex( i, j - 1 ) ] = geometry. getDualElementMeasure< 0, -1 >( CoordinatesType( i, j ) ); } if( GeometryType :: EdgeNormalStorage :: enabled ) for( IndexType j = 0; j < dimensions. y(); j ++ ) for( IndexType i = 0; i < dimensions. x(); i ++ ) { geometry. getEdgeNormal< 1, 0 >( CoordinatesType( i, j ), edgeNormals[ getEdgeIndex( i, j, 1, 0 ) ] ); geometry. getEdgeNormal< -1, 0 >( CoordinatesType( i, j ), edgeNormals[ getEdgeIndex( i, j, -1, 0 ) ] ); geometry. getEdgeNormal< 0, 1 >( CoordinatesType( i, j ), edgeNormals[ getEdgeIndex( i, j, 0, 1 ) ] ); geometry. getEdgeNormal< 0, -1 >( CoordinatesType( i, j ), edgeNormals[ getEdgeIndex( i, j, 0, -1 ) ] ); } } template< typename Real, typename Device, typename Index, Loading Loading @@ -218,7 +277,6 @@ Index tnlGrid< 2, Real, Device, Index, Geometry > :: getElementNeighbour( const return Element + dy * this -> dimensions. x() + dx; } template< typename Real, typename Device, typename Index, Loading @@ -232,53 +290,44 @@ template< typename Real, typename Device, typename Index, template< int, typename, typename, typename > class Geometry > void tnlGrid< 2, Real, Device, Index, Geometry > :: getElementCenter( const CoordinatesType& coordinates, VertexType& center ) const Index tnlGrid< 2, Real, Device, Index, Geometry > :: getNumberOfEdges() const { geometry. getElementCenter( origin, coordinates, center ); return ( this -> dimensions. x() + 1 ) * ( this -> dimensions. y() + 1 ); } template< typename Real, typename Device, typename Index, template< int, typename, typename, typename > class Geometry > Real tnlGrid< 2, Real, Device, Index, Geometry > :: getElementMeasure( const CoordinatesType& coordinates ) const void tnlGrid< 2, Real, Device, Index, Geometry > :: getElementCenter( const CoordinatesType& coordinates, VertexType& center ) const { return geometry. getElementMeasure( coordinates ); geometry. getElementCenter( origin, coordinates, center ); } template< typename Real, typename Device, typename Index, template< int, typename, typename, typename > class Geometry > template< int dx, int dy > Real tnlGrid< 2, Real, Device, Index, Geometry > :: getElementCoVolumeMeasure( const CoordinatesType& coordinates ) const Real tnlGrid< 2, Real, Device, Index, Geometry > :: getElementMeasure( const CoordinatesType& coordinates ) const { return geometry. getElementCoVolumeMeasure< dx, dy >( coordinates ); if( GeometryType :: ElementMeasureStorage :: enabled ) return elementsMeasure[ getElementIndex( coordinates. x(), coordinates. y() ) ]; return geometry. getElementMeasure( coordinates ); } template< typename Real, typename Device, typename Index, template< int, typename, typename, typename > class Geometry > Real tnlGrid< 2, Real, Device, Index, Geometry > :: getElementsDistance( const CoordinatesType& c1, const CoordinatesType& c2 ) const template< int dx, int dy > Real tnlGrid< 2, Real, Device, Index, Geometry > :: getDualElementMeasure( const CoordinatesType& coordinates ) const { return geometry. getElementsDistance( c1, c2 ); if( GeometryType :: DualElementMeasureStorage :: enabled ) return dualElementsMeasure[ getElementIndex( coordinates. x() + dx, coordinates. y() + dy ) ]; return geometry. getDualElementMeasure< dx, dy >( coordinates ); } /* 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, Loading @@ -287,6 +336,9 @@ template< int dx, int dy > void tnlGrid< 2, Real, Device, Index, Geometry > :: getEdgeNormal( const CoordinatesType& coordinates, VertexType& normal ) const { //if( GeometryType :: EdgeNormalStorage :: enabled ) // normal = edgeNormals[ getEdgeIndex( coordinates. x(), coordinates. y(), dx, dy ) ]; //else return geometry. getEdgeNormal< dx, dy >( coordinates, normal ); } Loading
src/implementation/mesh/tnlIdenticalGridGeometry_impl.h +1 −45 Original line number Diff line number Diff line Loading @@ -167,55 +167,11 @@ template< typename Real, typename Device, typename Index > template< int dx, int dy > Real tnlIdenticalGridGeometry< 2, Real, Device, Index > :: getElementCoVolumeMeasure( const CoordinatesType& coordinates ) const Real tnlIdenticalGridGeometry< 2, Real, Device, Index > :: getDualElementMeasure( const CoordinatesType& coordinates ) const { return 0.5 * elementMeasure; } template< typename Real, typename Device, typename Index > Real tnlIdenticalGridGeometry< 2, Real, Device, Index > :: getElementsDistance( const CoordinatesType& c1, const CoordinatesType& c2 ) const { CoordinatesType c( c2 ); c -= c1; if( c. y() == 0 ) return parametricStep. x() * fabs( c. x() ); if( c. x() == 0 ) return parametricStep. y() * fabs( c. y() ); return sqrt( c. x() * c. x() + c. y() * c. y() ); } /* template< typename Real, typename Device, typename Index > template< Index dx, Index dy > void tnlIdenticalGridGeometry< 2, Real, Device, Index > :: getEdgeCoordinates( const Index i, const Index j, const VertexType& origin, VertexType& coordinates ) const { coordinates. x() = origin. x() + ( i + 0.5 * ( 1.0 + dx ) ) * parametricStep. x(); coordinates. y() = origin. y() + ( j + 0.5 * ( 1.0 + dy ) ) * parametricStep. y(); } template< typename Real, typename Device, typename Index > template< Index dx, Index dy > Real tnlIdenticalGridGeometry< 2, Real, Device, Index > :: getEdgeLength( const Index i, const Index j ) const { if( dy == 0 && dx == 1 ) return parametricStep. y(); if( dy == 1 && dx == 0 ) return parametricStep. x(); tnlAssert( false, cerr << "Bad values of dx and dy - dx = " << dx << " dy = " << dy ); }*/ template< typename Real, typename Device, typename Index > Loading
src/implementation/mesh/tnlLinearGridGeometry_impl.h +21 −47 Original line number Diff line number Diff line Loading @@ -175,58 +175,32 @@ template< typename Real, typename Device, typename Index > template< int dx, int dy > Real tnlLinearGridGeometry< 2, Real, Device, Index > :: getElementCoVolumeMeasure( const CoordinatesType& coordinates ) const Real tnlLinearGridGeometry< 2, Real, Device, Index > :: getDualElementMeasure( const CoordinatesType& coordinates ) const { tnlAssert( ( dx == 0 && ( dy == 1 || dy == -1 ) ) || ( dy == 0 && ( dx == 1 || dx == -1 ) ), cerr << " dx = " << dx << " dy = " << dy << endl ); return 0.5 * elementMeasure; } template< typename Real, typename Device, typename Index > Real tnlLinearGridGeometry< 2, Real, Device, Index > :: getElementsDistance( const CoordinatesType& c1, const CoordinatesType& c2 ) const VertexType v0, v1, v2, v3; const VertexType origin( 0.0 ); this -> getElementCenter( origin, coordinates, v0 ); if( dy == 0 ) { CoordinatesType c( c2 ); c -= c1; if( c. y() == 0 ) return parametricStep. x() * fabs( c. x() ); if( c. x() == 0 ) return parametricStep. y() * fabs( c. y() ); return sqrt( c. x() * c. x() + c. y() * c. y() ); this -> template getVertex< dx, -1 >( coordinates, origin, v1 ); this -> template getVertex< dx, 1 >( coordinates, origin, v2 ); CoordinatesType c2( coordinates ); c2. x() += dx; this -> getElementCenter( origin, c2, v3 ); } /* template< typename Real, typename Device, typename Index > template< Index dx, Index dy > void tnlLinearGridGeometry< 2, Real, Device, Index > :: getEdgeCoordinates( const Index i, const Index j, const VertexType& origin, VertexType& coordinates ) const if( dx == 0 ) { coordinates. x() = origin. x() + ( i + 0.5 * ( 1.0 + dx ) ) * parametricStep. x(); coordinates. y() = origin. y() + ( j + 0.5 * ( 1.0 + dy ) ) * parametricStep. y(); this -> template getVertex< -1, dy >( coordinates, origin, v1 ); this -> template getVertex< 1, dy >( coordinates, origin, v2 ); CoordinatesType c2( coordinates ); c2. y() += dy; this -> getElementCenter( origin, c2, v3 ); } return tnlTriangleArea( v0, v1, v3 ) + tnlTriangleArea( v2, v3, v1 ); } template< typename Real, typename Device, typename Index > template< Index dx, Index dy > Real tnlLinearGridGeometry< 2, Real, Device, Index > :: getEdgeLength( const Index i, const Index j ) const { if( dy == 0 && dx == 1 ) return parametricStep. y(); if( dy == 1 && dx == 0 ) return parametricStep. x(); tnlAssert( false, cerr << "Bad values of dx and dy - dx = " << dx << " dy = " << dy ); }*/ template< typename Real, typename Device, Loading