Skip to content

1719 - Implement tag_dispatch::for_each#1770

Open
icui wants to merge 8 commits intoissue-1719from
1719-td
Open

1719 - Implement tag_dispatch::for_each#1770
icui wants to merge 8 commits intoissue-1719from
1719-td

Conversation

@icui
Copy link
Copy Markdown
Collaborator

@icui icui commented Apr 2, 2026

Description

  • Implement tag_dispatch::for_each_in_product
  • Apply to compute_stiffness_interaction
specfem::tag_dispatch::for_each<
    specfem::tag_dispatch::dimension_set<DimensionTag> *
    specfem::tag_dispatch::medium_set<MediumTag> *
    PROPERTY_T(isotropic, anisotropic, isotropic_cosserat) *
    BOUNDARY_T(none, stacey, acoustic_free_surface, composite_stacey_dirichlet)>([&]<typename Tags>() {
    if constexpr (DimensionTag == Tags::dimension_tag &&
                    MediumTag == Tags::medium_tag) {
        elements_updated += compute_stiffness_interaction_core<
            NGLL, Tags>(assembly, istep);
    }
});

Not implemented in this PR, but element_types will look like

class ElementTypes {
public:
  static constexpr auto ET =
      DIMENSION_T(dim2) *
      MEDIUM_T(elastic_psv, elastic_sh, elastic_psv_t, acoustic, poroelastic, electromagnetic_te) *
      PROPERTY_T(isotropic, anisotropic, isotropic_cosserat) *
      ATTENUATION_T(none, constant_isotropic) *
      BOUNDARY_T(none, stacey, acoustic_free_surface, composite_stacey_dirichlet);

...

int total_elements() const {
    int total = 0;
    specfem::tag_dispatch::for_each(ET, [&]<typename Tags>() { total += elements.get<Tags>().extent(0); });

    // we could also do
    //  return elements.reduce([](int sum, const auto& view) { return sum +
    //  view.extent(0); });
    return total;
  }

Issue Number

Adds to #1719

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

@icui icui marked this pull request as draft April 2, 2026 03:52
@icui icui requested review from Rohit-Kakodkar and lsawade April 2, 2026 03:52
@icui icui changed the title 1719 - Implement tag_dispatch::for_each_in_product 1719 - Implement tag_dispatch::for_each Apr 2, 2026
@icui icui requested review from Rohit-Kakodkar and lsawade April 2, 2026 18:49
@icui icui marked this pull request as ready for review April 2, 2026 18:49
@icui icui requested review from int-ptr-ptr and maxlchien April 2, 2026 18:50
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.

1 participant