Skip to content
Snippets Groups Projects
Commit 5d10bce5 authored by Timo Koch's avatar Timo Koch
Browse files

[tpfa][test] Make fv grid geometry test independent of TypeTag

parent 67c5968a
No related branches found
No related tags found
1 merge request!742Make FVGridGeometry independent of TypeTag
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)
......@@ -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");
......
......@@ -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();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment