specfem::algorithms::gradient

template<typename ChunkIndexType, typename VectorFieldType, typename JacobianMatrixType, typename QuadratureType, typename CallbackFunctor, std::enable_if_t<specfem::data_access::is_chunk_element<VectorFieldType>::value, int> = 0>
void gradient(const ChunkIndexType &chunk_index, const JacobianMatrixType &jacobian_matrix, const QuadratureType &quadrature, const VectorFieldType &f, const CallbackFunctor &callback)

Compute the gradient of a vector field f using the spectral element formulation (eqn: 29 in Komatitsch and Tromp, 1999)

Template Parameters:
  • ChunkIndexType – Chunk index type

  • VectorFieldType – Field view type (Chunk view)

  • QuadratureType – Quadrature view type

  • CallbackFunctor – Callback functor type

Parameters:
  • chunk_index – Chunk index specifying the elements within this chunk

  • jacobian_matrix – Jacobian matrix of basis functions

  • quadrature – Integration quadrature

  • f – Field to compute the gradient of

  • callback – Callback functor receiving (iterator_index, TensorPointViewType<components, dim>)

template<typename ChunkIndexType, typename VectorFieldType, typename JacobianMatrixType, typename QuadratureType, typename CallbackFunctor, std::enable_if_t<specfem::data_access::is_chunk_element<VectorFieldType>::value, int> = 0>
void gradient(const ChunkIndexType &chunk_index, const JacobianMatrixType &jacobian_matrix, const QuadratureType &quadrature, const VectorFieldType &f, const VectorFieldType &g, const CallbackFunctor &callback)

Compute the gradients of two vector fields f and g using the spectral element formulation (eqn: 29 in Komatitsch and Tromp, 1999)

Template Parameters:
  • ChunkIndexType – Chunk index type

  • VectorFieldType – Field view type (Chunk view)

  • QuadratureType – Quadrature view type

  • CallbackFunctor – Callback functor type

Parameters:
  • chunk_index – Chunk index specifying the elements within this chunk

  • jacobian_matrix – Jacobian matrix of basis functions

  • quadrature – Integration quadrature

  • f – First field to compute the gradient of

  • g – Second field to compute the gradient of

  • callback – Callback functor receiving (iterator_index, TensorPointViewType<components, dim>, TensorPointViewType<components, dim>)

template<typename ChunkIndexType, typename VectorFieldType, typename JacobianMatrixType, typename QuadratureType, typename CallbackFunctor>
void gradient(const ChunkIndexType &chunk_index, const JacobianMatrixType &jacobian_matrix, const QuadratureType &quadrature, const specfem::chunk_element::FieldPack<VectorFieldType> &field_pack, const CallbackFunctor &callback)

Compute the gradient of a FieldPack<F> using the spectral element formulation. The callback receives a GradientPack<TF>.

Template Parameters:
  • ChunkIndexType – Chunk index type

  • VectorFieldType – Chunk element field type held as .f

  • QuadratureType – Quadrature view type

  • CallbackFunctor – Callback functor receiving (iterator_index, GradientPack<TF>)

template<typename ChunkIndexType, typename VectorFieldTypeF, typename VectorFieldTypeG, typename JacobianMatrixType, typename QuadratureType, typename CallbackFunctor>
void gradient(const ChunkIndexType &chunk_index, const JacobianMatrixType &jacobian_matrix, const QuadratureType &quadrature, const specfem::chunk_element::FieldPack<VectorFieldTypeF, VectorFieldTypeG> &field_pack, const CallbackFunctor &callback)

Compute the gradients of a FieldPack<F, G> using the spectral element formulation. The callback receives a GradientPack<TF, TG>.

Template Parameters:
  • ChunkIndexType – Chunk index type

  • VectorFieldTypeF – Chunk element field type held as .f

  • VectorFieldTypeG – Chunk element field type held as .g

  • QuadratureType – Quadrature view type

  • CallbackFunctor – Callback functor receiving (iterator_index, GradientPack<TF, TG>)

Implementation Details

template<typename VectorFieldType, typename QuadratureType, typename std::enable_if_t<VectorFieldType::dimension_tag == specfem::element::dimension_tag::dim2, int> = 0>
auto specfem::algorithms::impl::element_gradient(const VectorFieldType &f, const specfem::point::index<specfem::element::dimension_tag::dim2, VectorFieldType::using_simd> &local_index, const specfem::point::jacobian_matrix<specfem::element::dimension_tag::dim2, false, VectorFieldType::using_simd> &point_jacobian_matrix, const QuadratureType &lagrange_derivative, typename VectorFieldType::simd::datatype (&df_dxi)[VectorFieldType::components], typename VectorFieldType::simd::datatype (&df_dgamma)[VectorFieldType::components])

Compute the gradient of a vector field at a specific point in a 2D spectral element.

Template Parameters:
  • VectorFieldType – Type of the vector field (must be 2D)

  • QuadratureType – Type of the Lagrange derivative polynomial

Parameters:
  • f – Vector field to compute gradient of

  • local_index – Local indices within the spectral element

  • point_jacobian_matrix – Jacobian matrix for coordinate transformation

  • lagrange_derivative – Lagrange derivative polynomials for differentiation

  • df_dxi – Output array for derivatives with respect to xi

  • df_dgamma – Output array for derivatives with respect to gamma

Returns:

Auto-deduced return type containing the gradient values

template<typename VectorFieldType, typename QuadratureType, typename std::enable_if_t<VectorFieldType::dimension_tag == specfem::element::dimension_tag::dim3, int> = 0>
auto specfem::algorithms::impl::element_gradient(const VectorFieldType &f, const specfem::point::index<specfem::element::dimension_tag::dim3, VectorFieldType::using_simd> &local_index, const specfem::point::jacobian_matrix<specfem::element::dimension_tag::dim3, false, VectorFieldType::using_simd> &point_jacobian_matrix, const QuadratureType &lagrange_derivative, typename VectorFieldType::simd::datatype (&df_dxi)[VectorFieldType::components], typename VectorFieldType::simd::datatype (&df_deta)[VectorFieldType::components], typename VectorFieldType::simd::datatype (&df_dgamma)[VectorFieldType::components])

Compute the gradient of a vector field at a specific point in a 3D spectral element.

Template Parameters:
  • VectorFieldType – Type of the vector field (must be 3D)

  • QuadratureType – Type of the Lagrange derivative polynomial

Parameters:
  • f – Vector field to compute gradient of

  • local_index – Local indices within the spectral element

  • point_jacobian_matrix – Jacobian matrix for coordinate transformation

  • lagrange_derivative – Lagrange derivative polynomials for differentiation

  • df_dxi – Output array for derivatives with respect to xi

  • df_deta – Output array for derivatives with respect to eta

  • df_dgamma – Output array for derivatives with respect to gamma

Returns:

Auto-deduced return type containing the gradient values