specfem::assembly::kernels¶
-
template<specfem::dimension::type DimensionTag>
struct kernels¶ Data container for misfit kernels within the spectral element domain.
This class provides storage and data access functions for the misfit kernels associated with spectral elements in spectral element mesh. The dimension specific implementations provide data containers for storing misfit kernels as well as methods for loading and storing data on device and host.
- Template Parameters:
DimensionTag – Spatial dimension (2D or 3D)
Dimension-Specific Implementations¶
-
template<>
struct kernels<specfem::dimension::type::dim2> : public specfem::assembly::impl::value_containers<specfem::dimension::type::dim2, specfem::medium::kernels_container>¶ 2D spectral element misfit kernels container for seismic inversion
This template specialization provides comprehensive storage and management for all types of misfit kernels in 2D spectral element simulations.
Physical Context: Misfit kernels represent the sensitivity of seismic observations (waveform data) to material parameters. They are computed through the interaction of forward and adjoint wavefields and form the gradient for iterative inversion algorithms such as full waveform inversion (FWI).
// Initialize kernels container for 2D mesh specfem::assembly::kernels<specfem::dimension::type::dim2> kernels( nspec, ngllz, ngllx, element_types); // Access elastic kernels for a specific point auto elastic_kernels = kernels.template get_container< specfem::element::medium_tag::elastic_psv, specfem::element::property_tag::isotropic>(); // Accumulate kernel values during adjoint simulation add_on_device(index, point_kernels, kernels); // Copy final kernels to host for output kernels.copy_to_host();
See also
specfem::assembly::kernels Base template class
See also
specfem::medium::kernels_container Individual medium kernel containers
See also
specfem::point::kernels Point-wise kernel accessors
Public Functions
-
kernels() = default¶
Default constructor.
-
kernels(const int nspec, const int ngllz, const int ngllx, const specfem::assembly::element_types<dimension_tag> &element_types)¶
Construct 2D kernels container from mesh and element information.
Initializes the complete kernels storage system for a 2D spectral element mesh. The constructor allocates kernel storage for all medium types and material property models present in the mesh, setting up the mapping between global element indices and local kernel storage indices.
- Parameters:
nspec – Total number of spectral elements in the 2D mesh
ngllz – Number of Gauss-Lobatto-Legendre quadrature points in z-direction
ngllx – Number of Gauss-Lobatto-Legendre quadrature points in x-direction
element_types – Element classification container specifying medium and property types
-
inline void copy_to_host()¶
Copy all kernel data from device to host memory.
-
inline void copy_to_device()¶
Copy all kernel data from host to device memory.
-
kernels() = default¶
-
template<>
struct kernels<specfem::dimension::type::dim3> : public specfem::assembly::impl::value_containers<specfem::dimension::type::dim3, specfem::medium::kernels_container>¶ 3D spectral element misfit kernels container for seismic inversion
This template specialization provides comprehensive storage and management for all types of misfit kernels in 3D spectral element simulations.
Physical Context: Misfit kernels represent the sensitivity of seismic observations (waveform data) to material parameters. They are computed through the interaction of forward and adjoint wavefields and form the gradient for iterative inversion algorithms such as full waveform inversion (FWI).
// Initialize kernels container for 3D mesh specfem::assembly::kernels<specfem::dimension::type::dim3> kernels( nspec, ngllz, nglly, ngllx, element_types); // Access elastic kernels for a specific point auto elastic_kernels = kernels.template get_container< specfem::element::medium_tag::elastic, specfem::element::property_tag::isotropic>(); // Accumulate kernel values during adjoint simulation add_on_device(index, point_kernels, kernels); // Copy final kernels to host for output kernels.copy_to_host();
See also
specfem::assembly::kernels Base template class
See also
specfem::medium::kernels_container Individual medium kernel containers
See also
specfem::point::kernels Point-wise kernel accessors
Public Functions
-
kernels(const int nspec, const int ngllz, const int nglly, const int ngllx, const specfem::assembly::element_types<dimension_tag> &element_types)¶
Construct 3D kernels container from mesh and element information.
Initializes the complete kernels storage system for a 3D spectral element mesh. The constructor allocates kernel storage for all medium types and material property models present in the mesh, setting up the mapping between global element indices and local kernel storage indices.
- Parameters:
nspec – Total number of spectral elements in the 3D mesh
ngllz – Number of Gauss-Lobatto-Legendre quadrature points in z-direction
nglly – Number of Gauss-Lobatto-Legendre quadrature points in y-direction
ngllx – Number of Gauss-Lobatto-Legendre quadrature points in x-direction
element_types – Element classification container specifying medium and property types
-
kernels() = default¶
Default destructor.
-
inline void copy_to_host()¶
Copy all kernel data from device to host memory.
-
inline void copy_to_device()¶
Copy all kernel data from host to device memory.
-
kernels(const int nspec, const int ngllz, const int nglly, const int ngllx, const specfem::assembly::element_types<dimension_tag> &element_types)¶
Data Access Functions¶
-
template<typename IndexType, typename PointKernelType, typename std::enable_if<IndexType::using_simd == PointKernelType::simd::using_simd, int>::type = 0>
void add_on_device(const IndexType &index, const PointKernelType &point_kernels, const kernels<PointKernelType::dimension_tag> &kernels)¶ Accumulate misfit kernel values on GPU device for seismic inversion.
This function performs point-wise accumulation of misfit kernel values.
// Example: Accumulate elastic kernels during adjoint simulation const specfem::point::index<...> index = ...; // Current element and GLL point const specfem::point::kernels<...> point_kernels = ...; const auto kernels = assembly.kernels; // Global kernels container add_on_device(index, point_kernels, kernels);
- Template Parameters:
IndexType – Index type for spectral element location (specfem::point::index)
PointKernelType – Kernel accessor type containing point-wise kernel values (specfem::point::kernels)
- Parameters:
index – Spatial index specifying element and quadrature point location
point_kernels – Point-wise kernel values computed from forward-adjoint correlation
kernels – Global kernels container to accumulate values into
-
template<typename IndexType, typename PointKernelType, typename std::enable_if<IndexType::using_simd == PointKernelType::simd::using_simd, int>::type = 0>
void add_on_host(const IndexType &index, const PointKernelType &point_kernels, const kernels<PointKernelType::dimension_tag> &kernels)¶ Accumulate misfit kernel values on CPU host for seismic inversion.
This function performs point-wise accumulation of misfit kernel values.
// Example: Accumulate elastic kernels during adjoint simulation const auto index = ...; // Current element and GLL const specfem::point::kernels<...> point_kernels = ...; const auto kernels = assembly.kernels; // Global kernels container add_on_host(index, point_kernels, kernels);
- Template Parameters:
IndexType – Index type for spectral element location (specfem::point::index)
PointKernelType – Kernel accessor type containing point-wise kernel values (specfem::point::kernels)
- Parameters:
index – Spatial index specifying element and quadrature point location
point_kernels – Point-wise kernel values computed from forward-adjoint correlation
kernels – Global kernels container to accumulate values into
-
template<typename PointKernelType, typename IndexType, typename std::enable_if<IndexType::using_simd == PointKernelType::simd::using_simd, int>::type = 0>
void load_on_device(const IndexType &index, const kernels<PointKernelType::dimension_tag> &kernels, PointKernelType &point_kernels)¶ Load misfit kernel values on GPU device for seismic inversion.
This function performs point-wise loading of misfit kernel values.
// Example: Load elastic kernels during adjoint simulation const auto index = specfem::point::index<...> ...; // Current element and GLL point specfem::point::kernels<...> point_kernels = ...; const auto kernels = assembly.kernels; // Global kernels container load_on_device(index, kernels, point_kernels);
- Template Parameters:
PointKernelType – Kernel accessor type containing point-wise kernel values (specfem::point::kernels)
IndexType – Index type for spectral element location (specfem::point::index)
- Parameters:
index – Spatial index specifying element and quadrature point location
kernels – Global kernels container to load values from
point_kernels – Point-wise kernel values loaded from global container
-
template<typename PointKernelType, typename IndexType, typename std::enable_if<IndexType::using_simd == PointKernelType::simd::using_simd, int>::type = 0>
void load_on_host(const IndexType &index, const kernels<PointKernelType::dimension_tag> &kernels, PointKernelType &point_kernels)¶ Load misfit kernel values on CPU host for seismic inversion.
This function performs point-wise loading of misfit kernel values.
// Example: Load elastic kernels during adjoint simulation const specfem::point::index<...> index = ...; // Current element and GLL point specfem::point::kernels<...> point_kernels = ...; const auto kernels = assembly.kernels; // Global kernels container load_on_host(index, kernels, point_kernels);
- Template Parameters:
PointKernelType – Kernel accessor type containing point-wise kernel values (specfem::point::kernels)
IndexType – Index type for spectral element location (specfem::point::index)
- Parameters:
index – Spatial index specifying element and quadrature point location
kernels – Global kernels container to load values from
point_kernels – Point-wise kernel values loaded from global container
-
template<typename PointKernelType, typename IndexType, typename std::enable_if<IndexType::using_simd == PointKernelType::simd::using_simd, int>::type = 0>
void store_on_device(const IndexType &index, const PointKernelType &point_kernels, const kernels<PointKernelType::dimension_tag> &kernels)¶ Store misfit kernel values on GPU device for seismic inversion.
This function performs point-wise storage of misfit kernel values.
// Example: Store elastic kernels during adjoint simulation const specfem::point::index<...> index = ...; // Current element and GLL point const specfem::point::kernels<...> point_kernels = ...; const auto kernels = assembly.kernels; // Global kernels container store_on_device(index, point_kernels, kernels);
- Template Parameters:
PointKernelType – Kernel accessor type containing point-wise kernel values (specfem::point::kernels)
IndexType – Index type for spectral element location (specfem::point::index)
- Parameters:
index – Spatial index specifying element and quadrature point location
point_kernels – Point-wise kernel values to store into global container
kernels – Global kernels container to store values into
-
template<typename PointKernelType, typename IndexType, typename std::enable_if<IndexType::using_simd == PointKernelType::simd::using_simd, int>::type = 0>
void store_on_host(const IndexType &index, const PointKernelType &point_kernels, const kernels<PointKernelType::dimension_tag> &kernels)¶ Store misfit kernel values on CPU host for seismic inversion.
This function performs point-wise storage of misfit kernel values.
// Example: Store elastic kernels during adjoint simulation const specfem::point::index<...> index = ...; // Current element and GLL point const specfem::point::kernels<...> point_kernels = ...; const auto kernels = assembly.kernels; // Global kernels container store_on_host(index, point_kernels, kernels);
- Template Parameters:
PointKernelType – Kernel accessor type containing point-wise kernel values (specfem::point::kernels)
IndexType – Index type for spectral element location (specfem::point::index)
- Parameters:
index – Spatial index specifying element and quadrature point location
point_kernels – Point-wise kernel values to store into global container
kernels – Global kernels container to store values into