diff --git a/.github/workflows/clang-tidy.yml b/.github/workflows/clang-tidy.yml index 784e8f71..26c7b639 100644 --- a/.github/workflows/clang-tidy.yml +++ b/.github/workflows/clang-tidy.yml @@ -105,7 +105,7 @@ jobs: with: repo-name: 'meshFields-openmpi' repo-path: 'SCOREC/meshFields' - repo-ref: 'b1482bbba288df210784b2345eae08e34faabdc4' + repo-ref: 'b9984520c20f73955a3b4e25e4907780b91d430f' cache: true options: '-DCMAKE_CXX_COMPILER=`which mpicxx` -DCMAKE_C_COMPILER=`which mpicc` diff --git a/.github/workflows/cmake-test.yml b/.github/workflows/cmake-test.yml index d736a952..6f2e4f2d 100644 --- a/.github/workflows/cmake-test.yml +++ b/.github/workflows/cmake-test.yml @@ -132,7 +132,7 @@ jobs: with: repo-name: 'meshFields' repo-path: 'SCOREC/meshFields' - repo-ref: 'b1482bbba288df210784b2345eae08e34faabdc4' + repo-ref: 'b9984520c20f73955a3b4e25e4907780b91d430f' cache: true cache-suffix: ${{ matrix.python_api == 'ON' && '-shared' || '' }} options: '-DCMAKE_CXX_COMPILER=`which mpicxx` diff --git a/src/pcms/field/evaluator/mesh_fields_backend.h b/src/pcms/field/evaluator/mesh_fields_backend.h index 84eb206d..04f81c2a 100644 --- a/src/pcms/field/evaluator/mesh_fields_backend.h +++ b/src/pcms/field/evaluator/mesh_fields_backend.h @@ -6,6 +6,7 @@ #include #include +#include #include #include "pcms/field/layout/mesh_fields.h" @@ -53,7 +54,7 @@ class MeshFieldBackendImpl : public MeshFieldBackend { auto self = const_cast*>(this); return self->mesh_field_.triangleLocalPointEval(localCoords, offsets, - shape_field_); + shape_field_.field); } void SetData(Rank1View data, size_t num_nodes, @@ -65,7 +66,7 @@ class MeshFieldBackendImpl : public MeshFieldBackend mesh_.nents(dim), KOKKOS_CLASS_LAMBDA(size_t ent) { for (size_t n = 0; n < num_nodes; ++n) { for (size_t c = 0; c < num_components; ++c) { - shape_field_(ent, n, c, topo) = + shape_field_.field(ent, n, c, topo) = data[ent * stride + n * num_components + c]; } } @@ -82,7 +83,7 @@ class MeshFieldBackendImpl : public MeshFieldBackend for (size_t n = 0; n < num_nodes; ++n) { for (size_t c = 0; c < num_components; ++c) { data[ent * stride + n * num_components + c] = - shape_field_(ent, n, c, topo); + shape_field_.field(ent, n, c, topo); } } }); @@ -91,9 +92,8 @@ class MeshFieldBackendImpl : public MeshFieldBackend private: Omega_h::Mesh& mesh_; MeshField::OmegahMeshField mesh_field_; - using ShapeField = - decltype(mesh_field_.template CreateLagrangeField()); - ShapeField shape_field_; + using FWC = decltype(mesh_field_.template CreateLagrangeField()); + FWC shape_field_; // FWC = FieldWithController; keeps ctrlr alive }; // --------------------------------------------------------------------------- @@ -240,7 +240,7 @@ struct FillCoordinatesAndIndicesFunctor const auto owner_idx = owning_elem_ids_(i); LO count = Kokkos::atomic_sub_fetch(&elem_counts_(owner_idx), 1); LO index = offsets_(owner_idx) + count - 1; - for (int j = 0; j < (dim_ + 1); ++j) { + for (int j = 0; j < dim_; ++j) { coordinates_(index, j) = coord[j]; } indices_(index) = i; @@ -404,8 +404,9 @@ struct FillCoordinatesDeviceFunctor global_coords_(orig_idx, 1)}; const auto local = Omega_h::barycentric_from_global<2, 2>(point, vertex_coords); - for (int j = 0; j < (dim_ + 1); ++j) + for (int j = 0; j < dim_; ++j) { coordinates_(index, j) = local[j]; + } indices_(index) = orig_idx; } }; @@ -495,7 +496,7 @@ struct MeshFieldsAdapter2LocalizationHint offsets_ = Kokkos::View("offsets", mesh.nelems() + 1); coordinates_ = Kokkos::View( - "coordinates", num_valid_, mesh.dim() + 1); + "coordinates", num_valid_, mesh.dim()); indices_ = Kokkos::View("indices", num_valid_); if (num_missing_ > 0) { @@ -537,8 +538,9 @@ struct MeshFieldsAdapter2LocalizationHint global_coords(orig_idx, 1)}; const auto local = Omega_h::barycentric_from_global<2, 2>(point, vertex_coords); - for (int j = 0; j < (mesh.dim() + 1); ++j) + for (int j = 0; j < mesh.dim(); ++j) { coordinates_(index, j) = local[j]; + } indices_(index) = static_cast(orig_idx); } @@ -632,7 +634,7 @@ struct MeshFieldsAdapter2LocalizationHint // Step 6: Fill coordinates and indices on device coordinates_d_ = - Kokkos::View("coordinates_d", num_valid_, mesh.dim() + 1); + Kokkos::View("coordinates_d", num_valid_, mesh.dim()); indices_d_ = Kokkos::View("indices_d", num_valid_); const auto tris2verts = mesh.ask_elem_verts(); const auto mesh_coords = mesh.coords(); @@ -654,7 +656,7 @@ struct MeshFieldsAdapter2LocalizationHint // Create host mirrors for compatibility (lazy copy - only if needed) offsets_ = Kokkos::create_mirror_view(offsets_d_); coordinates_ = Kokkos::View( - "coordinates_", num_valid_, mesh.dim() + 1); + "coordinates_", num_valid_, mesh.dim()); DeepCopyMismatchLayouts(coordinates_, coordinates_d_); indices_ = Kokkos::create_mirror_view(indices_d_); if (num_missing_ > 0) { @@ -681,4 +683,4 @@ struct MeshFieldsAdapter2LocalizationHint } // namespace pcms -#endif // PCMS_ADAPTER_MESHFIELDS_MESH_FIELDS_BACKEND_H +#endif // PCMS_ADAPTER_MESHFIELDS_MESH_FIELDS_BACKEND_H \ No newline at end of file diff --git a/src/pcms/transfer/mass_matrix_integrator.hpp b/src/pcms/transfer/mass_matrix_integrator.hpp index 7d36c975..b3031ff0 100644 --- a/src/pcms/transfer/mass_matrix_integrator.hpp +++ b/src/pcms/transfer/mass_matrix_integrator.hpp @@ -3,6 +3,7 @@ #include #include +#include #include #include #include @@ -38,7 +39,7 @@ class MassMatrixIntegrator : public MeshField::Integrator // std::cerr << " Number points per Elem : " << numPtsPerElem << "\n"; assert(numPtsPerElem >= 1); const size_t ptDim = p.extent(1); - assert(ptDim == fe.MeshEntDim + 1); + assert(ptDim == fe.MeshEntDim); // Copy values needed in the kernel to avoid capturing host references // (mesh and fe are host objects and cannot be dereferenced on the device) const auto numElems = mesh.nelems(); @@ -51,8 +52,7 @@ class MassMatrixIntegrator : public MeshField::Integrator const auto last = first + numPtsPerElem; for (auto pt = first; pt < last; pt++) { // FIXME better way to fill? pass kokkos::subview to getValues? - Kokkos::Array - localCoord; + Kokkos::Array localCoord; for (auto i = 0; i < localCoord.size(); i++) { localCoord[i] = p(pt, i); } diff --git a/src/pcms/transfer/omega_h_form_integrator_utils.hpp b/src/pcms/transfer/omega_h_form_integrator_utils.hpp index 23f5e35d..e40768f5 100644 --- a/src/pcms/transfer/omega_h_form_integrator_utils.hpp +++ b/src/pcms/transfer/omega_h_form_integrator_utils.hpp @@ -7,6 +7,7 @@ #include "pcms/utility/assert.h" #include #include +#include #include #include @@ -72,13 +73,15 @@ inline void CheckOmegaHScalarLagrangeLayout( } [[nodiscard]] OMEGA_H_INLINE Omega_h::Vector<2> GlobalFromBarycentric( - const MeshField::Vector3& barycentric_coord, + const MeshField::Vector2& barycentric_coord, const Omega_h::Few, 3>& verts_coord) { Omega_h::Vector<2> real_coords = {0.0, 0.0}; + const Omega_h::Real xi3 = 1.0 - barycentric_coord[0] - barycentric_coord[1]; + const Omega_h::Real xi[3] = {barycentric_coord[0], barycentric_coord[1], xi3}; for (int i = 0; i < 3; ++i) { - real_coords[0] += barycentric_coord[i] * verts_coord[i][0]; - real_coords[1] += barycentric_coord[i] * verts_coord[i][1]; + real_coords[0] += xi[i] * verts_coord[i][0]; + real_coords[1] += xi[i] * verts_coord[i][1]; } return real_coords; } @@ -250,7 +253,7 @@ OMEGA_H_INLINE void ForEachIntersectionSubtriangle( // source_order + target_order), which are only known at construction. struct IntegrationData { - Kokkos::View bary_coords; // barycentric coordinates + Kokkos::View bary_coords; // barycentric coordinates Kokkos::View weights; // quadrature weights explicit IntegrationData(int order) @@ -258,7 +261,7 @@ struct IntegrationData auto ip_vec = MeshField::getIntegrationPoints(order); const std::size_t num_ip = ip_vec.size(); - bary_coords = Kokkos::View("bary_coords", num_ip); + bary_coords = Kokkos::View("bary_coords", num_ip); weights = Kokkos::View("weights", num_ip); auto bary_coords_host = Kokkos::create_mirror_view(bary_coords); diff --git a/src/pcms/transfer/omega_h_mass_integrator.cpp b/src/pcms/transfer/omega_h_mass_integrator.cpp index 29cd90e2..7666a55c 100644 --- a/src/pcms/transfer/omega_h_mass_integrator.cpp +++ b/src/pcms/transfer/omega_h_mass_integrator.cpp @@ -123,7 +123,7 @@ OmegaHMassIntegrator::OmegaHMassIntegrator( omf(mesh); auto coordField = omf.getCoordField(); const auto [shp, map] = MeshField::Omegah::getTriangleElement<1>(mesh); - MeshField::FieldElement coordFe(mesh.nelems(), coordField, shp, map); + MeshField::FieldElement coordFe(mesh.nelems(), coordField.field, shp, map); auto elm_mass_dev = buildElementMassMatrix(mesh, coordFe); // Build COO sparsity pattern on device: each element contributes a 3x3 block. diff --git a/test/test_omega_h_mass_integrator.cpp b/test/test_omega_h_mass_integrator.cpp index 939283d1..a1de7e76 100644 --- a/test/test_omega_h_mass_integrator.cpp +++ b/test/test_omega_h_mass_integrator.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -60,7 +61,11 @@ std::map, pcms::Real> BuildReferenceMassMap( omf(mesh); auto coordField = omf.getCoordField(); const auto [shp, map] = MeshField::Omegah::getTriangleElement<1>(mesh); +#if MeshFields_VERSION < 10000 MeshField::FieldElement coordFe(mesh.nelems(), coordField, shp, map); +#else + MeshField::FieldElement coordFe(mesh.nelems(), coordField.field, shp, map); +#endif auto elm_mass_dev = buildElementMassMatrix(mesh, coordFe); auto elm_mass_host = Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace{}, elm_mass_dev);