@@ -108,6 +108,120 @@ in the dual space to `V` to assembled 1-forms in the dual space to
108
108
`W `.
109
109
110
110
111
+ Interpolation across meshes
112
+ ---------------------------
113
+
114
+ The interpolation API supports interpolation between meshes where the target
115
+ function space has finite elements (as given in the list of
116
+ :ref: `supported elements <supported_elements >`)
117
+
118
+ * **Lagrange/CG ** (also known a Continuous Galerkin or P elements),
119
+ * **Q ** (i.e. Lagrange/CG on lines, quadrilaterals and hexahedra),
120
+ * **Discontinuous Lagrange/DG ** (also known as Discontinuous Galerkin or DP elements) and
121
+ * **DQ ** (i.e. Discontinuous Lagrange/DG on lines, quadrilaterals and hexahedra).
122
+
123
+ Vector, tensor and mixed function spaces can also be interpolated into from
124
+ other meshes as long as they are constructed from these spaces.
125
+
126
+ .. note ::
127
+
128
+ The list of supported elements above is only for *target * function spaces.
129
+ Function spaces on the *source * mesh can be built from most of the supported
130
+ elements.
131
+
132
+ There are few constraints on the meshes involved: the target mesh can have a
133
+ different cell shape, topological dimension, or resolution to the source mesh.
134
+ There are many use cases for this: For example, two solutions to the same
135
+ problem calculated on meshes with different resolutions or cell shapes can be
136
+ interpolated onto one another, or onto a third, finer mesh, and be directly
137
+ compared.
138
+
139
+
140
+ Interpolating onto sub-domain meshes
141
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
142
+
143
+ The target mesh for a cross-mesh interpolation need not cover the full domain
144
+ of the source mesh. Volume, surface and line integrals can therefore be
145
+ calculated by interpolating onto the mesh or
146
+ :ref: `immersed manifold <immersed_manifolds >` which defines the volume,
147
+ surface or line of interest in the domain. The integral itself is calculated
148
+ by calling :py:func: `~.assemble ` on an approriate form over the target mesh
149
+ function space:
150
+
151
+ .. literalinclude :: ../../tests/regression/test_interpolation_manual.py
152
+ :language: python3
153
+ :dedent:
154
+ :lines: 11-18, 31-40
155
+
156
+ For more on forms, see :ref: `this section of the manual <more_complicated_forms >`.
157
+
158
+
159
+ Interpolating onto other meshes
160
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
161
+
162
+ .. note ::
163
+
164
+ Interpolation *from * :ref: `immersed manifolds <immersed_manifolds >` and
165
+ :ref: `high-order meshes <changing_coordinate_fs >` is currently not supported.
166
+
167
+ If the target mesh extends outside the source mesh domain, then cross-mesh
168
+ interpolation will raise a :py:class: `~.DofNotDefinedError `.
169
+
170
+ .. literalinclude :: ../../tests/regression/test_interpolation_manual.py
171
+ :language: python3
172
+ :dedent:
173
+ :lines: 46-58, 64-65
174
+
175
+ This can be overriden with the optional ``allow_missing_dofs `` keyword
176
+ argument:
177
+
178
+ .. literalinclude :: ../../tests/regression/test_interpolation_manual.py
179
+ :language: python3
180
+ :dedent:
181
+ :lines: 72-73, 80
182
+
183
+ By default the missing degrees of freedom (DoFs, the global basis function
184
+ coefficients which could not be set) are zero:
185
+
186
+ .. literalinclude :: ../../tests/regression/test_interpolation_manual.py
187
+ :language: python3
188
+ :dedent:
189
+ :lines: 85
190
+
191
+ We can optionally specify a value to use for our missing DoFs. Here
192
+ we set them to be ``nan `` ('not a number') for easy identification:
193
+
194
+ .. literalinclude :: ../../tests/regression/test_interpolation_manual.py
195
+ :language: python3
196
+ :dedent:
197
+ :lines: 90-93
198
+
199
+ When using :py:class: `~.Interpolator `\s , the ``allow_missing_dofs `` keyword
200
+ argument is set at construction:
201
+
202
+ .. literalinclude :: ../../tests/regression/test_interpolation_manual.py
203
+ :language: python3
204
+ :dedent:
205
+ :lines: 100
206
+
207
+ The ``default_missing_val `` keyword argument is then set whenever we call
208
+ :py:meth: `~.Interpolator.interpolate `:
209
+
210
+ .. literalinclude :: ../../tests/regression/test_interpolation_manual.py
211
+ :language: python3
212
+ :dedent:
213
+ :lines: 103
214
+
215
+ If we supply an output :py:class: `~.Function ` and don't set
216
+ ``default_missing_val `` then any missing DoFs are left as they were prior to
217
+ interpolation:
218
+
219
+ .. literalinclude :: ../../tests/regression/test_interpolation_manual.py
220
+ :language: python3
221
+ :dedent:
222
+ :lines: 107-110, 113-115, 124-126
223
+
224
+
111
225
Interpolation from external data
112
226
--------------------------------
113
227
0 commit comments