Skip to content

Commit

Permalink
Merge pull request #28713 from GiudGiud/PR_fix_keps
Browse files Browse the repository at this point in the history
Fix distributed threaded NS issues
  • Loading branch information
GiudGiud authored Oct 9, 2024
2 parents 86067ab + b83f9f0 commit 45387e8
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
7 changes: 6 additions & 1 deletion framework/src/systems/SystemBase.C
Original file line number Diff line number Diff line change
Expand Up @@ -1356,7 +1356,9 @@ SystemBase::solutionState(const unsigned int state,
" was requested in ",
name(),
" but only up to state ",
_solution_states[static_cast<unsigned short>(iteration_type)].size() - 1,
(_solution_states[static_cast<unsigned short>(iteration_type)].size() == 0)
? 0
: _solution_states[static_cast<unsigned short>(iteration_type)].size() - 1,
" is available.");

const auto & solution_states = _solution_states[static_cast<unsigned short>(iteration_type)];
Expand Down Expand Up @@ -1385,6 +1387,9 @@ SystemBase::needSolutionState(const unsigned int state,
const Moose::SolutionIterationType iteration_type)
{
libmesh_parallel_only(this->comm());
mooseAssert(!Threads::in_threads,
"This routine is not thread-safe. Request the solution state before using it in "
"a threaded region.");

if (hasSolutionState(state, iteration_type))
return;
Expand Down
7 changes: 4 additions & 3 deletions framework/src/variables/MooseVariableFV.C
Original file line number Diff line number Diff line change
Expand Up @@ -461,9 +461,10 @@ MooseVariableFV<OutputType>::getElemValue(const Elem * const elem, const StateAr
// which is wrong during things like finite difference Jacobian evaluation, e.g. when PETSc
// perturbs the solution vector we feed these perturbations into the current_local_solution
// while the libMesh solution is frozen in the non-perturbed state
const auto & global_soln = (state.state == 0)
? *this->_sys.currentSolution()
: this->_sys.solutionState(state.state, state.iteration_type);
const auto & global_soln =
(state.state == 0)
? *this->_sys.currentSolution()
: std::as_const(this->_sys).solutionState(state.state, state.iteration_type);

ADReal value = global_soln(index);

Expand Down
6 changes: 3 additions & 3 deletions modules/navier_stokes/src/base/NavierStokesMethods.C
Original file line number Diff line number Diff line change
Expand Up @@ -156,24 +156,24 @@ computeSpeed(const ADRealVectorValue & velocity)

/// Bounded element maps for wall treatment
void
getWallBoundedElements(const std::vector<BoundaryName> & wall_boundary_name,
getWallBoundedElements(const std::vector<BoundaryName> & wall_boundary_names,
const FEProblemBase & fe_problem,
const SubProblem & subproblem,
const std::set<SubdomainID> & block_ids,
std::map<const Elem *, bool> & wall_bounded_map)
{

wall_bounded_map.clear();
const auto wall_boundary_ids = subproblem.mesh().getBoundaryIDs(wall_boundary_names);

for (const auto & elem : fe_problem.mesh().getMesh().active_element_ptr_range())
{
if (block_ids.find(elem->subdomain_id()) != block_ids.end())
for (const auto i_side : elem->side_index_range())
{
const auto & side_bnds = subproblem.mesh().getBoundaryIDs(elem, i_side);
for (const auto & name : wall_boundary_name)
for (const auto & wall_id : wall_boundary_ids)
{
const auto wall_id = subproblem.mesh().getBoundaryID(name);
for (const auto side_id : side_bnds)
if (side_id == wall_id)
wall_bounded_map[elem] = true;
Expand Down

0 comments on commit 45387e8

Please sign in to comment.