13 #include "libmesh/quadrature.h" 14 #include "libmesh/parallel_algebra.h" 15 #include "libmesh/parallel.h" 16 #include "libmesh/point.h" 17 #include "libmesh/dof_map.h" 19 #include "libmesh/parallel_ghost_sync.h" 20 #include "libmesh/mesh_communication.h" 29 "inactive_subdomain_id",
31 "The inactivate subdomain ID, i.e., the subdomain that you want to keep the same.");
33 "The expanded boundary name.");
44 _expand_boundary_name(getParam<
std::vector<BoundaryName>>(
"expand_boundary_name"))
64 mooseAssert(!
_disp_boundary_ids.empty(),
"Boundary ID in the displaced mesh is empty");
100 for (
unsigned int i = 0; i < ele->n_nodes(); ++i)
114 Parallel::sync_dofobject_data_by_id(
_mesh.
getMesh().comm(),
135 false,
false,
false);
156 std::set<dof_id_type> & add_set)
160 int sz = remove_set.size() + add_set.size();
161 std::vector<dof_id_type> v(sz);
162 std::vector<dof_id_type>::iterator it = std::set_difference(
163 remove_set.begin(), remove_set.end(), add_set.begin(), add_set.end(), v.begin());
164 v.resize(it - v.begin());
172 const unsigned short int side,
173 std::set<dof_id_type> & node_ids)
175 for (
unsigned int i = 0; i < ele->side_ptr(side)->n_nodes(); ++i)
176 node_ids.insert(ele->side_ptr(side)->node_id(i));
183 std::unordered_map<processor_id_type, std::vector<std::pair<dof_id_type, unsigned int>>>
184 ghost_sides_to_remove;
185 std::unordered_map<processor_id_type, std::vector<dof_id_type>> ghost_nodes_to_remove;
188 std::set<dof_id_type> add_nodes, remove_nodes;
192 Elem * ele =
mesh.elemPtr(ele_id);
193 for (
auto s : ele->side_index_range())
195 Elem * neighbor_ele = ele->neighbor_ptr(s);
196 if (neighbor_ele ==
nullptr)
214 mesh.getMesh().get_boundary_info().remove_side(ele, s);
218 unsigned int neighbor_s = neighbor_ele->which_neighbor_am_i(ele);
219 mesh.getMesh().get_boundary_info().remove_side(neighbor_ele, neighbor_s);
222 if (neighbor_ele->processor_id() != this->
processor_id())
223 ghost_sides_to_remove[neighbor_ele->processor_id()].emplace_back(neighbor_ele->id(),
237 mesh.getMesh().get_boundary_info().parallel_sync_side_ids();
238 mesh.getMesh().get_boundary_info().parallel_sync_node_ids();
245 std::unordered_map<
processor_id_type, std::vector<std::pair<dof_id_type, unsigned int>>> &
248 auto elem_action_functor =
250 const std::vector<std::pair<dof_id_type, unsigned int>> & received_elem)
253 for (
const auto & pr : received_elem)
254 mesh.getMesh().get_boundary_info().remove_side(
258 Parallel::push_parallel_vector_data(
259 mesh.getMesh().get_boundary_info().comm(), elems_to_push, elem_action_functor);
267 auto node_action_functor =
270 for (
const auto & pr : received_nodes)
273 mesh.getMesh().get_boundary_info().remove_node(
mesh.getMesh().node_ptr(pr),
278 Parallel::push_parallel_vector_data(
279 mesh.getMesh().get_boundary_info().comm(), nodes_to_push, node_action_functor);
289 std::vector<Elem *> elems;
295 Elem *
const * elempp =
const_cast<Elem *
const *
>(elems.data());
296 Elem *
const * elemend = elempp + elems.size();
298 const auto elems_begin =
301 const auto elems_end =
316 std::vector<const BndNode *> nodes;
317 std::set<const BndNode *> set_nodes;
319 for (
auto & bnode : bnd_nodes)
324 set_nodes.insert(bnode);
327 nodes.assign(set_nodes.begin(), set_nodes.end());
331 BndNode *
const * nodepp =
const_cast<BndNode *
const *
>(nodes.data());
332 BndNode *
const * nodeend = nodepp + nodes.size();
334 const auto nodes_begin =
353 std::vector<const Node *> nodes;
356 const Node *
const * elem_nodes =
_mesh.
elemPtr(elem_id)->get_nodes();
358 for (
unsigned int n = 0; n <
n_nodes; ++n)
361 const Node * nd = elem_nodes[n];
369 Node *
const * nodepp =
const_cast<Node *
const *
>(nodes.data());
370 Node *
const * nodeend = nodepp + nodes.size();
372 const auto nodes_begin =
375 const auto nodes_end =
388 auto node_to_elem_pair = node_to_elem_map.find(nd->id());
389 if (node_to_elem_pair != node_to_elem_map.end())
391 const std::vector<dof_id_type> & connected_ele_ids = node_to_elem_pair->second;
392 for (
auto connected_ele_id : connected_ele_ids)
423 DofMap & dof_map = nl.dofMap();
426 std::set<dof_id_type> dofs, dofs_aux;
428 for (
auto & elem : elem_range)
430 std::vector<dof_id_type> di, di_aux;
432 dof_map_aux.dof_indices(elem, di_aux);
433 for (
unsigned int i = 0; i < di.size(); ++i)
435 for (
unsigned int i = 0; i < di_aux.size(); ++i)
436 dofs_aux.insert(di_aux[i]);
443 for (
auto dof : dofs)
445 old_solution.
set(dof, current_solution(dof));
446 older_solution.
set(dof, current_solution(dof));
449 for (
auto dof_aux : dofs_aux)
451 old_aux_solution.
set(dof_aux, current_aux_solution(dof_aux));
452 older_aux_solution.
set(dof_aux, current_aux_solution(dof_aux));
458 current_solution.
close();
459 old_solution.
close();
460 older_solution.
close();
462 current_aux_solution.
close();
463 old_aux_solution.
close();
464 older_aux_solution.
close();
virtual void meshChanged(bool intermediate_change, bool contract_mesh, bool clean_refinement_flags)
Update data after a mesh change.
std::set< dof_id_type > _node_to_remove_from_bnd
Somes nodes are to be removed from the boundary when adding/removing sides.
std::unique_ptr< ConstBndNodeRange > _activated_bnd_node_range
void getNodesToRemoveFromBnd(std::set< dof_id_type > &remove_set, std::set< dof_id_type > &add_set)
std::shared_ptr< DisplacedProblem > displaced_problem
const unsigned int invalid_uint
std::unique_ptr< ConstElemRange > _activated_elem_range
Ranges for use with threading.
void push_boundary_node_info(MooseMesh &mesh, std::unordered_map< processor_id_type, std::vector< dof_id_type >> &nodes_to_push)
virtual Elem * elemPtr(const dof_id_type i)
void dof_indices(const Elem *const elem, std::vector< dof_id_type > &di) const
static InputParameters validParams()
void finalize() override
Finalize.
const std::vector< BoundaryName > _expand_boundary_name
expanded boundary name
BoundaryID getExpandedBoundaryID()
The definition of the const_bnd_node_iterator struct.
ConstNodeRange * getNewlyActivatedNodeRange()
ConstBndNodeRange * getNewlyActivatedBndNodeRange()
NumericVector< Number > & solutionOlder()
void initElementStatefulProps(const libMesh::ConstElemRange &elem_range, const bool threaded)
Initialize stateful properties for elements in a specific elem_range This is needed when elements/bou...
void projectInitialConditionOnCustomRange(libMesh::ConstElemRange &elem_range, ConstBndNodeRange &bnd_node_range)
Project initial conditions for custom elem_range and bnd_node_range This is needed when elements/boun...
StoredRange< MeshBase::const_element_iterator, const Elem *> ConstElemRange
virtual bool isElementActivated()=0
void execute() override
Execute method.
uint8_t processor_id_type
std::vector< BoundaryID > _boundary_ids
expanded boundary IDs
std::set< dof_id_type > _newly_activated_elem
virtual libMesh::DofMap & dofMap()
Gets writeable reference to the dof map.
ActivateElementsUserObjectBase(const InputParameters ¶meters)
const dof_id_type n_nodes
MeshBase & getMesh()
Accessor for the underlying libMesh Mesh object.
const subdomain_id_type _active_subdomain_id
activate subdomain ID
std::set< dof_id_type > _newly_activated_node
MooseMesh wraps a libMesh::Mesh object and enhances its capabilities by caching additional data and s...
virtual void restoreSolutions()
std::vector< BoundaryID > _disp_boundary_ids
void updateBoundaryInfo(MooseMesh &mesh)
NonlinearSystemBase & getNonlinearSystemBase(const unsigned int sys_num)
SystemBase & _sys
Reference to the system object for this user object.
void insertNodeIdsOnSide(const Elem *ele, const unsigned short int side, std::set< dof_id_type > &node_ids)
unsigned int number() const
Gets the number of this system.
AuxiliarySystem & getAuxiliarySystem()
static InputParameters validParams()
void setBoundaryName(BoundaryID boundary_id, BoundaryName name)
This method sets the boundary name of the boundary based on the id parameter.
virtual std::shared_ptr< const DisplacedProblem > getDisplacedProblem() const
const Elem *const & _current_elem
The current element pointer (available during execute())
FEProblemBase & _fe_problem
Reference to the FEProblemBase for this user object.
ConstElemRange * getNewlyActivatedElementRange()
Get ranges for use with threading.
std::unique_ptr< ConstNodeRange > _activated_node_range
const subdomain_id_type _inactive_subdomain_id
inactivate subdomain ID (the subdomain that you want to keep the same)
std::unique_ptr< NumericVector< Number > > current_local_solution
void push_boundary_side_info(MooseMesh &mesh, std::unordered_map< processor_id_type, std::vector< std::pair< dof_id_type, unsigned int >>> &elems_to_push)
void initSolutions(ConstElemRange &elem_range, ConstBndNodeRange &bnd_node_range)
Initialize solutions for the nodes.
virtual void set(const numeric_index_type i, const Number value)=0
virtual libMesh::System & system() override
Get the reference to the libMesh system.
std::vector< BoundaryID > getBoundaryIDs(const Elem *const elem, const unsigned short int side) const
Returns a vector of boundary IDs for the requested element on the requested side. ...
NumericVector< Number > & solutionOld()
processor_id_type processor_id() const
bool isNewlyActivated(const Node *node)
Returns true if all the connected elements are in the _newly_activated_elem.
libMesh::StoredRange< MooseMesh::const_bnd_node_iterator, const BndNode * > * getBoundaryNodeRange()
const std::map< dof_id_type, std::vector< dof_id_type > > & nodeToElemMap()
If not already created, creates a map from every node to all elements to which they are connected...