LCOV - code coverage report
Current view: top level - src/vectorpostprocessors - PerProcessorRayTracingResultsVectorPostprocessor.C (source / functions) Hit Total Coverage
Test: idaholab/moose ray_tracing: #31405 (292dce) with base fef103 Lines: 120 122 98.4 %
Date: 2025-09-04 07:56:07 Functions: 5 5 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //* This file is part of the MOOSE framework
       2             : //* https://mooseframework.inl.gov
       3             : //*
       4             : //* All rights reserved, see COPYRIGHT for full restrictions
       5             : //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
       6             : //*
       7             : //* Licensed under LGPL 2.1, please see LICENSE for details
       8             : //* https://www.gnu.org/licenses/lgpl-2.1.html
       9             : 
      10             : #include "PerProcessorRayTracingResultsVectorPostprocessor.h"
      11             : 
      12             : // Local includes
      13             : #include "RayTracingStudy.h"
      14             : 
      15             : #include "TraceRay.h"
      16             : #include "ParallelRayStudy.h"
      17             : 
      18             : registerMooseObject("RayTracingApp", PerProcessorRayTracingResultsVectorPostprocessor);
      19             : 
      20             : InputParameters
      21          38 : PerProcessorRayTracingResultsVectorPostprocessor::validParams()
      22             : {
      23          38 :   InputParameters params = GeneralVectorPostprocessor::validParams();
      24             : 
      25          38 :   params.addClassDescription(
      26             :       "Accumulates ray tracing results (information about the trace) on a per-processor basis.");
      27             : 
      28          76 :   params.addRequiredParam<UserObjectName>("study", "The RayTracingStudy to get results from");
      29             : 
      30             :   const std::string result_names =
      31             :       "rays_started rays_traced chunks_traced rays_received buffers_received rays_sent "
      32             :       "buffers_sent intersections generation_time propagation_time num_probes ray_pool_created "
      33             :       "receive_ray_pool_created receive_buffer_pool_created send_buffer_pool_created face_hit "
      34             :       "vertex_hit edge_hit moved_through_neighbors backface_culling_successes "
      35             :       "backface_culling_failures intersection_calls vertex_neighbor_builds vertex_neighbor_lookups "
      36          38 :       "edge_neighbor_builds edge_neighbor_lookups point_neighbor_builds failed_traces";
      37          76 :   MultiMooseEnum results(result_names, result_names);
      38             : 
      39          76 :   params.addParam<MultiMooseEnum>("results", results, "The selection of results you want reported");
      40             : 
      41          38 :   return params;
      42          38 : }
      43             : 
      44          19 : PerProcessorRayTracingResultsVectorPostprocessor::PerProcessorRayTracingResultsVectorPostprocessor(
      45          19 :     const InputParameters & parameters)
      46             :   : GeneralVectorPostprocessor(parameters),
      47          19 :     _study(getUserObject<RayTracingStudy>("study")),
      48          38 :     _results(getParam<MultiMooseEnum>("results")),
      49          19 :     _pid(processor_id()),
      50          38 :     _pid_values(declareVector("pid"))
      51             : {
      52             :   auto num_procs = n_processors();
      53             : 
      54          19 :   _pid_values.resize(num_procs, 0);
      55             : 
      56         551 :   for (auto & result : _results)
      57             :   {
      58             :     std::string lower_result_name;
      59             : 
      60         532 :     std::transform(result.name().begin(),
      61             :                    result.name().end(),
      62             :                    std::back_inserter(lower_result_name),
      63             :                    ::tolower);
      64             : 
      65         532 :     auto id = result.id();
      66             : 
      67         532 :     _result_values[id] = &declareVector(lower_result_name);
      68             : 
      69         532 :     _result_values[id]->resize(num_procs, 0);
      70             :   }
      71          19 : }
      72             : 
      73             : void
      74          14 : PerProcessorRayTracingResultsVectorPostprocessor::initialize()
      75             : {
      76          14 : }
      77             : 
      78             : void
      79          14 : PerProcessorRayTracingResultsVectorPostprocessor::execute()
      80             : {
      81          14 :   _pid_values[_pid] = _pid;
      82             : 
      83         406 :   for (auto & result : _results)
      84             :   {
      85         392 :     switch (result)
      86             :     {
      87          14 :       case 0: // rays_started
      88          14 :         (*_result_values[0])[_pid] = _study.parallelRayStudy().localWorkStarted();
      89          14 :         break;
      90          14 :       case 1: // rays_traced
      91          14 :         (*_result_values[1])[_pid] = _study.parallelRayStudy().localWorkExecuted();
      92          14 :         break;
      93          14 :       case 2: // chunks_traced
      94          14 :         (*_result_values[2])[_pid] = _study.parallelRayStudy().localChunksExecuted();
      95          14 :         break;
      96          14 :       case 3: // rays_received
      97          14 :         (*_result_values[3])[_pid] = _study.parallelRayStudy().receiveBuffer().objectsReceived();
      98          14 :         break;
      99          14 :       case 4: // buffers_received
     100          14 :         (*_result_values[4])[_pid] = _study.parallelRayStudy().receiveBuffer().buffersReceived();
     101          14 :         break;
     102          14 :       case 5: // rays_sent
     103          14 :         (*_result_values[5])[_pid] = _study.parallelRayStudy().parallelDataSent();
     104          14 :         break;
     105          14 :       case 6: // buffers_sent
     106          14 :         (*_result_values[6])[_pid] = _study.parallelRayStudy().buffersSent();
     107          14 :         break;
     108          14 :       case 7: // intersections
     109          14 :         (*_result_values[7])[_pid] = _study.localTraceRayResult(TraceRay::INTERSECTIONS);
     110          14 :         break;
     111          14 :       case 8: // generation_time
     112          14 :         (*_result_values[8])[_pid] = _study.generationTime();
     113          14 :         break;
     114          14 :       case 9: // propagation_time
     115          14 :         (*_result_values[9])[_pid] = _study.propagationTime();
     116          14 :         break;
     117          14 :       case 10: // num_probes
     118          14 :         (*_result_values[10])[_pid] = _study.parallelRayStudy().receiveBuffer().numProbes();
     119          14 :         break;
     120          14 :       case 11: // ray_pool_created
     121          28 :         (*_result_values[11])[_pid] = _study.parallelRayStudy().poolParallelDataCreated();
     122          14 :         break;
     123          14 :       case 12: // receive_ray_pool_created
     124          14 :         (*_result_values[12])[_pid] = _study.parallelRayStudy().receiveBuffer().objectPoolCreated();
     125          14 :         break;
     126          14 :       case 13: // receive_buffer_pool_created
     127          14 :         (*_result_values[13])[_pid] = _study.parallelRayStudy().receiveBuffer().bufferPoolCreated();
     128          14 :         break;
     129          14 :       case 14: // send_buffer_pool_created
     130          14 :         (*_result_values[14])[_pid] = _study.parallelRayStudy().sendBufferPoolCreated();
     131          14 :         break;
     132          14 :       case 15: // face_hit
     133          14 :         (*_result_values[15])[_pid] = _study.localTraceRayResult(TraceRay::FACE_HITS);
     134          14 :         break;
     135          14 :       case 16: // vertex_hit
     136          14 :         (*_result_values[16])[_pid] = _study.localTraceRayResult(TraceRay::VERTEX_HITS);
     137          14 :         break;
     138          14 :       case 17: // edge_hit
     139          14 :         (*_result_values[17])[_pid] = _study.localTraceRayResult(TraceRay::EDGE_HITS);
     140          14 :         break;
     141          14 :       case 18: // moved_through_neighbors
     142          14 :         (*_result_values[18])[_pid] = _study.localTraceRayResult(TraceRay::MOVED_THROUGH_NEIGHBORS);
     143          14 :         break;
     144          14 :       case 19: // backface_culling_successes
     145          14 :         (*_result_values[19])[_pid] =
     146          14 :             _study.localTraceRayResult(TraceRay::BACKFACE_CULLING_SUCCESSES);
     147          14 :         break;
     148          14 :       case 20: // backface_culling_failures
     149          14 :         (*_result_values[20])[_pid] =
     150          14 :             _study.localTraceRayResult(TraceRay::BACKFACE_CULLING_FAILURES);
     151          14 :         break;
     152          14 :       case 21: // intersection_calls
     153          14 :         (*_result_values[21])[_pid] = _study.localTraceRayResult(TraceRay::INTERSECTION_CALLS);
     154          14 :         break;
     155          14 :       case 22: // vertex_neighbor_builds
     156          14 :         (*_result_values[22])[_pid] = _study.localTraceRayResult(TraceRay::VERTEX_NEIGHBOR_BUILDS);
     157          14 :         break;
     158          14 :       case 23: // vertex_neighbor_lookups
     159          14 :         (*_result_values[23])[_pid] = _study.localTraceRayResult(TraceRay::VERTEX_NEIGHBOR_LOOKUPS);
     160          14 :         break;
     161          14 :       case 24: // edge_neighbor_builds
     162          14 :         (*_result_values[24])[_pid] = _study.localTraceRayResult(TraceRay::EDGE_NEIGHBOR_BUILDS);
     163          14 :         break;
     164          14 :       case 25: // edge_neighbor_lookups
     165          14 :         (*_result_values[25])[_pid] = _study.localTraceRayResult(TraceRay::EDGE_NEIGHBOR_LOOKUPS);
     166          14 :         break;
     167          14 :       case 26: // point_neighbor_builds
     168          14 :         (*_result_values[26])[_pid] = _study.localTraceRayResult(TraceRay::POINT_NEIGHBOR_BUILDS);
     169          14 :         break;
     170          14 :       case 27: // failed_traces
     171          14 :         (*_result_values[27])[_pid] = _study.localTraceRayResult(TraceRay::FAILED_TRACES);
     172          14 :         break;
     173           0 :       default:
     174           0 :         mooseError("Unknown result type '",
     175             :                    result.name(),
     176             :                    "/",
     177             :                    result.id(),
     178             :                    "' in PerProcessorRayTracingResultsVectorPostprocessor ",
     179             :                    name());
     180             :     }
     181             :   }
     182          14 : }
     183             : 
     184             : void
     185          14 : PerProcessorRayTracingResultsVectorPostprocessor::finalize()
     186             : {
     187             :   // TODO: Should be able to just "gather" to proc zero - but that's not working....
     188          14 :   gatherMax(_pid_values);
     189             : 
     190         406 :   for (auto & result : _results)
     191         392 :     gatherMax(*_result_values[result.id()]);
     192          14 : }

Generated by: LCOV version 1.14