specfem::algorithms::gradient

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

Compute the gradient of a scalar 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. Callback signature must be:

     void(const typename IteratorType::index_type, const
    specfem::datatype::TensorPointViewType<type_real, 2,
    VectorFieldType::components>)
    

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

Compute the gradient of a field f & 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 – Field to compute the gradient of

  • g – Field to compute the gradient of

  • callback – Callback functor. Callback signature must be:

     void(const typename IteratorType::index_type, const
    specfem::datatype::TensorPointViewType<type_real, 2,
    VectorFieldType::components>, const
    specfem::datatype::TensorPointViewType<type_real, 2,
    VectorFieldType::components>)
    

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

Compute the gradient of a scalar field f using the spectral element formulation for 3D elements.

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. Callback signature must be:

     void(const typename IteratorType::index_type, const
    specfem::datatype::TensorPointViewType<type_real, 3,
    VectorFieldType::components>)
    

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

Compute the gradient of a field f & g using the spectral element formulation for 3D elements.

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

  • g – Field to compute the gradient of

  • callback – Callback functor. Callback signature must be:

     void(const typename IteratorType::index_type, const
    specfem::datatype::TensorPointViewType<type_real, 3,
    VectorFieldType::components>, const
    specfem::datatype::TensorPointViewType<type_real, 3,
    VectorFieldType::components>)
    

Implementation Details

template<typename VectorFieldType, typename QuadratureType, typename std::enable_if_t<VectorFieldType::dimension_tag == specfem::dimension::type::dim2, int> = 0>
auto specfem::algorithms::impl::element_gradient(const VectorFieldType &f, const specfem::point::index<specfem::dimension::type::dim2, VectorFieldType::using_simd> &local_index, const specfem::point::jacobian_matrix<specfem::dimension::type::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::dimension::type::dim3, int> = 0>
auto specfem::algorithms::impl::element_gradient(const VectorFieldType &f, const specfem::point::index<specfem::dimension::type::dim3, VectorFieldType::using_simd> &local_index, const specfem::point::jacobian_matrix<specfem::dimension::type::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