feat(mapper): finished porting over mapper
This commit is contained in:
@@ -5,6 +5,8 @@
|
||||
#include "mfem/linalg/vector.hpp"
|
||||
#include "mfem/linalg/densemat.hpp"
|
||||
|
||||
#include "serif/utils/misc/concepts/numeric.hpp"
|
||||
|
||||
namespace serif::utils::checks {
|
||||
// If we have a new backend / new vector and matrix type in the future we can add new overloads
|
||||
inline bool is_finite(const mfem::Vector& vector) {
|
||||
@@ -28,4 +30,10 @@ namespace serif::utils::checks {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
template <typename Scalar>
|
||||
requires requires (Scalar x) {{std::isfinite(x)} -> std::convertible_to<bool>; }
|
||||
bool is_finite(const Scalar scalar) {
|
||||
return std::isfinite(scalar);
|
||||
}
|
||||
}
|
||||
@@ -15,7 +15,7 @@ namespace serif::utils::errors {
|
||||
// stay consistent here.
|
||||
|
||||
// At some point someone should go through and come up with some well defined schema for all this
|
||||
enum class SERiFErrorCode : uint16_t {
|
||||
enum class SERiFErrorCode : uint16_t { // 16 bit backing type, so 65535 possible error codes, which should be far far far more than enough for now
|
||||
UNKNOWN_ERROR = 0,
|
||||
|
||||
// RUNTIME FAILURES (>100)
|
||||
@@ -30,6 +30,7 @@ namespace serif::utils::errors {
|
||||
// Jacobian Errors
|
||||
JACOBIAN_ERROR = 200,
|
||||
INVERTED_JACOBIAN,
|
||||
NON_FINITE_DETERMINATE,
|
||||
|
||||
// EOS Errors
|
||||
EOS_ERROR = 300,
|
||||
@@ -50,16 +51,35 @@ namespace serif::utils::errors {
|
||||
OUTSIDE_REFERENCE_DOMAIN,
|
||||
NON_FINITE_MAPPING_RESULT,
|
||||
NON_POSITIVE_DETERMINATE,
|
||||
INVALID_MAPPING,
|
||||
|
||||
MISC_MAPPING_ERROR=410,
|
||||
INVALID_DOF_COUNT,
|
||||
INVALID_ELEMENT_GEOMETRY,
|
||||
INVALID_DOF_ORDERING,
|
||||
INVALID_COMPACTIFICATION_RANK,
|
||||
INVALID_COMPACTIFICATION_TYPE,
|
||||
INVALID_COMPACTIFICATION_DERIVATIVE_VALUE,
|
||||
INVALID_COMPACTIFICATION_DERIVATIVE_TYPE,
|
||||
INVALID_VACUUM_ELEMENT_ATTRIBUTE_ID,
|
||||
MISSING_EXTERIOR_MAP,
|
||||
COMPACTIFICATION_MISMATCH,
|
||||
MISSING_FACE_ELEMENT,
|
||||
JACOBIAN_SHAPE_ERROR,
|
||||
MISSING_DISPLACEMENT_FINITE_ELEMENT_SPACE,
|
||||
MISMATCHED_MESHING_MAPS,
|
||||
|
||||
IMPROPERLY_ORDERED_REFERENCE_RADII = 450,
|
||||
INVALID_COORDINATE_TOLERANCE,
|
||||
|
||||
EVALUATOR_ERROR=460,
|
||||
CACHE_FE_BINDING_ERROR,
|
||||
INVALID_ELEMENT_ID_ERROR,
|
||||
ELEMENT_NULLPTR_ERROR,
|
||||
|
||||
//As yet uncategorized errors
|
||||
MATRIX_SHAPE_ERROR = 500,
|
||||
OUT_OF_RANGE_ERROR,
|
||||
|
||||
// COMPILE TIME FAILURES (>1000)
|
||||
// Type Invariant Failures
|
||||
FAILED_TYPE_INVARIANT = 1000
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace serif::utils::errors {
|
||||
throw ExceptionT(error_msg);
|
||||
}
|
||||
|
||||
template <SERiFErrorCode code>
|
||||
template <SERiFErrorCode code, misc::concepts::IsException ExceptionT = std::logic_error>
|
||||
void serif_assert(const bool condition, const std::string_view message, auto... args) {
|
||||
// collapse to a noop if NDEBUG is defined
|
||||
#ifndef NDEBUG
|
||||
@@ -48,7 +48,7 @@ namespace serif::utils::errors {
|
||||
#endif
|
||||
if constexpr(is_debug_build) {
|
||||
if (!condition) {
|
||||
serif_error<std::logic_error, code>(message, args...);
|
||||
serif_error<ExceptionT, code>(message, args...);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -75,4 +75,25 @@ namespace serif::utils::errors {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// The difference between serif_assert and serif_ensure is that serif_assert is a noop in release builds, while serif_ensure is always active.
|
||||
// Use an ensure when you want to always check things. Use an assert when you want to check things that are true bugs
|
||||
// and should not manifest in release builds.
|
||||
template <SERiFErrorCode code, misc::concepts::IsException ExceptionT = std::logic_error>
|
||||
void serif_ensure(const bool condition, const std::string_view message, auto... args) {
|
||||
if (!condition) {
|
||||
serif_error<ExceptionT, code>(message, args...);
|
||||
}
|
||||
}
|
||||
|
||||
template <SERiFErrorCode code, types::ct_error_string message, bool condition>
|
||||
constexpr void serif_ensure() {
|
||||
if constexpr (!condition) {
|
||||
// Trigger an intentional error to display the message and code at compile time
|
||||
|
||||
// Note if we move to C++26 we can replace this with a more standard and less convoluted
|
||||
// formated static_assert.
|
||||
[[maybe_unused]] std::size_t error_kick = sizeof(serif_error_printer<message, code>);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user