Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dune-pdelab-tutorials
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
PDELab
dune-pdelab-tutorials
Commits
f7f59b9a
Commit
f7f59b9a
authored
9 years ago
by
Steffen Müthing
Browse files
Options
Downloads
Patches
Plain Diff
Update line numbers in tutorial04
parent
3a9d6789
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
tutorial04/doc/tutorial04.tex
+56
-39
56 additions, 39 deletions
tutorial04/doc/tutorial04.tex
tutorial04/src/driver.hh
+4
-1
4 additions, 1 deletion
tutorial04/src/driver.hh
with
60 additions
and
40 deletions
tutorial04/doc/tutorial04.tex
+
56
−
39
View file @
f7f59b9a
...
...
@@ -232,7 +232,7 @@ backgroundcolor=\color{listingbg}]{../src/driver.hh}
The next step is to set up the product space containing
two components. This is done by the following code section:
\lstinputlisting
[linerange=
{
21-2
6
}
,
\lstinputlisting
[linerange=
{
21-2
8
}
,
basicstyle=
\ttfamily\small
,
frame=single,
backgroundcolor=
\color
{
listingbg
}
]
{
../src/driver.hh
}
...
...
@@ -244,6 +244,13 @@ which may only differ in the constraints. With the
class template
\lstinline
{
CompositeGridFunctionSpace
}
you can create
a product space where all components might be different spaces.
We also have to set up names for the child spaces to facilitate VTK output later on:
\lstinputlisting
[linerange=
{
31-33
}
,
basicstyle=
\ttfamily\small
,
frame=single,
backgroundcolor=
\color
{
listingbg
}
]
{
../src/driver.hh
}
An important aspect of product spaces is the ordering of the corresponding degrees
of freedom. Often the solvers need to exploit an underlying block structure
of the matrices.
...
...
@@ -270,7 +277,7 @@ for higher polynomial degree!
In order to define a function that specifies the initial value we can
use the same techniques as in the scalar case. We first define a lambda
closure
\lstinputlisting
[linerange=
{
29-34
}
,
\lstinputlisting
[linerange=
{
35-41
}
,
basicstyle=
\ttfamily\small
,
frame=single,
backgroundcolor=
\color
{
listingbg
}
]
{
../src/driver.hh
}
...
...
@@ -278,46 +285,46 @@ now returning two components in a \lstinline{FieldVector}.
The first component is the initial value for
$
u
$
and the second component
is the initial value for
$
\partial
_
t u
$
. Then a PDELab grid function
can be constructed from the lambda closure
\lstinputlisting
[linerange=
{
35-35
}
,
\lstinputlisting
[linerange=
{
42-42
}
,
basicstyle=
\ttfamily\small
,
frame=single,
backgroundcolor=
\color
{
listingbg
}
]
{
../src/driver.hh
}
Using the grid function a coefficient vector can now be initialized:
\lstinputlisting
[linerange=
{
38-40
}
,
basicstyle=
\ttfamily\small
,
frame=single,
backgroundcolor=
\color
{
listingbg
}
]
{
../src/driver.hh
}
Given a product function space it is also possible to
extract the individual component spaces from the product
space. This is done by the following code section:
\lstinputlisting
[linerange=
{
43-48
}
,
\lstinputlisting
[linerange=
{
45-48
}
,
basicstyle=
\ttfamily\small
,
frame=single,
backgroundcolor=
\color
{
listingbg
}
]
{
../src/driver.hh
}
In fact, one could have a tree-structured function space and
extract an arbitrary node as a function space.
The component spaces can now be used to build
up discrete grid functions for the two solution components:
\lstinputlisting
[linerange=
{
51-54
}
,
basicstyle=
\ttfamily\small
,
frame=single,
backgroundcolor=
\color
{
listingbg
}
]
{
../src/driver.hh
}
Note that the full solution vector
\lstinline
{
z
}
is passed as an argument.
The subspace automatically extracts the required components from the solution vector.
% Given a product function space it is also possible to
% extract the individual component spaces from the product
% space. This is done by the following code section:
% \lstinputlisting[linerange={43-48},
% basicstyle=\ttfamily\small,
% frame=single,
% backgroundcolor=\color{listingbg}]{../src/driver.hh}
% In fact, one could have a tree-structured function space and
% extract an arbitrary node as a function space.
% The component spaces can now be used to build
% up discrete grid functions for the two solution components:
% \lstinputlisting[linerange={51-54},
% basicstyle=\ttfamily\small,
% frame=single,
% backgroundcolor=\color{listingbg}]{../src/driver.hh}
% Note that the full solution vector \lstinline{z} is passed as an argument.
% The subspace automatically extracts the required components from the solution vector.
The next step is to assemble the constraints container for the composite
function space. Unfortunately there is currently no way to define the
constraints for both components in one go. We need to
set up a separate lambda closure for each component:
\lstinputlisting
[linerange=
{
5
7-62
}
,
\lstinputlisting
[linerange=
{
5
0-55
}
,
basicstyle=
\ttfamily\small
,
frame=single,
backgroundcolor=
\color
{
listingbg
}
]
{
../src/driver.hh
}
and then combine it using:
\lstinputlisting
[linerange=
{
63-65
}
,
\lstinputlisting
[linerange=
{
56-59
}
,
basicstyle=
\ttfamily\small
,
frame=single,
backgroundcolor=
\color
{
listingbg
}
]
{
../src/driver.hh
}
...
...
@@ -325,10 +332,20 @@ Note that you could define different constraints for each component
space although it is the same underlying function space.
Now the constraints container can be assembled as before:
\lstinputlisting
[linerange=
{
66-69
}
,
\lstinputlisting
[linerange=
{
61-63
}
,
basicstyle=
\ttfamily\small
,
frame=single,
backgroundcolor=
\color
{
listingbg
}
]
{
../src/driver.hh
}
As we do not want to manually extract the subspaces for
$
u
_
0
$
and
$
u
_
1
$
from the
overall space to add to them to the VTK writer, we call a PDELab helper function that
handles this automatically:
\lstinputlisting
[linerange=
{
86-86
}
,
basicstyle=
\ttfamily\small
,
frame=single,
backgroundcolor=
\color
{
listingbg
}
]
{
../src/driver.hh
}
Note that in order to use this function, we have to set the names of the subspaces,
as we did earlier in the tutorial.
The rest of the driver is the same as for tutorial 03 except that
a linear solver is used instead of Newton's method.
...
...
@@ -358,7 +375,7 @@ they consist of two components.
(up to constraints) and that also both components are identical!
}
The two components can be extracted with the following code
\lstinputlisting
[linerange=
{
59
-6
1
}
,
\lstinputlisting
[linerange=
{
60
-6
2
}
,
basicstyle=
\ttfamily\small
,
frame=single,
backgroundcolor=
\color
{
listingbg
}
]
{
../src/wavefem.hh
}
...
...
@@ -366,12 +383,12 @@ The function spaces \lstinline{lfsu0} and \lstinline{lfsu1} are
now scalar spaces (which we assume to be identical).
After extracting the dimension
\lstinputlisting
[linerange=
{
6
4
-6
4
}
,
\lstinputlisting
[linerange=
{
6
5
-6
5
}
,
basicstyle=
\ttfamily\small
,
frame=single,
backgroundcolor=
\color
{
listingbg
}
]
{
../src/wavefem.hh
}
we select a quadrature rule
\lstinputlisting
[linerange=
{
6
7-69
}
,
\lstinputlisting
[linerange=
{
6
8-70
}
,
basicstyle=
\ttfamily\small
,
frame=single,
backgroundcolor=
\color
{
listingbg
}
]
{
../src/wavefem.hh
}
...
...
@@ -379,38 +396,38 @@ and may now loop over the quadrature points.
For each quadrature point, evaluate the basis function
of the first component:
\lstinputlisting
[linerange=
{
7
5
-7
6
}
,
\lstinputlisting
[linerange=
{
7
6
-7
7
}
,
basicstyle=
\ttfamily\small
,
frame=single,
backgroundcolor=
\color
{
listingbg
}
]
{
../src/wavefem.hh
}
As the components are identical we need only evaluate the basis once
and can compute the value of
$
u
_
1
$
at the quadrature point
\lstinputlisting
[linerange=
{
79
-8
1
}
,
\lstinputlisting
[linerange=
{
80
-8
2
}
,
basicstyle=
\ttfamily\small
,
frame=single,
backgroundcolor=
\color
{
listingbg
}
]
{
../src/wavefem.hh
}
Then we evaluate the gradients of the basis functions
\lstinputlisting
[linerange=
{
8
4
-8
5
}
,
\lstinputlisting
[linerange=
{
8
5
-8
6
}
,
basicstyle=
\ttfamily\small
,
frame=single,
backgroundcolor=
\color
{
listingbg
}
]
{
../src/wavefem.hh
}
transform them from the reference element to the real element
\lstinputlisting
[linerange=
{
8
8
-9
2
}
,
\lstinputlisting
[linerange=
{
8
9
-9
3
}
,
basicstyle=
\ttfamily\small
,
frame=single,
backgroundcolor=
\color
{
listingbg
}
]
{
../src/wavefem.hh
}
and compute the gradient of
$
u
_
0
$
:
\lstinputlisting
[linerange=
{
9
5
-9
7
}
,
\lstinputlisting
[linerange=
{
9
6
-9
8
}
,
basicstyle=
\ttfamily\small
,
frame=single,
backgroundcolor=
\color
{
listingbg
}
]
{
../src/wavefem.hh
}
With the integration factor
\lstinputlisting
[linerange=
{
10
0
-10
1
}
,
\lstinputlisting
[linerange=
{
10
1
-10
2
}
,
basicstyle=
\ttfamily\small
,
frame=single,
backgroundcolor=
\color
{
listingbg
}
]
{
../src/wavefem.hh
}
the residuals can now be accumulated:
\lstinputlisting
[linerange=
{
10
2
-10
5
}
,
\lstinputlisting
[linerange=
{
10
3
-10
6
}
,
basicstyle=
\ttfamily\small
,
frame=single,
backgroundcolor=
\color
{
listingbg
}
]
{
../src/wavefem.hh
}
...
...
@@ -421,7 +438,7 @@ As the problem is linear it is advisable to also implement the
\lstinline
{
jacobian
_
volume
}
method for efficiency and accuracy.
The interface is the same as in the scalar case:
\lstinputlisting
[linerange=
{
11
0
-11
3
}
,
\lstinputlisting
[linerange=
{
11
1
-11
4
}
,
basicstyle=
\ttfamily\small
,
frame=single,
backgroundcolor=
\color
{
listingbg
}
]
{
../src/wavefem.hh
}
...
...
@@ -429,7 +446,7 @@ backgroundcolor=\color{listingbg}]{../src/wavefem.hh}
Component selection, quadrature rule selection and
basis evaluation are the same as in
\lstinline
{
alpha
_
volume
}
.
We only consider the accumulation of the Jacobian entries here:
\lstinputlisting
[linerange=
{
14
0
-14
8
}
,
\lstinputlisting
[linerange=
{
14
1
-14
9
}
,
basicstyle=
\ttfamily\small
,
frame=single,
backgroundcolor=
\color
{
listingbg
}
]
{
../src/wavefem.hh
}
...
...
@@ -454,7 +471,7 @@ to the one in the spatial operator, except that the value of $u_0$
is needed instead of the gradient.
Here we just show the residual accumulation:
\lstinputlisting
[linerange=
{
23
1
-23
5
}
,
\lstinputlisting
[linerange=
{
23
3
-23
7
}
,
basicstyle=
\ttfamily\small
,
frame=single,
backgroundcolor=
\color
{
listingbg
}
]
{
../src/wavefem.hh
}
...
...
@@ -465,7 +482,7 @@ and vice versa.
The corresponding Jacobian entries are accumulated in the
\lstinline
{
jacobian
_
volume
}
method:
\lstinputlisting
[linerange=
{
26
2
-2
69
}
,
\lstinputlisting
[linerange=
{
26
4
-2
71
}
,
basicstyle=
\ttfamily\small
,
frame=single,
backgroundcolor=
\color
{
listingbg
}
]
{
../src/wavefem.hh
}
...
...
This diff is collapsed.
Click to expand it.
tutorial04/src/driver.hh
+
4
−
1
View file @
f7f59b9a
...
...
@@ -19,7 +19,9 @@ void driver (const GV& gv, const FEM& fem,
// Make grid function space for the system
using
VBE
=
Dune
::
PDELab
::
istl
::
VectorBackend
<
Dune
::
PDELab
::
istl
::
Blocking
::
fixed
>
;
Dune
::
PDELab
::
istl
::
VectorBackend
<
Dune
::
PDELab
::
istl
::
Blocking
::
fixed
>
;
using
OrderingTag
=
Dune
::
PDELab
::
EntityBlockedOrderingTag
;
using
GFS
=
Dune
::
PDELab
::
PowerGridFunctionSpace
<
GFS0
,
2
,
VBE
,
OrderingTag
>
;
...
...
@@ -55,6 +57,7 @@ void driver (const GV& gv, const FEM& fem,
decltype
(
b0
),
decltype
(
b1
)
>
;
B
b
(
b0
,
b1
);
using
CC
=
typename
GFS
::
template
ConstraintsContainer
<
RF
>
::
Type
;
CC
cc
;
Dune
::
PDELab
::
constraints
(
b
,
gfs
,
cc
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment