Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Praetorius, Simon
amdis_workshop_16
Commits
10fe6b95
Commit
10fe6b95
authored
Nov 30, 2018
by
Praetorius, Simon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
session 2 updated
parent
f5016a96
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
11 deletions
+48
-11
02_data_processing.html
02_data_processing.html
+30
-6
X0_expressions.html
X0_expressions.html
+18
-5
No files found.
02_data_processing.html
View file @
10fe6b95
...
...
@@ -17,7 +17,7 @@
<textarea
id=
"source"
>
# Session 2
##
Wednes
day Nov
28
##
Fri
day Nov
30
- Scalar linear second order PDEs
- **Discrete functions on unstructured grids**
---
...
...
@@ -34,7 +34,7 @@
# Working with discrete functions
Finite-Element function `\(u_h\in V_h = span\{\phi_i\}\)`, a linear combination of basis-functions `\(\phi_i\)`:
\\[
u\_h(x) = \sum\_i u\_i \phi\_i(x) = \sum\_j u\_{i\_T(j)} \hat{\phi}_j(\lambda\_T(x)),
u\_h(x) = \sum\_i u\_i \phi\_i(x) = \sum\_j u\_{i\_T(j)} \hat{\phi}_j(\lambda\_T(x)),
\text{ for }x\in T
\\]
with `\(u_i:=\)` Degrees of Freedom, stored in `DOFVector
<value_type>
U`:
- Evaluate at DOF index: `u_i = U[i]`
...
...
@@ -76,19 +76,22 @@ basFcts->evalUh(lambda, uh); // linear combination
---
# Interpolate a local function to a DOFVector
A local function is something that can be evaluated at local coordinates in a *bound* element.
A local function
(*element function*)
is something that can be evaluated at local coordinates in a *bound* element.
By traversing the mesh the local function can be used to locally interpolate to the DOFs of an
element
.
element
, i.e., `\(u_h = I_h f\;\rightarrow\)` `U=(u_i)`
```
U
<
<
EXPRESSION
;
```
where
`
EXPRESSION
`
can
contain
e.g.
-
The
coordinates:
`
X
()`,
`
X
(
i
)`
where
`
EXPRESSION
`
represents
`\(
f
\)`
as
composition
of
*element
functions*
and
can
contain
e.g.
-
The
global
coordinates:
`
X
()`,
`
X
(
i
)`
-
Scalar
values:
`1.0`,
`
constant
(1.0)`
-
Other
DOFVectors:
`
valueOf
(
V
)`,
`
gradientOf
(
V
)`
-
Matrix
and
vector
expressions:
`
two_norm
(...)`,
`
vec
*
vec
`
-
and
any
function
applied
to
these
*terminal*
expressions.
NOTE:
This
has
to
be
unserstood
in
the
sense
of
functional
programming
,
i.e.
everything
is
a
function
!
List
of
possible
expressions
,
see
`
X0_expressions.html
`
or
cheat
sheets.
...
...
@@ -250,6 +253,27 @@ io::readFile(FILENAME, DOFVECTOR);
```
- Use ARH format to exchange data (can be converted to VTU by MeshConv.)
---
## Use a FileWriter
- Configure the output in the parameter file
```
FileWriter fileWriter("name",
&
mesh,
&U);
fileWriter.writeFiles(
&
adaptInfo, true);
```
In the parameter file:
```
name->filename: xyz
name->ParaView format: 1
```
- Set which level to write
```
// leaf level
fileWriter.writeFile(
&
adaptInfo, true, -1, Mesh::CALL_LEAF_EL);
// specific level
fileWriter.writeFile(
&
adaptInfo, true, level, Mesh::CALL_EL_LEVEL);
```
with `level` and integer `>= 0`.
---
class: center, middle
...
...
X0_expressions.html
View file @
10fe6b95
<!DOCTYPE html>
<html>
<head>
<title>
AMDiS - Adaptive Multi-Dimensional Simulations
</title>
<title>
Expressions in AMDiS
</title>
<meta
http-equiv=
"Content-Type"
content=
"text/html; charset=UTF-8"
/>
<style
type=
"text/css"
>
@import
url(https://fonts.googleapis.com/css?family=Yanone+Kaffeesatz)
;
...
...
@@ -66,10 +66,13 @@ In the following table operations are listed that can be applied to elemental ex
| `abs_(T), signum(T)` | The absolute value and the sign (`T
<
0
=
>
signum(T) := -1, T>0 => signum(T) := 1, T==0 => signum(T) := 0`) |
| `clamp(T, lo, hi)` | Applies the `std::clamp` function locally to the evaluated expression `T`, where `lo` and `hi` are fixed values. |
| `ceil(T), floor(T)` | Round down or up the evaluated expression. |
| `function_(F, T1, T2, T3, ...)` | Apply a functor to the evaluated expressions `T1,T2,...` |
---
### Functor expressions
- `eval(F)`: Evaluate a functor at global coordinates, i.e. `F(x)`
- `eval(F, T1, T2, T3, ...)`: Apply a functor to the evaluated expressions `T1,T2,...`
A functor is a class with the following structure:
```c++
struct Functor : public FunctorBase
...
...
@@ -80,11 +83,21 @@ struct Functor : public FunctorBase
value_type operator()(const T1::value_type
&
, const T2::value_type
&
, ...) const { return (...); }
};
```
or any valid function object in c++.
When it is derived from `FunctorBase` one can specify an polynomial degree of the functor, relative to
When it is derived from `FunctorBase` one can specify an polynomial degree of the functor, relative to
the polynomial degrees of the arguments passed to the functor, i.e. the polynomial degrees of the passed expressions.
The `getDegree()` functor is then evaluated in the following form:
### Lambda expressions
Instead of the deriving from `FunctorBase`, any valid function object in c++ can be used:
```c++
eval([](auto const
&
x, double u) { return u*std::sin(x[0]); }, X(), valudOf(U));
```
In order to specify a polynomial degree of this expression, it must be wrapped in a `deg()` expression, i.e.
- `deg
<p>
(F)`: Assign a (constant) polynomial degree `p` to the functor `F`
- `deg(F, D)`: Evaluate the polynomial degree of functor `F`, depending on the polynomial degrees of the expressions passed to the functor.
```c++
getDegree(T1.getDegree(), T2.getDegree(), ...)
eval(deg([](double u) { return 2*u; }, [](int d) { return d; }), valueOf(U));
```
---
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment