Skip to content

Commit

Permalink
Generalized some NS objects to allow for NS component
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuahansel committed Apr 15, 2023
1 parent cbbac18 commit 78e2139
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 6 deletions.
Expand Up @@ -44,11 +44,11 @@ PINSFVSpeedFunctorMaterial::PINSFVSpeedFunctorMaterial(const InputParameters & p
parameters.isParamSetByUser(NS::superficial_velocity_x) +
parameters.isParamSetByUser(NS::superficial_velocity_y) +
parameters.isParamSetByUser(NS::superficial_velocity_z);
if (num_components_specified != _mesh.dimension())
if (num_components_specified != blocksMaxDimension())
mooseError("Only ",
num_components_specified,
" superficial velocity components were provided for a mesh of dimension ",
_mesh.dimension());
blocksMaxDimension());

// Interstitial velocity is needed by certain correlations
addFunctorProperty<ADRealVectorValue>(NS::velocity,
Expand Down
49 changes: 46 additions & 3 deletions modules/navier_stokes/src/userobjects/INSFVRhieChowInterpolator.C
Expand Up @@ -93,7 +93,7 @@ INSFVRhieChowInterpolator::INSFVRhieChowInterpolator(const InputParameters & par
ADFunctorInterface(this),
_moose_mesh(UserObject::_subproblem.mesh()),
_mesh(_moose_mesh.getMesh()),
_dim(_moose_mesh.dimension()),
_dim(blocksMaxDimension()),
_vel(libMesh::n_threads()),
_p(dynamic_cast<INSFVPressureVariable *>(
&UserObject::_subproblem.getVariable(0, getParam<VariableName>(NS::pressure)))),
Expand Down Expand Up @@ -134,16 +134,59 @@ INSFVRhieChowInterpolator::INSFVRhieChowInterpolator(const InputParameters & par

auto check_blocks = [this](const auto & var)
{
if (blockIDs() != var.blockIDs())
const auto & var_blocks = var.blockIDs();
const auto & uo_blocks = blockIDs();

// Error if this UO has any blocks that the variable does not
std::set<SubdomainID> uo_blocks_minus_var_blocks;
std::set_difference(
uo_blocks.begin(),
uo_blocks.end(),
var_blocks.begin(),
var_blocks.end(),
std::inserter(uo_blocks_minus_var_blocks, uo_blocks_minus_var_blocks.end()));
if (uo_blocks_minus_var_blocks.size() > 0)
mooseError("Block restriction of interpolator user object '",
this->name(),
"' (",
Moose::stringify(blocks()),
") doesn't match the block restriction of variable '",
") includes blocks not in the block restriction of variable '",
var.name(),
"' (",
Moose::stringify(var.blocks()),
")");

// Get the blocks in the variable but not this UO
std::set<SubdomainID> var_blocks_minus_uo_blocks;
std::set_difference(
var_blocks.begin(),
var_blocks.end(),
uo_blocks.begin(),
uo_blocks.end(),
std::inserter(var_blocks_minus_uo_blocks, var_blocks_minus_uo_blocks.end()));

// For each block in the variable but not this UO, error if there is connection
// to any blocks on the UO.
for (auto & block_id : var_blocks_minus_uo_blocks)
{
const auto connected_blocks = _moose_mesh.getBlockConnectedBlocks(block_id);
std::set<SubdomainID> connected_blocks_on_uo;
std::set_intersection(connected_blocks.begin(),
connected_blocks.end(),
uo_blocks.begin(),
uo_blocks.end(),
std::inserter(connected_blocks_on_uo, connected_blocks_on_uo.end()));
if (connected_blocks_on_uo.size() > 0)
mooseError("Block restriction of interpolator user object '",
this->name(),
"' (",
Moose::stringify(uo_blocks),
") doesn't match the block restriction of variable '",
var.name(),
"' (",
Moose::stringify(var_blocks),
")");
}
};

fill_container(NS::pressure, _ps);
Expand Down
Expand Up @@ -10,7 +10,7 @@
[bad_restriction]
type = RunException
input = bad-restriction.i
expect_err = "Block restriction of interpolator user object.* doesn't match the block restriction of variable"
expect_err = "Block restriction of interpolator user object.* includes blocks not in the block restriction of variable"
requirement = 'The system shall error if the interpolation object has block restriction different from the nonlinear flow variables.'
[]
[]

0 comments on commit 78e2139

Please sign in to comment.