Map Values from and to Internal Domain#

import minterpy as mp
import numpy as np

Once a Domain instance is constructed, it can be used to map (i.e., transform) values between the user-defined domain \(\Omega\) and the internal reference domain (currently \([-1, 1]^m\)) in both directions.

This guide demonstrates how to carry out such mapping.

Example: Three-dimensional rectangular domain#

Create a three-dimensional rectangular domain that corresponds to:

\[ \Omega = [0.0, 5.0] \times [10.0, 15.0] \times [0.5, 3.0] \]

Domain instance#

The rectangular domain is defined by three pairs of bounds (each forms an interval) one for each dimension. We can specify them in a single two-dimensional array of three rows:

bounds = np.array([
    [0.0, 5.0],
    [10.0, 15.0],
    [0.5, 3.0],
])

An instance of Domain given an array of bounds can be constructed using the default constructor:

dom = mp.Domain(bounds)

We can verify that the domain is three dimensional:

print(dom.spatial_dimension)
3

and with the appropriate bounds:

print(dom.bounds)
[[ 0.   5. ]
 [10.  15. ]
 [ 0.5  3. ]]

Map values from the internal domain#

We can use the instance to transform a set of values in the internal domain to the corresponding values in the user domain. For instance, consider the set of values

xx = np.array([
    [-1.0, 1.0, 0.5],
    [0.5, 0.5, 0.5],
    [0.25, 0.75, -0.75],
])

in which each row corresponds to a point in the three dimensional space in the internal domain. The corresponding values in the user domain

dom.map_from_internal(xx)
array([[ 0.    , 15.    ,  2.375 ],
       [ 3.75  , 13.75  ,  2.375 ],
       [ 3.125 , 14.375 ,  0.8125]])

Note

Such a transformation is required, for instance, when evaluating the function of interest at the unisolvent nodes, which Minterpy provides in the internal reference domain (currently \([-1, 1]^m\)).

Map values to the internal domain#

We can also use the instance to transform a set of values in the user domain to the corresponding values in the internal domain. For instance, consider the set of values in the user domain

xx = np.array([
    [0.5, 11.0, 1.75],
    [1.0, 14.0, 2.5],
    [0, 15, 0.5],
])

in which each row corresponds to a point in the three-dimensional space in the user domain. The corresponding values in the internal domain can be obtained with

dom.map_to_internal(xx)
array([[-0.8, -0.6,  0. ],
       [-0.6,  0.6,  0.6],
       [-1. ,  1. , -1. ]])

Note

Such a transformation is required, for instance, when evaluating the internal polynomial representation at the points defined in the user domain.