You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/src/ODEs.md
+10-10
Original file line number
Diff line number
Diff line change
@@ -91,8 +91,7 @@ A `TransientTrialFESpace` can be evaluated at any time derivative order, and the
91
91
92
92
For example, the following creates a transient `FESpace` and evaluates its first two time derivatives.
93
93
```
94
-
gtx(t, x) = x[1] + x[2] * t
95
-
g = time_slicing(gtx)
94
+
g(t) = x -> x[1] + x[2] * t
96
95
V = FESpace(model, reffe, dirichlet_tags="boundary")
97
96
U = TransientTrialFESpace (V, g)
98
97
@@ -106,13 +105,6 @@ U0 = U(t0)
106
105
∂ttU0 = ∂ttU(t0)
107
106
```
108
107
109
-
## The `time_slicing` constructor
110
-
Note that the constructor `time_slicing` was used above to prescribe the boundary condition, instead of a more natural function `f(t, x) = gtx(t, x)` or functor `F(t) = x -> gtx(t, x)`. It would be possible to provide `f` instead of `g` in this example, but it would not be possible to do so for time-dependent coefficients inside an integrand, simply because `Gridap` expects an integrand to be a function of space only. This `time_slicing` constructor unifies these two scenarios and is motivated by performance and convenience reasons:
111
-
* With the functor approach, `h(t)` is an anonymous function of `x`. This leads to performance drops when evaluating `h(t)(x)`, even when the function `h(t)` is instantiated only once, i.e. creating `ht = h(t)` and calling `ht(x)`. An even more significant loss in performance happens when computing (space or time) derivatives with automatic differentiation. With the `time_slicing` constructor, `g(t)` is a named function of `x`, and brings the same performance as if calling `gtx`.
112
-
* With the functor approach, applying spatial differential operators is somewhat cumbersome, for example one would have to write `∂t(h)(t)(x) - Δ(h(t))(x)`. With the `time_slicing` constructor, one can simply write `∂t(g)(t, x) - Δ(g)(t, x)`.
113
-
114
-
As a summary, `g = time_slicing(gtx)` allows the syntax `op(g)`, `op(g)(t)` and `op(g)(t, x)`, for all spatial and temporal differential operator, i.e. `op` in `(time_derivative, gradient, symmetric_gradient, divergence, curl, laplacian)` and their symbolic aliases (`∂t`, `∂tt`, `∇`, ...).
115
-
116
108
## Cell fields
117
109
The time-dependent equivalent of `CellField` is `TransientCellField`. It stores the cell field itself together with its derivatives up to the order of the ODE.
118
110
@@ -163,7 +155,15 @@ TransientLinearFEOperator((stiffness, mass), res, U, V, constant_forms=(false, t
163
155
```
164
156
If $\kappa$ is constant, the keyword `constant_forms` could be replaced by `(true, true)`.
165
157
166
-
**Important** Note that in these examples, for optimal performance, `κ` should be a `time_slicing`.
158
+
## The `TimeSpaceFunction` constructor
159
+
Apply differential operators on a function that depends on time and space is somewhat cumbersome. Let `f` be a function of time and space, and `g(t) = x -> f(t, x)` (as in the prescription of the boundary conditions `g` above). Applying the operator $\partial_{t} - \Delta$ to `g` and evaluating at $(t, x)$ is written `∂t(g)(t)(x) - Δ(g(t))(x)`.
160
+
161
+
The constructor `TimeSpaceFunction` allows for simpler notations: let `h = TimeSpaceFunction(g)`. The object `h` is a functor that supports the notations
162
+
*`op(h)`: a `TimeSpaceFunction` representing both `t -> x -> op(f)(t, x)` and `(t, x) -> op(f)(t, x)`,
163
+
*`op(h)(t)`: a function of space representing `x -> op(f)(t, x)`
164
+
*`op(h)(t, x)`: the quantity `op(f)(t, x)` (this notation is equivalent to `op(h)(t)(x)`),
165
+
166
+
for all spatial and temporal differential operator, i.e. `op` in `(time_derivative, gradient, symmetric_gradient, divergence, curl, laplacian)` and their symbolic aliases (`∂t`, `∂tt`, `∇`, ...). The operator above applied to `h` and evaluated at `(t, x)` can be conveniently written `∂t(h)(t, x) - Δ(h)(t, x)`.
167
167
168
168
## Solver and solution
169
169
The next step is to choose an ODE solver (see below for a full list) and specify the boundary conditions. The solution can then be iterated over until the final time is reached.
0 commit comments