From a41e56ae91238fd44281a557a21dfbb5e148cfe5 Mon Sep 17 00:00:00 2001 From: Emily Boudreaux Date: Sun, 23 Feb 2025 14:11:50 -0500 Subject: [PATCH 01/15] feat(probe): added getRadius and start of ray cast solution --- src/probe/private/probe.cpp | 52 +++++++++++++++++++++++++++++++++++++ src/probe/public/probe.h | 6 +++++ 2 files changed, 58 insertions(+) diff --git a/src/probe/private/probe.cpp b/src/probe/private/probe.cpp index 6d26f66..921610c 100644 --- a/src/probe/private/probe.cpp +++ b/src/probe/private/probe.cpp @@ -3,10 +3,12 @@ #include "quill/Logger.h" #include "quill/sinks/ConsoleSink.h" #include "quill/sinks/FileSink.h" +#include "quill/LogMacros.h" #include #include #include #include +#include #include "mfem.hpp" @@ -39,6 +41,56 @@ void glVisView(mfem::GridFunction& u, mfem::Mesh& mesh, } } +double getMeshRadius(mfem::Mesh& mesh) { + int numVertices = mesh.GetNV(); // Number of vertices + double maxRadius = 0.0; + + for (int i = 0; i < numVertices; i++) { + double* vertex; + vertex = mesh.GetVertex(i); // Get vertex coordinates + + // Compute the Euclidean distance from the origin + double radius = std::sqrt(vertex[0] * vertex[0] + + vertex[1] * vertex[1] + + vertex[2] * vertex[2]); + + if (radius > maxRadius) { + maxRadius = radius; + } + } + return maxRadius; +} + +std::vector getRaySolution(mfem::GridFunction& u, mfem::Mesh& mesh, + const std::vector& rayDirection, + int numSamples) { + LogManager& logManager = LogManager::getInstance(); + quill::Logger* logger = logManager.getLogger("polyTest"); + std::vector samples; + samples.reserve(numSamples); + double x, y, z, r; + double radius = getMeshRadius(mesh); + mfem::Vector rayOrigin(3); rayOrigin = 0.0; + mfem::DenseMatrix rayPoints(3, numSamples); + + for (int i = 0; i < numSamples; i++) { + r = i * radius / numSamples; + // Let rayDirection = (theta, phi) that the ray will be cast too + x = r * std::sin(rayDirection[0]) * std::cos(rayDirection[1]); + y = r * std::sin(rayDirection[0]) * std::sin(rayDirection[1]); + z = r * std::cos(rayDirection[0]); + rayPoints(0, i) = x; + rayPoints(1, i) = y; + rayPoints(2, i) = z; + LOG_INFO(logger, "Ray point {}: ({}, {}, {})", i, x, y, z); + } + + mfem::Array elementIds; + mfem::Array ips; + mesh.FindPoints(rayPoints, elementIds, ips); + return samples; +} + LogManager::LogManager() { Config& config = Config::getInstance(); quill::Backend::start(); diff --git a/src/probe/public/probe.h b/src/probe/public/probe.h index 1ef7e09..abd19ca 100644 --- a/src/probe/public/probe.h +++ b/src/probe/public/probe.h @@ -33,6 +33,12 @@ namespace Probe { */ void glVisView(mfem::GridFunction& u, mfem::Mesh& mesh, const std::string& windowTitle = "solution"); + + double getMeshRadius(mfem::Mesh& mesh); + + std::vector getRaySolution(mfem::GridFunction& u, mfem::Mesh& mesh, + const std::vector& rayDirection, + int numSamples); /** * @brief Class to manage logging operations. From c08a40e568928a502d74408848b1ddeafce5da5e Mon Sep 17 00:00:00 2001 From: Emily Boudreaux Date: Mon, 24 Feb 2025 12:39:48 -0500 Subject: [PATCH 02/15] feat(probe): functions to get solution along ray and view solution with GLVis --- src/probe/private/probe.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/probe/private/probe.cpp b/src/probe/private/probe.cpp index 921610c..1f00e22 100644 --- a/src/probe/private/probe.cpp +++ b/src/probe/private/probe.cpp @@ -34,6 +34,8 @@ void glVisView(mfem::GridFunction& u, mfem::Mesh& mesh, if (config.get("Probe:GLVis:Visualization", true)) { std::string vishost = config.get("Probe:GLVis:Host", "localhost"); int visport = config.get("Probe:GLVis:Port", 19916); // Changed default port + std::cout << "GLVis visualization enabled. Opening GLVis window... " << std::endl; + std::cout << "Using host: " << vishost << " and port: " << visport << std::endl; mfem::socketstream sol_sock(vishost.c_str(), visport); sol_sock.precision(8); sol_sock << "solution\n" << mesh << u @@ -68,7 +70,7 @@ std::vector getRaySolution(mfem::GridFunction& u, mfem::Mesh& mesh, quill::Logger* logger = logManager.getLogger("polyTest"); std::vector samples; samples.reserve(numSamples); - double x, y, z, r; + double x, y, z, r, sampleValue; double radius = getMeshRadius(mesh); mfem::Vector rayOrigin(3); rayOrigin = 0.0; mfem::DenseMatrix rayPoints(3, numSamples); @@ -82,12 +84,23 @@ std::vector getRaySolution(mfem::GridFunction& u, mfem::Mesh& mesh, rayPoints(0, i) = x; rayPoints(1, i) = y; rayPoints(2, i) = z; - LOG_INFO(logger, "Ray point {}: ({}, {}, {})", i, x, y, z); } mfem::Array elementIds; mfem::Array ips; mesh.FindPoints(rayPoints, elementIds, ips); + for (int i = 0; i < elementIds.Size(); i++) { + int elementId = elementIds[i]; + mfem::IntegrationPoint ip = ips[i]; + + if (elementId >= 0) { // Check if the point was found in an element + sampleValue = u.GetValue(i, ip); + LOG_INFO(logger, "Sample {}: Value = {:0.2E}", i, sampleValue); + samples.push_back(sampleValue); + } else { // If the point was not found in an element + samples.push_back(0.0); + } + } return samples; } From 2d9e1d5bf6e0cce020b1491455c229c58f04ae55 Mon Sep 17 00:00:00 2001 From: Emily Boudreaux Date: Fri, 28 Feb 2025 09:47:15 -0500 Subject: [PATCH 03/15] feat(probe): vector overload for glVisView glVisView can now also be called with a vector and finite element space as opposed to just a grid function and mesh --- src/probe/meson.build | 2 +- src/probe/private/probe.cpp | 11 +++++++++++ src/probe/public/probe.h | 14 +++++++++++--- 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/src/probe/meson.build b/src/probe/meson.build index 59f951e..8d6c069 100644 --- a/src/probe/meson.build +++ b/src/probe/meson.build @@ -13,7 +13,7 @@ libprobe = static_library('probe', include_directories: include_directories('public'), cpp_args: ['-fvisibility=default'], install : true, - dependencies: [config_dep, mfem_dep, quill_dep] + dependencies: [config_dep, mfem_dep, quill_dep, warning_control_dep] ) probe_dep = declare_dependency( diff --git a/src/probe/private/probe.cpp b/src/probe/private/probe.cpp index 1f00e22..4f38045 100644 --- a/src/probe/private/probe.cpp +++ b/src/probe/private/probe.cpp @@ -15,6 +15,8 @@ #include "config.h" #include "probe.h" +#include "warning_control.h" + namespace Probe { @@ -43,6 +45,15 @@ void glVisView(mfem::GridFunction& u, mfem::Mesh& mesh, } } +void glVisView(mfem::Vector &vec, mfem::FiniteElementSpace &fes, const std::string &windowTitle) { + mfem::GridFunction gf(&fes); + + DEPRECATION_WARNING_OFF + gf.SetData(vec); + DEPRECATION_WARNING_ON + glVisView(gf, *fes.GetMesh(), windowTitle); +} + double getMeshRadius(mfem::Mesh& mesh) { int numVertices = mesh.GetNV(); // Number of vertices double maxRadius = 0.0; diff --git a/src/probe/public/probe.h b/src/probe/public/probe.h index abd19ca..af178a0 100644 --- a/src/probe/public/probe.h +++ b/src/probe/public/probe.h @@ -32,13 +32,21 @@ namespace Probe { * @param windowTitle The title of the visualization window. */ void glVisView(mfem::GridFunction& u, mfem::Mesh& mesh, - const std::string& windowTitle = "solution"); + const std::string& windowTitle = "grid function"); + + /** + * @brief Visualize a vector using GLVis. + * @param vec The vector to visualize. + * @param mesh The mesh associated with the vector. + * @param windowTitle The title of the visualization window. + */ + void glVisView(mfem::Vector &vec, mfem::FiniteElementSpace &fes, + const std::string &windowTitle = "vector"); double getMeshRadius(mfem::Mesh& mesh); std::vector getRaySolution(mfem::GridFunction& u, mfem::Mesh& mesh, - const std::vector& rayDirection, - int numSamples); + const std::vector& rayDirection, int numSamples); /** * @brief Class to manage logging operations. From 1740d0e9e23fbb85a80decc519fc2995e654dfaa Mon Sep 17 00:00:00 2001 From: Emily Boudreaux Date: Mon, 3 Mar 2025 09:55:24 -0500 Subject: [PATCH 04/15] feat(probe): default glvis keysets and vector version of glvisView glVisView function now accepts a keyset to send and has an overloaded version which takes a vector and finite element space instead of just a grid function and mesh --- src/probe/private/probe.cpp | 93 ++++++++++++++++++++++++++----------- src/probe/public/probe.h | 16 +++++-- 2 files changed, 79 insertions(+), 30 deletions(-) diff --git a/src/probe/private/probe.cpp b/src/probe/private/probe.cpp index 4f38045..b5c0d0f 100644 --- a/src/probe/private/probe.cpp +++ b/src/probe/private/probe.cpp @@ -4,11 +4,14 @@ #include "quill/sinks/ConsoleSink.h" #include "quill/sinks/FileSink.h" #include "quill/LogMacros.h" + #include #include #include #include #include +#include +#include #include "mfem.hpp" @@ -31,7 +34,7 @@ void wait(int seconds) { } void glVisView(mfem::GridFunction& u, mfem::Mesh& mesh, - const std::string& windowTitle) { + const std::string& windowTitle, const std::string& keyset) { Config& config = Config::getInstance(); if (config.get("Probe:GLVis:Visualization", true)) { std::string vishost = config.get("Probe:GLVis:Host", "localhost"); @@ -41,50 +44,56 @@ void glVisView(mfem::GridFunction& u, mfem::Mesh& mesh, mfem::socketstream sol_sock(vishost.c_str(), visport); sol_sock.precision(8); sol_sock << "solution\n" << mesh << u - << "window_title '" << windowTitle << "'\n" << std::flush; // Added title + << "window_title '" << windowTitle << "'\n"; // Added title + if (!keyset.empty()) { + sol_sock << "keys " << keyset << '\n'; + } + sol_sock << std::flush; } } -void glVisView(mfem::Vector &vec, mfem::FiniteElementSpace &fes, const std::string &windowTitle) { +void glVisView(mfem::Vector &vec, mfem::FiniteElementSpace &fes, const std::string &windowTitle, const std::string& keyset) { mfem::GridFunction gf(&fes); DEPRECATION_WARNING_OFF gf.SetData(vec); DEPRECATION_WARNING_ON - glVisView(gf, *fes.GetMesh(), windowTitle); + glVisView(gf, *fes.GetMesh(), windowTitle, keyset); } double getMeshRadius(mfem::Mesh& mesh) { - int numVertices = mesh.GetNV(); // Number of vertices - double maxRadius = 0.0; + mesh.EnsureNodes(); + const mfem::GridFunction *nodes = mesh.GetNodes(); + double *node_data = nodes->GetData(); // THIS IS KEY - for (int i = 0; i < numVertices; i++) { - double* vertex; - vertex = mesh.GetVertex(i); // Get vertex coordinates + int data_size = nodes->Size(); + double max_radius = 0.0; - // Compute the Euclidean distance from the origin - double radius = std::sqrt(vertex[0] * vertex[0] + - vertex[1] * vertex[1] + - vertex[2] * vertex[2]); - - if (radius > maxRadius) { - maxRadius = radius; - } + for (int i = 0; i < data_size; ++i) { + if (node_data[i] > max_radius) { + max_radius = node_data[i]; + } } - return maxRadius; + return max_radius; + } -std::vector getRaySolution(mfem::GridFunction& u, mfem::Mesh& mesh, +std::pair, std::vector> getRaySolution(mfem::GridFunction& u, mfem::Mesh& mesh, const std::vector& rayDirection, - int numSamples) { - LogManager& logManager = LogManager::getInstance(); - quill::Logger* logger = logManager.getLogger("polyTest"); + int numSamples, std::string filename) { + Probe::LogManager& logManager = Probe::LogManager::getInstance(); + quill::Logger* logger = logManager.getLogger("log"); + LOG_INFO(logger, "Getting ray solution..."); std::vector samples; samples.reserve(numSamples); double x, y, z, r, sampleValue; double radius = getMeshRadius(mesh); mfem::Vector rayOrigin(3); rayOrigin = 0.0; mfem::DenseMatrix rayPoints(3, numSamples); + std::vector radialPoints; + radialPoints.reserve(numSamples); + mfem::ElementTransformation* Trans = nullptr; + mfem::Vector physicalCoords; for (int i = 0; i < numSamples; i++) { r = i * radius / numSamples; @@ -101,18 +110,50 @@ std::vector getRaySolution(mfem::GridFunction& u, mfem::Mesh& mesh, mfem::Array ips; mesh.FindPoints(rayPoints, elementIds, ips); for (int i = 0; i < elementIds.Size(); i++) { + Trans = mesh.GetElementTransformation(elementIds[i]); + Trans->Transform(ips[i], physicalCoords); + double r = std::sqrt(physicalCoords[0] * physicalCoords[0] + + physicalCoords[1] * physicalCoords[1] + + physicalCoords[2] * physicalCoords[2]); + radialPoints.push_back(r); + int elementId = elementIds[i]; mfem::IntegrationPoint ip = ips[i]; - if (elementId >= 0) { // Check if the point was found in an element - sampleValue = u.GetValue(i, ip); - LOG_INFO(logger, "Sample {}: Value = {:0.2E}", i, sampleValue); + sampleValue = u.GetValue(elementId, ip); + LOG_INFO(logger, "Ray point {} found in element {} with r={:0.2f} and theta={:0.2f}", i, elementId, r, sampleValue); samples.push_back(sampleValue); } else { // If the point was not found in an element samples.push_back(0.0); } } - return samples; + std::pair, std::vector> samplesPair(radialPoints, samples); + + if (!filename.empty()) { + std::ofstream file(filename); + if (file.is_open()) { + file << "r,u\n"; + for (int i = 0; i < numSamples; i++) { + file << samplesPair.first[i] << "," << samplesPair.second[i] << "\n"; + } + file << std::endl; + file.close(); + } else { + throw(std::runtime_error("Could not open file " + filename)); + } + } + + return samplesPair; +} + +std::pair, std::vector> getRaySolution(mfem::Vector &vec, mfem::FiniteElementSpace &fes, + const std::vector& rayDirection, + int numSamples, std::string filename) { + mfem::GridFunction gf(&fes); + DEPRECATION_WARNING_OFF + gf.SetData(vec); + DEPRECATION_WARNING_ON + return getRaySolution(gf, *fes.GetMesh(), rayDirection, numSamples, filename); } LogManager::LogManager() { diff --git a/src/probe/public/probe.h b/src/probe/public/probe.h index af178a0..dfe81b8 100644 --- a/src/probe/public/probe.h +++ b/src/probe/public/probe.h @@ -6,6 +6,7 @@ #include #include #include +#include #include "mfem.hpp" #include "quill/Logger.h" @@ -30,23 +31,30 @@ namespace Probe { * @param u The GridFunction to visualize. * @param mesh The mesh associated with the GridFunction. * @param windowTitle The title of the visualization window. + * @param keyset The keyset to use for visualization. */ void glVisView(mfem::GridFunction& u, mfem::Mesh& mesh, - const std::string& windowTitle = "grid function"); + const std::string& windowTitle = "grid function", const std::string& keyset=""); /** * @brief Visualize a vector using GLVis. * @param vec The vector to visualize. * @param mesh The mesh associated with the vector. * @param windowTitle The title of the visualization window. + * @param keyset The keyset to use for visualization. */ void glVisView(mfem::Vector &vec, mfem::FiniteElementSpace &fes, - const std::string &windowTitle = "vector"); + const std::string &windowTitle = "vector", const std::string& keyset=""); + double getMeshRadius(mfem::Mesh& mesh); - std::vector getRaySolution(mfem::GridFunction& u, mfem::Mesh& mesh, - const std::vector& rayDirection, int numSamples); + std::pair, std::vector> getRaySolution(mfem::GridFunction& u, mfem::Mesh& mesh, + const std::vector& rayDirection, int numSamples, std::string filename=""); + + std::pair, std::vector> getRaySolution(mfem::Vector &vec, mfem::FiniteElementSpace &fes, + const std::vector& rayDirection, int numSamples, std::string filename=""); + /** * @brief Class to manage logging operations. From 0cf16b4965c9f54f851c15bf08b85c40b6270cea Mon Sep 17 00:00:00 2001 From: Emily Boudreaux Date: Wed, 5 Mar 2025 12:56:31 -0500 Subject: [PATCH 05/15] feat(probe): moved default glvis potions inside probe --- src/probe/private/probe.cpp | 40 +++++++++++++++++++++++++++++++------ 1 file changed, 34 insertions(+), 6 deletions(-) diff --git a/src/probe/private/probe.cpp b/src/probe/private/probe.cpp index b5c0d0f..ca30f21 100644 --- a/src/probe/private/probe.cpp +++ b/src/probe/private/probe.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include "mfem.hpp" @@ -36,18 +37,26 @@ void wait(int seconds) { void glVisView(mfem::GridFunction& u, mfem::Mesh& mesh, const std::string& windowTitle, const std::string& keyset) { Config& config = Config::getInstance(); + quill::Logger* logger = LogManager::getInstance().getLogger("log"); + std::string usedKeyset; if (config.get("Probe:GLVis:Visualization", true)) { + LOG_INFO(logger, "Visualizing solution using GLVis..."); + LOG_INFO(logger, "Window title: {}", windowTitle); + if (keyset == "") { + usedKeyset = config.get("Probe:GLVis:DefaultKeyset", ""); + } else { + usedKeyset = keyset; + } + LOG_INFO(logger, "Keyset: {}", usedKeyset); std::string vishost = config.get("Probe:GLVis:Host", "localhost"); - int visport = config.get("Probe:GLVis:Port", 19916); // Changed default port + int visport = config.get("Probe:GLVis:Port", 19916); std::cout << "GLVis visualization enabled. Opening GLVis window... " << std::endl; std::cout << "Using host: " << vishost << " and port: " << visport << std::endl; mfem::socketstream sol_sock(vishost.c_str(), visport); sol_sock.precision(8); sol_sock << "solution\n" << mesh << u - << "window_title '" << windowTitle << "'\n"; // Added title - if (!keyset.empty()) { - sol_sock << "keys " << keyset << '\n'; - } + << "window_title '" << windowTitle << + "'\n" << "keys " << usedKeyset << "\n"; sol_sock << std::flush; } } @@ -81,9 +90,28 @@ double getMeshRadius(mfem::Mesh& mesh) { std::pair, std::vector> getRaySolution(mfem::GridFunction& u, mfem::Mesh& mesh, const std::vector& rayDirection, int numSamples, std::string filename) { + Config& config = Config::getInstance(); Probe::LogManager& logManager = Probe::LogManager::getInstance(); quill::Logger* logger = logManager.getLogger("log"); LOG_INFO(logger, "Getting ray solution..."); + // Check if the directory to write to exists + // If it does not exist and MakeDir is true create it + // Otherwise throw an exception + bool makeDir = config.get("Probe:GetRaySolution:MakeDir", true); + std::filesystem::path path = filename; + + if (makeDir) { + std::filesystem::path dir = path.parent_path(); + if (!std::filesystem::exists(dir)) { + LOG_INFO(logger, "Creating directory {}", dir.string()); + std::filesystem::create_directories(dir); + } + } else { + if (!std::filesystem::exists(path.parent_path())) { + throw(std::runtime_error("Directory " + path.parent_path().string() + " does not exist")); + } + } + std::vector samples; samples.reserve(numSamples); double x, y, z, r, sampleValue; @@ -121,7 +149,7 @@ std::pair, std::vector> getRaySolution(mfem::GridFun mfem::IntegrationPoint ip = ips[i]; if (elementId >= 0) { // Check if the point was found in an element sampleValue = u.GetValue(elementId, ip); - LOG_INFO(logger, "Ray point {} found in element {} with r={:0.2f} and theta={:0.2f}", i, elementId, r, sampleValue); + LOG_DEBUG(logger, "Probe::getRaySolution() : Ray point {} found in element {} with r={:0.2f} and theta={:0.2f}", i, elementId, r, sampleValue); samples.push_back(sampleValue); } else { // If the point was not found in an element samples.push_back(0.0); From 2310b02195adee141153678626c38252b2eda726 Mon Sep 17 00:00:00 2001 From: Emily Boudreaux Date: Wed, 19 Mar 2025 13:50:01 -0400 Subject: [PATCH 06/15] docs(src): updated headers --- src/probe/meson.build | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/probe/meson.build b/src/probe/meson.build index 8d6c069..b9a3dfb 100644 --- a/src/probe/meson.build +++ b/src/probe/meson.build @@ -1,3 +1,23 @@ +# *********************************************************************** +# +# Copyright (C) 2025 -- The 4D-STAR Collaboration +# File Author: Emily Boudreaux +# Last Modified: February 28, 2025 +# +# 4DSSE is free software; you can use it and/or modify +# it under the terms and restrictions the GNU General Library Public +# License version 3 (GPLv3) as published by the Free Software Foundation. +# +# 4DSSE is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Library General Public License for more details. +# +# You should have received a copy of the GNU Library General Public License +# along with this software; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# *********************************************************************** # # Define the library probe_sources = files( 'private/probe.cpp', @@ -13,7 +33,7 @@ libprobe = static_library('probe', include_directories: include_directories('public'), cpp_args: ['-fvisibility=default'], install : true, - dependencies: [config_dep, mfem_dep, quill_dep, warning_control_dep] + dependencies: [config_dep, mfem_dep, quill_dep, macros_dep] ) probe_dep = declare_dependency( From 6338f43976d7e666a844cf555dfb536cdcf0b769 Mon Sep 17 00:00:00 2001 From: Emily Boudreaux Date: Wed, 19 Mar 2025 13:50:21 -0400 Subject: [PATCH 07/15] docs(probe): updated headers --- src/probe/meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/probe/meson.build b/src/probe/meson.build index b9a3dfb..851f3bd 100644 --- a/src/probe/meson.build +++ b/src/probe/meson.build @@ -2,7 +2,7 @@ # # Copyright (C) 2025 -- The 4D-STAR Collaboration # File Author: Emily Boudreaux -# Last Modified: February 28, 2025 +# Last Modified: March 19, 2025 # # 4DSSE is free software; you can use it and/or modify # it under the terms and restrictions the GNU General Library Public From 71bae34a49890e6679c37939973e7d18ffc55d45 Mon Sep 17 00:00:00 2001 From: Emily Boudreaux Date: Wed, 26 Mar 2025 11:41:34 -0400 Subject: [PATCH 08/15] build(probe): added macros_dep for warning control --- src/probe/meson.build | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/probe/meson.build b/src/probe/meson.build index d86377b..cf6accf 100644 --- a/src/probe/meson.build +++ b/src/probe/meson.build @@ -30,7 +30,8 @@ probe_headers = files( dependencies = [ config_dep, mfem_dep, - quill_dep + quill_dep, + macros_dep ] # Define the liblogger library so it can be linked against by other parts of the build system From 153d203f28dc093f2f7666ce7e70811245d10439 Mon Sep 17 00:00:00 2001 From: Emily Boudreaux Date: Thu, 3 Apr 2025 11:14:50 -0400 Subject: [PATCH 09/15] fix(poly): bug fixing in block form currently derivitive constraint is not working --- src/probe/public/probe.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/probe/public/probe.h b/src/probe/public/probe.h index d9157f6..dfe3427 100644 --- a/src/probe/public/probe.h +++ b/src/probe/public/probe.h @@ -25,7 +25,6 @@ #include #include #include -#include #include #include "mfem.hpp" @@ -65,7 +64,6 @@ namespace Probe { */ void glVisView(mfem::Vector &vec, mfem::FiniteElementSpace &fes, const std::string &windowTitle = "vector", const std::string& keyset=""); - double getMeshRadius(mfem::Mesh& mesh); From 4613fa50b126000af26948d010d08139e49b8291 Mon Sep 17 00:00:00 2001 From: Emily Boudreaux Date: Mon, 21 Apr 2025 08:56:45 -0400 Subject: [PATCH 10/15] docs(src): updated file headers --- src/probe/private/probe.cpp | 2 +- src/probe/public/probe.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/probe/private/probe.cpp b/src/probe/private/probe.cpp index 7b78ecb..78d512a 100644 --- a/src/probe/private/probe.cpp +++ b/src/probe/private/probe.cpp @@ -2,7 +2,7 @@ // // Copyright (C) 2025 -- The 4D-STAR Collaboration // File Author: Emily Boudreaux -// Last Modified: February 23, 2025 +// Last Modified: March 18, 2025 // // 4DSSE is free software; you can use it and/or modify // it under the terms and restrictions the GNU General Library Public diff --git a/src/probe/public/probe.h b/src/probe/public/probe.h index dfe3427..f0d2709 100644 --- a/src/probe/public/probe.h +++ b/src/probe/public/probe.h @@ -2,7 +2,7 @@ // // Copyright (C) 2025 -- The 4D-STAR Collaboration // File Author: Emily Boudreaux -// Last Modified: February 23, 2025 +// Last Modified: April 03, 2025 // // 4DSSE is free software; you can use it and/or modify // it under the terms and restrictions the GNU General Library Public From 9f2f71cfff1a2b0fde8ac91e73c52473553a6604 Mon Sep 17 00:00:00 2001 From: Emily Boudreaux Date: Wed, 30 Apr 2025 07:35:27 -0400 Subject: [PATCH 11/15] refactor(probe): removed old cout debug statements --- src/probe/private/probe.cpp | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/probe/private/probe.cpp b/src/probe/private/probe.cpp index 78d512a..3cbced4 100644 --- a/src/probe/private/probe.cpp +++ b/src/probe/private/probe.cpp @@ -58,25 +58,23 @@ void glVisView(mfem::GridFunction& u, mfem::Mesh& mesh, const std::string& windowTitle, const std::string& keyset) { Config& config = Config::getInstance(); quill::Logger* logger = LogManager::getInstance().getLogger("log"); - std::string usedKeyset; if (config.get("Probe:GLVis:Visualization", true)) { + std::string usedKeyset; LOG_INFO(logger, "Visualizing solution using GLVis..."); LOG_INFO(logger, "Window title: {}", windowTitle); - if (keyset == "") { + if (keyset.empty()) { usedKeyset = config.get("Probe:GLVis:DefaultKeyset", ""); } else { usedKeyset = keyset; } LOG_INFO(logger, "Keyset: {}", usedKeyset); - std::string vishost = config.get("Probe:GLVis:Host", "localhost"); - int visport = config.get("Probe:GLVis:Port", 19916); - std::cout << "GLVis visualization enabled. Opening GLVis window... " << std::endl; - std::cout << "Using host: " << vishost << " and port: " << visport << std::endl; + const auto vishost = config.get("Probe:GLVis:Host", "localhost"); + const auto visport = config.get("Probe:GLVis:Port", 19916); mfem::socketstream sol_sock(vishost.c_str(), visport); sol_sock.precision(8); - sol_sock << "solution\n" << mesh << u - << "window_title '" << windowTitle << - "'\n" << "keys " << usedKeyset << "\n"; + sol_sock << "mesh\n" << mesh << u + << "window_title '" << windowTitle << '\n'; + // "'\n" << "keys " << usedKeyset << "\n"; sol_sock << std::flush; } } From 406d9cf1aff4f965d95bbee61637b75c50b1547b Mon Sep 17 00:00:00 2001 From: Emily Boudreaux Date: Sun, 11 May 2025 14:40:58 -0400 Subject: [PATCH 12/15] feat(glVlisView): changed mesh socket stream to display solution --- src/probe/private/probe.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/probe/private/probe.cpp b/src/probe/private/probe.cpp index 3cbced4..23a8ea0 100644 --- a/src/probe/private/probe.cpp +++ b/src/probe/private/probe.cpp @@ -72,9 +72,9 @@ void glVisView(mfem::GridFunction& u, mfem::Mesh& mesh, const auto visport = config.get("Probe:GLVis:Port", 19916); mfem::socketstream sol_sock(vishost.c_str(), visport); sol_sock.precision(8); - sol_sock << "mesh\n" << mesh << u - << "window_title '" << windowTitle << '\n'; - // "'\n" << "keys " << usedKeyset << "\n"; + sol_sock << "solution\n" << mesh << u + << "window_title '" << windowTitle << + "'\n" << "keys " << usedKeyset << "\n"; sol_sock << std::flush; } } From 0f91347a6dd4d77cdf2d691cffb0c0ee6b4ec03a Mon Sep 17 00:00:00 2001 From: Emily Boudreaux Date: Mon, 9 Jun 2025 10:20:00 -0400 Subject: [PATCH 13/15] refactor(probe): changed from header guard to pragma once --- src/probe/public/probe.h | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/probe/public/probe.h b/src/probe/public/probe.h index f0d2709..3987a69 100644 --- a/src/probe/public/probe.h +++ b/src/probe/public/probe.h @@ -19,8 +19,7 @@ // // *********************************************************************** */ //=== Probe.h === -#ifndef PROBE_H -#define PROBE_H +#pragma once #include #include @@ -135,5 +134,4 @@ namespace Probe { const std::string& loggerName); }; -} // namespace Probe -#endif \ No newline at end of file +} // namespace Probe \ No newline at end of file From a9a94e43c448993df0cb59e9b7d12dfc12d0fb17 Mon Sep 17 00:00:00 2001 From: Emily Boudreaux Date: Tue, 10 Jun 2025 12:50:15 -0400 Subject: [PATCH 14/15] feat(probe): added minor new logging --- src/probe/private/probe.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/probe/private/probe.cpp b/src/probe/private/probe.cpp index 23a8ea0..950f08b 100644 --- a/src/probe/private/probe.cpp +++ b/src/probe/private/probe.cpp @@ -170,6 +170,7 @@ std::pair, std::vector> getRaySolution(mfem::GridFun LOG_DEBUG(logger, "Probe::getRaySolution() : Ray point {} found in element {} with r={:0.2f} and theta={:0.2f}", i, elementId, r, sampleValue); samples.push_back(sampleValue); } else { // If the point was not found in an element + LOG_INFO(logger, "Probe::getRaySolution() : Ray point {} not found", i); samples.push_back(0.0); } } From 42949d58c7f1f4ad8bffce0e46be11ffb17e8583 Mon Sep 17 00:00:00 2001 From: Emily Boudreaux Date: Wed, 11 Jun 2025 14:49:11 -0400 Subject: [PATCH 15/15] refactor(serif): refactored entire codebase into serif and sub namespaces --- src/probe/private/probe.cpp | 16 ++++++++-------- src/probe/public/probe.h | 8 ++++---- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/probe/private/probe.cpp b/src/probe/private/probe.cpp index 950f08b..111f01d 100644 --- a/src/probe/private/probe.cpp +++ b/src/probe/private/probe.cpp @@ -37,12 +37,12 @@ #include "mfem.hpp" #include "config.h" -#include "probe.h" +#include "probe.h" #include "warning_control.h" -namespace Probe { +namespace serif::probe { void pause() { std::cout << "Execution paused. Please press enter to continue..." @@ -56,7 +56,7 @@ void wait(int seconds) { void glVisView(mfem::GridFunction& u, mfem::Mesh& mesh, const std::string& windowTitle, const std::string& keyset) { - Config& config = Config::getInstance(); + serif::config::Config& config = serif::config::Config::getInstance(); quill::Logger* logger = LogManager::getInstance().getLogger("log"); if (config.get("Probe:GLVis:Visualization", true)) { std::string usedKeyset; @@ -81,7 +81,7 @@ void glVisView(mfem::GridFunction& u, mfem::Mesh& mesh, void glVisView(mfem::Vector &vec, mfem::FiniteElementSpace &fes, const std::string &windowTitle, const std::string& keyset) { mfem::GridFunction gf(&fes); - + DEPRECATION_WARNING_OFF gf.SetData(vec); DEPRECATION_WARNING_ON @@ -108,8 +108,8 @@ double getMeshRadius(mfem::Mesh& mesh) { std::pair, std::vector> getRaySolution(mfem::GridFunction& u, mfem::Mesh& mesh, const std::vector& rayDirection, int numSamples, std::string filename) { - Config& config = Config::getInstance(); - Probe::LogManager& logManager = Probe::LogManager::getInstance(); + serif::config::Config& config = serif::config::Config::getInstance(); + serif::probe::LogManager& logManager = serif::probe::LogManager::getInstance(); quill::Logger* logger = logManager.getLogger("log"); LOG_INFO(logger, "Getting ray solution..."); // Check if the directory to write to exists @@ -171,7 +171,7 @@ std::pair, std::vector> getRaySolution(mfem::GridFun samples.push_back(sampleValue); } else { // If the point was not found in an element LOG_INFO(logger, "Probe::getRaySolution() : Ray point {} not found", i); - samples.push_back(0.0); + samples.push_back(0.0); } } std::pair, std::vector> samplesPair(radialPoints, samples); @@ -204,7 +204,7 @@ std::pair, std::vector> getRaySolution(mfem::Vector } LogManager::LogManager() { - Config& config = Config::getInstance(); + serif::config::Config& config = serif::config::Config::getInstance(); quill::Backend::start(); auto CLILogger = quill::Frontend::create_or_get_logger( "root", diff --git a/src/probe/public/probe.h b/src/probe/public/probe.h index 3987a69..6b55474 100644 --- a/src/probe/public/probe.h +++ b/src/probe/public/probe.h @@ -32,7 +32,7 @@ /** * @brief The Probe namespace contains utility functions for debugging and logging. */ -namespace Probe { +namespace serif::probe { /** * @brief Pause the execution and wait for user input. */ @@ -53,7 +53,7 @@ namespace Probe { */ void glVisView(mfem::GridFunction& u, mfem::Mesh& mesh, const std::string& windowTitle = "grid function", const std::string& keyset=""); - + /** * @brief Visualize a vector using GLVis. * @param vec The vector to visualize. @@ -62,8 +62,8 @@ namespace Probe { * @param keyset The keyset to use for visualization. */ void glVisView(mfem::Vector &vec, mfem::FiniteElementSpace &fes, - const std::string &windowTitle = "vector", const std::string& keyset=""); - + const std::string &windowTitle = "vector", const std::string& keyset=""); + double getMeshRadius(mfem::Mesh& mesh); std::pair, std::vector> getRaySolution(mfem::GridFunction& u, mfem::Mesh& mesh,