https://mooseframework.inl.gov
Loading...
Searching...
No Matches
ElementSubdomainModifierBase.h
Go to the documentation of this file.
1//* This file is part of the MOOSE framework
2//* https://mooseframework.inl.gov
3//*
4//* All rights reserved, see COPYRIGHT for full restrictions
5//* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6//*
7//* Licensed under LGPL 2.1, please see LICENSE for details
8//* https://www.gnu.org/licenses/lgpl-2.1.html
9
10#pragma once
11
12#include "ElementUserObject.h"
13#include "NonlinearSystemBase.h"
14#include "AuxiliarySystem.h"
16#include "KDTree.h"
17
41
46{
47public:
49
51
52 void initialSetup() override;
53 void meshChanged() override;
54 void timestepSetup() override;
55
56protected:
74 virtual void
75 modify(const std::unordered_map<dof_id_type, std::pair<SubdomainID, SubdomainID>> & moved_elems);
76
79
82
85
87 std::unordered_map<BoundaryID, BoundaryName> _moving_boundary_names;
88
91
94
95private:
98
100 const std::unordered_map<dof_id_type, std::pair<SubdomainID, SubdomainID>> & moved_elems,
101 MooseMesh & mesh);
102
104 void setAncestorsSubdomainIDs(Elem * elem, const SubdomainID subdomain_id);
105
107 const std::unordered_map<dof_id_type, std::pair<SubdomainID, SubdomainID>> & moved_elems);
108
109 void gatherMovingBoundaryChangesHelper(const Elem * elem,
110 unsigned short side,
111 const Elem * neigh,
112 unsigned short neigh_side);
113
115
116 void prepareVariableForReinitialization(const VariableName & var_name,
117 ReinitStrategy reinit_strategy);
118
121
123 const std::unordered_map<dof_id_type, std::pair<SubdomainID, SubdomainID>> & moved_elems);
124
127 ConstElemRange & elem_range,
128 ConstBndNodeRange & bnd_node_range);
129
131 bool nodeIsNewlyReinitialized(dof_id_type node_id) const;
132
134 void applyIC();
135
138
140 ConstElemRange & reinitializedElemRange();
141
143 ConstNodeRange & reinitializedNodeRange();
144
147
149 void gatherPatchElements(const VariableName & var_name, ReinitStrategy reinit_strategy);
150
152 void extrapolatePolynomial(const VariableName & var_name);
153
156 void storeOverriddenDofValues(const VariableName & var_name);
157
159 void restoreOverriddenDofValues(const VariableName & var_name);
160
162 std::unordered_map<dof_id_type, std::pair<SubdomainID, SubdomainID>> _moved_elems;
163
166
169
172
174 std::vector<SubdomainID> _subdomain_ids_to_reinitialize;
175
178
180 typedef std::pair<SubdomainID, SubdomainID> SubdomainPair;
181 std::unordered_map<SubdomainPair, BoundaryID> _moving_boundaries;
182
184 std::unordered_map<dof_id_type, std::unordered_map<unsigned short, BoundaryID>>
186
188 std::unordered_map<dof_id_type, std::unordered_map<unsigned short, BoundaryID>>
190
192 std::unordered_map<dof_id_type, std::unordered_map<unsigned short, BoundaryID>>
194
196 std::unordered_map<dof_id_type, std::unordered_map<unsigned short, BoundaryID>>
198
200 std::unordered_set<dof_id_type> _reinitialized_elems;
202 std::unique_ptr<ConstElemRange> _reinitialized_elem_range;
203
205 std::unordered_set<dof_id_type> _semi_local_reinitialized_elems;
206
208 std::unordered_set<dof_id_type> _reinitialized_nodes;
210 std::unique_ptr<ConstNodeRange> _reinitialized_node_range;
212 std::unique_ptr<ConstBndNodeRange> _reinitialized_bnd_node_range;
213
219 std::map<VariableName, std::pair<std::vector<dof_id_type>, std::vector<Number>>>
221
223 std::vector<ReinitStrategy> _reinit_strategy;
224
226 const std::vector<UserObjectName> _pr_names;
227
229 std::vector<NodalPatchRecoveryVariable *> _pr;
230
232 std::vector<VariableName> _reinit_vars;
233
235 std::map<VariableName, unsigned int> _var_name_to_pr_idx;
236
243 std::map<unsigned int, std::pair<std::unordered_set<const Elem *>, std::vector<dof_id_type>>>
245
247 std::map<VariableName, std::vector<dof_id_type>> _patch_elem_ids;
248
254 std::vector<Point> _kd_tree_points;
258
260 std::vector<VariableName> _vars_to_restore_overridden_dofs;
261};
ReinitStrategy
Strategies for (re)initializing the solution:
A system that holds auxiliary variables.
Base class for mesh modifiers modifying element subdomains.
std::map< VariableName, std::vector< dof_id_type > > _patch_elem_ids
A map from variable names to their corresponding patch element IDs.
void applySubdomainChanges(const std::unordered_map< dof_id_type, std::pair< SubdomainID, SubdomainID > > &moved_elems, MooseMesh &mesh)
DisplacedProblem * _displaced_problem
Pointer to the displaced problem.
std::map< VariableName, std::pair< std::vector< dof_id_type >, std::vector< Number > > > _overridden_values_on_reinit_elems
A map from variable name to a pair of: (1) a vector of DOF IDs associated with non-reinitialized node...
std::unordered_map< dof_id_type, std::unordered_map< unsigned short, BoundaryID > > _add_neighbor_sides
Neighbor sides to be added.
std::unordered_map< BoundaryID, BoundaryName > _moving_boundary_names
Boundary names associated with each moving boundary ID.
void restoreOverriddenDofValues(const VariableName &var_name)
Restore values to non-reinitialized DoFs on reinitialized elements.
std::unordered_set< dof_id_type > _semi_local_reinitialized_elems
Semi-local reinitialized elements: ghosted and local reinitialized elements.
std::vector< VariableName > _vars_to_restore_overridden_dofs
List of variable names for which overridden DOF values should be restored.
void timestepSetup() override
Gets called at the beginning of the timestep before this object is asked to do its job.
void createMovingBoundaries(MooseMesh &mesh)
Create moving boundaries.
std::unordered_map< dof_id_type, std::unordered_map< unsigned short, BoundaryID > > _add_element_sides
Element sides to be added.
void findReinitializedElemsAndNodes(const std::unordered_map< dof_id_type, std::pair< SubdomainID, SubdomainID > > &moved_elems)
void meshChanged() override
Called on this object when the mesh changes.
NonlinearSystemBase & _nl_sys
Nonlinear system.
std::map< VariableName, unsigned int > _var_name_to_pr_idx
map from variable name to the index of the nodal patch recovery user object in _pr
virtual void modify(const std::unordered_map< dof_id_type, std::pair< SubdomainID, SubdomainID > > &moved_elems)
Modify the element subdomains.
std::unique_ptr< ConstBndNodeRange > _reinitialized_bnd_node_range
Range of reinitialized boundary nodes.
const std::vector< UserObjectName > _pr_names
Names of the NodalPatchRecoveryVariable user objects.
void initialSetup() override
Gets called at the beginning of the simulation before this object is asked to do its job.
void gatherMovingBoundaryChanges(const std::unordered_map< dof_id_type, std::pair< SubdomainID, SubdomainID > > &moved_elems)
void applyIC()
Reinitialize variables on range of elements and nodes to be reinitialized.
bool nodeIsNewlyReinitialized(dof_id_type node_id) const
Determine if a node is newly reinitialized.
void storeOverriddenDofValues(const VariableName &var_name)
Store values from non-reinitialized DoFs on reinitialized elements Stores the value before re-initial...
std::unordered_map< SubdomainPair, BoundaryID > _moving_boundaries
std::unique_ptr< ConstElemRange > _reinitialized_elem_range
Range of reinitialized elements.
MooseMesh * _displaced_mesh
Displaced mesh.
double _nearby_distance_threshold
Radius threshold for the k-d tree neighbor search.
bool _skip_restore_subdomain_changes
Skipping restoring the subdomain changes if the timestep is not advanced.
std::vector< SubdomainID > _subdomain_ids_to_reinitialize
Reinitialize moved elements whose new subdomain is in this list.
int & _t_step_old
Previous time step number.
std::vector< VariableName > _reinit_vars
List of variable names to be initialized for IC.
void extrapolatePolynomial(const VariableName &var_name)
Extrapolate polynomial for the given variable onto the reinitialized elements.
AuxiliarySystem & _aux_sys
Auxiliary system.
bool _restep
Whether this is a re-step.
std::vector< ReinitStrategy > _reinit_strategy
The strategies used to apply IC on newly activated elements, for each variable.
std::unordered_set< dof_id_type > _reinitialized_nodes
Reinitialized nodes.
std::vector< Point > _kd_tree_points
Centroids of all solved elements used for k-d tree construction.
const bool _old_subdomain_reinitialized
Whether to reinitialize moved elements whose old subdomain was in _reinitialize_subdomains.
std::map< unsigned int, std::pair< std::unordered_set< const Elem * >, std::vector< dof_id_type > > > _evaluable_elems
local evaluable elements before reinitializing the equation systems Key of the map is the system numb...
ConstBndNodeRange & reinitializedBndNodeRange()
Range of reinitialized boundary nodes.
std::unique_ptr< ConstNodeRange > _reinitialized_node_range
Range of reinitialized nodes.
bool subdomainIsReinitialized(SubdomainID id) const
Determine if a subdomain is to be reinitialized.
std::unordered_map< dof_id_type, std::unordered_map< unsigned short, BoundaryID > > _remove_element_sides
Element sides to be removed.
ConstElemRange & reinitializedElemRange()
Range of reinitialized elements.
void initElementStatefulProps()
Reinitialize stateful material properties on range of elements and nodes to be reinitialized.
std::unordered_map< dof_id_type, std::pair< SubdomainID, SubdomainID > > _moved_elems
Cached moved elements for potential restore.
std::unordered_set< dof_id_type > _reinitialized_elems
Reinitialized elements.
void setOldAndOlderSolutions(SystemBase &sys, ConstElemRange &elem_range, ConstBndNodeRange &bnd_node_range)
Set old and older solutions to reinitialized elements and nodes.
void setAncestorsSubdomainIDs(Elem *elem, const SubdomainID subdomain_id)
Change the subdomain ID of all ancestor elements.
std::vector< NodalPatchRecoveryVariable * > _pr
Apply initial conditions using polynomial extrapolation.
std::pair< SubdomainID, SubdomainID > SubdomainPair
Moving boundaries associated with each subdomain pair.
void gatherPatchElements(const VariableName &var_name, ReinitStrategy reinit_strategy)
Gather patch elements for reinitialized elements based on the reinitialization strategy.
std::unordered_map< dof_id_type, std::unordered_map< unsigned short, BoundaryID > > _remove_neighbor_sides
Neighbor sides to be removed.
ConstNodeRange & reinitializedNodeRange()
Range of reinitialized nodes.
void updateAMRMovingBoundary(MooseMesh &mesh)
Update boundaries for adaptive mesh from the parent to children elements.
int _leaf_max_size
KD-tree related members.
void gatherMovingBoundaryChangesHelper(const Elem *elem, unsigned short side, const Elem *neigh, unsigned short neigh_side)
void prepareVariableForReinitialization(const VariableName &var_name, ReinitStrategy reinit_strategy)
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
const InputParameters & parameters() const
Get the parameters of the object.
Definition MooseBase.h:131
MooseMesh wraps a libMesh::Mesh object and enhances its capabilities by caching additional data and s...
Definition MooseMesh.h:95
Nonlinear system to be solved.
Base class for a system (of equations)
Definition SystemBase.h:87