README.md 4.45 KB
Newer Older
Praetorius, Simon's avatar
Praetorius, Simon committed
1
# Dune-CurvedGrid - A Dune module for geometry parametrization
Praetorius, Simon's avatar
Praetorius, Simon committed
2
This Dune module provides a meta-grid for wrapping other grid implementations and providing
Praetorius, Simon's avatar
Praetorius, Simon committed
3
a curved geometry on each element, parametrized by a [Dune-CurvedGeometry](https://gitlab.mn.tu-dresden.de/iwr/dune-curvedgeometry)
Praetorius, Simon's avatar
Praetorius, Simon committed
4
class.
Stenger, Florian's avatar
Stenger, Florian committed
5

Praetorius, Simon's avatar
Praetorius, Simon committed
6
7
For an overview about the CurvedGrid and the CurvedGeometry, see also the presentation
[Dune-CurvedGrid - A Dune module for surface parametrization](http://wwwpub.zih.tu-dresden.de/~praetori/presentations/dune-curvedgrid).
Praetorius, Simon's avatar
Praetorius, Simon committed
8
9
10

## Installation Instructions
`dune-curvedgrid` requires the DUNE core modules, version 2.7 or later.
Praetorius, Simon's avatar
Praetorius, Simon committed
11
12
Please see the [general instructions for building DUNE modules](https://www.dune-project.org/doc/installation)
for detailed instructions on how to build the module.
Praetorius, Simon's avatar
Praetorius, Simon committed
13
14

## Initial Example
Praetorius, Simon's avatar
Praetorius, Simon committed
15
(See [example1.cc](https://gitlab.mn.tu-dresden.de/iwr/dune-curvedgrid/-/blob/master/src/example1.cc))
Praetorius, Simon's avatar
Praetorius, Simon committed
16
17
18
19
20
21
22
23
24
25

```c++
// 1. Construct a reference grid
auto refGrid = GmshReader< FoamGrid<2,3> >::read("sphere.msh");

// 2. Define the geometry mapping
auto sphere = [](const auto& x) { return x / x.two_norm(); };
auto sphereGF = analyticDiscreteFunction(sphere, *refGrid, order);

// 3. Wrap the reference grid to build a curved grid
Praetorius, Simon's avatar
Praetorius, Simon committed
26
CurvedGrid grid{*refGrid, sphereGF};
Praetorius, Simon's avatar
Praetorius, Simon committed
27
28
29
30
```

At first, we have to create a reference grid that acts as a parametrization domain for the
target curved grid. In the example, we use [Dune-FoamGrid](https://gitlab.dune-project.org/extensions/dune-foamgrid)
Praetorius, Simon's avatar
Praetorius, Simon committed
31
and read a piece-wise flat grid from a GMsh file [`sphere.msh`](https://gitlab.mn.tu-dresden.de/iwr/dune-curvedgrid/-/blob/master/doc/grids/sphere.msh).
Praetorius, Simon's avatar
Praetorius, Simon committed
32
33
34
35
36
37
38
39
40

In a second step, we describe the parametrization of the curved surface by a closest-point
projection to the sphere with radius 1. This projection is given by a callable `sphere` and
the wrapped into a grid-function by a call to `analyticDiscreteFunction`. This grid-function
wrapper associated the lambda-expression with a grid and a polynomial order for the local
interpolation of the projection into a Lagrange basis. This interpolation allows to obtain
values and derivatives of the geometry mapping.

Finally, the reference grid and the parametrization together build the curved grid. This
Praetorius, Simon's avatar
Praetorius, Simon committed
41
meta-grid `CurvedGrid` implements the Dune grid interface and can thus be used as
Praetorius, Simon's avatar
Praetorius, Simon committed
42
43
44
replacement for, e.g., the reference grid.

## Two Different Geometry Mappings
Praetorius, Simon's avatar
Praetorius, Simon committed
45
The [Dune-CurvedGeometry](https://gitlab.mn.tu-dresden.de/iwr/dune-curvedgeometry) module
Praetorius, Simon's avatar
Praetorius, Simon committed
46
47
48
49
50
51
52
53
54
provides two different geometry implementations that differ in the input and in the
representation of the parametrization.

### Parametrized-Geometry
The first one, `ParametrizedGeometry`, provides a geometry that locally interpolates a given
projection function into a (Lagrange) basis on the reference element. This requires from the
projection mapping just that it allows to map local coordinates in the reference element to
global coordinates on the surface.

Praetorius, Simon's avatar
Praetorius, Simon committed
55
The `CurvedGrid` constructs on request of the element geometry a LocalFiniteElement
Praetorius, Simon's avatar
Praetorius, Simon committed
56
57
58
of Lagrange basis functions for the internal parametrization of the geometry. The `ParametrizedGeometry`
is constructed, if the grid gets a polynomial order `k > 0`.

Praetorius, Simon's avatar
Praetorius, Simon committed
59
(See [example2.cc](https://gitlab.mn.tu-dresden.de/iwr/dune-curvedgrid/-/blob/master/src/example2.cc))
Praetorius, Simon's avatar
Praetorius, Simon committed
60
61
62
63
64
65
66
67
68
69
70
```c++
// Construct a reference grid
auto refGrid = GmshReader< FoamGrid<2,3> >::read("sphere.msh");

// Define the geometry mapping
auto sphere = [](const auto& x) { return x / x.two_norm(); };

template <int order>
using Order_t = std::integral_constant<int,order>;

// Wrap the reference grid to build a curved grid
Praetorius, Simon's avatar
Praetorius, Simon committed
71
CurvedGrid grid{*refGrid, sphere, Order_t<k>{}};
Praetorius, Simon's avatar
Praetorius, Simon committed
72
73
74
75
76
77
78
79
```

### LocalFunction-Geometry
In case the projection is given as a differentiable mapping `f`, i.e., there exists a
function `derivative(f)` returning a callable that gives the Jacobian of the mapping, the
grid constructs a `LocalFunctionGeometry` on each element. This geometry is exactly parametrized
with the mapping and its derivative, i.e., no additional interpolation is performed.

Praetorius, Simon's avatar
Praetorius, Simon committed
80
(See [example3.cc](https://gitlab.mn.tu-dresden.de/iwr/dune-curvedgrid/-/blob/master/src/example3.cc))
Praetorius, Simon's avatar
Praetorius, Simon committed
81
82
83
84
85
86
87
88
89
90
91
```c++
auto gv = refGrid->leafGridView();

// Define a discrete grid-function on the reference grid
// with dim(range) = 3 and polynomial order k
auto f = discreteGridViewFunction<3>(gv, k);

// Interpolate the parametrization into the grid-function
Functions::interpolate(f.basis(), f.coefficients(), sphere);

// Wrap the reference grid and the grid-function
Praetorius, Simon's avatar
Praetorius, Simon committed
92
CurvedGrid grid{*refGrid, f};
Praetorius, Simon's avatar
Praetorius, Simon committed
93
```