From c29e8996d28c2417a1b35501caae7d7393a02419 Mon Sep 17 00:00:00 2001 From: Wendy Ji <61012460+Wendy-Ji@users.noreply.github.com> Date: Fri, 30 Aug 2024 01:03:01 +1000 Subject: [PATCH] Address review: - more docstring - modified doco - deprecate old boundary parameters --- .../meshmodifiers/ElementSubdomainModifier.md | 8 ++++---- .../ElementSubdomainModifierBase.h | 7 ++++++- .../ElementSubdomainModifierBase.C | 20 ++++++++++--------- 3 files changed, 21 insertions(+), 14 deletions(-) diff --git a/framework/doc/content/source/meshmodifiers/ElementSubdomainModifier.md b/framework/doc/content/source/meshmodifiers/ElementSubdomainModifier.md index 4d890a94f803..5b0d4fe5b327 100644 --- a/framework/doc/content/source/meshmodifiers/ElementSubdomainModifier.md +++ b/framework/doc/content/source/meshmodifiers/ElementSubdomainModifier.md @@ -2,7 +2,7 @@ ## Overview -The `ElementSubdomainModifier` modifies an element subdomain ID. This is inherited by other mesh modifiers, such as [CoupledVarThresholdElementSubdomainModifier.md] and [TimedSubdomainModifier.md], which implement different criteria for a subdomain ID to be modified. +The `ElementSubdomainModifier` modifies an element subdomain ID. This class is inherited by other mesh modifiers, such as [CoupledVarThresholdElementSubdomainModifier.md] and [TimedSubdomainModifier.md], which implement different criteria for a subdomain ID to be modified. The `ElementSubdomainModifier` can model @@ -25,7 +25,7 @@ Consider a unit square domain decomposed by a vertical line $x=0.25$. The elemen !alert note If the moving boundary is defined completely around a subdomain, or between subdomains, then [SidesetAroundSubdomainUpdater.md] may be more useful to use in conjunction with the `ElementSubdomainModifier`, rather than using the `moving_boundaries` and `moving_boundary_subdomain_pairs` parameters in `ElementSubdomainModifier`. -The change of element subdomains will alter the definitions of certain sidesets and nodesets. The parameters `moving_boundaries` and `moving_boundary_subdomain_pairs` can optionally be used to modify the corresponding sidesets/nodesets over the elements that change subdomain. The names of the boundaries are specified in `moving_boundaries`, and the pair of subdomains that each boundary in `moving_boundaries` lies between must be specified in the corresponding `moving_boundary_subdomain_pairs`. The element side from the first subdomain of the pair is added to the boundary. +The change of element subdomains will alter the definitions of certain sidesets and nodesets. The parameters [!param](/MeshModifiers/ElementSubdomainModifier/moving_boundaries) and [!param](/MeshModifiers/ElementSubdomainModifier/moving_boundary_subdomain_pairs) can optionally be used to modify the corresponding sidesets/nodesets over the elements that change subdomain. The names of the boundaries are specified in `moving_boundaries`, and the pair of subdomains that each boundary in `moving_boundaries` lies between must be specified in the corresponding `moving_boundary_subdomain_pairs`. The element side from the first subdomain of the pair is added to the boundary. If the boundaries provided through `moving_boundaries` already exist, the modifier will attempt to modify the provided sidesets/nodesets whenever an element changes subdomain ID. If the boundaries do not exist, the modifier will create sidesets and nodesets with the provided names. @@ -80,7 +80,7 @@ An auxiliary variable $u$ is defined over the domain, with initial values of 1, !media large_media/mesh_modifiers/element_subdomain_modifier/orig.png style=float:center;width:100%; caption=The default behaviour of the modifier is to reinitializate all elements that change subdomain ID. -However, if a list of subdomains (IDs or names) is provided through the parameter `reinitialize_subdomains`, the reinitialization only occurs if the element's new subdomain ID is in the provided list: +However, if a list of subdomains (IDs or names) is provided through the parameter [!param](/MeshModifiers/ElementSubdomainModifier/reinitialize_subdomains), the reinitialization only occurs if the element's new subdomain ID is in the provided list: !listing test/tests/meshmodifiers/element_subdomain_modifier/reinitialization_into.i start=[MeshModifiers] end=[AuxVariables] @@ -92,7 +92,7 @@ If an empty list is given in `reinitialize_subdomains`, then there is no reiniti !media large_media/mesh_modifiers/element_subdomain_modifier/none.png style=float:center;width:100%; caption=No reinitialization of any elements that change subdomain ID. -Reinitialization can be further restricted by setting the parameter `old_subdomain_reinitialized` to `false`. The modifier will then additionally check the element's old subdomain ID. Reinitialization then only occurs if the old subdomain ID was not in the list provided in the parameter `reinitialize_subdomains`. +Reinitialization can be further restricted by setting the parameter [!param](/MeshModifiers/ElementSubdomainModifier/old_subdomain_reinitialized) to `false`. The modifier will then additionally check the element's old subdomain ID. Reinitialization then only occurs if the old subdomain ID was not in the list provided in the parameter `reinitialize_subdomains`. !listing test/tests/meshmodifiers/element_subdomain_modifier/reinitialization_from_into.i start=[MeshModifiers] end=[AuxVariables] diff --git a/framework/include/meshmodifiers/ElementSubdomainModifierBase.h b/framework/include/meshmodifiers/ElementSubdomainModifierBase.h index a3fc8b3e1e56..4d01389417cd 100644 --- a/framework/include/meshmodifiers/ElementSubdomainModifierBase.h +++ b/framework/include/meshmodifiers/ElementSubdomainModifierBase.h @@ -13,6 +13,9 @@ #include "NonlinearSystemBase.h" #include "AuxiliarySystem.h" +/** + * Base class for mesh modifiers modifying element subdomains + */ class ElementSubdomainModifierBase : public ElementUserObject { public: @@ -88,11 +91,13 @@ class ElementSubdomainModifierBase : public ElementUserObject ConstElemRange & elem_range, ConstBndNodeRange & bnd_node_range); - /// Determine if a node is newly activated + /// Determine if a node is newly reinitialized bool nodeIsNewlyReinitialized(dof_id_type node_id) const; + /// Reinitialize variables on range of elements and nodes to be reinitialized void applyIC(bool displaced); + /// Reinitialize stateful material properties on range of elements and nodes to be reinitialized void initElementStatefulProps(bool displaced); /// Range of reinitialized elements diff --git a/framework/src/meshmodifiers/ElementSubdomainModifierBase.C b/framework/src/meshmodifiers/ElementSubdomainModifierBase.C index 17ba872bedc4..99137afa2169 100644 --- a/framework/src/meshmodifiers/ElementSubdomainModifierBase.C +++ b/framework/src/meshmodifiers/ElementSubdomainModifierBase.C @@ -29,10 +29,10 @@ ElementSubdomainModifierBase::validParams() params.set("use_displaced_mesh") = false; params.suppressParameter("use_displaced_mesh"); - params.addParam( + params.addDeprecatedParam( "moving_boundary_name", "This has been replaced by 'moving_boundaries' and 'moving_boundary_subdomain_pairs'."); - params.addParam( + params.addDeprecatedParam( "complement_moving_boundary_name", "This has been replaced by 'moving_boundaries' and 'moving_boundary_subdomain_pairs'."); params.addDeprecatedParam( @@ -177,6 +177,14 @@ void ElementSubdomainModifierBase::modify( const std::unordered_map> & moved_elems) { + + // If nothing need to change, just return. + // This will skip all mesh changes, and so no adaptivity mesh files will be written. + auto n_moved_elem = moved_elems.size(); + gatherSum(n_moved_elem); + if (n_moved_elem == 0) + return; + // Create moving boundaries on the undisplaced and displaced meshes // // Note: We do this _everytime_ because previous execution might have removed the sidesets and @@ -186,13 +194,6 @@ ElementSubdomainModifierBase::modify( if (_displaced_mesh) createMovingBoundaries(*_displaced_mesh); - // If nothing need to change, just return. - // This will skip all mesh changes, and so no adaptivity mesh files will be written. - auto n_moved_elem = moved_elems.size(); - gatherSum(n_moved_elem); - if (n_moved_elem == 0) - return; - // This has to be done _before_ subdomain changes are applied findReinitializedElemsAndNodes(moved_elems); @@ -531,6 +532,7 @@ ElementSubdomainModifierBase::applyIC(bool displaced) _fe_problem.projectInitialConditionOnCustomRange(reinitializedElemRange(displaced), reinitializedBndNodeRange(displaced)); + mooseAssert(_fe_problem.numSolverSystems() < 2, "This code was written for a single nonlinear system"); // Set old and older solutions on the reinitialized dofs to the reinitialized values setOldAndOlderSolutions(_fe_problem.getNonlinearSystemBase(_sys.number()), reinitializedElemRange(displaced),