LCOV - code coverage report
Current view: top level - src/utils - ResidualAccumulator.C (source / functions) Hit Total Coverage
Test: idaholab/salamander: 762d38 Lines: 23 25 92.0 %
Date: 2025-07-22 20:51:44 Functions: 4 4 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //* This file is part of SALAMANDER: Software for Advanced Large-scale Analysis of MAgnetic confinement for Numerical Design, Engineering & Research,
       2             : //* A multiphysics application for modeling plasma facing components
       3             : //* https://github.com/idaholab/salamander
       4             : //* https://mooseframework.inl.gov/salamander
       5             : //*
       6             : //* SALAMANDER is powered by the MOOSE Framework
       7             : //* https://www.mooseframework.inl.gov
       8             : //*
       9             : //* Licensed under LGPL 2.1, please see LICENSE for details
      10             : //* https://www.gnu.org/licenses/lgpl-2.1.html
      11             : //*
      12             : //* Copyright 2025, Battelle Energy Alliance, LLC
      13             : //* ALL RIGHTS RESERVED
      14             : //*
      15             : 
      16             : #include "ResidualAccumulator.h"
      17             : 
      18             : #include "FEProblemBase.h"
      19             : #include "MooseVariableFE.h"
      20             : 
      21             : namespace SALAMANDER
      22             : {
      23        1452 : ResidualAccumulator::ResidualAccumulator(FEProblemBase & problem,
      24             :                                          const MooseObject * const object,
      25             :                                          const NonlinearVariableName & variable,
      26        1452 :                                          const unsigned int nl_sys_num)
      27             :   : AccumulatorBase(problem),
      28             :     TaggingInterface(object),
      29        1452 :     _var(dynamic_cast<MooseVariableField<Real> &>(_problem.getVariable(
      30           0 :         _tid, variable, Moose::VarKindType::VAR_SOLVER, Moose::VarFieldType::VAR_FIELD_STANDARD))),
      31        1452 :     _assembly(_problem.assembly(_tid, nl_sys_num)),
      32        2904 :     _test(_var.phi())
      33             : {
      34        1452 :   if (!_problem.currentlyComputingResidual())
      35           0 :     mooseError("ResidualAccumulator: The residual is not currently being computed. You should only "
      36             :                "construct this object when it is.");
      37        1452 : }
      38             : 
      39             : void
      40      424432 : ResidualAccumulator::add(const Elem & elem, const Point & point, const Real & value)
      41             : {
      42      424432 :   prepare(elem);
      43             : 
      44      424432 :   _problem.reinitElemPhys(&elem, {point}, _tid);
      45      424432 :   _assembly.modifyArbitraryWeights({1});
      46             : 
      47     2031856 :   for (const auto i : index_range(_test))
      48     1607424 :     _local_re(i) -= _test[i][0] * value;
      49      424432 : }
      50             : 
      51             : void
      52       94234 : ResidualAccumulator::addCachedValues()
      53             : {
      54       94234 :   accumulateTaggedLocalResidual();
      55             : 
      56       94234 :   _problem.cacheResidual(_tid);
      57       94234 :   _problem.addCachedResidual(_tid);
      58       94234 : }
      59             : 
      60             : void
      61       94234 : ResidualAccumulator::initCachedValues()
      62             : {
      63       94234 :   _problem.prepare(&currentElem(), _tid);
      64       94234 :   prepareVectorTag(_assembly, _var.number());
      65       94234 : }
      66             : 
      67             : }

Generated by: LCOV version 1.14