我想在FEniCS中为Julia应用一个周期边界条件,但是我发现的所有例子都是用C++或Python。如何利用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)发布于 2018-10-29 17:14:06
我看了构成FEniCS的朱莉娅代码,fenics页面上的周期性边界条件的例子,以及我为fenics编写的一些以前的python代码,它激励我写了这样的文章:
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中完成整个过程,但我认为我必须接受它。
https://stackoverflow.com/questions/53048053
复制相似问题