// 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 #include #include #include #include #include #include #include "laplacian.hh" #if HAVE_SUPERLU template void runSuperLU(std::size_t N) { using Operator = Dune::MatrixAdapter; Matrix mat; Operator fop(mat); Vector b(N*N), x(N*N), b1(N/2), x1(N/2); setupLaplacian(mat,N); b=1; b1=1; x=0; x1=0; Dune::Timer watch; watch.reset(); Dune::SuperLU solver(mat, true); Dune::InverseOperatorResult res; Dune::SuperLU solver1; solver.setVerbosity(true); solver.apply(x,b, res); std::set mrs; for(typename Matrix::size_type s=0; s < N/2; ++s) mrs.insert(s); solver1.setSubMatrix(mat,mrs); solver1.apply(x1,b1, res); solver1.apply(reinterpret_cast(&x1[0]), reinterpret_cast(&b1[0])); } // explicit template instantiation of SuperLU class #if __has_include("slu_sdefs.h") template class Dune::SuperLU>; template class Dune::SuperLU >>; template class Dune::SuperLU >>; #endif #if __has_include("slu_ddefs.h") template class Dune::SuperLU>; template class Dune::SuperLU >>; template class Dune::SuperLU >>; #endif #if __has_include("slu_cdefs.h") template class Dune::SuperLU >>; template class Dune::SuperLU,1,1> >>; template class Dune::SuperLU,2,2> >>; #endif #if __has_include("slu_zdefs.h") template class Dune::SuperLU >>; template class Dune::SuperLU,1,1> >>; template class Dune::SuperLU,2,2> >>; #endif #endif int main(int argc, char** argv) try { #if HAVE_SUPERLU std::size_t N=100; if(argc>1) N = atoi(argv[1]); // ------------------------------------------------------------------------------ std::cout<<"testing for N="<"<; using Vector = Dune::BlockVector; runSuperLU(N); } #endif #if __has_include("slu_ddefs.h") { using Matrix = Dune::BCRSMatrix; using Vector = Dune::BlockVector; runSuperLU(N); } #endif #if __has_include("slu_cdefs.h") { using Matrix = Dune::BCRSMatrix >; using Vector = Dune::BlockVector >; runSuperLU(N); } #endif #if __has_include("slu_zdefs.h") { using Matrix = Dune::BCRSMatrix >; using Vector = Dune::BlockVector >; runSuperLU(N); } #endif // ------------------------------------------------------------------------------ std::cout<<"testing for N="< >"< >; using Vector = Dune::BlockVector >; runSuperLU(N); } #endif #if __has_include("slu_ddefs.h") { using Matrix = Dune::BCRSMatrix >; using Vector = Dune::BlockVector >; runSuperLU(N); } #endif #if __has_include("slu_cdefs.h") { using Matrix = Dune::BCRSMatrix,1,1> >; using Vector = Dune::BlockVector,1> >; runSuperLU(N); } #endif #if __has_include("slu_zdefs.h") { using Matrix = Dune::BCRSMatrix,1,1> >; using Vector = Dune::BlockVector,1> >; runSuperLU(N); } #endif // ------------------------------------------------------------------------------ std::cout<<"testing for N="< >"< >; using Vector = Dune::BlockVector >; runSuperLU(N); } #endif #if __has_include("slu_ddefs.h") { using Matrix = Dune::BCRSMatrix >; using Vector = Dune::BlockVector >; runSuperLU(N); } #endif #if __has_include("slu_cdefs.h") { using Matrix = Dune::BCRSMatrix,2,2> >; using Vector = Dune::BlockVector,2> >; runSuperLU(N); } #endif #if __has_include("slu_zdefs.h") { using Matrix = Dune::BCRSMatrix,2,2> >; using Vector = Dune::BlockVector,2> >; runSuperLU(N); } #endif return 0; #else // HAVE_SUPERLU std::cerr << "You need SuperLU to run this test." << std::endl; return 77; #endif // HAVE_SUPERLU } 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); }