LCOV - code coverage report
Current view: top level - src/vectorpostprocessors - SideValueSampler.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: #32971 (54bef8) with base c6cf66 Lines: 45 47 95.7 %
Date: 2026-05-29 20:35:17 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 "SideValueSampler.h"
      11             : 
      12             : // MOOSE includes
      13             : #include "MooseVariableFE.h"
      14             : 
      15             : #include "libmesh/quadrature.h"
      16             : 
      17             : registerMooseObject("MooseApp", SideValueSampler);
      18             : 
      19             : InputParameters
      20        3355 : SideValueSampler::validParams()
      21             : {
      22        3355 :   InputParameters params = SideVectorPostprocessor::validParams();
      23        3355 :   params += SamplerBase::validParams();
      24        6710 :   params.addClassDescription("Sample variable(s) along a sideset, internal or external.");
      25       10065 :   params.addRequiredCoupledVar(
      26             :       "variable", "The names of the variables that this VectorPostprocessor operates on");
      27             : 
      28        3355 :   return params;
      29           0 : }
      30             : 
      31         152 : SideValueSampler::SideValueSampler(const InputParameters & parameters)
      32             :   : SideVectorPostprocessor(parameters),
      33             :     SamplerBase(parameters, this, _communicator),
      34         152 :     _qp_sampling(true)
      35             : {
      36         152 :   std::vector<std::string> var_names(_coupled_moose_vars.size());
      37         152 :   _values.resize(_coupled_moose_vars.size());
      38             : 
      39         430 :   for (unsigned int i = 0; i < _coupled_moose_vars.size(); i++)
      40             :   {
      41         278 :     var_names[i] = _coupled_moose_vars[i]->name();
      42         834 :     SamplerBase::checkForStandardFieldVariableType(_coupled_moose_vars[i]);
      43             :   }
      44             : 
      45         152 :   if (!_coupled_fv_moose_vars.empty())
      46             :   {
      47          22 :     const auto num_fv_vars = _coupled_fv_moose_vars.size();
      48          22 :     if (num_fv_vars != _coupled_moose_vars.size())
      49           0 :       paramError(
      50             :           "variable",
      51             :           "This object cannot accept mixed FE and FV variables, please make "
      52             :           "sure all the provided variables are either FE or FV by separating this vector "
      53             :           "postprocessor "
      54             :           "into two blocks, one for finite element and another for finite volume variables!");
      55             : 
      56          22 :     _qp_sampling = false;
      57             :   }
      58             : 
      59             :   // Initialize the data structures in SamplerBase
      60         152 :   SamplerBase::setupVariables(var_names);
      61         152 : }
      62             : 
      63             : void
      64         140 : SideValueSampler::initialize()
      65             : {
      66         140 :   SamplerBase::initialize();
      67         140 : }
      68             : 
      69             : void
      70       26548 : SideValueSampler::execute()
      71             : {
      72       26548 :   if (_qp_sampling)
      73       55232 :     for (unsigned int _qp = 0; _qp < _qrule->n_points(); _qp++)
      74             :     {
      75       58016 :       for (unsigned int i = 0; i < _coupled_moose_vars.size(); i++)
      76       29248 :         _values[i] = (dynamic_cast<MooseVariable *>(_coupled_moose_vars[i]))->sln()[_qp];
      77             : 
      78       28768 :       SamplerBase::addSample(_q_point[_qp], _current_elem->id(), _values);
      79             :     }
      80             :   else
      81             :   {
      82          84 :     getFaceInfos();
      83             : 
      84          84 :     const auto state = determineState();
      85             : 
      86         168 :     for (const auto & fi : _face_infos)
      87             :     {
      88         252 :       for (unsigned int i = 0; i < _coupled_fv_moose_vars.size(); i++)
      89             :       {
      90             :         mooseAssert(_coupled_fv_moose_vars[i]->hasFaceSide(*fi, true) ||
      91             :                         _coupled_fv_moose_vars[i]->hasFaceSide(*fi, false),
      92             :                     "Variable " + _coupled_fv_moose_vars[i]->name() +
      93             :                         " should be defined on one side of the face!");
      94             : 
      95             :         const auto * elem =
      96         168 :             _coupled_fv_moose_vars[i]->hasFaceSide(*fi, true) ? fi->elemPtr() : fi->neighborPtr();
      97             : 
      98         168 :         const auto face_arg = Moose::FaceArg(
      99         168 :             {fi, Moose::FV::LimiterType::CentralDifference, true, false, elem, nullptr});
     100         168 :         _values[i] = MetaPhysicL::raw_value((*_coupled_fv_moose_vars[i])(face_arg, state));
     101             :       }
     102             : 
     103          84 :       SamplerBase::addSample(fi->faceCentroid(), _current_elem->id(), _values);
     104             :     }
     105             :   }
     106       26548 : }
     107             : 
     108             : void
     109         130 : SideValueSampler::finalize()
     110             : {
     111         130 :   SamplerBase::finalize();
     112         130 : }
     113             : 
     114             : void
     115          10 : SideValueSampler::threadJoin(const UserObject & y)
     116             : {
     117          10 :   const auto & vpp = static_cast<const SideValueSampler &>(y);
     118             : 
     119          10 :   SamplerBase::threadJoin(vpp);
     120          10 : }

Generated by: LCOV version 1.14