13#include <dune/common/fvector.hh>
14#include <dune/common/exceptions.hh>
16#include <dumux/io/json/json.hpp>
24template <
typename ctype,
int k>
25struct adl_serializer<
Dune::FieldVector<ctype, k>>
27 static void to_json(json& j,
const Dune::FieldVector<ctype, k>& fv)
30 for (
int i = 0; i < k; ++i) {
35 static void from_json(
const json& j, Dune::FieldVector<ctype, k>& fv)
38 DUNE_THROW(Dune::IOError,
"json: Cannot convert to FieldVector, not an array");
41 DUNE_THROW(Dune::IOError,
"json: Cannot convert to FieldVector of size " << k <<
" from array of size " << j.size());
43 for (
int i = 0; i < k; ++i)
44 fv[i] = j[i].
template get<ctype>();
nlohmann::json JsonTree
Definition: json.hh:19
Definition: common/pdesolver.hh:24
static void to_json(json &j, const Dune::FieldVector< ctype, k > &fv)
Definition: json.hh:27
static void from_json(const json &j, Dune::FieldVector< ctype, k > &fv)
Definition: json.hh:35