│ │ │ │
│ │ │ │
│ │ │ │ -
4#ifndef DUNE_TYPETREE_TRANSFORMATION_HH
│ │ │ │ -
5#define DUNE_TYPETREE_TRANSFORMATION_HH
│ │ │ │ +
4#ifndef DUNE_TYPETREE_UTILITY_HH
│ │ │ │ +
5#define DUNE_TYPETREE_UTILITY_HH
│ │ │ │
│ │ │ │ -
│ │ │ │ +
│ │ │ │
│ │ │ │ -
│ │ │ │ +
│ │ │ │
│ │ │ │ -
│ │ │ │ -
12#include <dune/common/hybridutilities.hh>
│ │ │ │ -
13#include <dune/common/exceptions.hh>
│ │ │ │ -
14#include <dune/common/typetraits.hh>
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
51 template<
typename SourceNode,
typename Transformation,
typename Tag>
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
13#include <dune/common/shared_ptr.hh>
│ │ │ │ +
14#include <dune/common/indices.hh>
│ │ │ │ +
15#include <dune/common/hybridutilities.hh>
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
29 std::shared_ptr<T> convert_arg(
const T& t)
│ │ │ │ +
│ │ │ │ +
31 return std::make_shared<T>(t);
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
35 std::shared_ptr<T> convert_arg(T& t)
│ │ │ │ +
│ │ │ │ +
37 return stackobject_to_shared_ptr(t);
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
40 template<
typename BaseType,
typename T>
│ │ │ │ +
41 T& assertGridViewType(T& t)
│ │ │ │ +
│ │ │ │ +
43 static_assert((std::is_same<
typename BaseType::Traits::GridViewType,
│ │ │ │ +
44 typename T::Traits::GridViewType>::value),
│ │ │ │ +
45 "GridViewType must be equal in all components of composite type");
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
51 typename std::enable_if<!std::is_lvalue_reference<T>::value,std::shared_ptr<T> >::type convert_arg(T&& t)
│ │ │ │ +
│ │ │ │ +
53 return std::make_shared<T>(std::forward<T>(t));
│ │ │ │ +
│ │ │ │
│ │ │ │ -
66 template<
typename S,
typename T,
typename Tag>
│ │ │ │ -
67 struct LookupNodeTransformation
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
76 static_assert((!std::is_same<type,void>::value),
"Unable to find valid transformation descriptor");
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
92 template<
typename SourceTree,
typename Transformation,
typename Tag = StartTag,
bool recursive = true>
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
98 typedef typename LookupNodeTransformation<SourceTree,Transformation,typename SourceTree::ImplementationTag>::type NodeTransformation;
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ +
│ │ │ │ +
57 namespace Experimental {
│ │ │ │ +
│ │ │ │ +
67 template<
class BinaryOp,
class Arg>
│ │ │ │ +
68 constexpr decltype(
auto)
│ │ │ │ +
69 left_fold(BinaryOp&& binary_op, Arg&& arg)
│ │ │ │ +
│ │ │ │ +
71 return std::forward<Arg>(arg);
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
95 template<
class BinaryOp,
class Init,
class Arg0,
class... Args>
│ │ │ │ +
96 constexpr decltype(
auto)
│ │ │ │ +
97 left_fold(BinaryOp&& binary_op, Init&& init, Arg0&& arg_0, Args&&... args)
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
100 std::forward<BinaryOp>(binary_op),
│ │ │ │ +
101 binary_op(std::forward<Init>(init), std::forward<Arg0>(arg_0)),
│ │ │ │ +
102 std::forward<Args>(args)...);
│ │ │ │ +
│ │ │ │ +
│ │ │ │
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
114 static transformed_type
transform(
const SourceTree& s,
const Transformation& t = Transformation())
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
120 static transformed_type
transform(
const SourceTree& s, Transformation& t)
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
126 static transformed_type
transform(std::shared_ptr<const SourceTree> sp,
const Transformation& t = Transformation())
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
132 static transformed_type
transform(std::shared_ptr<const SourceTree> sp, Transformation& t)
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ +
│ │ │ │ +
107 using namespace Dune::Hybrid;
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
110 template<
class Op,
class... Args>
│ │ │ │ +
111 constexpr auto applyOperator(Op&& op, Args&&... args)
│ │ │ │ +
│ │ │ │ +
113 using T = std::common_type_t<Args...>;
│ │ │ │ +
114 return op(
static_cast<T
>(args)...);
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
117 template<
class Op,
class T, T... Args>
│ │ │ │ +
118 constexpr auto applyOperator(Op, std::integral_constant<T,Args>...)
│ │ │ │ +
│ │ │ │ +
120 static_assert(std::is_default_constructible_v<Op>,
│ │ │ │ +
121 "Operator in integral expressions shall be default constructible");
│ │ │ │ +
122 constexpr auto result = Op{}(T{Args}...);
│ │ │ │ +
123 return std::integral_constant<std::decay_t<
decltype(
result)>,
result>{};
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
128 template<
class... Args>
│ │ │ │ +
129 constexpr auto operator()(Args&&... args)
const
│ │ │ │ +
│ │ │ │ +
131 using T = std::common_type_t<Args...>;
│ │ │ │ +
132 return std::max({
static_cast<T
>(args)...});
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
│ │ │ │
│ │ │ │ -
│ │ │ │ -
139 static transformed_storage_type
transform_storage(std::shared_ptr<const SourceTree> sp,
const Transformation& t = Transformation())
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
146 static transformed_storage_type
transform_storage(std::shared_ptr<const SourceTree> sp, Transformation& t)
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ +
137 static constexpr auto max = [](
const auto& a,
const auto& b)
│ │ │ │ +
│ │ │ │ +
139 return Detail::applyOperator(Detail::Max{}, a, b);
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
142 static constexpr auto plus = [](
const auto& a,
const auto& b)
│ │ │ │ +
│ │ │ │ +
144 return Detail::applyOperator(std::plus<>{}, a, b);
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
147 static constexpr auto minus = [](
const auto& a,
const auto& b)
│ │ │ │ +
│ │ │ │ +
149 return Detail::applyOperator(std::minus<>{}, a, b);
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
│ │ │ │
│ │ │ │ -
│ │ │ │ -
157 template<
typename S,
typename T,
bool recursive>
│ │ │ │ -
158 struct TransformTree<S,T,LeafNodeTag,recursive>
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
161 typedef typename LookupNodeTransformation<S,T,ImplementationTag<S>>
::type NodeTransformation;
│ │ │ │ -
│ │ │ │ -
163 typedef typename NodeTransformation::transformed_type transformed_type;
│ │ │ │ -
164 typedef typename NodeTransformation::transformed_storage_type transformed_storage_type;
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
167 static transformed_type
transform(
const S& s, T& t)
│ │ │ │ -
│ │ │ │ -
169 return NodeTransformation::transform(s,t);
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
173 static transformed_type
transform(
const S& s,
const T& t)
│ │ │ │ -
│ │ │ │ -
175 return NodeTransformation::transform(s,t);
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
179 static transformed_type
transform(std::shared_ptr<const S> sp, T& t)
│ │ │ │ -
│ │ │ │ -
181 return NodeTransformation::transform(sp,t);
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
185 static transformed_type
transform(std::shared_ptr<const S> sp,
const T& t)
│ │ │ │ -
│ │ │ │ -
187 return NodeTransformation::transform(sp,t);
│ │ │ │ -
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
166 template<
typename Tree,
typename Tag = StartTag>
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
│ │ │ │
│ │ │ │ -
190 static transformed_storage_type
transform_storage(std::shared_ptr<const S> sp, T& t)
│ │ │ │ -
│ │ │ │ -
192 return NodeTransformation::transform_storage(sp,t);
│ │ │ │ -
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
│ │ │ │
│ │ │ │ -
195 static transformed_storage_type
transform_storage(std::shared_ptr<const S> sp,
const T& t)
│ │ │ │ -
│ │ │ │ -
197 return NodeTransformation::transform_storage(sp,t);
│ │ │ │ -
│ │ │ │ +
│ │ │ │ +
196 template<
typename Node>
│ │ │ │ +
│ │ │ │ +
│ │ │ │
│ │ │ │ -
│ │ │ │ +
200 static const std::size_t
depth = 1;
│ │ │ │
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
204 template<
typename S,
typename T>
│ │ │ │ -
205 struct TransformTreeNonRecursive
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
208 typedef typename LookupNodeTransformation<S,T,ImplementationTag<S>>::type NodeTransformation;
│ │ │ │ -
│ │ │ │ -
210 typedef typename NodeTransformation::transformed_type transformed_type;
│ │ │ │ -
211 typedef typename NodeTransformation::transformed_storage_type transformed_storage_type;
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
214 static transformed_type transform(
const S& s, T& t)
│ │ │ │ -
│ │ │ │ -
216 return NodeTransformation::transform(s,t);
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
220 static transformed_type transform(
const S& s,
const T& t)
│ │ │ │ -
│ │ │ │ -
222 return NodeTransformation::transform(s,t);
│ │ │ │ -
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
210 template<
typename Node>
│ │ │ │ +
211 struct TreeInfo<Node,PowerNodeTag>
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
214 typedef TreeInfo<typename Node::ChildType,NodeTag<typename Node::ChildType>> ChildInfo;
│ │ │ │ +
│ │ │ │ +
216 static const std::size_t
depth = 1 + ChildInfo::depth;
│ │ │ │ +
│ │ │ │ +
218 static const std::size_t
nodeCount = 1 + StaticDegree<Node>::value * ChildInfo::nodeCount;
│ │ │ │ +
│ │ │ │ +
220 static const std::size_t
leafCount = StaticDegree<Node>::value * ChildInfo::leafCount;
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
│ │ │ │
│ │ │ │ -
│ │ │ │ -
226 static transformed_type transform(std::shared_ptr<const S> sp, T& t)
│ │ │ │ -
│ │ │ │ -
228 return NodeTransformation::transform(sp,t);
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
232 static transformed_type transform(std::shared_ptr<const S> sp,
const T& t)
│ │ │ │ -
│ │ │ │ -
234 return NodeTransformation::transform(sp,t);
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
237 static transformed_storage_type transform_storage(std::shared_ptr<const S> sp, T& t)
│ │ │ │ -
│ │ │ │ -
239 return NodeTransformation::transform_storage(sp,t);
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
242 static transformed_storage_type transform_storage(std::shared_ptr<const S> sp,
const T& t)
│ │ │ │ -
│ │ │ │ -
244 return NodeTransformation::transform_storage(sp,t);
│ │ │ │ -
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
229 template<
typename Node, std::
size_t k, std::
size_t n>
│ │ │ │ +
230 struct generic_compositenode_children_info
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
233 typedef generic_compositenode_children_info<Node,k+1,n> NextChild;
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
236 typedef typename Node::template Child<k>::Type Child;
│ │ │ │ +
237 typedef NodeTag<Child> ChildTag;
│ │ │ │ +
238 typedef TreeInfo<Child,ChildTag> ChildInfo;
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
241 static const std::size_t maxDepth = ChildInfo::depth > NextChild::maxDepth ? ChildInfo::depth : NextChild::maxDepth;
│ │ │ │ +
│ │ │ │ +
243 static const std::size_t nodeCount = ChildInfo::nodeCount + NextChild::nodeCount;
│ │ │ │ +
│ │ │ │ +
245 static const std::size_t leafCount = ChildInfo::leafCount + NextChild::leafCount;
│ │ │ │
│ │ │ │ -
│ │ │ │ +
│ │ │ │
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
253 template<
class Source,
class Transformation,
class Tag>
│ │ │ │ -
254 class RecursivePowerTransformTree
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
257 static_assert(std::is_same_v<Tag,PowerNodeTag> or std::is_same_v<Tag,DynamicPowerNodeTag>);
│ │ │ │ -
│ │ │ │ -
259 using ChildType =
typename Source::ChildType;
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
262 template<
class NodeStorage>
│ │ │ │ -
263 static auto node_storage_provider(
const std::size_t& degree)
│ │ │ │ -
│ │ │ │ -
265 return std::vector<NodeStorage>(degree);
│ │ │ │ -
│ │ │ │ +
│ │ │ │ +
250 template<
typename Node, std::
size_t n>
│ │ │ │ +
251 struct generic_compositenode_children_info<Node,n,n>
│ │ │ │ +
│ │ │ │ +
253 static const std::size_t maxDepth = 0;
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
264 template<
typename Node>
│ │ │ │ +
265 struct GenericCompositeNodeInfo
│ │ │ │ +
│ │ │ │
│ │ │ │ -
│ │ │ │ -
269 template<
class NodeStorage,
class StaticIndex>
│ │ │ │ -
270 static auto node_storage_provider(StaticIndex)
│ │ │ │ -
│ │ │ │ -
272 return std::array<NodeStorage,std::size_t(StaticIndex{})>();
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
283 using NodeTransformation =
typename LookupNodeTransformation<Source,Transformation,ImplementationTag<Source>>::type;
│ │ │ │ -
284 using ChildNodeTransformation =
typename LookupNodeTransformation<ChildType,Transformation,ImplementationTag<ChildType>>::type;
│ │ │ │ +
268 typedef generic_compositenode_children_info<Node,0,StaticDegree<Node>::value> Children;
│ │ │ │ +
│ │ │ │ +
270 static const std::size_t
depth = 1 + Children::maxDepth;
│ │ │ │ +
│ │ │ │ +
272 static const std::size_t
nodeCount = 1 + Children::nodeCount;
│ │ │ │ +
│ │ │ │ +
274 static const std::size_t
leafCount = Children::leafCount;
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
280 template<
typename Node>
│ │ │ │ +
281 struct TreeInfo<Node,CompositeNodeTag>
│ │ │ │ +
282 :
public GenericCompositeNodeInfo<Node>
│ │ │ │ +
│ │ │ │ +
│ │ │ │
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
288 using ChildTreeTransformation = TransformTree<ChildType,
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
291 ChildNodeTransformation::recursive>;
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
294 using transformed_child_type =
typename ChildTreeTransformation::transformed_type;
│ │ │ │ -
295 using transformed_child_storage_type =
typename ChildTreeTransformation::transformed_storage_type;
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
298 using transformed_type =
typename NodeTransformation::template result<transformed_child_type>::type;
│ │ │ │ -
299 using transformed_storage_type =
typename NodeTransformation::template result<transformed_child_type>::storage_type;
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
302 static transformed_type transform(
const Source& source, Transformation& transformation)
│ │ │ │ -
│ │ │ │ -
304 auto children_storage = node_storage_provider<std::shared_ptr<transformed_child_type>>(source.degree());
│ │ │ │ -
305 for (std::size_t k = 0; k < source.degree(); ++k) {
│ │ │ │ -
306 children_storage[k] = ChildTreeTransformation::transform_storage(source.childStorage(k),transformation);
│ │ │ │ -
│ │ │ │ -
308 return NodeTransformation::transform(source,transformation,children_storage);
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
312 static transformed_type transform(
const Source& source,
const Transformation& transformation)
│ │ │ │ -
│ │ │ │ -
314 auto children_storage = node_storage_provider<std::shared_ptr<transformed_child_type>>(source.degree());
│ │ │ │ -
315 for (std::size_t k = 0; k < source.degree(); ++k) {
│ │ │ │ -
316 children_storage[k] = ChildTreeTransformation::transform_storage(source.childStorage(k),transformation);
│ │ │ │ -
│ │ │ │ -
318 return NodeTransformation::transform(source,transformation,children_storage);
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
322 static transformed_type transform(std::shared_ptr<const Source> source_ptr, Transformation& transformation)
│ │ │ │ -
│ │ │ │ -
324 auto children_storage = node_storage_provider<std::shared_ptr<transformed_child_type>>(source_ptr->degree());
│ │ │ │ -
325 for (std::size_t k = 0; k < source_ptr->degree(); ++k) {
│ │ │ │ -
326 children_storage[k] = ChildTreeTransformation::transform_storage(source_ptr->childStorage(k),transformation);
│ │ │ │ -
│ │ │ │ -
328 return NodeTransformation::transform(source_ptr,transformation,children_storage);
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
332 static transformed_type transform(std::shared_ptr<const Source> source_ptr,
const Transformation& transformation)
│ │ │ │ -
│ │ │ │ -
334 auto children_storage = node_storage_provider<std::shared_ptr<transformed_child_type>>(source_ptr->degree());
│ │ │ │ -
335 for (std::size_t k = 0; k < source_ptr->degree(); ++k) {
│ │ │ │ -
336 children_storage[k] = ChildTreeTransformation::transform_storage(source_ptr->childStorage(k),transformation);
│ │ │ │ -
│ │ │ │ -
338 return NodeTransformation::transform(source_ptr,transformation,children_storage);
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
342 static transformed_storage_type transform_storage(std::shared_ptr<const Source> source_ptr, Transformation& transformation)
│ │ │ │ -
│ │ │ │ -
344 auto children_storage = node_storage_provider<transformed_child_storage_type>(source_ptr->degree());
│ │ │ │ -
345 for (std::size_t k = 0; k < source_ptr->degree(); ++k) {
│ │ │ │ -
346 children_storage[k] = ChildTreeTransformation::transform_storage(source_ptr->childStorage(k),transformation);
│ │ │ │ -
│ │ │ │ -
348 return NodeTransformation::transform_storage(source_ptr,transformation,children_storage);
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
352 static transformed_storage_type transform_storage(std::shared_ptr<const Source> source_ptr,
const Transformation& transformation)
│ │ │ │ -
│ │ │ │ -
354 auto children_storage = node_storage_provider<transformed_child_storage_type>(source_ptr->degree());
│ │ │ │ -
355 for (std::size_t k = 0; k < source_ptr->degree(); ++k) {
│ │ │ │ -
356 children_storage[k] = ChildTreeTransformation::transform_storage(source_ptr->childStorage(k),transformation);
│ │ │ │ -
│ │ │ │ -
358 return NodeTransformation::transform_storage(source_ptr,transformation,children_storage);
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
365 template<
typename Source,
typename Transformation>
│ │ │ │ -
366 struct TransformTree<Source,Transformation,PowerNodeTag,true>
│ │ │ │ -
367 :
public Impl::RecursivePowerTransformTree<Source,Transformation,PowerNodeTag>
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
371 template<
typename Source,
typename Transformation>
│ │ │ │ -
372 struct TransformTree<Source,Transformation,DynamicPowerNodeTag,true>
│ │ │ │ -
373 :
public Impl::RecursivePowerTransformTree<Source,Transformation,DynamicPowerNodeTag>
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
377 template<
typename S,
typename T>
│ │ │ │ -
378 struct TransformTree<S,T,PowerNodeTag,false>
│ │ │ │ -
379 :
public TransformTreeNonRecursive<S,T>
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
383 template<
typename S,
typename T>
│ │ │ │ -
384 struct TransformTree<S,T,DynamicPowerNodeTag,false>
│ │ │ │ -
385 :
public TransformTreeNonRecursive<S,T>
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
393 template<
typename S,
typename Children,
typename T>
│ │ │ │ -
394 struct transform_composite_node;
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
399 template<
typename S,
typename T,
typename... C>
│ │ │ │ -
400 struct transform_composite_node<S,std::tuple<C...>,T>
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
404 typedef ImplementationTag<S> Tag;
│ │ │ │ -
405 typedef typename LookupNodeTransformation<S,T,Tag>::type NodeTransformation;
│ │ │ │ -
406 typedef typename NodeTransformation::template
result<
typename TransformTree<C,
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
409 LookupNodeTransformation<C,T,ImplementationTag<C>>::type::recursive
│ │ │ │ -
410 >::transformed_type...
│ │ │ │ -
411 >::type transformed_type;
│ │ │ │ -
│ │ │ │ -
413 typedef typename NodeTransformation::template
result<
typename TransformTree<C,
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
416 LookupNodeTransformation<C,T,ImplementationTag<C>>::type::recursive
│ │ │ │ -
417 >::transformed_type...
│ │ │ │ -
418 >::storage_type transformed_storage_type;
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
423 template<std::
size_t i>
│ │ │ │ -
424 struct ChildTransformation
│ │ │ │ -
425 :
public TransformTree<typename S::template Child<i>::Type,
│ │ │ │ -
│ │ │ │ -
427 NodeTag<typename S::template Child<i>::Type>,
│ │ │ │ -
428 LookupNodeTransformation<
│ │ │ │ -
429 typename S::template Child<i>::Type,
│ │ │ │ -
│ │ │ │ -
431 ImplementationTag<typename S::template Child<i>::Type>
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
436 template<std::
size_t i,
typename Tuple,
typename Value>
│ │ │ │ -
437 static void setElement(Tuple& tuple, Value&& value)
│ │ │ │ -
│ │ │ │ -
439 std::get<i>(tuple) = std::forward<Value>(value);
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
442 template<
typename Trafo, std::size_t... i>
│ │ │ │ -
443 static transformed_type transform(
const S& s, Trafo&& t, std::index_sequence<i...> indices)
│ │ │ │ -
│ │ │ │ -
445 std::tuple<typename ChildTransformation<i>::transformed_storage_type...> storage;
│ │ │ │ -
446 Dune::Hybrid::Impl::evaluateFoldExpression<int>({(setElement<i>(storage, ChildTransformation<i>::transform_storage(s.template childStorage<i>(), std::forward<Trafo>(t))),0)...});
│ │ │ │ -
447 return NodeTransformation::transform(s, std::forward<Trafo>(t), std::get<i>(storage)...);
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
450 template<
typename Trafo, std::size_t... i>
│ │ │ │ -
451 static transformed_storage_type transform_storage(std::shared_ptr<const S> sp, Trafo&& t, std::index_sequence<i...> indices)
│ │ │ │ -
│ │ │ │ -
453 std::tuple<typename ChildTransformation<i>::transformed_storage_type...> storage;
│ │ │ │ -
454 Dune::Hybrid::Impl::evaluateFoldExpression<int>({(setElement<i>(storage, ChildTransformation<i>::transform_storage(sp->template childStorage<i>(), std::forward<Trafo>(t))),0)...});
│ │ │ │ -
455 return NodeTransformation::transform_storage(sp, std::forward<Trafo>(t), std::get<i>(storage)...);
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
462 template<
typename S,
typename T>
│ │ │ │ -
463 struct TransformTree<S,T,CompositeNodeTag,true>
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
468 typedef typename S::ChildTypes ChildTypes;
│ │ │ │ -
│ │ │ │ -
470 static auto child_indices()
│ │ │ │ -
│ │ │ │ -
472 return std::make_index_sequence<S::degree()>();
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
477 typedef typename transform_composite_node<S,ChildTypes,T>::transformed_type transformed_type;
│ │ │ │ -
478 typedef typename transform_composite_node<S,ChildTypes,T>::transformed_storage_type transformed_storage_type;
│ │ │ │ -
│ │ │ │ -
480 static transformed_type
transform(
const S& s, T& t)
│ │ │ │ -
│ │ │ │ -
482 return transform_composite_node<S,ChildTypes,T>::transform(s,t,child_indices());
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
485 static transformed_type
transform(
const S& s,
const T& t)
│ │ │ │ -
│ │ │ │ -
487 return transform_composite_node<S,ChildTypes,T>::transform(s,t,child_indices());
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
490 static transformed_storage_type
transform_storage(std::shared_ptr<const S> sp, T& t)
│ │ │ │ -
│ │ │ │ -
492 return transform_composite_node<S,ChildTypes,T>::transform_storage(sp,t,child_indices());
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
495 static transformed_storage_type
transform_storage(std::shared_ptr<const S> sp,
const T& t)
│ │ │ │ -
│ │ │ │ -
497 return transform_composite_node<S,ChildTypes,T>::transform_storage(sp,t,child_indices());
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
503 template<
typename S,
typename T>
│ │ │ │ -
504 struct TransformTree<S,T,CompositeNodeTag,false>
│ │ │ │ -
505 :
public TransformTreeNonRecursive<S,T>
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
static const result_type result
Definition accumulate_static.hh:110
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
void registerNodeTransformation(SourceNode *, Transformation *, Tag *)
Register transformation descriptor to transform SourceNode with Transformation.
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
289 using Dune::index_constant;
│ │ │ │ +
290 namespace Indices = Dune::Indices;
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
static const result_type result
Definition accumulate_static.hh:110
│ │ │ │
Definition accumulate_static.hh:13
│ │ │ │ -
Transform a TypeTree.
Definition transformation.hh:94
│ │ │ │ -
type Type
Definition transformation.hh:111
│ │ │ │ -
static transformed_type transform(std::shared_ptr< const SourceTree > sp, Transformation &t)
Apply transformation to an existing tree s.
Definition transformation.hh:132
│ │ │ │ -
static transformed_type transform(std::shared_ptr< const SourceTree > sp, const Transformation &t=Transformation())
Apply transformation to an existing tree s.
Definition transformation.hh:126
│ │ │ │ -
static transformed_type transform(const SourceTree &s, Transformation &t)
Apply transformation to an existing tree s.
Definition transformation.hh:120
│ │ │ │ -
transformed_type type
The type of the transformed tree.
Definition transformation.hh:109
│ │ │ │ -
static transformed_type transform(const SourceTree &s, const Transformation &t=Transformation())
Apply transformation to an existing tree s.
Definition transformation.hh:114
│ │ │ │ -
static transformed_storage_type transform_storage(std::shared_ptr< const SourceTree > sp, const Transformation &t=Transformation())
Definition transformation.hh:139
│ │ │ │ -
static transformed_storage_type transform_storage(std::shared_ptr< const SourceTree > sp, Transformation &t)
Definition transformation.hh:146
│ │ │ │ -
Meta function that evaluates its argument iff it inherits from meta_function.
Definition typetraits.hh:140
│ │ │ │ +
auto leafCount(const Tree &tree)
The number of leaf nodes in the Tree.
Definition visitor.hh:530
│ │ │ │ +
auto nodeCount(const Tree &tree)
The total number of nodes in the Tree.
Definition visitor.hh:522
│ │ │ │ +
auto depth(const Tree &tree)
The depth of the TypeTree.
Definition visitor.hh:506
│ │ │ │ +
Tag designating a leaf node.
Definition nodetags.hh:16
│ │ │ │ +
Struct for obtaining some basic structural information about a TypeTree.
Definition utility.hh:168
│ │ │ │ +
static const std::size_t leafCount
The number of leaf nodes in the TypeTree.
Definition utility.hh:183
│ │ │ │ +
static const std::size_t depth
The depth of the TypeTree.
Definition utility.hh:177
│ │ │ │ +
static const std::size_t nodeCount
The total number of nodes in the TypeTree.
Definition utility.hh:180
│ │ │ │