15 #include "nlohmann/json.h" 19 #include "libmesh/libmesh_common.h" 21 #include "metaphysicl/dualsemidynamicsparsenumberarray.h" 30 typedef std::variant<
int,
36 std::vector<unsigned int>,
37 std::vector<std::string>,
60 void to_json(nlohmann::json & json,
const Point & p);
68 template <
typename Scalar,
int Rows,
int Cols,
int Options,
int MaxRows,
int MaxCols>
69 void to_json(nlohmann::json & json,
70 const Matrix<Scalar, Rows, Cols, Options, MaxRows, MaxCols> & matrix);
81 std::visit([&j](
const auto &
value) { j =
value; }, data);
86 struct adl_serializer<
std::unique_ptr<T>>
92 static void to_json(json & j,
const std::unique_ptr<T> & v)
94 if constexpr (std::is_constructible_v<nlohmann::json, T>)
102 mooseAssert(
false,
"Should not get to this");
109 template <
template <
typename,
size_t>
class Array,
typename T,
size_t N>
111 to_json(nlohmann::json & json,
const DynamicArrayWrapper<Array, T, N> & array)
113 for (
const auto element : array)
117 template <
typename T,
typename I,
typename N,
typename ArrayWrapper>
120 const SemiDynamicSparseNumberArrayGeneric<T, I, N, ArrayWrapper> & sdsna)
122 to_json(json, sdsna.nude_indices());
123 to_json(json, sdsna.nude_data());
126 template <
typename T,
typename D,
bool asd>
131 to_json(json, dn.derivatives());
137 template <
typename Scalar,
int Rows,
int Cols,
int Options,
int MaxRows,
int MaxCols>
139 to_json(nlohmann::json & json,
const Matrix<Scalar, Rows, Cols, Options, MaxRows, MaxCols> & matrix)
141 if constexpr (Rows == 1 || Cols == 1)
143 std::vector<Scalar> values(matrix.data(), matrix.data() + matrix.rows() * matrix.cols());
148 const auto nrows = matrix.rows();
149 const auto ncols = matrix.cols();
150 std::vector<std::vector<Scalar>> values(nrows, std::vector<Scalar>(ncols));
153 values[i][j] = matrix(i, j);
159 template <
typename T>
163 to_json(json,
static_cast<const Eigen::Matrix<T, 2, 1> &
>(two_vector));
template class LIBMESH_EXPORT DenseVector< Real >
Base class for MOOSE-based applications.
void to_json(nlohmann::json &json, const Point &p)
The following methods are specializations for using the libMesh::Parallel::packed_range_* routines fo...
static void to_json(json &j, const std::unique_ptr< T > &v)
Serializer that will output a unique ptr if it exists.
Real value(unsigned n, unsigned alpha, unsigned beta, Real x)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
std::variant< int, unsigned int, std::string, Real, bool, std::vector< int >, std::vector< unsigned int >, std::vector< std::string >, std::vector< Real >, std::vector< bool > > AttributeVariant
Type definition for a variant that can hold all the supported types for lattice attributes.
IntRange< T > make_range(T beg, T end)
A two-component zero initialized vector used for tangential quantities.
void to_json(nlohmann::json &json, const MooseApp &app)
void to_json(nlohmann::json &json, const Matrix< Scalar, Rows, Cols, Options, MaxRows, MaxCols > &matrix)
void ErrorVector unsigned int
static void to_json(json &j, const AttributeVariant &data)