Commit f688bc11 authored by Praetorius, Simon's avatar Praetorius, Simon
Browse files

Cleanup of directory structure and removed obsolete files and functions

parent 0ef5f46a
......@@ -2,13 +2,10 @@
#include <tuple>
#include <type_traits>
#include <utility>
#include <dune/common/hash.hh>
#include <amdis/common/IndexSeq.hpp>
#include <amdis/common/Mpl.hpp>
#include <amdis/common/Utility.hpp>
namespace AMDiS
{
namespace Impl
......@@ -35,207 +32,4 @@ namespace AMDiS
} // end namespace Impl
namespace Impl
{
template <class Tuple, std::size_t N>
struct ConstructTuple
{
// add arg to repeated constructor argument list
template <class Arg, class... Args>
static Tuple make(Arg&& arg, Args&&... args)
{
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),
"Nr. of argument != tuple-size");
return Tuple{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,
"Construction of empty tuples with empty argument list only!");
return Tuple{};
}
};
template <class Tuple>
struct FoldTuples
{
// add arg to repeated constructor argument list
template <std::size_t... Is, class... Tuples>
static Tuple make(Indices<Is...>, Tuples&&... tuples)
{
return Tuple{make_element(index_<Is>, std::forward<Tuples>(tuples)...)...};
}
template <std::size_t I, class... Tuples>
static std::tuple_element_t<I, Tuple> make_element(index_t<I>, Tuples&&... tuples)
{
using ::AMDiS::get;
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(
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>
Tuple foldTuples(Args&&... args)
{
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, std::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 =
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, std::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 =
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, std::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 =
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, std::size_t... I>
struct RepeatedTuple<T, Indices<I...>>
{
template <std::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 <std::size_t N, class T>
using Repeat_t =
typename Impl::RepeatedTuple<T, MakeSeq_t<N>>::type;
namespace Impl
{
template <template<class> class Base, class Tuple, class Indices> struct MapTuple;
template <template<class> class Base, class Tuple, std::size_t... I>
struct MapTuple<Base, Tuple, Indices<I...>>
{
using type = std::tuple<typename Base<std::tuple_element_t<I, Tuple>>::type...>;
};
} // end namespace Impl
/// Constructs tuple type, by wrapping Base around the tuple elements.
/// Returns tuple type tuple<Base<tuple_element_t<0>>::type, Base<tuple_element_t<1>>::type, ...>
template <template<class> class Base, class Tuple>
using MapTuple_t =
typename Impl::MapTuple<Base, Tuple, MakeSeq_t<std::tuple_size<Tuple>::value>>::type;
template <class Functor, class Tuples, std::size_t I, std::size_t... J>
auto mapTuple(Functor f, Tuples&& tuples, index_t<I>, Indices<J...>)
{
return f(std::get<I>(std::get<J>(std::forward<Tuples>(tuples)))...);
}
template <class Functor, class Tuples, std::size_t... I>
auto mapTuple(Functor f, Tuples&& tuples, Indices<I...>)
{
return std::make_tuple(mapTuple(f, std::forward<Tuples>(tuples), index_<I>,
MakeSeq_t<std::tuple_size<std::decay_t<Tuples>>::value>{})...);
}
// construction method to construct a new tuple by applying a functor to the elements
// of a given tuple
template <class Functor, class Tuple0, class... Tuples>
auto mapTuple(Functor f, Tuple0&& tuple0, Tuples&&... tuples)
{
return mapTuple(f, std::make_tuple(std::forward<Tuple0>(tuple0), std::forward<Tuples>(tuples)...),
MakeSeq_t<std::tuple_size<std::decay_t<Tuple0>>::value>{});
}
} // end namespace AMDiS
......@@ -17,66 +17,21 @@ namespace AMDiS
template <class T>
struct UnderlyingType
{
using type = std::decay_t<T>;
using type = T;
};
template <class T>
struct UnderlyingType<std::reference_wrapper<T>>
{
using type = std::decay_t<T>;
using type = T;
};
}
template <class T>
using Underlying_t = typename Impl::UnderlyingType<T>::type;
namespace Impl
{
template <class T0, class... Ts>
struct CommonType
{
using type = std::common_type_t<T0, typename CommonType<Ts...>::type>;
};
template <class T0>
struct CommonType<T0>
{
using type = T0;
};
}
template <class... T>
using CommonType_t = typename Impl::CommonType<T...>::type;
/// Create a unique_ptr by copy/move construction
template <class Obj>
auto makeUniquePtr(Obj&& obj)
{
return std::make_unique<std::decay_t<Obj>>(std::forward<Obj>(obj));
}
// ---------------------------------------------------------------------------
// base template for tuple size, must implement a static value member
template <class TupleType>
struct TupleSize;
// utility constant returning the value of the tuple size
template <class TupleType>
constexpr std::size_t TupleSize_v = TupleSize<TupleType>::value;
// base template for retrieving the tuple element type, must implement the type member `type`
template <size_t I, class TupleType>
struct TupleElement;
// base template for retrieving the tuple element type
template <size_t I, class TupleType>
using TupleElement_t = typename TupleElement<I, TupleType>::type;
/// A variadic type list
template <class... Ts>
struct Types {};
......@@ -85,36 +40,16 @@ namespace AMDiS
using Types_t = Types<std::decay_t<Ts>...>;
template <class... T>
struct TupleSize<Types<T...>>
: std::integral_constant<std::size_t, sizeof...(T)> {};
template <size_t I, class Head, class... Tail>
struct TupleElement<I, Types<Head, Tail...>>
{
using type = typename TupleElement<I-1, Types<Tail...>>::type;
};
template <class Head, class... Tail>
struct TupleElement<0, Types<Head, Tail...>>
{
using type = Head;
};
/// Alias that indicates ownership of resources
template <class T>
using owner = T;
// ---------------------------------------------------------------------------
/// generalization of get<tuple>, get<array> for vectors
template <std::size_t I, class T, class A>
T const& get(std::vector<T,A> const& vec)
/// Create a unique_ptr by copy/move construction
template <class Obj>
auto makeUniquePtr(Obj&& obj)
{
return vec[I];
return std::make_unique<std::decay_t<Obj>>(std::forward<Obj>(obj));
}
} // end namespace AMDiS
......@@ -10,6 +10,5 @@ install(FILES
DOFVectorView.hpp
FunctorGridFunction.hpp
GridFunctionConcepts.hpp
Integrate.hpp
OperationsGridFunction.hpp
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/amdis/gridfunctions)
......@@ -8,7 +8,7 @@
#include <dune/common/fvector.hh>
#include <dune/functions/common/defaultderivativetraits.hh>
#include <amdis/common/Utility.hpp>
#include <amdis/common/TypeTraits.hpp>
#include <amdis/gridfunctions/AnalyticGridFunction.hpp>
#include <amdis/gridfunctions/GridFunctionConcepts.hpp>
......
......@@ -10,8 +10,8 @@
#include <dune/typetree/childextraction.hh>
#include <amdis/GridFunctions.hpp>
#include <amdis/utility/FiniteElementType.hpp>
#include <amdis/utility/TreePath.hpp>
#include <amdis/typetree/FiniteElementType.hpp>
#include <amdis/typetree/TreePath.hpp>
namespace AMDiS
{
......
#pragma once
#include <amdis/common/FieldMatVec.hpp>
#include <amdis/LocalBasisCache.hpp>
#include <amdis/utility/LocalBasisCache.hpp>
#include <dune/grid/utility/hierarchicsearch.hh>
......
......@@ -6,7 +6,6 @@
#include <dune/common/std/apply.hh>
#include <amdis/Operations.hpp>
#include <amdis/common/IndexSeq.hpp>
#include <amdis/common/Loops.hpp>
#include <amdis/common/Mpl.hpp>
#include <amdis/gridfunctions/GridFunctionConcepts.hpp>
......
......@@ -3,7 +3,6 @@
#include <dune/common/typeutilities.hh>
#include <amdis/common/Concepts.hpp>
#include <amdis/common/IndexSeq.hpp>
#include <amdis/common/Mpl.hpp>
namespace AMDiS
......
#install headers
install(FILES
FileWriterInterface.hpp
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/amdis/io)
#pragma once
#if HAVE_MTL
#include <boost/numeric/mtl/mtl_fwd.hpp>
#endif
#include <dune/functions/functionspacebases/sizeinfo.hh>
#include <amdis/utility/MultiIndex.hpp>
namespace AMDiS
{
template <class Matrix>
class HierarchicMatrixWrapper
{
public:
explicit HierarchicMatrixWrapper(Matrix& matrix)
: matrix_(matrix)
{}
template <class RowIndex, class ColIndex>
auto& operator()(RowIndex const& row, ColIndex const& col)
{
return matrix_(flatMultiIndex(row), flatMultiIndex(col));
}
template <class RowIndex, class ColIndex>
auto const& operator()(RowIndex const& row, ColIndex const& col) const
{
return matrix_(flatMultiIndex(row), flatMultiIndex(col));
}
private:
Matrix& matrix_;
};
template <class Matrix>
HierarchicMatrixWrapper<Matrix> hierarchicMatrixWrapper(Matrix& matrix)
{
return {matrix};
}
template <class Vector>
class HierarchicVectorWrapper
{
public:
explicit HierarchicVectorWrapper(Vector& vector)
: vector_(vector)
{}
template <class Index>
auto& operator[](Index const& idx)
{
return vector_[flatMultiIndex(idx)];
}
template <class Index>
auto const& operator[](Index const& idx) const
{
return vector_[flatMultiIndex(idx)];
}
template <class Basis>
void resize(Dune::Functions::SizeInfo<Basis> const& s)
{
resizeImpl(vector_, s);
}
std::size_t size() const
{
return sizeImpl(vector_);
}
protected:
template <class Vec, class Basis>
void_t<decltype( std::declval<Vec>().resize(std::size_t(0)) )>
resizeImpl(Vec& vec, Dune::Functions::SizeInfo<Basis> const& s)
{
vec.resize(std::size_t(s));
}
template <class Vec, class Basis>
void_t<decltype( std::declval<Vec>().change_dim(std::size_t(0)) )>
resizeImpl(Vec& vec, Dune::Functions::SizeInfo<Basis> const& s)
{
vec.change_dim(std::size_t(s));
}
#if HAVE_MTL
template <class... Params>
std::size_t sizeImpl(mtl::vec::dense_vector<Params...> const& v) const
{
return mtl::size(v);
}
#endif
template <class V>
using HasSizeMember = decltype(std::declval<V>().size());
template <class V,
std::enable_if_t<Dune::Std::is_detected<HasSizeMember, V>::value, int> = 0>
std::size_t sizeImpl(V const& v) const
{
return v.size();
}
private:
Vector& vector_;
};
template <class Vector>
auto hierarchicVectorWrapper(Vector& vector)
{
return HierarchicVectorWrapper<Vector>{vector};
}
} // end namespace AMDiS
......@@ -6,13 +6,12 @@ install(FILES
DOFVectorBase.hpp
DOFVectorBase.inc.hpp
DOFVectorInterface.hpp
HierarchicWrapper.hpp
LinearSolver.hpp
LinearSolverInterface.hpp
PreconditionerInterface.hpp
RunnerInterface.hpp
SolverInfo.hpp
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/amdis/linear_algebra)
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/amdis/linearalgebra)
add_subdirectory("eigen")
add_subdirectory("istl")
......
#pragma once
#include <amdis/linear_algebra/DOFMatrixBase.hpp>
#include <amdis/linearalgebra/DOFMatrixBase.hpp>
namespace AMDiS
{
......
......@@ -4,10 +4,10 @@
#include <dune/common/timer.hh>
#include <amdis/LocalAssemblerList.hpp>
#include <amdis/OperatorList.hpp>
#include <amdis/common/Math.hpp>
#include <amdis/utility/MultiIndex.hpp>
#include <amdis/utility/TreePath.hpp>
#include <amdis/typetree/MultiIndex.hpp>
#include <amdis/typetree/TreePath.hpp>
namespace AMDiS
{
......@@ -41,6 +41,9 @@ namespace AMDiS
operators_.init(rowBasis, colBasis);
}
DOFMatrixBase(DOFMatrixBase const&) = delete;
DOFMatrixBase(DOFMatrixBase&&) = delete;
/// Return the row-basis \ref rowBasis of the matrix
RowBasis const& rowBasis() const
{
......
#pragma once
#include <amdis/Assembler.hpp>
#include <amdis/LocalAssembler.hpp>
#include <amdis/LocalOperator.hpp>
#include <amdis/common/Utility.hpp>
#include <amdis/utility/Visitor.hpp>
#include <amdis/typetree/Visitor.hpp>
#include <amdis/utility/AssembleOperators.hpp>
namespace AMDiS {
......@@ -61,7 +60,7 @@ addOperator(ContextTag contextTag, PreOperator const& preOp,
using Context = typename ContextTag::type;
auto op = makeLocalOperator<Context>(preOp, rowBasis_->gridView());
auto localAssembler = makeUniquePtr(makeLocalAssembler<Context>(std::move(op), i, j));
auto localAssembler = makeUniquePtr(makeAssembler<Context>(std::move(op), i, j));
operators_[i][j].push(contextTag, std::move(localAssembler));
}
......
......@@ -3,16 +3,16 @@
#include <cmath>
#include <utility>
#include <dune/common/typetraits.hh>
#include <dune/functions/functionspacebases/sizeinfo.hh>
#include <amdis/DataTransfer.hpp>
#include <amdis/GridTransferManager.hpp>
#include <amdis/LocalAssemblerList.hpp>
#include <amdis/OperatorList.hpp>
#include <amdis/common/Math.hpp>
#include <amdis/common/ScalarTypes.hpp>
#include <amdis/linear_algebra/DOFVectorInterface.hpp>
#include <amdis/utility/MultiIndex.hpp>
#include <amdis/utility/TreePath.hpp>
#include <amdis/linearalgebra/DOFVectorInterface.hpp>
#include <amdis/typetree/MultiIndex.hpp>