Reference points wrongly mapped

Using basix, I’m getting reference points mapped to wrong physical points. See below

import basix
import basix.ufl
import numpy as np


def compute_physical_points(nodes_coords, x_ref):
    """
    Parameters
    ----------
    nodes_coords : np.array(shape=(n, 2))
        node coords of the mesh cell
    x_ref : np.array(shape=(m, 2))
        points in the reference cell

    Returns:
    -------
    np.array(shape=(m, 2))
        Physical points in the cell.
    """
    element = basix.ufl.element("Lagrange", "quadrilateral", 1)
    basis_values = element.tabulate(0, x_ref)
    x = basis_values[0, :, :] @ nodes_coords
    return x


nodes_coords = np.array([[0, 0], [1, 0], [1, 1], [0, 1]])
x_ref = np.array([[0.5, 0.5], [0.5, 0.25], [0.25, 0.5], [0.25, 0.25]])
print(compute_physical_points(nodes_coords, x_ref))

The output is

[[0.5   0.5  ]
 [0.5   0.25 ]
 [0.5   0.5  ]
 [0.375 0.25 ]]

The second and third point (row) are x_ref is wrongly mapped. In fact, the first and third point are mapped to the same physical point.

Are you sure you’ve ordered your quadrilateral correctly?

1 Like

You’re right. Thanks!

1 Like