From 83213f961b9ca2b24f6519230b0f065a13309d76 Mon Sep 17 00:00:00 2001 From: Emily Boudreaux Date: Mon, 24 Feb 2025 12:39:48 -0500 Subject: [PATCH] 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; }