Compare commits

...

2 Commits

6 changed files with 20 additions and 45 deletions

View File

@@ -31,19 +31,6 @@ namespace serif::discretization::domain::schema {
using relation::validation::HaveValidRelationEntities;
/**
* @brief A DomainSchema is a collection of relations that describe the relationships between domains and boundaries in a mesh.
* It is used to validate that a mesh has the expected set of domains and boundaries, and that those domains and boundaries
* have the expected topological relations.
*
* @tparam DomainIDs The list of domain IDs that are expected in the mesh.
* @tparam BoundaryIDs The list of boundary IDs that are expected in the mesh.
* @tparam Relations The list of relations that describe the relationships between the domains and boundaries.
*
* There is an additional requirement on instantiating a DomainSchema, that the relations defined in the third template
* argument only require domain and boundary IDs that are present in the first two template arguments.
*
*
* /**
* @brief A DomainSchema is a collection of relations that describe the relationships between domains and boundaries in a mesh.
* It is used to validate that a mesh has the expected set of domains and boundaries, and that those domains and boundaries
* have the expected topological relations. This is important for ensuring that the mesh is suitable for the intended

View File

@@ -4,11 +4,9 @@
* @file all.hpp
* @author Emily M. Boudreaux
*
* @brief File containing the overloads of validate_schema which automatically distributes the mesh to the correct validation function based on the schema type
* @brief File containing validate_schema, which selects the topology validators required by the schema type.
*/
#include <mfem.hpp>
#include "serif/discretization/domain/mesh/topology.hpp"
#include "serif/discretization/domain/schema/concepts.hpp"
#include "serif/discretization/domain/schema/validation/results.hpp"
@@ -16,8 +14,8 @@
// Every RelationValidator specialization must be visible before
// SchemaRelationValidator is instantiated, so they are all included here and
// validate_schema is defined only in this header. Include this file to validate
// a mesh; including validator.hpp alone is not enough.
// the topology overload of validate_schema is defined here. Include this file
// to validate topology; including validator.hpp alone is not enough.
#include "serif/discretization/domain/schema/validation/boundary.hpp"
#include "serif/discretization/domain/schema/validation/connected.hpp"
#include "serif/discretization/domain/schema/validation/inscribed.hpp"
@@ -36,19 +34,4 @@ namespace serif::discretization::domain::schema::validation {
return SchemaRelationValidator<SchemaT, RelationsT>::validate(topology);
}
/**
* @brief Validate a mesh against a schema.
*
* @tparam SchemaT The schema type to validate against.
* @param mfemMesh The MFEM mesh to validate.
* @return A SchemaValidationResult containing the validation results.
*
* @note This overload is provided for convenience. It constructs a MeshTopology from the given MFEM mesh and then calls the other overload of validate_schema. It
* may be more efficient to construct a MeshTopology once and reuse it for multiple validations, rather than constructing it each time.
*/
template <IsSchema SchemaT>
[[nodiscard]] SchemaValidationResult validate_schema(const mfem::Mesh &mfemMesh) {
const mesh::MeshTopology topology{mfemMesh};
return validate_schema<SchemaT>(topology);
}
}

View File

@@ -66,10 +66,10 @@ namespace serif::discretization::domain::schema::validation {
if (domainElementCount == 0) {
return {
.failure = RelationValidationFailure::DomainAbsent,
.connectedDiagnostics = std::make_optional<RelationValidationResult::ConnectedDiagnostics>({
.connectedDiagnostics = RelationValidationResult::ConnectedDiagnostics{
.domainElementCount = 0,
.visitedElementCount = 0
})};
}};
}
std::vector<bool> visited(static_cast<std::size_t>(elementCount), false);
@@ -102,9 +102,7 @@ namespace serif::discretization::domain::schema::validation {
if (visitedElementCount == domainElementCount) {
return {
.connectedDiagnostics = std::make_optional<RelationValidationResult::ConnectedDiagnostics>(
{.domainElementCount = domainElementCount, .visitedElementCount = visitedElementCount}
)
.connectedDiagnostics = RelationValidationResult::ConnectedDiagnostics{.domainElementCount = domainElementCount, .visitedElementCount = visitedElementCount}
};
}
@@ -121,11 +119,11 @@ namespace serif::discretization::domain::schema::validation {
return {
.failure = RelationValidationFailure::DomainDisconnected,
.connectedDiagnostics = std::make_optional<RelationValidationResult::ConnectedDiagnostics>({
.connectedDiagnostics = RelationValidationResult::ConnectedDiagnostics{
.elementID = disconnectedElementID,
.domainElementCount = domainElementCount,
.visitedElementCount = visitedElementCount
})};
}};
}
};
}

View File

@@ -86,10 +86,10 @@ namespace serif::discretization::domain::schema::validation {
if (adjacentElementID < 0) {
return {
.failure = RelationValidationFailure::InnerDomainTouchesMeshBoundary,
.inscribedDiagnostics = std::make_optional<RelationValidationResult::InscribedDiagnostics>({
.inscribedDiagnostics = RelationValidationResult::InscribedDiagnostics{
.faceID = faceID,
.innerElementID = innerElementID,
})};
}};
}
const int adjacentDomainID = topology.element_domain_id(adjacentElementID);
@@ -97,12 +97,12 @@ namespace serif::discretization::domain::schema::validation {
if (!SchemaT::template domain_id_belongs_to<OuterT>(adjacentDomainID)) {
return {
.failure = RelationValidationFailure::InnerDomainTouchesUnexpectedDomain,
.inscribedDiagnostics = std::make_optional<RelationValidationResult::InscribedDiagnostics>({
.inscribedDiagnostics = RelationValidationResult::InscribedDiagnostics{
.faceID = faceID,
.innerElementID = innerElementID,
.adjacentElementID = adjacentElementID,
.adjacentDomainID = adjacentDomainID
})};
}};
}
}

View File

@@ -0,0 +1,7 @@
#pragma once
#include "serif/backend/mfem/discretization/schema.hpp"
namespace serif::discretization::domain::schema::validation {
using serif::backend::mfem::discretization::validate_schema;
}

View File

@@ -45,7 +45,7 @@ namespace serif::discretization::domain::schema::validation {
* @tparam RelationTs The list of relations to validate.
*/
template <IsSchema SchemaT, IsRelation... RelationTs>
struct SchemaRelationValidator<SchemaT, RelationList<RelationTs...>> {
struct SchemaRelationValidator<SchemaT, relation::lists::RelationList<RelationTs...>> {
/**
* @brief Validate a mesh against a schema, running one validator per declared relation in the schema.
* @param topology The mesh topology to validate against the schema.