66
77#include < Kokkos_Core.hpp>
88#include < MeshField.hpp>
9+ #include < MeshField_Config.hpp>
910#include < memory>
1011
1112#include " pcms/field/layout/mesh_fields.h"
@@ -53,7 +54,7 @@ class MeshFieldBackendImpl : public MeshFieldBackend<T>
5354 {
5455 auto self = const_cast <MeshFieldBackendImpl<T, Dim, Order>*>(this );
5556 return self->mesh_field_ .triangleLocalPointEval (localCoords, offsets,
56- shape_field_);
57+ shape_field_. field );
5758 }
5859
5960 void SetData (Rank1View<const T, DeviceMemorySpace> data, size_t num_nodes,
@@ -65,7 +66,7 @@ class MeshFieldBackendImpl : public MeshFieldBackend<T>
6566 mesh_.nents (dim), KOKKOS_CLASS_LAMBDA (size_t ent) {
6667 for (size_t n = 0 ; n < num_nodes; ++n) {
6768 for (size_t c = 0 ; c < num_components; ++c) {
68- shape_field_ (ent, n, c, topo) =
69+ shape_field_. field (ent, n, c, topo) =
6970 data[ent * stride + n * num_components + c];
7071 }
7172 }
@@ -82,7 +83,7 @@ class MeshFieldBackendImpl : public MeshFieldBackend<T>
8283 for (size_t n = 0 ; n < num_nodes; ++n) {
8384 for (size_t c = 0 ; c < num_components; ++c) {
8485 data[ent * stride + n * num_components + c] =
85- shape_field_ (ent, n, c, topo);
86+ shape_field_. field (ent, n, c, topo);
8687 }
8788 }
8889 });
@@ -91,9 +92,8 @@ class MeshFieldBackendImpl : public MeshFieldBackend<T>
9192private:
9293 Omega_h::Mesh& mesh_;
9394 MeshField::OmegahMeshField<DefaultExecutionSpace, Dim> mesh_field_;
94- using ShapeField =
95- decltype (mesh_field_.template CreateLagrangeField<T, Order, 1 >());
96- ShapeField shape_field_;
95+ using FWC = decltype (mesh_field_.template CreateLagrangeField<T, Order, 1 >());
96+ FWC shape_field_; // FWC = FieldWithController; keeps ctrlr alive
9797};
9898
9999// ---------------------------------------------------------------------------
@@ -240,7 +240,7 @@ struct FillCoordinatesAndIndicesFunctor
240240 const auto owner_idx = owning_elem_ids_ (i);
241241 LO count = Kokkos::atomic_sub_fetch (&elem_counts_ (owner_idx), 1 );
242242 LO index = offsets_ (owner_idx) + count - 1 ;
243- for (int j = 0 ; j < ( dim_ + 1 ) ; ++j) {
243+ for (int j = 0 ; j < dim_; ++j) {
244244 coordinates_ (index, j) = coord[j];
245245 }
246246 indices_ (index) = i;
@@ -404,8 +404,9 @@ struct FillCoordinatesDeviceFunctor
404404 global_coords_ (orig_idx, 1 )};
405405 const auto local =
406406 Omega_h::barycentric_from_global<2 , 2 >(point, vertex_coords);
407- for (int j = 0 ; j < ( dim_ + 1 ) ; ++j)
407+ for (int j = 0 ; j < dim_; ++j) {
408408 coordinates_ (index, j) = local[j];
409+ }
409410 indices_ (index) = orig_idx;
410411 }
411412};
@@ -495,7 +496,7 @@ struct MeshFieldsAdapter2LocalizationHint
495496
496497 offsets_ = Kokkos::View<LO *, HostMemorySpace>(" offsets" , mesh.nelems () + 1 );
497498 coordinates_ = Kokkos::View<Real**, HostMemorySpace>(
498- " coordinates" , num_valid_, mesh.dim () + 1 );
499+ " coordinates" , num_valid_, mesh.dim ());
499500 indices_ = Kokkos::View<LO *, HostMemorySpace>(" indices" , num_valid_);
500501
501502 if (num_missing_ > 0 ) {
@@ -537,8 +538,9 @@ struct MeshFieldsAdapter2LocalizationHint
537538 global_coords (orig_idx, 1 )};
538539 const auto local =
539540 Omega_h::barycentric_from_global<2 , 2 >(point, vertex_coords);
540- for (int j = 0 ; j < ( mesh.dim () + 1 ) ; ++j)
541+ for (int j = 0 ; j < mesh.dim (); ++j) {
541542 coordinates_ (index, j) = local[j];
543+ }
542544 indices_ (index) = static_cast <LO >(orig_idx);
543545 }
544546
@@ -632,7 +634,7 @@ struct MeshFieldsAdapter2LocalizationHint
632634
633635 // Step 6: Fill coordinates and indices on device
634636 coordinates_d_ =
635- Kokkos::View<Real**>(" coordinates_d" , num_valid_, mesh.dim () + 1 );
637+ Kokkos::View<Real**>(" coordinates_d" , num_valid_, mesh.dim ());
636638 indices_d_ = Kokkos::View<LO *>(" indices_d" , num_valid_);
637639 const auto tris2verts = mesh.ask_elem_verts ();
638640 const auto mesh_coords = mesh.coords ();
@@ -654,7 +656,7 @@ struct MeshFieldsAdapter2LocalizationHint
654656 // Create host mirrors for compatibility (lazy copy - only if needed)
655657 offsets_ = Kokkos::create_mirror_view (offsets_d_);
656658 coordinates_ = Kokkos::View<Real**, HostMemorySpace>(
657- " coordinates_" , num_valid_, mesh.dim () + 1 );
659+ " coordinates_" , num_valid_, mesh.dim ());
658660 DeepCopyMismatchLayouts (coordinates_, coordinates_d_);
659661 indices_ = Kokkos::create_mirror_view (indices_d_);
660662 if (num_missing_ > 0 ) {
@@ -681,4 +683,4 @@ struct MeshFieldsAdapter2LocalizationHint
681683
682684} // namespace pcms
683685
684- #endif // PCMS_ADAPTER_MESHFIELDS_MESH_FIELDS_BACKEND_H
686+ #endif // PCMS_ADAPTER_MESHFIELDS_MESH_FIELDS_BACKEND_H
0 commit comments