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

Builds mapping between a 1D/2D boundary and a 3D boundary. More...

#include <MeshAlignmentOneToMany.h>

Inheritance diagram for MeshAlignmentOneToMany:
[legend]

Public Member Functions

 MeshAlignmentOneToMany (const MooseMesh &mesh)
 Constructor.
 
bool hasCoupledPrimaryElemID (const dof_id_type &secondary_elem_id) const
 Returns true if the given secondary element ID has a coupled primary element.
 
dof_id_type getCoupledPrimaryElemID (const dof_id_type &secondary_elem_id) const
 Gets the coupled primary element ID for a given secondary element ID.
 
bool hasCoupledSecondaryElemIDs (const dof_id_type &primary_elem_id) const
 Returns true if the given primary element ID has coupled secondary elements.
 
const std::vector< dof_id_type > & getCoupledSecondaryElemIDs (const dof_id_type &primary_elem_id) const
 Gets the coupled secondary element IDs for a given primary element ID.
 
unsigned int getPrimaryNumberOfQuadraturePoints () const
 Gets the number of quadrature points for faces on the primary boundary.
 
unsigned int getSecondaryNumberOfQuadraturePoints () const
 Gets the number of quadrature points for faces on the secondary boundary.
 
unsigned int getCoupledPrimaryElemQpIndex (const dof_id_type &secondary_elem_id, const unsigned int &secondary_qp) const
 Gets the quadrature point index on the primary element corresponding to the quadrature point index on the provided secondary element.
 
unsigned int getMaxCouplingSize () const
 Gets the maximum number of secondary elements coupled to any primary element.
 
const std::vector< dof_id_type > & getPrimaryElemIDs () const
 Returns the list of element IDs on the primary boundary.
 
const std::vector< dof_id_type > & getSecondaryElemIDs () const
 Returns the list of element IDs on the secondary boundary.
 
bool meshesAreAligned () const
 Returns true if the primary and secondary meshes are aligned.
 

Protected Member Functions

void buildMapping ()
 Builds the mapping using the extracted mesh information.
 
void checkAlignment (const Point &axis_point, const RealVectorValue &axis_direction)
 Checks the alignment and sets _mesh_alignment accordingly.
 
void extractFrom1DElements (const std::vector< dof_id_type > &elem_ids, std::vector< Point > &elem_points, std::vector< dof_id_type > &node_ids, std::vector< Point > &node_points) const
 Extracts mesh information from 1D elements.
 
void extractFromBoundaryInfo (const std::vector< std::tuple< dof_id_type, unsigned short int > > &boundary_info, std::vector< dof_id_type > &elem_ids, std::vector< unsigned short int > &side_ids, std::vector< Point > &side_points, std::vector< dof_id_type > &node_ids, std::vector< Point > &node_points) const
 Extracts mesh information from boundary info.
 

Protected Attributes

std::map< dof_id_type, std::vector< dof_id_type > > _primary_elem_id_to_secondary_elem_ids
 Map of primary element ID to coupled secondary element IDs.
 
std::map< dof_id_type, dof_id_type > _secondary_elem_id_to_primary_elem_id
 Map of secondary element ID to coupled primary element ID.
 
std::map< dof_id_type, std::vector< unsigned int > > _secondary_elem_id_to_qp_indices
 Map of secondary element ID to vector of coupled quadrature points.
 
unsigned int _n_qp_primary
 Number of quadrature points for faces on the primary boundary.
 
unsigned int _n_qp_secondary
 Number of quadrature points for faces on the secondary boundary.
 
unsigned long _max_coupling_size
 The maximum number of secondary elements coupled to any primary element.
 
const MooseMesh_mesh
 Mesh.
 
std::vector< dof_id_type > _primary_elem_ids
 List of primary element IDs.
 
std::vector< dof_id_type > _secondary_elem_ids
 List of secondary element IDs.
 
std::vector< Point > _primary_elem_points
 List of primary element points.
 
std::vector< Point > _secondary_elem_points
 List of secondary element points.
 
std::vector< unsigned short int_primary_side_ids
 List of primary side IDs (if any)
 
std::vector< unsigned short int_secondary_side_ids
 List of secondary side IDs (if any)
 
std::vector< dof_id_type > _primary_node_ids
 List of primary node IDs.
 
std::vector< dof_id_type > _secondary_node_ids
 List of secondary node IDs.
 
std::vector< Point > _primary_node_points
 List of primary node points.
 
std::vector< Point > _secondary_node_points
 List of secondary node points.
 
bool _meshes_are_aligned
 Flag that meshes are aligned.
 

Detailed Description

Builds mapping between a 1D/2D boundary and a 3D boundary.

The "primary" mesh is the 1D/2D boundary, and the "secondary" mesh is the 3D boundary.

Definition at line 19 of file MeshAlignmentOneToMany.h.

Constructor & Destructor Documentation

◆ MeshAlignmentOneToMany()

MeshAlignmentOneToMany::MeshAlignmentOneToMany ( const MooseMesh mesh)

Constructor.

Parameters
mesh[in]mesh Mesh

Definition at line 14 of file MeshAlignmentOneToMany.C.

16{
17}
Builds mapping between two aligned subdomains/boundaries.
unsigned long _max_coupling_size
The maximum number of secondary elements coupled to any primary element.

Member Function Documentation

◆ buildMapping()

void MeshAlignmentOneToMany::buildMapping ( )
protected

Builds the mapping using the extracted mesh information.

Definition at line 20 of file MeshAlignmentOneToMany.C.

21{
22 // Build the element mapping
23 if (_primary_elem_points.size() > 0 && _secondary_elem_points.size() > 0)
24 {
25 // find the primary elements that are nearest to the secondary elements
27 for (std::size_t i_secondary = 0; i_secondary < _secondary_elem_points.size(); i_secondary++)
28 {
29 unsigned int patch_size = 1;
30 std::vector<std::size_t> return_index(patch_size);
31 kd_tree.neighborSearch(_secondary_elem_points[i_secondary], patch_size, return_index);
32 const std::size_t i_primary = return_index[0];
33
34 const auto primary_elem_id = _primary_elem_ids[i_primary];
35 const auto secondary_elem_id = _secondary_elem_ids[i_secondary];
36
37 _secondary_elem_id_to_primary_elem_id[secondary_elem_id] = primary_elem_id;
38
39 auto it = _primary_elem_id_to_secondary_elem_ids.find(primary_elem_id);
41 _primary_elem_id_to_secondary_elem_ids.insert({primary_elem_id, {secondary_elem_id}});
42 else
43 it->second.push_back(secondary_elem_id);
44 }
45
46 // Determine max coupling size
47 for (const auto primary_elem_id : _primary_elem_ids)
48 if (hasCoupledSecondaryElemIDs(primary_elem_id))
49 {
50 const auto & secondary_elem_ids = getCoupledSecondaryElemIDs(primary_elem_id);
51 _max_coupling_size = std::max(secondary_elem_ids.size(), _max_coupling_size);
52 }
53 }
54}
const MooseMesh & _mesh
Mesh.
std::vector< dof_id_type > _primary_elem_ids
List of primary element IDs.
std::vector< Point > _primary_elem_points
List of primary element points.
std::vector< Point > _secondary_elem_points
List of secondary element points.
std::vector< dof_id_type > _secondary_elem_ids
List of secondary element IDs.
bool hasCoupledSecondaryElemIDs(const dof_id_type &primary_elem_id) const
Returns true if the given primary element ID has coupled secondary elements.
std::map< dof_id_type, std::vector< dof_id_type > > _primary_elem_id_to_secondary_elem_ids
Map of primary element ID to coupled secondary element IDs.
const std::vector< dof_id_type > & getCoupledSecondaryElemIDs(const dof_id_type &primary_elem_id) const
Gets the coupled secondary element IDs for a given primary element ID.
std::map< dof_id_type, dof_id_type > _secondary_elem_id_to_primary_elem_id
Map of secondary element ID to coupled primary element ID.
unsigned int getMaxLeafSize() const
if(subdm)

Referenced by MeshAlignment1D3D::initialize(), MeshAlignment2D3D::initialize(), and MeshAlignment2D2D::initialize().

◆ checkAlignment()

void MeshAlignmentOneToMany::checkAlignment ( const Point &  axis_point,
const RealVectorValue &  axis_direction 
)
protected

Checks the alignment and sets _mesh_alignment accordingly.

Parameters
[in]axis_pointAny point on the axis of the 1D or 2D boundary
[in]axis_directionDirection of the axis for the 1D or 2D boundary

Definition at line 57 of file MeshAlignmentOneToMany.C.

59{
60 if (_primary_elem_points.size() > 0 && _secondary_elem_points.size() > 0)
61 {
62 // Check if meshes are aligned: all secondary boundary faces paired to a
63 // primary element/face must have the same axial coordinate.
65 for (const auto i_primary : index_range(_primary_elem_ids))
66 {
67 const auto primary_elem_id = _primary_elem_ids[i_primary];
68 const auto primary_elem_point = _primary_elem_points[i_primary];
69 const auto primary_ax_coord = axis_direction * (primary_elem_point - axis_point);
70
71 if (hasCoupledSecondaryElemIDs(primary_elem_id))
72 {
73 const auto & secondary_elem_ids = getCoupledSecondaryElemIDs(primary_elem_id);
74 for (const auto secondary_elem_id : secondary_elem_ids)
75 {
76 auto it =
77 std::find(_secondary_elem_ids.begin(), _secondary_elem_ids.end(), secondary_elem_id);
78 const auto i_secondary = std::distance(_secondary_elem_ids.begin(), it);
79 const auto secondary_elem_point = _secondary_elem_points[i_secondary];
80 const auto secondary_ax_coord = axis_direction * (secondary_elem_point - axis_point);
81 if (!MooseUtils::absoluteFuzzyEqual(secondary_ax_coord, primary_ax_coord))
82 _meshes_are_aligned = false;
83 }
84 }
85 else
86 _meshes_are_aligned = false;
87 }
88 }
89}
bool _meshes_are_aligned
Flag that meshes are aligned.
auto index_range(const T &sizable)

Referenced by MeshAlignment2D3D::initialize(), and MeshAlignment2D2D::initialize().

◆ extractFrom1DElements()

void MeshAlignmentBase::extractFrom1DElements ( const std::vector< dof_id_type > &  elem_ids,
std::vector< Point > &  elem_points,
std::vector< dof_id_type > &  node_ids,
std::vector< Point > &  node_points 
) const
protectedinherited

Extracts mesh information from 1D elements.

Parameters
[in]elem_idsVector of element IDs
[out]elem_pointsVector of element centroids
[out]node_idsVector of node IDs
[out]node_pointsVector of node points

Definition at line 20 of file MeshAlignmentBase.C.

24{
25 elem_points.clear();
26 node_ids.clear();
27 node_points.clear();
28
29 for (const auto & elem_id : elem_ids)
30 {
31 const Elem * elem = _mesh.elemPtr(elem_id);
32 elem_points.push_back(elem->vertex_average());
33
34 for (const auto j : elem->node_index_range())
35 {
36 const Node & node = elem->node_ref(j);
37 const auto node_id = node.id();
38 if (std::find(node_ids.begin(), node_ids.end(), node_id) == node_ids.end())
39 {
40 node_ids.push_back(node_id);
41 node_points.push_back(node);
42 }
43 }
44 }
45}
virtual Elem * elemPtr(const dof_id_type i)

Referenced by MeshAlignment::initialize(), and MeshAlignment1D3D::initialize().

◆ extractFromBoundaryInfo()

void MeshAlignmentBase::extractFromBoundaryInfo ( const std::vector< std::tuple< dof_id_type, unsigned short int > > &  boundary_info,
std::vector< dof_id_type > &  elem_ids,
std::vector< unsigned short int > &  side_ids,
std::vector< Point > &  side_points,
std::vector< dof_id_type > &  node_ids,
std::vector< Point > &  node_points 
) const
protectedinherited

Extracts mesh information from boundary info.

Parameters
[in]boundary_infoVector of tuples of element ID and side ID on boundary
[out]elem_idsVector of element IDs
[out]side_idsVector of side IDs
[out]side_pointsVector of side centroids
[out]node_idsVector of node IDs
[out]node_pointsVector of node points

Definition at line 48 of file MeshAlignmentBase.C.

55{
56 elem_ids.clear();
57 side_ids.clear();
58 side_points.clear();
59 node_ids.clear();
60 node_points.clear();
61
62 for (const auto & elem_id_and_side : boundary_info)
63 {
64 auto elem_id = std::get<0>(elem_id_and_side);
65 elem_ids.push_back(elem_id);
66
67 auto side = std::get<1>(elem_id_and_side);
68 side_ids.push_back(side);
69
70 const Elem * elem = _mesh.elemPtr(elem_id);
71 const Elem * side_elem = elem->build_side_ptr(side).release();
72 const Point side_center = side_elem->vertex_average();
73 side_points.push_back(side_center);
74
75 for (const auto j : side_elem->node_index_range())
76 {
77 const Node & node = side_elem->node_ref(j);
78 const auto node_id = node.id();
79 if (std::find(node_ids.begin(), node_ids.end(), node_id) == node_ids.end())
80 {
81 node_ids.push_back(node_id);
82 node_points.push_back(node);
83 }
84 }
85 delete side_elem;
86 }
87}

Referenced by MeshAlignment::initialize(), MeshAlignment1D3D::initialize(), MeshAlignment::initialize(), MeshAlignment2D3D::initialize(), and MeshAlignment2D2D::initialize().

◆ getCoupledPrimaryElemID()

dof_id_type MeshAlignmentOneToMany::getCoupledPrimaryElemID ( const dof_id_type &  secondary_elem_id) const

Gets the coupled primary element ID for a given secondary element ID.

Parameters
[in]secondary_elem_idSecondary element ID for which to find the coupled primary element ID

Definition at line 99 of file MeshAlignmentOneToMany.C.

100{
101 mooseAssert(hasCoupledPrimaryElemID(secondary_elem_id),
102 "The element ID has no coupled elements.");
103 return _secondary_elem_id_to_primary_elem_id.find(secondary_elem_id)->second;
104}
bool hasCoupledPrimaryElemID(const dof_id_type &secondary_elem_id) const
Returns true if the given secondary element ID has a coupled primary element.

Referenced by MeshAlignment2D3D::buildCoupledElemQpIndexMapSecondary(), HSCoupler2D3DUserObject::execute(), and HSCoupler2D3D::setupMesh().

◆ getCoupledPrimaryElemQpIndex()

unsigned int MeshAlignmentOneToMany::getCoupledPrimaryElemQpIndex ( const dof_id_type &  secondary_elem_id,
const unsigned int secondary_qp 
) const

Gets the quadrature point index on the primary element corresponding to the quadrature point index on the provided secondary element.

Only secondary elements corresponding to local primary elements may be queried.

Parameters
[in]secondary_elem_idSecondary element ID for which to find the coupled quadrature point
[in]secondary_qpQuadrature point index on the given secondary element

Definition at line 122 of file MeshAlignmentOneToMany.C.

124{
125 auto it = _secondary_elem_id_to_qp_indices.find(secondary_elem_id);
126 mooseAssert(it != _secondary_elem_id_to_qp_indices.end(),
127 "The element ID has no coupled quadrature point indices.");
128 mooseAssert(secondary_qp < it->second.size(), "The quadrature index does not exist in the map.");
129 return it->second[secondary_qp];
130}
std::map< dof_id_type, std::vector< unsigned int > > _secondary_elem_id_to_qp_indices
Map of secondary element ID to vector of coupled quadrature points.

Referenced by ADHeatTransferFromHeatStructure3D1PhaseUserObject::execute(), and HSCoupler2D3DUserObject::execute().

◆ getCoupledSecondaryElemIDs()

const std::vector< dof_id_type > & MeshAlignmentOneToMany::getCoupledSecondaryElemIDs ( const dof_id_type &  primary_elem_id) const

Gets the coupled secondary element IDs for a given primary element ID.

Parameters
[in]primary_elem_idPrimary element ID for which to find the coupled secondary element IDs

Definition at line 114 of file MeshAlignmentOneToMany.C.

115{
116 mooseAssert(hasCoupledSecondaryElemIDs(primary_elem_id),
117 "The element ID has no coupled elements.");
118 return _primary_elem_id_to_secondary_elem_ids.find(primary_elem_id)->second;
119}

Referenced by MeshAlignment1D3D::buildCoupledElemQpIndexMap(), buildMapping(), checkAlignment(), ADHeatTransferFromHeatStructure3D1PhaseUserObject::execute(), HSCoupler2D2DRadiationUserObject::execute(), HeatTransferFromHeatStructure3D1Phase::setupMesh(), and HSCoupler2D2DRadiation::setupMesh().

◆ getMaxCouplingSize()

unsigned int MeshAlignmentOneToMany::getMaxCouplingSize ( ) const
inline

Gets the maximum number of secondary elements coupled to any primary element.

Definition at line 88 of file MeshAlignmentOneToMany.h.

88{ return _max_coupling_size; }

Referenced by HSCoupler2D3D::check().

◆ getPrimaryElemIDs()

const std::vector< dof_id_type > & MeshAlignmentBase::getPrimaryElemIDs ( ) const
inlineinherited

Returns the list of element IDs on the primary boundary.

Definition at line 34 of file MeshAlignmentBase.h.

34{ return _primary_elem_ids; }

Referenced by HeatStructure2DCouplerBase::setupMesh(), HeatTransferFromHeatStructure1Phase::setupMesh(), and HSCoupler2D2DRadiation::setupMesh().

◆ getPrimaryNumberOfQuadraturePoints()

unsigned int MeshAlignmentOneToMany::getPrimaryNumberOfQuadraturePoints ( ) const
inline

Gets the number of quadrature points for faces on the primary boundary.

Definition at line 65 of file MeshAlignmentOneToMany.h.

65{ return _n_qp_primary; }
unsigned int _n_qp_primary
Number of quadrature points for faces on the primary boundary.

Referenced by HSCoupler2D3DUserObject::execute().

◆ getSecondaryElemIDs()

const std::vector< dof_id_type > & MeshAlignmentBase::getSecondaryElemIDs ( ) const
inlineinherited

Returns the list of element IDs on the secondary boundary.

Definition at line 39 of file MeshAlignmentBase.h.

39{ return _secondary_elem_ids; }

Referenced by HSCoupler2D3D::setupMesh().

◆ getSecondaryNumberOfQuadraturePoints()

unsigned int MeshAlignmentOneToMany::getSecondaryNumberOfQuadraturePoints ( ) const
inline

Gets the number of quadrature points for faces on the secondary boundary.

Definition at line 70 of file MeshAlignmentOneToMany.h.

70{ return _n_qp_secondary; }
unsigned int _n_qp_secondary
Number of quadrature points for faces on the secondary boundary.

Referenced by ADHeatTransferFromHeatStructure3D1PhaseUserObject::execute().

◆ hasCoupledPrimaryElemID()

bool MeshAlignmentOneToMany::hasCoupledPrimaryElemID ( const dof_id_type &  secondary_elem_id) const

Returns true if the given secondary element ID has a coupled primary element.

Parameters
[in]secondary_elem_idSecondary element ID for which to find the coupled primary element ID

Definition at line 92 of file MeshAlignmentOneToMany.C.

93{
94 return _secondary_elem_id_to_primary_elem_id.find(secondary_elem_id) !=
96}

Referenced by getCoupledPrimaryElemID(), and HSCoupler2D3D::setupMesh().

◆ hasCoupledSecondaryElemIDs()

bool MeshAlignmentOneToMany::hasCoupledSecondaryElemIDs ( const dof_id_type &  primary_elem_id) const

Returns true if the given primary element ID has coupled secondary elements.

Parameters
[in]primary_elem_idPrimary element ID for which to find the coupled secondary element IDs

Definition at line 107 of file MeshAlignmentOneToMany.C.

108{
109 return _primary_elem_id_to_secondary_elem_ids.find(primary_elem_id) !=
111}

Referenced by buildMapping(), checkAlignment(), getCoupledSecondaryElemIDs(), and HeatTransferFromHeatStructure3D1Phase::setupMesh().

◆ meshesAreAligned()

bool MeshAlignmentBase::meshesAreAligned ( ) const
inlineinherited

Member Data Documentation

◆ _max_coupling_size

unsigned long MeshAlignmentOneToMany::_max_coupling_size
protected

The maximum number of secondary elements coupled to any primary element.

Definition at line 117 of file MeshAlignmentOneToMany.h.

Referenced by buildMapping(), and getMaxCouplingSize().

◆ _mesh

const MooseMesh& MeshAlignmentBase::_mesh
protectedinherited

◆ _meshes_are_aligned

bool MeshAlignmentBase::_meshes_are_aligned
protectedinherited

Flag that meshes are aligned.

Definition at line 105 of file MeshAlignmentBase.h.

Referenced by MeshAlignment::buildMapping(), checkAlignment(), and MeshAlignmentBase::meshesAreAligned().

◆ _n_qp_primary

unsigned int MeshAlignmentOneToMany::_n_qp_primary
protected

Number of quadrature points for faces on the primary boundary.

Definition at line 112 of file MeshAlignmentOneToMany.h.

Referenced by MeshAlignment1D3D::buildCoupledElemQpIndexMap(), MeshAlignment2D3D::buildCoupledElemQpIndexMapSecondary(), and getPrimaryNumberOfQuadraturePoints().

◆ _n_qp_secondary

unsigned int MeshAlignmentOneToMany::_n_qp_secondary
protected

Number of quadrature points for faces on the secondary boundary.

Definition at line 114 of file MeshAlignmentOneToMany.h.

Referenced by MeshAlignment1D3D::buildCoupledElemQpIndexMap(), MeshAlignment2D3D::buildCoupledElemQpIndexMapSecondary(), and getSecondaryNumberOfQuadraturePoints().

◆ _primary_elem_id_to_secondary_elem_ids

std::map<dof_id_type, std::vector<dof_id_type> > MeshAlignmentOneToMany::_primary_elem_id_to_secondary_elem_ids
protected

Map of primary element ID to coupled secondary element IDs.

Definition at line 105 of file MeshAlignmentOneToMany.h.

Referenced by buildMapping(), getCoupledSecondaryElemIDs(), and hasCoupledSecondaryElemIDs().

◆ _primary_elem_ids

std::vector<dof_id_type> MeshAlignmentBase::_primary_elem_ids
protectedinherited

◆ _primary_elem_points

std::vector<Point> MeshAlignmentBase::_primary_elem_points
protectedinherited

◆ _primary_node_ids

std::vector<dof_id_type> MeshAlignmentBase::_primary_node_ids
protectedinherited

◆ _primary_node_points

std::vector<Point> MeshAlignmentBase::_primary_node_points
protectedinherited

◆ _primary_side_ids

std::vector<unsigned short int> MeshAlignmentBase::_primary_side_ids
protectedinherited

◆ _secondary_elem_id_to_primary_elem_id

std::map<dof_id_type, dof_id_type> MeshAlignmentOneToMany::_secondary_elem_id_to_primary_elem_id
protected

Map of secondary element ID to coupled primary element ID.

Definition at line 107 of file MeshAlignmentOneToMany.h.

Referenced by buildMapping(), getCoupledPrimaryElemID(), and hasCoupledPrimaryElemID().

◆ _secondary_elem_id_to_qp_indices

std::map<dof_id_type, std::vector<unsigned int> > MeshAlignmentOneToMany::_secondary_elem_id_to_qp_indices
protected

Map of secondary element ID to vector of coupled quadrature points.

Definition at line 109 of file MeshAlignmentOneToMany.h.

Referenced by MeshAlignment1D3D::buildCoupledElemQpIndexMap(), MeshAlignment2D3D::buildCoupledElemQpIndexMapSecondary(), and getCoupledPrimaryElemQpIndex().

◆ _secondary_elem_ids

std::vector<dof_id_type> MeshAlignmentBase::_secondary_elem_ids
protectedinherited

◆ _secondary_elem_points

std::vector<Point> MeshAlignmentBase::_secondary_elem_points
protectedinherited

◆ _secondary_node_ids

std::vector<dof_id_type> MeshAlignmentBase::_secondary_node_ids
protectedinherited

◆ _secondary_node_points

std::vector<Point> MeshAlignmentBase::_secondary_node_points
protectedinherited

◆ _secondary_side_ids

std::vector<unsigned short int> MeshAlignmentBase::_secondary_side_ids
protectedinherited

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