diff --git a/src/implementation/mesh/CMakeLists.txt b/src/implementation/mesh/CMakeLists.txt index 5a46422a511a93f5ce8268809ee135d12418bc1c..9d5f0578790f2d720a5bdc2bbb7727238bad9fb4 100755 --- a/src/implementation/mesh/CMakeLists.txt +++ b/src/implementation/mesh/CMakeLists.txt @@ -1,6 +1,7 @@ SET( headers tnlGrid1D_impl.h tnlGrid2D_impl.h tnlGrid3D_impl.h + tnlGridCellNeighbours_impl.h tnlTraversal_Grid1D_impl.h tnlTraversal_Grid2D_impl.h tnlTraversal_Grid3D_impl.h ) diff --git a/src/implementation/mesh/tnlGridCellNeighbours_impl.h b/src/implementation/mesh/tnlGridCellNeighbours_impl.h new file mode 100644 index 0000000000000000000000000000000000000000..b91f082976799a8ffa9e9fb002f281df1d26e84e --- /dev/null +++ b/src/implementation/mesh/tnlGridCellNeighbours_impl.h @@ -0,0 +1,110 @@ +/*************************************************************************** + tnlGridCellNeighbours_impl.h - description + ------------------- + begin : Jul 29, 2014 + copyright : (C) 2014 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 TNLGRIDCELLNEIGHBOURS_IMPL_H_ +#define TNLGRIDCELLNEIGHBOURS_IMPL_H_ + +template< typename Real, + typename Device, + typename Index > +tnlGridCellNeighbours< tnlGrid< 1, Real, Device, Index > >:: +tnlGridCellNeighbours( const GridType& grid, + const CoordinatesType& cellCoordinates ) +{ + const IndexType cellIndex = grid.getCellIndex( cellCoordinates ); + this->xPredecessor = cellIndex - 1; + this->xSuccessor = cellIndex + 1; +} + +template< typename Real, + typename Device, + typename Index > +Index +tnlGridCellNeighbours< tnlGrid< 1, Real, Device, Index > >:: +getXPredecessor() const +{ + return this->xPredecessor; +} + +template< typename Real, + typename Device, + typename Index > +Index +tnlGridCellNeighbours< tnlGrid< 1, Real, Device, Index > >:: +getXSuccessor() const +{ + return this->xSuccessor; +} + +template< typename Real, + typename Device, + typename Index > +tnlGridCellNeighbours< tnlGrid< 2, Real, Device, Index > >:: +tnlGridCellNeighbours( const GridType& grid, + const CoordinatesType& cellCoordinates ) +{ + const IndexType cellIndex = grid.getCellIndex( cellCoordinates ); + this->xPredecessor = cellIndex - 1; + this->xSuccessor = cellIndex + 1; + this->yPredecessor = cellIndex - grid.getDimensions().x(); + this->ySuccessor = cellIndex + grid.getDimensions().x(); +} + +template< typename Real, + typename Device, + typename Index > +Index +tnlGridCellNeighbours< tnlGrid< 2, Real, Device, Index > >:: +getXPredecessor() const +{ + return this->xPredecessor; +} + +template< typename Real, + typename Device, + typename Index > +Index +tnlGridCellNeighbours< tnlGrid< 2, Real, Device, Index > >:: +getXSuccessor() const +{ + return this->xSuccessor; +} + +template< typename Real, + typename Device, + typename Index > +Index +tnlGridCellNeighbours< tnlGrid< 2, Real, Device, Index > >:: +getYPredecessor() const +{ + return this->yPredecessor; +} + +template< typename Real, + typename Device, + typename Index > +Index +tnlGridCellNeighbours< tnlGrid< 2, Real, Device, Index > >:: +getYSuccessor() const +{ + return this->ySuccessor; +} + + + + +#endif /* TNLGRIDCELLNEIGHBOURS_IMPL_H_ */ diff --git a/src/mesh/CMakeLists.txt b/src/mesh/CMakeLists.txt index 1a55833a80446a379cf3f66d5e98b01e5821ac5d..afc30628d3c6bc1941358274981d6f4bff42ba52 100755 --- a/src/mesh/CMakeLists.txt +++ b/src/mesh/CMakeLists.txt @@ -4,6 +4,7 @@ ADD_SUBDIRECTORY( traits ) ADD_SUBDIRECTORY( topologies ) SET( headers tnlGrid.h + tnlGridCellNeighbours.h tnlDummyMesh.h tnlGnuplotWriter.h tnlMesh.h diff --git a/src/mesh/tnlGridCellNeighbours.h b/src/mesh/tnlGridCellNeighbours.h new file mode 100644 index 0000000000000000000000000000000000000000..fd180486ec62c90e84f7210236dd372d855da1b7 --- /dev/null +++ b/src/mesh/tnlGridCellNeighbours.h @@ -0,0 +1,116 @@ +/*************************************************************************** + tnlGridCellNeighbours.h - description + ------------------- + begin : Jul 29, 2014 + copyright : (C) 2014 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 TNLGRIDCELLNEIGHBOURS_H_ +#define TNLGRIDCELLNEIGHBOURS_H_ + +#include <mesh/tnlGrid.h> + +template< typename Grid > +class tnlGridCellNeighbours{}; + +template< typename Real, + typename Device, + typename Index > +class tnlGridCellNeighbours< tnlGrid< 1, Real, Device, Index > > +{ + public: + typedef tnlGrid< 1, Real, Device, Index > GridType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + typedef typename GridType::CoordinatesType CoordinatesType; + enum { Dimensions = GridType::Dimensions }; + + tnlGridCellNeighbours( const GridType& grid, + const CoordinatesType& cellCoordinates ); + + const IndexType& getXPredecessor() const; + + const IndexType& getXSuccessor() const; + + protected: + IndexType xPredecessor, xSuccessor; +}; + +template< typename Real, + typename Device, + typename Index > +class tnlGridCellNeighbours< tnlGrid< 2, Real, Device, Index > > +{ + public: + typedef tnlGrid< 2, Real, Device, Index > GridType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + typedef typename GridType::CoordinatesType CoordinatesType; + enum { Dimensions = GridType::Dimensions }; + + tnlGridCellNeighbours( const GridType& grid, + const CoordinatesType& cellCoordinates ); + + const IndexType& getXPredecessor() const; + + const IndexType& getXSuccessor() const; + + const IndexType& getYPredecessor() const; + + const IndexType& getYSuccessor() const; + + + protected: + IndexType xPredecessor, xSuccessor, + yPredecessor, ySuccessor; +}; + +template< typename Real, + typename Device, + typename Index > +class tnlGridCellNeighbours< tnlGrid< 2, Real, Device, Index > > +{ + public: + typedef tnlGrid< 2, Real, Device, Index > GridType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + typedef typename GridType::CoordinatesType CoordinatesType; + enum { Dimensions = GridType::Dimensions }; + + tnlGridCellNeighbours( const GridType& grid, + const CoordinatesType& cellCoordinates ); + + const IndexType& getXPredecessor() const; + + const IndexType& getXSuccessor() const; + + const IndexType& getYPredecessor() const; + + const IndexType& getYSuccessor() const; + + const IndexType& getZPredecessor() const; + + const IndexType& getZSuccessor() const; + + protected: + IndexType xPredecessor, xSuccessor, + yPredecessor, ySuccessor, + zPredecessor, zSuccessor; +}; + +#include <implementation/mesh/tnlGridCellNeighbours_impl.h> + +#endif /* TNLGRIDCELLNEIGHBOURS_H_ */