KASKADE 7 development version
Loading...
Searching...
No Matches
variables.hh
Go to the documentation of this file.
1/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2/* */
3/* This file is part of the library KASKADE 7 */
4/* https://www.zib.de/research/projects/kaskade7-finite-element-toolbox */
5/* */
6/* Copyright (C) 2002-2025 Zuse Institute Berlin */
7/* */
8/* KASKADE 7 is distributed under the terms of the ZIB Academic License. */
9/* see $KASKADE/academic.txt */
10/* */
11/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
12
13#ifndef MULTIVARIATIONALUTIL_HH
14#define MULTIVARIATIONALUTIL_HH
15
16#include <algorithm>
17#include <array>
18#include <cassert>
19#include <iostream>
20
21#include <boost/fusion/algorithm.hpp>
22#include <boost/fusion/include/fold.hpp>
23#include <boost/fusion/include/make_vector.hpp>
24#include <boost/fusion/include/size.hpp>
25#include <boost/fusion/sequence.hpp>
26#include <boost/mpl/int.hpp>
27#include <boost/type_traits/remove_reference.hpp>
28#include <boost/type_traits/remove_const.hpp>
29
30
31#include "fem/fixdune.hh"
32#include "fem/functionspace.hh"
33#include "fem/linearspace.hh"
34#include "io/iobase.hh" // for paddedString
35#include "linalg/crsutil.hh"
36
50
51
52//---------------------------------------------------------------------
53
54namespace Kaskade
55{
74 template <int spaceId, int components, int Id=-1>
76 {
78 static int const id = Id;
80 static int const m = components;
82 static int const spaceIndex = spaceId;
83 };
84
85
91 template <int spaceIndex>
92 struct SpaceIndex : public VariableDescription<spaceIndex,-1,-1> {};
93
99 template <int components>
100 struct Components : public VariableDescription<-1,components,-1> {};
101
119 template <typename A, typename B>
120 struct Variable
121 {
122 static int const spaceIndex = A::spaceIndex>=0? A::spaceIndex : B::spaceIndex;
123 static int const m = A::m>=0? A::m : B::m;
124
125 static_assert(spaceIndex>=0,"Space index has to be nonnegative (space indices cover a contiguous range from 0 to k-1).");
126 static_assert(m>=0,"Number of components has to be nonnegative (in fact, 0 makes rarely sense as well).");
127
132 Variable(std::string const& name_)
133 : name(name_) {}
134
139 Variable() = default;
140
141 std::string name;
142 };
143
144
145 //---------------------------------------------------------------------
146
152 template <class Spaces>
154 {
155 ConstructElement(Spaces const& spaces_):
156 spaces(spaces_)
157 {}
158
164 template <typename Arg> struct result {};
165
166 template <class Variable>
168 {
169 typedef typename boost::remove_reference<Variable>::type Var;
171 typedef typename Space::template Element_t<Var::m> type;
172 };
173
177 template <class Variable>
179 {
180 return typename result<ConstructElement<Spaces>(Variable)>::type(*boost::fusion::at_c<Variable::spaceIndex>(spaces));
181 }
182
183 private:
184 Spaces const& spaces;
185 };
186
192 template <class Spaces>
194 {
195 ConstructCoefficientVector(Spaces const& spaces_):
196 spaces(spaces_)
197 {}
198
204 template <typename Arg> struct result {};
205
206 template <class Variable>
208 {
209 typedef typename boost::remove_reference<Variable>::type Var;
211 typedef typename Space::template Element_t<Var::m>::StorageType StorageType;
212
214 };
215
223 template <class Variable>
225 {
226 return typename result<ConstructCoefficientVector<Spaces>(Variable)>::type(boost::fusion::at_c<Variable::spaceIndex>(spaces)->degreesOfFreedom());
227 }
228
229 private:
230 Spaces const& spaces;
231 };
232
233 //---------------------------------------------------------------------
234
238 namespace Variables_Detail
239 {
240 using namespace boost::fusion;
241
242 // A functor constructing representations of consecutive subsets of variables
243 template <class Variables, class RepresentationConstructor,
244 int first=0, int last=result_of::size<Variables>::type::value>
245 class VariableRangeCreator
246 {
247 typedef typename result_of::begin<Variables>::type Begin;
248 typedef typename result_of::advance_c<Begin,first>::type First;
249 typedef typename result_of::advance_c<Begin,last>::type Last;
250
251 public:
252 typedef typename boost::fusion::transform_view<iterator_range<First,Last> const,
253 RepresentationConstructor> View;
254 using type = typename result_of::as_vector<View>::type;
255
256 static View apply(RepresentationConstructor const& c)
257 {
258 using namespace boost::fusion;
259 Variables vars;
260 return transform(iterator_range<First,Last>(advance_c<first>(begin(vars)),advance_c<last>(begin(vars))),c);
261 }
262 };
263
264 // Metafunction class for boost mpl transform. It takes a variable description and an id,
265 // and overwrites the variable id by the given id.
266 struct AddIdToVariableDescription
267 {
268 template <class Vd, class Int>
269 struct apply
270 {
271 using type = Kaskade::VariableDescription<Vd::spaceIndex, Vd::m, Int::value>;
272 };
273 };
274
275 // Given a type of a sequence of VariableDescriptions a new sequence type of
276 // VariableDescriptions is created where the id of each VariableDescription is
277 // the position in the sequence
278 template <typename IncompleteVariableDescriptions>
279 struct ImplicitIdVariableDescriptions
280 {
281 using size = typename result_of::size<IncompleteVariableDescriptions>::type;
282 using type = typename result_of::as_vector<typename boost::mpl::transform<IncompleteVariableDescriptions,
283 boost::mpl::range_c<int,0,size::value>,
284 AddIdToVariableDescription>::type
285 >::type;
286 };
287
288 // Given a sequence of variables and a sequence of spaces, returns the minimal
289 // continuity of all variables.
290 template <typename Variables, typename Spaces>
291 class Continuity
292 {
293 struct Min
294 {
295 template <typename C, typename Var>
296 auto operator()(C,Var) const
297 {
298 using SpacePtr = typename result_of::value_at_c<Spaces,Var::spaceIndex>::type;
299 constexpr int m = std::remove_pointer_t<SpacePtr>::continuity;
300 return typename boost::mpl::min<C,boost::mpl::int_<m>>::type();
301 }
302 };
303
304 public:
305 static int const value = result_of::fold<Variables,boost::mpl::int_<1000>,Min>::type::value;
306 };
307
308 }
312
313 //---------------------------------------------------------------------
314
334 template <class VSDescriptions>
335 class VariableSet: public LinearProductSpace<typename VSDescriptions::Scalar,
336 typename VSDescriptions::RepresentationData>
337 {
338 public:
340 typedef VSDescriptions Descriptions;
341
343 typedef typename VSDescriptions::RepresentationData Functions;
344
345 private:
346 typedef VariableSet<Descriptions> Self;
349
351 typedef typename Descriptions::Grid Grid;
352 using GridView = typename Descriptions::GridView;
353
354 public:
356
357 // No default constructor
358 VariableSet() = delete;
359
361 VariableSet(Self const& vs):
362 Base(vs.data), descriptions(vs.descriptions)
363 {
364 }
365
367 VariableSet(Self&& vs)
368 : Base(static_cast<Base&&>(vs)) // std::move doesn't work here, since VariableSet&&
369 , descriptions(vs.descriptions) // matches LinearProductSpace const& but not
370 { // LinearProductSpace&&.
371 }
372
380 explicit VariableSet(Descriptions const& d):
381 Base(Variables_Detail::VariableRangeCreator<typename Descriptions::Variables,ConstructElement<typename Descriptions::Spaces> >::apply(
382 ConstructElement<typename Descriptions::Spaces>(d.spaces))),
383 descriptions(&d)
384 {}
385
387 // TODO: Maybe switch to a (private) pointer member and provide a constant getter?
388 Self& operator=(Self const& v)
389 {
390 if (this!=&v)
391 {
392 this->data = v.data;
394 }
395 return *this;
396 }
397
399 Self& operator=(Self&& v)
400 {
401 if (this!=&v)
402 {
403 this->data = std::move(v.data);
404 descriptions = v.descriptions;
405 }
406 return *this;
407 }
408
417 template <class S>
418 Self& operator=(S const& s)
419 {
420 static_cast<Base&>(*this) = s;
421 return *this;
422 }
423
428
435 template <int i, class Evaluators>
436 auto value(Evaluators const& evals) const
437 {
438 static_assert(boost::fusion::result_of::size<Evaluators>::type::value==boost::fusion::result_of::size<typename Descriptions::Spaces>::type::value,
439 "Evaluators have to match the space list");
440 constexpr int spaceIndex = Descriptions::template spaceIndex<i>;
441 return component<i>(*this).value(boost::fusion::at_c<spaceIndex>(evals));
442 }
443
450 template <int i>
451 auto value(Cell<GridView> const& cell, LocalPosition<GridView> const& xi) const
452 {
453 return component<i>(*this).value(cell,xi);
454 }
455
462 template <int i>
463 auto value(GlobalPosition<GridView> const& x) const
464 {
465 return component<i>(*this).value(x);
466 }
467
471 template <int i, class Evaluators>
472 auto derivative(Evaluators const& evals) const
473 {
474 int const spaceIndex = Descriptions::template spaceIndex<i>;
475 return component<i>(*this).derivative(boost::fusion::at_c<spaceIndex>(evals));
476 }
477
481 template <int i>
482 auto derivative(Cell<GridView> const& cell, LocalPosition<GridView> const& xi) const
483 {
484 return component<i>(*this).derivative(cell,xi);
485 }
486
491 template <int i>
493 {
494 return component<i>(*this).derivative(x);
495 }
496
500 template <int i, class Evaluators>
501 auto hessian(Evaluators const& evals) const
502 {
503 int const spaceIndex = Descriptions::template spaceIndex<i>;
504 return component<i>(*this).hessian(boost::fusion::at_c<spaceIndex>(evals));
505 }
506
510 template <int i>
511 auto hessian(Cell<GridView> const& cell, LocalPosition<GridView> const& xi) const
512 {
513 return component<i>(*this).hessian(cell,xi);
514 }
515
520 template <int i>
522 {
523 return component<i>(*this).hessian(x);
524 }
525
527
530 };
531
532 //---------------------------------------------------------------------
533 //---------------------------------------------------------------------
534
535
552 template <class SpaceList, class VariableList>
554 {
555 public:
557 typedef SpaceList Spaces;
558
560 using Variables = typename Variables_Detail::ImplicitIdVariableDescriptions<VariableList>::type;
561
567 typedef typename Variables_Detail::VariableRangeCreator<Variables,ConstructElement<Spaces>>::type RepresentationData;
568
584
593
595 static int const noOfVariables = boost::fusion::result_of::size<Variables>::type::value;
596
604 static int const continuity = Variables_Detail::Continuity<Variables,Spaces>::value;
605
609 typedef typename boost::fusion::result_of::as_vector<
610 typename boost::fusion::result_of::transform<Spaces, GetEvaluators<ShapeFunctionCache<Grid,Scalar>> >::type
612
617
619 template <class RAIter>
620 VariableSetDescription(Spaces const& spaces_, RAIter nameIt):
622 {
623 std::copy(nameIt,nameIt+noOfVariables,names.begin());
624 }
625
632 VariableSetDescription(Spaces const& spaces_, std::vector<std::string> names_)
633 : VariableSetDescription(spaces_)
634 {
635 assert(names.size()==names_.size());
636 std::copy(names_.begin(),names_.end(),names.begin());
637 }
638
642 template <class RAIter>
643 VariableSetDescription(Spaces const& spaces_, RAIter nameIt, RAIter roleIt)
644 : VariableSetDescription(spaces_,nameIt)
645 {
646 std::copy(roleIt,roleIt+noOfVariables,roles.begin());
647 }
648
652 VariableSetDescription(Spaces const& spaces_, std::vector<std::string> names_, std::vector<std::string> roles_)
653 : VariableSetDescription(spaces_,names_)
654 {
655 std::copy(roles_.begin(),roles_.end(),roles.begin());
656 }
657
660 : spaces(spaces_)
661 , gridView(boost::fusion::at_c<0>(spaces_)->gridView())
662 , indexSet(boost::fusion::at_c<0>(spaces_)->indexSet())
663 {}
664
668
673
679 size_t degreesOfFreedom(int first=0, int last=noOfVariables) const
680 {
681 return degreesOfFreedom(spaces,first,last);
682 }
683
689 static size_t degreesOfFreedom(Spaces const& spaces, int first, int last)
690 {
691 auto dimensions = variableDimensions(spaces);
692 assert(0<=first && first<=last && last<=dimensions.size());
693 return std::accumulate(begin(dimensions)+first,begin(dimensions)+last,0);
694 }
695
699 static std::array<size_t,noOfVariables> variableDimensions(Spaces const& spaces, int first=0, int last=noOfVariables)
700 {
701 std::array<size_t,noOfVariables> dimensions;
702 boost::fusion::for_each(Variables(),ComputeDimension<noOfVariables>(dimensions,spaces));
703 return dimensions;
704 }
705
709 template <int i>
710 constexpr static int components = boost::fusion::result_of::value_at_c<Variables,i>::type::m;
711
713 template <int idx>
714 struct [[deprecated]] Components { static int const m = boost::fusion::result_of::value_at_c<Variables,idx>::type::m; };
715
719
731 template <int idx>
732 constexpr static int spaceIndex = boost::fusion::result_of::value_at_c<Variables,idx>::type::spaceIndex;
733
737 template <int idx>
738 struct [[deprecated]] SpaceIndex { static int const spaceIndex = boost::fusion::result_of::value_at_c<Variables,idx>::type::spaceIndex; };
739
740
744 template <int idx>
745 using Space = std::remove_pointer_t<typename boost::fusion::result_of::value_at_c<Spaces,spaceIndex<idx>>::type>;
746
751
752 private:
765 template <int first=0, int last=noOfVariables>
766 class CoefficientVectorRepresentation
767 {
768 using Creator = Variables_Detail::VariableRangeCreator<Variables,ConstructCoefficientVector<Spaces>,first,last>;
769
770 public:
778
784 static typename Creator::View init(Spaces const& spaces)
785 {
786 return Creator::apply(ConstructCoefficientVector<Spaces>(spaces));
787 }
788 };
789
790 public:
799 template <int first=0, int last=noOfVariables>
800 using CoefficientVector = typename CoefficientVectorRepresentation<first,last>::type;
801
805 template <int first=0, int last=noOfVariables>
807 {
808 using CVec = CoefficientVectorRepresentation<first,last>;
809 return typename CVec::type(CVec::init(spaces));
810 }
811
815 template <int first=0, int last=noOfVariables>
820
821
822
827 {
828 return VariableSet(*this);
829 }
830
834
839
844
848 GridManagerBase<Grid> const& gridManager() const { return boost::fusion::at_c<0>(spaces)->gridManager(); }
849
852
856 std::array<std::string,noOfVariables> names;
857
858 std::array<std::string,noOfVariables> roles;
859
860 private:
861
862 struct CheckHasEqualGridAndIndexSet
863 {
864 CheckHasEqualGridAndIndexSet(GridManagerBase<Grid> const* gp_, IndexSet const* isp_):
865 gp(gp_), isp(isp_)
866 {}
867
868 template <class Space>
869 void operator()(Space const* space) const {
870 assert(&(space->gridManager())== gp);
871 assert(&(space->indexSet()) == isp);
872 }
873
874 GridManagerBase<Grid> const* gp;
875 IndexSet const* isp;
876 };
877
878 template <int nvars>
879 struct ComputeDimension
880 {
881 ComputeDimension(std::array<size_t,nvars>& dims, Spaces const& spaces_):
882 dims_(dims), spaces(spaces_)
883 {}
884
885 template <class Variable>
886 void operator()(Variable const& /* v */) const
887 {
888 assert(dims_.size()>Variable::id);
889 dims_[Variable::id] = Variable::m * boost::fusion::at_c<Variable::spaceIndex>(spaces)->degreesOfFreedom();
890 }
891
892 std::array<size_t,nvars>& dims_;
893 Spaces const& spaces;
894 };
895
896 };
897
904 template <class VarSetDesc, int varIdx>
905 constexpr int spaceIndex = VarSetDesc::template spaceIndex<varIdx>;
906
907 //---------------------------------------------------------------------
908
909
922 template <class ...Spaces>
924 {
925 return boost::fusion::make_vector(const_cast<Spaces const*>(spaces)...);
926 }
927
941 template <class SpaceList, class VariableList>
943 VariableList const& vars)
944 {
945 using namespace boost::fusion;
946
947 // Extract the names of the variables.
948 std::vector<std::string> names;
949 for_each(vars,[&](auto var) { names.push_back(var.name); });
950 // If (some) variable names are not specified, assign default ones.
951 for (int i=0; i<names.size(); ++i)
952 if (names[i].empty())
953 names[i] = "var" + paddedString(i,2);
954
956 }
957
958
959 //------------------------------------------------------------------------------------------------
960 //------------------------------------------------------------------------------------------------
961
963 namespace Variables_Detail
964 {
965 template <class AnsatzVariables, class TestVariables>
966 auto makeAllSystemBlocks(AnsatzVariables a, TestVariables t)
967 {
968 using namespace boost::fusion;
969
970 auto appendRow = [=](auto blocks, auto rowVar)
971 {
972 auto thisRow = transform(a,[=](auto colVar)
973 { return std::pair(rowVar,colVar);
974 });
975 return join(blocks,thisRow);
976 };
977
978 return as_vector(accumulate(t,vector<>(),appendRow));
979 };
980 }
982
995 template <class AnsatzVariables, class TestVariables>
996 using AllSystemBlocks = decltype(Variables_Detail::makeAllSystemBlocks(AnsatzVariables(),
997 TestVariables()));
998
999 //------------------------------------------------------------------------------------------------
1000 //------------------------------------------------------------------------------------------------
1001
1002
1018 template <class Variables, class Functions, class Evaluators, class Method>
1019 auto evaluateFunctions(Functions const& fs,
1020 Evaluators const& eval,
1021 Method const& method = Method())
1022 {
1023 using namespace boost::fusion;
1024
1025 // Define the functor that evaluates the individual variables.
1026 auto doEval = [&] (auto const& pair)
1027 {
1028 // Extract the space index from the second component of the pair provided by zip.
1029 static int const sid = std::remove_reference_t<typename result_of::value_at_c<std::remove_reference_t<decltype(pair)>,1>::type>::spaceIndex;
1030 // Evaluate with evaluator corresponding to the function's space.
1031 return method(at_c<0>(pair),at_c<sid>(eval));
1032 };
1033
1034 // We need this as vector type to default construct an object for transform. This way we can submit
1035 // views (such as joint_view) as template parameter.
1036 using VarDesc = typename result_of::as_vector<Variables>::type;
1037
1038 // For evaluation, the corresponding evaluator must be used based on the space index of the variables. To provide this,
1039 // we zip the functions with their variable descriptions to pairs from which we can extract both function and space index.
1040 return as_vector(transform(zip(fs,VarDesc()),doEval));
1041 }
1042
1058 template <class VariableSet, class Method>
1060 typename VariableSet::Descriptions::Evaluators const& eval,
1061 Method const& method = Method())
1062 {
1064 }
1065
1076 template <class VariableSet, class Method>
1077 using EvaluateVariables = decltype(evaluateVariables(std::declval<VariableSet>(),
1078 std::declval<typename VariableSet::Descriptions::Evaluators>(),
1079 std::declval<Method>()));
1080
1081
1089 constexpr auto valueMethod = [](auto const& f, auto const& eval) { return f.value(eval); };
1090
1098 constexpr auto derivativeMethod = [](auto const& f, auto const& eval) { return f.derivative(eval); };
1099
1104 using ValueMethod = decltype(valueMethod);
1105
1111
1112} // end of namespace Kaskade
1113
1114
1115
1116
1117//---------------------------------------------------------------------
1118//---------------------------------------------------------------------
1119//---------------------------------------------------------------------
1120
1121#endif
Basic functionality for managing grids and their refinement.
VariableSet variableSet() const
Returns a zero-initialized variable set.
Definition variables.hh:826
static size_t degreesOfFreedom(Spaces const &spaces, int first, int last)
Computes the total number of scalar degrees of freedom collected in the variables [first,...
Definition variables.hh:689
VariableSetDescription(Spaces const &spaces_, RAIter nameIt, RAIter roleIt)
Constructor specifying for each variable both a name and a role.
Definition variables.hh:643
size_t degreesOfFreedom(int first=0, int last=noOfVariables) const
Computes the total number of scalar degrees of freedom collected in the variables [first,...
Definition variables.hh:679
GridManagerBase< Grid > const & gridManager() const
The gridManager keeping the grid on which we operate.
Definition variables.hh:848
VariableSetDescription(Spaces const &spaces_, std::vector< std::string > names_)
Constructor.
Definition variables.hh:632
auto zeroCoefficientVector() const
Returns a zero initialized coefficient vector for variables [first,last[.
Definition variables.hh:816
typename CoefficientVectorRepresentation< first, last >::type CoefficientVector
Definition variables.hh:800
boost::fusion::result_of::as_vector< typenameboost::fusion::result_of::transform< Spaces, GetEvaluators< ShapeFunctionCache< Grid, Scalar > > >::type >::type Evaluators
Definition variables.hh:611
Variables_Detail::VariableRangeCreator< Variables, ConstructElement< Spaces > >::type RepresentationData
Definition variables.hh:567
static std::array< size_t, noOfVariables > variableDimensions(Spaces const &spaces, int first=0, int last=noOfVariables)
Computes for each variable the number of scalar degrees of freedom.
Definition variables.hh:699
Kaskade::VariableSet< VariableSetDescription< Spaces, ErrorFunctionVariables > > VariableSet
Definition variables.hh:583
typename Variables_Detail::ImplicitIdVariableDescriptions< ErrorFunctionVariables >::type Variables
Definition variables.hh:560
std::remove_pointer_t< typename boost::fusion::result_of::value_at_c< Spaces, spaceIndex< idx > >::type > Space
Definition variables.hh:745
VariableSetDescription(Spaces const &spaces_, RAIter nameIt)
Constructor, giving each variable a name (e.g. for output purposes)
Definition variables.hh:620
VariableSetDescription(Spaces const &spaces_)
Constructor without naming the variables.
Definition variables.hh:659
static auto zeroCoefficientVector(Spaces const &spaces)
Returns a zero initialized coefficient vector for variables [first,last[.
Definition variables.hh:806
VariableSetDescription(Spaces const &spaces_, std::vector< std::string > names_, std::vector< std::string > roles_)
Constructor specifying for each variable both a name and a role.
Definition variables.hh:652
A class for storing a heterogeneous collection of FunctionSpaceElement s.
Definition variables.hh:337
auto derivative(GlobalPosition< GridView > const &x) const
derivative of an individual variable in the set. \WARNING This method is comparatively DEAD SLOW.
Definition variables.hh:492
VSDescriptions::RepresentationData Functions
boost::fusion::vector of data elements (of type FunctionSpaceElement)
Definition variables.hh:343
auto value(Cell< GridView > const &cell, LocalPosition< GridView > const &xi) const
Value of an individual variable in the set.
Definition variables.hh:451
VSDescriptions Descriptions
Type of the VariableSetDescription.
Definition variables.hh:340
VariableSet(Self const &vs)
Copy constructor.
Definition variables.hh:361
auto derivative(Evaluators const &evals) const
Derivative of an individual variable in the set.
Definition variables.hh:472
Descriptions const * descriptions
Definition variables.hh:529
auto hessian(Cell< GridView > const &cell, LocalPosition< GridView > const &xi) const
Hessian of an individual variable in the set.
Definition variables.hh:511
Self & operator=(S const &s)
Assignment from other (compatible) types.
Definition variables.hh:418
Self & operator=(Self &&v)
Move assignment.
Definition variables.hh:399
LinearProductSpace< Scalar, Functions > LinearSpace
Definition variables.hh:355
auto value(Evaluators const &evals) const
Value of an individual variable in the set.
Definition variables.hh:436
VariableSet(Self &&vs)
Move constructor.
Definition variables.hh:367
auto hessian(GlobalPosition< GridView > const &x) const
Hessian of an individual variable in the set. \WARNING This method is comparatively DEAD SLOW.
Definition variables.hh:521
auto value(GlobalPosition< GridView > const &x) const
Value of an individual variable in the set.
Definition variables.hh:463
VariableSet(Descriptions const &d)
Constructor.
Definition variables.hh:380
auto hessian(Evaluators const &evals) const
Hessian of an individual variable in the set.
Definition variables.hh:501
auto derivative(Cell< GridView > const &cell, LocalPosition< GridView > const &xi) const
Derivative of an individual variable in the set.
Definition variables.hh:482
Self & operator=(Self const &v)
Assignment.
Definition variables.hh:388
This file contains various utility functions that augment the basic functionality of Dune.
FEFunctionSpace and FunctionSpaceElement and the like.
std::string paddedString(int n, int places=3)
creates a zero-padded string representation of the given number
typename boost::fusion::result_of::as_vector< typename boost::fusion::result_of::transform< Spaces, GetEvaluatorTypes >::type >::type Evaluators
the heterogeneous sequence type of Evaluators for the given spaces
typename GridView::template Codim< 0 >::Entity Cell
The type of cells (entities of codimension 0) in the grid view.
Definition gridBasics.hh:35
Dune::FieldVector< typename GridView::ctype, GridView::dimensionworld > GlobalPosition
The type of global positions within the grid view.
Definition gridBasics.hh:50
Dune::FieldVector< typename GridView::ctype, GridView::dimension > LocalPosition
The type of local positions within cells of the grid view.
Definition gridBasics.hh:59
auto const & component(LinearProductSpace< Scalar, Sequence > const &x)
auto evaluateFunctions(Functions const &fs, Evaluators const &eval, Method const &method=Method())
A function evaulating all functions in a variable set using the provided method.
decltype(valueMethod) ValueMethod
The type of the valueMethod helper functor.
auto makeSpaceList(Spaces *... spaces)
Creates a list of finite element spaces in the required format. Usage example (for Stokes flow):
Definition variables.hh:923
constexpr auto valueMethod
Helper method for evaluating whole variable sets.
auto evaluateVariables(VariableSet const &vars, typename VariableSet::Descriptions::Evaluators const &eval, Method const &method=Method())
A function evaulating all functions in a variable set using the provided method.
decltype(derivativeMethod) DerivativeMethod
The type of the derivativeMethod helper functor.
VariableSetDescription< SpaceList, VariableList > makeVariableSetDescription(SpaceList const &spaces, VariableList const &vars)
Creates a variable set description from given spaces and variables.
Definition variables.hh:942
constexpr auto derivativeMethod
Helper method for evaluating whole variable sets.
decltype(Variables_Detail::makeAllSystemBlocks(AnsatzVariables(), TestVariables())) AllSystemBlocks
A type list of all possible variable combinations of the ansatz and test variables provided.
Definition variables.hh:996
decltype(evaluateVariables(std::declval< VariableSet >(), std::declval< typename VariableSet::Descriptions::Evaluators >(), std::declval< Method >())) EvaluateVariables
The type of evaluated variables as returned by evaluateVariables.
Output of mesh and solution for visualization software.
Helper class for specifying the number of components of a variable.
Definition variables.hh:100
A boost::fusion functor for generating coefficient vectors for given variables.
Definition variables.hh:194
ConstructCoefficientVector(Spaces const &spaces_)
Definition variables.hh:195
result< ConstructCoefficientVector< Spaces >(Variable)>::type operator()(Variable const &variable) const
Returns a FunctionSpaceElement from the FEFunctionSpace associated to the variable.
Definition variables.hh:224
For a given variable, defines the correct FunctionSpaceElement type.
Definition variables.hh:164
A boost::fusion functor for generating function space elements for given variables.
Definition variables.hh:154
ConstructElement(Spaces const &spaces_)
Definition variables.hh:155
result< ConstructElement< Spaces >(Variable)>::type operator()(Variable const &variable) const
Returns a FunctionSpaceElement element from the FEFunctionSpace associated to the Variable.
Definition variables.hh:178
Abstract base class of creators that can be registered at the pluggable factory.
Definition factory.hh:33
Helper class for specifying the FE space index of a variable.
Definition variables.hh:92
Extracts the type of FE space with given index from set of spaces.
std::remove_pointer_t< typename boost::fusion::result_of::value_at_c< Spaces, Idx >::type > type
A class storing elementary information about a single variable.This includes the number of components...
Definition variables.hh:76
static int const spaceIndex
number of the space, this variable is associated with
Definition variables.hh:82
static int const m
number of component of this variable
Definition variables.hh:80
A class defining elementary information about a single variable.
Definition variables.hh:121
std::string name
Definition variables.hh:141
Variable(std::string const &name_)
Constructor.
Definition variables.hh:132
static int const spaceIndex
Definition variables.hh:122
Variable()=default
Constructor. This will create a default name based on the variable id.
static int const m
Definition variables.hh:123
DEPRECATED, use components instead.
Definition variables.hh:714
DEPRECATED, use spaceIndex instead.
Definition variables.hh:738