https://mooseframework.inl.gov
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"
15 
20 {
21 public:
23 
25 
26  virtual void initialSetup() override;
27  virtual void meshChanged() override;
28 
29 protected:
47  virtual void
48  modify(const std::unordered_map<dof_id_type, std::pair<SubdomainID, SubdomainID>> & moved_elems);
49 
52 
55 
58 
60  std::unordered_map<BoundaryID, BoundaryName> _moving_boundary_names;
61 
62 private:
64  void createMovingBoundaries(MooseMesh & mesh);
65 
67  const std::unordered_map<dof_id_type, std::pair<SubdomainID, SubdomainID>> & moved_elems,
68  MooseMesh & mesh);
69 
71  void setAncestorsSubdomainIDs(Elem * elem, const SubdomainID subdomain_id);
72 
74  const std::unordered_map<dof_id_type, std::pair<SubdomainID, SubdomainID>> & moved_elems);
75 
76  void gatherMovingBoundaryChangesHelper(const Elem * elem,
77  unsigned short side,
78  const Elem * neigh,
79  unsigned short neigh_side);
80 
82 
85 
87  const std::unordered_map<dof_id_type, std::pair<SubdomainID, SubdomainID>> & moved_elems);
88 
91  ConstElemRange & elem_range,
92  ConstBndNodeRange & bnd_node_range);
93 
95  bool nodeIsNewlyReinitialized(dof_id_type node_id) const;
96 
98  void applyIC(bool displaced);
99 
101  void initElementStatefulProps(bool displaced);
102 
104  ConstElemRange & reinitializedElemRange(bool displaced = false);
105 
107  ConstBndNodeRange & reinitializedBndNodeRange(bool displaced = false);
108 
110  std::vector<SubdomainID> _subdomain_ids_to_reinitialize;
111 
114 
116  typedef std::pair<SubdomainID, SubdomainID> SubdomainPair;
117  std::unordered_map<SubdomainPair, BoundaryID> _moving_boundaries;
118 
120  std::unordered_map<dof_id_type, std::unordered_map<unsigned short, BoundaryID>>
122 
124  std::unordered_map<dof_id_type, std::unordered_map<unsigned short, BoundaryID>>
126 
128  std::unordered_map<dof_id_type, std::unordered_map<unsigned short, BoundaryID>>
130 
132  std::unordered_map<dof_id_type, std::unordered_map<unsigned short, BoundaryID>>
134 
136  std::unordered_set<dof_id_type> _reinitialized_elems;
138  std::unique_ptr<ConstElemRange> _reinitialized_elem_range;
140  std::unique_ptr<ConstElemRange> _reinitialized_displaced_elem_range;
141 
143  std::unordered_set<dof_id_type> _reinitialized_nodes;
145  std::unique_ptr<ConstBndNodeRange> _reinitialized_bnd_node_range;
147  std::unique_ptr<ConstBndNodeRange> _reinitialized_displaced_bnd_node_range;
148 };
std::unique_ptr< ConstBndNodeRange > _reinitialized_displaced_bnd_node_range
Range of reinitialized boundary nodes on the displaced mesh.
DisplacedProblem * _displaced_problem
Pointer to the displaced problem.
std::unordered_set< dof_id_type > _reinitialized_elems
Reinitialized elements.
std::pair< SubdomainID, SubdomainID > SubdomainPair
Moving boundaries associated with each subdomain pair.
std::unordered_map< BoundaryID, BoundaryName > _moving_boundary_names
Boundary names associated with each moving boundary ID.
void gatherMovingBoundaryChanges(const std::unordered_map< dof_id_type, std::pair< SubdomainID, SubdomainID >> &moved_elems)
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
Base class for a system (of equations)
Definition: SystemBase.h:84
void gatherMovingBoundaryChangesHelper(const Elem *elem, unsigned short side, const Elem *neigh, unsigned short neigh_side)
virtual void initialSetup() override
Gets called at the beginning of the simulation before this object is asked to do its job...
StoredRange< MeshBase::const_element_iterator, const Elem *> ConstElemRange
void updateAMRMovingBoundary(MooseMesh &mesh)
Update boundaries for adaptive mesh from the parent to children elements.
void applyIC(bool displaced)
Reinitialize variables on range of elements and nodes to be reinitialized.
virtual void modify(const std::unordered_map< dof_id_type, std::pair< SubdomainID, SubdomainID >> &moved_elems)
Modify the element subdomains.
void createMovingBoundaries(MooseMesh &mesh)
Create moving boundaries.
ConstElemRange & reinitializedElemRange(bool displaced=false)
Range of reinitialized elements.
virtual void meshChanged() override
Called on this object when the mesh changes.
void setAncestorsSubdomainIDs(Elem *elem, const SubdomainID subdomain_id)
Change the subdomain ID of all ancestor elements.
void applySubdomainChanges(const std::unordered_map< dof_id_type, std::pair< SubdomainID, SubdomainID >> &moved_elems, MooseMesh &mesh)
std::unordered_set< dof_id_type > _reinitialized_nodes
Reinitialized nodes.
MooseMesh wraps a libMesh::Mesh object and enhances its capabilities by caching additional data and s...
Definition: MooseMesh.h:88
std::unique_ptr< ConstElemRange > _reinitialized_displaced_elem_range
Range of reinitialized elements on the displaced mesh.
bool subdomainIsReinitialized(SubdomainID id) const
Determine if a subdomain is to be reinitialized.
std::vector< SubdomainID > _subdomain_ids_to_reinitialize
Reinitialize moved elements whose new subdomain is in this list.
std::unordered_map< dof_id_type, std::unordered_map< unsigned short, BoundaryID > > _add_element_sides
Element sides to be added.
void initElementStatefulProps(bool displaced)
Reinitialize stateful material properties on range of elements and nodes to be reinitialized.
std::unordered_map< dof_id_type, std::unordered_map< unsigned short, BoundaryID > > _remove_element_sides
Element sides to be removed.
void applyMovingBoundaryChanges(MooseMesh &mesh)
bool nodeIsNewlyReinitialized(dof_id_type node_id) const
Determine if a node is newly reinitialized.
std::unique_ptr< ConstBndNodeRange > _reinitialized_bnd_node_range
Range of reinitialized boundary nodes.
MooseMesh * _displaced_mesh
Displaced mesh.
ConstBndNodeRange & reinitializedBndNodeRange(bool displaced=false)
Range of reinitialized boundary nodes.
std::unique_ptr< ConstElemRange > _reinitialized_elem_range
Range of reinitialized elements.
const InputParameters & parameters() const
Get the parameters of the object.
Base class for mesh modifiers modifying element subdomains.
void setOldAndOlderSolutions(SystemBase &sys, ConstElemRange &elem_range, ConstBndNodeRange &bnd_node_range)
Set old and older solutions to reinitialized elements and nodes.
void findReinitializedElemsAndNodes(const std::unordered_map< dof_id_type, std::pair< SubdomainID, SubdomainID >> &moved_elems)
std::unordered_map< SubdomainPair, BoundaryID > _moving_boundaries
std::unordered_map< dof_id_type, std::unordered_map< unsigned short, BoundaryID > > _remove_neighbor_sides
Neighbor sides to be removed.
std::unordered_map< dof_id_type, std::unordered_map< unsigned short, BoundaryID > > _add_neighbor_sides
Neighbor sides to be added.
ElementSubdomainModifierBase(const InputParameters &parameters)
const bool _old_subdomain_reinitialized
Whether to reinitialize moved elements whose old subdomain was in _reinitialize_subdomains.
uint8_t dof_id_type