~~~~~ I have one file contains node coordinates and displacement field/temperature field data and would like to import function in Dolfinx as boundary conditions. I wonder how this works in the Dolfinx version? ~~~~~ I tried with reference to Impose Velocity Profile on Inlet Face using Array - #6 by dokken , but some of the code under dolfinx may not apply.
# read mesh and meshtags
with dolfinx.io.XDMFFile(MPI.COMM_WORLD, 'mesh.xdmf', 'r') as xdmf:
mesh = xdmf.read_mesh(name="Grid")
subdomains = xdmf.read_meshtags(mesh, name="Grid")
mesh.topology.create_connectivity(mesh.topology.dim, mesh.topology.dim-1)
with dolfinx.io.XDMFFile(MPI.COMM_WORLD, 'mt.xdmf', 'r') as xdmf:
boundaries = xdmf.read_meshtags(mesh, name="Grid")
# Define Function
V = dolfinx.fem.FunctionSpace(mesh, ("CG", 1))
u_p = dolfinx.fem.Function(V)
dof_coords = V.tabulate_dof_coordinates()
# from .txt import data
dofs = np.array([[x0,y0,z0],...,[xn,yn,zn]])
u_x = np.array([u_x])
u_y = np.array([])
u_z = np.array([])
# Function degrees of freedom are assigned through /.txt X/Y/Z value data
u_p.vector.setValueLocal(dof_index, values[u_x]/values[u_y]/values[u_z])
# Apply the dirichlet boundary to S0 surface of meshtag
bcl = DirichletBC(V, u_p, S0)
But here it has a constant pressure “q”, and if the pressure is a spatial distribution q(x,y,z), how do I define it in variational form? I now have to import pressure to dolfinx.fem.functionspace definition of function, but the test-function “v” is dolfinx.fem.VectorFunctionSpace defined.
~~~~~ Yes, I also got a lot of help from this topic before. However, the difference between my current problem and this is that the distribution I imported is not as DirichletBC, it appears in the linear term as Neumann boundary. ~~~~~ At this time, the p is defined in dolfinx.fem.functionspace and the test-function “v” is defined in dolfinx.fem.VectorFunctionSpace. p[pressure] is just one column of degrees of freedom, and V is three columns of degrees[v_x,v_y,v_z] of freedom, I don’t know how do they multiply. Profile - RokyC - FEniCS Project, In the above example, the problem is avoided because p is a constant in space.
The pressure p cannot be a scalar value, as there is a dot product between p and v, meaning that they are of the same dimension.
I guess you are assuming that the pressure p(x,y,z) is working in the normal direction?