LCOV - code coverage report
Current view: top level - src/vectorpostprocessors - ElementValueSampler.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 3501bd Lines: 38 39 97.4 %
Date: 2025-09-04 20:01:23 Functions: 6 6 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 "ElementValueSampler.h"
      11             : 
      12             : // MOOSE includes
      13             : #include "MooseVariableFE.h"
      14             : 
      15             : // C++ includes
      16             : #include <numeric>
      17             : 
      18             : registerMooseObject("MooseApp", ElementValueSampler);
      19             : 
      20             : InputParameters
      21       14871 : ElementValueSampler::validParams()
      22             : {
      23       14871 :   InputParameters params = ElementVariableVectorPostprocessor::validParams();
      24             : 
      25       14871 :   params.addClassDescription("Samples values of variables on elements.");
      26             : 
      27       14871 :   params += SamplerBase::validParams();
      28             : 
      29       14871 :   return params;
      30           0 : }
      31             : 
      32         314 : ElementValueSampler::ElementValueSampler(const InputParameters & parameters)
      33         314 :   : ElementVariableVectorPostprocessor(parameters), SamplerBase(parameters, this, _communicator)
      34             : {
      35             :   // ensure that variables are 'elemental'
      36         662 :   for (unsigned int i = 0; i < _coupled_moose_vars.size(); i++)
      37             :   {
      38         360 :     if (_coupled_moose_vars[i]->isNodal())
      39           8 :       paramError("variable",
      40             :                  "The variable '",
      41           4 :                  _coupled_moose_vars[i]->name(),
      42             :                  "' is a nodal variable. Nodal variables can be sampled using a "
      43             :                  "'NodalValueSampler'.");
      44        1060 :     SamplerBase::checkForStandardFieldVariableType(_coupled_moose_vars[i]);
      45             :   }
      46         302 :   std::vector<std::string> var_names(_coupled_moose_vars.size());
      47         302 :   _values.resize(_coupled_moose_vars.size());
      48             : 
      49         650 :   for (unsigned int i = 0; i < _coupled_moose_vars.size(); i++)
      50         348 :     var_names[i] = _coupled_moose_vars[i]->name();
      51             : 
      52             :   // Initialize the data structures in SamplerBase
      53         302 :   SamplerBase::setupVariables(var_names);
      54         302 : }
      55             : 
      56             : void
      57         440 : ElementValueSampler::initialize()
      58             : {
      59         440 :   SamplerBase::initialize();
      60         440 : }
      61             : 
      62             : void
      63       80218 : ElementValueSampler::execute()
      64             : {
      65       80218 :   unsigned int i_fe = 0, i_fv = 0;
      66      160660 :   for (unsigned int i = 0; i < _coupled_moose_vars.size(); i++)
      67       80442 :     if (_coupled_moose_vars[i]->isFV())
      68             :     {
      69        2724 :       const auto state = determineState();
      70        2724 :       const Moose::ElemArg elem_arg = {_current_elem, /*correct_skewness*/ false};
      71        2724 :       _values[i] = MetaPhysicL::raw_value((*_coupled_fv_moose_vars[i_fv++])(elem_arg, state));
      72             :     }
      73             :     else
      74       77718 :       _values[i] = _coupled_standard_moose_vars[i_fe++]->getElementalValue(_current_elem);
      75             : 
      76       80218 :   SamplerBase::addSample(_current_elem->vertex_average(), _current_elem->id(), _values);
      77       80218 : }
      78             : 
      79             : void
      80         406 : ElementValueSampler::finalize()
      81             : {
      82         406 :   SamplerBase::finalize();
      83         406 : }
      84             : 
      85             : void
      86          34 : ElementValueSampler::threadJoin(const UserObject & y)
      87             : {
      88          34 :   const auto & vpp = static_cast<const ElementValueSampler &>(y);
      89             : 
      90          34 :   SamplerBase::threadJoin(vpp);
      91          34 : }

Generated by: LCOV version 1.14