LCOV - code coverage report
Current view: top level - include/vectorpostprocessors - SamplerBase.h (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 2bf808 Lines: 1 1 100.0 %
Date: 2025-07-17 01:28:37 Functions: 1 2 50.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             : #pragma once
      11             : 
      12             : // MOOSE includes
      13             : #include "MooseTypes.h"
      14             : 
      15             : // Forward Declarations
      16             : class InputParameters;
      17             : class VectorPostprocessor;
      18             : 
      19             : namespace libMesh
      20             : {
      21             : class Point;
      22             : 
      23             : namespace Parallel
      24             : {
      25             : class Communicator;
      26             : }
      27             : }
      28             : 
      29             : template <typename T>
      30             : InputParameters validParams();
      31             : 
      32             : /**
      33             :  * Base class for VectorPostprocessors that need to do "sampling" of
      34             :  * values in the domain.
      35             :  */
      36             : class SamplerBase
      37             : {
      38             : public:
      39             :   static InputParameters validParams();
      40             : 
      41             :   /**
      42             :    * @param parameters The parameters for the object
      43             :    * @param vpp A pointer to the child object
      44             :    * @param comm The communicator of the child
      45             :    */
      46             :   SamplerBase(const InputParameters & parameters,
      47             :               VectorPostprocessor * vpp,
      48             :               const libMesh::Parallel::Communicator & comm);
      49        1609 :   virtual ~SamplerBase() = default;
      50             : 
      51             : protected:
      52             :   /**
      53             :    * You MUST call this in the constructor of the child class and pass down the name
      54             :    * of the variables.
      55             :    *
      56             :    * @param variable_names The names of the variables.  Note: The order of the variables sets the
      57             :    * order of the values for addSample()
      58             :    */
      59             :   void setupVariables(const std::vector<std::string> & variable_names);
      60             : 
      61             :   /**
      62             :    *  Checks whether the passed variable pointer corresponds to a regular single-valued field
      63             :    * variable
      64             :    * @param var_param_name name of the variable parameter in which the variables were passed
      65             :    * @param var_ptr pointer to the field variable
      66             :    */
      67             :   void checkForStandardFieldVariableType(const MooseVariableFieldBase * const var_ptr,
      68             :                                          const std::string & var_param_name = "variable") const;
      69             : 
      70             :   /**
      71             :    * Call this with the value of every variable at each point you want to sample at.
      72             :    * @param p The point where you took the sample
      73             :    * @param id This can either be an actual ID or a distance or anything else you want
      74             :    * @param values The value of each variable
      75             :    */
      76             :   virtual void addSample(const Point & p, const Real & id, const std::vector<Real> & values);
      77             : 
      78             :   /**
      79             :    * Initialize the datastructures.
      80             :    *
      81             :    * YOU MUST CALL THIS DURING initialize() in the child class!
      82             :    */
      83             :   virtual void initialize();
      84             : 
      85             :   /**
      86             :    * Finalize the values.
      87             :    *
      88             :    * YOU MUST CALL THIS DURING finalize() in the child class!
      89             :    */
      90             :   virtual void finalize();
      91             : 
      92             :   /**
      93             :    * Join the values.
      94             :    *
      95             :    * YOU MUST CALL THIS DURING threadJoin() in the child class!
      96             :    *
      97             :    * @param y You must cast the UserObject to your child class type first then you can pass it in
      98             :    * here.
      99             :    */
     100             :   virtual void threadJoin(const SamplerBase & y);
     101             : 
     102             :   /// The child params
     103             :   const InputParameters & _sampler_params;
     104             : 
     105             :   /// The child VectorPostprocessor
     106             :   VectorPostprocessor * _vpp;
     107             : 
     108             :   /// The communicator of the child
     109             :   const libMesh::Parallel::Communicator & _comm;
     110             : 
     111             :   /// The variable names
     112             :   std::vector<std::string> _variable_names;
     113             : 
     114             :   /// What to sort by
     115             :   const unsigned int _sort_by;
     116             : 
     117             :   /// x coordinate of the points
     118             :   VectorPostprocessorValue & _x;
     119             :   /// y coordinate of the points
     120             :   VectorPostprocessorValue & _y;
     121             :   /// x coordinate of the points
     122             :   VectorPostprocessorValue & _z;
     123             : 
     124             :   /// The node ID of each point
     125             :   VectorPostprocessorValue & _id;
     126             : 
     127             :   std::vector<VectorPostprocessorValue *> _values;
     128             : };

Generated by: LCOV version 1.14