Skip to content

Commit

Permalink
Style changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
nuclearkevin committed Jan 20, 2025
1 parent 560190b commit 4f005a6
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 22 deletions.
47 changes: 29 additions & 18 deletions src/auxkernels/FDTallyGradAux.C
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,20 @@ FDTallyGradAux::validParams()
{
auto params = OpenMCVectorAuxKernel::validParams();
params.addClassDescription(
"An auxkernel which approximates tally gradients at element centroids using "
"forward finite differences.");
params.addRequiredParam<MooseEnum>("score",
getSingleTallyScoreEnum(), "The tally score this auxkernel should approximate the gradient of.");
params.addParam<unsigned int>("ext_filter_bin", 0, "The non-spatial filter bin for the tally score (with bin indices starting at 0).");
"An auxkernel which approximates tally gradients at element centroids using "
"forward finite differences.");
params.addRequiredParam<MooseEnum>(
"score",
getSingleTallyScoreEnum(),
"The tally score this auxkernel should approximate the gradient of.");
params.addParam<unsigned int>(
"ext_filter_bin",
0,
"The non-spatial filter bin for the tally score (with bin indices starting at 0).");

params.addRelationshipManager("ElementSideNeighborLayers",
Moose::RelationshipManagerType::ALGEBRAIC |
Moose::RelationshipManagerType::GEOMETRIC,
Moose::RelationshipManagerType::GEOMETRIC,
[](const InputParameters &, InputParameters & rm_params)
{ rm_params.set<unsigned short>("layers") = 2; });

Expand All @@ -51,21 +56,21 @@ FDTallyGradAux::FDTallyGradAux(const InputParameters & parameters)
_sum_y_du_dy(RealEigenVector::Zero(3))
{
if (_var.feType() != FEType(CONSTANT, MONOMIAL_VEC))
paramError(
"variable",
"FDTallyGradAux only supports CONSTANT MONOMIAL_VEC shape functions. Please "
"ensure that 'variable' is of type CONSTANT MONOMIAL_VEC.");
paramError("variable",
"FDTallyGradAux only supports CONSTANT MONOMIAL_VEC shape functions. Please "
"ensure that 'variable' is of type CONSTANT MONOMIAL_VEC.");

std::string score = getParam<MooseEnum>("score");
std::replace(score.begin(), score.end(), '_', '-');

// Error check and fetch the tally score.
const auto & all_scores = _openmc_problem->getTallyScores();
if (std::find(all_scores.begin(), all_scores.end(), score) == all_scores.end())
paramError("score", "The problem does not contain any score named " +
std::string(getParam<MooseEnum>("score")) +
"! Please "
"ensure that one of your [Tallies] is scoring the requested score.");
paramError("score",
"The problem does not contain any score named " +
std::string(getParam<MooseEnum>("score")) +
"! Please "
"ensure that one of your [Tallies] is scoring the requested score.");

auto score_vars = getTallyScoreVariables(score);
auto score_bins = getTallyScoreVariableValues(score);
Expand All @@ -74,11 +79,16 @@ FDTallyGradAux::FDTallyGradAux(const InputParameters & parameters)
if (_bin_index >= score_bins.size())
paramError("ext_filter_bin",
"The external filter bin provided is invalid for the number of "
"external filter bins (" + std::to_string(score_bins.size()) + ") "
"applied to " + std::string(getParam<MooseEnum>("score")) + "!");
"external filter bins (" +
std::to_string(score_bins.size()) +
") "
"applied to " +
std::string(getParam<MooseEnum>("score")) + "!");

if (score_vars[_bin_index]->feType() != FEType(CONSTANT, MONOMIAL))
paramError("score", "FDTallyGradAux only supports CONSTANT MONOMIAL shape functions for tally variables.");
paramError(
"score",
"FDTallyGradAux only supports CONSTANT MONOMIAL shape functions for tally variables.");

_tally_val = score_bins[_bin_index];
_tally_neighbor_val = neighbor_score_bins[_bin_index];
Expand Down Expand Up @@ -116,7 +126,8 @@ FDTallyGradAux::compute()

// Compute du/dy along the direction pointing towards the neighbor's centroid.
// Add to the b vector.
_sum_y_du_dy += y_prime_eig * ((*_tally_neighbor_val)[0] - (*_tally_val)[0]) / y_prime.norm_sq();
_sum_y_du_dy +=
y_prime_eig * ((*_tally_neighbor_val)[0] - (*_tally_val)[0]) / y_prime.norm_sq();
// Compute the outer product between y' and y'.T.
// Add to the A matrix.
_sum_y_y_t += y_prime_eig * y_prime_eig.transpose();
Expand Down
12 changes: 8 additions & 4 deletions src/auxkernels/OpenMCAuxKernel.C
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ OpenMCAuxKernelTempl<ComputeValueType>::getTallyScoreVariables(const std::string
{
auto vars = t->getScoreVars(score);
for (const auto & v : vars)
score_vars.emplace_back(dynamic_cast<const MooseVariableFE<Real> *>(&this->_subproblem.getVariable(this->_tid, v)));
score_vars.emplace_back(dynamic_cast<const MooseVariableFE<Real> *>(
&this->_subproblem.getVariable(this->_tid, v)));
}
}

Expand All @@ -76,7 +77,8 @@ OpenMCAuxKernelTempl<ComputeValueType>::getTallyScoreVariableValues(const std::s
auto vars = t->getScoreVars(score);
for (const auto & v : vars)
score_vars.emplace_back(
&(dynamic_cast<MooseVariableFE<Real> *>(&this->_subproblem.getVariable(this->_tid, v))->sln()));
&(dynamic_cast<MooseVariableFE<Real> *>(&this->_subproblem.getVariable(this->_tid, v))
->sln()));
}
}

Expand All @@ -88,7 +90,8 @@ OpenMCAuxKernelTempl<ComputeValueType>::getTallyScoreVariableValues(const std::s

template <typename ComputeValueType>
std::vector<const VariableValue *>
OpenMCAuxKernelTempl<ComputeValueType>::getTallyScoreNeighborVariableValues(const std::string & score)
OpenMCAuxKernelTempl<ComputeValueType>::getTallyScoreNeighborVariableValues(
const std::string & score)
{
std::vector<const VariableValue *> score_vars;
const auto & tallies = _openmc_problem->getLocalTally();
Expand All @@ -99,7 +102,8 @@ OpenMCAuxKernelTempl<ComputeValueType>::getTallyScoreNeighborVariableValues(cons
auto vars = t->getScoreVars(score);
for (const auto & v : vars)
score_vars.emplace_back(
&(dynamic_cast<MooseVariableFE<Real> *>(&this->_subproblem.getVariable(this->_tid, v))->slnNeighbor()));
&(dynamic_cast<MooseVariableFE<Real> *>(&this->_subproblem.getVariable(this->_tid, v))
->slnNeighbor()));
}
}

Expand Down

0 comments on commit 4f005a6

Please sign in to comment.