From 25e7f557a0a12de78e5b67ae29b20c6a4995a6aa Mon Sep 17 00:00:00 2001 From: Guillaume Giudicelli Date: Thu, 9 Jan 2025 08:51:04 -0700 Subject: [PATCH] Add a clean error on adding components with a regular / mesh generated mesh closes #29667 --- .../src/actions/AddComponentAction.C | 7 +++ .../tests/misc/mesh_block_interaction/test.i | 54 +++++++++++++++++++ .../tests/misc/mesh_block_interaction/tests | 10 ++++ 3 files changed, 71 insertions(+) create mode 100644 modules/thermal_hydraulics/test/tests/misc/mesh_block_interaction/test.i create mode 100644 modules/thermal_hydraulics/test/tests/misc/mesh_block_interaction/tests diff --git a/modules/thermal_hydraulics/src/actions/AddComponentAction.C b/modules/thermal_hydraulics/src/actions/AddComponentAction.C index 5304db47cf29..215eaeea6663 100644 --- a/modules/thermal_hydraulics/src/actions/AddComponentAction.C +++ b/modules/thermal_hydraulics/src/actions/AddComponentAction.C @@ -9,6 +9,7 @@ #include "AddComponentAction.h" #include "THMProblem.h" +#include "THMMesh.h" registerMooseAction("ThermalHydraulicsApp", AddComponentAction, "THM:add_component"); @@ -29,6 +30,12 @@ AddComponentAction::AddComponentAction(const InputParameters & params) void AddComponentAction::act() { + // Error if using an unsupported mesh type, as most components cannot handle working with a + // regular MooseMesh instead of a THM mesh + if (!dynamic_cast(_mesh.get())) + mooseError("The Components block cannot be used to add a Component in conjunction with the " + "Mesh block at this time"); + if (!_group) { THMProblem * thm_problem = dynamic_cast(_problem.get()); diff --git a/modules/thermal_hydraulics/test/tests/misc/mesh_block_interaction/test.i b/modules/thermal_hydraulics/test/tests/misc/mesh_block_interaction/test.i new file mode 100644 index 000000000000..689ffa74f368 --- /dev/null +++ b/modules/thermal_hydraulics/test/tests/misc/mesh_block_interaction/test.i @@ -0,0 +1,54 @@ +[Mesh] + type = GeneratedMesh + dim = 1 + nx = 1 +[] + +[Variables] + [u] + [] +[] + +[Kernels] + [diff] + type = CoefDiffusion + variable = u + coef = 0.1 + [] + [time] + type = TimeDerivative + variable = u + [] +[] + +[Components] + [inlet] + type = InletMassFlowRateTemperature1Phase + input = 'iwst_pipe_1:in' + m_dot = 1 + T = 100 + [] + + [iwst_pipe_1] + type = FlowChannel1Phase + position = '0 0 0' + orientation = '0 1 0' + length = 10 + n_elems = 15 + A = 1 + D_h = 1 + [] + + [outlet] + type = Outlet1Phase + input = 'iwst_pipe_1:out' + p = 1e5 + [] +[] + +[Executioner] + type = Transient + dt = 0.1 + num_steps = 10 + abort_on_solve_fail = true +[] diff --git a/modules/thermal_hydraulics/test/tests/misc/mesh_block_interaction/tests b/modules/thermal_hydraulics/test/tests/misc/mesh_block_interaction/tests new file mode 100644 index 000000000000..1925b12195ab --- /dev/null +++ b/modules/thermal_hydraulics/test/tests/misc/mesh_block_interaction/tests @@ -0,0 +1,10 @@ +[Tests] + issues = '#29667' + design = 'THMMesh.md' + [no_components_and_mesh] + type = 'RunException' + input = 'test.i' + requirement = 'The system shall error if using both a regular mesh, usually created in the Mesh syntax, and components, usually created in the Components syntax.' + expect_err = "The Components block cannot be used to add a Component in conjunction with the Mesh block at this time" + [] +[]