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 "AccumulatorBase.h" 17 : 18 : namespace SALAMANDER 19 : { 20 1537 : AccumulatorBase::AccumulatorBase(FEProblemBase & problem) 21 1537 : : _problem(problem), _current_elem(nullptr), _finalized(false) 22 : { 23 1537 : } 24 : 25 1537 : AccumulatorBase::~AccumulatorBase() 26 : { 27 1537 : if (!_finalized) 28 1 : mooseError("AccumulatorBase was not finalized"); 29 1536 : } 30 : 31 : void 32 1536 : AccumulatorBase::finalize() 33 : { 34 : mooseAssert(!_finalized, "Already finalized"); 35 : 36 1536 : if (_current_elem) 37 1512 : addCachedValues(); 38 1536 : _current_elem = nullptr; 39 : 40 1536 : _finalized = true; 41 1536 : } 42 : 43 : const Elem & 44 96457 : AccumulatorBase::currentElem() const 45 : { 46 : mooseAssert(_current_elem, "Not set"); 47 96457 : return *_current_elem; 48 : } 49 : 50 : void 51 442904 : AccumulatorBase::prepare(const Elem & elem) 52 : { 53 : mooseAssert(!_finalized, "Already finalized"); 54 : 55 442904 : if (_current_elem != &elem) 56 : { 57 96458 : if (_current_elem) 58 94945 : addCachedValues(); 59 96458 : _current_elem = &elem; 60 96458 : initCachedValues(); 61 : } 62 442904 : } 63 : 64 : }