Skip to content

Commit

Permalink
Adding invariants namespace to MinIncidentValenceInvariant.
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-zint committed Oct 12, 2023
1 parent c2f52b3 commit 91a6855
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
22 changes: 20 additions & 2 deletions src/wmtk/invariants/MinIncidentValenceInvariant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@
#include <wmtk/Mesh.hpp>
#include <wmtk/SimplicialComplex.hpp>

wmtk::MinIncidentValenceInvariant::MinIncidentValenceInvariant(const Mesh& m, long min_valence)
namespace wmtk::invariants {


MinIncidentValenceInvariant::MinIncidentValenceInvariant(const Mesh& m, long min_valence)
: MeshInvariant(m)
, m_min_valence(min_valence)
{}

bool wmtk::MinIncidentValenceInvariant::before(const Tuple& t) const
bool MinIncidentValenceInvariant::before(const Tuple& t) const
{
const Tuple v0 = t;
const Tuple v1 = mesh().switch_vertex(t);
Expand All @@ -17,3 +20,18 @@ bool wmtk::MinIncidentValenceInvariant::before(const Tuple& t) const

return val0 >= m_min_valence && val1 >= m_min_valence;
}

bool MinIncidentValenceInvariant::after(PrimitiveType type, const std::vector<Tuple>& t) const
{
assert(type == PrimitiveType::Edge);

for (const Tuple& e : t) {
if (!before(e)) {
return false;
}
}

return true;
}

} // namespace wmtk::invariants
6 changes: 3 additions & 3 deletions src/wmtk/invariants/MinIncidentValenceInvariant.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include <wmtk/attribute/AttributeHandle.hpp>
#include "MeshInvariant.hpp"

namespace wmtk {
namespace wmtk::invariants {
/**
* Invariant for minimum valence on both incident vertices of an edge.
*/
Expand All @@ -13,9 +13,9 @@ class MinIncidentValenceInvariant : public MeshInvariant
MinIncidentValenceInvariant(const Mesh& m, long min_valence);
using MeshInvariant::MeshInvariant;
bool before(const Tuple& t) const override;
bool after(PrimitiveType type, const std::vector<Tuple>& t) const override;

private:
const MeshAttributeHandle<double> m_coordinate_handle;
long m_min_valence;
};
} // namespace wmtk
} // namespace wmtk::invariants

0 comments on commit 91a6855

Please sign in to comment.