-
-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using DirichletBC #20
Comments
Hi!
We've had a very brief discussion on this in Gitter with Chris. https://fenicsproject.org/pub/tutorial/html/._ftut1004.html gives a slightly more detailed explanation of what each function does. To get it to work like that in Julia, I believe we need to change the u0_boundary function slightly (I'm not quite sure how this modification will be , but I'd assume it will resemble the direct implementation (calculating the distance between point and boundary?)
…________________________________
From: Bart Janssens <[email protected]>
Sent: 27 July 2017 20:46:48
To: JuliaDiffEq/FEniCS.jl
Cc: Subscribed
Subject: [JuliaDiffEq/FEniCS.jl] Using DirichletBC (#20)
Hi,
I'm trying to use the DirichletBC, translating the following Python script:
from dolfin import *
n = 64
# Create mesh and define function space
mesh = UnitSquareMesh(n, n)
V = FunctionSpace(mesh, 'Lagrange', 1)
# Define boundary conditions
u0 = Expression('1 + x[0]*x[0] + 2*x[1]*x[1]', degree=2)
def u0_boundary(x, on_boundary):
return on_boundary
bc = DirichletBC(V, u0, u0_boundary)
into Julia:
using FEniCS
n = 64
# Create mesh and define function space
mesh = UnitSquareMesh(n, n)
V = FunctionSpace(mesh, "Lagrange", 1)
# Define boundary conditions
u0 = Expression("1 + x[0]*x[0] + 2*x[1]*x[1]", degree=2)
function bc_func(x, on_boundary)
return on_boundary
end
bc = DirichletBC(V, u0, bc_func)
This gives the error:
ERROR: LoadError: PyError (ccall(@pysym(:PyObject_Call), PyPtr, (PyPtr, PyPtr, PyPtr), o, arg, C_NULL)) <class 'TypeError'>
TypeError("float() argument must be a string or a number, not 'PyCall.jlwrap'",)
File "/usr/lib/python3.6/site-packages/dolfin/fem/bcs.py", line 97, in __init__
expr = Constant(args[1]) # let Constant handle all problems
File "/usr/lib/python3.6/site-packages/dolfin/functions/constant.py", line 75, in __init__
floats = list(map(float, array.flat))
Stacktrace:
[1] pyerr_check at /home/username/.julia/v0.6/PyCall/src/exception.jl:56 [inlined]
[2] pyerr_check at /home/username/.julia/v0.6/PyCall/src/exception.jl:61 [inlined]
[3] macro expansion at /home/username/.julia/v0.6/PyCall/src/exception.jl:81 [inlined]
[4] #_pycall#66(::Array{Any,1}, ::Function, ::PyCall.PyObject, ::PyCall.PyObject, ::Vararg{Any,N} where N) at /home/username/.julia/v0.6/PyCall/src/PyCall.jl:596
[5] _pycall(::PyCall.PyObject, ::PyCall.PyObject, ::Vararg{Any,N} where N) at /home/username/.julia/v0.6/PyCall/src/PyCall.jl:584
[6] #pycall#70(::Array{Any,1}, ::Function, ::PyCall.PyObject, ::Type{PyCall.PyAny}, ::PyCall.PyObject, ::Vararg{Any,N} where N) at /home/username/.julia/v0.6/PyCall/src/PyCall.jl:618
[7] pycall(::PyCall.PyObject, ::Type{PyCall.PyAny}, ::PyCall.PyObject, ::Vararg{Any,N} where N) at /home/username/.julia/v0.6/PyCall/src/PyCall.jl:618
[8] #call#71(::Array{Any,1}, ::PyCall.PyObject, ::PyCall.PyObject, ::Vararg{Any,N} where N) at /home/username/.julia/v0.6/PyCall/src/PyCall.jl:621
[9] DirichletBC(::FEniCS.FunctionSpaceImpl, ::FEniCS.ExpressionImpl, ::Function) at /home/username/.julia/v0.6/FEniCS/src/jfem.jl:68
while loading /home/username/CloudStation/projects/julia/gsoc/2017/poisson.jl, in expression starting on line 16
Any ideas?
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub<#20>, or mute the thread<https://github.com/notifications/unsubscribe-auth/APV6MX70pb1_IhEpob_iCXpclO54Ofoxks5sSOkngaJpZM4OlwHt>.
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi,
I'm trying to use the DirichletBC, translating the following Python script:
into Julia:
This gives the error:
Any ideas?
The text was updated successfully, but these errors were encountered: