LCOV - code coverage report
Current view: top level - src/postprocessors - VectorPostprocessorComparison.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 2bf808 Lines: 27 29 93.1 %
Date: 2025-07-17 01:28:37 Functions: 5 5 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 "VectorPostprocessorComparison.h"
      11             : #include "VectorPostprocessorInterface.h"
      12             : 
      13             : registerMooseObject("MooseApp", VectorPostprocessorComparison);
      14             : 
      15             : InputParameters
      16       14361 : VectorPostprocessorComparison::validParams()
      17             : {
      18       14361 :   InputParameters params = ComparisonPostprocessor::validParams();
      19             : 
      20       14361 :   params.addRequiredParam<VectorPostprocessorName>(
      21             :       "vectorpostprocessor_a", "The first vector post-processor in the comparison");
      22       14361 :   params.addRequiredParam<VectorPostprocessorName>(
      23             :       "vectorpostprocessor_b", "The second vector post-processor in the comparison");
      24       14361 :   params.addRequiredParam<std::string>(
      25             :       "vector_name_a", "The name of the vector in the first vector post-processor to compare");
      26       14361 :   params.addRequiredParam<std::string>(
      27             :       "vector_name_b", "The name of the vector in the second vector post-processor to compare");
      28             : 
      29       14361 :   params.addClassDescription(
      30             :       "Compares two vector post-processors of equal size and produces a boolean value");
      31             : 
      32       14361 :   return params;
      33           0 : }
      34             : 
      35          48 : VectorPostprocessorComparison::VectorPostprocessorComparison(const InputParameters & parameters)
      36             :   : ComparisonPostprocessor(parameters),
      37             : 
      38          48 :     _values_a(getVectorPostprocessorValue("vectorpostprocessor_a",
      39          96 :                                           getParam<std::string>("vector_name_a"))),
      40          48 :     _values_b(getVectorPostprocessorValue("vectorpostprocessor_b",
      41          96 :                                           getParam<std::string>("vector_name_b"))),
      42             : 
      43          48 :     _comparison_value(0.0)
      44             : {
      45          48 : }
      46             : 
      47             : void
      48          44 : VectorPostprocessorComparison::initialize()
      49             : {
      50          44 :   _comparison_value = 0.0;
      51          44 : }
      52             : 
      53             : void
      54          44 : VectorPostprocessorComparison::execute()
      55             : {
      56          44 :   if (_values_a.size() != _values_b.size())
      57           0 :     mooseError("The compared vector post-processors must have the same size");
      58             : 
      59             :   // Set comparison value to "false" if comparison is false for any pair of elements
      60          44 :   bool comparison_bool = true;
      61         176 :   for (unsigned int i = 0; i < _values_a.size(); ++i)
      62         132 :     comparison_bool = comparison_bool && comparisonIsTrue(_values_a[i], _values_b[i]);
      63             : 
      64          44 :   _comparison_value = comparison_bool;
      65          44 : }
      66             : 
      67             : PostprocessorValue
      68          44 : VectorPostprocessorComparison::getValue() const
      69             : {
      70          44 :   return _comparison_value;
      71             : }

Generated by: LCOV version 1.14