Skip to content

Commit

Permalink
Use OpenMCBase.
Browse files Browse the repository at this point in the history
  • Loading branch information
nuclearkevin committed Jan 25, 2025
1 parent 70075db commit 2fa321f
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 48 deletions.
7 changes: 5 additions & 2 deletions include/auxkernels/FDTallyGradAux.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,18 @@

#pragma once

#include "OpenMCAuxKernel.h"
#include "AuxKernel.h"

#include "OpenMCBase.h"

/**
* A class which approximates gradients of constant monomial tallies using forward finite
* differences. The gradient computation is based on:
* K. N. Stolte and P. V. Tsvetkov (2023), Annals of Nuclear Energy, 182, 109617.
* https://doi.org/10.1016/j.anucene.2022.109617
*/
class FDTallyGradAux : public OpenMCVectorAuxKernel
class FDTallyGradAux : public VectorAuxKernel,
public OpenMCBase
{
public:
static InputParameters validParams();
Expand Down
2 changes: 1 addition & 1 deletion include/base/OpenMCBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,5 @@ class OpenMCBase
THREAD_ID t_id) const;

/// The OpenMCCellAverageProblem required by all objects which inherit from OpenMCBase.
const OpenMCCellAverageProblem * _openmc_problem;
OpenMCCellAverageProblem * _openmc_problem;
};
12 changes: 7 additions & 5 deletions src/auxkernels/FDTallyGradAux.C
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ registerMooseObject("CardinalApp", FDTallyGradAux);
InputParameters
FDTallyGradAux::validParams()
{
auto params = OpenMCVectorAuxKernel::validParams();
auto params = VectorAuxKernel::validParams();
params += OpenMCBase::validParams();
params.addClassDescription(
"An auxkernel which approximates tally gradients at element centroids using "
"forward finite differences.");
Expand All @@ -50,7 +51,8 @@ FDTallyGradAux::validParams()
}

FDTallyGradAux::FDTallyGradAux(const InputParameters & parameters)
: OpenMCVectorAuxKernel(parameters),
: VectorAuxKernel(parameters),
OpenMCBase(this, parameters),
_bin_index(getParam<unsigned int>("ext_filter_bin")),
_sum_y_y_t(RealEigenMatrix::Zero(3, 3)),
_sum_y_du_dy(RealEigenVector::Zero(3))
Expand All @@ -72,9 +74,9 @@ FDTallyGradAux::FDTallyGradAux(const InputParameters & parameters)
"! Please "
"ensure that one of your [Tallies] is scoring the requested score.");

auto score_vars = getTallyScoreVariables(score);
auto score_bins = getTallyScoreVariableValues(score);
auto neighbor_score_bins = getTallyScoreNeighborVariableValues(score);
auto score_vars = getTallyScoreVariables(score, _tid);
auto score_bins = getTallyScoreVariableValues(score, _tid);
auto neighbor_score_bins = getTallyScoreNeighborVariableValues(score, _tid);

if (_bin_index >= score_bins.size())
paramError("ext_filter_bin",
Expand Down
7 changes: 0 additions & 7 deletions test/tests/neutronics/tally_grad/finite_diff/tests
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,4 @@
mesh_mode = 'replicated'
required_objects = 'OpenMCCellAverageProblem'
[]
[wrong_problem]
type = RunException
input = 'wrong_problem.i'
requirement = 'The system shall error if the user attempts to add an FDTallyGradAux without an OpenMCCellAverageProblem.'
expect_err = "This auxkernel can only be used with problems of type 'OpenMCCellAverageProblem'!"
required_objects = 'OpenMCCellAverageProblem'
[]
[]
33 changes: 0 additions & 33 deletions test/tests/neutronics/tally_grad/finite_diff/wrong_problem.i

This file was deleted.

0 comments on commit 2fa321f

Please sign in to comment.