LCOV - code coverage report
Current view: top level - src/postprocessors - TensorIntegralChangePostprocessor.C (source / functions) Hit Total Coverage
Test: idaholab/swift: #92 (25e020) with base b3cd84 Lines: 16 17 94.1 %
Date: 2025-09-10 17:10:32 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://www.mooseframework.org
       3             : //*
       4             : /**********************************************************************/
       5             : /*                    DO NOT MODIFY THIS HEADER                       */
       6             : /*             Swift, a Fourier spectral solver for MOOSE             */
       7             : /*                                                                    */
       8             : /*            Copyright 2024 Battelle Energy Alliance, LLC            */
       9             : /*                        ALL RIGHTS RESERVED                         */
      10             : /**********************************************************************/
      11             : 
      12             : #include "TensorIntegralChangePostprocessor.h"
      13             : #include "DomainAction.h"
      14             : #include "TensorProblem.h"
      15             : 
      16             : registerMooseObject("SwiftApp", TensorIntegralChangePostprocessor);
      17             : 
      18             : InputParameters
      19          34 : TensorIntegralChangePostprocessor::validParams()
      20             : {
      21          34 :   InputParameters params = TensorPostprocessor::validParams();
      22          34 :   params.addClassDescription("Compute the integral over a buffer");
      23          34 :   return params;
      24           0 : }
      25             : 
      26          16 : TensorIntegralChangePostprocessor::TensorIntegralChangePostprocessor(const InputParameters & parameters)
      27          32 :   : TensorPostprocessor(parameters), _u_old(_tensor_problem.getBufferOld(getParam<TensorInputBufferName>("buffer"), 1))
      28             : {
      29          16 : }
      30             : 
      31             : void
      32         160 : TensorIntegralChangePostprocessor::execute()
      33             : {
      34             :   {
      35         160 :   if (!_u_old.empty())
      36         432 :     _integral = torch::abs(_u - _u_old[0]).sum().cpu().item<double>();
      37             :   else
      38          48 :     _integral = torch::abs(_u).sum().cpu().item<double>();
      39             : 
      40         520 :   for (const auto dim : make_range(_domain.getDim()))
      41         360 :     _integral *= _domain.getGridSpacing()(dim);
      42             :   }
      43         160 : }
      44             : 
      45             : PostprocessorValue
      46         160 : TensorIntegralChangePostprocessor::getValue() const
      47             : {
      48         160 :   return _integral;
      49             : }

Generated by: LCOV version 1.14