... | ... | @@ -38,17 +38,82 @@ Available examples: |
|
|
## Expressions
|
|
|
In order to write a differential equation in a mathematical natural way we have developed an expression framework, that allowes exacly this. Instead of adding abstract operator-classes to the problem definition we implement the coefficient functions of the operators using mathematical operators. An example is the following bilinearform
|
|
|
|
|
|
```math
|
|
|
a(c,\vartheta) := \big\langle\frac{1}{\epsilon}(\phi^2 - 1) c,\; \vartheta\big\rangle + \big\langle\max(10^{-5},\;(\phi+1))\nabla c,\; \nabla\vartheta\big\rangle
|
|
|
```
|
|
|
|
|
|
Assume that ``\phi`` represents a DOFVector, i.e. a discrete representation of a function in a function-space, that is known in advance, or given by an iterative solution procedure from the last iteration. Here we use a solution component of the problem `prob`:
|
|
|
<!-- begin MathToWeb -->
|
|
|
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block" title="a(c,\vartheta) := \langle\frac{1}{\epsilon}(\phi^2 - 1) c,\; \vartheta\rangle + \langle\max(10^{-5},\;(\phi+1))\nabla c,\; \nabla\vartheta\rangle ">
|
|
|
<mrow>
|
|
|
<mi>a</mi>
|
|
|
<mo maxsize="1">(</mo>
|
|
|
<mi>c</mi>
|
|
|
<mo>,</mo>
|
|
|
<mi>ϑ</mi>
|
|
|
<mo maxsize="1">)</mo>
|
|
|
<mo>:</mo>
|
|
|
<mo>=</mo>
|
|
|
<mo>〈</mo>
|
|
|
<mfrac>
|
|
|
<mrow>
|
|
|
<mn>1</mn>
|
|
|
</mrow>
|
|
|
<mrow>
|
|
|
<mi>ϵ</mi>
|
|
|
</mrow>
|
|
|
</mfrac>
|
|
|
<mo maxsize="1">(</mo>
|
|
|
<msup>
|
|
|
<mrow>
|
|
|
<mi>ϕ</mi>
|
|
|
</mrow>
|
|
|
<mrow>
|
|
|
<mn>2</mn>
|
|
|
</mrow>
|
|
|
</msup>
|
|
|
<mo>-</mo>
|
|
|
<mn>1</mn>
|
|
|
<mo maxsize="1">)</mo>
|
|
|
<mi>c</mi>
|
|
|
<mo>,</mo>
|
|
|
<mspace width="0.278em"></mspace>
|
|
|
<mi>ϑ</mi>
|
|
|
<mo>〉</mo>
|
|
|
<mo>+</mo>
|
|
|
<mo>〈</mo>
|
|
|
<mo>max</mo>
|
|
|
<mo maxsize="1">(</mo>
|
|
|
<msup>
|
|
|
<mrow>
|
|
|
<mn>10</mn>
|
|
|
</mrow>
|
|
|
<mrow>
|
|
|
<mo>-</mo>
|
|
|
<mn>5</mn>
|
|
|
</mrow>
|
|
|
</msup>
|
|
|
<mo>,</mo>
|
|
|
<mspace width="0.278em"></mspace>
|
|
|
<mo maxsize="1">(</mo>
|
|
|
<mi>ϕ</mi>
|
|
|
<mo>+</mo>
|
|
|
<mn>1</mn>
|
|
|
<mo maxsize="1">)</mo>
|
|
|
<mo maxsize="1">)</mo>
|
|
|
<mo>∇</mo>
|
|
|
<mi>c</mi>
|
|
|
<mo>,</mo>
|
|
|
<mspace width="0.278em"></mspace>
|
|
|
<mo>∇</mo>
|
|
|
<mi>ϑ</mi>
|
|
|
<mo>〉</mo>
|
|
|
</mrow>
|
|
|
</math>
|
|
|
<!-- end MathToWeb -->
|
|
|
|
|
|
Assume that φ represents a DOFVector, i.e. a discrete representation of a function in a function-space, that is known in advance, or given by an iterative solution procedure from the last iteration. Here we use a solution component of the problem `prob`:
|
|
|
|
|
|
```c++
|
|
|
DOFVector<double>* phi = prob->getSolution(0);
|
|
|
```
|
|
|
|
|
|
The bilinearform consists of two individual parts, a term of zeroth derivative order (ZOT) and a term that contains two derivatives, of ``c`` and ``\vartheta``, i.e. of the trial and test function. We have to implement the corresponding coefficient functions of these two terms individually and add the term using the functions `addZOT`, respective `addSOT` to the operator. Lets assume the trial and test functions are in the finite element space`feSpace` given as the first space of the problem, then we can define the bilinearform as
|
|
|
The bilinearform consists of two individual parts, a term of zeroth derivative order (ZOT) and a term that contains two derivatives, of c and ϑ, i.e. of the trial and test function. We have to implement the corresponding coefficient functions of these two terms individually and add the term using the functions `addZOT`, respective `addSOT` to the operator. Lets assume the trial and test functions are in the finite element space`feSpace` given as the first space of the problem, then we can define the bilinearform as
|
|
|
|
|
|
```c++
|
|
|
const FiniteElemSpace* feSpace = prob->getFeSpace(0);
|
... | ... | |