我具有由泊松方程在两个维度支配的物理问题 我有两个梯度分量的测量 ∂ ü / ∂ X和 ∂ ú / ∂ ý沿边界的某些部分, Γ 米,所以想强加 ∂ û
切向梯度分量,,我可以整合,然后通过狄利克雷条件执行,使得 ∫Γ米∂ù 为了同时施加法向分量, ∂ ù
所以我觉得变形式是那么 我花了很长时间尝试将有关问题的信息(例如https://answers.launchpad.net/fenics/+question/212434https://https://answers.launchpad.net/fenics/+question)拼凑起来 / 216323
但仍然看不到我要去哪里。到目前为止,我的解决方案尝试是:
from dolfin import *
# Create mesh and define function space
mesh = UnitSquareMesh(64, 64)
V = FunctionSpace(mesh, "Lagrange", 1)
R = FunctionSpace(mesh, "R", 0)
W = V * R
# Create mesh function over cell facets
boundary_parts = MeshFunction("uint", mesh, mesh.topology().dim()-1)
# Mark left boundary facets as subdomain 0
class LeftBoundary(SubDomain):
def inside(self, x, on_boundary):
return on_boundary and x[0] < DOLFIN_EPS
Gamma_Left = LeftBoundary()
Gamma_Left.mark(boundary_parts, 0)
class FarField(SubDomain):
def inside(self, x, on_boundary):
return on_boundary and ( (x[0] > 1.0-DOLFIN_EPS) \
or (x[1]<DOLFIN_EPS) or (x[1]> 1.0-DOLFIN_EPS) )
Gamma_FF = FarField()
Gamma_FF.mark(boundary_parts, 1)
# Define boundary condition
u0 = Expression("sin(x[1]*pi)")
bcs = [DirichletBC(V, u0, Gamma_Left)]
# Define variational problem
(u, lmbd) = TrialFunctions(W)
(v, d) = TestFunctions(W)
f = Expression("10*exp(-(pow(x[0] - 0.5, 2) + pow(x[1] - 0.5, 2)) / 0.02)")
g = Constant(0.0)
h = Constant(-4.0)
n = FacetNormal(mesh)
F = inner(grad(u), grad(v))*dx + d*dot(grad(u),n)*ds(0) + lmbd*dot(grad(v),n)*ds(0)-\
(f*v*dx + g*v*ds(1) + h*d*ds(0) + lmbd*h*ds(0))
a = lhs(F)
L = rhs(F)
# Compute solution
A = assemble(a, exterior_facet_domains=boundary_parts)
b = assemble(L, exterior_facet_domains=boundary_parts)
for bc in bcs: bc.apply(A, b)
w = Function(W)
solve(A, w.vector(), b, 'lu')
(u,lmbd) = w.split()
# Plot solution
plot(u, interactive=True)
可以运行,但给出的噪声结果根本不像泊松方程的解。似乎与组合函数空间有关,但是我找不到错误。
我将不胜感激,向正确的方向提供帮助或指示-非常感谢!
干杯
马库斯