Skip to content

Commit 64e69fe

Browse files
Merge pull request #1605 from PrincetonUniversity/issue-1563
Issue 1563 - Remove anonymous namespaces, Part 1
2 parents e7e98b3 + 566ff25 commit 64e69fe

File tree

13 files changed

+420
-352
lines changed

13 files changed

+420
-352
lines changed

core/specfem/algorithms/locate_point/dim2/locate_point_impl.cpp

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -225,24 +225,6 @@ std::pair<type_real, bool> get_local_edge_coordinate(
225225
return { edgecoord, true };
226226
}
227227

228-
template <typename GraphType>
229-
std::vector<int> get_best_candidates_from_graph(const int ispec_guess,
230-
const GraphType &graph) {
231-
232-
std::vector<int> ispec_candidates;
233-
ispec_candidates.push_back(ispec_guess);
234-
235-
for (auto edge :
236-
boost::make_iterator_range(boost::out_edges(ispec_guess, graph))) {
237-
const int ispec = boost::target(edge, graph);
238-
if (std::find(ispec_candidates.begin(), ispec_candidates.end(), ispec) ==
239-
ispec_candidates.end()) {
240-
ispec_candidates.push_back(ispec);
241-
}
242-
}
243-
return ispec_candidates;
244-
}
245-
246228
std::tuple<type_real, type_real> get_best_location(
247229
const specfem::point::global_coordinates<specfem::dimension::type::dim2>
248230
&global,

core/specfem/algorithms/locate_point/locate_point_impl.tpp

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,6 @@
66
#include <tuple>
77
#include <vector>
88

9-
namespace {
10-
template <typename GraphType>
11-
std::vector<int> get_best_candidates_from_graph(const int ispec_guess,
12-
const GraphType &graph) {
13-
14-
std::vector<int> ispec_candidates;
15-
ispec_candidates.push_back(ispec_guess);
16-
17-
for (auto edge :
18-
boost::make_iterator_range(boost::out_edges(ispec_guess, graph))) {
19-
const int ispec = boost::target(edge, graph);
20-
if (std::find(ispec_candidates.begin(), ispec_candidates.end(), ispec) ==
21-
ispec_candidates.end()) {
22-
ispec_candidates.push_back(ispec);
23-
}
24-
}
25-
return ispec_candidates;
26-
}
27-
} // namespace
28-
299
namespace specfem::algorithms::locate_point_impl {
3010

3111
template <typename GraphType>
@@ -41,6 +21,22 @@ locate_point_core(
4121
&control_node_coord,
4222
const int ngnod) {
4323

24+
auto get_best_candidates_from_graph = [](const int ispec_guess,
25+
const GraphType &graph) {
26+
std::vector<int> ispec_candidates;
27+
ispec_candidates.push_back(ispec_guess);
28+
29+
for (auto edge :
30+
boost::make_iterator_range(boost::out_edges(ispec_guess, graph))) {
31+
const int ispec = boost::target(edge, graph);
32+
if (std::find(ispec_candidates.begin(), ispec_candidates.end(), ispec) ==
33+
ispec_candidates.end()) {
34+
ispec_candidates.push_back(ispec);
35+
}
36+
}
37+
return ispec_candidates;
38+
};
39+
4440
int ix_guess, iz_guess, ispec_guess;
4541

4642
std::tie(ix_guess, iz_guess, ispec_guess) =
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#include "utilities.hpp"
2+
#include <stdexcept>
3+
4+
namespace specfem::assembly::boundaries_impl {
5+
6+
bool is_on_boundary(specfem::mesh_entity::dim2::type type, int iz, int ix,
7+
int ngllz, int ngllx) {
8+
return (type == specfem::mesh_entity::dim2::type::top && iz == ngllz - 1) ||
9+
(type == specfem::mesh_entity::dim2::type::bottom && iz == 0) ||
10+
(type == specfem::mesh_entity::dim2::type::left && ix == 0) ||
11+
(type == specfem::mesh_entity::dim2::type::right && ix == ngllx - 1) ||
12+
(type == specfem::mesh_entity::dim2::type::bottom_right && iz == 0 &&
13+
ix == ngllx - 1) ||
14+
(type == specfem::mesh_entity::dim2::type::bottom_left && iz == 0 &&
15+
ix == 0) ||
16+
(type == specfem::mesh_entity::dim2::type::top_right &&
17+
iz == ngllz - 1 && ix == ngllx - 1) ||
18+
(type == specfem::mesh_entity::dim2::type::top_left &&
19+
iz == ngllz - 1 && ix == 0);
20+
}
21+
22+
std::tuple<std::array<type_real, 2>, type_real> get_boundary_edge_and_weight(
23+
specfem::mesh_entity::dim2::type type,
24+
const std::array<type_real, 2> &weights,
25+
const specfem::point::jacobian_matrix<specfem::dimension::type::dim2, true,
26+
false> &point_jacobian_matrix) {
27+
28+
if (type == specfem::mesh_entity::dim2::type::bottom_left ||
29+
type == specfem::mesh_entity::dim2::type::top_left ||
30+
type == specfem::mesh_entity::dim2::type::left) {
31+
const auto normal = point_jacobian_matrix.compute_normal(
32+
specfem::mesh_entity::dim2::type::left);
33+
const std::array<type_real, 2> edge_normal = { normal(0), normal(1) };
34+
return std::make_tuple(edge_normal, weights[1]);
35+
}
36+
37+
if (type == specfem::mesh_entity::dim2::type::bottom_right ||
38+
type == specfem::mesh_entity::dim2::type::top_right ||
39+
type == specfem::mesh_entity::dim2::type::right) {
40+
const auto normal = point_jacobian_matrix.compute_normal(
41+
specfem::mesh_entity::dim2::type::right);
42+
const std::array<type_real, 2> edge_normal = { normal(0), normal(1) };
43+
return std::make_tuple(edge_normal, weights[1]);
44+
}
45+
46+
if (type == specfem::mesh_entity::dim2::type::top) {
47+
const auto normal = point_jacobian_matrix.compute_normal(
48+
specfem::mesh_entity::dim2::type::top);
49+
const std::array<type_real, 2> edge_normal = { normal(0), normal(1) };
50+
return std::make_tuple(edge_normal, weights[0]);
51+
}
52+
53+
if (type == specfem::mesh_entity::dim2::type::bottom) {
54+
const auto normal = point_jacobian_matrix.compute_normal(
55+
specfem::mesh_entity::dim2::type::bottom);
56+
const std::array<type_real, 2> edge_normal = { normal(0), normal(1) };
57+
return std::make_tuple(edge_normal, weights[0]);
58+
}
59+
60+
throw std::invalid_argument("Error: Unknown boundary type");
61+
}
62+
63+
} // namespace specfem::assembly::boundaries_impl
Lines changed: 29 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,38 @@
11
#pragma once
22

33
#include "enumerations/interface.hpp"
4-
5-
namespace {
4+
#include "specfem/datatype.hpp"
5+
#include "specfem/point.hpp"
6+
#include <array>
7+
#include <tuple>
8+
9+
namespace specfem::assembly::boundaries_impl {
10+
11+
/**
12+
* @brief Check if a point is on the boundary for a given boundary type
13+
*
14+
* @param type The boundary type to check
15+
* @param iz Z-direction index
16+
* @param ix X-direction index
17+
* @param ngllz Number of GLL points in Z direction
18+
* @param ngllx Number of GLL points in X direction
19+
* @return true if point is on the specified boundary, false otherwise
20+
*/
621
bool is_on_boundary(specfem::mesh_entity::dim2::type type, int iz, int ix,
7-
int ngllz, int ngllx) {
8-
return (type == specfem::mesh_entity::dim2::type::top && iz == ngllz - 1) ||
9-
(type == specfem::mesh_entity::dim2::type::bottom && iz == 0) ||
10-
(type == specfem::mesh_entity::dim2::type::left && ix == 0) ||
11-
(type == specfem::mesh_entity::dim2::type::right && ix == ngllx - 1) ||
12-
(type == specfem::mesh_entity::dim2::type::bottom_right && iz == 0 &&
13-
ix == ngllx - 1) ||
14-
(type == specfem::mesh_entity::dim2::type::bottom_left && iz == 0 &&
15-
ix == 0) ||
16-
(type == specfem::mesh_entity::dim2::type::top_right &&
17-
iz == ngllz - 1 && ix == ngllx - 1) ||
18-
(type == specfem::mesh_entity::dim2::type::top_left &&
19-
iz == ngllz - 1 && ix == 0);
20-
}
21-
22+
int ngllz, int ngllx);
23+
24+
/**
25+
* @brief Get the boundary edge normal and weight for boundary integration
26+
*
27+
* @param type The boundary type
28+
* @param weights Array of quadrature weights
29+
* @param point_jacobian_matrix Jacobian matrix at the point
30+
* @return Tuple containing edge normal vector and integration weight
31+
*/
2232
std::tuple<std::array<type_real, 2>, type_real> get_boundary_edge_and_weight(
2333
specfem::mesh_entity::dim2::type type,
2434
const std::array<type_real, 2> &weights,
2535
const specfem::point::jacobian_matrix<specfem::dimension::type::dim2, true,
26-
false> &point_jacobian_matrix) {
27-
28-
if (type == specfem::mesh_entity::dim2::type::bottom_left ||
29-
type == specfem::mesh_entity::dim2::type::top_left ||
30-
type == specfem::mesh_entity::dim2::type::left) {
31-
const auto normal = point_jacobian_matrix.compute_normal(
32-
specfem::mesh_entity::dim2::type::left);
33-
const std::array<type_real, 2> edge_normal = { normal(0), normal(1) };
34-
return std::make_tuple(edge_normal, weights[1]);
35-
}
36-
37-
if (type == specfem::mesh_entity::dim2::type::bottom_right ||
38-
type == specfem::mesh_entity::dim2::type::top_right ||
39-
type == specfem::mesh_entity::dim2::type::right) {
40-
const auto normal = point_jacobian_matrix.compute_normal(
41-
specfem::mesh_entity::dim2::type::right);
42-
const std::array<type_real, 2> edge_normal = { normal(0), normal(1) };
43-
return std::make_tuple(edge_normal, weights[1]);
44-
}
45-
46-
if (type == specfem::mesh_entity::dim2::type::top) {
47-
const auto normal = point_jacobian_matrix.compute_normal(
48-
specfem::mesh_entity::dim2::type::top);
49-
const std::array<type_real, 2> edge_normal = { normal(0), normal(1) };
50-
return std::make_tuple(edge_normal, weights[0]);
51-
}
52-
53-
if (type == specfem::mesh_entity::dim2::type::bottom) {
54-
const auto normal = point_jacobian_matrix.compute_normal(
55-
specfem::mesh_entity::dim2::type::bottom);
56-
const std::array<type_real, 2> edge_normal = { normal(0), normal(1) };
57-
return std::make_tuple(edge_normal, weights[0]);
58-
}
36+
false> &point_jacobian_matrix);
5937

60-
throw std::invalid_argument("Error: Unknown boundary type");
61-
}
62-
} // namespace
38+
} // namespace specfem::assembly::boundaries_impl
Lines changed: 163 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
#include "utilities.hpp"
2+
#include <stdexcept>
3+
4+
namespace specfem::assembly::boundaries_impl {
5+
6+
bool is_on_boundary(specfem::mesh_entity::dim3::type type, int iz, int iy,
7+
int ix, int ngllz, int nglly, int ngllx) {
8+
return (type == specfem::mesh_entity::dim3::type::top && iz == ngllz - 1) ||
9+
(type == specfem::mesh_entity::dim3::type::bottom && iz == 0) ||
10+
(type == specfem::mesh_entity::dim3::type::left && ix == 0) ||
11+
(type == specfem::mesh_entity::dim3::type::right && ix == ngllx - 1) ||
12+
(type == specfem::mesh_entity::dim3::type::front && iy == nglly - 1) ||
13+
(type == specfem::mesh_entity::dim3::type::back && iy == 0) ||
14+
// Edges
15+
(type == specfem::mesh_entity::dim3::type::bottom_left && iz == 0 &&
16+
ix == 0) ||
17+
(type == specfem::mesh_entity::dim3::type::bottom_right && iz == 0 &&
18+
ix == ngllx - 1) ||
19+
(type == specfem::mesh_entity::dim3::type::top_right &&
20+
iz == ngllz - 1 && ix == ngllx - 1) ||
21+
(type == specfem::mesh_entity::dim3::type::top_left &&
22+
iz == ngllz - 1 && ix == 0) ||
23+
(type == specfem::mesh_entity::dim3::type::front_bottom &&
24+
iy == nglly - 1 && iz == 0) ||
25+
(type == specfem::mesh_entity::dim3::type::front_top &&
26+
iy == nglly - 1 && iz == ngllz - 1) ||
27+
(type == specfem::mesh_entity::dim3::type::front_left &&
28+
iy == nglly - 1 && ix == 0) ||
29+
(type == specfem::mesh_entity::dim3::type::front_right &&
30+
iy == nglly - 1 && ix == ngllx - 1) ||
31+
(type == specfem::mesh_entity::dim3::type::back_bottom && iy == 0 &&
32+
iz == 0) ||
33+
(type == specfem::mesh_entity::dim3::type::back_top && iy == 0 &&
34+
iz == ngllz - 1) ||
35+
(type == specfem::mesh_entity::dim3::type::back_left && iy == 0 &&
36+
ix == 0) ||
37+
(type == specfem::mesh_entity::dim3::type::back_right && iy == 0 &&
38+
ix == ngllx - 1) ||
39+
// Corners
40+
(type == specfem::mesh_entity::dim3::type::bottom_front_left &&
41+
iz == 0 && iy == nglly - 1 && ix == 0) ||
42+
(type == specfem::mesh_entity::dim3::type::bottom_front_right &&
43+
iz == 0 && iy == nglly - 1 && ix == ngllx - 1) ||
44+
(type == specfem::mesh_entity::dim3::type::bottom_back_left &&
45+
iz == 0 && iy == 0 && ix == 0) ||
46+
(type == specfem::mesh_entity::dim3::type::bottom_back_right &&
47+
iz == 0 && iy == 0 && ix == ngllx - 1) ||
48+
(type == specfem::mesh_entity::dim3::type::top_front_left &&
49+
iz == ngllz - 1 && iy == nglly - 1 && ix == 0) ||
50+
(type == specfem::mesh_entity::dim3::type::top_front_right &&
51+
iz == ngllz - 1 && iy == nglly - 1 && ix == ngllx - 1) ||
52+
(type == specfem::mesh_entity::dim3::type::top_back_left &&
53+
iz == ngllz - 1 && iy == 0 && ix == 0) ||
54+
(type == specfem::mesh_entity::dim3::type::top_back_right &&
55+
iz == ngllz - 1 && iy == 0 && ix == ngllx - 1);
56+
}
57+
58+
std::tuple<std::array<type_real, 3>, type_real> get_boundary_face_and_weight(
59+
specfem::mesh_entity::dim3::type type,
60+
const std::array<type_real, 3> &weights,
61+
const specfem::point::jacobian_matrix<specfem::dimension::type::dim3, true,
62+
false> &point_jacobian_matrix) {
63+
64+
if (type == specfem::mesh_entity::dim3::type::bottom_front_left ||
65+
type == specfem::mesh_entity::dim3::type::bottom_back_left ||
66+
type == specfem::mesh_entity::dim3::type::top_front_left ||
67+
type == specfem::mesh_entity::dim3::type::top_back_left ||
68+
type == specfem::mesh_entity::dim3::type::front_left ||
69+
type == specfem::mesh_entity::dim3::type::back_left ||
70+
type == specfem::mesh_entity::dim3::type::bottom_left ||
71+
type == specfem::mesh_entity::dim3::type::top_left ||
72+
type == specfem::mesh_entity::dim3::type::left) {
73+
const auto normal = point_jacobian_matrix.compute_normal(
74+
specfem::mesh_entity::dim3::type::left);
75+
const std::array<type_real, 3> face_normal = { normal(0), normal(1),
76+
normal(2) };
77+
return std::make_tuple(face_normal, weights[1] * weights[2]);
78+
}
79+
80+
if (type == specfem::mesh_entity::dim3::type::bottom_front_right ||
81+
type == specfem::mesh_entity::dim3::type::bottom_back_right ||
82+
type == specfem::mesh_entity::dim3::type::top_front_right ||
83+
type == specfem::mesh_entity::dim3::type::top_back_right ||
84+
type == specfem::mesh_entity::dim3::type::front_right ||
85+
type == specfem::mesh_entity::dim3::type::back_right ||
86+
type == specfem::mesh_entity::dim3::type::bottom_right ||
87+
type == specfem::mesh_entity::dim3::type::top_right ||
88+
type == specfem::mesh_entity::dim3::type::right) {
89+
const auto normal = point_jacobian_matrix.compute_normal(
90+
specfem::mesh_entity::dim3::type::right);
91+
const std::array<type_real, 3> face_normal = { normal(0), normal(1),
92+
normal(2) };
93+
return std::make_tuple(face_normal, weights[1] * weights[2]);
94+
}
95+
96+
if (type == specfem::mesh_entity::dim3::type::top_front_left ||
97+
type == specfem::mesh_entity::dim3::type::top_front_right ||
98+
type == specfem::mesh_entity::dim3::type::top_back_left ||
99+
type == specfem::mesh_entity::dim3::type::top_back_right ||
100+
type == specfem::mesh_entity::dim3::type::front_top ||
101+
type == specfem::mesh_entity::dim3::type::back_top ||
102+
type == specfem::mesh_entity::dim3::type::top_left ||
103+
type == specfem::mesh_entity::dim3::type::top_right ||
104+
type == specfem::mesh_entity::dim3::type::top) {
105+
const auto normal = point_jacobian_matrix.compute_normal(
106+
specfem::mesh_entity::dim3::type::top);
107+
const std::array<type_real, 3> face_normal = { normal(0), normal(1),
108+
normal(2) };
109+
return std::make_tuple(face_normal, weights[0] * weights[2]);
110+
}
111+
112+
if (type == specfem::mesh_entity::dim3::type::bottom_front_left ||
113+
type == specfem::mesh_entity::dim3::type::bottom_front_right ||
114+
type == specfem::mesh_entity::dim3::type::bottom_back_left ||
115+
type == specfem::mesh_entity::dim3::type::bottom_back_right ||
116+
type == specfem::mesh_entity::dim3::type::front_bottom ||
117+
type == specfem::mesh_entity::dim3::type::back_bottom ||
118+
type == specfem::mesh_entity::dim3::type::bottom_left ||
119+
type == specfem::mesh_entity::dim3::type::bottom_right ||
120+
type == specfem::mesh_entity::dim3::type::bottom) {
121+
const auto normal = point_jacobian_matrix.compute_normal(
122+
specfem::mesh_entity::dim3::type::bottom);
123+
const std::array<type_real, 3> face_normal = { normal(0), normal(1),
124+
normal(2) };
125+
return std::make_tuple(face_normal, weights[0] * weights[2]);
126+
}
127+
128+
if (type == specfem::mesh_entity::dim3::type::bottom_front_left ||
129+
type == specfem::mesh_entity::dim3::type::bottom_front_right ||
130+
type == specfem::mesh_entity::dim3::type::top_front_left ||
131+
type == specfem::mesh_entity::dim3::type::top_front_right ||
132+
type == specfem::mesh_entity::dim3::type::front_left ||
133+
type == specfem::mesh_entity::dim3::type::front_right ||
134+
type == specfem::mesh_entity::dim3::type::front_bottom ||
135+
type == specfem::mesh_entity::dim3::type::front_top ||
136+
type == specfem::mesh_entity::dim3::type::front) {
137+
const auto normal = point_jacobian_matrix.compute_normal(
138+
specfem::mesh_entity::dim3::type::front);
139+
const std::array<type_real, 3> face_normal = { normal(0), normal(1),
140+
normal(2) };
141+
return std::make_tuple(face_normal, weights[0] * weights[1]);
142+
}
143+
144+
if (type == specfem::mesh_entity::dim3::type::bottom_back_left ||
145+
type == specfem::mesh_entity::dim3::type::bottom_back_right ||
146+
type == specfem::mesh_entity::dim3::type::top_back_left ||
147+
type == specfem::mesh_entity::dim3::type::top_back_right ||
148+
type == specfem::mesh_entity::dim3::type::back_left ||
149+
type == specfem::mesh_entity::dim3::type::back_right ||
150+
type == specfem::mesh_entity::dim3::type::back_bottom ||
151+
type == specfem::mesh_entity::dim3::type::back_top ||
152+
type == specfem::mesh_entity::dim3::type::back) {
153+
const auto normal = point_jacobian_matrix.compute_normal(
154+
specfem::mesh_entity::dim3::type::back);
155+
const std::array<type_real, 3> face_normal = { normal(0), normal(1),
156+
normal(2) };
157+
return std::make_tuple(face_normal, weights[0] * weights[1]);
158+
}
159+
160+
throw std::invalid_argument("Error: Unknown boundary type");
161+
}
162+
163+
} // namespace specfem::assembly::boundaries_impl

0 commit comments

Comments
 (0)