From 81b2ef215a982b02c695a58fc5efd240495777dc Mon Sep 17 00:00:00 2001 From: Simon Praetorius Date: Fri, 25 Sep 2020 00:46:39 +0200 Subject: [PATCH 1/8] Add utility to convert a preBasis to a flag preBasis --- amdis/DOFVector.hpp | 4 +- amdis/functions/CMakeLists.txt | 1 + amdis/functions/FlatPreBasis.hpp | 127 ++++++++++++++++++++++++ amdis/functions/ParallelGlobalBasis.hpp | 11 +- examples/ellipt.cc | 5 +- examples/vecellipt.cc | 8 +- 6 files changed, 144 insertions(+), 12 deletions(-) create mode 100644 amdis/functions/FlatPreBasis.hpp diff --git a/amdis/DOFVector.hpp b/amdis/DOFVector.hpp index 55524515..f6a1a162 100644 --- a/amdis/DOFVector.hpp +++ b/amdis/DOFVector.hpp @@ -222,7 +222,7 @@ namespace AMDiS // deduction guides template DOFVector(GB&& basis, DataTransferOperation op = DataTransferOperation::INTERPOLATE) - -> DOFVector::PreBasis>>; + -> DOFVector>; template DOFVector(GV const& gridView, PBF const& pbf, DataTransferOperation op = DataTransferOperation::INTERPOLATE) @@ -240,7 +240,7 @@ namespace AMDiS * \ref DataTransferOperation for more options. **/ template - DOFVector::PreBasis>, ValueType> + DOFVector, ValueType> makeDOFVector(GB&& basis, DataTransferOperation op = DataTransferOperation::INTERPOLATE) { return {FWD(basis), op}; diff --git a/amdis/functions/CMakeLists.txt b/amdis/functions/CMakeLists.txt index 0491d5b0..a8814ffc 100644 --- a/amdis/functions/CMakeLists.txt +++ b/amdis/functions/CMakeLists.txt @@ -1,4 +1,5 @@ install(FILES + FlatPreBasis.hpp FunctionFromCallable.hpp GlobalIdSet.hpp HierarchicNodeToRangeMap.hpp diff --git a/amdis/functions/FlatPreBasis.hpp b/amdis/functions/FlatPreBasis.hpp new file mode 100644 index 00000000..e7f9e5c2 --- /dev/null +++ b/amdis/functions/FlatPreBasis.hpp @@ -0,0 +1,127 @@ +#pragma once + +#include +#include +#include +#include +#include + +#include +#include +#include + +namespace AMDiS +{ + // Convert the index-merging strategy to FlatLexicographic or FlatInterleaved for + // composite or power bases, respectively. + template > + struct FlatPreBasis + { + using type = PreBasis; + + template + static type create(PB const& preBasis) + { + warning("Currently only flat index-merging strategies supported."); + return {preBasis.gridView()}; + } + + static PreBasis const& create(PreBasis const& preBasis) + { + return preBasis; + } + }; + + template > + using FlatPreBasis_t = typename FlatPreBasis::type; + + template + auto flatPreBasis(PreBasis const& preBasis) + { + return FlatPreBasis::create(preBasis); + } + + // specialization for Lagrange basis that needs an additional `order` parameter. + template + struct FlatPreBasis, MultiIndex> + { + using type = Dune::Functions::LagrangePreBasis; + + template + static type create(PB const& preBasis) + { + warning("Currently only flat index-merging strategies supported."); + auto node = preBasis.makeNode(); + node.bind(*preBasis.gridView().template begin<0>()); + return {preBasis.gridView(), (unsigned int)(polynomialDegree(node))}; + } + + static type const& create(type const& preBasis) + { + return preBasis; + } + }; + + // specialization for composite bases + template + struct FlatPreBasis, MultiIndex> + { + using FIMS = Dune::Functions::BasisFactory::FlatLexicographic; + using type = Dune::Functions::CompositePreBasis; + + template + static type create(PreBasis const& preBasis) + { + return create(preBasis, std::index_sequence_for{}); + } + + template + static type create(PreBasis const& preBasis, std::index_sequence) + { + return {FlatPreBasis::create(preBasis.subPreBasis(Dune::index_constant{}))...}; + } + }; + + // specialization for power bases + template + struct FlatPreBasis, MultiIndex> + { + using type = Dune::Functions::PowerPreBasis; + + template + static type create(PreBasis const& preBasis) + { + return {FlatPreBasis::create(preBasis.subPreBasis())}; + } + }; + + // specialization for power bases + template + struct FlatPreBasis, MultiIndex> + { + using FIMS = Dune::Functions::BasisFactory::FlatInterleaved; + using type = Dune::Functions::PowerPreBasis; + + template + static type create(PreBasis const& preBasis) + { + return {FlatPreBasis::create(preBasis.subPreBasis())}; + } + }; + + template + struct FlatPreBasis, MultiIndex> + { + using FIMS = Dune::Functions::BasisFactory::FlatLexicographic; + using type = Dune::Functions::PowerPreBasis; + + template + static type create(PreBasis const& preBasis) + { + return {FlatPreBasis::create(preBasis.subPreBasis())}; + } + }; + +} // end namespace AMDiS diff --git a/amdis/functions/ParallelGlobalBasis.hpp b/amdis/functions/ParallelGlobalBasis.hpp index bcd63d2b..9937eb71 100644 --- a/amdis/functions/ParallelGlobalBasis.hpp +++ b/amdis/functions/ParallelGlobalBasis.hpp @@ -28,6 +28,7 @@ #include #include #include +#include #include #include @@ -103,7 +104,7 @@ namespace AMDiS template ParallelGlobalBasis(std::string const& name, GridView const& gridView, PBF const& preBasisFactory) : ParallelGlobalBasis(name, gridView.grid(), - preBasisFactory.template makePreBasis>(gridView)) + flatPreBasis(preBasisFactory.template makePreBasis>(gridView))) {} /// Construct this global basis with empty name @@ -180,12 +181,12 @@ namespace AMDiS // Deduction guides template ParallelGlobalBasis(std::string const& name, GV const& gridView, PBF&& preBasisFactory) - -> ParallelGlobalBasis>(gridView))>; + -> ParallelGlobalBasis>(gridView)))>; template ParallelGlobalBasis(GV const& gridView, PBF&& preBasisFactory) - -> ParallelGlobalBasis>(gridView))>; + -> ParallelGlobalBasis>(gridView)))>; } // end namespace AMDiS diff --git a/examples/ellipt.cc b/examples/ellipt.cc index 419242e9..3345dc7a 100644 --- a/examples/ellipt.cc +++ b/examples/ellipt.cc @@ -28,8 +28,9 @@ int main(int argc, char** argv) return {-20.0 * std::exp(-10.0 * dot(x,x)) * x}; }; - using Param = LagrangeBasis; - ProblemStat prob("ellipt"); + auto grid = MeshCreator{"elliptMesh"}.create(); + + ProblemStat prob("ellipt", *grid, Dune::Functions::BasisFactory::lagrange<2>()); prob.initialize(INIT_ALL); auto opL = makeOperator(tag::gradtest_gradtrial{}, 1.0); diff --git a/examples/vecellipt.cc b/examples/vecellipt.cc index 6f6b2048..634cdbc6 100644 --- a/examples/vecellipt.cc +++ b/examples/vecellipt.cc @@ -8,14 +8,16 @@ using namespace AMDiS; -using ElliptParam = YaspGridBasis; -using ElliptProblem = ProblemStat; +using Grid = Dune::YaspGrid; int main(int argc, char** argv) { Environment env(argc, argv); - ElliptProblem prob("ellipt"); + using namespace Dune::Functions::BasisFactory; + + auto grid = MeshCreator{"elliptMesh"}.create(); + ProblemStat prob("ellipt", *grid, power<2>(lagrange<2>())); prob.initialize(INIT_ALL); AdaptInfo adaptInfo("adapt"); -- GitLab From ee24f4952adfefeb0c9fe032a83f863850475754 Mon Sep 17 00:00:00 2001 From: Simon Praetorius Date: Fri, 9 Oct 2020 16:48:16 +0200 Subject: [PATCH 2/8] added dirty hack to access protected members in pre dune-functions-2.7 preBases --- amdis/functions/FlatPreBasis.hpp | 54 ++++++++++++++++++++++++++++---- 1 file changed, 48 insertions(+), 6 deletions(-) diff --git a/amdis/functions/FlatPreBasis.hpp b/amdis/functions/FlatPreBasis.hpp index e7f9e5c2..d6d528b8 100644 --- a/amdis/functions/FlatPreBasis.hpp +++ b/amdis/functions/FlatPreBasis.hpp @@ -1,5 +1,6 @@ #pragma once +#include #include #include #include @@ -44,10 +45,17 @@ namespace AMDiS } // specialization for Lagrange basis that needs an additional `order` parameter. +#if DUNE_VERSION_LT(DUNE_FUNCTIONS,2,7) + template + struct FlatPreBasis, MultiIndex> + { + using type = Dune::Functions::LagrangePreBasis; +#else template struct FlatPreBasis, MultiIndex> { using type = Dune::Functions::LagrangePreBasis; +#endif template static type create(PB const& preBasis) @@ -64,6 +72,38 @@ namespace AMDiS } }; + namespace Impl + { +#if DUNE_VERSION_LT(DUNE_FUNCTION,2,7) + // NOTE: dirty hack to get access to protected member variable, due to missing + // function in dune-functions-2.6 + template + class DerivedPreBasis : public PreBasis { + public: + DerivedPreBasis(PreBasis const& pb) : PreBasis(pb) {} + // specialization for PowerPreBasis + template + SPB const& subPreBasis() const { return this->subPreBasis_; } + // specialization for CompositePreBasis + template > + SPB const& subPreBasis(Dune::index_constant) const { return std::get(this->subPreBases_); } + }; + template + static auto const& subPreBasis(PreBasis const& preBasis, Index... ii) + { + DerivedPreBasis d(preBasis); + return d.subPreBasis(ii...); + } +#else + template + static auto const& subPreBasis(PreBasis const& preBasis, Index... ii) + { + return preBasis.subPreBasis(ii...); + } +#endif + } // end namespace Impl + + // specialization for composite bases template struct FlatPreBasis, MultiIndex> @@ -80,7 +120,7 @@ namespace AMDiS template static type create(PreBasis const& preBasis, std::index_sequence) { - return {FlatPreBasis::create(preBasis.subPreBasis(Dune::index_constant{}))...}; + return {FlatPreBasis::create(Impl::subPreBasis(preBasis,Dune::index_constant{}))...}; } }; @@ -93,13 +133,14 @@ namespace AMDiS template static type create(PreBasis const& preBasis) { - return {FlatPreBasis::create(preBasis.subPreBasis())}; + return {FlatPreBasis::create(Impl::subPreBasis(preBasis))}; } }; // specialization for power bases template - struct FlatPreBasis, MultiIndex> + struct FlatPreBasis, MultiIndex> { using FIMS = Dune::Functions::BasisFactory::FlatInterleaved; using type = Dune::Functions::PowerPreBasis; @@ -107,12 +148,13 @@ namespace AMDiS template static type create(PreBasis const& preBasis) { - return {FlatPreBasis::create(preBasis.subPreBasis())}; + return {FlatPreBasis::create(Impl::subPreBasis(preBasis))}; } }; template - struct FlatPreBasis, MultiIndex> + struct FlatPreBasis, MultiIndex> { using FIMS = Dune::Functions::BasisFactory::FlatLexicographic; using type = Dune::Functions::PowerPreBasis; @@ -120,7 +162,7 @@ namespace AMDiS template static type create(PreBasis const& preBasis) { - return {FlatPreBasis::create(preBasis.subPreBasis())}; + return {FlatPreBasis::create(Impl::subPreBasis(preBasis))}; } }; -- GitLab From d7b353adb1e20786148e8a79dd6e61bf65bf8e30 Mon Sep 17 00:00:00 2001 From: Simon Praetorius Date: Fri, 9 Oct 2020 22:06:38 +0200 Subject: [PATCH 3/8] correct version check for flat preBasis --- amdis/functions/FlatPreBasis.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/amdis/functions/FlatPreBasis.hpp b/amdis/functions/FlatPreBasis.hpp index d6d528b8..71ed8d27 100644 --- a/amdis/functions/FlatPreBasis.hpp +++ b/amdis/functions/FlatPreBasis.hpp @@ -74,7 +74,7 @@ namespace AMDiS namespace Impl { -#if DUNE_VERSION_LT(DUNE_FUNCTION,2,7) +#if DUNE_VERSION_LT(DUNE_FUNCTIONS,2,7) // NOTE: dirty hack to get access to protected member variable, due to missing // function in dune-functions-2.6 template -- GitLab From cc6e94bba363398843494c1fa8e9551ed691b390 Mon Sep 17 00:00:00 2001 From: Simon Praetorius Date: Fri, 9 Oct 2020 22:12:04 +0200 Subject: [PATCH 4/8] add warnings for blocked preBases --- amdis/functions/FlatPreBasis.hpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/amdis/functions/FlatPreBasis.hpp b/amdis/functions/FlatPreBasis.hpp index 71ed8d27..88d58ab2 100644 --- a/amdis/functions/FlatPreBasis.hpp +++ b/amdis/functions/FlatPreBasis.hpp @@ -24,7 +24,6 @@ namespace AMDiS template static type create(PB const& preBasis) { - warning("Currently only flat index-merging strategies supported."); return {preBasis.gridView()}; } @@ -120,6 +119,7 @@ namespace AMDiS template static type create(PreBasis const& preBasis, std::index_sequence) { + warning("Currently only flat index-merging strategies supported."); return {FlatPreBasis::create(Impl::subPreBasis(preBasis,Dune::index_constant{}))...}; } }; @@ -133,6 +133,7 @@ namespace AMDiS template static type create(PreBasis const& preBasis) { + warning("Currently only flat index-merging strategies supported."); return {FlatPreBasis::create(Impl::subPreBasis(preBasis))}; } }; @@ -162,6 +163,7 @@ namespace AMDiS template static type create(PreBasis const& preBasis) { + warning("Currently only flat index-merging strategies supported."); return {FlatPreBasis::create(Impl::subPreBasis(preBasis))}; } }; -- GitLab From f57396d79d3b9a7447ba5b3a0081713463965ba1 Mon Sep 17 00:00:00 2001 From: Simon Praetorius Date: Sat, 10 Oct 2020 01:18:17 +0200 Subject: [PATCH 5/8] use accessor for protected member access --- amdis/functions/FlatPreBasis.hpp | 34 +++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/amdis/functions/FlatPreBasis.hpp b/amdis/functions/FlatPreBasis.hpp index 88d58ab2..ff280fe4 100644 --- a/amdis/functions/FlatPreBasis.hpp +++ b/amdis/functions/FlatPreBasis.hpp @@ -77,21 +77,33 @@ namespace AMDiS // NOTE: dirty hack to get access to protected member variable, due to missing // function in dune-functions-2.6 template - class DerivedPreBasis : public PreBasis { + class DerivedPreBasis { public: - DerivedPreBasis(PreBasis const& pb) : PreBasis(pb) {} // specialization for PowerPreBasis - template - SPB const& subPreBasis() const { return this->subPreBasis_; } + template + static SPB const& subPreBasis(PB const& pb) + { + return access(pb).subPreBasis_; + } + // specialization for CompositePreBasis - template > - SPB const& subPreBasis(Dune::index_constant) const { return std::get(this->subPreBases_); } + template > + static SPB const& subPreBasis(PB const& pb, Dune::index_constant) + { + return std::get(access(pb).subPreBases_); + } + + template + class Accessor : public T { friend class DerivedPreBasis; }; + + template + static Accessor const& access(T const& obj) { return static_cast const&>(obj); } }; + template static auto const& subPreBasis(PreBasis const& preBasis, Index... ii) { - DerivedPreBasis d(preBasis); - return d.subPreBasis(ii...); + return DerivedPreBasis::subPreBasis(preBasis,ii...); } #else template @@ -108,7 +120,7 @@ namespace AMDiS struct FlatPreBasis, MultiIndex> { using FIMS = Dune::Functions::BasisFactory::FlatLexicographic; - using type = Dune::Functions::CompositePreBasis; + using type = Dune::Functions::CompositePreBasis...>; template static type create(PreBasis const& preBasis) @@ -144,7 +156,7 @@ namespace AMDiS , MultiIndex> { using FIMS = Dune::Functions::BasisFactory::FlatInterleaved; - using type = Dune::Functions::PowerPreBasis; + using type = Dune::Functions::PowerPreBasis, C>; template static type create(PreBasis const& preBasis) @@ -158,7 +170,7 @@ namespace AMDiS , MultiIndex> { using FIMS = Dune::Functions::BasisFactory::FlatLexicographic; - using type = Dune::Functions::PowerPreBasis; + using type = Dune::Functions::PowerPreBasis, C>; template static type create(PreBasis const& preBasis) -- GitLab From e9e28fec0f33ca6a4410b2bf34ab2620cc49cc6f Mon Sep 17 00:00:00 2001 From: Simon Praetorius Date: Sat, 10 Oct 2020 12:37:27 +0200 Subject: [PATCH 6/8] Add test for flat preBases --- CMakeLists.txt | 5 ++-- amdis/AdaptiveGrid.hpp | 5 ++++ test/CMakeLists.txt | 3 +++ test/FlatPreBasisTest.cpp | 52 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 62 insertions(+), 3 deletions(-) create mode 100644 test/FlatPreBasisTest.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 1608e8f2..3c315eb0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,8 +23,6 @@ add_subdirectory("libs") add_subdirectory("test") dune_target_link_libraries(amdis fmt) -target_compile_options(amdis PUBLIC "-Wall" "-Wpedantic") - if (MTL_FOUND) dune_target_link_libraries(amdis MTL::MTL) @@ -48,7 +46,8 @@ endif (PETSc_FOUND) option(ENABLE_ALL_WARNINGS "enable all meaningful warnings" OFF) if (ENABLE_ALL_WARNINGS) - target_compile_options(amdis PUBLIC "-Wextra" "-Wnon-virtual-dtor" + target_compile_options(amdis PUBLIC "-Wall" "-Wpedantic" + "-Wextra" "-Wnon-virtual-dtor" "-Wold-style-cast" "-Wcast-align" "-Woverloaded-virtual" "-Wconversion") endif (ENABLE_ALL_WARNINGS) diff --git a/amdis/AdaptiveGrid.hpp b/amdis/AdaptiveGrid.hpp index 0402adea..41e07080 100644 --- a/amdis/AdaptiveGrid.hpp +++ b/amdis/AdaptiveGrid.hpp @@ -312,6 +312,11 @@ namespace AMDiS unsigned long changeIndex_ = 0; }; + // deduction guide + template + AdaptiveGrid(HostGrid const&) + -> AdaptiveGrid; + template class AdaptiveGridFamily diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index ded27d37..2274a638 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -60,6 +60,9 @@ dune_add_test(SOURCES FilesystemTest.cpp dune_add_test(SOURCES FlatMatVecTest.cpp LINK_LIBRARIES amdis) +dune_add_test(SOURCES FlatPreBasisTest.cpp + LINK_LIBRARIES amdis) + dune_add_test(SOURCES GlobalIdSetTest.cpp LINK_LIBRARIES amdis MPI_RANKS 2 diff --git a/test/FlatPreBasisTest.cpp b/test/FlatPreBasisTest.cpp new file mode 100644 index 00000000..dd289bfd --- /dev/null +++ b/test/FlatPreBasisTest.cpp @@ -0,0 +1,52 @@ +#include +#include +#include +#include + +#include + +int test() +{ + using namespace AMDiS; + using namespace Dune::Functions::BasisFactory; + + // construct a grid + Dune::YaspGrid<2> grid({1.0, 1.0}, {8,8}); + + // adaptive grid wrapper + AdaptiveGrid adaptiveGrid(grid); + auto gridView = adaptiveGrid.leafGridView(); + + // construct a basis + ParallelGlobalBasis basis1(gridView, power<2>(lagrange<1>(), blockedInterleaved())); + ParallelGlobalBasis basis2(gridView, power<2>(lagrange<1>(), blockedLexicographic())); + ParallelGlobalBasis basis3(gridView, power<2>(lagrange<1>(), flatInterleaved())); + ParallelGlobalBasis basis4(gridView, power<2>(lagrange<1>(), flatLexicographic())); + ParallelGlobalBasis basis5(gridView, power<2>(lagrange<1>())); + ParallelGlobalBasis basis6(gridView, composite(lagrange<1>())); + + // construct a ProblemStat + ProblemStat prob1("prob1", grid, power<2>(lagrange<1>(), blockedInterleaved())); + ProblemStat prob2("prob2", grid, power<2>(lagrange<1>(), blockedLexicographic())); + ProblemStat prob3("prob3", grid, power<2>(lagrange<1>(), flatInterleaved())); + ProblemStat prob4("prob4", grid, power<2>(lagrange<1>(), flatLexicographic())); + ProblemStat prob5("prob5", grid, power<2>(lagrange<1>())); + ProblemStat prob6("prob6", grid, composite(lagrange<1>())); + + // construct a DOFVector + DOFVector vec1(gridView, power<2>(lagrange<1>(), blockedInterleaved())); + DOFVector vec2(gridView, power<2>(lagrange<1>(), blockedLexicographic())); + DOFVector vec3(gridView, power<2>(lagrange<1>(), flatInterleaved())); + DOFVector vec4(gridView, power<2>(lagrange<1>(), flatLexicographic())); + DOFVector vec5(gridView, power<2>(lagrange<1>())); + DOFVector vec6(gridView, composite(lagrange<1>())); + + return 0; +} + +int main(int argc, char** argv) +{ + AMDiS::Environment env(argc, argv); + + return test(); +} -- GitLab From 98002aca7efb6c28dfe9a4dc60ed97c92435bd22 Mon Sep 17 00:00:00 2001 From: Simon Praetorius Date: Sat, 10 Oct 2020 13:41:18 +0200 Subject: [PATCH 7/8] adapt Observer to accept non-notifier types --- amdis/Observer.hpp | 16 +++++++++++++--- amdis/functions/FlatPreBasis.hpp | 12 ++++++------ test/FlatPreBasisTest.cpp | 5 +---- 3 files changed, 20 insertions(+), 13 deletions(-) diff --git a/amdis/Observer.hpp b/amdis/Observer.hpp index 70498058..ec78aa56 100644 --- a/amdis/Observer.hpp +++ b/amdis/Observer.hpp @@ -3,6 +3,7 @@ #include #include +#include #include #include #include @@ -100,13 +101,22 @@ namespace AMDiS : public ObserverInterface { public: - template - Observer(Notifier const& notifier) - : notifier_(const_cast(¬ifier)) + template ,N>)> + Observer(N const& notifier) + : notifier_(const_cast(¬ifier)) { notifier_->attach(this); } + template ,N>)> + Observer(N const& notifier) + { + warning("Ignoring Notifier. Use AdaptiveGrid wrapper."); + } + + /// Destructor, detaches from the notifier virtual ~Observer() { diff --git a/amdis/functions/FlatPreBasis.hpp b/amdis/functions/FlatPreBasis.hpp index ff280fe4..6c204861 100644 --- a/amdis/functions/FlatPreBasis.hpp +++ b/amdis/functions/FlatPreBasis.hpp @@ -59,7 +59,6 @@ namespace AMDiS template static type create(PB const& preBasis) { - warning("Currently only flat index-merging strategies supported."); auto node = preBasis.makeNode(); node.bind(*preBasis.gridView().template begin<0>()); return {preBasis.gridView(), (unsigned int)(polynomialDegree(node))}; @@ -131,12 +130,12 @@ namespace AMDiS template static type create(PreBasis const& preBasis, std::index_sequence) { - warning("Currently only flat index-merging strategies supported."); + test_warning(std::is_same_v, "Basis converted into flat index-merging strategy."); return {FlatPreBasis::create(Impl::subPreBasis(preBasis,Dune::index_constant{}))...}; } }; - // specialization for power bases + // specialization for flat power bases template struct FlatPreBasis, MultiIndex> { @@ -145,12 +144,11 @@ namespace AMDiS template static type create(PreBasis const& preBasis) { - warning("Currently only flat index-merging strategies supported."); return {FlatPreBasis::create(Impl::subPreBasis(preBasis))}; } }; - // specialization for power bases + // specialization for blocked power bases template struct FlatPreBasis, MultiIndex> @@ -161,10 +159,12 @@ namespace AMDiS template static type create(PreBasis const& preBasis) { + warning("Basis converted into flat index-merging strategy."); return {FlatPreBasis::create(Impl::subPreBasis(preBasis))}; } }; + // specialization for blocked power bases template struct FlatPreBasis, MultiIndex> @@ -175,7 +175,7 @@ namespace AMDiS template static type create(PreBasis const& preBasis) { - warning("Currently only flat index-merging strategies supported."); + warning("Basis converted into flat index-merging strategy."); return {FlatPreBasis::create(Impl::subPreBasis(preBasis))}; } }; diff --git a/test/FlatPreBasisTest.cpp b/test/FlatPreBasisTest.cpp index dd289bfd..18fd12a5 100644 --- a/test/FlatPreBasisTest.cpp +++ b/test/FlatPreBasisTest.cpp @@ -12,10 +12,7 @@ int test() // construct a grid Dune::YaspGrid<2> grid({1.0, 1.0}, {8,8}); - - // adaptive grid wrapper - AdaptiveGrid adaptiveGrid(grid); - auto gridView = adaptiveGrid.leafGridView(); + auto gridView = grid.leafGridView(); // construct a basis ParallelGlobalBasis basis1(gridView, power<2>(lagrange<1>(), blockedInterleaved())); -- GitLab From dc55a7fad955ccf4fd41db5bd590fe6039881b51 Mon Sep 17 00:00:00 2001 From: Simon Praetorius Date: Sat, 10 Oct 2020 13:56:47 +0200 Subject: [PATCH 8/8] some cleanup --- amdis/functions/ParallelGlobalBasis.hpp | 8 ++++---- examples/ellipt.cc | 3 ++- examples/vecellipt.cc | 6 ++---- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/amdis/functions/ParallelGlobalBasis.hpp b/amdis/functions/ParallelGlobalBasis.hpp index 9937eb71..16e7de46 100644 --- a/amdis/functions/ParallelGlobalBasis.hpp +++ b/amdis/functions/ParallelGlobalBasis.hpp @@ -180,13 +180,13 @@ namespace AMDiS // Deduction guides template - ParallelGlobalBasis(std::string const& name, GV const& gridView, PBF&& preBasisFactory) + ParallelGlobalBasis(std::string const& name, GV const& gridView, PBF const& preBasisFactory) -> ParallelGlobalBasis>(gridView)))>; + preBasisFactory.template makePreBasis>(gridView)))>; template - ParallelGlobalBasis(GV const& gridView, PBF&& preBasisFactory) + ParallelGlobalBasis(GV const& gridView, PBF const& preBasisFactory) -> ParallelGlobalBasis>(gridView)))>; + preBasisFactory.template makePreBasis>(gridView)))>; } // end namespace AMDiS diff --git a/examples/ellipt.cc b/examples/ellipt.cc index 3345dc7a..0deafb22 100644 --- a/examples/ellipt.cc +++ b/examples/ellipt.cc @@ -8,6 +8,7 @@ using Grid = Dune::YaspGrid; using namespace AMDiS; +using namespace Dune::Functions::BasisFactory; int main(int argc, char** argv) { @@ -30,7 +31,7 @@ int main(int argc, char** argv) auto grid = MeshCreator{"elliptMesh"}.create(); - ProblemStat prob("ellipt", *grid, Dune::Functions::BasisFactory::lagrange<2>()); + ProblemStat prob("ellipt", *grid, lagrange<2>()); prob.initialize(INIT_ALL); auto opL = makeOperator(tag::gradtest_gradtrial{}, 1.0); diff --git a/examples/vecellipt.cc b/examples/vecellipt.cc index 634cdbc6..f9b06185 100644 --- a/examples/vecellipt.cc +++ b/examples/vecellipt.cc @@ -7,15 +7,13 @@ #include using namespace AMDiS; - -using Grid = Dune::YaspGrid; +using namespace Dune::Functions::BasisFactory; int main(int argc, char** argv) { Environment env(argc, argv); - using namespace Dune::Functions::BasisFactory; - + using Grid = Dune::YaspGrid; auto grid = MeshCreator{"elliptMesh"}.create(); ProblemStat prob("ellipt", *grid, power<2>(lagrange<2>())); prob.initialize(INIT_ALL); -- GitLab