From 32f8a323491fffbedb96b14ede2c9089992c3719 Mon Sep 17 00:00:00 2001 From: wanqing0421 Date: Tue, 13 May 2025 20:11:09 +0800 Subject: [PATCH] upload box region --- .../boxRegionPoints/boxRegionPoints.cpp | 47 +++++ .../boxRegionPoints/boxRegionPoints.hpp | 170 ++++++++++++++++++ 2 files changed, 217 insertions(+) create mode 100644 src/PostprocessData/region/regionPoints/boxRegionPoints/boxRegionPoints.cpp create mode 100644 src/PostprocessData/region/regionPoints/boxRegionPoints/boxRegionPoints.hpp diff --git a/src/PostprocessData/region/regionPoints/boxRegionPoints/boxRegionPoints.cpp b/src/PostprocessData/region/regionPoints/boxRegionPoints/boxRegionPoints.cpp new file mode 100644 index 00000000..5b5bb151 --- /dev/null +++ b/src/PostprocessData/region/regionPoints/boxRegionPoints/boxRegionPoints.cpp @@ -0,0 +1,47 @@ +#include "boxRegionPoints.hpp" +#include "fieldsDataBase.hpp" +#include "numericConstants.hpp" + +namespace pFlow::postprocessData +{ + +boxRegionPoints::boxRegionPoints +( + const dictionary &dict, + fieldsDataBase &fieldsDataBase +) +: + regionPoints(dict, fieldsDataBase), + boxRegion_(dict.subDict("boxInfo")), + volume_((boxRegion_.maxPoint().x() - boxRegion_.minPoint().x()) * (boxRegion_.maxPoint().y() - boxRegion_.minPoint().y()) * (boxRegion_.maxPoint().z() - boxRegion_.minPoint().z())), + diameter_(pow(3 * volume_ / 4.0 / Pi, 1.0 / 3.0)), + selectedPoints_("selectedPoints") +{ +} + +bool boxRegionPoints::update() +{ + const auto points = database().updatePoints(); + selectedPoints_.clear(); + for(uint32 i = 0; i < points.size(); ++i) + { + if( boxRegion_.isInside(points[i])) + { + selectedPoints_.push_back(i); + } + } + + return true; +} + +bool boxRegionPoints::write(iOstream &os) const +{ + os <<"# Single box\n"; + os <<"# min point: "<< boxRegion_.minPoint() < volumes()const override + { + return span(&volume_, 1); + } + + /** + * @brief Get the equivalent diameter of the box region + * @return A span containing the diameter of the region + */ + span eqDiameters()const override + { + return span(&diameter_, 1); + } + + /** + * @brief Get the center of the box region + * @return A span containing the center point of the region + */ + span centers()const override + { + return span(&boxRegion_.minPoint(), 1); + } + + /** + * @brief Get the indices of points within the region (const version) + * @param elem Element index (ignored as there's only one box) + * @return A span containing indices of points within the region + */ + span indices(uint32 elem)const override + { + return span(selectedPoints_.data(), selectedPoints_.size()); + } + + /** + * @brief Get the indices of points within the region (non-const version) + * @param elem Element index (ignored as there's only one box) + * @return A span containing indices of points within the region + */ + span indices(uint32 elem) override + { + return span(selectedPoints_.data(), selectedPoints_.size()); + } + + /** + * @brief Update the points selected by this region + * @return True if update was successful + */ + bool update()override; + + /** + * @brief Determine if data should be written to the same time file + * @return Always returns true + */ + bool writeToSameTimeFile()const override + { + return true; + } + + /** + * @brief Write region data to output stream + * @param os Output stream to write to + * @return True if write was successful + */ + bool write(iOstream& os)const override; + +}; + +} + +#endif // __boxRegionPoints_hpp__ \ No newline at end of file