From d350b4f3424572a63d734afc8fa5f53983e2e714 Mon Sep 17 00:00:00 2001 From: Jaron Kent-Dobias Date: Wed, 20 Nov 2019 13:09:40 -0500 Subject: automated a field class --- src/measurements.hpp | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'src/measurements.hpp') diff --git a/src/measurements.hpp b/src/measurements.hpp index 7bc8137..18b2e8e 100644 --- a/src/measurements.hpp +++ b/src/measurements.hpp @@ -12,6 +12,24 @@ #include "analysis_tools.hpp" +class RealField { + public: + coordinate L; + std::array M; + std::vector N; + std::vector F; + + RealField(coordinate L, std::array M) : L(L), M(M), N(M[0] * M[1], 0), F(M[0] * M[1], 0.0) {} + + void add(coordinate r, double x) { + unsigned ind = (unsigned)floor(M[1] * (r.y / L.y)) + M[1] * + (unsigned)floor(M[0] * (r.x / L.x)); + N[ind]++; + F[ind] += x; + } + +}; + class ma : public hooks { // need: // - interface for turning on and off specific measurements @@ -55,8 +73,7 @@ class ma : public hooks { std::vector cq; std::list> aG; - std::vector cS; - std::vector NS; + RealField fS; std::vector sp; ClusterTree last_clusters; -- cgit v1.2.3-70-g09d2