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

Cleanup of directory structure and removed obsolete files and functions

parent 0ef5f46a
......@@ -3,8 +3,8 @@
#include <type_traits>
#include <amdis/GridFunctionOperator.hpp>
#include <amdis/LocalBasisCache.hpp>
#include <amdis/common/Size.hpp>
#include <amdis/utility/LocalBasisCache.hpp>
#include <amdis/common/StaticSize.hpp>
namespace AMDiS
{
......
......@@ -3,8 +3,8 @@
#include <type_traits>
#include <amdis/GridFunctionOperator.hpp>
#include <amdis/LocalBasisCache.hpp>
#include <amdis/common/Size.hpp>
#include <amdis/utility/LocalBasisCache.hpp>
#include <amdis/common/StaticSize.hpp>
namespace AMDiS
{
......
......@@ -3,8 +3,8 @@
#include <type_traits>
#include <amdis/GridFunctionOperator.hpp>
#include <amdis/LocalBasisCache.hpp>
#include <amdis/common/Size.hpp>
#include <amdis/utility/LocalBasisCache.hpp>
#include <amdis/common/StaticSize.hpp>
namespace AMDiS
{
......@@ -46,7 +46,7 @@ namespace AMDiS
"RowNode must be Leaf-Node and ColNode must be a Power-Node.");
static const std::size_t CHILDREN = ColNode::CHILDREN;
static_assert( std::is_same<typename GridFct::Range, Dune::FieldVector<double, CHILDREN>>::value, "" );
static_assert( std::is_same<typename GridFct::Range, Dune::FieldVector<double, int(CHILDREN)>>::value, "" );
auto const& quad = this->getQuadratureRule(context.type(), rowNode, colNode);
auto const& rowLocalFE = rowNode.finiteElement();
......
......@@ -3,8 +3,8 @@
#include <type_traits>
#include <amdis/GridFunctionOperator.hpp>
#include <amdis/LocalBasisCache.hpp>
#include <amdis/common/Size.hpp>
#include <amdis/utility/LocalBasisCache.hpp>
#include <amdis/common/StaticSize.hpp>
namespace AMDiS
{
......
......@@ -2,7 +2,7 @@
#include <type_traits>
#include <amdis/assembler/ZeroOrderTestTrialvec.hpp>
#include <amdis/localoperators/ZeroOrderTestTrialvec.hpp>
namespace AMDiS
{
......
......@@ -3,8 +3,8 @@
#include <type_traits>
#include <amdis/GridFunctionOperator.hpp>
#include <amdis/LocalBasisCache.hpp>
#include <amdis/common/Size.hpp>
#include <amdis/utility/LocalBasisCache.hpp>
#include <amdis/common/StaticSize.hpp>
#include <amdis/common/ValueCategory.hpp>
namespace AMDiS
......@@ -167,7 +167,7 @@ namespace AMDiS
tag::matrix)
{
static const std::size_t CHILDREN = RowNode::CHILDREN;
static_assert( std::is_same<expr_value_type, Dune::FieldMatrix<double, CHILDREN, CHILDREN>>::value, "" );
static_assert( std::is_same<expr_value_type, Dune::FieldMatrix<double, int(CHILDREN), int(CHILDREN)>>::value, "" );
auto const& rowLocalFE = rowNode.child(0).finiteElement();
auto const& colLocalFE = colNode.child(0).finiteElement();
......@@ -183,7 +183,7 @@ namespace AMDiS
// The multiplicative factor in the integral transformation formula
const auto factor = context.integrationElement(quad[iq].position()) * quad[iq].weight();
const Dune::FieldMatrix<double, CHILDREN, CHILDREN> exprValue = Super::coefficient(local);
const Dune::FieldMatrix<double, int(CHILDREN), int(CHILDREN)> exprValue = Super::coefficient(local);
auto const& rowShapeValues = rowShapeValuesCache[iq];
auto const& colShapeValues = colShapeValuesCache[iq];
......
......@@ -18,37 +18,23 @@ namespace AMDiS
/// Functor that represents A+B
struct Plus
{
#ifdef AMDIS_HAS_CXX_FOLD_EXPRESSIONS
template <class... Ts>
constexpr auto operator()(Ts const&... ts) const
{
return (ts + ...);
}
#else
template <class T0, class T1>
constexpr auto operator()(T0 const& t0, T1 const& t1) const
{
return t0 + t1;
return Math::sum(ts...);
}
template <class T0, class... Ts>
constexpr auto operator()(T0 const& t0, Ts const&... ts) const
{
return t0 + operator()(ts...);
}
#endif
};
#ifndef DOXYGEN
// [0] + g => g
template <class G>
struct ComposerBuilder<Plus, Zero, G>
: ComposerBuilder<Plus, G> {};
: ComposerBuilder<Id, G> {};
// g + [0] => g
template <class G>
struct ComposerBuilder<Plus, G, Zero>
: ComposerBuilder<Plus, G> {};
: ComposerBuilder<Id, G> {};
// [0] + [0] => [0]
template <>
......@@ -97,15 +83,10 @@ namespace AMDiS
};
#ifndef DOXYGEN
// [0] - g => -g
// template <class G>
// struct ComposerBuilder<Minus, Zero, G>
// : ComposerBuilder<Id, Negate> {};
// g - [0] => g
template <class G>
struct ComposerBuilder<Minus, G, Zero>
: ComposerBuilder<Minus, G> {};
: ComposerBuilder<Id, G> {};
// [0] - [0] => [0]
template <>
......@@ -169,14 +150,74 @@ namespace AMDiS
// -------------------------------------------------------------------------
/// Functor that represents A/B
struct Divides
{
template <class T, class S>
constexpr auto operator()(T const& lhs, S const& rhs) const
{
return lhs / rhs;
}
// d_0 f(x,y) = 1 / y
friend auto partial(Divides, index_t<0>)
{
return compose(Divides{}, One{}, Arg<1>{});
}
// d_1 f(x,y) = (y - x)/y^2
friend auto partial(Divides, index_t<1>);
};
// -------------------------------------------------------------------------
/// Functor that represents A-B
struct Negate
{
template <class T>
constexpr auto operator()(T const& x) const
{
return -x;
}
friend int order(Negate, int d)
{
return d;
}
friend auto partial(Negate, index_t<0>)
{
return StaticConstant<int,-1>{};
}
};
#ifndef DOXYGEN
// g + -h => g - h
template <class G>
struct ComposerBuilder<Plus, G, Negate>
: ComposerBuilder<Minus, G, Id> {};
// [0] - g => -g
template <class G>
struct ComposerBuilder<Minus, Zero, G>
: ComposerBuilder<Id, Negate> {};
// -(g - h) => (h - g)
template <>
struct ComposerBuilder<Negate, Minus>
: ComposerBuilder<Minus, Arg<1>, Arg<0>> {};
#endif
// -------------------------------------------------------------------------
// forward declaration
template <int p>
template <int p, bool positive>
struct PowImpl;
template <int p>
struct PowType
{
using type = PowImpl<p>;
using type = PowImpl<p, (p>0)>;
};
template <> struct PowType<1> { using type = Id; };
......@@ -189,10 +230,8 @@ namespace AMDiS
/// Functor that represents x^p
template <int p>
struct PowImpl
struct PowImpl<p, true>
{
static_assert(p > 1, "Exponent in power must be non-negative!");
template <class T>
constexpr auto operator()(T const& x) const
{
......@@ -210,14 +249,47 @@ namespace AMDiS
}
};
template <int p>
struct PowImpl<p, false>
: public Composer<Divides, One, Pow<-p>>
{
constexpr PowImpl()
: Composer<Divides, One, Pow<-p>>{}
{}
template <class T>
constexpr auto operator()(T const& x) const
{
return T(1) / Math::pow<-p>(x);
}
};
#ifndef DOXYGEN
// (x^p1)^p2 => x^(p1*p2)
template <int p1, bool pos1, int p2, bool pos2>
struct ComposerBuilder<PowImpl<p1,pos1>, PowImpl<p2,pos2>>
: ComposerBuilder<Id, Pow<p1*p2>> {};
// x^p * y^p => (x*y)^p
template <int p, bool pos>
struct ComposerBuilder<Multiplies, PowImpl<p,pos>, PowImpl<p,pos>>
: ComposerBuilder<Pow<p>, Multiplies> {};
#endif
// d_1 f(x,y) = (y - x)/y^2
auto partial(Divides, index_t<1>)
{
return compose(Divides{}, compose(Minus{}, Arg<1>{}, Arg<0>{}),
compose(Pow<2>{}, Arg<1>{}));
}
/// Functor that represents x^p, \see \ref Pow
struct Pow_
{
Pow_(int p)
: p_(p)
{
assert( p_ >= 0 );
}
{}
template <class T>
auto operator()(T const& x) const
......@@ -238,53 +310,6 @@ namespace AMDiS
int p_;
};
// -------------------------------------------------------------------------
/// Functor that represents A/B
struct Divides
{
template <class T, class S>
constexpr auto operator()(T const& lhs, S const& rhs) const
{
return lhs / rhs;
}
// d_0 f(x,y) = 1 / y
friend auto partial(Divides, index_t<0>)
{
return compose(Divides{}, One{}, Arg<1>{});
}
// d_1 f(x,y) = (y - x)/y^2
friend auto partial(Divides, index_t<1>)
{
return compose(Divides{}, compose(Minus{}, Arg<1>{}, Arg<0>{}),
compose(Pow<2>{}, Arg<1>{}));
}
};
// -------------------------------------------------------------------------
/// Functor that represents A-B
struct Negate
{
template <class T>
constexpr auto operator()(T const& x) const
{
return -x;
}
friend int order(Negate, int d)
{
return d;
}
friend auto partial(Negate, index_t<0>)
{
return StaticConstant<int,-1>{};
}
};
/** @} **/
} // end namespace Operation
......
#pragma once
#include <algorithm>
#include <utility>
#include <amdis/common/IndexSeq.hpp>
#include <amdis/common/Math.hpp>
#include <amdis/common/Mpl.hpp>
#include <amdis/common/Concepts.hpp>
#include <amdis/common/ScalarTypes.hpp>
#include <amdis/common/ConceptsBase.hpp>
namespace AMDiS
{
......@@ -16,13 +14,13 @@ namespace AMDiS
{
struct HasFunctorOrder
{
template <class F, std::size_t... I>
auto requires_(F&& f, Indices<I...>) -> decltype( order(f, int(I)...) );
template <class F, int... I>
auto requires_(F&& f, std::integer_sequence<int,I...>) -> decltype( order(f, I...) );
};
}
template <class F, std::size_t N>
constexpr bool HasFunctorOrder = models<Definition::HasFunctorOrder(F, MakeSeq_t<N>)>;
template <class F, int N>
constexpr bool HasFunctorOrder = models<Definition::HasFunctorOrder(F, std::make_integer_sequence<int,N>)>;
}
namespace Operation
......
......@@ -2,6 +2,7 @@
install(FILES
Arithmetic.hpp
Assigner.hpp
Basic.hpp
CMath.hpp
Composer.hpp
......
......@@ -90,30 +90,18 @@ namespace AMDiS
return std::atan2(x, y);
}
struct D0 {
template <class T1, class T2>
constexpr auto operator() (T1 const& x, T2 const& y) const
{
return -y/(Math::sqr(x) + Math::sqr(y));
}
};
// -y/(Math::sqr(x) + Math::sqr(y))
constexpr friend auto partial(Atan2, index_t<0>)
{
return D0{};
return compose(Divides{}, compose(Negate{}, Arg<1>{}),
compose(Plus{}, compose(Pow<2>{}, Arg<0>{}), compose(Pow<2>{}, Arg<1>{})));
}
struct D1 {
template <class T1, class T2>
constexpr auto operator() (T1 const& x, T2 const& y) const
{
return x/(Math::sqr(x) + Math::sqr(y));
}
};
// x/(Math::sqr(x) + Math::sqr(y));
constexpr friend auto partial(Atan2, index_t<1>)
{
return D1{};
return compose(Divides{}, Arg<0>{},
compose(Plus{}, compose(Pow<2>{}, Arg<0>{}), compose(Pow<2>{}, Arg<1>{})));
}
};
......@@ -121,11 +109,11 @@ namespace AMDiS
template <class T>
struct Clamp
{
Clamp(T const& lo, T const& hi)
constexpr Clamp(T const& lo, T const& hi)
: lo_(lo)
, hi_(hi)
{
assert(lo < hi);
// assert(lo < hi);
}
constexpr auto operator() (T const& v) const
......
......@@ -6,7 +6,6 @@
#include <dune/common/std/apply.hh>
#include <amdis/common/Concepts.hpp>
#include <amdis/common/IndexSeq.hpp>
#include <amdis/common/Mpl.hpp>
#include <amdis/operations/Basic.hpp>
......@@ -51,7 +50,7 @@ namespace AMDiS
/// Generator function for \ref composer
template <class F, class... Gs>
auto compose(F&& f, Gs&&... gs)
constexpr auto compose(F&& f, Gs&&... gs)
{
return ComposerBuilder<std::decay_t<F>, std::decay_t<Gs>...>::build(
std::forward<F>(f), std::forward<Gs>(gs)...);
......
#pragma once
#include <utility>
#include <amdis/operations/Composer.hpp>
#include <amdis/operations/Arithmetic.hpp>
......@@ -11,7 +12,7 @@ namespace AMDiS { namespace Operation {
template <int J, class F, class... Gs>
auto partial(Composer<F,Gs...> const& c, index_t<J> _j)
{
auto index_seq = MakeSeq_t<sizeof...(Gs)>{};
auto index_seq = std::make_index_sequence<sizeof...(Gs)>{};
// d_i(f)[g...] * d_j(g_i)
auto term_i = [&](auto const _i)
......
......@@ -20,7 +20,7 @@ namespace AMDiS
template <class T0, class T1, int N>
constexpr auto operator()(Dune::FieldVector<T0,N> const& lhs, Dune::FieldVector<T1,N> const& rhs) const
{
return dot(lhs, rhs);
return lhs.dot(rhs);
}
friend constexpr int order(Dot, int d1, int d2)
......@@ -67,7 +67,7 @@ namespace AMDiS
struct TwoNorm
: public Composer<Sqrt, UnaryDot>
{
TwoNorm()
constexpr TwoNorm()
: Composer<Sqrt, UnaryDot>(Sqrt{}, UnaryDot{})
{}
......
......@@ -10,7 +10,6 @@ namespace AMDiS
template <class T, class S>
constexpr auto operator()(T const& lhs, S const& rhs) const
{
static_assert(Concepts::LessThanComparable<T,S>, "Argument types are not comparable by <.");
return Math::max(lhs, rhs);
}
};
......@@ -23,7 +22,6 @@ namespace AMDiS
template <class T, class S>
constexpr auto operator()(T const& lhs, S const& rhs) const
{
static_assert(Concepts::LessThanComparable<T,S>, "Argument types are not comparable by <.");
return Math::min(lhs, rhs);
}
};
......
install(FILES
FiniteElementType.hpp
MultiIndex.hpp
RangeType.hpp
Traversal.hpp
TreeContainer.hpp
TreeData.hpp
TreePath.hpp
Visitor.hpp
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/amdis/typetree)
......@@ -2,6 +2,9 @@
#include <cmath>
#include <dune/common/typetraits.hh>
#include <dune/typetree/nodetags.hh>
#include <amdis/common/Loops.hpp>
#include <amdis/common/Mpl.hpp>
#include <amdis/common/Tags.hpp>
......@@ -10,10 +13,10 @@ namespace AMDiS
{
namespace Impl
{
template <class Node, bool isLeaf, bool isPower, bool isComposite>
template <class Node, class NodeTag>
struct FiniteElementTypeImpl
{
static_assert( isLeaf || isPower || isComposite, "Unknown node-type for range definition" );
static_assert( Dune::AlwaysFalse<NodeTag>::value, "Unknown node-type for range definition" );
// polynomial degree of finite-element basis functions
static int order(Node const&) { return 0; }
......@@ -22,7 +25,7 @@ namespace AMDiS
template <class Node>
using FiniteElementType =
Impl::FiniteElementTypeImpl<Node, Node::isLeaf, Node::isPower, Node::isComposite>;
Impl::FiniteElementTypeImpl<Node, typename Node::NodeTag>;
template <class Node>
using FiniteElementType_t = typename FiniteElementType<Node>::type;
......@@ -38,7 +41,7 @@ namespace AMDiS
{
// Leaf node
template <class Node>
struct FiniteElementTypeImpl<Node, true, false, false>
struct FiniteElementTypeImpl<Node, Dune::TypeTree::LeafNodeTag>
{
using type = typename Node::FiniteElement;
......@@ -50,7 +53,7 @@ namespace AMDiS
// Power node
template <class Node>
struct FiniteElementTypeImpl<Node, false, true, false>
struct FiniteElementTypeImpl<Node, Dune::TypeTree::PowerNodeTag>
{
using ChildNode = typename Node::template Child<0>::type;
using type = FiniteElementType_t<ChildNode>;
......@@ -63,7 +66,7 @@ namespace AMDiS
// Composite node
template <class Node>
struct FiniteElementTypeImpl<Node, false, false, true>
struct FiniteElementTypeImpl<Node, Dune::TypeTree::CompositeNodeTag>
{
using type = tag::unknown; // no common FiniteElement type
......
#pragma once
#include <type_traits>
#include <utility>
#include <dune/common/fvector.hh>
#include <dune/common/typetraits.hh>
#include <amdis/common/IndexSeq.hpp>
#include <amdis/common/MultiTypeVector.hpp>
namespace AMDiS
{
namespace Impl
{
template <class> struct always_false : std::false_type {};
template <class Node, class R, class NodeTag>
struct RangeTypeImpl
{
static_assert( always_false<NodeTag>::value, "Unknown node-type for range definition" );
static_assert( Dune::AlwaysFalse<NodeTag>::value, "Unknown node-type for range definition" );
};
}
......@@ -79,7 +78,7 @@ namespace AMDiS
using type = MultiTypeVector<RangeType_t<ChildNode<I>,R>...>;
};