PrincetonUniversity/SPECFEMPP

Simplify medium access for kernels and properties

Closed this issue · 0 comments

icui commented

Define a method for kernels and properties

template <specfem::element::medium_tag MediumTag, specfem::element::property_tag PropertyTag>
    constexpr specfem::compute::impl::kernels::material_kernels<
        MediumTag,
        PropertyTag> get_medium(const kernels &kernels) {

    if constexpr ((MediumTag == specfem::element::medium_tag::elastic) &&
                  (PropertyTag == specfem::element::property_tag::isotropic)) {
      return kernels.elastic_isotropic;
    } else if constexpr ((MediumTag == specfem::element::medium_tag::elastic) &&
                        (PropertyTag ==
                          specfem::element::property_tag::anisotropic)) {
      return kernels.elastic_anisotropic;
    } else if constexpr ((MediumTag == specfem::element::medium_tag::acoustic) &&
                        (PropertyTag ==
                          specfem::element::property_tag::isotropic)) {
      return kernels.acoustic_isotropic;
    } else {
      static_assert("Material type not implemented");
    }
  }

So that calling medium methods can be simplified to e.g.

get_medium<PointKernelType>(kernels).load_device_kernels(l_index, point_kernels);