Commit 3856cc1b authored by Dennis Gläser's avatar Dennis Gläser
Browse files

[constraintseval] add more verbose boolean interface

parent 9e3323f8
Pipeline #2727 passed with stages
in 8 minutes and 37 seconds
......@@ -185,11 +185,11 @@ int main(int argc, char** argv)
{ status.increaseRejectedCounter("minimum contained area violation"); continue; }
// enforce constraints w.r.t. to the other entities
if (const auto res = constraintsMatrix.evaluate(entitySets, geom, id); !res)
if (const auto res = constraintsMatrix.evaluate(entitySets, geom, id); res.violationDetected())
{ status.increaseRejectedCounter(res.violationLabel()); continue; }
// enforce constraints w.r.t. the domain boundaries
if (const auto res = constraintsOnDomain.evaluate(domainBoundaryFaces, geom); !res)
if (const auto res = constraintsOnDomain.evaluate(domainBoundaryFaces, geom); res.violationDetected())
{ status.increaseRejectedCounter(res.violationLabel() + " (boundary)"); continue; }
// the geometry is admissible
......
......@@ -154,15 +154,15 @@ while not status.finished():
continue
# enforce constraints w.r.t. to the other entities
check = constraintsMatrix.evaluate(entitySets, geom, id)
if not check:
status.increaseRejectedCounter(check.violationLabel())
eval = constraintsMatrix.evaluate(entitySets, geom, id)
if eval.violationDetected():
status.increaseRejectedCounter(eval.violationLabel())
continue
# enforce constraints w.r.t. the domain boundaries
check = constraintsOnDomain.evaluate(domainBoundaryFaces, geom)
if not check:
status.increaseRejectedCounter(check.violationLabel() + " (boundary)")
eval = constraintsOnDomain.evaluate(domainBoundaryFaces, geom)
if eval.violationDetected():
status.increaseRejectedCounter(eval.violationLabel() + " (boundary)")
continue
# the geometry is admissible
......
......@@ -76,11 +76,14 @@ struct ConstraintsEvaluation
std::string violationLabel() const
{ return violationLabel(violation_); }
//! returns true if evaluation was
//! positive, i.e. no violation was detected
//! this evaluates to true if no violation was detected
explicit operator bool() const
{ return violation_ == Violation::none; }
//! returns true if a violation was detected
bool violationDetected() const
{ return violation_ != Violation::none; }
//! return a label for the given violation
static std::string violationLabel(Violation v)
{
......
......@@ -150,6 +150,7 @@ void registerConstraints(py::module& module)
evalResult.def(py::init<Result::Violation>());
evalResult.def("__bool__", &Result::operator bool, "returns true if no violation was detected");
evalResult.def("violation", &Result::violation, "return the type of detected violation");
evalResult.def("violationDetected", &Result::violationDetected, "return true if a violation was detected");
evalResult.def("violationLabel", py::overload_cast<>(&Result::violationLabel, py::const_),
"return a label for the type of detected violation");
evalResult.def("violationLabel", py::overload_cast<Result::Violation>(&Result::violationLabel),
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment