Skip to content
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

Open
barche opened this issue Jul 27, 2017 · 1 comment
Open

Using DirichletBC #20

barche opened this issue Jul 27, 2017 · 1 comment

Comments

@barche
Copy link
Contributor

barche commented Jul 27, 2017

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?

@ysimillides
Copy link
Contributor

ysimillides commented Jul 27, 2017 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants