// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- // vi: set et ts=4 sw=4 sts=4: /***************************************************************************** * See the file COPYING for full copying permissions. * * * * This program is free software: you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation, either version 3 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program. If not, see . * *****************************************************************************/ /*! * \file * \ingroup Common * \brief The infrastructure to retrieve metadata information. */ #ifndef DUMUX_METADATA_HH #define DUMUX_METADATA_HH #include #include #include #include #include #include #include #include #include "dumux/assembly/fvassembler.hh" #include "dumux/assembly/diffmethod.hh" #include "dumux/discretization/basegridgeometry.hh" #include "dumux/discretization/fvgridvariables.hh" namespace Dumux { namespace Detail { //! Helper to determine whether a given type inherits from BaseGridGeometry struct isGridGeometry { template void isConstructable(const BaseGridGeometry&) {} template auto operator()(GridGeometry&& gg) -> decltype(isConstructable(gg)) {} }; //! Helper to determine whether a given type inherits from FVGridVariables struct isGridVariables { template void isConstructable(const FVGridVariables&) {} template auto operator()(GridVariables&& gv) -> decltype(isConstructable(gv)) {} }; } // end namespace Detail /*! * \ingroup Common * \brief Class to collect metadata * \todo Doc me! */ class Metadata { using JsonTree = nlohmann::json; public: template static void collectMetaData(const FVAssembler& a) { auto& obj = getTree()["Assembler"]; obj["Type"] = Dune::className(a); obj["Stationary"] = a.isStationaryProblem() ? "true" : "false"; } template static auto collectMetaData(const GridGeometry& gg) -> typename std::enable_if_t { auto& obj = getTree()["GridGeometry"]; obj["Type"] = Dune::className(gg); obj["GridView"] = Dune::className(gg.gridView()); obj["IsPeriodic"] = gg.isPeriodic() ? "true" : "false"; } template static auto collectMetaData(const GridVariables& gv) -> typename std::enable_if_t { auto& obj = getTree()["GridVariables"]; obj["Type"] = Dune::className(gv); } //! prints json tree static void print() { std::cout << getTree().dump(4) << std::endl; } /*! * \brief Get the json tree */ static JsonTree& getTree() { static JsonTree parser_; return parser_; } }; } // end namespace Dumux #endif