KASKADE 7 development version
constantspace.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-2023 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 CONSTANTSPACE_HH
14#define CONSTANTSPACE_HH
15
16#include <numeric>
17#include <limits>
18
20#include "fem/functionspace.hh"
21#include "fem/views.hh"
22
23namespace Kaskade
24{
32 template <class ScalarType, class GV>
34 {
36
37 public:
39
40 typedef GV GridView;
41 typedef typename GridView::Grid Grid;
42 typedef typename GridView::IndexSet IndexSet;
43 using ctype = typename GridView::ctype;
44
45 static int const dim = Grid::dimension;
46 static int const maxLocalSize = 1;
47
49 typedef LagrangeSimplexShapeFunctionSet<ctype,dim,ScalarType> ShapeFunctionSetImplementation; // constant functions are the same for any polytope
52
53 typedef std::pair<size_t,int> IndexPair;
54 typedef std::vector<IndexPair>::const_iterator SortedIndexIterator;
56
61 static int const continuity = std::numeric_limits<int>::max()-1; // mpl::int_ chokes on true max int value...
62
66 static bool const globalSupport = true;
67
68 template <int m>
69 struct Element
70 {
72 };
73
74 ConstantMapper(GridView const& gridView)
75 : indexSet(gridView.indexSet())
76 , globIdx{0}
77 , sortedIdx(1)
78 {
79 sortedIdx[0] = std::make_pair(0,0);
80 }
81
82 virtual ~ConstantMapper() {}
83
84 ShapeFunctionSet const& shapefunctions(Cell const& cell) const
85 {
86 return lagrangeShapeFunctionSet<ctype,dim,Scalar>(Dune::GeometryType(Dune::GeometryType::simplex,dim),0); // constant functions are the same for any polytope
87 }
88
89 ShapeFunctionSet const& shapefunctions(size_t) const
90 {
91 // constant functions are the same for any polytope
92 Dune::GeometryType gt(0,dim,false); // elementId:0, dimension:dim, bool isNone:false
93 return lagrangeShapeFunctionSet<ctype,dim,Scalar>(gt,0);
94 }
95
99 int maxOrder() const
100 {
101 return 0;
102 }
103
109 {
110 return GlobalIndexRange(globIdx.begin(),globIdx.begin());
111 }
112
119 GlobalIndexRange globalIndices(typename Grid::template Codim<0>::Entity const& /* cell */) const
120 {
121 return GlobalIndexRange(globIdx.begin(),globIdx.end());
122 }
123
131 {
132 return GlobalIndexRange(globIdx.begin(),globIdx.end());
133 }
134
139 {
140 static std::vector<IndexPair> dummy; // empty
141 return SortedIndexRange(dummy.begin(),dummy.end());
142 }
143
148 {
149 return SortedIndexRange(sortedIdx.begin(),sortedIdx.end());
150 }
151
156 {
157 return SortedIndexRange(sortedIdx.begin(),sortedIdx.end());
158 }
159
163 size_t size() const { return 1; }
164
171 {
172 public:
174
175 Converter(Cell const& /* cell */) {}
176
177 void moveTo(Cell const& /* cell */) { }
178
180
183
184
188 template <class Scalar>
190 {
192 phi.value = 1;
193 phi.derivative = 0;
194 phi.hessian = 0;
195 return phi;
196 }
197
199 };
200
208 class Combiner {
209 public:
210 Combiner(Cell const& cell) {}
211
216 template <class Matrix>
217 void rightTransform(Matrix& /* A */) const {}
218
220 template <int n, int m>
221 void rightTransform(std::vector<VariationalArg<Scalar,n,m> >& /* v */) const {}
222
224 template <class Matrix>
225 void leftPseudoInverse(Matrix& /* A */) const {}
226
229 operator Dune::BCRSMatrix<Dune::FieldMatrix<Scalar,1,1> >() const
230 {
231 Dune::BCRSMatrix<Dune::FieldMatrix<Scalar,1,1> > K(1,1,Dune::BCRSMatrix<Dune::FieldMatrix<Scalar,1,1> >::random);
232 K.incrementrowsize(0);
233 K.endrowsizes();
234 K.addindex(0,0);
235 K.endindices();
236
237 *K[0].begin() = 1;
238 return K;
239 }
240
241 };
242
246 Combiner combiner(Cell const& cell, size_t index) const { return Combiner(cell); }
247
248
249
255 void update() {}
256
257 private:
258 IndexSet const& indexSet;
259 std::vector<size_t> globIdx;
260 std::vector<IndexPair> sortedIdx;
261 };
262} /* end of namespace Kaskade */
263
264#endif
A class implementing a matrix mapping a subset of global degrees of freedom (those given by globalIn...
void leftPseudoInverse(Matrix &) const
In-place computation of .
void rightTransform(Matrix &) const
In-place computation of . Since is the identity, this is a no-op.
void rightTransform(std::vector< VariationalArg< Scalar, n, m > > &) const
In-place computation of row vectors .
A class mapping local shape function values and derivatives to global shape function values and deriv...
Dune::FieldMatrix< Scalar, 1, 1 > local(Dune::FieldMatrix< Scalar, 1, 1 > const &glob) const
VariationalArg< Scalar, dim, 1 > global(VariationalArg< Scalar, dim, 1 > const &sf, int deriv=1) const
Applies the transformation to shape function value, derivative, and Hessian, returning a filled Vari...
void setLocalPosition(Dune::FieldVector< ctype, Grid::dimension > const &)
Dune::FieldMatrix< Scalar, 1, 1 > global(Dune::FieldMatrix< Scalar, 1, 1 > const &sf) const
Applies the transformation to shape function value.
ShapeFunctionSet const & shapefunctions(size_t) const
GlobalIndexRange globalIndices(size_t) const
Returns a const sequence containing the global indices of the shape functions associated to this cell...
GridView::IndexSet IndexSet
GlobalIndexRange initGlobalIndexRange() const
Returns an empty range just for initialization purposes, since RangeView is not default constructible...
int maxOrder() const
Returns the maximal polynomial order of shape functions encountered in any cell.
void update()
Recomputes the internal information after grid changes. Since there is no internal state of this triv...
GlobalIndexRange globalIndices(typename Grid::template Codim< 0 >::Entity const &) const
Returns a const sequence containing the global indices of the shape functions associated to this cell...
static int const dim
ConstantMapper(GridView const &gridView)
RangeView< SortedIndexIterator > SortedIndexRange
Combiner combiner(Cell const &cell, size_t index) const
std::vector< IndexPair >::const_iterator SortedIndexIterator
LagrangeSimplexShapeFunctionSet< ctype, dim, ScalarType > ShapeFunctionSetImplementation
Kaskade::Cell< GridView > Cell
RangeView< std::vector< size_t >::const_iterator > GlobalIndexRange
SortedIndexRange sortedIndices(size_t) const
Returns an immutable sequence of (global index, local index) pairs sorted in ascending global index o...
static int const maxLocalSize
LagrangeShapeFunctionSetContainer< ctype, dim, ScalarType >::value_type ShapeFunctionSet
ShapeFunctionSet const & shapefunctions(Cell const &cell) const
std::pair< size_t, int > IndexPair
typename GridView::ctype ctype
static int const continuity
Continuity index. Since constant functions are , even analytic, this is infinity (or as close as int ...
static bool const globalSupport
Whether the ansatz functions have global support (i.e. lead to dense matrices).
size_t size() const
Returns the number of global degrees of freedom managed.
SortedIndexRange sortedIndices(Cell const &) const
Returns an immutable sequence of (global index, local index) pairs sorted in ascending global index o...
static SortedIndexRange initSortedIndexRange()
Returns an empty range just for initialization, since RangeView is not default constructible.
A class for representing finite element functions.
A container of Lagrange shape functions of order Ord on the unit simplex of grid dimension....
DEPRECATED. Use boost::iterator_range instead.
Definition: views.hh:25
A set of shape functions.
FEFunctionSpace and FunctionSpaceElement and the like.
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< T, n > max(Dune::FieldVector< T, n > x, Dune::FieldVector< T, n > const &y)
Componentwise maximum.
Definition: fixdune.hh:110
define Lagrange type shape functions for simplicial elements of arbitrary dimension and order
typename GetScalar< Type >::type ScalarType
Extracts the scalar field type from linear algebra data types.
FunctionSpaceElement< FEFunctionSpace< Self >, m > type
A class that stores values, gradients, and Hessians of evaluated shape functions.
Dune::FieldMatrix< Scalar, components, dim > derivative
The shape function's spatial derivative, a components x dim matrix.
ValueType value
The shape function's value, a vector of dimension components
Tensor< Scalar, components, dim, dim > hessian