From f1d837341d7defcfefcb39eeb2775aec6960fd11 Mon Sep 17 00:00:00 2001 From: Guillaume Giudicelli Date: Mon, 2 Oct 2023 20:16:10 -0600 Subject: [PATCH 01/12] Apply parameter is useless if it does not override the default --- framework/include/utils/InputParameters.h | 4 +++- framework/src/utils/InputParameters.C | 5 +++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/framework/include/utils/InputParameters.h b/framework/include/utils/InputParameters.h index af3ccf3a103c..a550bde0b44b 100644 --- a/framework/include/utils/InputParameters.h +++ b/framework/include/utils/InputParameters.h @@ -830,11 +830,13 @@ class InputParameters : public Parameters * (1) A local parameter must exist with the same name as common parameter * (2) Common parameter must valid * (3) Local parameter must be invalid OR not have been set from its default + * (except if override_default is set) * (4) Both cannot be private */ void applyParameter(const InputParameters & common, const std::string & common_name, - bool allow_private = false); + bool allow_private = false, + bool override_default = false); // END APPLY PARAMETER METHODS /** diff --git a/framework/src/utils/InputParameters.C b/framework/src/utils/InputParameters.C index 1707468fc3b3..a9b747d49a4c 100644 --- a/framework/src/utils/InputParameters.C +++ b/framework/src/utils/InputParameters.C @@ -1019,7 +1019,8 @@ InputParameters::applyCoupledVar(const InputParameters & common, const std::stri void InputParameters::applyParameter(const InputParameters & common, const std::string & common_name, - bool allow_private) + bool allow_private, + bool override_default) { // Disable the display of deprecated message when applying common parameters, this avoids a dump // of messages @@ -1036,7 +1037,7 @@ InputParameters::applyParameter(const InputParameters & common, // Extract the properties from the common parameter const bool common_exist = common._values.find(common_name) != common._values.end(); const bool common_priv = allow_private ? false : common.isPrivate(common_name); - const bool common_valid = common.isParamValid(common_name); + const bool common_valid = common.isParamValid(common_name) || override_default; /* In order to apply a common parameter 4 statements must be satisfied * (1) A local parameter must exist with the same name as the common parameter From a644e39b668d0e58a53de397075dc529e615f21d Mon Sep 17 00:00:00 2001 From: Guillaume Giudicelli Date: Tue, 10 Oct 2023 09:37:31 -0600 Subject: [PATCH 02/12] Add a component to handle a physics definition --- .../components/FileMeshPhysicsComponent.h | 59 +++++++++++++++++++ .../src/components/FileMeshPhysicsComponent.C | 52 ++++++++++++++++ .../thermal_hydraulics/src/parser/THMSyntax.C | 3 +- 3 files changed, 112 insertions(+), 2 deletions(-) create mode 100644 modules/thermal_hydraulics/include/components/FileMeshPhysicsComponent.h create mode 100644 modules/thermal_hydraulics/src/components/FileMeshPhysicsComponent.C diff --git a/modules/thermal_hydraulics/include/components/FileMeshPhysicsComponent.h b/modules/thermal_hydraulics/include/components/FileMeshPhysicsComponent.h new file mode 100644 index 000000000000..6266e44160ee --- /dev/null +++ b/modules/thermal_hydraulics/include/components/FileMeshPhysicsComponent.h @@ -0,0 +1,59 @@ +//* This file is part of the MOOSE framework +//* https://www.mooseframework.org +//* +//* All rights reserved, see COPYRIGHT for full restrictions +//* https://github.com/idaholab/moose/blob/master/COPYRIGHT +//* +//* Licensed under LGPL 2.1, please see LICENSE for details +//* https://www.gnu.org/licenses/lgpl-2.1.html + +#pragma once + +#include "FileMeshComponent.h" + +/** + * Create a component with a single Physics object active on it + */ +class FileMeshPhysicsComponent : public FileMeshComponent +{ +public: + static InputParameters validParams(); + + FileMeshPhysicsComponent(const InputParameters & parameters); + + virtual void addRelationshipManagers(Moose::RelationshipManagerType input_rm_type) override; + // These objects are added by the Physics already + virtual void addVariables() override{}; + virtual void addMooseObjects() override{}; + +protected: + virtual void init() override; + + virtual std::vector getBlocks() const { return getSubdomainNames(); } + virtual Factory & getFactory() { return getMooseApp().getFactory(); } + virtual FEProblemBase & getProblem() { return getMooseApp().feProblem(); } + virtual const MooseMesh & getMesh() const { return constMesh(); } + // virtual void addNSNonlinearVariable(const std::string & var_type, + // const std::string & var_name, + // InputParameters & params) + // { + // getTHMProblem().addSimVariable(true, var_type, var_name, params); + // } + // virtual void addNSAuxVariable(const std::string & var_type, + // const std::string & var_name, + // InputParameters & params) + // { + // getTHMProblem().addSimVariable(false, var_type, var_name, params); + // } + // virtual void addNSInitialCondition(const std::string & type, + // const std::string & name, + // InputParameters & params) + // { + // getTHMProblem().addSimInitialCondition(type, name, params); + // } + virtual std::string prefix() const { return name() + ":"; } + +private: + /// Physics object that creates the equations on this component + std::vector _physics; +}; diff --git a/modules/thermal_hydraulics/src/components/FileMeshPhysicsComponent.C b/modules/thermal_hydraulics/src/components/FileMeshPhysicsComponent.C new file mode 100644 index 000000000000..05c96749c778 --- /dev/null +++ b/modules/thermal_hydraulics/src/components/FileMeshPhysicsComponent.C @@ -0,0 +1,52 @@ +//* This file is part of the MOOSE framework +//* https://www.mooseframework.org +//* +//* All rights reserved, see COPYRIGHT for full restrictions +//* https://github.com/idaholab/moose/blob/master/COPYRIGHT +//* +//* Licensed under LGPL 2.1, please see LICENSE for details +//* https://www.gnu.org/licenses/lgpl-2.1.html + +#include "FileMeshPhysicsComponent.h" +#include "PhysicsBase.h" + +registerMooseObject("ThermalHydraulicsApp", FileMeshPhysicsComponent); + +InputParameters +FileMeshPhysicsComponent::validParams() +{ + InputParameters params = FileMeshComponent::validParams(); + + params.addClassDescription("Component with a single physics active on it."); + params.addParam>("physics", "Physics object(s) active on the Component"); + return params; +} + +FileMeshPhysicsComponent::FileMeshPhysicsComponent(const InputParameters & parameters) + : FileMeshComponent(parameters) +{ +} + +void FileMeshPhysicsComponent::addRelationshipManagers( + Moose::RelationshipManagerType /*input_rm_type*/) +{ + // TODO: We ll just add late relationship managers + // At this point in the setup, we do not have a problem, so we cannot retrieve a Physics. We can + // send the default ghosting for the physics, but that's it. + addRelationshipManagersFromParameters(PhysicsBase::validParams()); +} + +void +FileMeshPhysicsComponent::init() +{ + FileMeshComponent::init(); + + // Before this point, we did not have a problem, so we could not retrieve the physics + for (const auto & physics_name : getParam>("physics")) + _physics.push_back(getProblem().getPhysics(physics_name)); + + for (auto physics : _physics) + { + physics->addBlocks(getSubdomainNames()); + } +} diff --git a/modules/thermal_hydraulics/src/parser/THMSyntax.C b/modules/thermal_hydraulics/src/parser/THMSyntax.C index ffc902a2cba8..b589c8999828 100644 --- a/modules/thermal_hydraulics/src/parser/THMSyntax.C +++ b/modules/thermal_hydraulics/src/parser/THMSyntax.C @@ -66,7 +66,6 @@ registerActions(Syntax & syntax) try { - syntax.addDependency("THM:add_heat_structure_material", "add_function"); syntax.addDependency("THM:output_vector_velocity", "setup_mesh"); syntax.addDependency("THM:add_closures", "setup_mesh"); syntax.addDependency("THM:init_components", "THM:output_vector_velocity"); @@ -87,7 +86,7 @@ registerActions(Syntax & syntax) syntax.addDependency("add_variable", "add_fluid_properties"); syntax.addDependency("THM:init_components", "THM:add_heat_structure_material"); syntax.addDependency("THM:init_components", "THM:add_closures"); - syntax.addDependency("THM:add_variables", "THM:init_components"); + syntax.addDependency("add_variable", "THM:init_components"); syntax.addDependency("THM:setup_output", "add_output"); syntax.addDependency("THM:add_component_moose_objects", "add_material"); syntax.addDependency("check_output", "THM:add_component_moose_objects"); From 2156ecbeb99f0bb897833dc5a1a32f32ce0d180e Mon Sep 17 00:00:00 2001 From: Guillaume Giudicelli Date: Tue, 10 Oct 2023 09:43:26 -0600 Subject: [PATCH 03/12] Add a test for adding a single physics to a single component --- .../gold/single_physics_out.e | Bin 0 -> 63628 bytes .../components/physics_component/rectangle.i | 1 + .../physics_component/single_physics.i | 109 ++++++++++++++++++ .../tests/components/physics_component/tests | 24 ++++ 4 files changed, 134 insertions(+) create mode 100644 modules/thermal_hydraulics/test/tests/components/physics_component/gold/single_physics_out.e create mode 120000 modules/thermal_hydraulics/test/tests/components/physics_component/rectangle.i create mode 100644 modules/thermal_hydraulics/test/tests/components/physics_component/single_physics.i create mode 100644 modules/thermal_hydraulics/test/tests/components/physics_component/tests diff --git a/modules/thermal_hydraulics/test/tests/components/physics_component/gold/single_physics_out.e b/modules/thermal_hydraulics/test/tests/components/physics_component/gold/single_physics_out.e new file mode 100644 index 0000000000000000000000000000000000000000..10d3414dfae4b824bc1b3c855001303449daead8 GIT binary patch literal 63628 zcmeHw349bq+I|3$TSQSjR%|W-H3$U66s(+PB1wRiWi}%6*d8)hS$|RYdjNhj+{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4VcrmY?R#UOlc-ZT;rR(3(H=Q`@w+6zzKcMzxLYerx-cqt!OcwqIud@msac<*t7m zb>Dkxn-v9Hr}w-K{E~l9Jarp5{Kr=hgTsIP?h}A3Uf3P{`>&$l*V#$mu@> zhyM^9{zGv154A<*s%5J_xL0jeIqT5N56xGP*xPc)(?1@owhn$hf90nysIAwY(6{F% ztJ?bZ)qibSM2dDqo zPY(aFiyZ#rT5|dia`=yX1Yf^*x!@b_xJYpL54EM^q$TIxvQ=&QzI*uY>#kN?migYf zuXcvovg_T4zSwh|+TuVk(8*S-w)n8N{k03vQd{il`uF`$&Q@FO?%!|t;E`$z_>b?( z6ma;DNB;*L{^QP<$uD&6T1)=OH=7od!+)Gl4*&5Va{3Q)`VYb3KLm&W5FGwPZDF4A z-iZZE&4+@|>@L3WNAtH|{o}w^e>?LxBWJhx{qPm$uOD#iJvizd^Ve65yHJ@t%>4Bd zkLl9W{%iia=HP3;d+`AH67z;f{|4^8;alZfaQKf2_kqKI_`=}uABR?f(|_zChyS>q zT=)-g;XlafKgj7n$mu^0zH8ch^5A~v{k`x1c=5mL%paco)Kl-AwZ^<><6ZWPHrAQ< zw6XU1+mIK`yWd@V^U4=Sns>v0{B7lK^KST$8*bhKe&2Ifk9z<-T>AFf_rc*m7Q6)x w|8eJ9aQcrs$l*V}Cl~$$T=)-g;XlafKgj7n$l*WKX@A(av8v=f`M&=D0V;ek9RL6T literal 0 HcmV?d00001 diff --git a/modules/thermal_hydraulics/test/tests/components/physics_component/rectangle.i b/modules/thermal_hydraulics/test/tests/components/physics_component/rectangle.i new file mode 120000 index 000000000000..6291681463ae --- /dev/null +++ b/modules/thermal_hydraulics/test/tests/components/physics_component/rectangle.i @@ -0,0 +1 @@ +../flow_component_ns/rectangle.i \ No newline at end of file diff --git a/modules/thermal_hydraulics/test/tests/components/physics_component/single_physics.i b/modules/thermal_hydraulics/test/tests/components/physics_component/single_physics.i new file mode 100644 index 000000000000..ef9bc7e2da97 --- /dev/null +++ b/modules/thermal_hydraulics/test/tests/components/physics_component/single_physics.i @@ -0,0 +1,109 @@ +# Operating conditions +u_inlet = 1 +p_outlet = 0 + +[AuxVariables] + [porosity] + type = MooseVariableFVReal + initial_condition = 0.5 + [] + [velocity_norm] + type = MooseVariableFVReal + [] +[] + +[Physics] + [flow] + type = WCNSFVFlowPhysics + compressibility = 'incompressible' + porous_medium_treatment = true + + density = 'rho' + dynamic_viscosity = 'mu' + + initial_velocity = '${u_inlet} 0 0' + initial_pressure = '${p_outlet}' + + mass_advection_interpolation = 'upwind' + momentum_advection_interpolation = 'upwind' + + inlet_boundaries = 'comp1:left' + momentum_inlet_types = 'fixed-velocity' + momentum_inlet_function = 'f1 f1' + + wall_boundaries = 'comp1:top comp1:bottom' + momentum_wall_types = 'noslip symmetry' + + outlet_boundaries = 'comp1:right' + momentum_outlet_types = 'fixed-pressure' + pressure_function = 'f1' + [] +[] + +[Functions] + [f1] + type = ConstantFunction + value = 1 + [] +[] + +[Components] + [comp1] + type = FileMeshPhysicsComponent + file = rectangle.e + position = '0 0 0' + physics = 'flow' + [] +[] + +[Materials] + [const_functor] + type = ADGenericFunctorMaterial + prop_names = 'rho mu' + prop_values = '1 1' + [] +[] + +[AuxKernels] + [speed] + type = ParsedAux + variable = 'velocity_norm' + coupled_variables = 'superficial_vel_x superficial_vel_y porosity' + expression = 'sqrt(superficial_vel_x*superficial_vel_x + superficial_vel_y*superficial_vel_y) / porosity' + [] +[] + +[Executioner] + type = Steady + solve_type = 'NEWTON' + petsc_options_iname = '-pc_type -pc_factor_shift_type -pc_factor_mat_solver_type' + petsc_options_value = 'lu NONZERO mumps' + line_search = 'none' + nl_rel_tol = 1e-12 + automatic_scaling = true + off_diagonals_in_auto_scaling = true + verbose = true + scaling_group_variables = 'superficial_vel_x superficial_vel_y' +[] + +[Debug] + show_var_residual_norms = true +[] + +# Some basic Postprocessors to examine the solution +[Postprocessors] + [inlet-p] + type = SideAverageValue + variable = pressure + boundary = 'comp1:left' + [] + [outlet-u] + type = SideAverageValue + variable = superficial_vel_x + boundary = 'comp1:right' + [] +[] + +[Outputs] + exodus = true +[] diff --git a/modules/thermal_hydraulics/test/tests/components/physics_component/tests b/modules/thermal_hydraulics/test/tests/components/physics_component/tests new file mode 100644 index 000000000000..3a393d82c9ef --- /dev/null +++ b/modules/thermal_hydraulics/test/tests/components/physics_component/tests @@ -0,0 +1,24 @@ +[Tests] + design = 'FlowComponentNS.md' + issues = '#23794' + + [generate_mesh] + type = RunApp + input = rectangle.i + recover = false # No transient, just mesh generation + cli_args = "--mesh-only rectangle.e" + requirement = 'The system shall be able to generate a simple rectangular mesh for the physics component tests.' + [] + [single_physics] + type = Exodiff + input = single_physics.i + exodiff = single_physics_out.e + abs_zero = 5e-6 + prereq = 'generate_mesh' + method = "!dbg" + installation_type = in_tree + max_parallel = 4 # https://github.com/idaholab/moose/issues/24503 + valgrind = HEAVY + requirement = 'The system shall model the porous, incompressible Navier-Stokes equations with a finite volume discretization, using a component, abstracting the flow equation definitions using the Physics system.' + [] +[] From 47ecf494dffd5466395e49885140ca84ffb2d014 Mon Sep 17 00:00:00 2001 From: Guillaume Giudicelli Date: Wed, 18 Oct 2023 15:43:11 -0600 Subject: [PATCH 04/12] Add ability for components to query AD functors --- modules/thermal_hydraulics/include/components/Component.h | 6 +++++- modules/thermal_hydraulics/src/components/Component.C | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/modules/thermal_hydraulics/include/components/Component.h b/modules/thermal_hydraulics/include/components/Component.h index 82e2fa959367..bf1489dd7c67 100644 --- a/modules/thermal_hydraulics/include/components/Component.h +++ b/modules/thermal_hydraulics/include/components/Component.h @@ -15,6 +15,7 @@ #include "InputParameterWarehouse.h" #include "LoggingInterface.h" #include "NamingInterface.h" +#include "ADFunctorInterface.h" class THMProblem; class THMMesh; @@ -23,7 +24,10 @@ class ThermalHydraulicsApp; /** * Base class for THM components */ -class Component : public THMObject, public LoggingInterface, public NamingInterface +class Component : public THMObject, + public LoggingInterface, + public NamingInterface, + public ADFunctorInterface { public: Component(const InputParameters & parameters); diff --git a/modules/thermal_hydraulics/src/components/Component.C b/modules/thermal_hydraulics/src/components/Component.C index bdba1d31d033..7e2cc6fb3eb6 100644 --- a/modules/thermal_hydraulics/src/components/Component.C +++ b/modules/thermal_hydraulics/src/components/Component.C @@ -18,6 +18,7 @@ InputParameters Component::validParams() { InputParameters params = THMObject::validParams(); + params += ADFunctorInterface::validParams(); params.addPrivateParam("_thm_problem"); params.addPrivateParam("_parent", nullptr); params.addPrivateParam("built_by_action", "add_component"); @@ -35,6 +36,7 @@ Component::Component(const InputParameters & parameters) : THMObject(parameters), LoggingInterface(getCheckedPointerParam("_thm_problem")->log()), NamingInterface(), + ADFunctorInterface(this), _parent(getParam("_parent")), _sim(*getCheckedPointerParam("_thm_problem")), From 11762960e131a55175cd85a89210dc9e98ab76f8 Mon Sep 17 00:00:00 2001 From: Guillaume Giudicelli Date: Mon, 23 Oct 2023 13:39:56 -0600 Subject: [PATCH 05/12] Update to new syntax for physics component tests Enable valgrind --- .../physics_component/single_physics.i | 39 ++++++++++--------- .../tests/components/physics_component/tests | 1 - 2 files changed, 21 insertions(+), 19 deletions(-) diff --git a/modules/thermal_hydraulics/test/tests/components/physics_component/single_physics.i b/modules/thermal_hydraulics/test/tests/components/physics_component/single_physics.i index ef9bc7e2da97..80453aa5f2e4 100644 --- a/modules/thermal_hydraulics/test/tests/components/physics_component/single_physics.i +++ b/modules/thermal_hydraulics/test/tests/components/physics_component/single_physics.i @@ -13,30 +13,33 @@ p_outlet = 0 [] [Physics] - [flow] - type = WCNSFVFlowPhysics - compressibility = 'incompressible' - porous_medium_treatment = true + [NavierStokes] + [WCNSFVFlowPhysics] + [flow] + compressibility = 'incompressible' + porous_medium_treatment = true - density = 'rho' - dynamic_viscosity = 'mu' + density = 'rho' + dynamic_viscosity = 'mu' - initial_velocity = '${u_inlet} 0 0' - initial_pressure = '${p_outlet}' + initial_velocity = '${u_inlet} 0 0' + initial_pressure = '${p_outlet}' - mass_advection_interpolation = 'upwind' - momentum_advection_interpolation = 'upwind' + mass_advection_interpolation = 'upwind' + momentum_advection_interpolation = 'upwind' - inlet_boundaries = 'comp1:left' - momentum_inlet_types = 'fixed-velocity' - momentum_inlet_function = 'f1 f1' + inlet_boundaries = 'comp1:left' + momentum_inlet_types = 'fixed-velocity' + momentum_inlet_function = 'f1 f1' - wall_boundaries = 'comp1:top comp1:bottom' - momentum_wall_types = 'noslip symmetry' + wall_boundaries = 'comp1:top comp1:bottom' + momentum_wall_types = 'noslip symmetry' - outlet_boundaries = 'comp1:right' - momentum_outlet_types = 'fixed-pressure' - pressure_function = 'f1' + outlet_boundaries = 'comp1:right' + momentum_outlet_types = 'fixed-pressure' + pressure_function = 'f1' + [] + [] [] [] diff --git a/modules/thermal_hydraulics/test/tests/components/physics_component/tests b/modules/thermal_hydraulics/test/tests/components/physics_component/tests index 3a393d82c9ef..5bfa2ce8f47d 100644 --- a/modules/thermal_hydraulics/test/tests/components/physics_component/tests +++ b/modules/thermal_hydraulics/test/tests/components/physics_component/tests @@ -18,7 +18,6 @@ method = "!dbg" installation_type = in_tree max_parallel = 4 # https://github.com/idaholab/moose/issues/24503 - valgrind = HEAVY requirement = 'The system shall model the porous, incompressible Navier-Stokes equations with a finite volume discretization, using a component, abstracting the flow equation definitions using the Physics system.' [] [] From cc572d9a4430bce5691cdc8beb885ce5bf47f522 Mon Sep 17 00:00:00 2001 From: Guillaume Giudicelli Date: Tue, 24 Oct 2023 15:19:05 -0600 Subject: [PATCH 06/12] Adapting input file for merging Physics and new syntax --- .../test/tests/components/physics_component/single_physics.i | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/thermal_hydraulics/test/tests/components/physics_component/single_physics.i b/modules/thermal_hydraulics/test/tests/components/physics_component/single_physics.i index 80453aa5f2e4..211fb65c1257 100644 --- a/modules/thermal_hydraulics/test/tests/components/physics_component/single_physics.i +++ b/modules/thermal_hydraulics/test/tests/components/physics_component/single_physics.i @@ -30,14 +30,14 @@ p_outlet = 0 inlet_boundaries = 'comp1:left' momentum_inlet_types = 'fixed-velocity' - momentum_inlet_function = 'f1 f1' + momentum_inlet_functors = 'f1 f1' wall_boundaries = 'comp1:top comp1:bottom' momentum_wall_types = 'noslip symmetry' outlet_boundaries = 'comp1:right' momentum_outlet_types = 'fixed-pressure' - pressure_function = 'f1' + pressure_functors = 'f1' [] [] [] From dad8777df7e42b5311205330796a0f9fed71cb5c Mon Sep 17 00:00:00 2001 From: Guillaume Giudicelli Date: Wed, 29 May 2024 12:26:10 +0900 Subject: [PATCH 07/12] Update syntax Fix test definition Add documentation to new component refs #23794 #24103 --- .../components/FileMeshPhysicsComponent.md | 22 ++++++++++++++++ .../components/FileMeshPhysicsComponent.h | 25 ++++--------------- .../src/components/FileMeshPhysicsComponent.C | 7 +++--- .../physics_component/single_physics.i | 2 +- .../tests/components/physics_component/tests | 6 ++--- 5 files changed, 34 insertions(+), 28 deletions(-) create mode 100644 modules/thermal_hydraulics/doc/content/source/components/FileMeshPhysicsComponent.md diff --git a/modules/thermal_hydraulics/doc/content/source/components/FileMeshPhysicsComponent.md b/modules/thermal_hydraulics/doc/content/source/components/FileMeshPhysicsComponent.md new file mode 100644 index 000000000000..dd9fdf81c323 --- /dev/null +++ b/modules/thermal_hydraulics/doc/content/source/components/FileMeshPhysicsComponent.md @@ -0,0 +1,22 @@ +# FileMeshPhysicsComponent + +This component first loads a mesh from an ExodusII file. It is equivalent to the [FileMeshGenerator.md] +but can be used within a simulation with the geometry described with [Components](Components/index.md) instead of a [Mesh](Mesh/index.md) +block. + +This component then adds its block to the domain of definition of [Physics](Physics/index.md) actions. +The `Physics` must have implemented the `::addBlocks` routine. + +## Loading the mesh file + +See the [FileMeshComponent.md] for explanations on how to load the mesh. + +## Defining Physics + +The `Physics` active on the mesh loaded by this component are specified with the [!param](/Components/FileMeshPhysicsComponent/physics) parameter. + +!syntax parameters /Components/FileMeshPhysicsComponent + +!syntax inputs /Components/FileMeshPhysicsComponent + +!syntax children /Components/FileMeshPhysicsComponent diff --git a/modules/thermal_hydraulics/include/components/FileMeshPhysicsComponent.h b/modules/thermal_hydraulics/include/components/FileMeshPhysicsComponent.h index 6266e44160ee..d63747ad0bea 100644 --- a/modules/thermal_hydraulics/include/components/FileMeshPhysicsComponent.h +++ b/modules/thermal_hydraulics/include/components/FileMeshPhysicsComponent.h @@ -12,7 +12,7 @@ #include "FileMeshComponent.h" /** - * Create a component with a single Physics object active on it + * Create a component with user-selected Physics active on it */ class FileMeshPhysicsComponent : public FileMeshComponent { @@ -29,31 +29,16 @@ class FileMeshPhysicsComponent : public FileMeshComponent protected: virtual void init() override; + /// Return the blocks this component defines (assuming the ids do not overlap with other components) virtual std::vector getBlocks() const { return getSubdomainNames(); } virtual Factory & getFactory() { return getMooseApp().getFactory(); } virtual FEProblemBase & getProblem() { return getMooseApp().feProblem(); } + /// Returns the mesh, which also contains other components virtual const MooseMesh & getMesh() const { return constMesh(); } - // virtual void addNSNonlinearVariable(const std::string & var_type, - // const std::string & var_name, - // InputParameters & params) - // { - // getTHMProblem().addSimVariable(true, var_type, var_name, params); - // } - // virtual void addNSAuxVariable(const std::string & var_type, - // const std::string & var_name, - // InputParameters & params) - // { - // getTHMProblem().addSimVariable(false, var_type, var_name, params); - // } - // virtual void addNSInitialCondition(const std::string & type, - // const std::string & name, - // InputParameters & params) - // { - // getTHMProblem().addSimInitialCondition(type, name, params); - // } + /// Returns a useful prefix for logs virtual std::string prefix() const { return name() + ":"; } private: - /// Physics object that creates the equations on this component + /// Physics that creates the equations on this component std::vector _physics; }; diff --git a/modules/thermal_hydraulics/src/components/FileMeshPhysicsComponent.C b/modules/thermal_hydraulics/src/components/FileMeshPhysicsComponent.C index 05c96749c778..56f2008a085b 100644 --- a/modules/thermal_hydraulics/src/components/FileMeshPhysicsComponent.C +++ b/modules/thermal_hydraulics/src/components/FileMeshPhysicsComponent.C @@ -17,7 +17,8 @@ FileMeshPhysicsComponent::validParams() { InputParameters params = FileMeshComponent::validParams(); - params.addClassDescription("Component with a single physics active on it."); + params.addClassDescription( + "Component using a mesh from a file with one or more Physics active on it."); params.addParam>("physics", "Physics object(s) active on the Component"); return params; } @@ -43,10 +44,8 @@ FileMeshPhysicsComponent::init() // Before this point, we did not have a problem, so we could not retrieve the physics for (const auto & physics_name : getParam>("physics")) - _physics.push_back(getProblem().getPhysics(physics_name)); + _physics.push_back(_app.actionWarehouse().getPhysics(physics_name)); for (auto physics : _physics) - { physics->addBlocks(getSubdomainNames()); - } } diff --git a/modules/thermal_hydraulics/test/tests/components/physics_component/single_physics.i b/modules/thermal_hydraulics/test/tests/components/physics_component/single_physics.i index 211fb65c1257..26bfb11b2218 100644 --- a/modules/thermal_hydraulics/test/tests/components/physics_component/single_physics.i +++ b/modules/thermal_hydraulics/test/tests/components/physics_component/single_physics.i @@ -14,7 +14,7 @@ p_outlet = 0 [Physics] [NavierStokes] - [WCNSFVFlowPhysics] + [Flow] [flow] compressibility = 'incompressible' porous_medium_treatment = true diff --git a/modules/thermal_hydraulics/test/tests/components/physics_component/tests b/modules/thermal_hydraulics/test/tests/components/physics_component/tests index 5bfa2ce8f47d..b468377d8a57 100644 --- a/modules/thermal_hydraulics/test/tests/components/physics_component/tests +++ b/modules/thermal_hydraulics/test/tests/components/physics_component/tests @@ -1,6 +1,6 @@ [Tests] - design = 'FlowComponentNS.md' - issues = '#23794' + design = 'FileMeshPhysicsComponent.md' + issues = '#23794 #24103' [generate_mesh] type = RunApp @@ -18,6 +18,6 @@ method = "!dbg" installation_type = in_tree max_parallel = 4 # https://github.com/idaholab/moose/issues/24503 - requirement = 'The system shall model the porous, incompressible Navier-Stokes equations with a finite volume discretization, using a component, abstracting the flow equation definitions using the Physics system.' + requirement = 'The system shall be able to create a component leveraging the Physics syntax to define equations.' [] [] From 0ed277bb45cfe921986c293838c55d5683d5ca7d Mon Sep 17 00:00:00 2001 From: Guillaume Giudicelli Date: Sat, 1 Jun 2024 15:55:28 +0900 Subject: [PATCH 08/12] Default physics to being defined everywhere --- framework/src/physics/PhysicsBase.C | 12 ++++++++++++ .../src/physics/NavierStokesPhysicsBase.C | 11 ----------- .../src/components/FileMeshPhysicsComponent.C | 4 ++-- modules/thermal_hydraulics/src/parser/THMSyntax.C | 2 ++ .../components/physics_component/single_physics.i | 2 +- 5 files changed, 17 insertions(+), 14 deletions(-) diff --git a/framework/src/physics/PhysicsBase.C b/framework/src/physics/PhysicsBase.C index 8f91fb9f1199..d958a43fa761 100644 --- a/framework/src/physics/PhysicsBase.C +++ b/framework/src/physics/PhysicsBase.C @@ -195,6 +195,18 @@ PhysicsBase::addRelationshipManagers(Moose::RelationshipManagerType input_rm_typ void PhysicsBase::initializePhysics() { + // Annoying edge case. We cannot use ANY_BLOCK_ID for kernels and variables since errors got added + // downstream for using it, we cannot leave it empty as that sets all objects to not live on any + // block + if (isParamSetByUser("block") && _blocks.empty()) + paramError("block", + "Empty block restriction is not supported. Comment out the Physics if you are " + "trying to disable it."); + + // Components should have added their blocks already. + if (_blocks.empty()) + _blocks.push_back("ANY_BLOCK_ID"); + mooseAssert(_mesh, "We should have a mesh to find the dimension"); if (_blocks.size()) _dim = _mesh->getBlocksMaxDimension(_blocks); diff --git a/modules/navier_stokes/src/physics/NavierStokesPhysicsBase.C b/modules/navier_stokes/src/physics/NavierStokesPhysicsBase.C index 4b5c87fcdaf0..46efc60c6203 100644 --- a/modules/navier_stokes/src/physics/NavierStokesPhysicsBase.C +++ b/modules/navier_stokes/src/physics/NavierStokesPhysicsBase.C @@ -34,17 +34,6 @@ NavierStokesPhysicsBase::validParams() NavierStokesPhysicsBase::NavierStokesPhysicsBase(const InputParameters & parameters) : PhysicsBase(parameters), _define_variables(getParam("define_variables")) { - // Annoying edge case. We cannot use ANY_BLOCK_ID for kernels and variables since errors got added - // downstream for using it, we cannot leave it empty as that sets all objects to not live on any - // block - if (isParamSetByUser("block") && _blocks.empty()) - paramError("block", - "Empty block restriction is not supported. Comment out the Physics if you are " - "trying to disable it."); - - // Placeholder before work with components - if (_blocks.empty()) - _blocks.push_back("ANY_BLOCK_ID"); } InputParameters diff --git a/modules/thermal_hydraulics/src/components/FileMeshPhysicsComponent.C b/modules/thermal_hydraulics/src/components/FileMeshPhysicsComponent.C index 56f2008a085b..6aea711c5e4c 100644 --- a/modules/thermal_hydraulics/src/components/FileMeshPhysicsComponent.C +++ b/modules/thermal_hydraulics/src/components/FileMeshPhysicsComponent.C @@ -28,8 +28,8 @@ FileMeshPhysicsComponent::FileMeshPhysicsComponent(const InputParameters & param { } -void FileMeshPhysicsComponent::addRelationshipManagers( - Moose::RelationshipManagerType /*input_rm_type*/) +void +FileMeshPhysicsComponent::addRelationshipManagers(Moose::RelationshipManagerType /*input_rm_type*/) { // TODO: We ll just add late relationship managers // At this point in the setup, we do not have a problem, so we cannot retrieve a Physics. We can diff --git a/modules/thermal_hydraulics/src/parser/THMSyntax.C b/modules/thermal_hydraulics/src/parser/THMSyntax.C index b589c8999828..dc60eadde2ad 100644 --- a/modules/thermal_hydraulics/src/parser/THMSyntax.C +++ b/modules/thermal_hydraulics/src/parser/THMSyntax.C @@ -73,6 +73,8 @@ registerActions(Syntax & syntax) syntax.addDependency("THM:init_simulation", "THM:add_component"); syntax.addDependency("add_mesh_generator", "THM:add_component"); syntax.addDependency("THM:identify_loops", "THM:add_component"); + // Components must specify their blocks to the Physics before it gets initialized + syntax.addDependency("init_physics", "THM:init_components"); syntax.addDependency("THM:identify_loops", "add_fluid_properties"); syntax.addDependency("THM:integrity_check", "THM:init_components"); syntax.addDependency("THM:integrity_check", "THM:identify_loops"); diff --git a/modules/thermal_hydraulics/test/tests/components/physics_component/single_physics.i b/modules/thermal_hydraulics/test/tests/components/physics_component/single_physics.i index 26bfb11b2218..5a05eeb60736 100644 --- a/modules/thermal_hydraulics/test/tests/components/physics_component/single_physics.i +++ b/modules/thermal_hydraulics/test/tests/components/physics_component/single_physics.i @@ -59,7 +59,7 @@ p_outlet = 0 [] [] -[Materials] +[FunctorMaterials] [const_functor] type = ADGenericFunctorMaterial prop_names = 'rho mu' From 24b6730e765f4032882f46d407e1080953f07fb7 Mon Sep 17 00:00:00 2001 From: Guillaume Giudicelli Date: Mon, 3 Jun 2024 19:38:33 +0900 Subject: [PATCH 09/12] Relax dependency on problem for NSFVAction processMesh by moving a call to addNSVariables Re-organize task dependencies to allow physics being initialized after componentse --- framework/src/base/Moose.C | 5 +++-- modules/fluid_properties/src/base/FluidPropertiesApp.C | 2 +- modules/navier_stokes/include/base/NSFVBase.h | 5 +++-- .../include/components/FileMeshPhysicsComponent.h | 1 + .../src/components/FileMeshPhysicsComponent.C | 2 +- modules/thermal_hydraulics/src/parser/THMSyntax.C | 4 ++++ 6 files changed, 13 insertions(+), 6 deletions(-) diff --git a/framework/src/base/Moose.C b/framework/src/base/Moose.C index 24a02d35313b..e55f38edcc75 100644 --- a/framework/src/base/Moose.C +++ b/framework/src/base/Moose.C @@ -306,7 +306,9 @@ addActionTypes(Syntax & syntax) "(create_problem_custom)" "(create_problem_default)" "(create_problem_complete)" - "(init_physics)" + "(add_function)" // Functions can depend on scalar variables, but this dependence can be + // added on initialSetup() rather than construction + "(init_physics)" // Components add their blocks to Physics, and components need functions at initialization "(setup_postprocessor_data)" "(setup_time_integrator)" "(setup_executioner)" @@ -322,7 +324,6 @@ addActionTypes(Syntax & syntax) "(add_mortar_variable)" "(setup_variable_complete)" "(setup_quadrature)" - "(add_function)" "(add_periodic_bc)" "(add_user_object)" "(add_distribution)" diff --git a/modules/fluid_properties/src/base/FluidPropertiesApp.C b/modules/fluid_properties/src/base/FluidPropertiesApp.C index 50c9107b8fd6..e0ba164b0c03 100644 --- a/modules/fluid_properties/src/base/FluidPropertiesApp.C +++ b/modules/fluid_properties/src/base/FluidPropertiesApp.C @@ -45,7 +45,7 @@ associateSyntaxInner(Syntax & syntax, ActionFactory & /*action_factory*/) registerMooseObjectTask("add_fluid_properties", FluidProperties, false); registerMooseObjectTask("add_fp_output", Output, false); - syntax.addDependency("add_fluid_properties", "init_displaced_problem"); + // Fluid properties depend on variables syntax.addDependency("add_aux_variable", "add_fluid_properties"); syntax.addDependency("add_variable", "add_fluid_properties"); syntax.addDependency("add_elemental_field_variable", "add_fluid_properties"); diff --git a/modules/navier_stokes/include/base/NSFVBase.h b/modules/navier_stokes/include/base/NSFVBase.h index 290f5705d97b..de128fc0bdcb 100644 --- a/modules/navier_stokes/include/base/NSFVBase.h +++ b/modules/navier_stokes/include/base/NSFVBase.h @@ -1171,6 +1171,9 @@ template void NSFVBase::addNSVariables() { + // We use finite volume variables + getProblem().needFV(); + // Determine which variables to add processVariables(); @@ -3051,8 +3054,6 @@ template void NSFVBase::processMesh() { - getProblem().needFV(); - _blocks = getBlocks(); // If the user doesn't define a block name we go with the default diff --git a/modules/thermal_hydraulics/include/components/FileMeshPhysicsComponent.h b/modules/thermal_hydraulics/include/components/FileMeshPhysicsComponent.h index d63747ad0bea..d51358713db4 100644 --- a/modules/thermal_hydraulics/include/components/FileMeshPhysicsComponent.h +++ b/modules/thermal_hydraulics/include/components/FileMeshPhysicsComponent.h @@ -10,6 +10,7 @@ #pragma once #include "FileMeshComponent.h" +#include "THMMesh.h" /** * Create a component with user-selected Physics active on it diff --git a/modules/thermal_hydraulics/src/components/FileMeshPhysicsComponent.C b/modules/thermal_hydraulics/src/components/FileMeshPhysicsComponent.C index 6aea711c5e4c..561f5463fe1e 100644 --- a/modules/thermal_hydraulics/src/components/FileMeshPhysicsComponent.C +++ b/modules/thermal_hydraulics/src/components/FileMeshPhysicsComponent.C @@ -29,7 +29,7 @@ FileMeshPhysicsComponent::FileMeshPhysicsComponent(const InputParameters & param } void -FileMeshPhysicsComponent::addRelationshipManagers(Moose::RelationshipManagerType /*input_rm_type*/) +FileMeshPhysicsComponent::addRelationshipManagers(Moose::RelationshipManagerType /*in_rm_type*/) { // TODO: We ll just add late relationship managers // At this point in the setup, we do not have a problem, so we cannot retrieve a Physics. We can diff --git a/modules/thermal_hydraulics/src/parser/THMSyntax.C b/modules/thermal_hydraulics/src/parser/THMSyntax.C index dc60eadde2ad..b6276c2c4f45 100644 --- a/modules/thermal_hydraulics/src/parser/THMSyntax.C +++ b/modules/thermal_hydraulics/src/parser/THMSyntax.C @@ -75,6 +75,10 @@ registerActions(Syntax & syntax) syntax.addDependency("THM:identify_loops", "THM:add_component"); // Components must specify their blocks to the Physics before it gets initialized syntax.addDependency("init_physics", "THM:init_components"); + // Fluid properties are retrieved during component initialization + syntax.addDependency("THM:init_components", "add_fluid_properties"); + // Solid material property used in a component needs a function + syntax.addDependency("THM:init_components", "add_function"); syntax.addDependency("THM:identify_loops", "add_fluid_properties"); syntax.addDependency("THM:integrity_check", "THM:init_components"); syntax.addDependency("THM:integrity_check", "THM:identify_loops"); From 034c3cec09bec6d36faa01be64f4d6cd3e568738 Mon Sep 17 00:00:00 2001 From: Guillaume Giudicelli Date: Wed, 12 Jun 2024 18:40:58 -0600 Subject: [PATCH 10/12] Remove retrieval of FPs at construction in fluid property functions - lets us construct functions much earlier. As FPs depend on variables --- .../functions/SaturationDensityFunction.h | 9 ++++++--- .../functions/SaturationPressureFunction.h | 5 ++++- .../functions/SaturationTemperatureFunction.h | 5 ++++- .../src/functions/SaturationDensityFunction.C | 17 +++++++++++------ .../src/functions/SaturationPressureFunction.C | 13 +++++++++---- .../functions/SaturationTemperatureFunction.C | 13 +++++++++---- 6 files changed, 43 insertions(+), 19 deletions(-) diff --git a/modules/fluid_properties/include/functions/SaturationDensityFunction.h b/modules/fluid_properties/include/functions/SaturationDensityFunction.h index ed8b1dab0563..da7c7d37a4d3 100644 --- a/modules/fluid_properties/include/functions/SaturationDensityFunction.h +++ b/modules/fluid_properties/include/functions/SaturationDensityFunction.h @@ -25,6 +25,9 @@ class SaturationDensityFunction : public Function, public FunctionInterface SaturationDensityFunction(const InputParameters & parameters); + // To retrieve the fluid properties + virtual void initialSetup() override; + using Function::value; virtual Real value(Real t, const Point & p) const override; @@ -32,11 +35,11 @@ class SaturationDensityFunction : public Function, public FunctionInterface /// Temperature function const Function & _T_fn; /// 2-phase fluid properties object - const TwoPhaseFluidProperties & _fp_2phase; + const TwoPhaseFluidProperties * _fp_2phase; /// Single-phase liquid properties - const SinglePhaseFluidProperties & _fp_liquid; + const SinglePhaseFluidProperties * _fp_liquid; /// Single-phase vapor properties - const SinglePhaseFluidProperties & _fp_vapor; + const SinglePhaseFluidProperties * _fp_vapor; /// Set true to use liquid phase; else vapor phase const bool _use_liquid; }; diff --git a/modules/fluid_properties/include/functions/SaturationPressureFunction.h b/modules/fluid_properties/include/functions/SaturationPressureFunction.h index 9f624be68bd7..2ec7818ebbb9 100644 --- a/modules/fluid_properties/include/functions/SaturationPressureFunction.h +++ b/modules/fluid_properties/include/functions/SaturationPressureFunction.h @@ -24,6 +24,9 @@ class SaturationPressureFunction : public Function, public FunctionInterface SaturationPressureFunction(const InputParameters & parameters); + // To retrieve the fluid properties + virtual void initialSetup() override; + using Function::value; virtual Real value(Real t, const Point & p) const override; virtual RealVectorValue gradient(Real t, const Point & p) const override; @@ -32,5 +35,5 @@ class SaturationPressureFunction : public Function, public FunctionInterface /// Temperature function const Function & _T_fn; /// 2-phase fluid properties object - const TwoPhaseFluidProperties & _fp_2phase; + const TwoPhaseFluidProperties * _fp_2phase; }; diff --git a/modules/fluid_properties/include/functions/SaturationTemperatureFunction.h b/modules/fluid_properties/include/functions/SaturationTemperatureFunction.h index 651f213db496..e584ca573cb1 100644 --- a/modules/fluid_properties/include/functions/SaturationTemperatureFunction.h +++ b/modules/fluid_properties/include/functions/SaturationTemperatureFunction.h @@ -24,6 +24,9 @@ class SaturationTemperatureFunction : public Function, public FunctionInterface SaturationTemperatureFunction(const InputParameters & parameters); + // To retrieve the fluid properties + virtual void initialSetup() override; + using Function::value; virtual Real value(Real t, const Point & p) const override; virtual RealVectorValue gradient(Real t, const Point & p) const override; @@ -32,5 +35,5 @@ class SaturationTemperatureFunction : public Function, public FunctionInterface /// Pressure function const Function & _p_fn; /// 2-phase fluid properties object - const TwoPhaseFluidProperties & _fp_2phase; + const TwoPhaseFluidProperties * _fp_2phase; }; diff --git a/modules/fluid_properties/src/functions/SaturationDensityFunction.C b/modules/fluid_properties/src/functions/SaturationDensityFunction.C index 9ee4b1736d53..469ef2c7278b 100644 --- a/modules/fluid_properties/src/functions/SaturationDensityFunction.C +++ b/modules/fluid_properties/src/functions/SaturationDensityFunction.C @@ -32,21 +32,26 @@ SaturationDensityFunction::SaturationDensityFunction(const InputParameters & par FunctionInterface(this), _T_fn(getFunction("T")), - _fp_2phase(getUserObject("fp_2phase")), - _fp_liquid(getUserObjectByName(_fp_2phase.getLiquidName())), - _fp_vapor(getUserObjectByName(_fp_2phase.getVaporName())), _use_liquid(getParam("use_liquid")) { } +void +SaturationDensityFunction::initialSetup() +{ + _fp_2phase = &getUserObject("fp_2phase"); + _fp_liquid = &getUserObjectByName(_fp_2phase->getLiquidName()); + _fp_vapor = &getUserObjectByName(_fp_2phase->getVaporName()); +} + Real SaturationDensityFunction::value(Real t, const Point & point) const { const Real T = _T_fn.value(t, point); - const Real p = _fp_2phase.p_sat(T); + const Real p = _fp_2phase->p_sat(T); if (_use_liquid) - return _fp_liquid.rho_from_p_T(p, T); + return _fp_liquid->rho_from_p_T(p, T); else - return _fp_vapor.rho_from_p_T(p, T); + return _fp_vapor->rho_from_p_T(p, T); } diff --git a/modules/fluid_properties/src/functions/SaturationPressureFunction.C b/modules/fluid_properties/src/functions/SaturationPressureFunction.C index a72ef8772cf7..91d89d08db84 100644 --- a/modules/fluid_properties/src/functions/SaturationPressureFunction.C +++ b/modules/fluid_properties/src/functions/SaturationPressureFunction.C @@ -30,19 +30,24 @@ SaturationPressureFunction::SaturationPressureFunction(const InputParameters & p : Function(parameters), FunctionInterface(this), - _T_fn(getFunction("T")), - _fp_2phase(getUserObject("fp_2phase")) + _T_fn(getFunction("T")) { } +void +SaturationPressureFunction::initialSetup() +{ + _fp_2phase = &getUserObject("fp_2phase"); +} + Real SaturationPressureFunction::value(Real t, const Point & point) const { - return _fp_2phase.p_sat(_T_fn.value(t, point)); + return _fp_2phase->p_sat(_T_fn.value(t, point)); } RealVectorValue SaturationPressureFunction::gradient(Real t, const Point & point) const { - return _T_fn.gradient(t, point) / _fp_2phase.dT_sat_dp(value(t, point)); + return _T_fn.gradient(t, point) / _fp_2phase->dT_sat_dp(value(t, point)); } diff --git a/modules/fluid_properties/src/functions/SaturationTemperatureFunction.C b/modules/fluid_properties/src/functions/SaturationTemperatureFunction.C index 7eba10caac8e..0900248cf554 100644 --- a/modules/fluid_properties/src/functions/SaturationTemperatureFunction.C +++ b/modules/fluid_properties/src/functions/SaturationTemperatureFunction.C @@ -30,19 +30,24 @@ SaturationTemperatureFunction::SaturationTemperatureFunction(const InputParamete : Function(parameters), FunctionInterface(this), - _p_fn(getFunction("p")), - _fp_2phase(getUserObject("fp_2phase")) + _p_fn(getFunction("p")) { } +void +SaturationTemperatureFunction::initialSetup() +{ + _fp_2phase = &getUserObject("fp_2phase"); +} + Real SaturationTemperatureFunction::value(Real t, const Point & point) const { - return _fp_2phase.T_sat(_p_fn.value(t, point)); + return _fp_2phase->T_sat(_p_fn.value(t, point)); } RealVectorValue SaturationTemperatureFunction::gradient(Real t, const Point & point) const { - return _fp_2phase.dT_sat_dp(_p_fn.value(t, point)) * _p_fn.gradient(t, point); + return _fp_2phase->dT_sat_dp(_p_fn.value(t, point)) * _p_fn.gradient(t, point); } From 2ba13fc6d8c52e3cd869c5ab06e27bcd18cbfcee Mon Sep 17 00:00:00 2001 From: Guillaume Giudicelli Date: Thu, 13 Jun 2024 14:37:15 -0600 Subject: [PATCH 11/12] Move displaced problem init earlier to have functions functors Add TI to displaced problem later as it is not ready when problem is created --- framework/include/problems/DisplacedProblem.h | 3 +++ .../src/actions/CreateDisplacedProblemAction.C | 4 ++-- framework/src/base/Moose.C | 4 ++-- framework/src/problems/DisplacedProblem.C | 13 +++++++++---- framework/src/problems/FEProblemBase.C | 4 ++++ framework/src/variables/MooseVariableFE.C | 15 ++++++++++++--- 6 files changed, 32 insertions(+), 11 deletions(-) diff --git a/framework/include/problems/DisplacedProblem.h b/framework/include/problems/DisplacedProblem.h index c96b39857590..699d9573f952 100644 --- a/framework/include/problems/DisplacedProblem.h +++ b/framework/include/problems/DisplacedProblem.h @@ -84,6 +84,9 @@ class DisplacedProblem : public SubProblem virtual unsigned int linearSysNum(const LinearSystemName & sys_name) const override; virtual unsigned int solverSysNum(const SolverSystemName & sys_name) const override; + /// Get the time integrators from the problem + void addTimeIntegrator(); + /** * Allocate vectors and save old solutions into them. */ diff --git a/framework/src/actions/CreateDisplacedProblemAction.C b/framework/src/actions/CreateDisplacedProblemAction.C index 88cbf6094016..b16063145956 100644 --- a/framework/src/actions/CreateDisplacedProblemAction.C +++ b/framework/src/actions/CreateDisplacedProblemAction.C @@ -131,7 +131,7 @@ CreateDisplacedProblemAction::act() "We should be adding geometric rms so early that we haven't set our MeshBase yet"); _mesh->allowRemoteElementRemoval(false); - // Displaced mesh should not exist yet + mooseAssert(!_displaced_mesh, "Displaced mesh should not exist yet"); } if (_current_task == "add_algebraic_rm") @@ -163,7 +163,7 @@ CreateDisplacedProblemAction::act() addProxyAlgebraicRelationshipManagers(undisplaced_aux, displaced_aux); addProxyAlgebraicRelationshipManagers(displaced_aux, undisplaced_aux); - // Add geoemtric ghosting (which only acts through the mesh) through the single auxiliary + // Add geometric ghosting (which only acts through the mesh) through the single auxiliary // system as opposed to duplicating the effort through potentially multiple nonlinear systems addProxyGeometricRelationshipManagers(undisplaced_aux, displaced_aux); addProxyGeometricRelationshipManagers(displaced_aux, undisplaced_aux); diff --git a/framework/src/base/Moose.C b/framework/src/base/Moose.C index e55f38edcc75..04cbb69fab77 100644 --- a/framework/src/base/Moose.C +++ b/framework/src/base/Moose.C @@ -306,7 +306,8 @@ addActionTypes(Syntax & syntax) "(create_problem_custom)" "(create_problem_default)" "(create_problem_complete)" - "(add_function)" // Functions can depend on scalar variables, but this dependence can be + "(init_displaced_problem)" // Problem must be init-ed before we start adding functors + "(add_function)" // Functions can depend on scalar variables & PPs, but this dependence can be // added on initialSetup() rather than construction "(init_physics)" // Components add their blocks to Physics, and components need functions at initialization "(setup_postprocessor_data)" @@ -318,7 +319,6 @@ addActionTypes(Syntax & syntax) "(check_integrity_early)" "(check_integrity_early_physics)" "(setup_predictor)" - "(init_displaced_problem)" "(add_aux_variable, add_variable, add_elemental_field_variable," " add_external_aux_variables)" "(add_mortar_variable)" diff --git a/framework/src/problems/DisplacedProblem.C b/framework/src/problems/DisplacedProblem.C index 4ef88d937133..84d9796d61c6 100644 --- a/framework/src/problems/DisplacedProblem.C +++ b/framework/src/problems/DisplacedProblem.C @@ -67,9 +67,6 @@ DisplacedProblem::DisplacedProblem(const InputParameters & parameters) for (unsigned int i = 0; i < n_threads; ++i) _assembly[i].emplace_back(std::make_unique(*displaced_nl, i)); - - displaced_nl->addTimeIntegrator( - _mproblem.getNonlinearSystemBase(nl_sys_num).getSharedTimeIntegrator()); } _nl_solution.resize(_displaced_solver_systems.size(), nullptr); @@ -80,7 +77,6 @@ DisplacedProblem::DisplacedProblem(const InputParameters & parameters) _mproblem.getAuxiliarySystem(), "displaced_" + _mproblem.getAuxiliarySystem().name(), Moose::VAR_AUXILIARY); - _displaced_aux->addTimeIntegrator(_mproblem.getAuxiliarySystem().getSharedTimeIntegrator()); // // Generally speaking, the mesh is prepared for use, and consequently remote elements are deleted // // well before our Problem(s) are constructed. Historically, in MooseMesh we have a bunch of @@ -195,6 +191,15 @@ DisplacedProblem::initAdaptivity() { } +void +DisplacedProblem::addTimeIntegrator() +{ + for (const auto nl_sys_num : make_range(_mproblem.numNonlinearSystems())) + _displaced_solver_systems[nl_sys_num]->addTimeIntegrator( + _mproblem.getNonlinearSystemBase(nl_sys_num).getSharedTimeIntegrator()); + _displaced_aux->addTimeIntegrator(_mproblem.getAuxiliarySystem().getSharedTimeIntegrator()); +} + void DisplacedProblem::saveOldSolutions() { diff --git a/framework/src/problems/FEProblemBase.C b/framework/src/problems/FEProblemBase.C index 843d73c24848..ad317ac4fa77 100644 --- a/framework/src/problems/FEProblemBase.C +++ b/framework/src/problems/FEProblemBase.C @@ -6335,6 +6335,10 @@ FEProblemBase::addTimeIntegrator(const std::string & type, if (!nl->hasVector(tag_udotdot) && uDotDotRequested()) nl->associateVectorToTag(*nl->solutionUDotDot(), tag_udotdot); } + + if (_displaced_problem) + // Time integrator does not exist when displaced problem is created. + _displaced_problem->addTimeIntegrator(); } void diff --git a/framework/src/variables/MooseVariableFE.C b/framework/src/variables/MooseVariableFE.C index bb506bb9685d..9258fddd6e32 100644 --- a/framework/src/variables/MooseVariableFE.C +++ b/framework/src/variables/MooseVariableFE.C @@ -1144,9 +1144,12 @@ template typename MooseVariableFE::DotType MooseVariableFE::evaluateDot(const ElemQpArg & elem_qp, const StateArg & state) const { - mooseAssert(_time_integrator && _time_integrator->dt(), + mooseAssert(_time_integrator, "A time derivative is being requested but we do not have a time integrator so we'll " "have no idea how to compute it"); + mooseAssert(_time_integrator->dt(), + "A time derivative is being requested but the time integrator wants to perform a 0s " + "time step"); evaluateOnElement(elem_qp, state, /*query_cache=*/true); const auto qp = elem_qp.qp; mooseAssert(qp < _current_elem_qp_functor_dot.size(), @@ -1158,9 +1161,12 @@ template typename MooseVariableFE::DotType MooseVariableFE::evaluateDot(const ElemArg & elem_arg, const StateArg & state) const { - mooseAssert(_time_integrator && _time_integrator->dt(), + mooseAssert(_time_integrator, "A time derivative is being requested but we do not have a time integrator so we'll " "have no idea how to compute it"); + mooseAssert(_time_integrator->dt(), + "A time derivative is being requested but the time integrator wants to perform a 0s " + "time step"); const QMonomial qrule(elem_arg.elem->dim(), CONSTANT); // We can use whatever we want for the point argument since it won't be used const ElemQpArg elem_qp_arg{elem_arg.elem, /*qp=*/0, &qrule, Point(0, 0, 0)}; @@ -1172,9 +1178,12 @@ template typename MooseVariableFE::GradientType MooseVariableFE::evaluateGradDot(const ElemArg & elem_arg, const StateArg & state) const { - mooseAssert(_time_integrator && _time_integrator->dt(), + mooseAssert(_time_integrator, "A time derivative is being requested but we do not have a time integrator so we'll " "have no idea how to compute it"); + mooseAssert(_time_integrator->dt(), + "A time derivative is being requested but the time integrator wants to perform a 0s " + "time step"); const QMonomial qrule(elem_arg.elem->dim(), CONSTANT); // We can use whatever we want for the point argument since it won't be used const ElemQpArg elem_qp_arg{elem_arg.elem, /*qp=*/0, &qrule, Point(0, 0, 0)}; From a333d030aa4baec111d085d8e37a829e325c1f7d Mon Sep 17 00:00:00 2001 From: Guillaume Giudicelli Date: Sun, 16 Jun 2024 15:49:53 -0600 Subject: [PATCH 12/12] Make sure displaced problem gets destructed earlier --- framework/include/executioners/SolveObject.h | 2 +- framework/src/executioners/SolveObject.C | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/framework/include/executioners/SolveObject.h b/framework/include/executioners/SolveObject.h index 503859a01207..dca615fda792 100644 --- a/framework/include/executioners/SolveObject.h +++ b/framework/include/executioners/SolveObject.h @@ -41,7 +41,7 @@ class SolveObject : public MooseObject, public PerfGraphInterface, public Postpr /// Reference to FEProblem FEProblemBase & _problem; /// Displaced problem - std::shared_ptr _displaced_problem; + DisplacedProblem * _displaced_problem; /// Mesh MooseMesh & _mesh; /// Displaced mesh diff --git a/framework/src/executioners/SolveObject.C b/framework/src/executioners/SolveObject.C index 5d45673552db..7445739e967b 100644 --- a/framework/src/executioners/SolveObject.C +++ b/framework/src/executioners/SolveObject.C @@ -22,7 +22,7 @@ SolveObject::SolveObject(Executioner & ex) _executioner(ex), _problem(*getCheckedPointerParam( "_fe_problem_base", "This might happen if you don't have a mesh")), - _displaced_problem(_problem.getDisplacedProblem()), + _displaced_problem(_problem.getDisplacedProblem().get()), _mesh(_problem.mesh()), _displaced_mesh(_displaced_problem ? &_displaced_problem->mesh() : nullptr), _solver_sys(_problem.numNonlinearSystems()