Skip to content

1064 Tags Part III - New tag syntax for stress and mass matrix (proposal)#1667

Merged
icui merged 5 commits into1064-tagsfrom
1064-stress
Mar 7, 2026
Merged

1064 Tags Part III - New tag syntax for stress and mass matrix (proposal)#1667
icui merged 5 commits into1064-tagsfrom
1064-stress

Conversation

@icui
Copy link
Copy Markdown
Collaborator

@icui icui commented Feb 24, 2026

Description

The new Tags syntax eliminates the need to verify the type of each argument and makes the code easier to follow. It can also significantly simplify impl_compute_frechet_derivatives (not implemented yet) which currently uses 3 integral_constant parameters for templating.

For medium_physics
Old

template <typename PointPropertiesType, typename PointFieldDerivativesType>
KOKKOS_INLINE_FUNCTION auto
compute_stress(const PointPropertiesType &properties,
               const PointFieldDerivativesType &field_derivatives)
    -> decltype(specfem::medium_physics::impl_compute_stress(
        properties, field_derivatives)) {

  // Check whether the point is of properties type
  static_assert(
      specfem::data_access::is_point<PointPropertiesType>::value &&
          specfem::data_access::is_properties<PointPropertiesType>::value,
      "properties is not a point properties type");

  static_assert(
      specfem::data_access::is_point<PointFieldDerivativesType>::value &&
          +specfem::data_access::is_field_derivatives<
              PointFieldDerivativesType>::value,
      "field_derivatives is not a point field derivatives type");

  static_assert(PointPropertiesType::dimension_tag ==
                    PointFieldDerivativesType::dimension_tag,
                "properties and field_derivatives have different dimensions");

  static_assert(PointPropertiesType::medium_tag ==
                    PointFieldDerivativesType::medium_tag,
                "properties and field_derivatives have different medium tags");

  static_assert(
      PointPropertiesType::simd::using_simd ==
          PointFieldDerivativesType::simd::using_simd,
      "properties and field_derivatives have different SIMD settings");

  return specfem::medium_physics::impl_compute_stress(properties,
                                                      field_derivatives);

New

template <typename Tags>
KOKKOS_INLINE_FUNCTION specfem::point::stress<Tags> compute_stress(
    const specfem::point::properties<Tags> &properties,
    const specfem::point::field_derivatives<Tags> &field_derivatives) {

  return specfem::medium_physics::impl_compute_stress<Tags>(properties,
                                                            field_derivatives);

For medium/stress
Old

template <bool UseSIMD>
KOKKOS_INLINE_FUNCTION
    specfem::point::stress<specfem::element::dimension_tag::dim3,
                           specfem::element::medium_tag::acoustic, UseSIMD>
    impl_compute_stress(
        const specfem::point::properties<specfem::tags::Tags<
            specfem::element::dimension_tag::dim3,
            specfem::element::medium_tag::acoustic,
            specfem::element::property_tag::isotropic, UseSIMD> > &properties,
        const specfem::point::field_derivatives<specfem::tags::Tags<
            specfem::element::dimension_tag::dim3,
            specfem::element::medium_tag::acoustic, UseSIMD> >
            &field_derivatives);

New

template <
    typename Tags,
    std::enable_if_t<
        Tags::dimension_tag == specfem::element::dimension_tag::dim3 &&
            Tags::medium_tag == specfem::element::medium_tag::acoustic &&
            Tags::property_tag == specfem::element::property_tag::isotropic,
        int> = 0>
KOKKOS_INLINE_FUNCTION specfem::point::stress<Tags> impl_compute_stress(
    const specfem::point::properties<Tags> &properties,
    const specfem::point::field_derivatives<Tags> &field_derivatives);

Issue Number

Adds to #1064

Checklist

Please make sure to check developer documentation on specfem docs.

  • I ran the code through pre-commit to check style
  • THE DOCUMENTATION BUILDS WITHOUT WARNINGS/ERRORS
  • I have added labels to the PR (see right hand side of the PR page)
  • My code passes all the integration tests
  • I have added sufficient unittests to test my changes
  • I have added/updated documentation for the changes I am proposing
  • I have updated CMakeLists to ensure my code builds
  • My code builds across all platforms

Copy link
Copy Markdown
Collaborator

@lsawade lsawade left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?


return specfem::medium_physics::impl_compute_stress(properties,
field_derivatives);
return specfem::medium_physics::impl_compute_stress<Tags>(properties,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return specfem::medium_physics::impl_compute_stress<Tags>(properties,
// impl exists in specfem::medium_physics
return impl::compute_stress<Tags>(properties, field_derivatives);

@icui icui changed the base branch from 1064-prop to 1064-tags March 6, 2026 15:13
@icui icui merged commit ff3f125 into 1064-tags Mar 7, 2026
5 checks passed
@icui icui deleted the 1064-stress branch March 7, 2026 16:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants