Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion core/specfem/algorithms/gradient.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#pragma once

#include "kokkos_abstractions.h"
#include "specfem/assembly.hpp"
#include "specfem/data_access.hpp"
#include "specfem/execution.hpp"
Expand Down
1 change: 0 additions & 1 deletion core/specfem/algorithms/interpolate.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#pragma once

#include "kokkos_abstractions.h"
#include "specfem/datatype.hpp"
#include "specfem/execution.hpp"
#include "specfem_setup.hpp"
Expand Down
1 change: 0 additions & 1 deletion core/specfem/assembly/compute_source_array.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#pragma once

#include "kokkos_abstractions.h"
#include "specfem/assembly/element_types.hpp"
#include "specfem/assembly/jacobian_matrix.hpp"
#include "specfem/assembly/mesh.hpp"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
#pragma once

#include "specfem/assembly/compute_source_array.hpp"
#include "enumerations/dimension.hpp"
#include "impl/compute_source_array_from_tensor.hpp"
#include "impl/compute_source_array_from_vector.hpp"
#include "kokkos_abstractions.h"
#include "specfem/assembly/compute_source_array.hpp"

#include "specfem/assembly/element_types.hpp"
#include "specfem/source.hpp"
#include "specfem_setup.hpp"
#include <Kokkos_Core.hpp>

template<typename SourceArrayViewType>
template <typename SourceArrayViewType>
void specfem::assembly::compute_source_array(
const std::shared_ptr<
specfem::sources::source<specfem::dimension::type::dim2> > &source,
Expand All @@ -20,7 +20,8 @@ void specfem::assembly::compute_source_array(
SourceArrayViewType &source_array) {

// Ensure source_array is a 3D view
static_assert(SourceArrayViewType::rank() == 3, "Source array must be in rank 3.");
static_assert(SourceArrayViewType::rank() == 3,
"Source array must be in rank 3.");

switch (source->get_source_type()) {
case specfem::sources::source_type::vector_source: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "compute_source_array_from_tensor.hpp"
#include "kokkos_abstractions.h"

#include "specfem/algorithms.hpp"
#include "specfem/assembly/element_types.hpp"
#include "specfem/assembly/jacobian_matrix.hpp"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#pragma once
#include "kokkos_abstractions.h"

#include "specfem/assembly/jacobian_matrix.hpp"
#include "specfem/assembly/mesh.hpp"
#include "specfem/source.hpp"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "compute_source_array_from_vector.hpp"
#include "kokkos_abstractions.h"

#include "specfem/algorithms.hpp"
#include "specfem/assembly/element_types.hpp"
#include "specfem/assembly/jacobian_matrix.hpp"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#pragma once
#include "kokkos_abstractions.h"

#include "specfem/assembly/mesh.hpp"
#include "specfem/source.hpp"
#include <Kokkos_Core.hpp>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
#pragma once

#include "specfem/assembly/compute_source_array.hpp"
#include "enumerations/dimension.hpp"
#include "impl/compute_source_array_from_tensor.hpp"
#include "impl/compute_source_array_from_vector.hpp"
#include "kokkos_abstractions.h"
#include "specfem/assembly/compute_source_array.hpp"

#include "specfem/assembly/element_types.hpp"
#include "specfem/source.hpp"
#include "specfem_setup.hpp"
#include <Kokkos_Core.hpp>

template<typename SourceArrayViewType>
template <typename SourceArrayViewType>
void specfem::assembly::compute_source_array(
const std::shared_ptr<
specfem::sources::source<specfem::dimension::type::dim3> > &source,
Expand All @@ -20,8 +20,8 @@ void specfem::assembly::compute_source_array(
SourceArrayViewType &source_array) {

// Ensure source_array is a 4D view
static_assert(SourceArrayViewType::rank() == 4, "Source array must be in rank 4.");

static_assert(SourceArrayViewType::rank() == 4,
"Source array must be in rank 4.");

switch (source->get_source_type()) {
case specfem::sources::source_type::vector_source: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "compute_source_array_from_tensor.hpp"
#include "kokkos_abstractions.h"

#include "specfem/algorithms.hpp"
#include "specfem/assembly/element_types.hpp"
#include "specfem/assembly/jacobian_matrix.hpp"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#pragma once
#include "kokkos_abstractions.h"

#include "specfem/assembly/jacobian_matrix.hpp"
#include "specfem/assembly/mesh.hpp"
#include "specfem/source.hpp"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "compute_source_array_from_vector.hpp"
#include "kokkos_abstractions.h"

#include "specfem/algorithms.hpp"
#include "specfem/assembly/element_types.hpp"
#include "specfem/assembly/jacobian_matrix.hpp"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#pragma once
#include "kokkos_abstractions.h"

#include "specfem/assembly/mesh.hpp"
#include "specfem/source.hpp"
#include <Kokkos_Core.hpp>
Expand Down
56 changes: 0 additions & 56 deletions core/specfem/assembly/fields/dim2/simulation_field.cpp

This file was deleted.

11 changes: 2 additions & 9 deletions core/specfem/assembly/fields/dim2/simulation_field.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,15 @@ struct simulation_field<specfem::dimension::type::dim2,
* Synchronizes all field components and index mappings from device-accessible
* memory to host memory for post-processing, I/O, or debugging operations.
*/
void copy_to_host() { sync_fields<specfem::sync::kind::DeviceToHost>(); }
void copy_to_host();

/**
* @brief Copy 2D simulation field data from host to device memory.
*
* Synchronizes all field components and index mappings from host memory
* to device-accessible memory for GPU-accelerated computations.
*/
void copy_to_device() { sync_fields<specfem::sync::kind::HostToDevice>(); }
void copy_to_device();

/**
* @brief Assignment operator for copying from different wavefield types.
Expand Down Expand Up @@ -275,13 +275,6 @@ struct simulation_field<specfem::dimension::type::dim2,
int get_total_degrees_of_freedom();

private:
/**
* @brief Synchronize field data between host and device memory.
*
* @tparam sync Synchronization direction (HostToDevice or DeviceToHost)
*/
template <specfem::sync::kind sync> void sync_fields();

int total_degrees_of_freedom = 0; ///< Cached total degrees of freedom count
};

Expand Down
30 changes: 20 additions & 10 deletions core/specfem/assembly/fields/dim2/simulation_field.tpp
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
#pragma once

#include "enumerations/interface.hpp"
#include "kokkos_abstractions.h"
#include "specfem/assembly/fields.hpp"

#include "specfem/assembly/element_types.hpp"
#include "specfem/assembly/fields.hpp"
#include "specfem/assembly/fields/impl/field_impl.tpp"
#include "specfem/assembly/mesh.hpp"
#include <Kokkos_Core.hpp>

template <specfem::simulation::field_type WavefieldType>
specfem::assembly::simulation_field<specfem::dimension::type::dim2,
WavefieldType>::
simulation_field(const specfem::assembly::mesh<dimension_tag> &mesh,
const specfem::assembly::element_types<dimension_tag> &element_types) {
simulation_field(
const specfem::assembly::mesh<dimension_tag> &mesh,
const specfem::assembly::element_types<dimension_tag> &element_types) {

this->nglob = mesh.nglob;
this->index_mapping = mesh.index_mapping;
Expand All @@ -23,10 +24,11 @@ specfem::assembly::simulation_field<specfem::dimension::type::dim2,
POROELASTIC, ELASTIC_PSV_T)),
CAPTURE(assembly_index_mapping, h_assembly_index_mapping, field) {
_assembly_index_mapping_ =
Kokkos::View<int *, Kokkos::LayoutLeft, Kokkos::DefaultExecutionSpace::memory_space>(
Kokkos::View<int *, Kokkos::LayoutLeft,
Kokkos::DefaultExecutionSpace::memory_space>(
"specfem::assembly::simulation_field::index_mapping", nglob);
_h_assembly_index_mapping_ = Kokkos::create_mirror_view(
_assembly_index_mapping_);
_h_assembly_index_mapping_ =
Kokkos::create_mirror_view(_assembly_index_mapping_);

for (int iglob = 0; iglob < nglob; iglob++) {
_h_assembly_index_mapping_(iglob) = -1;
Expand Down Expand Up @@ -64,11 +66,19 @@ int specfem::assembly::simulation_field<
}

template <specfem::simulation::field_type WavefieldType>
template <specfem::sync::kind sync>
void specfem::assembly::simulation_field<specfem::dimension::type::dim2,
WavefieldType>::sync_fields() {
WavefieldType>::copy_to_host() {
FOR_EACH_IN_PRODUCT(
(DIMENSION_TAG(DIM2), MEDIUM_TAG(ELASTIC_PSV, ELASTIC_SH, ACOUSTIC,
POROELASTIC, ELASTIC_PSV_T)),
CAPTURE(field) { _field_.copy_to_host(); })
}

template <specfem::simulation::field_type WavefieldType>
void specfem::assembly::simulation_field<specfem::dimension::type::dim2,
WavefieldType>::copy_to_device() {
FOR_EACH_IN_PRODUCT(
(DIMENSION_TAG(DIM2), MEDIUM_TAG(ELASTIC_PSV, ELASTIC_SH, ACOUSTIC,
POROELASTIC, ELASTIC_PSV_T)),
CAPTURE(field) { _field_.template sync_fields<sync>(); })
CAPTURE(field) { _field_.copy_to_device(); })
}
56 changes: 0 additions & 56 deletions core/specfem/assembly/fields/dim3/simulation_field.cpp

This file was deleted.

10 changes: 2 additions & 8 deletions core/specfem/assembly/fields/dim3/simulation_field.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,15 @@ struct simulation_field<specfem::dimension::type::dim3,
* device-accessible memory to host memory for post-processing, I/O, or
* debugging operations. Handles the full 3D tensor structure efficiently.
*/
void copy_to_host() { sync_fields<specfem::sync::kind::DeviceToHost>(); }
void copy_to_host();

/**
* @brief Copy 3D simulation field data from host to device memory.
*
* Synchronizes all 3D field components and index mappings from host memory
* to device-accessible memory for GPU-accelerated 3D computations.
*/
void copy_to_device() { sync_fields<specfem::sync::kind::HostToDevice>(); }
void copy_to_device();

/**
* @brief Assignment operator for copying between 3D wavefield types.
Expand Down Expand Up @@ -275,12 +275,6 @@ struct simulation_field<specfem::dimension::type::dim3,
int get_total_degrees_of_freedom();

private:
/**
* @brief Synchronize 3D field data between host and device memory.
*
* @tparam sync Synchronization direction (HostToDevice or DeviceToHost)
*/
template <specfem::sync::kind sync> void sync_fields();
int total_degrees_of_freedom = 0; ///< Total number of degrees of freedom
};

Expand Down
Loading
Loading