I have a question that if the orders of nodes and cells will be self-adujusted when creating mesh using dolfinx.mesh.create_mesh()
. And if that, how will they be adjusted?
When I used dolfinx.mesh.create_mesh()
to create a mesh, I found that my original nodes order and connectivities seemd to be adjusted in dolfinx.
The MWE is as follows:
import ufl
import basix
import dolfinx
from mpi4py import MPI
import numpy as np
nodes = np.array([[0, 0, 0], [1, 0, 0], [1, 1, 0], [0, 1, 0], [0, 0, 1], [1, 0, 1], [1, 1, 1], [0, 1, 1],
[-1, 0, 0], [-1, 0, 1], [-1, 1, 1], [-1, 1, 0]])
cells = np.array([[3, 11, 8, 0, 7, 10, 9, 4], [0, 1, 2, 3, 4, 5, 6, 7]], np.int32)
cells[:, [2,3,6,7]] = cells[:, [3, 2, 7, 6]]
c_el = ufl.Mesh(basix.ufl.element("Lagrange", "hexahedron", 1, shape=(nodes.shape[1],)))
domain = dolfinx.mesh.create_mesh(MPI.COMM_SELF, cells, nodes, c_el)
print(f"Nodes: {domain.geometry.x}, \n Cells: {domain.topology.connectivity(3,0)}")
with dolfinx.io.XDMFFile(MPI.COMM_SELF, "../../Data/Mesh/dol_mesh.xdmf", "w") as file:
file.write_mesh(domain)
The new nodes and cells became:
Nodes: [[ 0. 1. 0.]
[-1. 1. 0.]
[ 0. 0. 0.]
[-1. 0. 0.]
[ 0. 1. 1.]
[-1. 1. 1.]
[ 0. 0. 1.]
[-1. 0. 1.]
[ 1. 0. 0.]
[ 1. 1. 0.]
[ 1. 0. 1.]
[ 1. 1. 1.]],
Cells: <AdjacencyList> with 2 nodes
0: [0 1 2 3 4 5 6 7 ]
1: [2 8 0 9 6 10 4 11 ]
The order had changed.