Skip to content

Commit

Permalink
Address review:
Browse files Browse the repository at this point in the history
- more docstring
- modified doco
- deprecate old boundary parameters
  • Loading branch information
Wendy-Ji authored and GiudGiud committed Aug 29, 2024
1 parent 1d806e8 commit c29e899
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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.

Expand Down Expand Up @@ -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]

Expand All @@ -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]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
#include "NonlinearSystemBase.h"
#include "AuxiliarySystem.h"

/**
* Base class for mesh modifiers modifying element subdomains
*/
class ElementSubdomainModifierBase : public ElementUserObject
{
public:
Expand Down Expand Up @@ -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
Expand Down
20 changes: 11 additions & 9 deletions framework/src/meshmodifiers/ElementSubdomainModifierBase.C
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ ElementSubdomainModifierBase::validParams()
params.set<bool>("use_displaced_mesh") = false;
params.suppressParameter<bool>("use_displaced_mesh");

params.addParam<BoundaryName>(
params.addDeprecatedParam<BoundaryName>(
"moving_boundary_name",
"This has been replaced by 'moving_boundaries' and 'moving_boundary_subdomain_pairs'.");
params.addParam<BoundaryName>(
params.addDeprecatedParam<BoundaryName>(
"complement_moving_boundary_name",
"This has been replaced by 'moving_boundaries' and 'moving_boundary_subdomain_pairs'.");
params.addDeprecatedParam<bool>(
Expand Down Expand Up @@ -177,6 +177,14 @@ void
ElementSubdomainModifierBase::modify(
const std::unordered_map<dof_id_type, std::pair<SubdomainID, SubdomainID>> & 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
Expand All @@ -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);

Expand Down Expand Up @@ -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),
Expand Down

0 comments on commit c29e899

Please sign in to comment.