From 809a6a23efce62f9541adbcd0a25592d14eb3603 Mon Sep 17 00:00:00 2001 From: Tomas Oberhuber <tomas.oberhuber@fjfi.cvut.cz> Date: Tue, 29 Jul 2014 21:02:17 +0200 Subject: [PATCH] Implementing tnlGridCellNeighbours. --- src/implementation/mesh/CMakeLists.txt | 1 + .../mesh/tnlGridCellNeighbours_impl.h | 110 +++++++++++++++++ src/mesh/CMakeLists.txt | 1 + src/mesh/tnlGridCellNeighbours.h | 116 ++++++++++++++++++ 4 files changed, 228 insertions(+) create mode 100644 src/implementation/mesh/tnlGridCellNeighbours_impl.h create mode 100644 src/mesh/tnlGridCellNeighbours.h diff --git a/src/implementation/mesh/CMakeLists.txt b/src/implementation/mesh/CMakeLists.txt index 5a46422a51..9d5f057879 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 0000000000..b91f082976 --- /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 1a55833a80..afc30628d3 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 0000000000..fd180486ec --- /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_ */ -- GitLab