specfem::assembly::sources_impl::source_medium¶
-
template<specfem::dimension::type DimensionTag, specfem::element::medium_tag MediumTag>
struct source_medium¶ Medium-specific source data management for spectral element simulations.
This class manages source information for a specific medium type within the spectral element framework, providing efficient storage and access patterns for source time functions, Lagrange interpolants, and element mappings. Sources are organized by medium type to enable optimized computational kernels.
Note
This class is an implementation detail and should be only used within specfem::assembly::sources.
- Template Parameters:
DimensionTag – Spatial dimension (
dim2ordim3)MediumTag – Physical medium type (
elastic_psv,acoustic, etc.)
Private Type Definitions
Kokkos view types for efficient memory management and data access.
Public Constants
Template-dependent constants defining the characteristics of this source medium specialization.
-
static constexpr auto dimension_tag = DimensionTag¶
Spatial dimension identifier for this specialization.
-
static constexpr auto ndim = (DimensionTag == specfem::dimension::type::dim2) ? 2 : 3¶
Number of spatial dimensions (2 for 2D, 3 for 3D)
Data Members
Core data storage for medium-specific source information with device/host memory pairs for efficient computation.
-
IndexView source_index_mapping¶
Device view mapping sources to spectral element indices.
Contains the spectral element index (
ispec) for each source in this medium, enabling direct lookup during assembly operations.
-
IndexView::HostMirror h_source_index_mapping¶
Host mirror of spectral element index mapping.
Host-accessible copy of
source_index_mappingfor initialization and debugging.
-
SourceTimeFunctionView source_time_function¶
Device view storing time-dependent source functions.
3D array layout: [nsources][ncomponents][nsteps] Contains pre-computed or interpolated source amplitudes for each time step, component, and source in this medium.
-
SourceTimeFunctionView::HostMirror h_source_time_function¶
Host mirror of source time functions.
Host-accessible copy of
source_time_functionfor setup and analysis.
-
SourceArrayView source_array¶
Device view storing Lagrange interpolation weights.
Multi-dimensional array containing pre-computed Lagrange interpolant values at source locations within spectral elements:
2D: [nsources][ncomponents][ngllz][ngllx]
3D: [nsources][ncomponents][ngllz][nglly][ngllx]
-
SourceArrayView::HostMirror h_source_array¶
Host mirror of Lagrange interpolation weights.
Host-accessible copy of
source_arrayfor initialization and validation.
Constructors
Object lifecycle management for medium-specific source data structures.
-
source_medium() = default¶
Default constructor.
Creates an empty source medium structure. Use the parameterized constructor to initialize with actual source data.
Construct 2D source medium from mesh and source data.
Initializes source data structures for 2D problems by:
Computing Lagrange interpolants at source locations
Setting up time function storage and evaluation
Creating efficient device/host memory layouts
Establishing element-to-source mappings
- Parameters:
sources – Vector of source objects for this medium type
mesh – 2D finite element mesh with element connectivity
jacobian_matrix – Jacobian matrices for coordinate transformations
element_types – Element classification data
t0 – Initial time for source evaluation
dt – Time step size for discretization
nsteps – Total number of time steps
Construct 3D source medium from mesh and source data.
Initializes source data structures for 3D problems by:
Computing Lagrange interpolants at source locations in 3D space
Setting up time function storage and evaluation
Creating efficient device/host memory layouts for 3D arrays
Establishing element-to-source mappings
- Parameters:
sources – Vector of source objects for this medium type
mesh – 3D finite element mesh with element connectivity
jacobian_matrix – Jacobian matrices for 3D coordinate transformations
element_types – Element classification data
t0 – Initial time for source evaluation
dt – Time step size for discretization
nsteps – Total number of time steps
Data Access Functions
Template functions for efficient source data loading and storing on both device and host execution spaces, specialized for 2D and 3D problems.
-
template<typename IndexType, typename PointSourceType, specfem::dimension::type U = DimensionTag, typename std::enable_if<U == specfem::dimension::type::dim2>::type* = nullptr>
void load_on_device(const int timestep, const IndexType &index, PointSourceType &point_source) const¶ Load 2D source data for device-based computations.
Retrieves source information from device memory for 2D problems, including time-dependent amplitudes and Lagrange interpolation weights.
Note
This function is an implementation detail and is called by higher-level
load_on_devicefunction.- Template Parameters:
IndexType – Point index type for element-source mapping
PointSourceType – Point source data structure
- Parameters:
timestep – Current time step index for source function evaluation
index – Element index containing source location information
point_source – [out] Output structure populated with 2D source data
-
template<typename IndexType, typename PointSourceType, specfem::dimension::type U = DimensionTag, typename std::enable_if<U == specfem::dimension::type::dim3>::type* = nullptr>
void load_on_device(const int timestep, const IndexType &index, PointSourceType &point_source) const¶ Load 3D source data for device-based computations.
Retrieves source information from device memory for 3D problems, including time-dependent amplitudes and Lagrange interpolation weights.
Note
This function is an implementation detail and is called by higher-level
load_on_devicefunction.- Template Parameters:
IndexType – Point index type for element-source mapping
PointSourceType – Point source data structure
- Parameters:
timestep – Current time step index for source function evaluation
index – Element index containing source location information
point_source – [out] Output structure populated with 3D source data
-
template<typename IndexType, typename PointSourceType, specfem::dimension::type U = DimensionTag, typename std::enable_if<U == specfem::dimension::type::dim2>::type* = nullptr>
void store_on_device(const int timestep, const IndexType index, const PointSourceType &point_source) const¶ Store 2D source data from device computations.
Writes computed source data back to device memory for 2D problems. Used in adjoint computations and source inversion algorithms where source parameters are updated during GPU-based iterative processes.
Note
This function is an implementation detail and is called by higher-level
store_on_devicefunction.- Template Parameters:
IndexType – Point index type for element-source mapping
PointSourceType – Point source data structure
- Parameters:
timestep – Current time step index for source data storage
index – Element index identifying source storage location
point_source – [in] Source data to be stored in device memory
-
template<typename IndexType, typename PointSourceType, specfem::dimension::type U = DimensionTag, typename std::enable_if<U == specfem::dimension::type::dim3>::type* = nullptr>
void store_on_device(const int timestep, const IndexType index, const PointSourceType &point_source) const¶ Store 3D source data from device computations.
Writes computed source data back to device memory for 3D problems. Used in adjoint computations and source inversion algorithms where source parameters are updated during GPU-based iterative processes.
Note
This function is an implementation detail and is called by higher-level
store_on_devicefunction.- Template Parameters:
IndexType – Point index type for element-source mapping
PointSourceType – Point source data structure
- Parameters:
timestep – Current time step index for source data storage
index – Element index identifying source storage location
point_source – [in] Source data to be stored in device memory
-
template<typename IndexType, typename PointSourceType, specfem::dimension::type U = DimensionTag, typename std::enable_if<U == specfem::dimension::type::dim2>::type* = nullptr>
void load_on_host(const int timestep, const IndexType index, PointSourceType &point_source) const¶ Load 2D source data for host-based computations.
Retrieves source information from host memory for 2D problems during CPU-based processing, initialization, and analysis operations. Provides access to time functions and interpolation weights for host algorithms.
Note
This function is an implementation detail and is called by higher-level
load_on_devicefunction.- Template Parameters:
IndexType – Point index type for element-source mapping
PointSourceType – Point source data structure
- Parameters:
timestep – Current time step index for source function evaluation
index – Element index containing source location information
point_source – [out] Output structure populated with 2D source data
-
template<typename IndexType, typename PointSourceType, specfem::dimension::type U = DimensionTag, typename std::enable_if<U == specfem::dimension::type::dim3>::type* = nullptr>
void load_on_host(const int timestep, const IndexType index, PointSourceType &point_source) const¶ Load 3D source data for host-based computations.
Retrieves source information from host memory for 3D problems during CPU-based processing, initialization, and analysis operations. Provides access to time functions and interpolation weights for host algorithms.
Note
This function is an implementation detail and is called by higher-level
load_on_devicefunction.- Template Parameters:
IndexType – Point index type for element-source mapping
PointSourceType – Point source data structure
- Parameters:
timestep – Current time step index for source function evaluation
index – Element index containing source location information
point_source – [out] Output structure populated with 3D source data
-
template<typename IndexType, typename PointSourceType, specfem::dimension::type U = DimensionTag, typename std::enable_if<U == specfem::dimension::type::dim2>::type* = nullptr>
void store_on_host(const int timestep, const IndexType index, const PointSourceType &point_source) const¶ Store 2D source data from host computations.
Writes computed source data back to host memory for 2D problems. Used in preprocessing, initialization, and host-based iterative algorithms where source parameters are updated on the CPU.
- Template Parameters:
IndexType – Point index type for element-source mapping
PointSourceType – Point source data structure
- Parameters:
timestep – Current time step index for source data storage
index – Element index identifying source storage location
point_source – [in] Source data to be stored in host memory
-
template<typename IndexType, typename PointSourceType, specfem::dimension::type U = DimensionTag, typename std::enable_if<U == specfem::dimension::type::dim3>::type* = nullptr>
void store_on_host(const int timestep, const IndexType index, const PointSourceType &point_source) const¶ Store 3D source data from host computations.
Writes computed source data back to host memory for 3D problems. Used in preprocessing, initialization, and host-based iterative algorithms where source parameters are updated on the CPU.
- Template Parameters:
IndexType – Point index type for element-source mapping
PointSourceType – Point source data structure
- Parameters:
timestep – Current time step index for source data storage
index – Element index identifying source storage location
point_source – [in] Source data to be stored in host memory