LCOV - code coverage report
Current view: top level - src/postprocessors - PointValue.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 2bf808 Lines: 29 31 93.5 %
Date: 2025-07-17 01:28:37 Functions: 4 4 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 "PointValue.h"
      11             : 
      12             : // MOOSE includes
      13             : #include "Function.h"
      14             : #include "MooseMesh.h"
      15             : #include "MooseVariable.h"
      16             : #include "SubProblem.h"
      17             : 
      18             : #include "libmesh/system.h"
      19             : 
      20             : registerMooseObject("MooseApp", PointValue);
      21             : 
      22             : InputParameters
      23       15777 : PointValue::validParams()
      24             : {
      25       15777 :   InputParameters params = GeneralPostprocessor::validParams();
      26       15777 :   params.addClassDescription("Compute the value of a variable at a specified location.");
      27       15777 :   params.addRequiredParam<VariableName>(
      28             :       "variable", "The name of the variable that this postprocessor operates on.");
      29       15777 :   params.addRequiredParam<Point>("point",
      30             :                                  "The physical point where the solution will be evaluated.");
      31       15777 :   params.addClassDescription("Compute the value of a variable at a specified location");
      32       15777 :   return params;
      33           0 : }
      34             : 
      35         756 : PointValue::PointValue(const InputParameters & parameters)
      36             :   : GeneralPostprocessor(parameters),
      37        1512 :     _var_number(_subproblem
      38        2268 :                     .getVariable(_tid,
      39         756 :                                  parameters.get<VariableName>("variable"),
      40             :                                  Moose::VarKindType::VAR_ANY,
      41             :                                  Moose::VarFieldType::VAR_FIELD_STANDARD)
      42         756 :                     .number()),
      43         756 :     _system(_subproblem.getSystem(getParam<VariableName>("variable"))),
      44         756 :     _point(getParam<Point>("point")),
      45         756 :     _value(0)
      46             : {
      47         756 : }
      48             : 
      49             : void
      50        1917 : PointValue::execute()
      51             : {
      52        1917 :   _value = _system.point_value(_var_number, _point, false);
      53             : 
      54             :   /**
      55             :    * If we get exactly zero, we don't know if the locator couldn't find an element, or
      56             :    * if the solution is truly zero, more checking is needed.
      57             :    */
      58        1917 :   if (MooseUtils::absoluteFuzzyEqual(_value, 0.0))
      59             :   {
      60           4 :     auto pl = _subproblem.mesh().getPointLocator();
      61           4 :     pl->enable_out_of_mesh_mode();
      62             : 
      63           4 :     auto * elem = (*pl)(_point);
      64           4 :     auto elem_id = elem ? elem->id() : libMesh::DofObject::invalid_id;
      65           4 :     gatherMin(elem_id);
      66             : 
      67           4 :     if (elem_id == libMesh::DofObject::invalid_id)
      68           4 :       mooseError("No element located at ", _point, " in PointValue Postprocessor named: ", name());
      69           0 :   }
      70        1913 : }
      71             : 
      72             : Real
      73        1913 : PointValue::getValue() const
      74             : {
      75        1913 :   return _value;
      76             : }

Generated by: LCOV version 1.14