From e1b5ebb413a5b59f01069515d22bd7110a42ea57 Mon Sep 17 00:00:00 2001
From: Ned Coltman <edward.coltman@iws.uni-stuttgart.de>
Date: Tue, 31 Mar 2020 18:51:28 +0200
Subject: [PATCH] [Basics][propertiesheader] Adapt the 2p2c exercise to use a
 properties header

---
 exercises/exercise-basic/2p2cmain.cc          |  4 +-
 .../exercise-basic/injection2p2cproblem.hh    | 48 +-----------
 exercises/exercise-basic/properties2p2c.hh    | 78 +++++++++++++++++++
 3 files changed, 82 insertions(+), 48 deletions(-)
 create mode 100644 exercises/exercise-basic/properties2p2c.hh

diff --git a/exercises/exercise-basic/2p2cmain.cc b/exercises/exercise-basic/2p2cmain.cc
index 5ad81199..bce5f789 100644
--- a/exercises/exercise-basic/2p2cmain.cc
+++ b/exercises/exercise-basic/2p2cmain.cc
@@ -47,8 +47,8 @@
 #include <dumux/io/vtkoutputmodule.hh>
 #include <dumux/io/grid/gridmanager.hh>
 
-// The problem file, where setup-specific boundary and initial conditions are defined.
-#include "injection2p2cproblem.hh"
+// The properties file, where the compile time options are defined
+#include "properties2p2c.hh"
 
 ////////////////////////
 // the main function
diff --git a/exercises/exercise-basic/injection2p2cproblem.hh b/exercises/exercise-basic/injection2p2cproblem.hh
index 970b1aa1..911e3184 100644
--- a/exercises/exercise-basic/injection2p2cproblem.hh
+++ b/exercises/exercise-basic/injection2p2cproblem.hh
@@ -21,59 +21,15 @@
  *
  * \brief The two-phase porousmediumflow problem for exercise-basic
  */
+
 #ifndef DUMUX_EX_BASIC_PROBLEM_2P2C_HH
 #define DUMUX_EX_BASIC_PROBLEM_2P2C_HH
 
-#include <dune/grid/yaspgrid.hh>
-
-#include <dumux/discretization/cctpfa.hh>
-#include <dumux/porousmediumflow/2p2c/model.hh>
+#include <dumux/common/properties.hh>
 #include <dumux/porousmediumflow/problem.hh>
-#include <dumux/material/fluidsystems/h2on2.hh>
-
-#include "spatialparams.hh"
 
 namespace Dumux {
 
-// forward declare problem
-template <class TypeTag>
-class Injection2p2cProblem;
-
-namespace Properties {
-// Create new type tags
-namespace TTag {
-struct Injection2p2c { using InheritsFrom = std::tuple<TwoPTwoC>; };
-struct Injection2p2cCC { using InheritsFrom = std::tuple<Injection2p2c, CCTpfaModel>; };
-} // end namespace TTag
-
-// Set the grid type
-template<class TypeTag>
-struct Grid<TypeTag, TTag::Injection2p2c> { using type = Dune::YaspGrid<2>; };
-
-// Set the problem property
-template<class TypeTag>
-struct Problem<TypeTag, TTag::Injection2p2c> { using type = Injection2p2cProblem<TypeTag>; };
-
-// Set the spatial parameters
-template<class TypeTag>
-struct SpatialParams<TypeTag, TTag::Injection2p2c>
-{
-private:
-    using FVGridGeometry = GetPropType<TypeTag, Properties::GridGeometry>;
-    using Scalar = GetPropType<TypeTag, Properties::Scalar>;
-public:
-    using type = InjectionSpatialParams<FVGridGeometry, Scalar>;
-};
-
-// Set fluid configuration
-template<class TypeTag>
-struct FluidSystem<TypeTag, TTag::Injection2p2c> { using type = FluidSystems::H2ON2<GetPropType<TypeTag, Properties::Scalar>, FluidSystems::H2ON2DefaultPolicy</*fastButSimplifiedRelations=*/ true>>; };
-
-// Define whether mole (true) or mass (false) fractions are used
-template<class TypeTag>
-struct UseMoles<TypeTag, TTag::Injection2p2c> { static constexpr bool value = true; };
-} // end namespace Properties
-
 /*!
  * \ingroup TwoPTwoCModel
  * \ingroup ImplicitTestProblems
diff --git a/exercises/exercise-basic/properties2p2c.hh b/exercises/exercise-basic/properties2p2c.hh
new file mode 100644
index 00000000..0db24a19
--- /dev/null
+++ b/exercises/exercise-basic/properties2p2c.hh
@@ -0,0 +1,78 @@
+// -*- 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 2 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 <http://www.gnu.org/licenses/>.   *
+ *****************************************************************************/
+/*!
+ * \file
+ *
+ * \brief The two-phase two-component porousmediumflow properties file for exercise-basic
+ */
+
+#ifndef DUMUX_EX_BASIC_PROPERTIES_2P2C_HH
+#define DUMUX_EX_BASIC_PROPERTIES_2P2C_HH
+
+#include <dune/grid/yaspgrid.hh>
+
+#include <dumux/discretization/cctpfa.hh>
+#include <dumux/porousmediumflow/2p2c/model.hh>
+#include <dumux/material/fluidsystems/h2on2.hh>
+
+#include "injection2p2cproblem.hh"
+#include "spatialparams.hh"
+
+namespace Dumux::Properties {
+
+// Create new type tags
+namespace TTag {
+struct Injection2p2c { using InheritsFrom = std::tuple<TwoPTwoC>; };
+struct Injection2p2cCC { using InheritsFrom = std::tuple<Injection2p2c, CCTpfaModel>; };
+} // end namespace TTag
+
+// Set the grid type
+template<class TypeTag>
+struct Grid<TypeTag, TTag::Injection2p2c> { using type = Dune::YaspGrid<2>; };
+
+// Set the problem property
+template<class TypeTag>
+struct Problem<TypeTag, TTag::Injection2p2c> { using type = Injection2p2cProblem<TypeTag>; };
+
+// Set the spatial parameters
+template<class TypeTag>
+struct SpatialParams<TypeTag, TTag::Injection2p2c>
+{
+private:
+    using FVGridGeometry = GetPropType<TypeTag, Properties::GridGeometry>;
+    using Scalar = GetPropType<TypeTag, Properties::Scalar>;
+public:
+    using type = InjectionSpatialParams<FVGridGeometry, Scalar>;
+};
+
+// Set fluid configuration
+template<class TypeTag>
+struct FluidSystem<TypeTag, TTag::Injection2p2c>
+{
+    using type = FluidSystems::H2ON2< GetPropType<TypeTag, Properties::Scalar>,
+                                      FluidSystems::H2ON2DefaultPolicy</*fastButSimplifiedRelations=*/ true> >;
+};
+
+// Define whether mole (true) or mass (false) fractions are used
+template<class TypeTag>
+struct UseMoles<TypeTag, TTag::Injection2p2c> { static constexpr bool value = true; };
+
+} // end namespace Dumux::Properties
+
+#endif
-- 
GitLab