Skip to content

Commit

Permalink
add deprecated params; change param to old_subdomain_reinitialized
Browse files Browse the repository at this point in the history
  • Loading branch information
Wendy-Ji committed Aug 20, 2024
1 parent 8858167 commit 2abf514
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ If an empty list is given in `reinitialize_subdomains`, then there is no reiniti

!media media/userobjects/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 `previous_subdomain_reinitialized` to `false`. The modifier will then additionally check the changing element's previous subdomain ID. Reinitialization will only occur if the previous subdomain ID was not in the list provided in the parameter `reinitialize_subdomains`.
Reinitialization can be further restricted by setting the parameter `old_subdomain_reinitialized` to `false`. The modifier will then additionally check the changing element's old subdomain ID. Reinitialization will only occur if the old subdomain ID was not in the list provided in the parameter `reinitialize_subdomains`.

!listing test/tests/userobjects/element_subdomain_modifier/reinitialization_from_into.i start=[UserObjects] end=[AuxVariables]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class ElementSubdomainModifierBase : public ElementUserObject
std::vector<SubdomainID> _subdomain_ids_to_reinitialize;

/// Whether to reinitialize moved elements whose old subdomain was in _reinitialize_subdomains
const bool _previous_subdomain_reinitialized;
const bool _old_subdomain_reinitialized;

/// Moving boundaries associated with each subdomain pair
typedef std::pair<SubdomainID, SubdomainID> SubdomainPair;
Expand Down
38 changes: 23 additions & 15 deletions framework/src/userobjects/ElementSubdomainModifierBase.C
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,23 @@ ElementSubdomainModifierBase::validParams()
params.set<bool>("use_displaced_mesh") = false;
params.suppressParameter<bool>("use_displaced_mesh");

params.addDeprecatedParam<BoundaryName>(
"moving_boundary_name",
"This has been replaced by 'moving_boundaries' and 'moving_boundary_subdomain_pairs'.");
params.addDeprecatedParam<BoundaryName>(
"complement_moving_boundary_name",
"This has been replaced by 'moving_boundaries' and 'moving_boundary_subdomain_pairs'.");
params.addDeprecatedParam<bool>(
"apply_initial_conditions", true, "This has been replaced by 'reinitialize_subdomains'.");

params.addParam<std::vector<BoundaryName>>(
"moving_boundaries",
{},
"Moving boundaries between subdomains. These boundaries (both sidesets and nodesets) will be "
"updated as elements change their subdomain. The corresponding subdomains of each moving "
"boundary shall be specified using the parameter 'moving_boundary_subdomain_pairs'. If one "
"boundary and multiple subdomain pairs are specified, then it is assumed that the pairs all "
"apply to the boundary. A boundary will be created on the mesh if it does not already "
"updated for elements that change subdomain. The subdomains that each moving boundary "
"lies between shall be specified using the parameter 'moving_boundary_subdomain_pairs'. If "
"one boundary and multiple subdomain pairs are specified, then it is assumed that the pairs "
"all apply to the boundary. A boundary will be created on the mesh if it does not already "
"exist.");
params.addParam<std::vector<std::vector<SubdomainName>>>(
"moving_boundary_subdomain_pairs",
Expand All @@ -47,15 +56,14 @@ ElementSubdomainModifierBase::validParams()
"be delimited by ';'. If a pair only has one subdomain, the moving boundary is associated "
"with the subdomain's external boundary, i.e., when the elements have no neighboring "
"elements.");

params.addParam<std::vector<SubdomainName>>(
"reinitialize_subdomains",
{"ANY_BLOCK_ID"},
"By default, any element which changes subdomain is reinitialized. If a list of subdomains "
"(IDs or names) is set, then only elements which change to a subdomain in the list will be "
"reinitialized. If an empty list is set, then no elements will be reinitialized.");
params.addParam<bool>(
"previous_subdomain_reinitialized",
"old_subdomain_reinitialized",
true,
"If set to false, only elements which change from subdomains not listed in "
"'reinitialize_subdomains', to ones that are listed, are reinitialized. "
Expand All @@ -67,7 +75,7 @@ ElementSubdomainModifierBase::ElementSubdomainModifierBase(const InputParameters
: ElementUserObject(parameters),
_displaced_problem(_fe_problem.getDisplacedProblem().get()),
_displaced_mesh(_displaced_problem ? &_displaced_problem->mesh() : nullptr),
_previous_subdomain_reinitialized(getParam<bool>("previous_subdomain_reinitialized"))
_old_subdomain_reinitialized(getParam<bool>("old_subdomain_reinitialized"))
{
}

Expand All @@ -86,19 +94,19 @@ ElementSubdomainModifierBase::initialSetup()
std::set<SubdomainID> set_subdomain_ids_to_reinitialize(_subdomain_ids_to_reinitialize.begin(),
_subdomain_ids_to_reinitialize.end());

if (_previous_subdomain_reinitialized == false &&
if (_old_subdomain_reinitialized == false &&
(std::find(_subdomain_ids_to_reinitialize.begin(),
_subdomain_ids_to_reinitialize.end(),
Moose::ANY_BLOCK_ID) != _subdomain_ids_to_reinitialize.end() ||
set_subdomain_ids_to_reinitialize == _mesh.meshSubdomains()))
paramError("previous_subdomain_reinitialized",
"'previous_subdomain_reinitialized' can only be set to false if "
paramError("old_subdomain_reinitialized",
"'old_subdomain_reinitialized' can only be set to false if "
"reinitialize_subdomains does "
"not cover the whole model, otherwise no elements will be reinitialized as it is "
"impossible for an element to begin in a subdomain not in the list.");
else if (_previous_subdomain_reinitialized == false && _subdomain_ids_to_reinitialize.empty())
paramError("previous_subdomain_reinitialized",
"'previous_subdomain_reinitialized' can only be set to false if "
else if (_old_subdomain_reinitialized == false && _subdomain_ids_to_reinitialize.empty())
paramError("old_subdomain_reinitialized",
"'old_subdomain_reinitialized' can only be set to false if "
"reinitialize_subdomains is set to a non-empty list of subdomains, otherwise no "
"elements will be reinitialized as it is impossible for an element to change to a "
"subdomain in the list.");
Expand Down Expand Up @@ -449,10 +457,10 @@ ElementSubdomainModifierBase::findReinitializedElemsAndNodes(
else // Reinitialize if new subdomain is in list of subdomains to be reinitialized
{
const auto & [from, to] = subdomain;
if (subdomainIsReinitialized(to) && _previous_subdomain_reinitialized)
if (subdomainIsReinitialized(to) && _old_subdomain_reinitialized)
_reinitialized_elems.insert(elem_id);
// Only reinitialize if original subdomain is not in list of subdomains
else if (subdomainIsReinitialized(to) && !_previous_subdomain_reinitialized &&
else if (subdomainIsReinitialized(to) && !_old_subdomain_reinitialized &&
!subdomainIsReinitialized(from))
_reinitialized_elems.insert(elem_id);
else // New subdomain is not in list of subdomains
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
threshold = 0
subdomain_id = 1
reinitialize_subdomains = '1 2'
previous_subdomain_reinitialized = false
old_subdomain_reinitialized = false
execute_on = 'INITIAL TIMESTEP_BEGIN'
[]
[moving_circle_top]
Expand All @@ -78,7 +78,7 @@
threshold = 0
subdomain_id = 2
reinitialize_subdomains = '1 2'
previous_subdomain_reinitialized = false
old_subdomain_reinitialized = false
execute_on = 'INITIAL TIMESTEP_BEGIN'
[]
[]
Expand Down

0 comments on commit 2abf514

Please sign in to comment.