Skip to content

Commit ca9be18

Browse files
Merge pull request #1151 from PrincetonUniversity/issue-1150
Iterators and Access functions for edges
2 parents 3840e9a + 8dff2b4 commit ca9be18

File tree

76 files changed

+4027
-1411
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+4027
-1411
lines changed

CMakeLists.txt

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,7 @@ add_library(
256256
target_link_libraries(
257257
enumerations
258258
${BOOST_LIBS}
259+
Kokkos::kokkos
259260
)
260261

261262

@@ -407,17 +408,6 @@ target_link_libraries(
407408
# Disable unity build for source_time_function due to KOKKOS_INLINE_FUNCTION issues
408409
set_target_properties(source_time_function PROPERTIES UNITY_BUILD OFF)
409410

410-
411-
add_library(coupled_interface
412-
src/coupled_interface/coupled_interface.cpp
413-
)
414-
415-
target_link_libraries(
416-
coupled_interface
417-
Kokkos::kokkos
418-
assembly
419-
)
420-
421411
add_library(
422412
kokkos_kernels
423413
src/kokkos_kernels/impl/compute_mass_matrix.cpp
@@ -427,9 +417,13 @@ add_library(
427417
src/kokkos_kernels/impl/compute_source_interaction.cpp
428418
src/kokkos_kernels/impl/compute_stiffness_interaction.cpp
429419
src/kokkos_kernels/impl/compute_material_derivatives.cpp
420+
src/kokkos_kernels/impl/compute_coupling.cpp
430421
src/kokkos_kernels/frechet_kernels.cpp
431422
)
432-
set_target_properties(kokkos_kernels PROPERTIES UNITY_BUILD_BATCH_SIZE 4)
423+
set_target_properties(kokkos_kernels PROPERTIES
424+
UNITY_BUILD $<NOT:$<BOOL:${__APPLE__}>>
425+
UNITY_BUILD_BATCH_SIZE $<IF:$<BOOL:${__APPLE__}>,0,4>
426+
)
433427

434428
target_link_libraries(
435429
kokkos_kernels
@@ -557,7 +551,6 @@ target_link_libraries(
557551
writer
558552
periodic_tasks
559553
reader
560-
coupled_interface
561554
kokkos_kernels
562555
solver
563556
${BOOST_LIBS}
@@ -592,7 +585,6 @@ target_link_libraries(
592585
writer
593586
periodic_tasks
594587
reader
595-
coupled_interface
596588
kokkos_kernels
597589
solver
598590
${BOOST_LIBS}

core/specfem/assembly/assembly/dim2/assembly.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,12 @@ specfem::assembly::assembly<specfem::dimension::type::dim2>::assembly(
1919
const std::shared_ptr<specfem::io::reader> &property_reader) {
2020
this->mesh = { mesh.tags, mesh.control_nodes, quadratures,
2121
mesh.adjacency_graph };
22-
2322
this->element_types = { this->mesh.nspec, this->mesh.element_grid.ngllz,
2423
this->mesh.element_grid.ngllx, this->mesh,
2524
mesh.tags };
25+
this->edge_types = { this->mesh.element_grid.ngllx,
26+
this->mesh.element_grid.ngllz, this->mesh,
27+
this->element_types, mesh.coupled_interfaces };
2628
this->jacobian_matrix = { this->mesh };
2729
this->properties = { this->mesh.nspec,
2830
this->mesh.element_grid.ngllz,
@@ -55,8 +57,9 @@ specfem::assembly::assembly<specfem::dimension::type::dim2>::assembly(
5557
mesh,
5658
this->mesh,
5759
this->jacobian_matrix };
58-
this->coupled_interfaces = { mesh, this->mesh, this->jacobian_matrix,
59-
this->element_types };
60+
this->coupled_interfaces = { this->mesh.element_grid.ngllz,
61+
this->mesh.element_grid.ngllx, this->edge_types,
62+
this->jacobian_matrix, this->mesh };
6063
this->fields = { this->mesh, this->element_types, simulation };
6164

6265
if (allocate_boundary_values)

core/specfem/assembly/assembly/dim2/assembly.hpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
#include "specfem/assembly/boundary_values.hpp"
88
#include "specfem/assembly/compute_source_array.hpp"
99
#include "specfem/assembly/coupled_interfaces.hpp"
10+
#include "specfem/assembly/edge_types.hpp"
11+
#include "specfem/assembly/element_types.hpp"
1012
#include "specfem/assembly/fields.hpp"
1113
#include "specfem/assembly/jacobian_matrix.hpp"
1214
#include "specfem/assembly/kernels.hpp"
@@ -41,6 +43,8 @@ template <> struct assembly<specfem::dimension::type::dim2> {
4143
///< every
4244
///< spectral
4345
///< element
46+
47+
specfem::assembly::edge_types<dimension_tag> edge_types;
4448
specfem::assembly::jacobian_matrix<dimension_tag>
4549
jacobian_matrix; ///< Partial
4650
///< derivatives
@@ -57,10 +61,8 @@ template <> struct assembly<specfem::dimension::type::dim2> {
5761
specfem::assembly::boundaries<dimension_tag> boundaries; ///< Boundary
5862
///< conditions
5963
specfem::assembly::coupled_interfaces<dimension_tag>
60-
coupled_interfaces; ///< Coupled
61-
///< interfaces
62-
///< between 2
63-
///< mediums
64+
coupled_interfaces; ///< Coupled interfaces between 2 mediums (new
65+
///< implementation)
6466
specfem::assembly::fields<dimension_tag> fields; ///< Displacement, velocity,
6567
///< and acceleration fields
6668
specfem::assembly::boundary_values<dimension_tag>

core/specfem/assembly/boundaries/dim2/impl/acoustic_free_surface.hpp

Lines changed: 61 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include "mesh/mesh.hpp"
1010
#include "specfem/assembly/jacobian_matrix.hpp"
1111
#include "specfem/assembly/mesh.hpp"
12+
#include "specfem/data_access.hpp"
1213
#include "specfem/point.hpp"
1314

1415
namespace specfem::assembly::boundaries_impl {
@@ -44,8 +45,14 @@ template <> struct acoustic_free_surface<specfem::dimension::type::dim2> {
4445
const Kokkos::View<int *, Kokkos::HostSpace> &boundary_index_mapping,
4546
std::vector<specfem::element::boundary_tag_container> &boundary_tag);
4647

48+
template <typename IndexType,
49+
typename std::enable_if_t<
50+
specfem::data_access::is_index_type<IndexType>::value &&
51+
specfem::data_access::is_point<IndexType>::value &&
52+
IndexType::using_simd == false,
53+
int> = 0>
4754
KOKKOS_FORCEINLINE_FUNCTION void
48-
load_on_device(const specfem::point::index<dimension_tag> &index,
55+
load_on_device(const IndexType &index,
4956
specfem::point::boundary<boundary_tag, dimension_tag, false>
5057
&boundary) const {
5158

@@ -54,8 +61,14 @@ template <> struct acoustic_free_surface<specfem::dimension::type::dim2> {
5461
return;
5562
}
5663

64+
template <typename IndexType,
65+
typename std::enable_if_t<
66+
specfem::data_access::is_index_type<IndexType>::value &&
67+
specfem::data_access::is_point<IndexType>::value &&
68+
IndexType::using_simd == false,
69+
int> = 0>
5770
KOKKOS_FORCEINLINE_FUNCTION void
58-
load_on_device(const specfem::point::index<dimension_tag> &index,
71+
load_on_device(const IndexType &index,
5972
specfem::point::boundary<
6073
specfem::element::boundary_tag::composite_stacey_dirichlet,
6174
dimension_tag, false> &boundary) const {
@@ -65,8 +78,14 @@ template <> struct acoustic_free_surface<specfem::dimension::type::dim2> {
6578
return;
6679
}
6780

81+
template <typename IndexType,
82+
typename std::enable_if_t<
83+
specfem::data_access::is_index_type<IndexType>::value &&
84+
specfem::data_access::is_point<IndexType>::value &&
85+
IndexType::using_simd == true,
86+
int> = 0>
6887
KOKKOS_FORCEINLINE_FUNCTION void
69-
load_on_device(const specfem::point::simd_index<dimension_tag> &index,
88+
load_on_device(const IndexType &index,
7089
specfem::point::boundary<boundary_tag, dimension_tag, true>
7190
&boundary) const {
7291

@@ -87,8 +106,14 @@ template <> struct acoustic_free_surface<specfem::dimension::type::dim2> {
87106
return;
88107
}
89108

109+
template <typename IndexType,
110+
typename std::enable_if_t<
111+
specfem::data_access::is_index_type<IndexType>::value &&
112+
specfem::data_access::is_point<IndexType>::value &&
113+
IndexType::using_simd == true,
114+
int> = 0>
90115
KOKKOS_FORCEINLINE_FUNCTION void
91-
load_on_device(const specfem::point::simd_index<dimension_tag> &index,
116+
load_on_device(const IndexType &index,
92117
specfem::point::boundary<
93118
specfem::element::boundary_tag::composite_stacey_dirichlet,
94119
dimension_tag, true> &boundary) const {
@@ -110,17 +135,28 @@ template <> struct acoustic_free_surface<specfem::dimension::type::dim2> {
110135
return;
111136
}
112137

113-
inline void
114-
load_on_host(const specfem::point::index<dimension_tag> &index,
115-
specfem::point ::boundary<boundary_tag, dimension_tag, false>
116-
&boundary) const {
138+
template <typename IndexType,
139+
typename std::enable_if_t<
140+
specfem::data_access::is_index_type<IndexType>::value &&
141+
specfem::data_access::is_point<IndexType>::value &&
142+
IndexType::using_simd == false,
143+
int> = 0>
144+
inline void load_on_host(const IndexType &index,
145+
specfem::point::boundary<boundary_tag, dimension_tag,
146+
false> &boundary) const {
117147
boundary.tag +=
118148
h_quadrature_point_boundary_tag(index.ispec, index.iz, index.ix);
119149
return;
120150
}
121151

152+
template <typename IndexType,
153+
typename std::enable_if_t<
154+
specfem::data_access::is_index_type<IndexType>::value &&
155+
specfem::data_access::is_point<IndexType>::value &&
156+
IndexType::using_simd == false,
157+
int> = 0>
122158
inline void
123-
load_on_host(const specfem::point::index<dimension_tag> &index,
159+
load_on_host(const IndexType &index,
124160
specfem::point::boundary<
125161
specfem::element::boundary_tag::composite_stacey_dirichlet,
126162
dimension_tag, false> &boundary) const {
@@ -130,10 +166,15 @@ template <> struct acoustic_free_surface<specfem::dimension::type::dim2> {
130166
return;
131167
}
132168

133-
inline void
134-
load_on_host(const specfem::point::simd_index<dimension_tag> &index,
135-
specfem::point::boundary<boundary_tag, dimension_tag, true>
136-
&boundary) const {
169+
template <typename IndexType,
170+
typename std::enable_if_t<
171+
specfem::data_access::is_index_type<IndexType>::value &&
172+
specfem::data_access::is_point<IndexType>::value &&
173+
IndexType::using_simd == true,
174+
int> = 0>
175+
inline void load_on_host(const IndexType &index,
176+
specfem::point::boundary<boundary_tag, dimension_tag,
177+
true> &boundary) const {
137178

138179
using simd = typename specfem::datatype::simd<type_real, true>;
139180

@@ -149,8 +190,14 @@ template <> struct acoustic_free_surface<specfem::dimension::type::dim2> {
149190
return;
150191
}
151192

193+
template <typename IndexType,
194+
typename std::enable_if_t<
195+
specfem::data_access::is_index_type<IndexType>::value &&
196+
specfem::data_access::is_point<IndexType>::value &&
197+
IndexType::using_simd == true,
198+
int> = 0>
152199
inline void
153-
load_on_host(const specfem::point::simd_index<dimension_tag> &index,
200+
load_on_host(const IndexType &index,
154201
specfem::point::boundary<
155202
specfem::element::boundary_tag::composite_stacey_dirichlet,
156203
dimension_tag, true> &boundary) const {

0 commit comments

Comments
 (0)