I understand the use of algebra in the Expression statement, but I’m not sure how to use it in the NEAR function, e.g.
walls = 'near(x[1], 0) || near(x[1], 2*L),L=L'
The following error is returned
RuntimeError: Unable to compile C++ code with dijitso
But the direct use of numbers is valid
walls = 'near(x[1], 0) || near(x[1], 2*0.176)'
So what is the proper usage?
dokken
2
As it has to be a string that is readable by a C++ compiler, the value has to be declared in a way that the compiler can understand. For instance:
from dolfin import *
L = 2
mesh = RectangleMesh(Point(0,0), Point(L, 2*L), 10, 10)
walls = 'near(x[1], 0) || near(x[1], 2*{0:.2f})'.format(L)
V = FunctionSpace(mesh, "CG", 1)
u = Function(V)
bc = DirichletBC(V, Constant(1), walls)
bc.apply(u.vector())
plot(u)
import matplotlib.pyplot as plt
plt.savefig("u.png")