I hope you are familiar with some concepts of mesh deformation.
I am trying to solve the Laplace or biharmonic equation for mesh deformation. The mesh is an NACA0012 airfoil, with the deformation prescribed as a rotation about the quarter-chord point at (-0.25, 0). In the example, only the displacement contour in the X-direction after rotation is shown.
It might seem a bit complex, but it is simplified to a simple mathematical expression:
Laplace: Δu = 0 in Ω, u = fun_rotate on ∂Ω_in, and u = 0 on ∂Ω_out.
Biharmonic: ΔΔu = 0 in Ω, u = fun_rotate on ∂Ω_in, u = 0 on ∂Ω_out, and Δu = 0 on ∂Ω_in and ∂Ω_out.
I am currently unsure whether the result for the biharmonic equation is correct, as according to my previous analysis, it should be identical to the Laplace result.
So either the biharmonic result is incorrect, or my previous analysis is flawed.
If you could provide any assistance, I would be very grateful.
My code is:
from dolfin import *
import ufl
import matplotlib.pyplot as plt
file = 'naca0012'
x0 = -0.25
y0 = 0.0
angle0 = 0.2
def run_fenics_biharm():
parameters["form_compiler"]["cpp_optimize"] = True
parameters["form_compiler"]["optimize"] = True
parameters["ghost_mode"] = "shared_facet"
grid = Mesh((file + ".xml"))
boundaries = MeshFunction("size_t", grid, (file + "_facet_region.xml"))
h = CellDiameter(grid)
h_avg = (h('+') + h('-')) / 2.0
n = FacetNormal(grid)
f = Constant(0.0)
alpha = Constant(8.0)
V1 = FunctionSpace(grid, 'CG', 2)
u_D1 = Expression('x[0] * cos(angle) + x[1] * sin(angle) + x0 * (1 - cos(angle)) - y0 * sin(angle) - x[0]',
degree=2, x0=x0, y0=y0, angle=angle0)
bc_in1 = DirichletBC(V1, u_D1, boundaries, 2)
bc_out1 = DirichletBC(V1, Constant(0.0), boundaries, 3)
bc1 = [bc_in1, bc_out1]
u1 = TrialFunction(V1)
v1 = TestFunction(V1)
try:
a1 = (inner(div(grad(u1)), div(grad(v1))) * ufl.dx
- inner(avg(div(grad(u1))), jump(grad(v1), n)) * dS
- inner(jump(grad(u1), n), avg(div(grad(v1)))) * dS
+ alpha / h_avg * inner(jump(grad(u1), n), jump(grad(v1), n)) * dS)
L1 = f * v1 * ufl.dx
except TypeError as e:
print(f"\nCaught TypeError: {e}")
a1 = (inner(div(grad(u1)), div(grad(v1))) * dx
- inner(avg(div(grad(u1))), jump(grad(v1), n)) * dS
- inner(jump(grad(u1), n), avg(div(grad(v1)))) * dS
+ alpha / h_avg * inner(jump(grad(u1), n), jump(grad(v1), n)) * dS)
L1 = f * v1 * dx
u1 = Function(V1)
solve(a1 == L1, u1, bc1)
return u1
def run_fenics():
parameters["form_compiler"]["cpp_optimize"] = True
parameters["form_compiler"]["optimize"] = True
parameters["ghost_mode"] = "shared_facet"
grid = Mesh((file + ".xml"))
boundaries = MeshFunction("size_t", grid, (file + "_facet_region.xml"))
V1 = FunctionSpace(grid, 'CG', 2)
u_D1 = Expression('x[0] * cos(angle) + x[1] * sin(angle) + x0 * (1 - cos(angle)) - y0 * sin(angle) - x[0]',
degree=2, x0=x0, y0=y0, angle=angle0)
bc_in1 = DirichletBC(V1, u_D1, boundaries, 2)
bc_out1 = DirichletBC(V1, Constant(0.0), boundaries, 3)
bc1 = [bc_in1, bc_out1]
u1 = Function(V1)
v1 = TestFunction(V1)
f1 = Constant(0.0)
try:
F1 = dot(grad(u1), grad(v1)) * ufl.dx - f1 * v1 * ufl.dx
except TypeError as e:
print(f"\nCaught TypeError: {e}")
F1 = dot(grad(u1), grad(v1)) * dx - f1 * v1 * dx
solve(F1 == 0, u1, bc1)
return u1
u_laplace = run_fenics()
u_biharm = run_fenics_biharm()
plot(u_laplace)
plt.show()
plot(u_biharm)
plt.show()
My mesh file is: