From 1aaa4e3ed2712f1fb2f3ac3679b714e70ed324b6 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Wed, 27 Mar 2019 14:43:44 +0100 Subject: [PATCH] ENH: add min/max method to PDRblock::location (#1216) - grid(i,j,k) method for returning the grid point at an i-j-k location --- src/mesh/blockMesh/PDRblockMesh/PDRblock.H | 12 +++++++ src/mesh/blockMesh/PDRblockMesh/PDRblockI.H | 35 +++++++++++++++++++++ 2 files changed, 47 insertions(+) diff --git a/src/mesh/blockMesh/PDRblockMesh/PDRblock.H b/src/mesh/blockMesh/PDRblockMesh/PDRblock.H index 91e16b66e2..5f85f21ca9 100644 --- a/src/mesh/blockMesh/PDRblockMesh/PDRblock.H +++ b/src/mesh/blockMesh/PDRblockMesh/PDRblock.H @@ -110,6 +110,12 @@ public: //- True if the location is within the range inline bool contains(const scalar p) const; + //- The first() value is considered the min value. + inline const scalar& min() const; + + //- The last() value is considered the max value. + inline const scalar& max() const; + //- Mid-point location, zero for an empty list. inline scalar centre() const; @@ -305,6 +311,12 @@ public: //- Cell dimensions at i,j,k position. inline vector span(const labelVector& ijk) const; + //- Grid point at i,j,k position. + inline point grid(const label i, const label j, const label k) const; + + //- Grid point at i,j,k position. + inline point grid(const labelVector& ijk) const; + //- Cell centre at i,j,k position. inline point C(const label i, const label j, const label k) const; diff --git a/src/mesh/blockMesh/PDRblockMesh/PDRblockI.H b/src/mesh/blockMesh/PDRblockMesh/PDRblockI.H index a624ee68a6..7a04ce09ea 100644 --- a/src/mesh/blockMesh/PDRblockMesh/PDRblockI.H +++ b/src/mesh/blockMesh/PDRblockMesh/PDRblockI.H @@ -62,6 +62,18 @@ inline bool Foam::PDRblock::location::contains(const scalar p) const } +inline const Foam::scalar& Foam::PDRblock::location::min() const +{ + return scalarList::empty() ? pTraits::rootMax : first(); +} + + +inline const Foam::scalar& Foam::PDRblock::location::max() const +{ + return scalarList::empty() ? pTraits::rootMin : last(); +} + + inline Foam::scalar Foam::PDRblock::location::centre() const { return scalarList::empty() ? 0 : (0.5*first() + 0.5*last()); @@ -206,6 +218,29 @@ inline Foam::vector Foam::PDRblock::span(const labelVector& ijk) const } +inline Foam::point Foam::PDRblock::grid +( + const label i, + const label j, + const label k +) const +{ + return point(grid_.x()[i], grid_.y()[j], grid_.z()[k]); +} + + +inline Foam::point Foam::PDRblock::grid(const labelVector& ijk) const +{ + return + point + ( + grid_.x()[ijk.x()], + grid_.y()[ijk.y()], + grid_.z()[ijk.z()] + ); +} + + inline Foam::point Foam::PDRblock::C ( const label i,