15#include "nlohmann/json.h"
19#include "libmesh/libmesh_common.h"
21#include "metaphysicl/dualsemidynamicsparsenumberarray.h"
30typedef std::variant<
int,
36 std::vector<unsigned int>,
37 std::vector<std::string>,
61void to_json(nlohmann::json & json,
const BoundingBox & p);
62void to_json(nlohmann::json & json,
const Point & p);
70template <
typename Scalar,
int Rows,
int Cols,
int Options,
int MaxRows,
int MaxCols>
71void to_json(nlohmann::json & json,
72 const Matrix<Scalar, Rows, Cols, Options, MaxRows, MaxCols> & matrix);
83 std::visit([&j](
const auto & value) { j = value; }, data);
88struct adl_serializer<
std::unique_ptr<T>>
94 static void to_json(json & j,
const std::unique_ptr<T> & v)
96 if constexpr (std::is_constructible_v<nlohmann::json, T>)
104 mooseAssert(
false,
"Should not get to this");
111template <
template <
typename,
size_t>
class Array,
typename T,
size_t N>
113to_json(nlohmann::json & json,
const DynamicArrayWrapper<Array, T, N> & array)
115 for (
const auto element : array)
116 nlohmann::to_json(json, element);
119template <
typename T,
typename I,
typename N,
typename ArrayWrapper>
122 const SemiDynamicSparseNumberArrayGeneric<T, I, N, ArrayWrapper> & sdsna)
124 to_json(json, sdsna.nude_indices());
125 to_json(json, sdsna.nude_data());
128template <
typename T,
typename D,
bool asd>
132 nlohmann::to_json(json, dn.value());
133 to_json(json, dn.derivatives());
139template <
typename Scalar,
int Rows,
int Cols,
int Options,
int MaxRows,
int MaxCols>
141to_json(nlohmann::json & json,
const Matrix<Scalar, Rows, Cols, Options, MaxRows, MaxCols> & matrix)
143 if constexpr (Rows == 1 || Cols == 1)
145 std::vector<Scalar>
values(matrix.data(), matrix.data() + matrix.rows() * matrix.cols());
146 nlohmann::to_json(json,
values);
150 const auto nrows = matrix.rows();
151 const auto ncols = matrix.cols();
152 std::vector<std::vector<Scalar>>
values(nrows, std::vector<Scalar>(ncols));
153 for (
const auto i : make_range(nrows))
154 for (
const auto j : make_range(ncols))
155 values[i][j] = matrix(i, j);
156 nlohmann::to_json(json,
values);
165 to_json(json,
static_cast<const Eigen::Matrix<T, 2, 1> &
>(two_vector));
void to_json(nlohmann::json &json, const MooseApp &app)
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.
std::array< Real, 2 > values
void ErrorVector unsigned int
A two-component zero initialized vector used for tangential quantities.
Base class for MOOSE-based applications.
void to_json(nlohmann::json &json, const Matrix< Scalar, Rows, Cols, Options, MaxRows, MaxCols > &matrix)
The following methods are specializations for using the libMesh::Parallel::packed_range_* routines fo...
void to_json(nlohmann::json &json, const BoundingBox &p)
template class LIBMESH_EXPORT DenseMatrix< Real >
template class LIBMESH_EXPORT DenseVector< Real >
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
template class LIBMESH_EXPORT NumericVector< Number >
static void to_json(json &j, const AttributeVariant &data)
static void to_json(json &j, const std::unique_ptr< T > &v)
Serializer that will output a unique ptr if it exists.