https://mooseframework.inl.gov
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
CacheInfoThread Class Reference

Fills lower-d side maps and node-to-block ownership for MooseMesh::cacheInfo(). More...

#include <CacheInfoThread.h>

Public Member Functions

 CacheInfoThread (MooseMesh &mesh, bool cache_node_blocks)
 
 CacheInfoThread (CacheInfoThread &x, Threads::split split)
 
void operator() (const ConstElemRange &range)
 
void join (const CacheInfoThread &y)
 

Protected Member Functions

void cacheNodeBlock (dof_id_type node_id, SubdomainID block_id)
 Record that an element of subdomain block_id is incident on the node node_id.
 

Protected Attributes

MooseMesh & _mesh
 
const bool _cache_node_blocks
 Whether node-to-block ownership has to be recorded at all.
 
std::unordered_map< dof_id_type, SubdomainID > _node_block
 The subdomain of the elements incident on a node, for the nodes whose incident elements all agree, which is every node away from a subdomain interface.
 
std::unordered_map< dof_id_type, std::set< SubdomainID > > _interface_node_blocks
 The full subdomain set of the nodes whose incident elements disagree, that is the nodes on a subdomain interface.
 
std::set< SubdomainID > _lower_d_interior_blocks
 
std::set< SubdomainID > _lower_d_boundary_blocks
 
std::unordered_map< std::pair< const Elem *, unsigned short int >, const Elem * > _higher_d_elem_side_to_lower_d_elem
 
std::unordered_map< const Elem *, unsigned short int > _lower_d_elem_to_higher_d_elem_side
 

Friends

class MooseMesh
 

Detailed Description

Fills lower-d side maps and node-to-block ownership for MooseMesh::cacheInfo().

The range is all elements this rank knows about (local and ghosted).

Definition at line 21 of file CacheInfoThread.h.

Constructor & Destructor Documentation

◆ CacheInfoThread() [1/2]

CacheInfoThread::CacheInfoThread ( MooseMesh &  mesh,
bool  cache_node_blocks 
)
Parameters
cache_node_blocksWhether to record node-to-block ownership. MooseMesh::cacheInfo() passes false when the relation is constant, i.e. when the mesh has a single subdomain.

Definition at line 15 of file CacheInfoThread.C.

16 : _mesh(mesh), _cache_node_blocks(cache_node_blocks)
17{
18}
const bool _cache_node_blocks
Whether node-to-block ownership has to be recorded at all.
MooseMesh & _mesh

◆ CacheInfoThread() [2/2]

CacheInfoThread::CacheInfoThread ( CacheInfoThread &  x,
Threads::split  split 
)

Definition at line 20 of file CacheInfoThread.C.

Member Function Documentation

◆ cacheNodeBlock()

void CacheInfoThread::cacheNodeBlock ( dof_id_type  node_id,
SubdomainID  block_id 
)
protected

Record that an element of subdomain block_id is incident on the node node_id.

Each node is a key in exactly one of _node_block and _interface_node_blocks: it stays in _node_block while every recorded subdomain for the given node_id matches, and the first mismatching subdomain moves it to _interface_node_blocks with both subdomains.

Definition at line 26 of file CacheInfoThread.C.

27{
28 // Most calls revisit a node away from any interface, which this single lookup settles
29 if (const auto it = _node_block.find(node_id); it != _node_block.end())
30 {
31 if (it->second == block_id)
32 return;
33
34 // The elements incident on this node disagree, so it needs the full set from here on
35 _interface_node_blocks.emplace(node_id, std::set<SubdomainID>{it->second, block_id});
36 _node_block.erase(it);
37 return;
38 }
39
40 if (const auto it = _interface_node_blocks.find(node_id); it != _interface_node_blocks.end())
41 it->second.insert(block_id);
42 else
43 _node_block.emplace(node_id, block_id);
44}
std::unordered_map< dof_id_type, SubdomainID > _node_block
The subdomain of the elements incident on a node, for the nodes whose incident elements all agree,...
std::unordered_map< dof_id_type, std::set< SubdomainID > > _interface_node_blocks
The full subdomain set of the nodes whose incident elements disagree, that is the nodes on a subdomai...

Referenced by join(), and operator()().

◆ join()

void CacheInfoThread::join ( const CacheInfoThread &  y)

Definition at line 93 of file CacheInfoThread.C.

94{
95 // Adding y's entries through cacheNodeBlock() keeps each node in only one of _node_block and
96 // _interface_node_blocks: a node that each thread saw with a single, but different, subdomain
97 // becomes an interface node here
98 for (const auto & [node_id, block_id] : y._node_block)
99 cacheNodeBlock(node_id, block_id);
100 for (const auto & [node_id, block_ids] : y._interface_node_blocks)
101 for (const auto block_id : block_ids)
102 cacheNodeBlock(node_id, block_id);
103
112}
for(PetscInt i=0;i< nvars;++i)
std::unordered_map< std::pair< const Elem *, unsigned short int >, const Elem * > _higher_d_elem_side_to_lower_d_elem
std::unordered_map< const Elem *, unsigned short int > _lower_d_elem_to_higher_d_elem_side
void cacheNodeBlock(dof_id_type node_id, SubdomainID block_id)
Record that an element of subdomain block_id is incident on the node node_id.
std::set< SubdomainID > _lower_d_interior_blocks
std::set< SubdomainID > _lower_d_boundary_blocks

◆ operator()()

void CacheInfoThread::operator() ( const ConstElemRange &  range)

Definition at line 47 of file CacheInfoThread.C.

48{
49 const auto & mesh = _mesh.getMesh();
50
51 for (const auto & elem : range)
52 {
53 const Elem * ip_elem = elem->interior_parent();
54
55 if (ip_elem)
56 {
57 unsigned int ip_side = ip_elem->which_side_am_i(elem);
58
59 // For some grid sequencing tests: ip_side == libMesh::invalid_uint
60 if (ip_side != libMesh::invalid_uint)
61 {
62 auto pair = std::make_pair(ip_elem, static_cast<unsigned short int>(ip_side));
63 _higher_d_elem_side_to_lower_d_elem.emplace(pair, elem);
64 _lower_d_elem_to_higher_d_elem_side.emplace(elem, pair.second);
65
66 auto id = elem->subdomain_id();
67 if (ip_elem->neighbor_ptr(ip_side))
68 {
69 if (mesh.subdomain_name(id).find("INTERNAL_SIDE_LOWERD_SUBDOMAIN_") != std::string::npos)
70 _lower_d_interior_blocks.insert(id);
71 }
72 else
73 {
74 if (mesh.subdomain_name(id).find("BOUNDARY_SIDE_LOWERD_SUBDOMAIN_") != std::string::npos)
75 _lower_d_boundary_blocks.insert(id);
76 }
77 }
78 }
79
81 {
82 const auto block_id = elem->subdomain_id();
83 for (const auto nd : make_range(elem->n_nodes()))
84 {
85 const Node & node = *elem->node_ptr(nd);
86 cacheNodeBlock(node.id(), block_id);
87 }
88 }
89 }
90}
MeshBase & getMesh()
Accessor for the underlying libMesh Mesh object.
Definition MooseMesh.C:3535
MeshBase & mesh
const unsigned int invalid_uint
IntRange< T > make_range(T beg, T end)
const dof_id_type n_nodes

Friends And Related Symbol Documentation

◆ MooseMesh

friend class MooseMesh
friend

Definition at line 64 of file CacheInfoThread.h.

Member Data Documentation

◆ _cache_node_blocks

const bool CacheInfoThread::_cache_node_blocks
protected

Whether node-to-block ownership has to be recorded at all.

Definition at line 47 of file CacheInfoThread.h.

Referenced by operator()().

◆ _higher_d_elem_side_to_lower_d_elem

std::unordered_map<std::pair<const Elem *, unsigned short int>, const Elem *> CacheInfoThread::_higher_d_elem_side_to_lower_d_elem
protected

Definition at line 61 of file CacheInfoThread.h.

Referenced by join(), and operator()().

◆ _interface_node_blocks

std::unordered_map<dof_id_type, std::set<SubdomainID> > CacheInfoThread::_interface_node_blocks
protected

The full subdomain set of the nodes whose incident elements disagree, that is the nodes on a subdomain interface.

Interface nodes are typically a small fraction of the mesh, so storing a set for each of them costs little.

Definition at line 56 of file CacheInfoThread.h.

Referenced by MooseMesh::cacheInfo(), cacheNodeBlock(), and join().

◆ _lower_d_boundary_blocks

std::set<SubdomainID> CacheInfoThread::_lower_d_boundary_blocks
protected

Definition at line 59 of file CacheInfoThread.h.

Referenced by join(), and operator()().

◆ _lower_d_elem_to_higher_d_elem_side

std::unordered_map<const Elem *, unsigned short int> CacheInfoThread::_lower_d_elem_to_higher_d_elem_side
protected

Definition at line 62 of file CacheInfoThread.h.

Referenced by join(), and operator()().

◆ _lower_d_interior_blocks

std::set<SubdomainID> CacheInfoThread::_lower_d_interior_blocks
protected

Definition at line 58 of file CacheInfoThread.h.

Referenced by join(), and operator()().

◆ _mesh

MooseMesh& CacheInfoThread::_mesh
protected

Definition at line 44 of file CacheInfoThread.h.

Referenced by operator()().

◆ _node_block

std::unordered_map<dof_id_type, SubdomainID> CacheInfoThread::_node_block
protected

The subdomain of the elements incident on a node, for the nodes whose incident elements all agree, which is every node away from a subdomain interface.

Definition at line 51 of file CacheInfoThread.h.

Referenced by MooseMesh::cacheInfo(), cacheNodeBlock(), and join().


The documentation for this class was generated from the following files: