Files
MeanField_SERiF/tests/discritization/domain/schema/validation/connected.cpp
Emily Boudreaux cb20faeb3d test(tests): added test suite
The test suite is extensive. Note that LLMs were used to aid in the development of the test suite. All LLM generated code was manually reviewed.
2026-11-09 13:53:17 -05:00

75 lines
3.3 KiB
C++

#include <catch2/catch_test_macros.hpp>
#include "mfem/mesh/mesh.hpp"
#include "serif/backend/mfem/discretization/topology.hpp"
#include "serif/discretization/domain/physical_domains.hpp"
#include "serif/discretization/domain/relation/relations.hpp"
#include "serif/discretization/domain/relation/validation/runtime.hpp"
#include "serif/discretization/domain/schema/schemas.hpp"
#include "serif/discretization/domain/schema/validation/connected.hpp"
#include "serif/discretization/domain/types.hpp"
#include "serif/tests/test_tags.hpp"
#include "serif/tests/discritization/domain/domain_test_utils.hpp"
namespace domain = serif::discretization::domain;
namespace relation = domain::relation;
namespace schema = domain::schema;
namespace validation = schema::validation;
using domain::mesh::MeshTopology;
using serif::backend::mfem::discretization::make_mesh_topology;
TEST_CASE(
"Connected Accepts Face Connected Atomic And Composite Domains",
tags::unit &tags::mesh &tags::utils &tags::domain
) {
const mfem::Mesh mesh = domain_test_utils::make_layered_mesh();
const MeshTopology topology = make_mesh_topology(mesh);
const auto coreResult = validation::RelationValidator<relation::FullyConnected<domain::CoreDomain>>::template validate<schema::CoreEnvelopeVacuumDomainSchema>(topology);
REQUIRE(coreResult);
REQUIRE(coreResult.connectedDiagnostics.has_value());
CHECK(coreResult.connectedDiagnostics->domainElementCount == 1);
CHECK(coreResult.connectedDiagnostics->visitedElementCount == 1);
const auto stellarResult = validation::RelationValidator<relation::FullyConnected<domain::StellarDomains>>::template validate<schema::CoreEnvelopeVacuumDomainSchema>(topology);
REQUIRE(stellarResult);
REQUIRE(stellarResult.connectedDiagnostics.has_value());
CHECK(stellarResult.connectedDiagnostics->domainElementCount == 9);
CHECK(stellarResult.connectedDiagnostics->visitedElementCount == 9);
}
TEST_CASE(
"Connected Rejects An Absent Domain",
tags::unit &tags::mesh &tags::utils &tags::domain
) {
const mfem::Mesh mesh = domain_test_utils::make_grid_mesh(2, 1, {2, 2}, {});
const auto result = validation::RelationValidator<relation::FullyConnected<domain::CoreDomain>>::template validate<schema::CoreEnvelopeVacuumDomainSchema>(make_mesh_topology(mesh));
CHECK_FALSE(result);
CHECK(result.failure == validation::RelationValidationFailure::DomainAbsent);
REQUIRE(result.connectedDiagnostics.has_value());
CHECK(result.connectedDiagnostics->domainElementCount == 0);
CHECK(result.connectedDiagnostics->visitedElementCount == 0);
}
TEST_CASE(
"Connected Rejects Multiple Face Disconnected Components",
tags::unit &tags::mesh &tags::utils &tags::domain
) {
const mfem::Mesh mesh = domain_test_utils::make_grid_mesh(3, 1, {1, 2, 1}, {});
const auto result = validation::RelationValidator<relation::FullyConnected<domain::CoreDomain>>::template validate<schema::CoreEnvelopeVacuumDomainSchema>(make_mesh_topology(mesh));
CHECK_FALSE(result);
CHECK(result.failure == validation::RelationValidationFailure::DomainDisconnected);
REQUIRE(result.connectedDiagnostics.has_value());
CHECK(result.connectedDiagnostics->domainElementCount == 2);
CHECK(result.connectedDiagnostics->visitedElementCount == 1);
CHECK(result.connectedDiagnostics->elementID >= 0);
}