Skip to content

Commit

Permalink
Merge pull request #413 from PrincetonUniversity/issue-278
Browse files Browse the repository at this point in the history
Issue 278 - Refactor of domain folder.
  • Loading branch information
Rohit-Kakodkar authored Jan 22, 2025
2 parents fb0e3a0 + bbc92bf commit e41d8df
Show file tree
Hide file tree
Showing 155 changed files with 2,712 additions and 5,742 deletions.
54 changes: 21 additions & 33 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -327,18 +327,6 @@ target_link_libraries(
point
)

# add_library(
# utilities
# src/utilities/utilities.cpp
# )

# target_link_libraries(
# utilities
# jacobian
# Kokkos::kokkos
# specfem_mpi
# )

add_library(
read_seismogram
src/IO/seismogram/reader.cpp
Expand Down Expand Up @@ -429,8 +417,7 @@ target_link_libraries(
add_library(
compute
src/compute/compute_mesh.cpp
src/compute/impl/element_types.cpp
src/compute/impl/value_containers.cpp
src/compute/element_types/element_types.cpp
src/compute/compute_partial_derivatives.cpp
src/compute/compute_properties.cpp
src/compute/compute_kernels.cpp
Expand Down Expand Up @@ -460,17 +447,14 @@ target_link_libraries(
)

add_library(
domain
src/domain/impl/boundary_conditions/boundary_conditions.cpp
src/domain/impl/elements/kernel.cpp
src/domain/impl/kernels.cpp
src/domain/domain.cpp
boundary_conditions
src/boundary_conditions/boundary_conditions.cpp
)

target_link_libraries(
domain
boundary_conditions
Kokkos::kokkos
enumerations
${BOOST_LIBS}
)

add_library(
Expand All @@ -483,7 +467,7 @@ target_link_libraries(
medium
Kokkos::kokkos
compute
domain
boundary_conditions
enumerations
)

Expand All @@ -498,14 +482,22 @@ target_link_libraries(
)

add_library(
kernels
src/kernels/frechet_kernels.cpp
kokkos_kernels
src/kokkos_kernels/impl/compute_mass_matrix.cpp
src/kokkos_kernels/impl/invert_mass_matrix.cpp
src/kokkos_kernels/impl/divide_mass_matrix.cpp
src/kokkos_kernels/impl/compute_seismogram.cpp
src/kokkos_kernels/impl/compute_source_interaction.cpp
src/kokkos_kernels/impl/compute_stiffness_interaction.cpp
src/kokkos_kernels/impl/compute_material_derivatives.cpp
src/kokkos_kernels/frechet_kernels.cpp
)

target_link_libraries(
kernels
kokkos_kernels
Kokkos::kokkos
compute
boundary_conditions
)

add_library(
Expand All @@ -530,8 +522,7 @@ target_link_libraries(
solver
Kokkos::kokkos
timescheme
domain
kernels
kokkos_kernels
medium
)

Expand Down Expand Up @@ -603,8 +594,7 @@ target_link_libraries(
yaml-cpp
writer
reader
kernels
domain
kokkos_kernels
medium
solver
${BOOST_LIBS}
Expand All @@ -630,10 +620,9 @@ target_link_libraries(
writer
plotter
reader
domain
medium
coupled_interface
kernels
kokkos_kernels
solver
${BOOST_LIBS}
)
Expand Down Expand Up @@ -695,10 +684,9 @@ if (SPECFEMPP_BINDING_PYTHON)
writer
plotter
reader
domain
medium
coupled_interface
kernels
kokkos_kernels
solver
${BOOST_LIBS}
pybind11::headers
Expand Down
2 changes: 1 addition & 1 deletion include/IO/kernel/writer.hpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#pragma once

#include "IO/writer.hpp"
#include "compute/interface.hpp"
#include "enumerations/interface.hpp"
#include "IO/writer.hpp"

namespace specfem {
namespace IO {
Expand Down
7 changes: 4 additions & 3 deletions include/IO/kernel/writer.tpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ specfem::IO::kernel_writer<OutputLibrary>::kernel_writer(const std::string outpu
template <typename OutputLibrary>
void specfem::IO::kernel_writer<OutputLibrary>::write(specfem::compute::assembly &assembly) {
const auto &mesh = assembly.mesh;
auto &element_types = assembly.element_types;
auto &kernels = assembly.kernels;

using DomainView =
Expand All @@ -35,7 +36,7 @@ void specfem::IO::kernel_writer<OutputLibrary>::write(specfem::compute::assembly
{
typename OutputLibrary::Group elastic = file.createGroup("/ElasticIsotropic");

const auto element_indices = kernels.get_elements_on_host(
const auto element_indices = element_types.get_elements_on_host(
specfem::element::medium_tag::elastic,
specfem::element::property_tag::isotropic);
n_elastic_isotropic = element_indices.size();
Expand Down Expand Up @@ -89,7 +90,7 @@ void specfem::IO::kernel_writer<OutputLibrary>::write(specfem::compute::assembly
{
typename OutputLibrary::Group elastic = file.createGroup("/ElasticAnisotropic");

const auto element_indices = kernels.get_elements_on_host(
const auto element_indices = element_types.get_elements_on_host(
specfem::element::medium_tag::elastic,
specfem::element::property_tag::anisotropic);
n_elastic_anisotropic = element_indices.size();
Expand Down Expand Up @@ -146,7 +147,7 @@ void specfem::IO::kernel_writer<OutputLibrary>::write(specfem::compute::assembly
{
typename OutputLibrary::Group acoustic = file.createGroup("/Acoustic");

const auto element_indices = kernels.get_elements_on_host(specfem::element::medium_tag::acoustic);
const auto element_indices = element_types.get_elements_on_host(specfem::element::medium_tag::acoustic);
n_acoustic = element_indices.size();

DomainView x("xcoordinates_acoustic", n_acoustic, ngllz, ngllx);
Expand Down
7 changes: 4 additions & 3 deletions include/IO/property/writer.tpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ specfem::IO::property_writer<OutputLibrary>::property_writer(const std::string o
template <typename OutputLibrary>
void specfem::IO::property_writer<OutputLibrary>::write(specfem::compute::assembly &assembly) {
const auto &mesh = assembly.mesh;
auto &element_types = assembly.element_types;
auto &properties = assembly.properties;

using DomainView =
Expand All @@ -35,7 +36,7 @@ void specfem::IO::property_writer<OutputLibrary>::write(specfem::compute::assemb
{
typename OutputLibrary::Group elastic = file.createGroup("/ElasticIsotropic");

const auto element_indices = properties.get_elements_on_host(
const auto element_indices = element_types.get_elements_on_host(
specfem::element::medium_tag::elastic,
specfem::element::property_tag::isotropic);
n_elastic_isotropic = element_indices.size();
Expand Down Expand Up @@ -64,7 +65,7 @@ void specfem::IO::property_writer<OutputLibrary>::write(specfem::compute::assemb
{
typename OutputLibrary::Group elastic = file.createGroup("/ElasticAnisotropic");

const auto element_indices = properties.get_elements_on_host(
const auto element_indices = element_types.get_elements_on_host(
specfem::element::medium_tag::elastic,
specfem::element::property_tag::anisotropic);
n_elastic_anisotropic = element_indices.size();
Expand Down Expand Up @@ -100,7 +101,7 @@ void specfem::IO::property_writer<OutputLibrary>::write(specfem::compute::assemb
{
typename OutputLibrary::Group acoustic = file.createGroup("/Acoustic");

const auto element_indices = properties.get_elements_on_host(specfem::element::medium_tag::acoustic);
const auto element_indices = element_types.get_elements_on_host(specfem::element::medium_tag::acoustic);
n_acoustic = element_indices.size();

DomainView x("xcoordinates_acoustic", n_acoustic, ngllz, ngllx);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
#include <type_traits>

namespace specfem {
namespace domain {
namespace impl {

namespace boundary_conditions {
template <typename PointBoundaryType, typename PointPropertyType,
typename PointFieldType, typename PointAccelerationType>
Expand Down Expand Up @@ -78,6 +77,4 @@ compute_mass_matrix_terms(const type_real dt, const PointBoundaryType &boundary,
}

} // namespace boundary_conditions
} // namespace impl
} // namespace domain
} // namespace specfem
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
#include <Kokkos_Core.hpp>

namespace specfem {
namespace domain {
namespace impl {
namespace boundary_conditions {

using composite_stacey_dirichlet_type = std::integral_constant<
Expand All @@ -28,6 +26,4 @@ KOKKOS_FUNCTION void impl_compute_mass_matrix_terms(
PointMassMatrixType &mass_matrix);

} // namespace boundary_conditions
} // namespace impl
} // namespace domain
} // namespace specfem
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
#pragma once

#include "composite_stacey_dirichlet.hpp"
#include "domain/impl/boundary_conditions/boundary_conditions.hpp"
#include "domain/impl/boundary_conditions/dirichlet/dirichlet.hpp"
#include "domain/impl/boundary_conditions/stacey/stacey.hpp"
#include "boundary_conditions/boundary_conditions.hpp"
#include "boundary_conditions/dirichlet/dirichlet.hpp"
#include "boundary_conditions/stacey/stacey.hpp"
#include "enumerations/boundary.hpp"
#include "point/boundary.hpp"
#include <Kokkos_Core.hpp>

template <typename PointBoundaryType, typename PointPropertyType,
typename PointFieldType, typename PointAccelerationType>
KOKKOS_FUNCTION void
specfem::domain::impl::boundary_conditions::impl_apply_boundary_conditions(
specfem::boundary_conditions::impl_apply_boundary_conditions(
const composite_stacey_dirichlet_type &, const PointBoundaryType &boundary,
const PointPropertyType &property, const PointFieldType &field,
PointAccelerationType &acceleration) {
Expand Down Expand Up @@ -47,7 +47,7 @@ specfem::domain::impl::boundary_conditions::impl_apply_boundary_conditions(
template <typename PointBoundaryType, typename PointPropertyType,
typename PointMassMatrixType>
KOKKOS_FUNCTION void
specfem::domain::impl::boundary_conditions::impl_compute_mass_matrix_terms(
specfem::boundary_conditions::impl_compute_mass_matrix_terms(
const composite_stacey_dirichlet_type &, const type_real dt,
const PointBoundaryType &boundary, const PointPropertyType &property,
PointMassMatrixType &mass_matrix) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
#include <Kokkos_SIMD.hpp>

namespace specfem {
namespace domain {
namespace impl {
namespace boundary_conditions {

using acoustic_free_surface_type = std::integral_constant<
Expand Down Expand Up @@ -85,6 +83,4 @@ KOKKOS_FORCEINLINE_FUNCTION void impl_compute_mass_matrix_terms(
};

} // namespace boundary_conditions
} // namespace impl
} // namespace domain
} // namespace specfem
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
#include <Kokkos_Core.hpp>

namespace specfem {
namespace domain {
namespace impl {
namespace boundary_conditions {

using none_type = std::integral_constant<specfem::element::boundary_tag,
Expand Down Expand Up @@ -41,6 +39,4 @@ KOKKOS_INLINE_FUNCTION void impl_compute_mass_matrix_terms(
}

} // namespace boundary_conditions
} // namespace impl
} // namespace domain
} // namespace specfem
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
#include <Kokkos_Core.hpp>

namespace specfem {
namespace domain {
namespace impl {
namespace boundary_conditions {

using stacey_type =
Expand All @@ -27,6 +25,4 @@ KOKKOS_FUNCTION void impl_compute_mass_matrix_terms(
const PointPropertyType &property, PointMassMatrixType &mass_matrix);

} // namespace boundary_conditions
} // namespace impl
} // namespace domain
} // namespace specfem
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once

#include "algorithms/dot.hpp"
#include "domain/impl/boundary_conditions/boundary_conditions.hpp"
#include "boundary_conditions/boundary_conditions.hpp"
#include "enumerations/medium.hpp"
#include "point/field.hpp"
#include "stacey.hpp"
Expand Down Expand Up @@ -335,7 +335,7 @@ impl_enforce_traction(const elastic_type &, const anisotropic_type &,
template <typename PointBoundaryType, typename PointPropertyType,
typename PointFieldType, typename PointAccelerationType>
KOKKOS_FUNCTION void
specfem::domain::impl::boundary_conditions::impl_apply_boundary_conditions(
specfem::boundary_conditions::impl_apply_boundary_conditions(
const stacey_type &, const PointBoundaryType &boundary,
const PointPropertyType &property, const PointFieldType &field,
PointAccelerationType &acceleration) {
Expand All @@ -354,7 +354,7 @@ specfem::domain::impl::boundary_conditions::impl_apply_boundary_conditions(
template <typename PointBoundaryType, typename PointPropertyType,
typename PointMassMatrixType>
KOKKOS_FORCEINLINE_FUNCTION void
specfem::domain::impl::boundary_conditions::impl_compute_mass_matrix_terms(
specfem::boundary_conditions::impl_compute_mass_matrix_terms(
const stacey_type &, const type_real dt, const PointBoundaryType &boundary,
const PointPropertyType &property, PointMassMatrixType &mass_matrix) {

Expand Down
2 changes: 2 additions & 0 deletions include/compute/assembly/assembly.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ namespace compute {
*/
struct assembly {
specfem::compute::mesh mesh; ///< Properties of the assembled mesh
specfem::compute::element_types element_types; ///< Element tags for every
///< spectral element
specfem::compute::partial_derivatives partial_derivatives; ///< Partial
///< derivatives of
///< the basis
Expand Down
2 changes: 1 addition & 1 deletion include/compute/boundary_values/boundary_values.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class boundary_values {
composite_stacey_dirichlet;

boundary_values(const int nstep, const specfem::compute::mesh mesh,
const specfem::compute::properties properties,
const specfem::compute::element_types element_types,
const specfem::compute::boundaries boundaries);

template <specfem::element::boundary_tag BoundaryTag>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class boundary_value_container {
boundary_value_container() = default;

boundary_value_container(const int nstep, const specfem::compute::mesh mesh,
const specfem::compute::properties properties,
const specfem::compute::element_types element_types,
const specfem::compute::boundaries boundaries);

void sync_to_host() {
Expand Down
6 changes: 3 additions & 3 deletions include/compute/boundary_values/boundary_values_container.tpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ template <specfem::dimension::type DimensionType,
specfem::element::boundary_tag BoundaryTag>
specfem::compute::boundary_value_container<DimensionType, BoundaryTag>::
boundary_value_container(const int nstep, const specfem::compute::mesh mesh,
const specfem::compute::properties properties,
const specfem::compute::element_types element_types,
const specfem::compute::boundaries boundaries)
: property_index_mapping(
"specfem::compute::boundary_value_container::property_index_mapping",
Expand All @@ -24,11 +24,11 @@ specfem::compute::boundary_value_container<DimensionType, BoundaryTag>::

acoustic = specfem::compute::impl::boundary_medium_container<
DimensionType, specfem::element::medium_tag::acoustic, BoundaryTag>(
nstep, mesh, properties, boundaries, h_property_index_mapping);
nstep, mesh, element_types, boundaries, h_property_index_mapping);

elastic = specfem::compute::impl::boundary_medium_container<
DimensionType, specfem::element::medium_tag::elastic, BoundaryTag>(
nstep, mesh, properties, boundaries, h_property_index_mapping);
nstep, mesh, element_types, boundaries, h_property_index_mapping);

Kokkos::deep_copy(property_index_mapping, h_property_index_mapping);
}
Expand Down
Loading

0 comments on commit e41d8df

Please sign in to comment.