Hi everyone,
I am new to FEniCS, I am trying to calculate the terms that make up the dynamic equation of a fluid. I have a question about one of the terms that satisfies the Poisson equation. I need to determine the term \vec{H}_{vel} = Factor x \nabla^2 \vec{vel}. Here, vel is a known vector field and this equation has the condition of the normal derivative of vel is zero (similar to the first example of the Fenics tutorial).
In order to determine the Hvel, I have written the following code. But I do not sure if this is correct since vel is known. The result I get is not consistent with what I expect.
import numpy as np
import dolfinx
from dolfinx.fem import Function, FunctionSpace, Constant
from dolfinx import fem, mesh, plot
import ufl
Nx, Ny, Nz = 50, 50, 10
L, B, H = 100,100,10
mesh = dolfinx.mesh.create_box(MPI.COMM_WORLD, [np.array([0,0,0]), np.array([L, B, H])], [Nx,Ny,Nz])
V = fem.VectorFunctionSpace(mesh, ("CG", 1))
vel = Function(V)
def Velocity_Field(x):
values = np.zeros((3, x.shape[1]))
values[2, :] = 1
return values
vel.interpolate(Velocity_Field)
Hvel = Function(V)
v = ufl.TestFunction(V)
F = Factor*ufl.inner(ufl.grad(vel), ufl.grad(v)) * ufl.dx - ufl.inner(Hvel, v) * ufl.dx
problem = fem.petsc.NonlinearProblem(F, Hvel)
solver = nls.petsc.NewtonSolver(MPI.COMM_WORLD, problem)
thanks