12#ifndef DUMUX_COMMON_METADATA_HH 
   13#define DUMUX_COMMON_METADATA_HH 
   18#include <unordered_map> 
   24#include <dune/common/hybridutilities.hh> 
   25#include <dune/common/indices.hh> 
   26#include <dune/common/concept.hh> 
   27#include <dune/common/classname.hh> 
   28#include <dune/grid/common/gridview.hh> 
   64        Dune::Concept::requireType<typename GV::GridVolumeVariables>(),
 
   65        Dune::Concept::requireType<typename GV::VolumeVariables>(),
 
   66        Dune::Concept::requireType<typename GV::GridFluxVariablesCache>()
 
 
   75        Dune::Concept::requireBaseOf<Dune::GridView<typename GV::Traits>, GV>()
 
 
 
   85    std::size_t last = s.find_last_of(
"::");
 
   87    if(last != std::string::npos)
 
 
   93template<
class TTagTuple, 
class Collector>
 
   96    using namespace Dune::Hybrid;
 
   97    forEach(std::make_index_sequence<std::tuple_size_v<TTagTuple>>{},  [&](
auto i)
 
   99        using type = 
typename std::tuple_element<i, TTagTuple>::type;
 
  100        collector.push_back(std::tuple<int, int, std::string>{depth, parentBranch, 
removeNamespace(Dune::className<type>())});
 
  101        if constexpr (Dumux::Properties::Detail::hasParentTypeTag<type>(
int{}))
 
 
 
  146        const auto& tree = collector.
getTree();
 
  147        for (
const auto& [key, values] : tree.items())
 
  149            auto& dataAtKey = this->
getTree()[key];
 
  150            if(dataAtKey.is_array())
 
  152                if(values.is_array())
 
  153                    dataAtKey.insert(dataAtKey.end(), values.begin(), values.end());
 
  155                    dataAtKey.push_back(values);
 
  157            else if(dataAtKey.is_null())
 
  161            else if(convertToArrays)
 
  165                dataAtKey = JsonTree::array({val});
 
  166                if(values.is_array())
 
  167                    dataAtKey.insert(dataAtKey.end(), values.begin(), values.end());
 
  169                    dataAtKey.push_back(values);
 
  172                DUNE_THROW(Dune::InvalidStateException, 
"Unclear how to append data without conversion to array!");
 
 
  183    static std::string 
className(
const T& c, 
bool hideTemplates)
 
 
  196        std::size_t first = s.find(
"<");
 
  197        std::size_t last = s.find_last_of(
">");
 
  199        if(first != std::string::npos && last != std::string::npos)
 
  200            s.replace(first, last-first+1, 
"<...>");
 
  202        s.erase(std::unique(std::begin(s), std::end(s),
 
  203                [](
unsigned char a, 
unsigned char b){
return std::isspace(a) && std::isspace(b);}), std::end(s));
 
 
 
  215    std::ifstream infile(fileName + 
".json");
 
  216    return infile.good();
 
 
  220template<
class Collector>
 
  223    std::ifstream i(fileName + 
".json");
 
 
  228template<
class Collector>
 
  231    std::ofstream o(fileName + 
".json");
 
  232    o << std::setw(4) << collector.
getTree() << std::endl;
 
 
  236template<
class Collector>
 
  239    std::cout << collector.
getTree().dump(4) << std::endl;
 
 
  242template<
class Collector, 
class TypeTag, DiffMethod diffmethod, 
bool isImplicit>
 
  245    auto& obj = collector[
"Assembler"];
 
 
  250template<
class Collector, 
class Gr
idGeometry>
 
  252-> 
typename std::enable_if_t<Dune::models<Concept::GridGeometry, GridGeometry>()>
 
  254    auto& obj = collector[
"GridGeometry"];
 
  256    obj[
"IsPeriodic"] = gg.isPeriodic();
 
  257    obj[
"DiscretizationMethod"] = GridGeometry::discMethod.name();
 
  258    obj[
"NumScvs"] = gg.numScv();
 
  259    obj[
"NumScvfs"] = gg.numScvf();
 
  260    obj[
"NumBoundaryScvfs"] = gg.numBoundaryScvf();
 
  261    obj[
"NumDofs"] = gg.numDofs();
 
 
  264template<
class Collector, 
class Gr
idVariables>
 
  266-> 
typename std::enable_if_t<Dune::models<Concept::GridVariables, GridVariables>()>
 
  268    auto& obj = collector[
"GridVariables"];
 
  270    obj[
"GridVolumeVariables"][
"Type"] = Collector::template className<typename GridVariables::GridVolumeVariables>(hideTemplates);
 
  271    obj[
"VolumeVariables"][
"Type"] = Collector::template className<typename GridVariables::VolumeVariables>(hideTemplates);
 
  272    obj[
"GridFluxVariablesCache"][
"Type"] = Collector::template className<typename GridVariables::GridFluxVariablesCache>(hideTemplates);
 
 
  275template<
class Collector, 
class Gr
idView>
 
  277-> 
typename std::enable_if_t<Dune::models<Concept::GridView, GridView>()>
 
  279    auto& obj = collector[
"GridView"];
 
  281    obj[
"dimension"] = GridView::dimension;
 
  282    obj[
"dimensionWorld"] = GridView::dimensionworld;
 
  283    obj[
"conforming"] = GridView::conforming;
 
  285    for(
int codim = 0; codim < GridView::dimension; ++codim)
 
  286       obj[
"numEntities"][
"codim " + std::to_string(codim) ] = gridView.size(codim);
 
 
  291template<
class TypeTag, 
class Collector>
 
  294    auto& obj = collector[
"TTags"];
 
  295    obj = Dumux::Json::JsonTree::array();
 
 
 
A linear system assembler (residual and Jacobian) for finite volume schemes.
Base class for grid geometries.
A linear system assembler (residual and Jacobian) for finite volume schemes (box, tpfa,...
Definition assembly/fvassembler.hh:95
bool isStationaryProblem() const
Whether we are assembling a stationary or instationary problem.
Definition assembly/fvassembler.hh:318
Defines all properties used in Dumux.
An enum class to define various differentiation methods available in order to compute the derivatives...
The grid variable class for finite volume schemes, storing variables on scv and scvf (volume and flux...
A helper function for class member function introspection.
Collection of json classes from JSON for Modern C++ library.
nlohmann::json JsonTree
Definition json.hh:15
Utilities for template meta programming.