specfem::chunk_element::impl::field¶
-
template<int ChunkSize, int NGLL, specfem::element::dimension_tag DimensionTag, specfem::element::medium_tag MediumTag, specfem::data_access::DataClassType DataClass, bool UseSIMD>
class field : public specfem::data_access::Accessor<specfem::datatype::AccessorType::chunk_element, DataClass, DimensionTag, UseSIMD>¶ Chunk element field accessor for storing field values at all quadrature points within a chunk.
This class provides an accessor interface for chunk-based element field data, supporting efficient storage and access to field values at all Gauss-Lobatto-Legendre (GLL) quadrature points within a chunk of elements. It is designed for use in chunk execution policies where spacial locality of data is critical for performance. An example usage is shown below:
// Compute the gradient of a field using ChunkField = ... int scratch_size = ChunkField::shmem_size(); specfem::execution::ChunkedDomainIterator chunk(...) specfem::execution::for_each_level("compute_gradient", chunk.set_scratch_size(scratch_size), KOKKOS_LAMBDA(const decltype(chunk)::index_type &index) { ChunkField field(chunk.team_scratch(0)); specfem::assembly::load_on_device(index.get_index(), field_container, field); specfem::algorithms::gradient(..., field, [&](..., gradient_value) { // Store the computed gradient value back to the field }); });
- Template Parameters:
ChunkSize – Number of elements 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.
Subclassed by specfem::chunk_element::acceleration< ChunkSize, NGLL, DimensionTag, MediumTag, UseSIMD >, specfem::chunk_element::displacement< ChunkSize, NGLL, DimensionTag, MediumTag, UseSIMD >, specfem::chunk_element::velocity< ChunkSize, NGLL, DimensionTag, MediumTag, UseSIMD >
Public Types
-
using value_type = typename base_type::template vector_type<type_real, nelements, ngll, components>¶
Vector type for storing chunk field data with optimized layout.
-
template<typename T, int nelements, int ngll>
using scalar_type = specfem::datatype::ScalarChunkElementViewType<T, DimensionTag, nelements, ngll, UseSIMD>¶ Scalar field storage for chunked elements.
- Template Parameters:
T – Base data type
nelements – Number of elements in the chunk
ngll – Number of GLL points per element dimension
-
template<typename T, int nelements, int ngll, int components>
using vector_type = specfem::datatype::VectorChunkElementViewType<T, DimensionTag, nelements, ngll, components, UseSIMD>¶ Vector field storage for chunked elements.
- Template Parameters:
T – Base data type
nelements – Number of elements in the chunk
ngll – Number of GLL points per element dimension
components – Number of vector components
-
template<typename T, int nelements, int ngll, int components, int dimension>
using tensor_type = specfem::datatype::TensorChunkElementViewType<T, DimensionTag, nelements, ngll, components, dimension, UseSIMD>¶ Tensor field storage for chunked elements.
- Template Parameters:
T – Base data type
nelements – Number of elements in the chunk
ngll – Number of GLL points per element dimension
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 element fields, the indexing typically follows the pattern: (element_id, gll_indices…, component_id).
// For 2D fields: (element, i_gll, j_gll, component) auto disp_x = field(ielem, i, j, 0); // x-component auto disp_z = field(ielem, i, j, 1); // z-component field(ielem, i, j, 0) = new_value; // For 3D fields: (element, i_gll, j_gll, k_gll, component) auto value = field(ielem, i, j, k, icomp);
- 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 value_type &get_data() const¶
Access internal field data storage.
- Returns:
const reference to the internal value_type storing field components
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 auto dimension_tag = DimensionTag¶
Dimension tag identifying the physical medium type.
-
static constexpr auto accessor_type = specfem::datatype::AccessorType::chunk_element¶
Accessor pattern identifier.
Private Types
-
using base_type = specfem::data_access::Accessor<specfem::datatype::AccessorType::chunk_element, DataClass, DimensionTag, UseSIMD>¶
Type alias for the base accessor class.
Private Members
-
value_type m_data¶
Internal storage for chunk field data.