diff --git a/test/discretization/cellcentered/tpfa/CMakeLists.txt b/test/discretization/cellcentered/tpfa/CMakeLists.txt index f1a9818e9f789f451c2c064d6fa500827aa07d6f..74de3de84290aed94dbbdcbe2de3f1965286c029 100644 --- a/test/discretization/cellcentered/tpfa/CMakeLists.txt +++ b/test/discretization/cellcentered/tpfa/CMakeLists.txt @@ -1,15 +1,17 @@ dune_add_test(NAME test_tpfafvgeometry SOURCES test_tpfafvgeometry.cc - COMMAND ./test_tpfafvgeometry) + COMPILE_DEFINITIONS ENABLE_CACHING=false) + +dune_add_test(NAME test_tpfafvgeometry_caching + SOURCES test_tpfafvgeometry.cc + COMPILE_DEFINITIONS ENABLE_CACHING=true) dune_add_test(NAME test_tpfafvgeometry_nonconforming SOURCES test_tpfafvgeometry_nonconforming.cc - COMPILE_DEFINITIONS TYPETAG=TestFVGeometryNonConforming - CMAKE_GUARD dune-alugrid_FOUND - COMMAND ./test_tpfafvgeometry_nonconforming) + COMPILE_DEFINITIONS ENABLE_CACHING=false + CMAKE_GUARD dune-alugrid_FOUND) dune_add_test(NAME test_cachedtpfafvgeometry_nonconforming SOURCES test_tpfafvgeometry_nonconforming.cc - COMPILE_DEFINITIONS TYPETAG=TestCachedFVGeometryNonConforming - CMAKE_GUARD dune-alugrid_FOUND - COMMAND ./test_cachedtpfafvgeometry_nonconforming) + COMPILE_DEFINITIONS ENABLE_CACHING=true + CMAKE_GUARD dune-alugrid_FOUND) diff --git a/test/discretization/cellcentered/tpfa/test_tpfafvgeometry.cc b/test/discretization/cellcentered/tpfa/test_tpfafvgeometry.cc index 1fce537012970eba2eb0d24b5c5f4ad0e81926ef..3f6c269c52149f759232ad118337360158545b7a 100644 --- a/test/discretization/cellcentered/tpfa/test_tpfafvgeometry.cc +++ b/test/discretization/cellcentered/tpfa/test_tpfafvgeometry.cc @@ -26,48 +26,45 @@ #include <iostream> #include <utility> +#include <dune/common/fvector.hh> #include <dune/common/test/iteratortest.hh> #include <dune/grid/utility/structuredgridfactory.hh> #include <dune/grid/yaspgrid.hh> -#include <dune/grid/common/mcmgmapper.hh> -#include <dumux/common/properties.hh> -#include <dumux/discretization/cellcentered/tpfa/properties.hh> +#include <dumux/discretization/cellcentered/tpfa/fvgridgeometry.hh> +#ifndef DOXYGEN namespace Dumux { -namespace Properties { -NEW_TYPE_TAG(TestFVGeometry, INHERITS_FROM(CCTpfaModel)); -SET_TYPE_PROP(TestFVGeometry, Grid, Dune::YaspGrid<2>); -} // end namespace Properties -} // end namespace Dumux - +namespace Detail { template<class T> class NoopFunctor { public: NoopFunctor() {} void operator()(const T& t){} }; +} // end namespace Detail +} // end namespace Dumux +#endif int main (int argc, char *argv[]) try { + using namespace Dumux; + // maybe initialize mpi Dune::MPIHelper::instance(argc, argv); std::cout << "Checking the FVGeometries, SCVs and SCV faces" << std::endl; - // aliases - using TypeTag = TTAG(TestFVGeometry); - using Grid = typename GET_PROP_TYPE(TypeTag, Grid); - using GridView = typename Grid::LeafGridView; + using Grid = Dune::YaspGrid<2>; - constexpr int dim = GridView::dimension; - constexpr int dimworld = GridView::dimensionworld; + constexpr int dim = Grid::dimension; + constexpr int dimworld = Grid::dimensionworld; - using GlobalPosition = Dune::FieldVector<typename GridView::ctype, dimworld>; - using FVElementGeometry = typename GET_PROP_TYPE(TypeTag, FVGridGeometry)::LocalView; + using GlobalPosition = Dune::FieldVector<typename Grid::ctype, dimworld>; + using FVGridGeometry = CCTpfaFVGridGeometry<typename Grid::LeafGridView, ENABLE_CACHING>; + using FVElementGeometry = typename FVGridGeometry::LocalView; using SubControlVolume = typename FVElementGeometry::SubControlVolume; using SubControlVolumeFace = typename FVElementGeometry::SubControlVolumeFace; - using FVGridGeometry = typename GET_PROP_TYPE(TypeTag, FVGridGeometry); // make a grid GlobalPosition lower(0.0); @@ -89,7 +86,7 @@ int main (int argc, char *argv[]) try fvGeometry.bind(element); auto range = scvs(fvGeometry); - NoopFunctor<SubControlVolume> op; + Detail::NoopFunctor<SubControlVolume> op; if(0 != testForwardIterator(range.begin(), range.end(), op)) DUNE_THROW(Dune::Exception, "Iterator does not fulfill the forward iterator concept"); @@ -99,7 +96,7 @@ int main (int argc, char *argv[]) try } auto range2 = scvfs(fvGeometry); - NoopFunctor<SubControlVolumeFace> op2; + Detail::NoopFunctor<SubControlVolumeFace> op2; if(0 != testForwardIterator(range2.begin(), range2.end(), op2)) DUNE_THROW(Dune::Exception, "Iterator does not fulfill the forward iterator concept"); diff --git a/test/discretization/cellcentered/tpfa/test_tpfafvgeometry_nonconforming.cc b/test/discretization/cellcentered/tpfa/test_tpfafvgeometry_nonconforming.cc index a26bb86696b947398d597df304bd9dc553d3eb2b..f20998e0c506389eab8c7dd650bcadafb293a499 100644 --- a/test/discretization/cellcentered/tpfa/test_tpfafvgeometry_nonconforming.cc +++ b/test/discretization/cellcentered/tpfa/test_tpfafvgeometry_nonconforming.cc @@ -32,26 +32,13 @@ #include <dune/grid/utility/structuredgridfactory.hh> #include <dune/alugrid/grid.hh> -#include <dune/grid/common/mcmgmapper.hh> - -#include <dumux/common/properties.hh> -#include <dumux/discretization/cellcentered/tpfa/properties.hh> - -namespace Dumux { -namespace Properties{ -//! Test without using global caching of the geometries -NEW_TYPE_TAG(TestFVGeometryNonConforming, INHERITS_FROM(CCTpfaModel)); -SET_TYPE_PROP(TestFVGeometryNonConforming, Grid, Dune::ALUGrid<2, 2, Dune::cube, Dune::nonconforming>); - -//! Test using global geometry caching -NEW_TYPE_TAG(TestCachedFVGeometryNonConforming, INHERITS_FROM(CCTpfaModel)); -SET_TYPE_PROP(TestCachedFVGeometryNonConforming, Grid, Dune::ALUGrid<2, 2, Dune::cube, Dune::nonconforming>); -SET_BOOL_PROP(TestCachedFVGeometryNonConforming, EnableFVGridGeometryCache, true); -} // end namespace Properties -} // end namespace Dumux +#include <dumux/adaptive/markelements.hh> +#include <dumux/discretization/cellcentered/tpfa/fvgridgeometry.hh> +#ifndef DOXGEN namespace Dumux { +namespace Test { //! epsilon for checking direction of scvf normals constexpr double eps = 1e-6; @@ -115,27 +102,27 @@ std::string elementTypeName(const Dune::FieldVector<double, 2>& center) DUNE_THROW(Dune::InvalidStateException, "Element center position could not be interpreted."); } +} // end namespace Test } // end namespace Dumux +#endif int main (int argc, char *argv[]) try { + using namespace Dumux; + using namespace Dumux::Test; + // maybe initialize mpi Dune::MPIHelper::instance(argc, argv); std::cout << "Checking the FVGeometries, SCVs and SCV faces on a non-conforming grid" << std::endl; - using namespace Dumux; - - //! aliases - using TypeTag = TTAG(TYPETAG); - using Grid = typename GET_PROP_TYPE(TypeTag, Grid); - using GridView = typename Grid::LeafGridView; + using Grid = Dune::ALUGrid<2, 2, Dune::cube, Dune::nonconforming>; - constexpr int dim = GridView::dimension; - constexpr int dimworld = GridView::dimensionworld; + constexpr int dim = Grid::dimension; + constexpr int dimworld = Grid::dimensionworld; using GlobalPosition = Dune::FieldVector<typename Grid::ctype, dimworld>; - using FVGridGeometry = typename GET_PROP_TYPE(TypeTag, FVGridGeometry); + using FVGridGeometry = CCTpfaFVGridGeometry<typename Grid::LeafGridView, ENABLE_CACHING>; //! make a grid GlobalPosition lower(0.0); @@ -145,9 +132,7 @@ int main (int argc, char *argv[]) try //! refine the central element once auto leafGridView = grid->leafGridView(); - for (const auto& element : elements(leafGridView)) - if (isInCentralElement(element.geometry().center())) - grid->mark(1, element); + markElements(*grid, [&](const auto& e){ return isInCentralElement(e.geometry().center()) ? 1 : 0; }); grid->preAdapt(); grid->adapt(); grid->postAdapt();