// SPDX-FileCopyrightText: Copyright © DUNE Project contributors, see file LICENSE.md in module root // SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception // -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- // vi: set et ts=4 sw=2 sts=2: #include "anisotropic.hh" #include #include #include #include #include #include #include #include namespace Dune { using Mat = BCRSMatrix>; using Vec = BlockVector>; // explicit template instantiation of FastAMG preconditioner template class Amg::FastAMG, Vec, Amg::SequentialInformation>; } // end namespace Dune template void randomize(const M& mat, V& b) { V x=b; srand(20030317); typedef typename V::iterator iterator; for(iterator i=x.begin(); i != x.end(); ++i) *i=(rand() / (RAND_MAX + 1.0)); mat.mv(static_cast(x), b); } template void testAMG(int N, int coarsenTarget, int ml) { std::cout<<"N="< > CriterionBase; typedef Dune::Amg::CoarsenCriterion Criterion; Criterion criterion(15,coarsenTarget); criterion.setDefaultValuesIsotropic(2); criterion.setAlpha(.67); criterion.setBeta(1.0e-4); criterion.setMaxLevel(ml); criterion.setSkipIsolated(false); typedef Dune::Amg::FastAMG AMG; Dune::Amg::Parameters params; AMG amg(fop, criterion, params); // check if recalculation of matrix hierarchy works amg.recalculateHierarchy(); double buildtime = watch.elapsed(); std::cout<<"Building hierarchy took "< amgCG(fop,amg,1e-6,80,2); //Dune::LoopSolver amgCG(fop, amg, 1e-4, 10000, 2); watch.reset(); Dune::InverseOperatorResult r; amgCG.apply(x,b,r); double solvetime = watch.elapsed(); std::cout<<"AMG solving took "<1) N = atoi(argv[1]); if(argc>2) coarsenTarget = atoi(argv[2]); if(argc>3) ml = atoi(argv[3]); { using MB = double; using VB = double; testAMG(N, coarsenTarget, ml); } { using MB = Dune::FieldMatrix; using VB = Dune::FieldVector; testAMG(N, coarsenTarget, ml); } { using MB = Dune::FieldMatrix; using VB = Dune::FieldVector; testAMG(N, coarsenTarget, ml); } return 0; } catch (std::exception &e) { std::cout << "ERROR: " << e.what() << std::endl; return 1; } catch (...) { std::cerr << "Dune reported an unknown error." << std::endl; exit(1); }