Skip to content

Commit 7aa9c6f

Browse files
authored
Inverse maps (#236)
* add inverse functions * changelog
1 parent f127bc7 commit 7aa9c6f

File tree

2 files changed

+109
-0
lines changed

2 files changed

+109
-0
lines changed

CHANGELOG_SINCE_LAST_VERSION.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
- Bugfixes for piecewise functions on an interval
22
- Added HHJ on a tetrahedron
3+
- Add inverse mapping functions

symfem/mappings.py

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,3 +248,111 @@ def contravariant_inverse_transpose(
248248
j_inv = MatrixFunction([[i.diff(x[j]) for i in inverse_map] for j in range(tdim)])
249249
j_inv /= j_inv.det()
250250
return j_inv @ f
251+
252+
253+
def identity_inverse(
254+
f_in: FunctionInput, map: PointType, inverse_map: PointType, tdim: int,
255+
substitute: bool = True,
256+
) -> AnyFunction:
257+
"""Inverse of identity().
258+
259+
Args:
260+
f_in: The function
261+
map: The map from the reference cell to the physical cell
262+
inverse_map: The map to the reference cell from the physical cell
263+
tdim: The topological dimension of the cell
264+
265+
Returns:
266+
The mapped function
267+
"""
268+
return identity(f_in, inverse_map, map, tdim, substitute)
269+
270+
271+
def l2_inverse(
272+
f_in: FunctionInput, map: PointType, inverse_map: PointType, tdim: int,
273+
substitute: bool = True,
274+
) -> AnyFunction:
275+
"""Inverse of l2().
276+
277+
Args:
278+
f_in: The function
279+
map: The map from the reference cell to the physical cell
280+
inverse_map: The map to the reference cell from the physical cell
281+
tdim: The topological dimension of the cell
282+
283+
Returns:
284+
The mapped function
285+
"""
286+
return l2(f_in, inverse_map, map, tdim, substitute)
287+
288+
289+
def covariant_inverse(
290+
f_in: FunctionInput, map: PointType, inverse_map: PointType, tdim: int,
291+
substitute: bool = True,
292+
) -> AnyFunction:
293+
"""Inverse of covariant().
294+
295+
Args:
296+
f_in: The function
297+
map: The map from the reference cell to the physical cell
298+
inverse_map: The map to the reference cell from the physical cell
299+
tdim: The topological dimension of the cell
300+
301+
Returns:
302+
The mapped function
303+
"""
304+
return covariant(f_in, inverse_map, map, tdim, substitute)
305+
306+
307+
def contravariant_inverse(
308+
f_in: FunctionInput, map: PointType, inverse_map: PointType, tdim: int,
309+
substitute: bool = True
310+
) -> AnyFunction:
311+
"""Inverse of contravariant().
312+
313+
Args:
314+
f_in: The function
315+
map: The map from the reference cell to the physical cell
316+
inverse_map: The map to the reference cell from the physical cell
317+
tdim: The topological dimension of the cell
318+
319+
Returns:
320+
The mapped function
321+
"""
322+
return contravariant(f_in, inverse_map, map, tdim, substitute)
323+
324+
325+
def double_covariant_inverse(
326+
f_in: FunctionInput, map: PointType, inverse_map: PointType, tdim: int,
327+
substitute: bool = True,
328+
) -> AnyFunction:
329+
"""Inverse of double_covariant().
330+
331+
Args:
332+
f_in: The function
333+
map: The map from the reference cell to the physical cell
334+
inverse_map: The map to the reference cell from the physical cell
335+
tdim: The topological dimension of the cell
336+
337+
Returns:
338+
The mapped function
339+
"""
340+
return double_covariant(f_in, inverse_map, map, tdim, substitute)
341+
342+
343+
def double_contravariant_inverse(
344+
f_in: FunctionInput, map: PointType, inverse_map: PointType, tdim: int,
345+
substitute: bool = True
346+
) -> AnyFunction:
347+
"""Inverse of double_contravariant().
348+
349+
Args:
350+
f_in: The function
351+
map: The map from the reference cell to the physical cell
352+
inverse_map: The map to the reference cell from the physical cell
353+
tdim: The topological dimension of the cell
354+
355+
Returns:
356+
The mapped function
357+
"""
358+
return double_contravariant(f_in, inverse_map, map, tdim, substitute)

0 commit comments

Comments
 (0)