https://mooseframework.inl.gov
MeshAlignmentBase.C
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 #include "MeshAlignmentBase.h"
11 
12 #include "libmesh/elem.h"
13 
15  : _mesh(mesh), _meshes_are_aligned(false)
16 {
17 }
18 
19 void
20 MeshAlignmentBase::extractFrom1DElements(const std::vector<dof_id_type> & elem_ids,
21  std::vector<Point> & elem_points,
22  std::vector<dof_id_type> & node_ids,
23  std::vector<Point> & node_points) const
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 }
46 
47 void
49  const std::vector<std::tuple<dof_id_type, unsigned short int>> & boundary_info,
50  std::vector<dof_id_type> & elem_ids,
51  std::vector<unsigned short int> & side_ids,
52  std::vector<Point> & side_points,
53  std::vector<dof_id_type> & node_ids,
54  std::vector<Point> & node_points) const
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 }
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.
virtual Elem * elemPtr(const dof_id_type i)
const MooseMesh & _mesh
Mesh.
MeshBase & mesh
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.
static const std::complex< double > j(0, 1)
Complex number "j" (also known as "i")
MeshAlignmentBase(const MooseMesh &mesh)
Constructor.