KASKADE 7 development version
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-2024 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
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
105 template <int id>
106 struct [[deprecated]] VariableId : public VariableDescription<-1,-1,id> {};
107
108
126 template <typename A, typename B, typename C = VariableDescription<-1, -1, -1>>
127 struct Variable
128 {
129 static int const spaceIndex = A::spaceIndex>=0? A::spaceIndex : B::spaceIndex>=0? B::spaceIndex : C::spaceIndex;
130 static int const m = A::m>=0? A::m : B::m>=0? B::m : C::m;
131
132 static_assert(spaceIndex>=0,"Space index has to be nonnegative (space indices cover a contiguous range from 0 to k-1).");
133 static_assert(m>=0,"Number of components has to be nonnegative (in fact, 0 makes rarely sense as well).");
134
139 Variable(std::string const& name_)
140 : name(name_) {}
141
146 Variable() = default;
147
148 std::string name;
149 };
150
151
152 //---------------------------------------------------------------------
153
159 template <class Spaces>
161 {
162 ConstructElement(Spaces const& spaces_):
163 spaces(spaces_)
164 {}
165
171 template <typename Arg> struct result {};
172
173 template <class Variable>
175 {
176 typedef typename boost::remove_reference<Variable>::type Var;
178 typedef typename Space::template Element<Var::m>::type type;
179 };
180
184 template <class Variable>
185 typename result<ConstructElement<Spaces>(Variable)>::type operator()(Variable const& variable) const
186 {
187 return typename result<ConstructElement<Spaces>(Variable)>::type(*boost::fusion::at_c<Variable::spaceIndex>(spaces));
188 }
189
190 private:
191 Spaces const& spaces;
192 };
193
199 template <class Spaces>
201 {
202 ConstructCoefficientVector(Spaces const& spaces_):
203 spaces(spaces_)
204 {}
205
211 template <typename Arg> struct result {};
212
213 template <class Variable>
215 {
216 typedef typename boost::remove_reference<Variable>::type Var;
218 typedef typename Space::template Element<Var::m>::type::StorageType StorageType;
219
221 };
222
230 template <class Variable>
232 {
233 return typename result<ConstructCoefficientVector<Spaces>(Variable)>::type(boost::fusion::at_c<Variable::spaceIndex>(spaces)->degreesOfFreedom());
234 }
235
236 private:
237 Spaces const& spaces;
238 };
239
240 //---------------------------------------------------------------------
241
245 namespace Variables_Detail
246 {
247 using namespace boost::fusion;
248
249 // A functor constructing representations of consecutive subsets of variables
250 template <class Variables, class RepresentationConstructor,
251 int first=0, int last=result_of::size<Variables>::type::value>
252 class VariableRangeCreator
253 {
254 typedef typename result_of::begin<Variables>::type Begin;
255 typedef typename result_of::advance_c<Begin,first>::type First;
256 typedef typename result_of::advance_c<Begin,last>::type Last;
257
258 public:
259 typedef typename boost::fusion::transform_view<iterator_range<First,Last> const,
260 RepresentationConstructor> View;
261 using type = typename result_of::as_vector<View>::type;
262
263 static View apply(RepresentationConstructor const& c)
264 {
265 using namespace boost::fusion;
266 Variables vars;
267 return transform(iterator_range<First,Last>(advance_c<first>(begin(vars)),advance_c<last>(begin(vars))),c);
268 }
269 };
270
271 // Metafunction class for boost mpl transform. It takes a variable description and an id,
272 // and overwrites the variable id by the given id.
273 struct AddIdToVariableDescription
274 {
275 template <class Vd, class Int>
276 struct apply
277 {
279 };
280 };
281
282 // Given a type of a sequence of VariableDescriptions a new sequence type of VariableDescriptions is created
283 // where the id of each VariableDescription is the position in the sequence
284 template <typename IncompleteVariableDescriptions>
285 struct ImplicitIdVariableDescriptions
286 {
287 using size = typename result_of::size<IncompleteVariableDescriptions>::type;
288 using type = typename result_of::as_vector<typename boost::mpl::transform<IncompleteVariableDescriptions,
289 boost::mpl::range_c<int,0,size::value>,
290 AddIdToVariableDescription>::type
291 >::type;
292 };
293
294 // Given a sequence of variables and a sequence of spaces, returns the minimal
295 // continuity of all variables.
296 template <typename Variables, typename Spaces>
297 class Continuity
298 {
299 struct Min
300 {
301 template <typename C, typename Var>
302 auto operator()(C,Var) const
303 {
304 using SpacePtr = typename result_of::value_at_c<Spaces,Var::spaceIndex>::type;
305 constexpr int m = std::remove_pointer_t<SpacePtr>::continuity;
306 return typename boost::mpl::min<C,boost::mpl::int_<m>>::type();
307 }
308 };
309
310 public:
311 static int const value = result_of::fold<Variables,boost::mpl::int_<1000>,Min>::type::value;
312 };
313
314 }
319 //---------------------------------------------------------------------
320
338 template <class VSDescriptions>
339 class VariableSet: public LinearProductSpace<typename VSDescriptions::Scalar,
340 typename VSDescriptions::RepresentationData>
341 {
342 public:
344 typedef VSDescriptions Descriptions;
345
347 typedef typename VSDescriptions::RepresentationData Functions;
348
349 private:
353
355 typedef typename Descriptions::Grid Grid;
356 using GridView = typename Descriptions::GridView;
357
358 public:
360
362 VariableSet(Self const& vs):
364 {}
365
372 explicit VariableSet(Descriptions const& d):
373 Base(Variables_Detail::VariableRangeCreator<typename Descriptions::Variables,ConstructElement<typename Descriptions::Spaces> >::apply(
374 ConstructElement<typename Descriptions::Spaces>(d.spaces))),
375 descriptions(d)
376 {}
377
379 // TODO: The reference to the variable set description is not modified. Danger is,
380 // that the assigned-to function space elements are now elements from different spaces
381 // than before (and stated by the variable set description). Maybe switch to a (private)
382 // pointer member and provide a constant getter?
383 Self& operator=(Self const& v)
384 {
385 if (this!=&v)
386 this->data = v.data;
387 return *this;
388 }
389
398 template <class S>
399 Self& operator=(S const& s)
400 {
401 static_cast<Base&>(*this) = s;
402 return *this;
403 }
404
416 template <int i, class Evaluators>
417 auto value(Evaluators const& evals) const
418 {
419 static_assert(boost::fusion::result_of::size<Evaluators>::type::value==boost::fusion::result_of::size<typename Descriptions::Spaces>::type::value,
420 "Evaluators have to match the space list");
421 constexpr int spaceIndex = Descriptions::template spaceIndex<i>;
422 return component<i>(*this).value(boost::fusion::at_c<spaceIndex>(evals));
423 }
424
431 template <int i>
432 auto value(Cell<GridView> const& cell, LocalPosition<GridView> const& xi) const
433 {
434 return component<i>(*this).value(cell,xi);
435 }
436
443 template <int i>
444 auto value(GlobalPosition<GridView> const& x) const
445 {
446 return component<i>(*this).value(x);
447 }
448
452 template <int i, class Evaluators>
453 auto derivative(Evaluators const& evals) const
454 {
455 int const spaceIndex = Descriptions::template spaceIndex<i>;
456 return component<i>(*this).derivative(boost::fusion::at_c<spaceIndex>(evals));
457 }
458
462 template <int i>
463 auto derivative(Cell<GridView> const& cell, LocalPosition<GridView> const& xi) const
464 {
465 return component<i>(*this).derivative(cell,xi);
466 }
467
472 template <int i>
474 {
475 return component<i>(*this).derivative(x);
476 }
477
481 template <int i, class Evaluators>
482 auto hessian(Evaluators const& evals) const
483 {
484 int const spaceIndex = Descriptions::template spaceIndex<i>;
485 return component<i>(*this).hessian(boost::fusion::at_c<spaceIndex>(evals));
486 }
487
491 template <int i>
492 auto hessian(Cell<GridView> const& cell, LocalPosition<GridView> const& xi) const
493 {
494 return component<i>(*this).hessian(cell,xi);
495 }
496
501 template <int i>
503 {
504 return component<i>(*this).hessian(x);
505 }
506
508
511 };
512
513 //---------------------------------------------------------------------
514 //---------------------------------------------------------------------
515
516
535 template <class SpaceList, class VariableList>
537 {
538 public:
540 typedef SpaceList Spaces;
541
543 using Variables = typename Variables_Detail::ImplicitIdVariableDescriptions<VariableList>::type;
544
550 typedef typename Variables_Detail::VariableRangeCreator<Variables,ConstructElement<Spaces>>::type RepresentationData;
551
567
576
578 static int const noOfVariables = boost::fusion::result_of::size<Variables>::type::value;
579
586 static int const continuity = Variables_Detail::Continuity<Variables,Spaces>::value;
587
591 typedef typename boost::fusion::result_of::as_vector<
592 typename boost::fusion::result_of::transform<Spaces, GetEvaluators<ShapeFunctionCache<Grid,Scalar>> >::type
593 >::type Evaluators;
594
601 template <class RAIter>
602 VariableSetDescription(Spaces const& spaces_, RAIter nameIt):
604 {
605 std::copy(nameIt,nameIt+noOfVariables,names.begin());
606 }
607
614 VariableSetDescription(Spaces const& spaces_, std::vector<std::string> names_)
615 : VariableSetDescription(spaces_)
616 {
617 assert(names.size()==names_.size());
618 std::copy(names_.begin(),names_.end(),names.begin());
619 }
620
624 template <class RAIter>
625 VariableSetDescription(Spaces const& spaces_, RAIter nameIt, RAIter roleIt)
626 : VariableSetDescription(spaces_,nameIt)
627 {
628 std::copy(roleIt,roleIt+noOfVariables,roles.begin());
629 }
630
634 VariableSetDescription(Spaces const& spaces_, std::vector<std::string> names_, std::vector<std::string> roles_)
635 : VariableSetDescription(spaces_,names_)
636 {
637 std::copy(roles_.begin(),roles_.end(),roles.begin());
638 }
639
642 : spaces(spaces_)
643 , gridView(boost::fusion::at_c<0>(spaces_)->gridView())
644 , indexSet(boost::fusion::at_c<0>(spaces_)->indexSet())
645 {}
646
661 size_t degreesOfFreedom(int first=0, int last=noOfVariables) const
662 {
663 return degreesOfFreedom(spaces,first,last);
664 }
665
671 static size_t degreesOfFreedom(Spaces const& spaces, int first, int last)
672 {
673 auto dimensions = variableDimensions(spaces);
674 assert(0<=first && first<=last && last<=dimensions.size());
675 return std::accumulate(begin(dimensions)+first,begin(dimensions)+last,0);
676 }
677
681 static std::array<size_t,noOfVariables> variableDimensions(Spaces const& spaces, int first=0, int last=noOfVariables)
682 {
683 std::array<size_t,noOfVariables> dimensions;
684 boost::fusion::for_each(Variables(),ComputeDimension<noOfVariables>(dimensions,spaces));
685 return dimensions;
686 }
687
691 template <int i>
692 constexpr static int components = boost::fusion::result_of::value_at_c<Variables,i>::type::m;
693
695 template <int idx>
696 struct [[deprecated]] Components { static int const m = boost::fusion::result_of::value_at_c<Variables,idx>::type::m; };
697
713 template <int idx>
714 constexpr static int spaceIndex = boost::fusion::result_of::value_at_c<Variables,idx>::type::spaceIndex;
715
719 template <int idx>
720 struct [[deprecated]] SpaceIndex { static int const spaceIndex = boost::fusion::result_of::value_at_c<Variables,idx>::type::spaceIndex; };
721
722
726 template <int idx>
727 using Space = std::remove_pointer_t<typename boost::fusion::result_of::value_at_c<Spaces,SpaceIndex<idx>::spaceIndex>::type>;
728
746 template <int first=0, int last=noOfVariables>
748 {
749 using Creator = Variables_Detail::VariableRangeCreator<Variables,ConstructCoefficientVector<Spaces>,first,last>;
750
751 public:
759
765 static typename Creator::View init(Spaces const& spaces)
766 {
767 return Creator::apply(ConstructCoefficientVector<Spaces>(spaces));
768 }
769 };
770
779 template <int first=0, int last=noOfVariables>
781
785 template <int first=0, int last=noOfVariables>
787 {
789 return typename CVec::type(CVec::init(spaces));
790 }
791
796 {
797 return VariableSet(*this);
798 }
799
808
813
817 GridManagerBase<Grid> const& gridManager() const { return boost::fusion::at_c<0>(spaces)->gridManager(); }
818
821
825 std::array<std::string,noOfVariables> names;
826
827 std::array<std::string,noOfVariables> roles;
828
829 private:
830
831 struct CheckHasEqualGridAndIndexSet
832 {
833 CheckHasEqualGridAndIndexSet(GridManagerBase<Grid> const* gp_, IndexSet const* isp_):
834 gp(gp_), isp(isp_)
835 {}
836
837 template <class Space>
838 void operator()(Space const* space) const {
839 assert(&(space->gridManager())== gp);
840 assert(&(space->indexSet()) == isp);
841 }
842
843 GridManagerBase<Grid> const* gp;
844 IndexSet const* isp;
845 };
846
847 template <int nvars>
848 struct ComputeDimension
849 {
850 ComputeDimension(std::array<size_t,nvars>& dims, Spaces const& spaces_):
851 dims_(dims), spaces(spaces_)
852 {}
853
854 template <class Variable>
855 void operator()(Variable const& /* v */) const
856 {
857 assert(dims_.size()>Variable::id);
858 dims_[Variable::id] = Variable::m * boost::fusion::at_c<Variable::spaceIndex>(spaces)->degreesOfFreedom();
859 }
860
861 std::array<size_t,nvars>& dims_;
862 Spaces const& spaces;
863 };
864
865 };
866
873 template <class VarSetDesc, int varIdx>
874 constexpr int spaceIndex = VarSetDesc::template spaceIndex<varIdx>;
875
876 //---------------------------------------------------------------------
877
878
891 template <class ...Spaces>
892 auto makeSpaceList(Spaces*... spaces)
893 {
894 return boost::fusion::make_vector(const_cast<Spaces const*>(spaces)...);
895 }
896
910 template <class SpaceList, class VariableList>
912 VariableList const& vars)
913 {
914 using namespace boost::fusion;
915
916 // Extract the names of the variables.
917 std::vector<std::string> names;
918 for_each(vars,[&](auto var) { names.push_back(var.name); });
919 // If (some) variable names are not specified, assign default ones.
920 for (int i=0; i<names.size(); ++i)
921 if (names[i].empty())
922 names[i] = "var" + paddedString(i,2);
923
925 }
926
927
928 //---------------------------------------------------------------------
929 //---------------------------------------------------------------------
930
931
947 template <class Variables, class Functions, class Evaluators, class Method>
948 auto evaluateFunctions(Functions const& fs,
949 Evaluators const& eval,
950 Method const& method = Method())
951 {
952 using namespace boost::fusion;
953
954 // Define the functor that evaluates the individual variables.
955 auto doEval = [&] (auto const& pair)
956 {
957 // Extract the space index from the second component of the pair provided by zip.
958 static int const sid = std::remove_reference_t<typename result_of::value_at_c<std::remove_reference_t<decltype(pair)>,1>::type>::spaceIndex;
959 // Evaluate with evaluator corresponding to the function's space.
960 return method(at_c<0>(pair),at_c<sid>(eval));
961 };
962
963 // We need this as vector type to default construct an object for transform. This way we can submit
964 // views (such as joint_view) as template parameter.
965 using VarDesc = typename result_of::as_vector<Variables>::type;
966
967 // For evaluation, the corresponding evaluator must be used based on the space index of the variables. To provide this,
968 // we zip the functions with their variable descriptions to pairs from which we can extract both function and space index.
969 return as_vector(transform(zip(fs,VarDesc()),doEval));
970 }
971
987 template <class VariableSet, class Method>
989 typename VariableSet::Descriptions::Evaluators const& eval,
990 Method const& method = Method())
991 {
992 return evaluateFunctions<typename VariableSet::Descriptions::Variables>(vars.data,eval,method);
993 }
994
1005 template <class VariableSet, class Method>
1006 using EvaluateVariables = decltype(evaluateVariables(std::declval<VariableSet>(),
1007 std::declval<typename VariableSet::Descriptions::Evaluators>(),
1008 std::declval<Method>()));
1009
1010
1018 constexpr auto valueMethod = [](auto const& f, auto const& eval) { return f.value(eval); };
1019
1027 constexpr auto derivativeMethod = [](auto const& f, auto const& eval) { return f.derivative(eval); };
1028
1033 using ValueMethod = decltype(valueMethod);
1034
1040
1041} // end of namespace Kaskade
1042
1043
1044
1045
1046//---------------------------------------------------------------------
1047//---------------------------------------------------------------------
1048//---------------------------------------------------------------------
1049
1050#endif
Typedefs for coefficient vector representations of contiguous subranges of the variables.
Definition: variables.hh:748
static Creator::View init(Spaces const &spaces)
Returns a (small) initializer object for coefficient vectors.
Definition: variables.hh:765
A class that stores information about a set of variables.
Definition: variables.hh:537
GridView const & gridView
The grid view on which the variables live.
Definition: variables.hh:812
VariableSet variableSet() const
Returns a zero-initialized variable set.
Definition: variables.hh:795
std::remove_pointer_t< typename boost::fusion::result_of::value_at_c< Spaces, SpaceIndex< idx >::spaceIndex >::type > Space
The type of finite element space of the i-th variable.
Definition: variables.hh:727
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:671
VariableSetDescription(Spaces const &spaces_, RAIter nameIt, RAIter roleIt)
Constructor specifying for each variable both a name and a role.
Definition: variables.hh:625
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:661
std::array< std::string, noOfVariables > names
A sequence of variable names.
Definition: variables.hh:825
IndexSet const & indexSet
index set
Definition: variables.hh:820
GridManagerBase< Grid > const & gridManager() const
The gridManager keeping the grid on which we operate.
Definition: variables.hh:817
VariableSetDescription(Spaces const &spaces_, std::vector< std::string > names_)
Constructor.
Definition: variables.hh:614
auto zeroCoefficientVector() const
Returns a zero initialized coefficient vector for variables [first,last[.
Definition: variables.hh:786
std::array< std::string, noOfVariables > roles
Definition: variables.hh:827
static int const continuity
minimal continuity of any variable in the set
Definition: variables.hh:586
typename CoefficientVectorRepresentation< first, last >::type CoefficientVector
The type of coefficient vectors of variable sets (and subsets).
Definition: variables.hh:780
static constexpr int components
number of components of i'th variable
Definition: variables.hh:692
static int const noOfVariables
Number of variables in this set.
Definition: variables.hh:578
boost::fusion::result_of::as_vector< typenameboost::fusion::result_of::transform< Spaces, GetEvaluators< ShapeFunctionCache< Grid, Scalar > > >::type >::type Evaluators
The boost::fusion sequence of evaluators belonging to this variable set.
Definition: variables.hh:593
Variables_Detail::VariableRangeCreator< Variables, ConstructElement< Spaces > >::type RepresentationData
Type that contains a set of variables inside a boost vector, together with all the data.
Definition: variables.hh:550
SpaceList Spaces
type of boost::fusion::vector of FEFunctionSpace s needed
Definition: variables.hh:540
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:681
Kaskade::VariableSet< VariableSetDescription< Spaces, VariableList > > VariableSet
Type that contains a set of variable values with some functionality, such as simple vector arithmetic...
Definition: variables.hh:566
Spaces spaces
A heterogeneous sequence of pointers to (const) spaces involved.
Definition: variables.hh:807
typename Variables_Detail::ImplicitIdVariableDescriptions< VariableList >::type Variables
type of boost::fusion vector of VariableDescription s
Definition: variables.hh:543
SpaceType< Spaces, 0 >::type::Grid Grid
Grid type.
Definition: variables.hh:571
static constexpr int spaceIndex
space index of the i'th variable
Definition: variables.hh:714
SpaceType< Spaces, 0 >::type::Scalar Scalar
scalar field type
Definition: variables.hh:569
SpaceType< Spaces, 0 >::type::IndexSet IndexSet
IndexSet type.
Definition: variables.hh:575
SpaceType< Spaces, 0 >::type::GridView GridView
Grid view type.
Definition: variables.hh:573
VariableSetDescription(Spaces const &spaces_, RAIter nameIt)
Constructor, giving each variable a name (e.g. for output purposes)
Definition: variables.hh:602
VariableSetDescription(Spaces const &spaces_)
Constructor without naming the variables.
Definition: variables.hh:641
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:634
A class for storing a heterogeneous collection of FunctionSpaceElement s.
Definition: variables.hh:341
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:473
VSDescriptions::RepresentationData Functions
boost::fusion::vector of data elements (of type FunctionSpaceElement)
Definition: variables.hh:347
auto value(Cell< GridView > const &cell, LocalPosition< GridView > const &xi) const
Value of an individual variable in the set.
Definition: variables.hh:432
VSDescriptions Descriptions
Type of the VariableSetDescription.
Definition: variables.hh:344
VariableSet(Self const &vs)
Copy constructor.
Definition: variables.hh:362
auto derivative(Evaluators const &evals) const
Derivative of an individual variable in the set.
Definition: variables.hh:453
auto hessian(Cell< GridView > const &cell, LocalPosition< GridView > const &xi) const
Hessian of an individual variable in the set.
Definition: variables.hh:492
Self & operator=(S const &s)
Assignment from other (compatible) types.
Definition: variables.hh:399
LinearProductSpace< Scalar, Functions > LinearSpace
Definition: variables.hh:359
Descriptions const & descriptions
Descriptions of variable set, of type VariableSetDescription (lots of useful infos)
Definition: variables.hh:510
auto value(Evaluators const &evals) const
Value of an individual variable in the set.
Definition: variables.hh:417
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:502
auto value(GlobalPosition< GridView > const &x) const
Value of an individual variable in the set.
Definition: variables.hh:444
VariableSet(Descriptions const &d)
Constructor.
Definition: variables.hh:372
auto hessian(Evaluators const &evals) const
Hessian of an individual variable in the set.
Definition: variables.hh:482
auto derivative(Cell< GridView > const &cell, LocalPosition< GridView > const &xi) const
Derivative of an individual variable in the set.
Definition: variables.hh:463
Self & operator=(Self const &v)
Assignment.
Definition: variables.hh:383
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
decltype(evaluateVariables(std::declval< VariableSet >(), std::declval< typename VariableSet::Descriptions::Evaluators >(), std::declval< Method >())) EvaluateVariables
The type of evaluated variables as returned by evaluateVariables.
Definition: variables.hh:1008
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.
Definition: variables.hh:948
auto makeSpaceList(Spaces *... spaces)
Creates a list of finite element spaces in the required format. Usage example (for Stokes flow):
Definition: variables.hh:892
constexpr auto valueMethod
Helper method for evaluating whole variable sets.
Definition: variables.hh:1018
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.
Definition: variables.hh:988
VariableSetDescription< SpaceList, VariableList > makeVariableSetDescription(SpaceList const &spaces, VariableList const &vars)
Creates a variable set description from given spaces and variables.
Definition: variables.hh:911
constexpr auto derivativeMethod
Helper method for evaluating whole variable sets.
Definition: variables.hh:1027
decltype(valueMethod) ValueMethod
The type of the valueMethod helper functor.
Definition: variables.hh:1033
decltype(derivativeMethod) DerivativeMethod
The type of the derivativeMethod helper functor.
Definition: variables.hh:1039
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:201
ConstructCoefficientVector(Spaces const &spaces_)
Definition: variables.hh:202
result< ConstructCoefficientVector< Spaces >(Variable)>::type operator()(Variable const &variable) const
Returns a FunctionSpaceElement from the FEFunctionSpace associated to the variable.
Definition: variables.hh:231
For a given variable, defines the correct FunctionSpaceElement type.
Definition: variables.hh:171
A boost::fusion functor for generating function space elements for given variables.
Definition: variables.hh:161
ConstructElement(Spaces const &spaces_)
Definition: variables.hh:162
result< ConstructElement< Spaces >(Variable)>::type operator()(Variable const &variable) const
Returns a FunctionSpaceElement element from the FEFunctionSpace associated to the Variable.
Definition: variables.hh:185
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:128
Variable(std::string const &name_)
Constructor.
Definition: variables.hh:139
Variable()=default
Constructor. This will create a default name based on the variable id.
static int const spaceIndex
Definition: variables.hh:129
static int const m
Definition: variables.hh:130
std::string name
Definition: variables.hh:148
DEPRECATED, use components instead.
Definition: variables.hh:696
DEPRECATED, use spaceIndex instead.
Definition: variables.hh:720