Skip to content

Commit

Permalink
Fix and test AuxKernel support (idaholab#22563)
Browse files Browse the repository at this point in the history
  • Loading branch information
dschwen committed Mar 7, 2023
1 parent 65be7e5 commit e285c68
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 7 deletions.
5 changes: 2 additions & 3 deletions framework/src/loops/ComputeElemAuxVarsThread.C
Original file line number Diff line number Diff line change
Expand Up @@ -125,15 +125,14 @@ ComputeElemAuxVarsThread<AuxKernelType>::onElement(const Elem * elem)
Threads::spin_mutex::scoped_lock lock(writable_variable_mutex);
for (auto * var : aux->getWritableCoupledVariables())
{
std::cerr << aux->name() << " var " << var->name() << '\n';
// insert into the global solution vector
var->insert(_aux_sys.solution());
var->prepareAux();
}

// make solution values available for dependent AuxKernels
// aux->variable().insert(_aux_sys.solution());
// aux->variable().prepareAux();
aux->variable().insert(_aux_sys.solution());
aux->variable().prepareAux();
_fe_problem.reinitElem(elem, _tid);
}
}
Expand Down
2 changes: 2 additions & 0 deletions framework/src/loops/ComputeNodalAuxVarsThread.C
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ ComputeNodalAuxVarsThread<AuxKernelType>::onNode(ConstNodeRange::const_iterator
}

// make solution values available for dependent AuxKernels
aux->variable().insert(_aux_sys.solution());
aux->variable().prepareAux();
_fe_problem.reinitNode(node, _tid);
}
}
Expand Down
2 changes: 2 additions & 0 deletions test/include/auxkernels/MultipleUpdateElemAux.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,6 @@ class MultipleUpdateElemAux : public AuxKernel

unsigned int _n_vars;
std::vector<MooseVariable *> _vars;

const bool _use_compute_value;
};
14 changes: 10 additions & 4 deletions test/src/auxkernels/MultipleUpdateElemAux.C
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,14 @@ MultipleUpdateElemAux::validParams()
InputParameters params = AuxKernel::validParams();
params.addRequiredCoupledVar("vars",
"Coupled variables that will be written to by the test object.");
params.addParam<bool>("use_compute_value", false, "Use computeValue() instead of setNodalValue");
return params;
}

MultipleUpdateElemAux::MultipleUpdateElemAux(const InputParameters & parameters)
: AuxKernel(parameters), _n_vars(coupledComponents("vars"))
: AuxKernel(parameters),
_n_vars(coupledComponents("vars")),
_use_compute_value(getParam<bool>("use_compute_value"))
{
for (unsigned int i = 0; i < _n_vars; i++)
_vars.push_back(&writableVariable("vars", i));
Expand All @@ -39,14 +42,17 @@ MultipleUpdateElemAux::compute()
for (unsigned int i = 0; i < _n_vars; i++)
_vars[i]->setNodalValue(values[i]);

_var.setNodalValue(100.0);
if (_use_compute_value)
AuxKernel::compute();
else
_var.setNodalValue(0.0);
}

Real
MultipleUpdateElemAux::computeValue()
{
// never executed
return 100.0;
// executed if _use_compute_value == true
return 0.0;
}

void
Expand Down
8 changes: 8 additions & 0 deletions test/tests/auxkernels/nodal_aux_var/tests
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@
requirement = "The MOOSE auxiliary system shall be capable of updating multiple elemental "
"auxiliary variables within a single AuxKernel object."
[]
[multi_update_elem_test_coupled_value]
type = 'Exodiff'
input = 'multi_update_elem_var_test.i'
cli_args = 'AuxKernels/all/use_compute_value=true'
exodiff = 'out_multi_elem_var.e'
requirement = "The MOOSE auxiliary system shall be capable of updating multiple elemental "
"auxiliary variables within a single AuxKernel object."
[]

[ts_test]
type = 'Exodiff'
Expand Down

0 comments on commit e285c68

Please sign in to comment.