diff --git a/src/serac/infrastructure/CMakeLists.txt b/src/serac/infrastructure/CMakeLists.txt index dc88eed57..53e2fa324 100644 --- a/src/serac/infrastructure/CMakeLists.txt +++ b/src/serac/infrastructure/CMakeLists.txt @@ -41,7 +41,7 @@ set(infrastructure_sources terminator.cpp ) -set(infrastructure_depends axom::inlet axom::fmt axom::cli11 mfem ${serac_device_depends}) +set(infrastructure_depends axom::inlet axom::fmt axom::cli11 camp mfem ${serac_device_depends}) blt_list_append(TO infrastructure_depends ELEMENTS tribol IF TRIBOL_FOUND) blt_list_append(TO infrastructure_depends ELEMENTS caliper adiak::adiak IF SERAC_ENABLE_PROFILING) list(APPEND infrastructure_depends blt::mpi) diff --git a/src/serac/infrastructure/debug_print.hpp b/src/serac/infrastructure/debug_print.hpp index 485f058af..5dcc79b4c 100644 --- a/src/serac/infrastructure/debug_print.hpp +++ b/src/serac/infrastructure/debug_print.hpp @@ -68,53 +68,48 @@ std::ostream& operator<<(std::ostream& out, serac::SignedIndex i) } /** - * @brief write a 2D array of values out to file, in a space-separated format + * @brief write an array of values out to file, in a space-separated format * @tparam T the type of each value in the array * @param v the values to write to file * @param filename the name of the output file */ -template -void write_to_file(axom::Array arr, std::string filename) +template +void write_to_file(const ArrayT& arr_orig, std::string filename) { std::ofstream outfile(filename); - for (axom::IndexType i = 0; i < arr.shape()[0]; i++) { - outfile << "{"; - for (axom::IndexType j = 0; j < arr.shape()[1]; j++) { - outfile << arr(i, j); - if (j < arr.shape()[1] - 1) outfile << ", "; +#ifdef SERAC_USE_UMPIRE + axom::Array arr(arr_orig); +#else + const auto& arr = arr_orig; +#endif + + if constexpr (ArrayT::Dims == 2) { + for (axom::IndexType i = 0; i < arr.shape()[0]; i++) { + outfile << "{"; + for (axom::IndexType j = 0; j < arr.shape()[1]; j++) { + outfile << arr(i, j); + if (j < arr.shape()[1] - 1) outfile << ", "; + } + outfile << "}\n"; } - outfile << "}\n"; } + if constexpr (ArrayT::Dims == 3) { + outfile << std::setprecision(16); - outfile.close(); -} - -/** - * @brief write a 3D array of values out to file, in a mathematica-compatible format - * @tparam T the type of each value in the array - * @param v the values to write to file - * @param filename the name of the output file - */ -template -void write_to_file(axom::Array arr, std::string filename) -{ - std::ofstream outfile(filename); - - outfile << std::setprecision(16); - - for (axom::IndexType i = 0; i < arr.shape()[0]; i++) { - outfile << "{"; - for (axom::IndexType j = 0; j < arr.shape()[1]; j++) { + for (axom::IndexType i = 0; i < arr.shape()[0]; i++) { outfile << "{"; - for (axom::IndexType k = 0; k < arr.shape()[2]; k++) { - outfile << arr(i, j, k); - if (k < arr.shape()[2] - 1) outfile << ", "; + for (axom::IndexType j = 0; j < arr.shape()[1]; j++) { + outfile << "{"; + for (axom::IndexType k = 0; k < arr.shape()[2]; k++) { + outfile << arr(i, j, k); + if (k < arr.shape()[2] - 1) outfile << ", "; + } + outfile << "}"; + if (j < arr.shape()[1] - 1) outfile << ", "; } - outfile << "}"; - if (j < arr.shape()[1] - 1) outfile << ", "; + outfile << "}\n"; } - outfile << "}\n"; } outfile.close(); diff --git a/src/serac/numerics/functional/domain_integral_kernels.hpp b/src/serac/numerics/functional/domain_integral_kernels.hpp index c218025fb..b6043464c 100644 --- a/src/serac/numerics/functional/domain_integral_kernels.hpp +++ b/src/serac/numerics/functional/domain_integral_kernels.hpp @@ -10,7 +10,9 @@ #include "serac/numerics/functional/quadrature_data.hpp" #include "serac/numerics/functional/function_signature.hpp" #include "serac/numerics/functional/differentiate_wrt.hpp" +#ifdef SERAC_USE_RAJA #include "RAJA/RAJA.hpp" +#endif #include #include diff --git a/src/serac/numerics/functional/element_restriction.cpp b/src/serac/numerics/functional/element_restriction.cpp index 9068da405..58f776bb2 100644 --- a/src/serac/numerics/functional/element_restriction.cpp +++ b/src/serac/numerics/functional/element_restriction.cpp @@ -213,8 +213,7 @@ std::vector > geom_local_face_dofs(int p) return output; } -axom::Array GetElementRestriction(const mfem::FiniteElementSpace* fes, - mfem::Geometry::Type geom) +axom::Array GetElementRestriction(const mfem::FiniteElementSpace* fes, mfem::Geometry::Type geom) { std::vector elem_dofs{}; mfem::Mesh* mesh = fes->GetMesh(); @@ -267,17 +266,16 @@ axom::Array GetElementRestriction(const mfem::F } if (n == 0) { - return axom::Array{}; + return axom::Array{}; } else { - uint64_t dofs_per_elem = elem_dofs.size() / n; - axom::Array output(n, dofs_per_elem); + uint64_t dofs_per_elem = elem_dofs.size() / n; + axom::Array output(n, dofs_per_elem); std::memcpy(output.data(), elem_dofs.data(), sizeof(DoF) * n * dofs_per_elem); return output; } } -axom::Array GetFaceDofs(const mfem::FiniteElementSpace* fes, - mfem::Geometry::Type face_geom, FaceType type) +axom::Array GetFaceDofs(const mfem::FiniteElementSpace* fes, mfem::Geometry::Type face_geom, FaceType type) { std::vector face_dofs; mfem::Mesh* mesh = fes->GetMesh(); @@ -378,10 +376,10 @@ axom::Array GetFaceDofs(const mfem::FiniteEleme delete face_to_elem; if (n == 0) { - return axom::Array{}; + return axom::Array{}; } else { - uint64_t dofs_per_face = face_dofs.size() / n; - axom::Array output(n, dofs_per_face); + uint64_t dofs_per_face = face_dofs.size() / n; + axom::Array output(n, dofs_per_face); std::memcpy(output.data(), face_dofs.data(), sizeof(DoF) * n * dofs_per_face); return output; } diff --git a/src/serac/numerics/functional/element_restriction.hpp b/src/serac/numerics/functional/element_restriction.hpp index 7f12dca59..3dc1e6a3a 100644 --- a/src/serac/numerics/functional/element_restriction.hpp +++ b/src/serac/numerics/functional/element_restriction.hpp @@ -195,7 +195,7 @@ struct ElementRestriction { uint64_t nodes_per_elem; /// a 2D array (num_elements-by-nodes_per_elem) holding the dof info extracted from the finite element space - axom::Array dof_info; + axom::Array dof_info; /// whether the underlying dofs are arranged "byNodes" or "byVDim" mfem::Ordering::Type ordering;