specfem::chunk_edge::impl::field

template<int ChunkSize, int NGLL, specfem::dimension::type DimensionTag, specfem::element::medium_tag MediumTag, specfem::data_access::DataClassType DataClass, bool UseSIMD>
class field : public specfem::data_access::Accessor<specfem::data_access::AccessorType::chunk_edge, DataClass, DimensionTag, UseSIMD>

Chunk edge field accessor for storing field values at all quadrature points within a chunk.

This class provides an accessor interface for chunk-based edge field data, supporting efficient storage and access to field values at all Gauss-Lobatto-Legendre (GLL) quadrature points within a chunk of edges. It is designed for use in chunk execution policies where spacial locality of data is critical for performance. An example usage is shown below:

See also

remove_accessor_attribute for type trait to strip accessor attributes.

Template Parameters:
  • ChunkSize – Number of edges processed together in a chunk.

  • NGLL – Number of Gauss-Lobatto-Legendre points per spatial dimension.

  • DimensionTag – Spatial dimension (dim2 or dim3) of the field.

  • MediumTag – Medium type (acoustic, elastic, poroelastic, etc.).

  • DataClass – Data class type for access control and memory traits.

  • UseSIMD – Whether to enable SIMD vectorization for performance.

Public Types

using simd = typename base_type::template simd<type_real>

SIMD type for vectorized operations.

using value_type = typename base_type::template vector_type<type_real, nedges, ngll, components>

Vector type for storing chunk field data with optimized layout.

template<typename T, int nelements, int ngll>
using scalar_type = Kokkos::View<typename simd<T>::datatype[nelements][ngll], Kokkos::DefaultExecutionSpace::scratch_memory_space, Kokkos::MemoryTraits<Kokkos::Unmanaged>>

Scalar field storage for chunked edge elements.

Template Parameters:
  • T – Base data type

  • nelements – Number of elements in the chunk

  • ngll – Number of GLL points per element

template<typename T, int nelements, int ngll, int components>
using vector_type = Kokkos::View<typename simd<T>::datatype[nelements][ngll][components], Kokkos::DefaultExecutionSpace::scratch_memory_space, Kokkos::MemoryTraits<Kokkos::Unmanaged>>

Vector field storage for chunked edge elements.

Template Parameters:
  • T – Base data type

  • nelements – Number of elements in the chunk

  • ngll – Number of GLL points per element

  • components – Number of vector components

template<typename T, int nelements, int ngll, int components, int dimension>
using tensor_type = Kokkos::View<typename simd<T>::datatype[nelements][ngll][components][dimension], Kokkos::DefaultExecutionSpace::scratch_memory_space, Kokkos::MemoryTraits<Kokkos::Unmanaged>>

Tensor field storage for chunked edge elements.

Template Parameters:
  • T – Base data type

  • nelements – Number of elements in the chunk

  • ngll – Number of GLL points per element

  • components – Number of tensor components

  • dimension – Spatial dimension

Public Functions

field() = default

Default constructor - creates field with uninitialized data.

template<typename ScratchMemorySpace>
inline field(const ScratchMemorySpace &scratch_space)

Construct field with scratch memory allocation.

Initializes the chunk field with memory allocated from the provided scratch memory space. This is commonly used in team-based Kokkos execution where scratch memory is shared among team members for efficient data access.

// Example usage in a Kokkos team lambda
KOKKOS_LAMBDA(const TeamType& team) {
  DisplacementField field(team.team_scratch(0));
  // Use field for computations...
}

Template Parameters:

ScratchMemorySpace – Type of the scratch memory space (Kokkos concept)

Parameters:

scratch_space – The scratch memory space to allocate from

template<typename ...Indices>
inline value_type::value_type &operator()(Indices... indices) const

Multi-dimensional index operator for accessing field components.

Provides access to individual field values using multi-dimensional indexing. For chunk edge fields, the indexing typically follows the pattern: (edge_id, gll_indices…, component_id).

// For 2D fields: (edge, point_on_edge, component)
auto disp_x = field(ielem, ipoint, 0);  // x-component
auto disp_z = field(ielem, ipoint, 1);  // z-component
field(ielem, ipoint, 0) = new_value;

Template Parameters:

Indices – Parameter pack for multi-dimensional indices

Parameters:

indices – The indices specifying the location and component to access

Returns:

Reference to the field value at the specified location

inline const remove_accessor_attribute<ChunkSize, NGLL, DimensionTag, MediumTag, UseSIMD, value_type>::type field_without_accessor() const

Strip accessor attributes and return a field_without_accessor type.

This method provides a way to a unified field type that does not include the accessor interface. It is useful when you need to reference field of different types.

// Example usage of field_without_accessor
const specfem::wavefield::type wavefield_type = ...;
const auto field = [&]() {
  if (wavefield_type == specfem::wavefield::type::displacement) {
    return displacement_field.field_without_accessor();
  } else if (wavefield_type == specfem::wavefield::type::velocity) {
    return velocity_field.field_without_accessor();
  } else if (wavefield_type == specfem::wavefield::type::acceleration) {
    return acceleration_field.field_without_accessor();
  } else {
    throw std::runtime_error("Unsupported wavefield type");
  }
}();
Returns:

A field_without_accessor type with the same data storage

Public Static Functions

static inline constexpr std::size_t shmem_size()

Get the shared memory size required for this field type.

Returns the amount of shared memory (in bytes) required to allocate storage for this field type. This is used for Kokkos team scratch memory allocation.

// Example: Allocating team scratch memory
auto policy = Kokkos::TeamPolicy<>(num_teams, team_size)
  .set_scratch_size(0, Kokkos::PerTeam(DisplacementField::shmem_size()));

Returns:

Size in bytes required for field storage

Public Static Attributes

static constexpr int components = specfem::element::attributes<DimensionTag, MediumTag>::components

Number of field components based on dimension and medium type.

static constexpr int nedges = ChunkSize

Number of edges in the chunk.

static constexpr int ngll = NGLL

Number of Gauss-Lobatto-Legendre points per spatial dimension.

static constexpr auto medium_tag = MediumTag

Medium tag identifying the physical medium type.

static constexpr auto accessor_type = specfem::data_access::AccessorType::chunk_edge

Accessor pattern identifier.

static constexpr auto data_class = DataClass

Data classification type.

static constexpr auto dimension_tag = DimensionTag

Spatial dimension.

static constexpr bool using_simd = UseSIMD

SIMD vectorization flag.

Private Types

using base_type = specfem::data_access::Accessor<specfem::data_access::AccessorType::chunk_edge, DataClass, DimensionTag, UseSIMD>

Type alias for the base accessor class.

Private Members

value_type m_data

Internal storage for chunk field data.