LCOV - code coverage report
Current view: top level - src/postprocessors - ElementAverageMaterialProperty.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: #32971 (54bef8) with base c6cf66 Lines: 26 27 96.3 %
Date: 2026-05-29 20:35:17 Functions: 14 14 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 "ElementAverageMaterialProperty.h"
      11             : 
      12             : registerMooseObject("MooseApp", ElementAverageMaterialProperty);
      13             : registerMooseObject("MooseApp", ADElementAverageMaterialProperty);
      14             : 
      15             : template <bool is_ad>
      16             : InputParameters
      17        6539 : ElementAverageMaterialPropertyTempl<is_ad>::validParams()
      18             : {
      19        6539 :   InputParameters params = ElementIntegralMaterialPropertyTempl<is_ad>::validParams();
      20        6539 :   params.addClassDescription("Computes the average of a material property over a volume.");
      21        6539 :   return params;
      22           0 : }
      23             : 
      24             : template <bool is_ad>
      25         219 : ElementAverageMaterialPropertyTempl<is_ad>::ElementAverageMaterialPropertyTempl(
      26             :     const InputParameters & parameters)
      27         219 :   : ElementIntegralMaterialPropertyTempl<is_ad>(parameters), _volume(0.0)
      28             : {
      29         219 : }
      30             : 
      31             : template <bool is_ad>
      32             : void
      33         581 : ElementAverageMaterialPropertyTempl<is_ad>::initialize()
      34             : {
      35         581 :   ElementIntegralMaterialPropertyTempl<is_ad>::initialize();
      36             : 
      37         581 :   _volume = 0.0;
      38         581 : }
      39             : 
      40             : template <bool is_ad>
      41             : void
      42        2018 : ElementAverageMaterialPropertyTempl<is_ad>::execute()
      43             : {
      44        2018 :   ElementIntegralMaterialPropertyTempl<is_ad>::execute();
      45             : 
      46        2018 :   _volume += this->_current_elem_volume;
      47        2018 : }
      48             : 
      49             : template <bool is_ad>
      50             : Real
      51         533 : ElementAverageMaterialPropertyTempl<is_ad>::getValue() const
      52             : {
      53         533 :   return _integral_value / _volume;
      54             : }
      55             : 
      56             : template <bool is_ad>
      57             : void
      58         533 : ElementAverageMaterialPropertyTempl<is_ad>::finalize()
      59             : {
      60         533 :   ElementIntegralMaterialPropertyTempl<is_ad>::gatherSum(_volume);
      61         533 :   ElementIntegralMaterialPropertyTempl<is_ad>::gatherSum(_integral_value);
      62         533 : }
      63             : 
      64             : template <bool is_ad>
      65             : void
      66          48 : ElementAverageMaterialPropertyTempl<is_ad>::threadJoin(const UserObject & y)
      67             : {
      68          48 :   ElementIntegralMaterialPropertyTempl<is_ad>::threadJoin(y);
      69             : 
      70          48 :   const auto & pps = static_cast<const ElementAverageMaterialPropertyTempl<is_ad> &>(y);
      71          48 :   _volume += pps._volume;
      72          48 : }
      73             : 
      74             : template class ElementAverageMaterialPropertyTempl<false>;
      75             : template class ElementAverageMaterialPropertyTempl<true>;

Generated by: LCOV version 1.14