Skip to content
Merged
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
44 changes: 20 additions & 24 deletions tests/test_no_geom.cpp
Original file line number Diff line number Diff line change
@@ -1,39 +1,35 @@
// testing includes
#include <catch2/catch_test_macros.hpp>
#include <catch2/matchers/catch_matchers_floating_point.hpp>
#include <catch2/generators/catch_generators.hpp>

// xdg includes
#include "xdg/moab/mesh_manager.h"
#include "xdg/libmesh/mesh_manager.h"
#include "util.h"

using namespace xdg;

TEST_CASE("Test MOAB Mesh Without Geometry")
{
std::unique_ptr<MeshManager> mesh_manager = std::make_unique<MOABMeshManager>();

mesh_manager->load_file("cube-mesh-no-geom.h5m");
mesh_manager->init();

// there will be two volumes: one for the cube and one for the implicit complement
REQUIRE(mesh_manager->num_volumes() == 2);
// one surface (the boundary of the mesh) separates the two volumes
REQUIRE(mesh_manager->num_surfaces() == 1);
TEST_CASE("Test Mesh Without Geometry")
{
auto mesh_backend = GENERATE(MeshLibrary::MOAB, MeshLibrary::LIBMESH);

REQUIRE(mesh_manager->num_volume_elements() == 8814);
}
DYNAMIC_SECTION(fmt::format("Backend = {}", mesh_backend))
{
check_mesh_library_supported(mesh_backend); // skip if backend not enabled at configuration time
auto mesh_manager = create_mesh_manager(mesh_backend);
REQUIRE(mesh_manager);

TEST_CASE("Test libMesh Mesh Without Geometry")
{
std::unique_ptr<MeshManager> mesh_manager = std::make_unique<LibMeshManager>();
const std::string file = std::string("cube-mesh-no-geom.") +
(mesh_backend == MeshLibrary::MOAB ? "h5m" : "exo");

mesh_manager->load_file("cube-mesh-no-geom.exo");
mesh_manager->init();
mesh_manager->load_file(file);
mesh_manager->init();

// there will be two volumes: one for the cube and one for the implicit complement
REQUIRE(mesh_manager->num_volumes() == 2);
// one surface (the boundary of the mesh) separates the two volumes
REQUIRE(mesh_manager->num_surfaces() == 1);
// there will be two volumes: one for the cube and one for the implicit complement
REQUIRE(mesh_manager->num_volumes() == 2);
// one surface (the boundary of the mesh) separates the two volumes
REQUIRE(mesh_manager->num_surfaces() == 1);

REQUIRE(mesh_manager->num_volume_elements() == 8814);
REQUIRE(mesh_manager->num_volume_elements() == 8814);
}
}
44 changes: 38 additions & 6 deletions tests/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include "xdg/constants.h"
#include "xdg/ray_tracers.h"
#include "xdg/mesh_managers.h"
#include "vulkan_probe.h"

static std::random_device rd;
Expand All @@ -15,6 +16,8 @@ inline double rand_double(double min, double max)
return dis(gen);
}

// Library availability checks

inline void check_ray_tracer_supported(xdg::RTLibrary rt) {
#ifndef XDG_ENABLE_EMBREE
if (rt == xdg::RTLibrary::EMBREE) {
Expand All @@ -33,15 +36,44 @@ inline void check_ray_tracer_supported(xdg::RTLibrary rt) {
#endif
}

// Factory function to create ray tracer based on which library selected
inline std::shared_ptr<xdg::RayTracer> create_raytracer(xdg::RTLibrary rt) {
inline void check_mesh_library_supported(xdg::MeshLibrary mesh) {
#ifndef XDG_ENABLE_MOAB
if (mesh == xdg::MeshLibrary::MOAB) {
SKIP("MOAB backend not built; skipping.");
}
#endif

#ifndef XDG_ENABLE_LIBMESH
if (mesh == xdg::MeshLibrary::LIBMESH) {
SKIP("LibMesh backend not built; skipping.");
}
#endif
}

// Factories

inline std::unique_ptr<xdg::MeshManager>
create_mesh_manager(xdg::MeshLibrary mesh) {
#ifdef XDG_ENABLE_MOAB
if (mesh == xdg::MeshLibrary::MOAB)
return std::make_unique<xdg::MOABMeshManager>();
#endif

#ifdef XDG_ENABLE_LIBMESH
if (mesh == xdg::MeshLibrary::LIBMESH)
return std::make_unique<xdg::LibMeshManager>();
#endif
}

inline std::shared_ptr<xdg::RayTracer>
create_raytracer(xdg::RTLibrary rt) {
#ifdef XDG_ENABLE_EMBREE
if (rt == xdg::RTLibrary::EMBREE)
if (rt == xdg::RTLibrary::EMBREE)
return std::make_shared<xdg::EmbreeRayTracer>();
#endif

#ifdef XDG_ENABLE_GPRT
if (rt == xdg::RTLibrary::GPRT)
if (rt == xdg::RTLibrary::GPRT)
return std::make_shared<xdg::GPRTRayTracer>();
#endif
}
}
Loading