LCOV - code coverage report
Current view: top level - src/vectorpostprocessors - ElementValueSampler.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 419b9d Lines: 36 37 97.3 %
Date: 2025-08-08 20:01:16 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       14872 : ElementValueSampler::validParams()
      22             : {
      23       14872 :   InputParameters params = ElementVariableVectorPostprocessor::validParams();
      24             : 
      25       14872 :   params.addClassDescription("Samples values of variables on elements.");
      26             : 
      27       14872 :   params += SamplerBase::validParams();
      28             : 
      29       14872 :   return params;
      30           0 : }
      31             : 
      32         315 : ElementValueSampler::ElementValueSampler(const InputParameters & parameters)
      33         315 :   : ElementVariableVectorPostprocessor(parameters), SamplerBase(parameters, this, _communicator)
      34             : {
      35             :   // ensure that variables are 'elemental'
      36         654 :   for (unsigned int i = 0; i < _coupled_moose_vars.size(); i++)
      37             :   {
      38         351 :     if (_coupled_moose_vars[i]->isNodal())
      39           4 :       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         347 :     SamplerBase::checkForStandardFieldVariableType(_coupled_moose_vars[i]);
      45             :   }
      46         303 :   std::vector<std::string> var_names(_coupled_moose_vars.size());
      47         303 :   _values.resize(_coupled_moose_vars.size());
      48             : 
      49         642 :   for (unsigned int i = 0; i < _coupled_moose_vars.size(); i++)
      50         339 :     var_names[i] = _coupled_moose_vars[i]->name();
      51             : 
      52             :   // Initialize the data structures in SamplerBase
      53         303 :   SamplerBase::setupVariables(var_names);
      54         303 : }
      55             : 
      56             : void
      57         441 : ElementValueSampler::initialize()
      58             : {
      59         441 :   SamplerBase::initialize();
      60         441 : }
      61             : 
      62             : void
      63       80218 : ElementValueSampler::execute()
      64             : {
      65       80218 :   unsigned int i_fe = 0, i_fv = 0;
      66      160580 :   for (unsigned int i = 0; i < _coupled_moose_vars.size(); i++)
      67       80362 :     if (_coupled_moose_vars[i]->isFV())
      68        2644 :       _values[i] = _coupled_standard_fv_moose_vars[i_fv++]->getElementalValue(_current_elem);
      69             :     else
      70       77718 :       _values[i] = _coupled_standard_moose_vars[i_fe++]->getElementalValue(_current_elem);
      71             : 
      72       80218 :   SamplerBase::addSample(_current_elem->vertex_average(), _current_elem->id(), _values);
      73       80218 : }
      74             : 
      75             : void
      76         406 : ElementValueSampler::finalize()
      77             : {
      78         406 :   SamplerBase::finalize();
      79         406 : }
      80             : 
      81             : void
      82          35 : ElementValueSampler::threadJoin(const UserObject & y)
      83             : {
      84          35 :   const auto & vpp = static_cast<const ElementValueSampler &>(y);
      85             : 
      86          35 :   SamplerBase::threadJoin(vpp);
      87          35 : }

Generated by: LCOV version 1.14