diff --git a/components/multimesh/src/wmtk/components/multimesh/utils/get_attribute.cpp b/components/multimesh/src/wmtk/components/multimesh/utils/get_attribute.cpp index 90d14a3d92..b18d2748e7 100644 --- a/components/multimesh/src/wmtk/components/multimesh/utils/get_attribute.cpp +++ b/components/multimesh/src/wmtk/components/multimesh/utils/get_attribute.cpp @@ -116,32 +116,40 @@ wmtk::attribute::MeshAttributeHandle get_attribute( auto add_option = [&](PrimitiveType prim, AT t) { ret = get_attribute(mesh, name, prim, t); + assert(ret.is_valid()); uint8_t dimension = wmtk::get_primitive_type_id(prim); possibilities.emplace_back(AttributeDescription{name, dimension, t}); }; if (pt.has_value() && type.has_value()) { + wmtk::logger().debug("Reading attribute {} with pt {} and type {}", name, primitive_type_name(pt.value()), attribute_type_name(type.value())); add_option(pt.value(), type.value()); } else if (pt.has_value()) { + wmtk::logger().debug("Reading attribute {} with pt {}", name, primitive_type_name(pt.value())); for (AT at : types) { try { + wmtk::logger().trace("Attempting to read attribute {} with pt {} and guess {}", name, primitive_type_name(pt.value()), attribute_type_name(at)); add_option(pt.value(), at); } catch (const attribute_missing_error& e) { continue; } } } else if (type.has_value()) { + wmtk::logger().debug("Reading attribute {} with and type {}", name,attribute_type_name(type.value())); for (PrimitiveType p : wmtk::utils::primitive_below(mesh.top_simplex_type())) { try { + wmtk::logger().trace("Attempting to read attribute {} with guess pt {} and type {}", name, primitive_type_name(p), attribute_type_name(type.value())); add_option(p, type.value()); } catch (const attribute_missing_error& e) { continue; } } } else { + wmtk::logger().debug("Reading attribute {}", name); for (AT at : types) { for (PrimitiveType p : wmtk::utils::primitive_below(mesh.top_simplex_type())) { try { + wmtk::logger().trace("Attempting to read attribute {} with guess pt {} and guess type {}", name, primitive_type_name(p), attribute_type_name(at)); add_option(p, at); } catch (const attribute_missing_error& e) { continue; diff --git a/src/wmtk/attribute/AttributeType.cpp b/src/wmtk/attribute/AttributeType.cpp new file mode 100644 index 0000000000..a3fc3185ff --- /dev/null +++ b/src/wmtk/attribute/AttributeType.cpp @@ -0,0 +1,24 @@ +#include "AttributeType.hpp" +namespace wmtk::attribute { +const std::string_view attribute_type_name(AttributeType pt) { + + switch(pt) { + case AttributeType::Char: + return attribute_type_traits::name; + case AttributeType::Int64: + return attribute_type_traits::name; + case AttributeType::Double: + return attribute_type_traits::name; + case AttributeType::Rational: + return attribute_type_traits::name; + default: + break; + } + return ""; +} + +const std::string_view attribute_type_traits::name = "Rational"; +const std::string_view attribute_type_traits::name = "Double"; +const std::string_view attribute_type_traits::name = "Int64"; +const std::string_view attribute_type_traits::name = "Char"; +} diff --git a/src/wmtk/attribute/AttributeType.hpp b/src/wmtk/attribute/AttributeType.hpp index 3cccfddf19..c7e3938f50 100644 --- a/src/wmtk/attribute/AttributeType.hpp +++ b/src/wmtk/attribute/AttributeType.hpp @@ -5,32 +5,36 @@ namespace wmtk::attribute { enum class AttributeType { Char = 0, Int64 = 1, Double = 2, Rational = 3 }; template -struct type_from_attribute_type_enum +struct attribute_type_traits { }; template <> -struct type_from_attribute_type_enum +struct attribute_type_traits { using type = char; + const static std::string_view name; }; template <> -struct type_from_attribute_type_enum +struct attribute_type_traits { using type = double; + const static std::string_view name; }; template <> -struct type_from_attribute_type_enum +struct attribute_type_traits { using type = int64_t; + const static std::string_view name; }; template <> -struct type_from_attribute_type_enum +struct attribute_type_traits { using type = wmtk::Rational; + const static std::string_view name; }; template -using type_from_attribute_type_enum_t = typename type_from_attribute_type_enum::type; +using type_from_attribute_type_enum_t = typename attribute_type_traits::type; template inline constexpr auto attribute_type_enum_from_type() -> AttributeType @@ -53,4 +57,5 @@ inline constexpr auto attribute_type_enum_from_type() -> AttributeType return AttributeType::Char; } } +const std::string_view attribute_type_name(AttributeType pt); } // namespace wmtk::attribute diff --git a/src/wmtk/attribute/CMakeLists.txt b/src/wmtk/attribute/CMakeLists.txt index cd8f3506ca..7b2d12439b 100644 --- a/src/wmtk/attribute/CMakeLists.txt +++ b/src/wmtk/attribute/CMakeLists.txt @@ -35,6 +35,7 @@ set(SRC_FILES Accessor.hpp AttributeType.hpp + AttributeType.cpp ) target_sources(wildmeshing_toolkit PRIVATE ${SRC_FILES})