diff --git a/dumux/discretization/staggered/properties.hh b/dumux/discretization/staggered/properties.hh index 8dc80acd8f4f557946722bb574a2c6ecbc56f6c5..5c8d51ff77c255697e7d1e57ff7ff76043c01ff5 100644 --- a/dumux/discretization/staggered/properties.hh +++ b/dumux/discretization/staggered/properties.hh @@ -46,6 +46,8 @@ #include <dumux/discretization/staggered/globalfacevariables.hh> #include <dumux/discretization/staggered/facesolution.hh> #include <dumux/discretization/staggered/elementfacevariables.hh> +#include <dumux/discretization/staggered/freeflow/staggeredgeometryhelper.hh> +#include <dumux/discretization/staggered/freeflow/subcontrolvolumeface.hh> #include <dumux/common/intersectionmapper.hh> #include <dune/istl/multitypeblockvector.hh> @@ -68,8 +70,8 @@ NEW_PROP_TAG(StaggeredFaceSolution); NEW_PROP_TAG(ElementFaceVariables); NEW_PROP_TAG(EnableGlobalFaceVariablesCache); -//! Type tag for the box scheme. -NEW_TYPE_TAG(StaggeredModel, INHERITS_FROM(FiniteVolumeModel, NumericModel, LinearSolverTypeTag)); +//! Type tag for the staggered scheme. +NEW_TYPE_TAG(StaggeredModel, INHERITS_FROM(FiniteVolumeModel)); //! Set the corresponding discretization method property SET_PROP(StaggeredModel, DiscretizationMethod) @@ -100,10 +102,40 @@ public: using type = CCSubControlVolume<ScvGeometryTraits>; }; -SET_TYPE_PROP(StaggeredModel, GlobalFaceVars, Dumux::StaggeredGlobalFaceVariables<TypeTag, GET_PROP_VALUE(TypeTag, EnableGlobalFaceVariablesCache)>); +//! The default sub-controlvolume face +SET_PROP(StaggeredModel, SubControlVolumeFace) +{ +private: + using Grid = typename GET_PROP_TYPE(TypeTag, Grid); + static constexpr int dim = Grid::dimension; + static constexpr int dimWorld = Grid::dimensionworld; + + struct ScvfGeometryTraits + { + using GridIndexType = typename Grid::LeafGridView::IndexSet::IndexType; + using LocalIndexType = unsigned int; + using Scalar = typename Grid::ctype; + using Geometry = typename Grid::template Codim<1>::Geometry; + using GlobalPosition = Dune::FieldVector<Scalar, dim>; + }; + +public: + using type = StaggeredSubControlVolumeFace<ScvfGeometryTraits>; +}; + +//! The default geometry helper required for the stencils, etc. +SET_PROP(StaggeredModel, StaggeredGeometryHelper) +{ +private: + using GridView = typename GET_PROP_TYPE(TypeTag, GridView); +public: + using type = StaggeredGeometryHelper<GridView>; +}; + +SET_TYPE_PROP(StaggeredModel, GlobalFaceVars, StaggeredGlobalFaceVariables<TypeTag, GET_PROP_VALUE(TypeTag, EnableGlobalFaceVariablesCache)>); //! Set the default for the ElementBoundaryTypes -SET_TYPE_PROP(StaggeredModel, ElementBoundaryTypes, Dumux::CCElementBoundaryTypes<TypeTag>); +SET_TYPE_PROP(StaggeredModel, ElementBoundaryTypes, CCElementBoundaryTypes<TypeTag>); //! The global volume variables vector class SET_TYPE_PROP(StaggeredModel, GlobalVolumeVariables, StaggeredGlobalVolumeVariables<TypeTag, GET_PROP_VALUE(TypeTag, EnableGlobalVolumeVariablesCache)>); @@ -120,7 +152,7 @@ SET_TYPE_PROP(StaggeredModel, ElementFluxVariablesCache, StaggeredElementFluxVar //! Set the BaseLocalResidual to StaggeredLocalResidual SET_TYPE_PROP(StaggeredModel, BaseLocalResidual, StaggeredLocalResidual<TypeTag>); -SET_TYPE_PROP(StaggeredModel, IntersectionMapper, Dumux::ConformingGridIntersectionMapper<TypeTag>); +SET_TYPE_PROP(StaggeredModel, IntersectionMapper, ConformingGridIntersectionMapper<TypeTag>); SET_TYPE_PROP(StaggeredModel, StaggeredFaceSolution, StaggeredFaceSolution<TypeTag>); diff --git a/dumux/freeflow/properties.hh b/dumux/freeflow/properties.hh index e3aa08cfb09c2f8b7badb44691f32d75af1aae59..7c35e1c110084e5c2030c1866c20380c56f352a3 100644 --- a/dumux/freeflow/properties.hh +++ b/dumux/freeflow/properties.hh @@ -26,8 +26,6 @@ #ifndef DUMUX_FREE_FLOW_PROPERTIES_HH #define DUMUX_FREE_FLOW_PROPERTIES_HH -#include <dumux/discretization/staggered/freeflow/staggeredgeometryhelper.hh> -#include <dumux/discretization/staggered/freeflow/subcontrolvolumeface.hh> #include <dumux/discretization/staggered/freeflow/facevariables.hh> #include <dumux/implicit/staggered/primaryvariables.hh> @@ -54,36 +52,6 @@ SET_INT_PROP(FreeFlow, NumEqFace, 1); //!< set the number of equations to 1 SET_INT_PROP(FreeFlow, NumEqCellCenter, 1); //!< set the number of equations to 1 -//! The sub-controlvolume face -SET_PROP(FreeFlow, SubControlVolumeFace) -{ -private: - using Grid = typename GET_PROP_TYPE(TypeTag, Grid); - static constexpr int dim = Grid::dimension; - static constexpr int dimWorld = Grid::dimensionworld; - - struct ScvfGeometryTraits - { - using GridIndexType = typename Grid::LeafGridView::IndexSet::IndexType; - using LocalIndexType = unsigned int; - using Scalar = typename Grid::ctype; - using Geometry = typename Grid::template Codim<1>::Geometry; - using GlobalPosition = Dune::FieldVector<Scalar, dim>; - }; - -public: - using type = Dumux::StaggeredSubControlVolumeFace<ScvfGeometryTraits>; -}; - -//! The geometry helper required for the stencils, etc. -SET_PROP(FreeFlow, StaggeredGeometryHelper) -{ -private: - using GridView = typename GET_PROP_TYPE(TypeTag, GridView); -public: - using type = StaggeredGeometryHelper<GridView>; -}; - //! The variables living on the faces SET_TYPE_PROP(FreeFlow, FaceVariables, StaggeredFaceVariables<TypeTag>); diff --git a/dumux/freeflow/staggered/properties.hh b/dumux/freeflow/staggered/properties.hh index e7da1fb65f7423fb72dc8c3c36ea9329ea3899ab..992345c10d629473301518ee26be3bb7940fd35d 100644 --- a/dumux/freeflow/staggered/properties.hh +++ b/dumux/freeflow/staggered/properties.hh @@ -28,6 +28,7 @@ #define DUMUX_NAVIERSTOKES_PROPERTIES_HH #include <dumux/common/basicproperties.hh> +#include <dumux/linear/linearsolverproperties.hh> #include <dumux/freeflow/properties.hh> #include <dumux/implicit/staggered/localresidual.hh> @@ -61,7 +62,7 @@ namespace Properties { ////////////////////////////////////////////////////////////////// //! The type tags for the implicit single-phase problems -NEW_TYPE_TAG(NavierStokes, INHERITS_FROM(FreeFlow)); +NEW_TYPE_TAG(NavierStokes, INHERITS_FROM(LinearSolverTypeTag, NumericModel, FreeFlow)); //! The type tags for the corresponding non-isothermal problems NEW_TYPE_TAG(NavierStokesNI, INHERITS_FROM(NavierStokes, NavierStokesNonIsothermal)); diff --git a/dumux/freeflow/staggerednc/properties.hh b/dumux/freeflow/staggerednc/properties.hh index e3cf94efcb7243d0bbfa3fba594f84f97a9f1f2c..ef483a6cb65a7f4217c93843ae377005b5781669 100644 --- a/dumux/freeflow/staggerednc/properties.hh +++ b/dumux/freeflow/staggerednc/properties.hh @@ -27,6 +27,9 @@ #ifndef DUMUX_NAVIERSTOKES_NC_PROPERTIES_HH #define DUMUX_NAVIERSTOKES_NC_PROPERTIES_HH +#include <dumux/common/basicproperties.hh> +#include <dumux/linear/linearsolverproperties.hh> + #include <dumux/freeflow/staggered/properties.hh> #include <dumux/freeflow/staggeredni/properties.hh> #include <dumux/discretization/fickslaw.hh> @@ -56,7 +59,7 @@ namespace Properties { ////////////////////////////////////////////////////////////////// //! The type tags for the implicit single-phase problems -NEW_TYPE_TAG(NavierStokesNC, INHERITS_FROM(NavierStokes)); +NEW_TYPE_TAG(NavierStokesNC, INHERITS_FROM(NavierStokes, NumericModel, LinearSolverTypeTag)); NEW_TYPE_TAG(NavierStokesNCNI, INHERITS_FROM(NavierStokesNC, NavierStokesNonIsothermal)); /////////////////////////////////////////////////////////////////////////// diff --git a/test/discretization/staggered/CMakeLists.txt b/test/discretization/staggered/CMakeLists.txt index 806563abb451177a038eef7652500e35ee63e458..6f026f178477d077ab4794ad95fd444ba29a28d5 100644 --- a/test/discretization/staggered/CMakeLists.txt +++ b/test/discretization/staggered/CMakeLists.txt @@ -1,2 +1,12 @@ -add_dumux_test(test_staggered test_staggered test_staggered.cc - ${CMAKE_CURRENT_BINARY_DIR}/test_staggered) +dune_add_test(NAME test_staggeredfvgeometry + SOURCES test_staggeredfvgeometry.cc + COMPILE_DEFINITIONS ENABLE_CACHING=false) + +dune_add_test(NAME test_staggeredfvgeometry_caching + SOURCES test_staggeredfvgeometry.cc + COMPILE_DEFINITIONS ENABLE_CACHING=true) + +#install sources +install(FILES +test_staggeredfvgeometry.cc +DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/dumux/test/discretization/staggered) diff --git a/test/discretization/staggered/test_staggered.cc b/test/discretization/staggered/test_staggeredfvgeometry.cc similarity index 78% rename from test/discretization/staggered/test_staggered.cc rename to test/discretization/staggered/test_staggeredfvgeometry.cc index 6c3e3e28533e99f22e43f49d9909d6a222dcd485..48504ff483eca461496598f1117f02c59d5db671 100644 --- a/test/discretization/staggered/test_staggered.cc +++ b/test/discretization/staggered/test_staggeredfvgeometry.cc @@ -32,40 +32,21 @@ #include <dune/grid/yaspgrid.hh> #include <dune/grid/common/mcmgmapper.hh> -#include <dumux/implicit/staggered/properties.hh> +#include <dumux/common/basicproperties.hh> +#include <dumux/discretization/staggered/properties.hh> #include <dumux/discretization/staggered/fvgridgeometry.hh> #include <dumux/discretization/staggered/fvelementgeometry.hh> -// #include <dumux/discretization/staggered/subcontrolvolume.hh> -#include <dumux/discretization/staggered/freeflow/subcontrolvolumeface.hh> - -#include <dumux/freeflow/staggered/propertydefaults.hh> namespace Dumux { -template<class TypeTag> -class MockProblem -{ - using ElementMapper = typename GET_PROP_TYPE(TypeTag, DofMapper); - using GridView = typename GET_PROP_TYPE(TypeTag, GridView); -public: - MockProblem(const GridView& gridView) : mapper_(gridView) {} - - const ElementMapper& elementMapper() const - { return mapper_; } -private: - ElementMapper mapper_; -}; - namespace Properties { -NEW_TYPE_TAG(TestFVGeometry, INHERITS_FROM(StaggeredModel, NavierStokes)); +NEW_TYPE_TAG(TestFVGeometry, INHERITS_FROM(StaggeredModel, NumericModel)); SET_TYPE_PROP(TestFVGeometry, Grid, Dune::YaspGrid<2>); -SET_TYPE_PROP(TestFVGeometry, Problem, Dumux::MockProblem<TypeTag>); - -SET_BOOL_PROP(TestFVGeometry, EnableFVGridGeometryCache, true); +SET_BOOL_PROP(TestFVGeometry, EnableFVGridGeometryCache, ENABLE_CACHING); } } @@ -92,12 +73,10 @@ int main (int argc, char *argv[]) try constexpr int dim = GridView::dimension; constexpr int dimworld = GridView::dimensionworld; - using Scalar = typename GET_PROP_TYPE(TypeTag, Scalar); - using GlobalPosition = Dune::FieldVector<Scalar, dimworld>; + using GlobalPosition = typename Dune::FieldVector<Grid::ctype, dimworld>; using SubControlVolume = typename GET_PROP_TYPE(TypeTag, SubControlVolume); using SubControlVolumeFace = typename GET_PROP_TYPE(TypeTag, SubControlVolumeFace); using FVGridGeometry = typename GET_PROP_TYPE(TypeTag, FVGridGeometry); - using Problem = typename GET_PROP_TYPE(TypeTag, Problem); // make a grid GlobalPosition lower(0.0); @@ -106,28 +85,26 @@ int main (int argc, char *argv[]) try std::shared_ptr<Grid> grid = Dune::StructuredGridFactory<Grid>::createCubeGrid(lower, upper, els); auto leafGridView = grid->leafGridView(); - Problem problem(leafGridView); - - FVGridGeometry global(leafGridView); - global.update(problem); + FVGridGeometry fvGridGeometry(leafGridView); + fvGridGeometry.update(); std::cout << "Abbreviatons:\n" - << "ip - global postition of face center\n" - << "face - global face index\n" - << "self/oppo - global dofIdx on intersection (self/opposite)\n" - << "norm in/out - global dofIdx on side normal to intersection (within own element / in adjacent element)" << std::endl; + << "ip - postition of face center\n" + << "face - face index\n" + << "self/oppo - dofIdx on intersection (self/opposite)\n" + << "norm in/out - dofIdx on side normal to intersection (within own element / in adjacent element)" << std::endl; // iterate over elements. For every element get fv geometry and loop over scvs and scvfaces for (const auto& element : elements(leafGridView)) { - auto eIdx = problem.elementMapper().index(element); + auto eIdx = fvGridGeometry.elementMapper().index(element); std::cout << std::endl << "Checking fvGeometry of element " << eIdx << std::endl; - auto fvGeometry = localView(global); + auto fvGeometry = localView(fvGridGeometry); fvGeometry.bind(element); auto range = scvs(fvGeometry); NoopFunctor<SubControlVolume> op; - if(0 != testForwardIterator(range.begin(), range.end(), op)) + if(0 != testForwardIterator(range.begin(), range.end(), [](const SubControlVolumeFace& scvf){})) DUNE_THROW(Dune::Exception, "Iterator does not fulfill the forward iterator concept"); for (auto&& scv : scvs(fvGeometry)) @@ -137,7 +114,7 @@ int main (int argc, char *argv[]) try auto range2 = scvfs(fvGeometry); NoopFunctor<SubControlVolumeFace> op2; - if(0 != testForwardIterator(range2.begin(), range2.end(), op2)) + if(0 != testForwardIterator(range2.begin(), range2.end(), [](const SubControlVolumeFace& scvf){})) DUNE_THROW(Dune::Exception, "Iterator does not fulfill the forward iterator concept");