Commit 3c2194bd authored by Praetorius, Simon's avatar Praetorius, Simon
Browse files

cleanup for updated dune-* modules

parent 7bd235f6
...@@ -5,8 +5,6 @@ ...@@ -5,8 +5,6 @@
#include <boost/program_options.hpp> #include <boost/program_options.hpp>
#include <dune/common/parallel/mpihelper.hh> // An initializer of MPI
// AMDiS includes // AMDiS includes
#include "Initfile.hpp" #include "Initfile.hpp"
#include "Log.hpp" #include "Log.hpp"
...@@ -15,12 +13,10 @@ namespace AMDiS ...@@ -15,12 +13,10 @@ namespace AMDiS
{ {
// using namespace std; // using namespace std;
void init(int& argc, char**& argv, std::string initFileName) Dune::MPIHelper& init(int& argc, char**& argv, std::string initFileName)
{ {
// Maybe initialize MPI // Maybe initialize MPI
std::cout << "call MPIHelper::instance..."; Dune::MPIHelper& mpiHelper = Dune::MPIHelper::instance(argc, argv);
Dune::MPIHelper& helper = Dune::MPIHelper::instance(argc, argv);
std::cout << " [ ok ]\n";
Parameters::clearData(); Parameters::clearData();
...@@ -82,6 +78,8 @@ namespace AMDiS ...@@ -82,6 +78,8 @@ namespace AMDiS
// if (vm.count("parameters") && !ignoreCommandline) // if (vm.count("parameters") && !ignoreCommandline)
// Parameters::readArgv(vm["parameters"].as<std::string>(),0); // Parameters::readArgv(vm["parameters"].as<std::string>(),0);
// TODO: add command-line arguments again. // TODO: add command-line arguments again.
return mpiHelper;
} }
......
...@@ -7,10 +7,11 @@ ...@@ -7,10 +7,11 @@
#include <string> #include <string>
#include <dune/common/exceptions.hh> // We use exceptions #include <dune/common/exceptions.hh> // We use exceptions
#include <dune/common/parallel/mpihelper.hh>
namespace AMDiS namespace AMDiS
{ {
void init(int& argc, char**& argv, std::string initFileName = ""); Dune::MPIHelper& init(int& argc, char**& argv, std::string initFileName = "");
void init(std::string initFileName); void init(std::string initFileName);
......
#pragma once #pragma once
#include <dune/functions/functionspacebases/interpolate.hh> #include <dune/functions/functionspacebases/interpolate.hh>
#include <dune/amdis/LinearAlgebra.hpp>
namespace AMDiS namespace AMDiS
{ {
...@@ -14,7 +15,7 @@ namespace AMDiS ...@@ -14,7 +15,7 @@ namespace AMDiS
using Dune::Functions::interpolate; using Dune::Functions::interpolate;
if (!initialized) { if (!initialized) {
// interpolate(matrix.getRowFeSpace(), dirichletNodes, predicate); interpolate(matrix.getRowFeSpace(), dirichletNodes, predicate);
initialized = true; initialized = true;
} }
} }
...@@ -33,8 +34,8 @@ namespace AMDiS ...@@ -33,8 +34,8 @@ namespace AMDiS
matrix.clearDirichletRows(dirichletNodes, apply); matrix.clearDirichletRows(dirichletNodes, apply);
if (apply) { if (apply) {
// interpolate(matrix.getRowFeSpace(), rhs.getVector(), values, dirichletNodes); interpolate(matrix.getRowFeSpace(), wrapper(rhs.getVector()), values, dirichletNodes);
// interpolate(matrix.getColFeSpace(), solution.getVector(), values, dirichletNodes); interpolate(matrix.getColFeSpace(), wrapper(solution.getVector()), values, dirichletNodes);
} }
} }
......
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
#ifdef NDEBUG #ifdef NDEBUG
#define AMDIS_FUNCNAME_DBG(nn) #define AMDIS_FUNCNAME_DBG(nn)
#else #else
#define AMDIS_FUNCNAME_DBG(nn) const char *funcName; funcName = nn; #define AMDIS_FUNCNAME_DBG(nn) AMDIS_UNUSED(const char *funcName); funcName = nn;
#endif #endif
......
...@@ -388,7 +388,7 @@ namespace AMDiS ...@@ -388,7 +388,7 @@ namespace AMDiS
auto geometry = element.geometry(); auto geometry = element.geometry();
const auto& rowLocalBasis = rowView.tree().finiteElement().localBasis(); const auto& rowLocalBasis = rowView.tree().finiteElement().localBasis();
const auto& colLocalBasis = colView.tree().finiteElement().localBasis(); // const auto& colLocalBasis = colView.tree().finiteElement().localBasis();
int order = getQuadratureDegree(2); int order = getQuadratureDegree(2);
const auto& quad = Dune::QuadratureRules<double, dim>::rule(element.type(), order); const auto& quad = Dune::QuadratureRules<double, dim>::rule(element.type(), order);
......
...@@ -69,7 +69,7 @@ namespace AMDiS ...@@ -69,7 +69,7 @@ namespace AMDiS
} }
/// Implementation of \ref ProblemTimeInterface::transferInitialSolution(). /// Implementation of \ref ProblemTimeInterface::transferInitialSolution().
virtual void transferInitialSolution(AdaptInfo& adaptInfo); virtual void transferInitialSolution(AdaptInfo& adaptInfo) override;
protected: protected:
/// Space problem solved in each timestep. /// Space problem solved in each timestep.
......
...@@ -73,7 +73,7 @@ namespace AMDiS ...@@ -73,7 +73,7 @@ namespace AMDiS
virtual void closeTimestep(AdaptInfo&) override { /* by default, do nothing */ } virtual void closeTimestep(AdaptInfo&) override { /* by default, do nothing */ }
/// Implementation of \ref ProblemStatBase::getName(). /// Implementation of \ref ProblemStatBase::getName().
std::string getName() const virtual std::string getName() const override
{ {
return name; return name;
} }
......
...@@ -150,7 +150,7 @@ namespace AMDiS ...@@ -150,7 +150,7 @@ namespace AMDiS
/// Return the i'th \ref solution component /// Return the i'th \ref solution component
template <size_t I = 0> template <size_t I = 0>
decltype(auto) getSolution(const index_<I> _i = index_<I>()) decltype(auto) getSolution(const index_<I> _i = {})
{ {
return (*solution)[_i]; return (*solution)[_i];
} }
...@@ -176,7 +176,7 @@ namespace AMDiS ...@@ -176,7 +176,7 @@ namespace AMDiS
/// Return the I'th \ref feSpaces component /// Return the I'th \ref feSpaces component
template <size_t I = 0> template <size_t I = 0>
FeSpace<I> const& getFeSpace(const index_<I> = index_<I>()) const FeSpace<I> const& getFeSpace(const index_<I> = {}) const
{ {
return std::get<I>(*feSpaces); return std::get<I>(*feSpaces);
} }
...@@ -372,7 +372,7 @@ namespace AMDiS ...@@ -372,7 +372,7 @@ namespace AMDiS
**/ **/
virtual Flag oneIteration(AdaptInfo& adaptInfo, Flag toDo = FULL_ITERATION) override virtual Flag oneIteration(AdaptInfo& adaptInfo, Flag toDo = FULL_ITERATION) override
{ {
for (int i = 0; i < ProblemStatType::getNumComponents(); i++) for (size_t i = 0; i < ProblemStatType::getNumComponents(); ++i)
if (adaptInfo.spaceToleranceReached(i)) if (adaptInfo.spaceToleranceReached(i))
adaptInfo.allowRefinement(false, i); adaptInfo.allowRefinement(false, i);
else else
...@@ -391,13 +391,13 @@ namespace AMDiS ...@@ -391,13 +391,13 @@ namespace AMDiS
virtual void estimate(AdaptInfo& adaptInfo) override { /* Does nothing. */ } virtual void estimate(AdaptInfo& adaptInfo) override { /* Does nothing. */ }
/// Implementation of \ref ProblemStatBase::refineMesh. /// Implementation of \ref ProblemStatBase::refineMesh.
virtual Flag refineMesh(AdaptInfo& adaptInfo) override { /* Does nothing. */ } virtual Flag refineMesh(AdaptInfo& adaptInfo) override { return {0}; }
/// Implementation of \ref ProblemStatBase::coarsenMesh. /// Implementation of \ref ProblemStatBase::coarsenMesh.
virtual Flag coarsenMesh(AdaptInfo& adaptInfo) override { /* Does nothing. */ } virtual Flag coarsenMesh(AdaptInfo& adaptInfo) override { return {0}; }
/// Implementation of \ref ProblemStatBase::markElements. /// Implementation of \ref ProblemStatBase::markElements.
virtual Flag markElements(AdaptInfo& adaptInfo) override { /* Does nothing. */ } virtual Flag markElements(AdaptInfo& adaptInfo) override { return {0}; }
}; };
} // end namespace Impl } // end namespace Impl
......
...@@ -222,9 +222,6 @@ namespace AMDiS ...@@ -222,9 +222,6 @@ namespace AMDiS
For<0, nComponents>::loop([this, &nnz, asmMatrix, asmVector, _r](auto const _c) For<0, nComponents>::loop([this, &nnz, asmMatrix, asmVector, _r](auto const _c)
{ {
auto const& rowFeSpace = this->getFeSpace(_r);
auto const& colFeSpace = this->getFeSpace(_c);
// The DOFMatrix which should be assembled // The DOFMatrix which should be assembled
auto& dofmatrix = (*systemMatrix)(_r, _c); auto& dofmatrix = (*systemMatrix)(_r, _c);
auto& solution_vec = (*solution)[_c]; auto& solution_vec = (*solution)[_c];
......
...@@ -12,4 +12,41 @@ namespace AMDiS ...@@ -12,4 +12,41 @@ namespace AMDiS
template <class Vector> template <class Vector>
using BaseVector = typename Impl::BaseVector<Vector>::type; using BaseVector = typename Impl::BaseVector<Vector>::type;
namespace Impl
{
template <class Vector>
class BaseWrapper
{
public:
using value_type = typename Vector::value_type;
using size_type = typename Vector::size_type;
BaseWrapper(Vector& vec) : vec(vec) {}
void resize(size_type s)
{
vec.resize(s);
}
size_type size() const
{
return vec.size();
}
value_type& operator[](size_type i) { return vec[i]; }
value_type const& operator[](size_type i) const { return vec[i]; }
protected:
Vector& vec;
};
} // end namespace Impl
template <class Vector>
Impl::BaseWrapper<std::remove_reference_t<Vector>> wrapper(Vector&& vec)
{
return {std::forward<Vector>(vec)};
}
} // end namespace AMDiS } // end namespace AMDiS
...@@ -48,7 +48,7 @@ namespace AMDiS ...@@ -48,7 +48,7 @@ namespace AMDiS
} }
// return the runner/worker corresponding to this solver (optional) // return the runner/worker corresponding to this solver (optional)
virtual std::shared_ptr<RunnerBase> getRunner() { /* Does nothing */ }; virtual std::shared_ptr<RunnerBase> getRunner() { return {}; };
private: private:
/// main methods that all solvers must implement /// main methods that all solvers must implement
......
...@@ -33,8 +33,8 @@ namespace AMDiS ...@@ -33,8 +33,8 @@ namespace AMDiS
return 0; return 0;
} }
virtual std::shared_ptr<PreconBase> getLeftPrecon() {} virtual std::shared_ptr<PreconBase> getLeftPrecon() { return {}; }
virtual std::shared_ptr<PreconBase> getRightPrecon() {} virtual std::shared_ptr<PreconBase> getRightPrecon() { return {}; }
}; };
} // end namespace AMDiS } // end namespace AMDiS
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
#include <string> #include <string>
#include <dune/amdis/Initfile.hpp>
namespace AMDiS namespace AMDiS
{ {
/// Class that stores information about the solution process, like tolerances /// Class that stores information about the solution process, like tolerances
......
#pragma once #pragma once
#include <boost/numeric/mtl/utility/irange.hpp>
#include <dune/amdis/linear_algebra/LinearAlgebraBase.hpp> #include <dune/amdis/linear_algebra/LinearAlgebraBase.hpp>
#include <dune/amdis/linear_algebra/mtl/MTLDenseVector.hpp>
namespace AMDiS namespace AMDiS
{ {
...@@ -134,7 +137,7 @@ namespace AMDiS ...@@ -134,7 +137,7 @@ namespace AMDiS
}; };
template <class BlockVector, class Vector = mtl::dense_vector<typename BlockVector::value_type>> template <class BlockVector, class Vector = /**/MTLDenseVector<typename BlockVector::value_type>>
BlockVectorWrapper<BlockVector, Vector> BlockVectorWrapper<BlockVector, Vector>
blockWrapper(BlockVector& bvec) blockWrapper(BlockVector& bvec)
{ {
......
...@@ -3,13 +3,11 @@ ...@@ -3,13 +3,11 @@
#include <string> #include <string>
#include <memory> #include <memory>
#include <boost/numeric/mtl/vector/dense_vector.hpp>
#include <dune/functions/functionspacebases/interpolate.hh> #include <dune/functions/functionspacebases/interpolate.hh>
#include <dune/amdis/ClonablePtr.hpp> #include <dune/amdis/ClonablePtr.hpp>
#include <dune/amdis/Log.hpp> #include <dune/amdis/Log.hpp>
#include <dune/amdis/linear_algebra/mtl/MTLDenseVector.hpp>
namespace AMDiS namespace AMDiS
{ {
...@@ -24,7 +22,7 @@ namespace AMDiS ...@@ -24,7 +22,7 @@ namespace AMDiS
using FeSpace = FeSpaceType; using FeSpace = FeSpaceType;
/// The type of the base vector /// The type of the base vector
using BaseVector = mtl::dense_vector<ValueType>; using BaseVector = MTLDenseVector<ValueType>;
/// The index/size - type /// The index/size - type
using size_type = typename FeSpace::size_type; using size_type = typename FeSpace::size_type;
......
...@@ -34,7 +34,7 @@ namespace AMDiS ...@@ -34,7 +34,7 @@ namespace AMDiS
{} {}
/// Implements \ref LinearSolverInterface::getRunner() /// Implements \ref LinearSolverInterface::getRunner()
std::shared_ptr<RunnerBase> getRunner() virtual std::shared_ptr<RunnerBase> getRunner() override
{ {
return runner; return runner;
} }
......
#pragma once
#include <boost/numeric/mtl/vector/dense_vector.hpp>
#include <dune/amdis/linear_algebra/LinearAlgebraBase.hpp>
namespace AMDiS
{
template <class Value>
using MTLDenseVector = mtl::vec::dense_vector<Value>;
namespace Impl
{
template <class Vector>
class MTLWrapper
: public BaseWrapper<Vector>
{
using Super = BaseWrapper<Vector>;
public:
using value_type = typename Super::value_type;
using size_type = typename Super::size_type;
template <class Vector_>
MTLWrapper(Vector_&& vec)
: Super(std::forward<Vector_>(vec))
{}
void resize(size_type s)
{
this->vec.change_dim(s);
}
size_type size() const
{
return num_rows(this->vec);
}
};
} // end namespace Impl
template <class Value>
Impl::MTLWrapper<MTLDenseVector<Value>> wrapper(MTLDenseVector<Value>& vec)
{
return {vec};
}
}
...@@ -5,8 +5,6 @@ ...@@ -5,8 +5,6 @@
#include <memory> #include <memory>
#include <tuple> #include <tuple>
#include <boost/numeric/mtl/vector/dense_vector.hpp>
#include <dune/amdis/Basic.hpp> #include <dune/amdis/Basic.hpp>
#include <dune/amdis/Log.hpp> #include <dune/amdis/Log.hpp>
#include <dune/amdis/Loops.hpp> #include <dune/amdis/Loops.hpp>
...@@ -80,7 +78,8 @@ namespace AMDiS ...@@ -80,7 +78,8 @@ namespace AMDiS
AMDIS_STATIC_ASSERT( nComponents > 0 ); AMDIS_STATIC_ASSERT( nComponents > 0 );
/// The type of the block-vector /// The type of the block-vector
using MultiVector = BlockMTLVector<mtl::dense_vector<ValueType>, nComponents>; using BaseVector = typename DOFVectorGenerator<std::tuple_element_t<0, FeSpaces>>::BaseVector;
using MultiVector = BlockMTLVector<BaseVector, nComponents>;
/// The type of the vector of DOFVectors /// The type of the vector of DOFVectors
using DOFVectors = MakeTuple_t<DOFVectorGenerator, FeSpaces>; using DOFVectors = MakeTuple_t<DOFVectorGenerator, FeSpaces>;
......
// Software License for MTL
//
// Copyright (c) 2007 The Trustees of Indiana University.
// 2008 Dresden University of Technology and the Trustees of Indiana University.
// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com.
// All rights reserved.
// Authors: Peter Gottschling and Andrew Lumsdaine
//
// This file is part of the Matrix Template Library
//
// See also license.mtl.txt in the distribution.
#ifndef ITL_BASIC_ITERATION_INCLUDE
#define ITL_BASIC_ITERATION_INCLUDE
#include <iostream>
#include <complex>
#include <string>
namespace itl {
template <class Real>
class basic_iteration
{
public:
typedef basic_iteration self;
typedef Real real;
template <class Vector>
basic_iteration(const Vector& r0, int max_iter_, Real t, Real a = Real(0))
: error(0), i(0), norm_r0(std::abs(two_norm(r0))),
max_iter(max_iter_), rtol_(t), atol_(a), is_finished(false), my_quite(false), my_suppress(false) { }
basic_iteration(Real nb, int max_iter_, Real t, Real a = Real(0))
: error(0), i(0), norm_r0(nb), max_iter(max_iter_), rtol_(t), atol_(a), is_finished(false),
my_quite(false), my_suppress(false) {}
virtual ~basic_iteration() {}
bool check_max()
{
if (i >= max_iter)
error= 1, is_finished= true, err_msg= "Too many iterations.";
return is_finished;
}
template <class Vector>
bool finished(const Vector& r)
{
if (converged(two_norm(r)))
return is_finished= true;
return check_max();
}
bool finished(const Real& r)
{
if (converged(r))
return is_finished= true;
return check_max();
}
template <typename T>
bool finished(const std::complex<T>& r)
{
if (converged(std::abs(r)))
return is_finished= true;
return check_max();
}
bool finished() const { return is_finished; }
template <class T>
int terminate(const T& r) { finished(r); return error; }
bool converged(const Real& r) { resid_= r; return converged(); }
bool converged() const
{
if (norm_r0 == 0)
return resid_ <= atol_; // ignore relative tolerance if |r0| is zero
return resid_ <= rtol_ * norm_r0 || resid_ <= atol_;
}
self& operator++() { ++i; return *this; }
self& operator+=(int n) { i+= n; return *this; }
bool first() const { return i <= 1; }
virtual operator int() const { return error; }
virtual int error_code() const { return error; }
bool is_converged() const { return is_finished && error == 0; }
int iterations() const { return i; }
int max_iterations() const { return max_iter; }