specfem::medium::kernels_container

template<specfem::dimension::type DimensionTag, specfem::element::medium_tag MediumTag, specfem::element::property_tag PropertyTag>
struct kernels_container

Misfit kernel storage container for seismic inversion.

Template container that stores sensitivity kernels (Frechet derivatives) which represent the gradient of the misfit function with respect to material parameters and are computed from the interaction of forward and adjoint wavefields.

Specializes for different dimension/medium/property combinations and provides efficient accumulation operations for kernel computation during adjoint simulations. Inherits from kernels::data_container for storage and impl::Accessor for device/host data access.

Template Parameters:
  • DimensionTag – Spatial dimension (dim2/dim3)

  • MediumTag – Physical medium type

  • PropertyTag – Material property type

Dimension-specific Specializations

template<specfem::element::medium_tag MediumTag, specfem::element::property_tag PropertyTag>
struct kernels_container<specfem::dimension::type::dim2, MediumTag, PropertyTag> : public specfem::medium::kernels::data_container<specfem::dimension::type::dim2, MediumTag, PropertyTag>, public specfem::medium::impl::Accessor<specfem::dimension::type::dim2, kernels_container<specfem::dimension::type::dim2, MediumTag, PropertyTag>>

2D misfit kernels container specialization.

Stores sensitivity kernels for 2D spectral elements at all quadrature points. Data layout: kernels[element][ngllz][ngllx] where ngllz and ngllx are quadrature points in vertical and horizontal directions.

Used for accumulating kernel contributions during adjoint simulation:

  • Forward wavefield provides displacement/velocity/acceleration

  • Adjoint wavefield provides sensitivity information

  • Kernels accumulate the correlation between these fields

Template Parameters:
  • MediumTag – Physical medium (acoustic, elastic, poroelastic)

  • PropertyTag – Material symmetry (isotropic, anisotropic, cosserat)

Public Types

using base_type = kernels::data_container<specfem::dimension::type::dim2, MediumTag, PropertyTag>

Base kernels data container type.

Public Functions

kernels_container() = default

Default constructor for empty kernels container.

inline kernels_container(const Kokkos::View<int*, Kokkos::DefaultHostExecutionSpace> elements, const int ngllz, const int ngllx, const specfem::kokkos::HostView1d<int> property_index_mapping)

Construct 2D kernels container for specified elements.

Initializes kernels storage for the given spectral elements and sets up the mapping from global element indices to local kernel storage indices. All kernel values are initialized to zero for accumulation.

Parameters:
  • elements – Element indices to initialize kernels for

  • ngllz – Number of vertical quadrature points per element

  • ngllx – Number of horizontal quadrature points per element

  • property_index_mapping – Output mapping from element index to kernel storage index

inline void load_device_values(const IndexType &index, PointValues &values) const

Load data from container to point values on device.

Reads data from the container at the specified index and copies it to the provided point values object. Supports both scalar and SIMD vectorized indices for optimal performance.

Template Parameters:
  • PointValues – Point data type (properties, field, etc.)

  • IndexType – Index type (index or simd_index)

Parameters:
  • index – Quadrature point index within element

  • values – Point values object to fill with data

inline void load_host_values(const IndexType &index, PointValues &values) const

Load data from container to point values on host.

Host version of load_device_values. Should be called from host code for accessing data in host memory or performing host-side operations.

Template Parameters:
  • PointValues – Point data type (properties, field, etc.)

  • IndexType – Index type (index or simd_index)

Parameters:
  • index – Quadrature point index within element

  • values – Point values object to fill with data

inline void store_device_values(const IndexType &index, const PointValues &values) const

Store point values to container on device.

Writes data from point values object to the container at the specified index. Overwrites existing data in the container.

Template Parameters:
  • PointValues – Point data type (properties, field, etc.)

  • IndexType – Index type (index or simd_index)

Parameters:
  • index – Quadrature point index within element

  • values – Point values object containing data to store

inline void store_host_values(const IndexType &index, const PointValues &values) const

Store point values to container on host.

Host version of store_device_values for host-side operations.

Template Parameters:
  • PointValues – Point data type (properties, field, etc.)

  • IndexType – Index type (index or simd_index)

Parameters:
  • index – Quadrature point index within element

  • values – Point values object containing data to store

inline void add_device_values(const IndexType &index, const PointValues &values) const

Add point values to existing container data on device.

Performs element-wise addition of point values to existing data in the container. Commonly used for accumulating contributions (e.g., sensitivity kernels, forces).

Template Parameters:
  • PointValues – Point data type (properties, field, etc.)

  • IndexType – Index type (index or simd_index)

Parameters:
  • index – Quadrature point index within element

  • values – Point values to add to existing container data

inline void add_host_values(const IndexType &index, const PointValues &values) const

Add point values to existing container data on host.

Host version of add_device_values for accumulation operations.

Template Parameters:
  • PointValues – Point data type (properties, field, etc.)

  • IndexType – Index type (index or simd_index)

Parameters:
  • index – Quadrature point index within element

  • values – Point values to add to existing container data

Public Static Attributes

static constexpr auto dimension_tag = base_type::dimension_tag

2D spatial dimension

static constexpr auto medium_tag = base_type::medium_tag

Physical medium type.

static constexpr auto property_tag = base_type::property_tag

Material property type.

template<specfem::element::medium_tag MediumTag, specfem::element::property_tag PropertyTag>
struct kernels_container<specfem::dimension::type::dim3, MediumTag, PropertyTag> : public specfem::medium::kernels::data_container<specfem::dimension::type::dim3, MediumTag, PropertyTag>, public specfem::medium::impl::Accessor<specfem::dimension::type::dim3, kernels_container<specfem::dimension::type::dim3, MediumTag, PropertyTag>>

3D misfit kernels container specialization.

Stores sensitivity kernels for 3D spectral elements at all quadrature points. Data layout: kernels[element][ngllz][nglly][ngllx] where ngllz, nglly, and ngllx are quadrature points in z, y, and x directions.

Used for accumulating kernel contributions during 3D adjoint simulation. Provides efficient storage and access patterns for 3D kernel accumulation operations.

Template Parameters:
  • MediumTag – Physical medium (acoustic, elastic)

  • PropertyTag – Material symmetry (isotropic, anisotropic)

Public Types

using base_type = kernels::data_container<specfem::dimension::type::dim3, MediumTag, PropertyTag>

Base kernels data container type.

Public Functions

kernels_container() = default

Default constructor for empty kernels container.

inline kernels_container(const Kokkos::View<int*, Kokkos::DefaultHostExecutionSpace> elements, const int ngllz, const int nglly, const int ngllx, const specfem::kokkos::HostView1d<int> property_index_mapping)

Construct 3D kernels container for specified elements.

Initializes kernels storage for the given spectral elements and sets up the mapping from global element indices to local kernel storage indices. All kernel values are initialized to zero for accumulation.

Parameters:
  • elements – Element indices to initialize kernels for

  • ngllz – Number of z-direction quadrature points per element

  • nglly – Number of y-direction quadrature points per element

  • ngllx – Number of x-direction quadrature points per element

  • property_index_mapping – Output mapping from element index to kernel storage index

inline void load_device_values(const IndexType &index, PointValues &values) const

Load data from container to point values on device.

Reads data from the container at the specified index and copies it to the provided point values object. Supports both scalar and SIMD vectorized indices for optimal performance.

Template Parameters:
  • PointValues – Point data type (properties, field, etc.)

  • IndexType – Index type (index or simd_index)

Parameters:
  • index – Quadrature point index within element

  • values – Point values object to fill with data

inline void load_host_values(const IndexType &index, PointValues &values) const

Load data from container to point values on host.

Host version of load_device_values. Should be called from host code for accessing data in host memory or performing host-side operations.

Template Parameters:
  • PointValues – Point data type (properties, field, etc.)

  • IndexType – Index type (index or simd_index)

Parameters:
  • index – Quadrature point index within element

  • values – Point values object to fill with data

inline void store_device_values(const IndexType &index, const PointValues &values) const

Store point values to container on device.

Writes data from point values object to the container at the specified index. Overwrites existing data in the container.

Template Parameters:
  • PointValues – Point data type (properties, field, etc.)

  • IndexType – Index type (index or simd_index)

Parameters:
  • index – Quadrature point index within element

  • values – Point values object containing data to store

inline void store_host_values(const IndexType &index, const PointValues &values) const

Store point values to container on host.

Host version of store_device_values for host-side operations.

Template Parameters:
  • PointValues – Point data type (properties, field, etc.)

  • IndexType – Index type (index or simd_index)

Parameters:
  • index – Quadrature point index within element

  • values – Point values object containing data to store

inline void add_device_values(const IndexType &index, const PointValues &values) const

Add point values to existing container data on device.

Performs element-wise addition of point values to existing data in the container. Commonly used for accumulating contributions (e.g., sensitivity kernels, forces).

Template Parameters:
  • PointValues – Point data type (properties, field, etc.)

  • IndexType – Index type (index or simd_index)

Parameters:
  • index – Quadrature point index within element

  • values – Point values to add to existing container data

inline void add_host_values(const IndexType &index, const PointValues &values) const

Add point values to existing container data on host.

Host version of add_device_values for accumulation operations.

Template Parameters:
  • PointValues – Point data type (properties, field, etc.)

  • IndexType – Index type (index or simd_index)

Parameters:
  • index – Quadrature point index within element

  • values – Point values to add to existing container data

Public Static Attributes

static constexpr auto dimension_tag = base_type::dimension_tag

3D spatial dimension

static constexpr auto medium_tag = base_type::medium_tag

Physical medium type.

static constexpr auto property_tag = base_type::property_tag

Material property type.

Implementation Details