15#include "nlohmann/json.h"
19#include "libmesh/libmesh_common.h"
21#include "metaphysicl/dualsemidynamicsparsenumberarray.h"
31typedef std::variant<
int,
37 std::vector<unsigned int>,
38 std::vector<std::string>,
41 std::vector<std::vector<std::string>>>
63void to_json(nlohmann::json & json,
const BoundingBox & p);
64void to_json(nlohmann::json & json,
const Point & p);
72template <
typename Scalar,
int Rows,
int Cols,
int Options,
int MaxRows,
int MaxCols>
73void to_json(nlohmann::json & json,
74 const Matrix<Scalar, Rows, Cols, Options, MaxRows, MaxCols> & matrix);
85 std::visit([&j](
const auto & value) { j = value; }, data);
90struct adl_serializer<
std::unique_ptr<T>>
96 static void to_json(json & j,
const std::unique_ptr<T> & v)
98 if constexpr (std::is_constructible_v<nlohmann::json, T>)
106 mooseAssert(
false,
"Should not get to this");
113template <
template <
typename,
size_t>
class Array,
typename T,
size_t N>
115to_json(nlohmann::json & json,
const DynamicArrayWrapper<Array, T, N> & array)
117 for (
const auto element : array)
118 nlohmann::to_json(json, element);
121template <
typename T,
typename I,
typename N,
typename ArrayWrapper>
124 const SemiDynamicSparseNumberArrayGeneric<T, I, N, ArrayWrapper> & sdsna)
126 to_json(json, sdsna.nude_indices());
127 to_json(json, sdsna.nude_data());
130template <
typename T,
typename D,
bool asd>
134 nlohmann::to_json(json, dn.value());
135 to_json(json, dn.derivatives());
141template <
typename Scalar,
int Rows,
int Cols,
int Options,
int MaxRows,
int MaxCols>
143to_json(nlohmann::json & json,
const Matrix<Scalar, Rows, Cols, Options, MaxRows, MaxCols> & matrix)
145 if constexpr (Rows == 1 || Cols == 1)
147 std::vector<Scalar>
values(matrix.data(), matrix.data() + matrix.rows() * matrix.cols());
148 nlohmann::to_json(json,
values);
152 const auto nrows = matrix.rows();
153 const auto ncols = matrix.cols();
154 std::vector<std::vector<Scalar>>
values(nrows, std::vector<Scalar>(ncols));
155 for (
const auto i : make_range(nrows))
156 for (
const auto j : make_range(ncols))
157 values[i][j] = matrix(i, j);
158 nlohmann::to_json(json,
values);
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 >, std::vector< std::vector< std::string > > > AttributeVariant
Type definition for a variant that can hold all the supported types for lattice and CSG engineering u...
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)
Tnew cast_ref(Told &oldvar)
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.