From 8f8f6866037e90ace89b40a6e1e956528f0341af Mon Sep 17 00:00:00 2001 From: Hongyang Zhou Date: Wed, 19 Oct 2022 11:11:19 +0300 Subject: [PATCH] Add a method for extracting cell center coords --- fsgrid.hpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/fsgrid.hpp b/fsgrid.hpp index bd4a25d..bbf89a1 100644 --- a/fsgrid.hpp +++ b/fsgrid.hpp @@ -908,6 +908,22 @@ template class FsGrid : public FsGridTools{ return coords; } + /*! Get the cell-center coordinates in the global simulation space + * for the given cell. + * + * \param x local x-Coordinate, in cells + * \param y local y-Coordinate, in cells + * \param z local z-Coordinate, in cells + */ + std::array getCenterCoords(int x, int y, int z) { + std::array coords; + coords[0] = physicalGlobalStart[0] + (localStart[0]+x+0.5)*DX; + coords[1] = physicalGlobalStart[1] + (localStart[1]+y+0.5)*DY; + coords[2] = physicalGlobalStart[2] + (localStart[2]+z+0.5)*DZ; + + return coords; + } + /*! Debugging output helper function. Allows for nicely formatted printing * of grid contents. Since the grid data format is varying, the actual * printing should be done in a lambda passed to this function. Example usage