Commit 5a874ddf authored by Praetorius, Simon's avatar Praetorius, Simon
Browse files

some compiler problems removed

parent 59f0c65c
Pipeline #902 passed with stage
in 12 minutes and 30 seconds
......@@ -18,6 +18,7 @@ dune_add_library("duneamdis" NO_EXPORT
)
add_dune_alberta_flags("duneamdis" OBJECT USE_GENERIC)
target_compile_definitions("duneamdis" PUBLIC AMDIS_BACKEND_MTL=1)
target_compile_options("duneamdis" PUBLIC -ftemplate-backtrace-limit=0)
set(BOOST_VERSION "1.54")
set(BOOST_LIBS_REQUIRED system program_options)
......
......@@ -63,10 +63,10 @@ namespace AMDiS
/// < d_i(psi), b * phi >, where the first corresponds to
/// \p firstOrderType == GRD_PHI and the second one to \p firstOrderType == GRD_PSI.
/// The coefficient \p b must be a scalar expression.
template <class Term, size_t I>
Self& addFOT(Term const& b, const index_<I> _i, FirstOrderType firstOrderType)
template <class Term>
Self& addFOT(Term const& b, std::size_t i, FirstOrderType firstOrderType)
{
return addFOTImpl(toTerm(b), _i, firstOrderType);
return addFOTImpl(toTerm(b), i, firstOrderType);
}
template <class... Args>
......@@ -90,10 +90,10 @@ namespace AMDiS
/// where \p A can be a matrix or a scalar expression. The first index \p _i
/// corresponds to the derivative component of the test-function and the
/// second index \p _j to the derivative component of the trial function.
template <class Term, size_t I, size_t J>
Self& addSOT(Term const& A, const index_<I> _i, const index_<J> _j)
template <class Term>
Self& addSOT(Term const& A, std::size_t i, std::size_t j)
{
return addSOTImpl(toTerm(A), _i, _j);
return addSOTImpl(toTerm(A), i, j);
}
template <class... Args>
......@@ -175,15 +175,14 @@ namespace AMDiS
template <class Term>
Self& addFOTImpl(Term const& term, FirstOrderType firstOrderType);
template <class Term, size_t I>
Self& addFOTImpl(Term const& term, const index_<I>,
FirstOrderType firstOrderType);
template <class Term>
Self& addFOTImpl(Term const& term, std::size_t i, FirstOrderType firstOrderType);
template <class Term>
Self& addSOTImpl(Term const& term);
template <class Term, size_t I, size_t J>
Self& addSOTImpl(Term const& term, const index_<I>, const index_<J>);
template <class Term>
Self& addSOTImpl(Term const& term, std::size_t i, std::size_t j);
template <class... Args>
......
......@@ -515,17 +515,17 @@ namespace AMDiS
template <class MeshView>
template <class Term, size_t I>
template <class Term>
Operator<MeshView>& Operator<MeshView>::addFOTImpl(Term const& term,
const index_<I>,
std::size_t i,
FirstOrderType firstOrderType)
{
using OpTerm = GenericOperatorTerm<MeshView, Term, VectorComponent<I>>;
using OpTerm = GenericOperatorTerm<MeshView, Term, VectorComponent>;
if (firstOrderType == GRD_PHI)
firstOrderGrdPhi.push_back(new OpTerm(term));
firstOrderGrdPhi.push_back(new OpTerm(term, {i}));
else
firstOrderGrdPsi.push_back(new OpTerm(term));
firstOrderGrdPsi.push_back(new OpTerm(term, {i}));
return *this;
}
......@@ -540,13 +540,12 @@ namespace AMDiS
template <class MeshView>
template <class Term, size_t I, size_t J>
template <class Term>
Operator<MeshView>& Operator<MeshView>::addSOTImpl(Term const& term,
const index_<I>,
const index_<J>)
std::size_t i, std::size_t j)
{
using OpTerm = GenericOperatorTerm<MeshView, Term, MatrixComponent<I,J>>;
secondOrder.push_back(new OpTerm(term));
using OpTerm = GenericOperatorTerm<MeshView, Term, MatrixComponent>;
secondOrder.push_back(new OpTerm(term, {i,j}));
return *this;
}
......
......@@ -75,11 +75,11 @@ protected:
template <class... Args>
auto evalFotImpl(Args...) const { assert( false ); return 0; }
template <size_t I, class ValueType, class Gradient>
auto evalFotImpl(tag::scalar, VectorComponent<I>, ValueType const& v,
template <class ValueType, class Gradient>
auto evalFotImpl(tag::scalar, VectorComponent comp, ValueType const& v,
Gradient const& grad_test, Scalar const& trial) const
{
return v * grad_test[I] * trial;
return v * grad_test[comp.index] * trial;
}
template <class ValueType, class Gradient>
......@@ -100,11 +100,11 @@ protected:
template <class... Args>
auto evalSotImpl(Args...) const { assert( false ); return 0; }
template <size_t R, size_t C, class ValueType, class Gradient>
auto evalSotImpl(tag::scalar, MatrixComponent<R, C>, ValueType const& v,
template <class ValueType, class Gradient>
auto evalSotImpl(tag::scalar, MatrixComponent comp, ValueType const& v,
Gradient const& grad_test, Gradient const& grad_trial) const
{
return v * (grad_test[R] * grad_trial[C]);
return v * (grad_test[comp.row] * grad_trial[comp.col]);
}
template <class ValueType, class Gradient>
......
......@@ -68,8 +68,9 @@ namespace AMDiS
static constexpr int dow = MeshView::dimensionworld;
public:
GenericOperatorTerm(Term const& term)
GenericOperatorTerm(Term const& term, Traits traits = {})
: term(term)
, traits(traits)
{}
virtual void init(Element const& element,
......@@ -87,28 +88,28 @@ namespace AMDiS
Dune::FieldVector<double,1> const& test,
Dune::FieldVector<double,1> const trial = 1.0) const override
{
return this->evalZotImpl(_cat{}, _traits{}, values[iq], test, trial);
return this->evalZotImpl(_cat{}, traits, values[iq], test, trial);
}
virtual double evalFot1(size_t iq,
Dune::FieldVector<double,1> const& test,
Dune::FieldVector<double,dow> const& grad_trial) const override
{
return this->evalFotImpl(_cat{}, _traits{}, values[iq], grad_trial, test);
return this->evalFotImpl(_cat{}, traits, values[iq], grad_trial, test);
}
virtual double evalFot2(size_t iq,
Dune::FieldVector<double,dow> const& grad_test,
Dune::FieldVector<double,1> const trial = 1.0) const override
{
return this->evalFotImpl(_cat{}, _traits{}, values[iq], grad_test, trial);
return this->evalFotImpl(_cat{}, traits, values[iq], grad_test, trial);
}
virtual double evalSot(size_t iq,
Dune::FieldVector<double,dow> const& grad_test,
Dune::FieldVector<double,dow> const& grad_trial) const override
{
return this->evalSotImpl(_cat{}, _traits{}, values[iq], grad_test, grad_trial);
return this->evalSotImpl(_cat{}, traits, values[iq], grad_test, grad_trial);
}
virtual int getDegree(Dune::GeometryType const& t) const override
......@@ -118,10 +119,10 @@ namespace AMDiS
private:
Term term;
Traits traits;
using value_type = std::decay_t< decltype( std::declval<Term>()[std::declval<size_t>()] ) >;
using _cat = ValueCategory_t<value_type>;
using _traits = Traits;
std::vector<value_type> values;
};
......
......@@ -259,51 +259,54 @@ namespace AMDiS
Timer t;
For<0, nComponents>::loop([this](auto const _r) {
this->getNodeFactory(_r).initializeIndices();
this->getNodeFactory(_r).initializeIndices();
});
size_t nnz = 0;
For<0, nComponents>::loop([this, &nnz, asmMatrix_, asmVector_](auto const _r)
For<0, nComponents>::loop([this, &nnz, asmMatrix_, asmVector_](auto const r)
{
msg(this->getFeSpace(_r).size(), " DOFs for FeSpace[", _r, "]");
msg(this->getFeSpace(r).size(), " DOFs for FeSpace[", r, "]");
bool asmVector = asmVector_ && (!vectorAssembled[int(_r)] || vectorChanging[int(_r)]);
bool asmVector = asmVector_ && (!vectorAssembled[int(r)] || vectorChanging[int(r)]);
if (asmVector) {
rhs->compress(_r);
rhs->getVector(_r) = 0.0;
rhs->compress(r);
rhs->getVector(r) = 0.0;
}
For<0, nComponents>::loop([this, &nnz, asmMatrix_, asmVector, r=_r](auto const _c)
For<0, nComponents>::loop([this, &nnz, asmMatrix_, asmVector](auto const c)
{
auto const _r = r;
static const int _c = decltype(c)::value;
static const int _r = decltype(r)::value;
index_<_r> r{};
using MatrixData = typename ProblemStatSeq<Traits>::template MatrixData<_r, _c>;
using VectorData = typename ProblemStatSeq<Traits>::template VectorData<_r>;
// The DOFMatrix which should be assembled
auto& dofmatrix = (*systemMatrix)(_r, _c);
auto& solution_vec = (*solution)[_c];
auto& rhs_vec = (*rhs)[_r];
auto& dofmatrix = (*systemMatrix)(r, c);
auto& solution_vec = (*solution)[c];
auto& rhs_vec = (*rhs)[r];
auto row_col = std::make_pair(int(_r), int(_c));
auto row_col = std::make_pair(_r, _c);
bool assembleMatrix = asmMatrix_ && (!matrixAssembled[row_col] || matrixChanging[row_col]);
bool assembleVector = asmVector && _r == _c;
int r = 0, c = 0;
if (assembleMatrix) {
// init boundary condition
for (auto bc_list : dirichletBc) {
std::tie(r, c) = bc_list.first;
if (r == int(_r)) {
for (auto bc : bc_list.second)
bc->init(c == int(_c), dofmatrix, solution_vec, rhs_vec);
}
}
int r_ = 0, c_ = 0;
if (assembleMatrix) {
// init boundary condition
for (auto bc_list : dirichletBc) {
std::tie(r_, c_) = bc_list.first;
if (r_ == _r) {
for (auto bc : bc_list.second)
bc->init(c_ == _c, dofmatrix, solution_vec, rhs_vec);
}
}
}
auto mat = MatrixData{dofmatrix, matrixOperators[row_col], matrixFactors[row_col], assembleMatrix};
auto vec = VectorData{rhs_vec, vectorOperators[int(_r)], vectorFactors[int(_r)], assembleVector};
auto vec = VectorData{rhs_vec, vectorOperators[_r], vectorFactors[_r], assembleVector};
// assemble the DOFMatrix block and the corresponding rhs vector, of r==c
......@@ -314,20 +317,20 @@ namespace AMDiS
if (assembleMatrix)
matrixAssembled[row_col] = true;
if (assembleVector)
vectorAssembled[int(_r)] = true;
vectorAssembled[_r] = true;
if (assembleMatrix) {
// finish boundary condition
for (auto bc_list : dirichletBc) {
std::tie(r, c) = bc_list.first;
if (r == int(_r)) {
for (auto bc : bc_list.second)
bc->finish(c == int(_c), dofmatrix, solution_vec, rhs_vec);
}
}
nnz += dofmatrix.getNnz();
}
// finish boundary condition
for (auto bc_list : dirichletBc) {
std::tie(r_, c_) = bc_list.first;
if (r_ == _r) {
for (auto bc : bc_list.second)
bc->finish(c_ == _c, dofmatrix, solution_vec, rhs_vec);
}
}
nnz += dofmatrix.getNnz();
}
});
});
......
......@@ -7,7 +7,7 @@
#include <dune/amdis/common/Utility.hpp>
namespace AMDiS
{
{
namespace Impl
{
template <class Tuple, size_t N>
......@@ -17,36 +17,36 @@ namespace AMDiS
template <class Arg, class... Args>
static Tuple make(Arg&& arg, Args&&... args)
{
return ConstructTuple<Tuple, N-1>::make(
return ConstructTuple<Tuple, N-1>::make(
std::forward<Arg>(arg), std::forward<Arg>(arg), std::forward<Args>(args)...);
}
};
template <class Tuple>
struct ConstructTuple<Tuple, 1>
{
template <class... Args>
static Tuple make(Args&&... args)
{
static_assert(std::tuple_size<Tuple>::value == sizeof...(args),
static_assert(std::tuple_size<Tuple>::value == sizeof...(args),
"Nr. of argument != tuple-size");
return Tuple{std::forward<Args>(args)...};
return {std::forward<Args>(args)...};
}
};
template <class Tuple>
struct ConstructTuple<Tuple, 0>
{
template <class... Args>
static Tuple make(Args&&... args)
{
static_assert(std::tuple_size<Tuple>::value == 0,
static_assert(std::tuple_size<Tuple>::value == 0,
"Construction of empty tuples with empty argument list only!");
return {};
}
};
template <class Tuple>
struct FoldTuples
{
......@@ -56,7 +56,7 @@ namespace AMDiS
{
return Tuple{make_element(index_<Is>(), std::forward<Tuples>(tuples)...)...};
}
template <size_t I, class... Tuples>
static std::tuple_element_t<I, Tuple> make_element(index_<I>, Tuples&&... tuples)
{
......@@ -64,19 +64,19 @@ namespace AMDiS
return std::tuple_element_t<I, Tuple>{get<I>(std::forward<Tuples>(tuples))...};
}
};
} // end namespace Impl
/// Construct a tuple with each element constructed by the same argument arg.
/// Returns tuple { tuple_element_t<0>(arg), tuple_element_t<1>(arg), ... }
template <class Tuple, class Arg>
Tuple constructTuple(Arg&& arg)
{
return Impl::ConstructTuple<Tuple, std::tuple_size<Tuple>::value>::make(
return Impl::ConstructTuple<Tuple, std::tuple_size<Tuple>::value>::make(
std::forward<Arg>(arg));
}
/// Construct a tuple of tuples, by folding a list of tuples of the same size.
/// Return tuple { {arg0[0], arg1[0], arg2[0], ...}, {arg0[1], arg1[1], arg2[1], ...}, ...}
template <class Tuple, class... Args>
......@@ -85,85 +85,85 @@ namespace AMDiS
return Impl::FoldTuples<Tuple>::make(MakeSeq_t<std::tuple_size<Tuple>::value>(),
std::forward<Args>(args)...);
}
namespace Impl
{
template <template<class> class Base, class Tuple, class Indices> struct MakeTuple;
template <template<class> class Base, class Tuple, size_t... I>
template <template<class> class Base, class Tuple, size_t... I>
struct MakeTuple<Base, Tuple, Indices<I...>>
{
using type = std::tuple<Base<std::tuple_element_t<I, Tuple>>...>;
};
} // end namespace Impl
/// Constructs tuple type, by wrapping Base around the tuple elements.
/// Returns tuple type tuple<Base<tuple_element_t<0>>, Base<tuple_element_t<1>>, ...>
template <template<class> class Base, class Tuple>
using MakeTuple_t =
template <template<class> class Base, class Tuple>
using MakeTuple_t =
typename Impl::MakeTuple<Base, Tuple, MakeSeq_t<std::tuple_size<Tuple>::value>>::type;
namespace Impl
{
template <template<class,class> class Base, class Tuple1, class Tuple2, class Indices> struct MakeTuple2;
template <template<class,class> class Base, class Tuple1, class Tuple2, size_t... I>
template <template<class,class> class Base, class Tuple1, class Tuple2, size_t... I>
struct MakeTuple2<Base, Tuple1, Tuple2, Indices<I...>>
{
using type = std::tuple<Base<std::tuple_element_t<I, Tuple1>, std::tuple_element_t<I, Tuple2>>...>;
};
} // end namespace Impl
/// Constructs tuple type, by wrapping Base around the tuple elements.
/// Returns tuple type tuple<Base<tuple_element_t<0,T1>,tuple_element_t<0,T2>>, Base<tuple_element_t<1,T1>,tuple_element_t<1,T2>>, ...>
template <template<class,class> class Base, class Tuple1, class Tuple2>
using MakeTuple2_t =
template <template<class,class> class Base, class Tuple1, class Tuple2>
using MakeTuple2_t =
typename Impl::MakeTuple2<Base, Tuple1, Tuple2, MakeSeq_t<std::tuple_size<Tuple1>::value>>::type;
namespace Impl
{
template <template<class...> class Base, class Tuple, class Indices> struct ExpandTuple;
template <template<class...> class Base, class Tuple, size_t... I>
template <template<class...> class Base, class Tuple, size_t... I>
struct ExpandTuple<Base, Tuple, Indices<I...>>
{
using type = Base<std::tuple_element_t<I, Tuple>...>;
};
} // end namespace Impl
/// Expands tuple element types into template list of Base class.
/// Returns Base<tuple_element<0>, tuple_element<1>, ...>
template <template<class...> class Base, class Tuple>
using ExpandTuple_t =
template <template<class...> class Base, class Tuple>
using ExpandTuple_t =
typename Impl::ExpandTuple<Base, Tuple, MakeSeq_t<std::tuple_size<Tuple>::value>>::type;
namespace Impl
{
template <class T, class Indices> struct RepeatedTuple;
template <class T, size_t... I>
template <class T, size_t... I>
struct RepeatedTuple<T, Indices<I...>>
{
template <size_t, class U> using Id = U;
template <size_t, class U> using Id = U;
using type = std::tuple<Id<I, T>...>;
};
} // end namespace Impl
/// Construct tuple of N times type T.
/// Returns tuple<T, T, T, ...>
template <size_t N, class T>
using Repeat_t =
typename Impl::RepeatedTuple<T, MakeSeq_t<N>>::type;
template <size_t N, class T>
using Repeat_t =
typename Impl::RepeatedTuple<T, MakeSeq_t<N>>::type;
} // end namespace AMDiS
......@@ -13,18 +13,18 @@ namespace AMDiS
// pull in std implementations
using std::shared_ptr;
using std::make_shared;
using std::unique_ptr;
using std::make_unique;
// ---------------------------------------------------------------------------
namespace Impl
{
// workaround for MSVC (problems with alias templates in pack expansion)
template <class, class T>
struct InvokeType { using type = T; };
template <class, class, class T>
struct InvokeType2 { using type = T; };
}
......@@ -47,7 +47,7 @@ namespace AMDiS
// ---------------------------------------------------------------------------
/// A variadic type list
template <class... Ts>
struct Types {};
......@@ -55,18 +55,18 @@ namespace AMDiS
template <class... Ts>
using Types_t = Types<Decay_t<Ts>...>;
/// An identity type wrapper, represents the type itself
template <class T>
struct Id
{
using type = T;
};
template <class T>
using Id_t = typename Id<T>::type;
/// Alias that indicates ownership of resources
template <class T>
using owner = T;
......@@ -74,10 +74,10 @@ namespace AMDiS
/// Dummy type for unknown return type
struct no_valid_type {};
// ---------------------------------------------------------------------------
/// generalization of get<tuple>, get<array> for vectors
template <size_t I, class T, class A>
T const& get(std::vector<T,A> const& vec)
......@@ -85,21 +85,19 @@ namespace AMDiS
return vec[I];
}
// ---------------------------------------------------------------------------
template <size_t I>
struct VectorComponent
{
static constexpr size_t index = I;
struct VectorComponent
{
size_t index;
};
template <size_t R, size_t C>
struct MatrixComponent
{
static constexpr size_t row = R;