diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 25932ea1f..db6629673 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -11,7 +11,7 @@ repos: - id: requirements-txt-fixer - id: trailing-whitespace - repo: https://github.com/pre-commit/mirrors-clang-format - rev: "v14.0.5" + rev: "v15.0.6" hooks: - id: clang-format types_or: [c++] diff --git a/CMakeLists.txt b/CMakeLists.txt index 7d8243a62..e1afd8c4d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -526,11 +526,6 @@ add_library( src/plotter/plot_wavefield.cpp ) -# Only define the __APPLE__ compile definition if it is defined -if (__APPLE__) - target_compile_definitions(plotter PRIVATE __APPLE__) -endif(__APPLE__) - if (NOT VTK_CXX_BUILD) target_compile_definitions( plotter @@ -548,6 +543,10 @@ else () ${VTK_LIBRARIES} ) + # Only define the __APPLE__ compile definition if it is defined + if (__APPLE__) + target_compile_definitions(plotter PRIVATE __APPLE__) + endif(__APPLE__) endif() add_library( diff --git a/include/compute/properties/impl/properties_container.hpp b/include/compute/properties/impl/properties_container.hpp index fb33f70a0..bedefcafa 100644 --- a/include/compute/properties/impl/properties_container.hpp +++ b/include/compute/properties/impl/properties_container.hpp @@ -241,6 +241,313 @@ struct properties_container +struct properties_container { + + constexpr static auto dimension = specfem::dimension::type::dim2; + constexpr static auto value_type = specfem::element::medium_tag::elastic; + constexpr static auto property_type = + specfem::element::property_tag::anisotropic; + + using ViewType = typename Kokkos::View; + + int nspec; ///< total number of acoustic spectral elements + int ngllz; ///< number of quadrature points in z dimension + int ngllx; ///< number of quadrature points in x dimension + + ViewType rho; + ViewType::HostMirror h_rho; + ViewType c11; + ViewType::HostMirror h_c11; + ViewType c13; + ViewType::HostMirror h_c13; + ViewType c15; + ViewType::HostMirror h_c15; + ViewType c33; + ViewType::HostMirror h_c33; + ViewType c35; + ViewType::HostMirror h_c35; + ViewType c55; + ViewType::HostMirror h_c55; + ViewType c12; + ViewType::HostMirror h_c12; + ViewType c23; + ViewType::HostMirror h_c23; + ViewType c25; + ViewType::HostMirror h_c25; + + properties_container() = default; + + properties_container(const int nspec, const int ngllz, const int ngllx) + : nspec(nspec), ngllz(ngllz), ngllx(ngllx), + rho("specfem::compute::properties::rho", nspec, ngllz, ngllx), + h_rho(Kokkos::create_mirror_view(rho)), + c11("specfem::compute::properties::c11", nspec, ngllz, ngllx), + h_c11(Kokkos::create_mirror_view(c11)), + c12("specfem::compute::properties::c12", nspec, ngllz, ngllx), + h_c12(Kokkos::create_mirror_view(c12)), + c13("specfem::compute::properties::c13", nspec, ngllz, ngllx), + h_c13(Kokkos::create_mirror_view(c13)), + c15("specfem::compute::properties::c15", nspec, ngllz, ngllx), + h_c15(Kokkos::create_mirror_view(c15)), + c33("specfem::compute::properties::c33", nspec, ngllz, ngllx), + h_c33(Kokkos::create_mirror_view(c33)), + c35("specfem::compute::properties::c35", nspec, ngllz, ngllx), + h_c35(Kokkos::create_mirror_view(c35)), + c55("specfem::compute::properties::c55", nspec, ngllz, ngllx), + h_c55(Kokkos::create_mirror_view(c55)), + c23("specfem::compute::properties::c23", nspec, ngllz, ngllx), + h_c23(Kokkos::create_mirror_view(c23)), + c25("specfem::compute::properties::c25", nspec, ngllz, ngllx), + h_c25(Kokkos::create_mirror_view(c25)) {} + + template < + typename PointProperties, + typename std::enable_if_t = 0> + KOKKOS_FORCEINLINE_FUNCTION void + load_device_properties(const specfem::point::index &index, + PointProperties &property) const { + + static_assert(PointProperties::dimension == dimension, + "Dimension mismatch"); + static_assert(PointProperties::medium_tag == value_type, + "Medium tag mismatch"); + static_assert(PointProperties::property_tag == property_type, + "Property tag mismatch"); + + const int ispec = index.ispec; + const int iz = index.iz; + const int ix = index.ix; + + property.c11 = c11(ispec, iz, ix); + property.c12 = c12(ispec, iz, ix); + property.c13 = c13(ispec, iz, ix); + property.c15 = c15(ispec, iz, ix); + property.c33 = c33(ispec, iz, ix); + property.c35 = c35(ispec, iz, ix); + property.c55 = c55(ispec, iz, ix); + property.c23 = c23(ispec, iz, ix); + property.c25 = c25(ispec, iz, ix); + } + + template < + typename PointProperties, + typename std::enable_if_t = 0> + KOKKOS_FORCEINLINE_FUNCTION void + load_device_properties(const specfem::point::simd_index &index, + PointProperties &property) const { + + static_assert(PointProperties::dimension == dimension, + "Dimension mismatch"); + static_assert(PointProperties::medium_tag == value_type, + "Medium tag mismatch"); + static_assert(PointProperties::property_tag == property_type, + "Property tag mismatch"); + + using simd = typename PointProperties::simd; + using mask_type = typename simd::mask_type; + using tag_type = typename simd::tag_type; + + const int ispec = index.ispec; + const int iz = index.iz; + const int ix = index.ix; + + mask_type mask([&](std::size_t lane) { return index.mask(lane); }); + + Kokkos::Experimental::where(mask, property.rho) + .copy_from(&rho(ispec, iz, ix), tag_type()); + Kokkos::Experimental::where(mask, property.c11) + .copy_from(&c11(ispec, iz, ix), tag_type()); + Kokkos::Experimental::where(mask, property.c12) + .copy_from(&c12(ispec, iz, ix), tag_type()); + Kokkos::Experimental::where(mask, property.c13) + .copy_from(&c13(ispec, iz, ix), tag_type()); + Kokkos::Experimental::where(mask, property.c15) + .copy_from(&c15(ispec, iz, ix), tag_type()); + Kokkos::Experimental::where(mask, property.c33) + .copy_from(&c33(ispec, iz, ix), tag_type()); + Kokkos::Experimental::where(mask, property.c35) + .copy_from(&c35(ispec, iz, ix), tag_type()); + Kokkos::Experimental::where(mask, property.c55) + .copy_from(&c55(ispec, iz, ix), tag_type()); + Kokkos::Experimental::where(mask, property.c23) + .copy_from(&c23(ispec, iz, ix), tag_type()); + Kokkos::Experimental::where(mask, property.c25) + .copy_from(&c25(ispec, iz, ix), tag_type()); + } + + template < + typename PointProperties, + typename std::enable_if_t = 0> + inline void + load_host_properties(const specfem::point::index &index, + PointProperties &property) const { + + static_assert(PointProperties::dimension == dimension, + "Dimension mismatch"); + static_assert(PointProperties::medium_tag == value_type, + "Medium tag mismatch"); + static_assert(PointProperties::property_tag == property_type, + "Property tag mismatch"); + + const int ispec = index.ispec; + const int iz = index.iz; + const int ix = index.ix; + + property.rho = h_rho(ispec, iz, ix); + property.c11 = h_c11(ispec, iz, ix); + property.c12 = h_c12(ispec, iz, ix); + property.c13 = h_c13(ispec, iz, ix); + property.c15 = h_c15(ispec, iz, ix); + property.c33 = h_c33(ispec, iz, ix); + property.c35 = h_c35(ispec, iz, ix); + property.c55 = h_c55(ispec, iz, ix); + property.c23 = h_c23(ispec, iz, ix); + property.c25 = h_c25(ispec, iz, ix); + } + + template < + typename PointProperties, + typename std::enable_if_t = 0> + inline void + load_host_properties(const specfem::point::simd_index &index, + PointProperties &property) const { + + static_assert(PointProperties::dimension == dimension, + "Dimension mismatch"); + static_assert(PointProperties::medium_tag == value_type, + "Medium tag mismatch"); + static_assert(PointProperties::property_tag == property_type, + "Property tag mismatch"); + + using simd = typename PointProperties::simd; + using mask_type = typename simd::mask_type; + using tag_type = typename simd::tag_type; + + const int ispec = index.ispec; + const int iz = index.iz; + const int ix = index.ix; + + mask_type mask([&](std::size_t lane) { return index.mask(lane); }); + + Kokkos::Experimental::where(mask, property.rho) + .copy_from(&h_rho(ispec, iz, ix), tag_type()); + Kokkos::Experimental::where(mask, property.c11) + .copy_from(&h_c11(ispec, iz, ix), tag_type()); + Kokkos::Experimental::where(mask, property.c13) + .copy_from(&h_c13(ispec, iz, ix), tag_type()); + Kokkos::Experimental::where(mask, property.c15) + .copy_from(&h_c15(ispec, iz, ix), tag_type()); + Kokkos::Experimental::where(mask, property.c33) + .copy_from(&h_c33(ispec, iz, ix), tag_type()); + Kokkos::Experimental::where(mask, property.c35) + .copy_from(&h_c35(ispec, iz, ix), tag_type()); + Kokkos::Experimental::where(mask, property.c55) + .copy_from(&h_c55(ispec, iz, ix), tag_type()); + Kokkos::Experimental::where(mask, property.c23) + .copy_from(&h_c23(ispec, iz, ix), tag_type()); + Kokkos::Experimental::where(mask, property.c25) + .copy_from(&h_c25(ispec, iz, ix), tag_type()); + } + + void copy_to_device() { + Kokkos::deep_copy(rho, h_rho); + Kokkos::deep_copy(c11, h_c11); + Kokkos::deep_copy(c13, h_c13); + Kokkos::deep_copy(c15, h_c15); + Kokkos::deep_copy(c33, h_c33); + Kokkos::deep_copy(c35, h_c35); + Kokkos::deep_copy(c55, h_c55); + Kokkos::deep_copy(c23, h_c23); + Kokkos::deep_copy(c25, h_c25); + } + + void copy_to_host() { + Kokkos::deep_copy(h_rho, rho); + Kokkos::deep_copy(h_c11, c11); + Kokkos::deep_copy(h_c13, c13); + Kokkos::deep_copy(h_c15, c15); + Kokkos::deep_copy(h_c33, c33); + Kokkos::deep_copy(h_c35, c35); + Kokkos::deep_copy(h_c55, c55); + Kokkos::deep_copy(h_c23, c23); + Kokkos::deep_copy(h_c25, c25); + } + + template < + typename PointProperties, + typename std::enable_if_t = 0> + inline void assign(const specfem::point::index &index, + const PointProperties &property) const { + + static_assert(PointProperties::dimension == dimension, + "Dimension mismatch"); + static_assert(PointProperties::medium_tag == value_type, + "Medium tag mismatch"); + static_assert(PointProperties::property_tag == property_type, + "Property tag mismatch"); + + const int ispec = index.ispec; + const int iz = index.iz; + const int ix = index.ix; + + h_rho(ispec, iz, ix) = property.rho; + h_c11(ispec, iz, ix) = property.c11; + h_c13(ispec, iz, ix) = property.c13; + h_c15(ispec, iz, ix) = property.c15; + h_c33(ispec, iz, ix) = property.c33; + h_c35(ispec, iz, ix) = property.c35; + h_c55(ispec, iz, ix) = property.c55; + h_c23(ispec, iz, ix) = property.c23; + h_c25(ispec, iz, ix) = property.c25; + } + + template < + typename PointProperties, + typename std::enable_if_t = 0> + inline void assign(const specfem::point::simd_index &index, + const PointProperties &property) const { + + static_assert(PointProperties::dimension == dimension, + "Dimension mismatch"); + static_assert(PointProperties::medium_tag == value_type, + "Medium tag mismatch"); + static_assert(PointProperties::property_tag == property_type, + "Property tag mismatch"); + + using simd = typename PointProperties::simd; + using mask_type = typename simd::mask_type; + using tag_type = typename simd::tag_type; + + const int ispec = index.ispec; + const int iz = index.iz; + const int ix = index.ix; + + mask_type mask([&, this](std::size_t lane) { return index.mask(lane); }); + + Kokkos::Experimental::where(mask, property.rho) + .copy_to(&h_rho(ispec, iz, ix), tag_type()); + Kokkos::Experimental::where(mask, property.c11) + .copy_to(&h_c11(ispec, iz, ix), tag_type()); + Kokkos::Experimental::where(mask, property.c13) + .copy_to(&h_c13(ispec, iz, ix), tag_type()); + Kokkos::Experimental::where(mask, property.c15) + .copy_to(&h_c15(ispec, iz, ix), tag_type()); + Kokkos::Experimental::where(mask, property.c33) + .copy_to(&h_c33(ispec, iz, ix), tag_type()); + Kokkos::Experimental::where(mask, property.c35) + .copy_to(&h_c35(ispec, iz, ix), tag_type()); + Kokkos::Experimental::where(mask, property.c55) + .copy_to(&h_c55(ispec, iz, ix), tag_type()); + Kokkos::Experimental::where(mask, property.c23) + .copy_to(&h_c23(ispec, iz, ix), tag_type()); + Kokkos::Experimental::where(mask, property.c25) + .copy_to(&h_c25(ispec, iz, ix), tag_type()); + } +}; + template <> struct properties_container { diff --git a/include/compute/properties/properties.hpp b/include/compute/properties/properties.hpp index 102e723bd..590317483 100644 --- a/include/compute/properties/properties.hpp +++ b/include/compute/properties/properties.hpp @@ -52,6 +52,10 @@ struct properties { specfem::element::medium_tag::elastic, specfem::element::property_tag::isotropic> elastic_isotropic; ///< Elastic isotropic material properties + specfem::compute::impl::properties::material_property< + specfem::element::medium_tag::elastic, + specfem::element::property_tag::anisotropic> + elastic_anisotropic; ///< Elastic anisotropic material properties specfem::compute::impl::properties::material_property< specfem::element::medium_tag::acoustic, specfem::element::property_tag::isotropic> @@ -177,6 +181,11 @@ load_on_device(const IndexType &lcoord, (PropertyTag == specfem::element::property_tag::isotropic)) { properties.elastic_isotropic.load_device_properties(l_index, point_properties); + } else if constexpr ((MediumTag == specfem::element::medium_tag::elastic) && + (PropertyTag == + specfem::element::property_tag::anisotropic)) { + properties.elastic_anisotropic.load_device_properties(l_index, + point_properties); } else if constexpr ((MediumTag == specfem::element::medium_tag::acoustic) && (PropertyTag == specfem::element::property_tag::isotropic)) { @@ -227,6 +236,11 @@ void load_on_host(const IndexType &lcoord, (PropertyTag == specfem::element::property_tag::isotropic)) { properties.elastic_isotropic.load_host_properties(l_index, point_properties); + } else if constexpr ((MediumTag == specfem::element::medium_tag::elastic) && + (PropertyTag == + specfem::element::property_tag::anisotropic)) { + properties.elastic_anisotropic.load_host_properties(l_index, + point_properties); } else if constexpr ((MediumTag == specfem::element::medium_tag::acoustic) && (PropertyTag == specfem::element::property_tag::isotropic)) { @@ -275,6 +289,10 @@ void store_on_host(const IndexType &lcoord, if constexpr ((MediumTag == specfem::element::medium_tag::elastic) && (PropertyTag == specfem::element::property_tag::isotropic)) { properties.elastic_isotropic.assign(l_index, point_properties); + } else if constexpr ((MediumTag == specfem::element::medium_tag::elastic) && + (PropertyTag == + specfem::element::property_tag::anisotropic)) { + properties.elastic_anisotropic.assign(l_index, point_properties); } else if constexpr ((MediumTag == specfem::element::medium_tag::acoustic) && (PropertyTag == specfem::element::property_tag::isotropic)) { diff --git a/include/material/elastic_properties.hpp b/include/material/elastic_properties.hpp index f03642ea2..836f923e8 100644 --- a/include/material/elastic_properties.hpp +++ b/include/material/elastic_properties.hpp @@ -174,10 +174,10 @@ class properties get_properties() const { - // return { }; - // } + inline specfem::point::properties + get_properties() const { + return { c11, c13, c15, c33, c35, c55, c12, c23, c25, density }; + } inline std::string print() const { std::ostringstream message; diff --git a/include/point/properties.hpp b/include/point/properties.hpp index eee521753..b32c8804c 100644 --- a/include/point/properties.hpp +++ b/include/point/properties.hpp @@ -96,6 +96,77 @@ struct properties +struct properties { + + /** + * @name Typedefs + * + */ + ///@{ + constexpr static bool is_point_properties = true; + using simd = specfem::datatype::simd; ///< SIMD type + constexpr static auto dimension = specfem::dimension::type::dim2; + constexpr static auto medium_tag = specfem::element::medium_tag::elastic; + constexpr static auto property_tag = + specfem::element::property_tag::anisotropic; + using value_type = + typename simd::datatype; ///< Value type to store properties + ///@} + + /** + * @name Elastic constants + * + */ + ///@{ + value_type c11; ///< @f$ c_{11} @f$ + value_type c13; ///< @f$ c_{13} @f$ + value_type c15; ///< @f$ c_{15} @f$ + value_type c33; ///< @f$ c_{33} @f$ + value_type c35; ///< @f$ c_{35} @f$ + value_type c55; ///< @f$ c_{55} @f$ + value_type c12; ///< @f$ c_{12} @f$ + value_type c23; ///< @f$ c_{23} @f$ + value_type c25; ///< @f$ c_{25} @f$ + ///@} + + value_type rho; ///< Density @f$ \rho @f$ + +private: + KOKKOS_FUNCTION + properties(const value_type &c11, const value_type &c13, + const value_type &c15, const value_type &c33, + const value_type &c35, const value_type &c55, + const value_type &c12, const value_type &c23, + const value_type &c25, const value_type &rho, std::false_type) + : c11(c11), c13(c13), c15(c15), c33(c33), c35(c35), c55(c55), c12(c12), + c23(c23), c25(c25) {} + + KOKKOS_FUNCTION + properties(const value_type &c11, const value_type &c13, + const value_type &c15, const value_type &c33, + const value_type &c35, const value_type &c55, + const value_type &c12, const value_type &c23, + const value_type &c25, const value_type &rho, std::true_type) + : c11(c11), c13(c13), c15(c15), c33(c33), c35(c35), c55(c55), c12(c12), + c23(c23), c25(c25), rho(rho) {} + +public: + KOKKOS_FUNCTION + properties() = default; + + KOKKOS_FUNCTION + properties(const value_type &c11, const value_type &c13, + const value_type &c15, const value_type &c33, + const value_type &c35, const value_type &c55, + const value_type &c12, const value_type &c23, + const value_type &c25, const type_real &rho) + : properties(c11, c13, c15, c33, c35, c55, c12, c23, c25, rho, + std::integral_constant{}) {} +}; + /** * @brief Template specialization for 2D isotropic acoustic media * diff --git a/poetry.lock b/poetry.lock index 04c1bea4c..ed20bba14 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry 1.8.4 and should not be changed by hand. +# This file is automatically @generated by Poetry 1.8.5 and should not be changed by hand. [[package]] name = "alabaster" @@ -325,17 +325,13 @@ sphinx-basic-ng = ">=1.0.0.beta2" [[package]] name = "identify" -version = "2.6.2" -version = "2.6.2" +version = "2.6.3" description = "File identification library for Python" optional = false python-versions = ">=3.9" -python-versions = ">=3.9" files = [ - {file = "identify-2.6.2-py2.py3-none-any.whl", hash = "sha256:c097384259f49e372f4ea00a19719d95ae27dd5ff0fd77ad630aa891306b82f3"}, - {file = "identify-2.6.2.tar.gz", hash = "sha256:fab5c716c24d7a789775228823797296a2994b075fb6080ac83a102772a98cbd"}, - {file = "identify-2.6.2-py2.py3-none-any.whl", hash = "sha256:c097384259f49e372f4ea00a19719d95ae27dd5ff0fd77ad630aa891306b82f3"}, - {file = "identify-2.6.2.tar.gz", hash = "sha256:fab5c716c24d7a789775228823797296a2994b075fb6080ac83a102772a98cbd"}, + {file = "identify-2.6.3-py2.py3-none-any.whl", hash = "sha256:9edba65473324c2ea9684b1f944fe3191db3345e50b6d04571d10ed164f8d7bd"}, + {file = "identify-2.6.3.tar.gz", hash = "sha256:62f5dae9b5fef52c84cc188514e9ea4f3f636b1d8799ab5ebc475471f9e47a02"}, ] [package.extras] @@ -557,13 +553,13 @@ virtualenv = ">=20.10.0" [[package]] name = "pydantic" -version = "2.10.1" +version = "2.10.3" description = "Data validation using Python type hints" optional = false python-versions = ">=3.8" files = [ - {file = "pydantic-2.10.1-py3-none-any.whl", hash = "sha256:a8d20db84de64cf4a7d59e899c2caf0fe9d660c7cfc482528e7020d7dd189a7e"}, - {file = "pydantic-2.10.1.tar.gz", hash = "sha256:a4daca2dc0aa429555e0656d6bf94873a7dc5f54ee42b1f5873d666fb3f35560"}, + {file = "pydantic-2.10.3-py3-none-any.whl", hash = "sha256:be04d85bbc7b65651c5f8e6b9976ed9c6f41782a55524cef079a34a0bb82144d"}, + {file = "pydantic-2.10.3.tar.gz", hash = "sha256:cb5ac360ce894ceacd69c403187900a02c4b20b693a9dd1d643e1effab9eadf9"}, ] [package.dependencies] @@ -864,29 +860,29 @@ yaml = ["pyyaml (>=6.0.0)"] [[package]] name = "ruff" -version = "0.8.0" +version = "0.8.2" description = "An extremely fast Python linter and code formatter, written in Rust." optional = false python-versions = ">=3.7" files = [ - {file = "ruff-0.8.0-py3-none-linux_armv6l.whl", hash = "sha256:fcb1bf2cc6706adae9d79c8d86478677e3bbd4ced796ccad106fd4776d395fea"}, - {file = "ruff-0.8.0-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:295bb4c02d58ff2ef4378a1870c20af30723013f441c9d1637a008baaf928c8b"}, - {file = "ruff-0.8.0-py3-none-macosx_11_0_arm64.whl", hash = "sha256:7b1f1c76b47c18fa92ee78b60d2d20d7e866c55ee603e7d19c1e991fad933a9a"}, - {file = "ruff-0.8.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:eb0d4f250a7711b67ad513fde67e8870109e5ce590a801c3722580fe98c33a99"}, - {file = "ruff-0.8.0-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:0e55cce9aa93c5d0d4e3937e47b169035c7e91c8655b0974e61bb79cf398d49c"}, - {file = "ruff-0.8.0-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:3f4cd64916d8e732ce6b87f3f5296a8942d285bbbc161acee7fe561134af64f9"}, - {file = "ruff-0.8.0-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:c5c1466be2a2ebdf7c5450dd5d980cc87c8ba6976fb82582fea18823da6fa362"}, - {file = "ruff-0.8.0-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:2dabfd05b96b7b8f2da00d53c514eea842bff83e41e1cceb08ae1966254a51df"}, - {file = "ruff-0.8.0-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:facebdfe5a5af6b1588a1d26d170635ead6892d0e314477e80256ef4a8470cf3"}, - {file = "ruff-0.8.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:87a8e86bae0dbd749c815211ca11e3a7bd559b9710746c559ed63106d382bd9c"}, - {file = "ruff-0.8.0-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:85e654f0ded7befe2d61eeaf3d3b1e4ef3894469cd664ffa85006c7720f1e4a2"}, - {file = "ruff-0.8.0-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:83a55679c4cb449fa527b8497cadf54f076603cc36779b2170b24f704171ce70"}, - {file = "ruff-0.8.0-py3-none-musllinux_1_2_i686.whl", hash = "sha256:812e2052121634cf13cd6fddf0c1871d0ead1aad40a1a258753c04c18bb71bbd"}, - {file = "ruff-0.8.0-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:780d5d8523c04202184405e60c98d7595bdb498c3c6abba3b6d4cdf2ca2af426"}, - {file = "ruff-0.8.0-py3-none-win32.whl", hash = "sha256:5fdb6efecc3eb60bba5819679466471fd7d13c53487df7248d6e27146e985468"}, - {file = "ruff-0.8.0-py3-none-win_amd64.whl", hash = "sha256:582891c57b96228d146725975fbb942e1f30a0c4ba19722e692ca3eb25cc9b4f"}, - {file = "ruff-0.8.0-py3-none-win_arm64.whl", hash = "sha256:ba93e6294e9a737cd726b74b09a6972e36bb511f9a102f1d9a7e1ce94dd206a6"}, - {file = "ruff-0.8.0.tar.gz", hash = "sha256:a7ccfe6331bf8c8dad715753e157457faf7351c2b69f62f32c165c2dbcbacd44"}, + {file = "ruff-0.8.2-py3-none-linux_armv6l.whl", hash = "sha256:c49ab4da37e7c457105aadfd2725e24305ff9bc908487a9bf8d548c6dad8bb3d"}, + {file = "ruff-0.8.2-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:ec016beb69ac16be416c435828be702ee694c0d722505f9c1f35e1b9c0cc1bf5"}, + {file = "ruff-0.8.2-py3-none-macosx_11_0_arm64.whl", hash = "sha256:f05cdf8d050b30e2ba55c9b09330b51f9f97d36d4673213679b965d25a785f3c"}, + {file = "ruff-0.8.2-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:60f578c11feb1d3d257b2fb043ddb47501ab4816e7e221fbb0077f0d5d4e7b6f"}, + {file = "ruff-0.8.2-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:cbd5cf9b0ae8f30eebc7b360171bd50f59ab29d39f06a670b3e4501a36ba5897"}, + {file = "ruff-0.8.2-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:b402ddee3d777683de60ff76da801fa7e5e8a71038f57ee53e903afbcefdaa58"}, + {file = "ruff-0.8.2-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:705832cd7d85605cb7858d8a13d75993c8f3ef1397b0831289109e953d833d29"}, + {file = "ruff-0.8.2-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:32096b41aaf7a5cc095fa45b4167b890e4c8d3fd217603f3634c92a541de7248"}, + {file = "ruff-0.8.2-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:e769083da9439508833cfc7c23e351e1809e67f47c50248250ce1ac52c21fb93"}, + {file = "ruff-0.8.2-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:5fe716592ae8a376c2673fdfc1f5c0c193a6d0411f90a496863c99cd9e2ae25d"}, + {file = "ruff-0.8.2-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:81c148825277e737493242b44c5388a300584d73d5774defa9245aaef55448b0"}, + {file = "ruff-0.8.2-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:d261d7850c8367704874847d95febc698a950bf061c9475d4a8b7689adc4f7fa"}, + {file = "ruff-0.8.2-py3-none-musllinux_1_2_i686.whl", hash = "sha256:1ca4e3a87496dc07d2427b7dd7ffa88a1e597c28dad65ae6433ecb9f2e4f022f"}, + {file = "ruff-0.8.2-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:729850feed82ef2440aa27946ab39c18cb4a8889c1128a6d589ffa028ddcfc22"}, + {file = "ruff-0.8.2-py3-none-win32.whl", hash = "sha256:ac42caaa0411d6a7d9594363294416e0e48fc1279e1b0e948391695db2b3d5b1"}, + {file = "ruff-0.8.2-py3-none-win_amd64.whl", hash = "sha256:2aae99ec70abf43372612a838d97bfe77d45146254568d94926e8ed5bbb409ea"}, + {file = "ruff-0.8.2-py3-none-win_arm64.whl", hash = "sha256:fb88e2a506b70cfbc2de6fae6681c4f944f7dd5f2fe87233a7233d888bad73e8"}, + {file = "ruff-0.8.2.tar.gz", hash = "sha256:b84f4f414dda8ac7f75075c1fa0b905ac0ff25361f42e6d5da681a465e0f78e5"}, ] [[package]] @@ -1151,13 +1147,13 @@ pbr = ">=2.0.0" [[package]] name = "typer" -version = "0.13.1" +version = "0.15.1" description = "Typer, build great CLIs. Easy to code. Based on Python type hints." optional = false python-versions = ">=3.7" files = [ - {file = "typer-0.13.1-py3-none-any.whl", hash = "sha256:5b59580fd925e89463a29d363e0a43245ec02765bde9fb77d39e5d0f29dd7157"}, - {file = "typer-0.13.1.tar.gz", hash = "sha256:9d444cb96cc268ce6f8b94e13b4335084cef4c079998a9f4851a90229a3bd25c"}, + {file = "typer-0.15.1-py3-none-any.whl", hash = "sha256:7994fb7b8155b64d3402518560648446072864beefd44aa2dc36972a5972e847"}, + {file = "typer-0.15.1.tar.gz", hash = "sha256:a0588c0a7fa68a1978a069818657778f86abe6ff5ea6abf472f940a08bfe4f0a"}, ] [package.dependencies] @@ -1196,13 +1192,13 @@ zstd = ["zstandard (>=0.18.0)"] [[package]] name = "virtualenv" -version = "20.27.1" +version = "20.28.0" description = "Virtual Python Environment builder" optional = false python-versions = ">=3.8" files = [ - {file = "virtualenv-20.27.1-py3-none-any.whl", hash = "sha256:f11f1b8a29525562925f745563bfd48b189450f61fb34c4f9cc79dd5aa32a1f4"}, - {file = "virtualenv-20.27.1.tar.gz", hash = "sha256:142c6be10212543b32c6c45d3d3893dff89112cc588b7d0879ae5a1ec03a47ba"}, + {file = "virtualenv-20.28.0-py3-none-any.whl", hash = "sha256:23eae1b4516ecd610481eda647f3a7c09aea295055337331bb4e6892ecce47b0"}, + {file = "virtualenv-20.28.0.tar.gz", hash = "sha256:2c9c3262bb8e7b87ea801d715fae4495e6032450c71d2309be9550e7364049aa"}, ] [package.dependencies] diff --git a/src/compute/compute_properties.cpp b/src/compute/compute_properties.cpp index 1ea8b2936..d7a06eb9f 100644 --- a/src/compute/compute_properties.cpp +++ b/src/compute/compute_properties.cpp @@ -14,21 +14,27 @@ void compute_number_of_elements_per_medium( &h_element_types, const specfem::kokkos::HostView1d &h_element_property, - int &n_elastic, int &n_acoustic) { + int &n_elastic_isotropic, int &n_elastic_anisotropic, int &n_acoustic) { Kokkos::parallel_reduce( "specfem::compute::properties::compute_number_of_elements_per_medium", specfem::kokkos::HostRange(0, nspec), - [=](const int ispec, int &n_elastic, int &n_acoustic) { + [=](const int ispec, int &n_elastic_isotropic, int &n_elastic_anisotropic, + int &n_acoustic) { const int ispec_mesh = mapping.compute_to_mesh(ispec); if (tags.tags_container(ispec_mesh).medium_tag == specfem::element::medium_tag::elastic) { - n_elastic++; h_element_types(ispec) = specfem::element::medium_tag::elastic; if (tags.tags_container(ispec_mesh).property_tag == specfem::element::property_tag::isotropic) { + n_elastic_isotropic++; h_element_property(ispec) = specfem::element::property_tag::isotropic; + } else if (tags.tags_container(ispec_mesh).property_tag == + specfem::element::property_tag::anisotropic) { + n_elastic_anisotropic++; + h_element_property(ispec) = + specfem::element::property_tag::anisotropic; } else { throw std::runtime_error("Unknown property tag"); } @@ -45,9 +51,9 @@ void compute_number_of_elements_per_medium( } } }, - n_elastic, n_acoustic); + n_elastic_isotropic, n_elastic_anisotropic, n_acoustic); - if (n_elastic + n_acoustic != nspec) + if (n_elastic_isotropic + n_elastic_anisotropic + n_acoustic != nspec) throw std::runtime_error("Number of elements per medium does not match " "total number of elements"); @@ -71,12 +77,13 @@ specfem::compute::properties::properties( Kokkos::create_mirror_view(property_index_mapping)) { // compute total number of elastic and acoustic spectral elements - int n_elastic; + int n_elastic_isotropic; + int n_elastic_anisotropic; int n_acoustic; compute_number_of_elements_per_medium(nspec, mapping, tags, h_element_types, - h_element_property, n_elastic, - n_acoustic); + h_element_property, n_elastic_isotropic, + n_elastic_anisotropic, n_acoustic); acoustic_isotropic = specfem::compute::impl::properties::material_property< specfem::element::medium_tag::acoustic, @@ -86,9 +93,15 @@ specfem::compute::properties::properties( elastic_isotropic = specfem::compute::impl::properties::material_property< specfem::element::medium_tag::elastic, - specfem::element::property_tag::isotropic>(nspec, n_elastic, ngllz, ngllx, - mapping, tags, materials, - h_property_index_mapping); + specfem::element::property_tag::isotropic>( + nspec, n_elastic_isotropic, ngllz, ngllx, mapping, tags, materials, + h_property_index_mapping); + + elastic_anisotropic = specfem::compute::impl::properties::material_property< + specfem::element::medium_tag::elastic, + specfem::element::property_tag::anisotropic>( + nspec, n_elastic_anisotropic, ngllz, ngllx, mapping, tags, materials, + h_property_index_mapping); Kokkos::deep_copy(property_index_mapping, h_property_index_mapping); Kokkos::deep_copy(element_types, h_element_types);