如果您能帮我解决这个问题,我将不胜感激,因为我认为我遗漏了一些简单的东西,或者应该使用替代语法:
我在 FEniCS 中运行以下 Python 代码,在那里我求解一个变量 - 解决方案看起来像我期望的那样,所以没有问题,现在我希望求解下一个方程,我需要根据获得的定义子域解决方案,但新问题的子域图(在同一代码中)是错误的。看起来好像它不能将解决方案变量作为出现在子域定义中的合法参数;也许我需要改变/避免内部方法?
solve(a == L, phi1)
plot(phi1, title="phi1_t01")
# S at t1
# define mesh
htopv = 0.5
mesh = Rectangle(0, 0, 1, htopv, 250, 250)
# define a meshfunction for numbering subdomains
subdomains = MeshFunction("uint", mesh, 2)
# define the subdomains
class Biomass(SubDomain):
def inside(self, x):
return True if phi1 <= 0 else False
class Interface(SubDomain):
def inside(self, x):
return True if phi1 >= 0 and phi1 <= 0.1 else False
class Bulk(SubDomain):
def inside(self, x):
return True if phi1 >= 0.1 else False
# note: it is essential to use <= and >= in the comparisons
# mark the subdomains with numbers
subdomain0 = Biomass()
subdomain0.mark(subdomains, 0)
subdomain1 = Interface()
subdomain1.mark(subdomains, 1)
subdomain2 = Bulk()
subdomain2.mark(subdomains, 2)
# plot the subdomains
plot(subdomains, title="S_t1 subdomains")