ANSYS Fluent to FEniCSx

Hi everyone!
I have the following problem.
I have obtained a solution with ANSYS Fluent and I want to analyze it with FEniCSx. The mesh is in Nastran format and I have converted it to XDFM with the following line

 meshio convert mesh_12_nastran.bdf venturi_coarse.xdmf

I get from Fluent a .txt file with 4 columns. (vx.txt)
the number of the point, the 3 spatial coordinates and the value of the function in these points.

my code in FEniCSx:

import dolfinx
from mpi4py import MPI
from petsc4py import PETSc
import numpy as np
import math
import ufl
from ufl import (FacetNormal, FiniteElement, Identity, Measure, TestFunction, TrialFunction, VectorElement,
                 as_vector, div, dot, ds, dx, inner, lhs, grad, nabla_grad, rhs, sym)
from dolfinx.fem.petsc import (apply_lifting, assemble_matrix, assemble_vector, 
                               create_vector, create_matrix, set_bc)

from dolfinx.fem import (Constant, Function, FunctionSpace, 
                         assemble_scalar, dirichletbc, form, locate_dofs_topological, set_bc)

with dolfinx.io.XDMFFile(MPI.COMM_WORLD, "venturi_coarse.xdmf", "r") as xdmf:
    domain = xdmf.read_mesh(name="Grid")

s_cg1 = FiniteElement("CG", domain.ufl_cell(), 1)
Q = dolfinx.fem.FunctionSpace(domain, s_cg1)

vx_np = np.loadtxt('vx.txt')
vx_aux = []
vx_aux[:] = vx_np[:,4]

vx = Function(Q)
vx.x.array[:]=vx_aux[:]

with dolfinx.io.XDMFFile(domain.comm, "Plot/vx.xdmf", "w") as file:
    file.write_mesh(domain)
    file.write_function(vx)

and obtain

but it should be

Does anyone have any ideas? I think the vertices are not ordered in the same way.
Besides solving it, I would like to know how I can, given a point, find the nearest vertex (coordinates and mesh number).

In this folder are all the files

You are making a whole lot of assumptions on the ordering of the mesh vertices->dofs here.
Please see: I/O from XDMF/HDF5 files in dolfin-x - #32 by dokken

What you probably could do would be to read in a vertex marker in DOLFINx based on the function data (xdmf.read_meshtags) and map that input to a CG-1 function.

I have a couple of questions.

  • read_meshtags
c = xdmf.read_meshtags(domain , name = 'Grid')
print(len(c.indices))

show the number of cells, no the number of vertex.

print(domain.topology.original_cell_index)
[372552 372567 372553 ... 372758 372761 372760]

This means that the cell 0 is the cell 372552 in Fluent?
Is there something similar with vertices instead of cells?
I understand that this is your suggestion @dokken

  • Function CG-1
f = Function(Q)
print(f.vector.size)
447100

prints the number of vertexs.
can I define a function with values in the cells?