Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes for builds with no raja or umpire #1270

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/serac/infrastructure/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
63 changes: 29 additions & 34 deletions src/serac/infrastructure/debug_print.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <typename T>
void write_to_file(axom::Array<T, 2, axom::MemorySpace::Host> arr, std::string filename)
template <typename ArrayT>
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<ArrayT::value_type, ArrayT::Dims, axom::MemorySpace::Host> 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 <typename T>
void write_to_file(axom::Array<T, 3, axom::MemorySpace::Host> 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();
Expand Down
2 changes: 2 additions & 0 deletions src/serac/numerics/functional/domain_integral_kernels.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <array>
#include <cstdint>
Expand Down
18 changes: 8 additions & 10 deletions src/serac/numerics/functional/element_restriction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,7 @@ std::vector<Array2D<int> > geom_local_face_dofs(int p)
return output;
}

axom::Array<DoF, 2, axom::MemorySpace::Host> GetElementRestriction(const mfem::FiniteElementSpace* fes,
mfem::Geometry::Type geom)
axom::Array<DoF, 2> GetElementRestriction(const mfem::FiniteElementSpace* fes, mfem::Geometry::Type geom)
{
std::vector<DoF> elem_dofs{};
mfem::Mesh* mesh = fes->GetMesh();
Expand Down Expand Up @@ -267,17 +266,16 @@ axom::Array<DoF, 2, axom::MemorySpace::Host> GetElementRestriction(const mfem::F
}

if (n == 0) {
return axom::Array<DoF, 2, axom::MemorySpace::Host>{};
return axom::Array<DoF, 2>{};
} else {
uint64_t dofs_per_elem = elem_dofs.size() / n;
axom::Array<DoF, 2, axom::MemorySpace::Host> output(n, dofs_per_elem);
uint64_t dofs_per_elem = elem_dofs.size() / n;
axom::Array<DoF, 2> output(n, dofs_per_elem);
std::memcpy(output.data(), elem_dofs.data(), sizeof(DoF) * n * dofs_per_elem);
return output;
}
}

axom::Array<DoF, 2, axom::MemorySpace::Host> GetFaceDofs(const mfem::FiniteElementSpace* fes,
mfem::Geometry::Type face_geom, FaceType type)
axom::Array<DoF, 2> GetFaceDofs(const mfem::FiniteElementSpace* fes, mfem::Geometry::Type face_geom, FaceType type)
{
std::vector<DoF> face_dofs;
mfem::Mesh* mesh = fes->GetMesh();
Expand Down Expand Up @@ -378,10 +376,10 @@ axom::Array<DoF, 2, axom::MemorySpace::Host> GetFaceDofs(const mfem::FiniteEleme
delete face_to_elem;

if (n == 0) {
return axom::Array<DoF, 2, axom::MemorySpace::Host>{};
return axom::Array<DoF, 2>{};
} else {
uint64_t dofs_per_face = face_dofs.size() / n;
axom::Array<DoF, 2, axom::MemorySpace::Host> output(n, dofs_per_face);
uint64_t dofs_per_face = face_dofs.size() / n;
axom::Array<DoF, 2> output(n, dofs_per_face);
std::memcpy(output.data(), face_dofs.data(), sizeof(DoF) * n * dofs_per_face);
return output;
}
Expand Down
2 changes: 1 addition & 1 deletion src/serac/numerics/functional/element_restriction.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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, 2, axom::MemorySpace::Host> dof_info;
axom::Array<DoF, 2> dof_info;

/// whether the underlying dofs are arranged "byNodes" or "byVDim"
mfem::Ordering::Type ordering;
Expand Down