specfem::assembly::sources_impl::source_medium

template<specfem::element::dimension_tag DimensionTag, specfem::element::medium_tag MediumTag>
struct source_medium

Medium-specific source data management for spectral element simulations.

Manages source time functions, Lagrange interpolants, and element mappings for a specific (dimension, medium) pair.

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

  • MediumTag – Physical medium type (elastic_psv, acoustic, etc.)

Public Type Constants

static constexpr auto medium_tag = MediumTag

Physical medium type.

static constexpr auto dimension_tag = DimensionTag

Spatial dimension.

static constexpr auto ndim = (DimensionTag == specfem::element::dimension_tag::dim2) ? 2 : 3

Number of spatial dimensions.

static constexpr int source_array_rank = ndim + 2

Rank of source array (ndim GLL + source index + component)

Data Members

IndexView source_index_mapping

Maps source index to element index (device)

IndexView::host_mirror_type h_source_index_mapping

Maps source index to element index (host)

SourceTimeFunctionView source_time_function

Source time function values [timestep][source][component] (device)

SourceTimeFunctionView::host_mirror_type h_source_time_function

Source time function values (host)

SourceArrayView source_array

Lagrange interpolant weights at GLL points (device)

SourceArrayView::host_mirror_type h_source_array

Lagrange interpolant weights (host)

Constructors

source_medium() = default

Default constructor.

template<specfem::element::dimension_tag U = DimensionTag, typename std::enable_if<U == specfem::element::dimension_tag::dim2>::type* = nullptr>
source_medium(const std::vector<std::shared_ptr<specfem::sources::source<DimensionTag>>> &sources, const specfem::assembly::mesh<DimensionTag> &mesh, const specfem::assembly::jacobian_matrix<DimensionTag> &jacobian_matrix, const specfem::assembly::element_types<DimensionTag> &element_types, const type_real t0, const type_real dt, const int nsteps)

Construct 2D source medium from source list.

Initializes source time functions and Lagrange interpolants for all sources in the specified medium. Computes source arrays at GLL points.

Parameters:
  • sources – Source objects for this medium

  • mesh – Finite element mesh

  • jacobian_matrix – Jacobian transformation matrices

  • element_types – Element classification data

  • t0 – Initial simulation time

  • dt – Time step size

  • nsteps – Total number of time steps

template<specfem::element::dimension_tag U = DimensionTag, typename std::enable_if<U == specfem::element::dimension_tag::dim3>::type* = nullptr>
source_medium(const std::vector<std::shared_ptr<specfem::sources::source<DimensionTag>>> &sources, const specfem::assembly::mesh<DimensionTag> &mesh, const specfem::assembly::jacobian_matrix<DimensionTag> &jacobian_matrix, const specfem::assembly::element_types<DimensionTag> &element_types, const type_real t0, const type_real dt, const int nsteps)

Construct 3D source medium from source list.

Initializes source time functions and Lagrange interpolants for all sources in the specified medium. Computes source arrays at GLL points.

Parameters:
  • sources – Source objects for this medium

  • mesh – Finite element mesh

  • jacobian_matrix – Jacobian transformation matrices

  • element_types – Element classification data

  • t0 – Initial simulation time

  • dt – Time step size

  • nsteps – Total number of time steps

Public Functions

template<typename IndexType, typename PointSourceType, specfem::element::dimension_tag U = DimensionTag, typename std::enable_if<U == specfem::element::dimension_tag::dim2>::type* = nullptr>
void load_on_device(const int timestep, const IndexType &index, PointSourceType &point_source) const

Load source data on device for 2D simulations.

Retrieves source time function and Lagrange interpolants for a specific timestep and GLL point.

Template Parameters:
  • IndexType – Index type containing source and GLL coordinates

  • PointSourceType – Target point source structure

Parameters:
  • timestep – Current time step index

  • index – Source and grid point indices

  • point_source – [out] Populated with source data

template<typename IndexType, typename PointSourceType, specfem::element::dimension_tag U = DimensionTag, typename std::enable_if<U == specfem::element::dimension_tag::dim3>::type* = nullptr>
void load_on_device(const int timestep, const IndexType &index, PointSourceType &point_source) const

Load source data on device for 3D simulations.

Retrieves source time function and Lagrange interpolants for a specific timestep and GLL point.

Template Parameters:
  • IndexType – Index type containing source and GLL coordinates

  • PointSourceType – Target point source structure

Parameters:
  • timestep – Current time step index

  • index – Source and grid point indices

  • point_source – [out] Populated with source data

template<typename IndexType, typename PointSourceType, specfem::element::dimension_tag U = DimensionTag, typename std::enable_if<U == specfem::element::dimension_tag::dim2>::type* = nullptr>
void store_on_device(const int timestep, const IndexType index, const PointSourceType &point_source) const

Store source data on device for 2D simulations.

Writes source time function and Lagrange interpolants to device memory.

Template Parameters:
  • IndexType – Index type containing source and GLL coordinates

  • PointSourceType – Source point source structure

Parameters:
  • timestep – Current time step index

  • index – Source and grid point indices

  • point_source – [in] Source data to store

template<typename IndexType, typename PointSourceType, specfem::element::dimension_tag U = DimensionTag, typename std::enable_if<U == specfem::element::dimension_tag::dim3>::type* = nullptr>
void store_on_device(const int timestep, const IndexType index, const PointSourceType &point_source) const

Store source data on device for 3D simulations.

Writes source time function and Lagrange interpolants to device memory.

Template Parameters:
  • IndexType – Index type containing source and GLL coordinates

  • PointSourceType – Source point source structure

Parameters:
  • timestep – Current time step index

  • index – Source and grid point indices

  • point_source – [in] Source data to store

template<typename IndexType, typename PointSourceType, specfem::element::dimension_tag U = DimensionTag, typename std::enable_if<U == specfem::element::dimension_tag::dim2>::type* = nullptr>
void load_on_host(const int timestep, const IndexType index, PointSourceType &point_source) const

Load source data on host for 2D simulations.

Retrieves source time function and Lagrange interpolants for a specific timestep and GLL point from host memory.

Template Parameters:
  • IndexType – Index type containing source and GLL coordinates

  • PointSourceType – Target point source structure

Parameters:
  • timestep – Current time step index

  • index – Source and grid point indices

  • point_source – [out] Populated with source data

template<typename IndexType, typename PointSourceType, specfem::element::dimension_tag U = DimensionTag, typename std::enable_if<U == specfem::element::dimension_tag::dim3>::type* = nullptr>
void load_on_host(const int timestep, const IndexType index, PointSourceType &point_source) const

Load source data on host for 3D simulations.

Retrieves source time function and Lagrange interpolants for a specific timestep and GLL point from host memory.

Template Parameters:
  • IndexType – Index type containing source and GLL coordinates

  • PointSourceType – Target point source structure

Parameters:
  • timestep – Current time step index

  • index – Source and grid point indices

  • point_source – [out] Populated with source data

template<typename IndexType, typename PointSourceType, specfem::element::dimension_tag U = DimensionTag, typename std::enable_if<U == specfem::element::dimension_tag::dim2>::type* = nullptr>
void store_on_host(const int timestep, const IndexType index, const PointSourceType &point_source) const

Store source data on host for 2D simulations.

Writes source time function and Lagrange interpolants to host memory.

Template Parameters:
  • IndexType – Index type containing source and GLL coordinates

  • PointSourceType – Source point source structure

Parameters:
  • timestep – Current time step index

  • index – Source and grid point indices

  • point_source – [in] Source data to store

template<typename IndexType, typename PointSourceType, specfem::element::dimension_tag U = DimensionTag, typename std::enable_if<U == specfem::element::dimension_tag::dim3>::type* = nullptr>
void store_on_host(const int timestep, const IndexType index, const PointSourceType &point_source) const

Store source data on host for 3D simulations.

Writes source time function and Lagrange interpolants to host memory.

Template Parameters:
  • IndexType – Index type containing source and GLL coordinates

  • PointSourceType – Source point source structure

Parameters:
  • timestep – Current time step index

  • index – Source and grid point indices

  • point_source – [in] Source data to store