Tensor Source Implementation

2D Tensor Sources

void specfem::assembly::compute_source_array_impl::from_tensor(const specfem::sources::tensor_source<specfem::dimension::type::dim2> &source, const specfem::assembly::mesh<specfem::dimension::type::dim2> &mesh, const specfem::assembly::jacobian_matrix<specfem::dimension::type::dim2> &jacobian_matrix, Kokkos::View<type_real***, Kokkos::LayoutRight, Kokkos::HostSpace> source_array)

Compute source array for a 2D tensor source using spatial derivatives.

For moment tensor sources, computes source contributions by transforming tensor components via spatial derivatives of Lagrange basis functions: \( S_{i,jz,jx} = M_{i,0} \frac{\partial L}{\partial x} + M_{i,1} \frac{\partial L}{\partial z} \)

Derivatives are computed using the chain rule with Jacobian matrix elements.

Parameters:
  • source – Tensor source containing moment tensor components

  • mesh – Mesh providing quadrature information

  • jacobian_matrix – Coordinate transformation Jacobians at GLL points

  • source_array – Output array of shape (ncomponents, ngllz, ngllx)

void specfem::assembly::compute_source_array_impl::compute_source_array_from_tensor_and_element_jacobian(const specfem::sources::tensor_source<specfem::dimension::type::dim2> &tensor_source, const JacobianViewType2D &element_jacobian_matrix, const specfem::assembly::mesh_impl::quadrature<specfem::dimension::type::dim2> &quadrature, Kokkos::View<type_real***, Kokkos::LayoutRight, Kokkos::HostSpace> source_array)

Helper function computing tensor source array with precomputed Jacobians.

Algorithm:

  1. Compute Lagrange polynomials and derivatives at source location

  2. Build source polynomial field from interpolants

  3. Transform to physical space using Jacobian chain rule: \( \frac{\partial L}{\partial x} = \frac{\partial L}{\partial \xi} \frac{\partial \xi}{\partial x} + \frac{\partial L}{\partial \gamma} \frac{\partial \gamma}{\partial x} \)

  4. Apply moment tensor: \( S_i = M_{i,0} \frac{\partial L}{\partial x} + M_{i,1} \frac{\partial L}{\partial z} \)

Separates Jacobian extraction from computation for testability.

Note

The derivatives are computed using element Jacobian matrices to map from reference coordinates (xi, gamma) to physical coordinates (x, z).

Parameters:
  • tensor_source – Tensor source object

  • element_jacobian_matrix – Precomputed Jacobian matrices for the element

  • quadrature – Quadrature containing GLL points

  • source_array – Output array

3D Tensor Sources

void specfem::assembly::compute_source_array_impl::from_tensor(const specfem::sources::tensor_source<specfem::dimension::type::dim3> &source, const specfem::assembly::mesh<specfem::dimension::type::dim3> &mesh, const specfem::assembly::jacobian_matrix<specfem::dimension::type::dim3> &jacobian_matrix, Kokkos::View<type_real****, Kokkos::LayoutRight, Kokkos::HostSpace> source_array)

Compute source array for a 3D tensor source using spatial derivatives.

For moment tensor sources, computes contributions by transforming tensor components via spatial derivatives: \( S_{i,jz,jy,jx} = M_{i,0} \frac{\partial L}{\partial x} + M_{i,1} \frac{\partial L}{\partial y} + M_{i,2} \frac{\partial L}{\partial z} \)

Parameters:
  • source – Tensor source containing moment tensor components

  • mesh – Mesh providing quadrature information

  • jacobian_matrix – Coordinate transformation Jacobians at GLL points

  • source_array – Output array of shape (ncomponents, ngllz, nglly, ngllx)

void specfem::assembly::compute_source_array_impl::compute_source_array_from_tensor_and_element_jacobian(const specfem::sources::tensor_source<specfem::dimension::type::dim3> &tensor_source, const JacobianViewType3D &element_jacobian_matrix, const specfem::assembly::mesh_impl::quadrature<specfem::dimension::type::dim3> &quadrature, Kokkos::View<type_real****, Kokkos::LayoutRight, Kokkos::HostSpace> source_array)

Helper function computing tensor source array with precomputed Jacobians.

Algorithm:

  1. Compute Lagrange polynomials and derivatives at source location

  2. Build 3D source polynomial field from interpolants

  3. Transform to physical space using 3D Jacobian chain rule: \( \frac{\partial L}{\partial x} = \sum_{\zeta \in \{\xi,\eta,\gamma\}} \frac{\partial L}{\partial \zeta} \frac{\partial \zeta}{\partial x} \)

  4. Apply moment tensor: \( S_i = M_{i,0} \frac{\partial L}{\partial x} + M_{i,1} \frac{\partial L}{\partial y} + M_{i,2} \frac{\partial L}{\partial z} \)

Separates Jacobian extraction from computation for testability.

Note

The derivatives are computed using element Jacobian matrices to map from reference coordinates (xi, eta, gamma) to physical coordinates (x, y, z).

Parameters:
  • tensor_source – Tensor source object

  • element_jacobian_matrix – Precomputed Jacobian matrices for the element

  • quadrature – Quadrature containing GLL points

  • source_array – Output array