Julia 语言 FEniCS 周期性边界条件
Julia language FEniCS periodic boundary condition
我想在 FEniCS 中为 Julia 语言应用周期性边界条件,但我找到的所有示例都在 C++ 或 Python 中。如何使用 Julia 创建周期性边界条件?这似乎很难,因为 Julia 没有 类。
这是一个最小的例子:
using FEniCS
using PyCall
length=2.2
height=0.41
channel = Rectangle(Point([0.0, 0.0]), Point([length, height]))
domain = channel
mesh = generate_mesh(domain, 64)
# insert function here for PeriodicBoundarycondition
Q = FunctionSpace(mesh, "P", 1,constrained_domain=#the function that i am looking for)
我查看了构成 FEniCS 的 julia 代码、fenics 页面上的周期性边界条件示例,以及我的一些旧 python fenics 代码,它启发了我写这篇文章:
using FEniCS
using PyCall
@pyimport fenics
py"""
from dolfin import *
from mshr import *
length=2.2
height=0.41
channel = Rectangle(Point([0.0, 0.0]), Point([length, height]))
domain = channel
mesh = generate_mesh(domain, 64)
subdomains = MeshFunction("size_t", mesh, 1)
subdomains.set_all(0)
class Wall(SubDomain):
def inside(self,x,on_boundary):
return (near(x[1],height) or near(x[1],height)) and on_boundary
wall=Wall()
class PeriodicBoundary(SubDomain):
# Left boundary is "target domain" G
def inside(self, x, on_boundary):
return bool(x[0] < DOLFIN_EPS and x[0] > -DOLFIN_EPS and on_boundary)
# Map right boundary (H) to left boundary (G)
def map(self, x, y):
y[0] = x[0] - length
y[1] = x[1]
pbc=PeriodicBoundary()
"""
Q=FunctionSpace(fenics.VectorFunctionSpace(py"mesh", "P", 1,constrained_domain=py"pbc"))
该解决方案不是最优的,因为它只是完成了 python 中的所有事情,但我认为我将不得不接受它。
我想在 FEniCS 中为 Julia 语言应用周期性边界条件,但我找到的所有示例都在 C++ 或 Python 中。如何使用 Julia 创建周期性边界条件?这似乎很难,因为 Julia 没有 类。 这是一个最小的例子:
using FEniCS
using PyCall
length=2.2
height=0.41
channel = Rectangle(Point([0.0, 0.0]), Point([length, height]))
domain = channel
mesh = generate_mesh(domain, 64)
# insert function here for PeriodicBoundarycondition
Q = FunctionSpace(mesh, "P", 1,constrained_domain=#the function that i am looking for)
我查看了构成 FEniCS 的 julia 代码、fenics 页面上的周期性边界条件示例,以及我的一些旧 python fenics 代码,它启发了我写这篇文章:
using FEniCS
using PyCall
@pyimport fenics
py"""
from dolfin import *
from mshr import *
length=2.2
height=0.41
channel = Rectangle(Point([0.0, 0.0]), Point([length, height]))
domain = channel
mesh = generate_mesh(domain, 64)
subdomains = MeshFunction("size_t", mesh, 1)
subdomains.set_all(0)
class Wall(SubDomain):
def inside(self,x,on_boundary):
return (near(x[1],height) or near(x[1],height)) and on_boundary
wall=Wall()
class PeriodicBoundary(SubDomain):
# Left boundary is "target domain" G
def inside(self, x, on_boundary):
return bool(x[0] < DOLFIN_EPS and x[0] > -DOLFIN_EPS and on_boundary)
# Map right boundary (H) to left boundary (G)
def map(self, x, y):
y[0] = x[0] - length
y[1] = x[1]
pbc=PeriodicBoundary()
"""
Q=FunctionSpace(fenics.VectorFunctionSpace(py"mesh", "P", 1,constrained_domain=py"pbc"))
该解决方案不是最优的,因为它只是完成了 python 中的所有事情,但我认为我将不得不接受它。