From 78e21395077a0a51175f286a89d5b003f33139d0 Mon Sep 17 00:00:00 2001 From: "Joshua E. Hansel" Date: Fri, 7 Apr 2023 10:55:21 -0500 Subject: [PATCH] Generalized some NS objects to allow for NS component Refs #23794 --- .../materials/PINSFVSpeedFunctorMaterial.C | 4 +- .../userobjects/INSFVRhieChowInterpolator.C | 49 +++++++++++++++++-- .../tests/finite_volume/ins/exceptions/tests | 2 +- 3 files changed, 49 insertions(+), 6 deletions(-) diff --git a/modules/navier_stokes/src/materials/PINSFVSpeedFunctorMaterial.C b/modules/navier_stokes/src/materials/PINSFVSpeedFunctorMaterial.C index cfdda58ea779..aeef39f1cf51 100644 --- a/modules/navier_stokes/src/materials/PINSFVSpeedFunctorMaterial.C +++ b/modules/navier_stokes/src/materials/PINSFVSpeedFunctorMaterial.C @@ -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(NS::velocity, diff --git a/modules/navier_stokes/src/userobjects/INSFVRhieChowInterpolator.C b/modules/navier_stokes/src/userobjects/INSFVRhieChowInterpolator.C index 24cdb6fe92ad..310d91ab4af6 100644 --- a/modules/navier_stokes/src/userobjects/INSFVRhieChowInterpolator.C +++ b/modules/navier_stokes/src/userobjects/INSFVRhieChowInterpolator.C @@ -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( &UserObject::_subproblem.getVariable(0, getParam(NS::pressure)))), @@ -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 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 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 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); diff --git a/modules/navier_stokes/test/tests/finite_volume/ins/exceptions/tests b/modules/navier_stokes/test/tests/finite_volume/ins/exceptions/tests index 7e47b34c2bd4..cd4dc689e873 100644 --- a/modules/navier_stokes/test/tests/finite_volume/ins/exceptions/tests +++ b/modules/navier_stokes/test/tests/finite_volume/ins/exceptions/tests @@ -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.' [] []