Skip to content

Commit

Permalink
Merge pull request #853 from wildmeshing/dzint/public_id
Browse files Browse the repository at this point in the history
Make ids public.
  • Loading branch information
daniel-zint authored Feb 13, 2025
2 parents 958ba69 + 9d9d843 commit d81f349
Show file tree
Hide file tree
Showing 96 changed files with 436 additions and 788 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,15 @@ jobs:
cd build
ctest --verbose --output-on-failure
lcov --directory . --capture --output-file coverage.info
lcov --remove coverage.info '/usr/*' "${HOME}"'/.cache/*' '*tests/*.cpp' '*tests/*.hpp' --output-file coverage.info
lcov --remove coverage.info '/usr/*' '*tests/*.cpp' '*tests/*.hpp' --output-file coverage.info
- name: Upload Coverage
uses: codecov/codecov-action@v4
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
with:
flags: wildmeshing # optional
files: coverage.info
name: wildmeshing # optional
fail_ci_if_error: false # optional (default = false)
verbose: true # optional (default = false)
flags: wildmeshing # optional
files: coverage.info
name: wildmeshing # optional
fail_ci_if_error: false # optional (default = false)
verbose: true # optional (default = false)
5 changes: 1 addition & 4 deletions applications/procedural/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
#include <wmtk/utils/Logger.hpp>

#include <wmtk/components/input/input.hpp>
#include <wmtk/components/output/output.hpp>
#include <wmtk/components/output/OutputOptions.hpp>
#include <wmtk/components/output/output.hpp>
#include <wmtk/components/utils/resolve_path.hpp>

#include <wmtk/TriMesh.hpp>
Expand Down Expand Up @@ -74,9 +74,6 @@ int main(int argc, char* argv[])
},
options.settings);


using namespace internal;

if (!bool(mesh)) {
throw std::runtime_error("Did not obtain a mesh when generating a procedural one");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
#include <wmtk/Scheduler.hpp>
#include <wmtk/TriMesh.hpp>
#include <wmtk/invariants/FusionEdgeInvariant.hpp>
#include <wmtk/invariants/InteriorSimplexInvariant.hpp>
#include <wmtk/invariants/InvariantCollection.hpp>
#include <wmtk/invariants/MultiMeshMapValidInvariant.hpp>
#include <wmtk/invariants/MultiMeshLinkConditionInvariant.hpp>
#include <wmtk/invariants/MinEdgeLengthInvariant.hpp>
#include <wmtk/invariants/MaxEdgeLengthInvariant.hpp>
#include <wmtk/invariants/ValenceImprovementInvariant.hpp>
#include <wmtk/invariants/InteriorSimplexInvariant.hpp>
#include <wmtk/invariants/MinEdgeLengthInvariant.hpp>
#include <wmtk/invariants/MultiMeshLinkConditionInvariant.hpp>
#include <wmtk/invariants/MultiMeshMapValidInvariant.hpp>
#include <wmtk/invariants/SimplexInversionInvariant.hpp>
#include <wmtk/invariants/ValenceImprovementInvariant.hpp>
#include <wmtk/invariants/uvEdgeInvariant.hpp>
#include <wmtk/io/ParaviewWriter.hpp>
#include <wmtk/multimesh/MultiMeshVisitor.hpp>
Expand Down Expand Up @@ -55,9 +55,6 @@ double relative_to_absolute_length(

void isotropic_remeshing(const IsotropicRemeshingOptions& options)
{
using namespace internal;


auto position = options.position_attribute;

if (position.mesh().top_simplex_type() != PrimitiveType::Triangle) {
Expand Down Expand Up @@ -175,7 +172,6 @@ void isotropic_remeshing(const IsotropicRemeshingOptions& options)
ops.push_back(op_split);



//////////////////////////////////////////
// collapse
wmtk::logger().debug("Configure isotropic remeshing collapse");
Expand Down
1 change: 0 additions & 1 deletion components/tests/test_component_isotropic_remeshing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
#include <nlohmann/json.hpp>
#include <tools/DEBUG_EdgeMesh.hpp>
#include <tools/DEBUG_TriMesh.hpp>
#include <tools/DEBUG_Tuple.hpp>
#include <tools/EdgeMesh_examples.hpp>
#include <tools/TriMesh_examples.hpp>
#include <wmtk/Scheduler.hpp>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -916,8 +916,6 @@ std::tuple<std::shared_ptr<TriMesh>, nlohmann::json> tetwild_simplification(
double duplicate_tol,
bool use_sampling)
{
using namespace internal;

wmtk::utils::EigenMatrixWriter writer;
mesh.serialize(writer);

Expand Down
1 change: 1 addition & 0 deletions src/wmtk/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ set(SRC_FILES
Primitive.cpp
Tuple.hxx
Tuple.hpp
Tuple.cpp
Types.hpp
Scheduler.hpp
Scheduler.cpp
Expand Down
34 changes: 17 additions & 17 deletions src/wmtk/EdgeMesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ bool EdgeMesh::is_boundary_vertex(const Tuple& tuple) const
{
assert(is_valid(tuple));
const attribute::Accessor<int64_t> ee_accessor = create_const_accessor<int64_t>(m_ee_handle);
return ee_accessor.const_vector_attribute<2>(tuple)(tuple.m_local_vid) < 0;
return ee_accessor.const_vector_attribute<2>(tuple)(tuple.local_vid()) < 0;
}

Tuple EdgeMesh::switch_tuple(const Tuple& tuple, PrimitiveType type) const
Expand All @@ -43,22 +43,22 @@ Tuple EdgeMesh::switch_tuple(const Tuple& tuple, PrimitiveType type) const
switch (type) {
case PrimitiveType::Vertex:
return Tuple(
1 - tuple.m_local_vid,
tuple.m_local_eid,
tuple.m_local_fid,
tuple.m_global_cid);
1 - tuple.local_vid(),
tuple.local_eid(),
tuple.local_fid(),
tuple.global_cid());
case PrimitiveType::Edge: {
const int64_t gvid = id(tuple, PrimitiveType::Vertex);

const attribute::Accessor<int64_t> ee_accessor =
create_const_accessor<int64_t>(m_ee_handle);
auto ee = ee_accessor.const_vector_attribute<2>(tuple);

int64_t gcid_new = ee(tuple.m_local_vid);
int64_t gcid_new = ee(tuple.local_vid());

// This is for special case self-loop, just to make sure the local vid of the returned
// tuple is the same as the input. (When doing double-switch this is needed)
if (gcid_new == tuple.m_global_cid) {
if (gcid_new == tuple.global_cid()) {
return tuple;
}

Expand All @@ -77,7 +77,7 @@ Tuple EdgeMesh::switch_tuple(const Tuple& tuple, PrimitiveType type) const
assert(lvid_new != -1);


const Tuple res(lvid_new, tuple.m_local_eid, tuple.m_local_fid, gcid_new);
const Tuple res(lvid_new, tuple.local_eid(), tuple.local_fid(), gcid_new);
assert(is_valid(res));
return res;
}
Expand All @@ -92,7 +92,7 @@ Tuple EdgeMesh::switch_tuple(const Tuple& tuple, PrimitiveType type) const
bool EdgeMesh::is_ccw(const Tuple& tuple) const
{
assert(is_valid(tuple));
return tuple.m_local_vid == 0;
return tuple.local_vid() == 0;
}

void EdgeMesh::initialize(
Expand Down Expand Up @@ -217,16 +217,16 @@ bool EdgeMesh::is_valid(const Tuple& tuple) const
return false;
}

const bool is_connectivity_valid = tuple.m_local_vid >= 0 && tuple.m_global_cid >= 0;
const bool is_connectivity_valid = tuple.local_vid() >= 0 && tuple.global_cid() >= 0;
if (!is_connectivity_valid) {
#if !defined(NDEBUG)
logger().debug(
"tuple.m_local_vid={} >= 0"
" tuple.m_global_cid={} >= 0",
tuple.m_local_vid,
tuple.m_global_cid);
assert(tuple.m_local_vid >= 0);
assert(tuple.m_global_cid >= 0);
"tuple.local_vid()={} >= 0"
" tuple.global_cid()={} >= 0",
tuple.local_vid(),
tuple.global_cid());
assert(tuple.local_vid() >= 0);
assert(tuple.global_cid() >= 0);
#endif
return false;
}
Expand Down Expand Up @@ -292,7 +292,7 @@ std::vector<std::vector<TypedAttributeHandle<int64_t>>> EdgeMesh::connectivity_a

std::vector<Tuple> EdgeMesh::orient_vertices(const Tuple& tuple) const
{
int64_t cid = tuple.m_global_cid;
int64_t cid = tuple.global_cid();
return {Tuple(0, -1, -1, cid), Tuple(1, -1, -1, cid)};
}

Expand Down
8 changes: 4 additions & 4 deletions src/wmtk/EdgeMesh.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,18 @@ class EdgeMesh : public MeshCRTP<EdgeMesh>
std::vector<std::vector<TypedAttributeHandle<int64_t>>> connectivity_attributes()
const override;


Tuple switch_vertex(const Tuple& tuple) const;
Tuple switch_edge(const Tuple& tuple) const;

std::vector<Tuple> orient_vertices(const Tuple& tuple) const override;

protected:
int64_t id(const Tuple& tuple, PrimitiveType type) const;
using MeshCRTP<EdgeMesh>::id; // getting the (simplex) prototype

int64_t id_vertex(const Tuple& tuple) const { return id(tuple, PrimitiveType::Vertex); }
int64_t id_edge(const Tuple& tuple) const { return id(tuple, PrimitiveType::Edge); }

protected:
/**
* @brief internal function that returns the tuple of requested type, and has the global index
* cid
Expand Down Expand Up @@ -102,10 +102,10 @@ inline int64_t EdgeMesh::id(const Tuple& tuple, PrimitiveType type) const
const attribute::Accessor<int64_t, EdgeMesh> ev_accessor =
create_const_accessor<int64_t>(m_ev_handle);
auto ev = ev_accessor.const_vector_attribute<2>(tuple);
return ev(tuple.m_local_vid);
return ev(tuple.local_vid());
}
case PrimitiveType::Edge: {
return tuple.m_global_cid;
return tuple.global_cid();
}
case PrimitiveType::Triangle:
case PrimitiveType::Tetrahedron:
Expand Down
2 changes: 1 addition & 1 deletion src/wmtk/Mesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ bool Mesh::is_valid(const Tuple& tuple) const

bool Mesh::is_removed(const Tuple& tuple) const
{
return is_removed(tuple.m_global_cid);
return is_removed(tuple.global_cid());
}
bool Mesh::is_removed(const Tuple& t, PrimitiveType pt) const
{
Expand Down
27 changes: 6 additions & 21 deletions src/wmtk/Mesh.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
#include "Types.hpp"
#include "attribute/AttributeManager.hpp"
#include "attribute/AttributeScopeHandle.hpp"
#include "attribute/FlagAccessor.hpp"
#include "attribute/MeshAttributeHandle.hpp"
#include "attribute/MeshAttributes.hpp"
#include "attribute/FlagAccessor.hpp"
#include "multimesh/attribute/AttributeScopeHandle.hpp"

#include "multimesh/attribute/UseParentScopeRAII.hpp"
Expand All @@ -43,11 +43,6 @@
namespace wmtk {
namespace tests {
class DEBUG_Mesh;
namespace tools {

class TestTools;

}
} // namespace tests
// thread management tool that we will PImpl
namespace attribute {
Expand All @@ -69,13 +64,6 @@ class UpdateEdgeOperationMultiMeshMapFunctor;
}
} // namespace operations

namespace simplex {
class RawSimplex;
namespace utils {
class SimplexComparisons;
}
} // namespace simplex

namespace io {
class ParaviewWriter;
}
Expand All @@ -90,7 +78,7 @@ template <typename Visitor>
class MultiMeshVisitorExecutor;

namespace utils {
class MapValidator;
class MapValidator;
namespace internal {
class TupleTag;
}
Expand All @@ -106,7 +94,6 @@ class TupleTag;
class Mesh : public std::enable_shared_from_this<Mesh>, public wmtk::utils::MerkleTreeInteriorNode
{
public:
friend class tests::tools::TestTools;
friend class tests::DEBUG_Mesh;
template <typename T, int Dim>
friend class attribute::AccessorBase;
Expand All @@ -129,11 +116,6 @@ class Mesh : public std::enable_shared_from_this<Mesh>, public wmtk::utils::Merk
friend class multimesh::attribute::AttributeScopeHandle;
friend class multimesh::utils::internal::TupleTag;
friend class operations::utils::UpdateEdgeOperationMultiMeshMapFunctor;
friend class simplex::RawSimplex;
friend class simplex::Simplex;
friend class simplex::IdSimplex;
friend class simplex::SimplexCollection;
friend class simplex::utils::SimplexComparisons;
friend class operations::Operation;
friend class operations::EdgeCollapse;
friend class operations::EdgeSplit;
Expand Down Expand Up @@ -795,7 +777,7 @@ class Mesh : public std::enable_shared_from_this<Mesh>, public wmtk::utils::Merk
// creates a scope as int64_t as the AttributeScopeHandle exists
[[nodiscard]] attribute::AttributeScopeHandle create_single_mesh_scope();

protected:
public:
/**
* @brief return the global id of the Tuple of the given dimension
*
Expand All @@ -812,8 +794,11 @@ class Mesh : public std::enable_shared_from_this<Mesh>, public wmtk::utils::Merk

int64_t id(const simplex::NavigatableSimplex& s) const { return s.index(); }
int64_t id(const simplex::IdSimplex& s) const { return s.index(); }

/// Forwarding version of id on simplices that does id caching
virtual int64_t id(const simplex::Simplex& s) const = 0;

protected:
/// Internal utility to allow id to be virtual with a non-virtual overload in derived -Mesh classes.
/// Mesh::id invokes Mesh::id_virtual which is final overriden by MeshCRTP<TriMesh>::id_virtual, which in turn invokes MeshCRTP<TriMesh>::id, and then TriMesh::id.
/// This circuitous mechanism makes MeshCRTP<TriMesh>::id and TriMesh::id fully inlineable, so code that wants to take in any derived class can get optimized results with MeshCRTP, or for cases where classes want to utilize just TriMesh they can get inline/accelerated usage as well.
Expand Down
19 changes: 10 additions & 9 deletions src/wmtk/MeshCRTP.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,26 +98,27 @@ class MeshCRTP : public Mesh
return create_const_accessor<T, Dim>(handle.as<T>());
}

protected:
public:
/// Returns the id of a simplex encoded in a tuple
int64_t id(const Tuple& tuple, PrimitiveType type) const { return derived().id(tuple, type); }
/// internal utility for overriding the mesh class's id function without having the final override block the derived class's override
/// (we can't have Mesh::id be virtual, MeshCRTP<Derived>::id final override, and TriMesh::id. This indirection pushes the final override to this other function
int64_t id_virtual(const Tuple& tuple, PrimitiveType type) const final override
{
return id(tuple, type);
}

/// variant of id that can cache internally held values
int64_t id(const simplex::Simplex& s) const final override
{

return id(s.tuple(),s.primitive_type());
return id(s.tuple(), s.primitive_type());
}

// catch any other Mesh id methods that might emerge by default
using Mesh::id;

protected:
/// internal utility for overriding the mesh class's id function without having the final override block the derived class's override
/// (we can't have Mesh::id be virtual, MeshCRTP<Derived>::id final override, and TriMesh::id. This indirection pushes the final override to this other function
int64_t id_virtual(const Tuple& tuple, PrimitiveType type) const final override
{
return id(tuple, type);
}


protected:
Tuple tuple_from_id(const PrimitiveType type, const int64_t gid) const override
Expand Down
7 changes: 3 additions & 4 deletions src/wmtk/PointMesh.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ class PointMesh : public MeshCRTP<PointMesh>
void initialize(int64_t count);


bool is_valid(const Tuple& tuple)
const final override;
bool is_valid(const Tuple& tuple) const final override;

bool is_connectivity_valid() const override { return true; }

Expand All @@ -44,10 +43,10 @@ class PointMesh : public MeshCRTP<PointMesh>

std::vector<Tuple> orient_vertices(const Tuple& tuple) const override;

protected:
using MeshCRTP<PointMesh>::id; // getting the (simplex) prototype
int64_t id(const Tuple& tuple, PrimitiveType type) const;

protected:
/**
* @brief internal function that returns the tuple of requested type, and has the global index
* cid
Expand All @@ -61,7 +60,7 @@ class PointMesh : public MeshCRTP<PointMesh>
inline int64_t PointMesh::id(const Tuple& tuple, PrimitiveType type) const
{
switch (type) {
case PrimitiveType::Vertex: return tuple.m_global_cid;
case PrimitiveType::Vertex: return tuple.global_cid();
case PrimitiveType::Edge:
case PrimitiveType::Triangle:
case PrimitiveType::Tetrahedron:
Expand Down
Loading

0 comments on commit d81f349

Please sign in to comment.