Coder Social home page Coder Social logo

sciml / fenics.jl Goto Github PK

View Code? Open in Web Editor NEW
94.0 13.0 25.0 616 KB

A scientific machine learning (SciML) wrapper for the FEniCS Finite Element library in the Julia programming language

Home Page: https://docs.sciml.ai/FEniCS/stable/

License: Other

Julia 98.56% Dockerfile 1.44%
differentialequations differential-equations fenics julia pde partial-differential-equations sciml scientific-machine-learning

fenics.jl's Introduction

FEniCS.jl: Finite Element PDE Solving in Julia

Join the chat at https://julialang.zulipchat.com #sciml-bridged Global Docs

ColPrac: Contributor's Guide on Collaborative Practices for Community Packages SciML Code Style

FEniCS.jl is a wrapper for the FEniCS library for finite element discretizations of PDEs. This wrapper includes three parts:

  1. Installation and direct access to FEniCS via a Conda installation. Alternatively, one may use their current FEniCS installation.
  2. A low-level development API and provides some functionality to make directly dealing with the library a little bit easier, but still requires knowledge of FEniCS itself. Interfaces have been provided for the main functions and their attributes, and instructions to add further ones can be found here.
  3. A high-level API for usage with DifferentialEquations. An example can be seen solving the heat equation with high order adaptive timestepping.

Various gists/jupyter notebooks have been created to provide a brief overview of the overall functionality, and of any differences between the Pythonic FEniCS and the Julian wrapper. DifferentialEquations.jl ecosystem. Paraview can also be used to visualize various results, just like in FEniCS (see below).

Installation Instructions

To get the wrapper on your system, providing a FEniCS installation exists, follow the below steps:

  1. Add PyCall with the correct Python environment corresponding to FEniCS. Then simply add FEniCS.jl using Pkg.add("FEniCS")

  2. Alternatively, one can install Docker and then run the following command

docker run -ti cmhyett/julia-fenics

and once inside, Julia can be accessed by calling

julia

Once inside the Julia environment, simply add FEniCS with Pkg.add("FEniCS"). All other dependencies are handled by the docker image.

This wrapper was originally started via the Google Summer of Code program along with the help of Chris Rackauckas and Bart Janssens. This was continued via GSoC '18 along with the help of Chris Rackauckas and Timo Betcke.

Tutorial

Below is a small demonstration of how a user would use our code to solve the Poisson equation with Dirichlet conditions. This directly mirrors one of the tutorials FEniCS provides

using FEniCS
mesh = UnitSquareMesh(8,8)
V = FunctionSpace(mesh,"P",1)
u_D = Expression("1+x[0]*x[0]+2*x[1]*x[1]", degree=2)
u = TrialFunction(V)
bc1 = DirichletBC(V,u_D, "on_boundary")
v = TestFunction(V)
f = Constant(-6.0)
a = dot(grad(u),grad(v))*dx
L = f*v*dx
U = FeFunction(V)
lvsolve(a,L,U,bc1) #linear variational solver
errornorm(u_D, U, norm="L2")
get_array(L) #this returns an array for the stiffness matrix
get_array(U) #this returns an array for the solution values
vtkfile = File("poisson/solution.pvd")
vtkfile << U.pyobject #exports the solution to a vtkfile

We can also plot the solution (this relies on FEniCS backend for plotting) or import it from our file into Paraview:

import PyPlot # plotting won't work if PyPlot is not imported
FEniCS.Plot(U)
FEniCS.Plot(mesh)

alt text

alt text

See the examples directory for more examples.

fenics.jl's People

Contributors

arnostrouwen avatar asinghvi17 avatar barche avatar cfbaptista avatar chrisrackauckas avatar christopher-dg avatar cmhyett avatar dependabot[bot] avatar devmotion avatar femtocleaner[bot] avatar github-actions[bot] avatar juliatagbot avatar jw3126 avatar ranocha avatar scottpjones avatar sjkelly avatar thazhemadam avatar tungli avatar xanfus avatar ysimillides avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fenics.jl's Issues

pycall api updates

PyCall 1.90.0 is now released, which change o[:foo] and o["foo"] to o.foo and o."foo", respectively, for python objects o; see also JuliaPy/PyCall.jl#629.

The old getindex methods still work but are deprecated, so you'll want to put out a new release that uses the new methods and REQUIREs PyCall 1.90.0 to avoid having zillions of deprecation messages.

Problem with using FEniCS

If I open a new REPL and do ] build FEniCS and then using FEniCS everything works fine. However, if I just do using FEniCS from the start I get this error:

julia> using FEniCS [ Info: Installing fenics via the Conda fenics=2019.1.0 package... [ Info: Runningconda config --add channels conda-forge --file /Users/sverek/.julia/conda/3/condarc-julia.yml --forcein root environment Warning: 'conda-forge' already in 'channels' list, moving to the top [ Info: Runningconda install -y fenics=2019.1.0` in root environment
Collecting package metadata (current_repodata.json): done
Solving environment: done

All requested packages already installed.

ERROR: InitError: PyError (PyImport_ImportModule) <class 'RuntimeError'>
RuntimeError('Could not find DOLFIN pkg-config file. Please make sure appropriate paths are set.')
File "/Users/sverek/.julia/conda/3/lib/python3.7/site-packages/fenics/init.py", line 7, in
from dolfin import *
File "/Users/sverek/.julia/conda/3/lib/python3.7/site-packages/dolfin/init.py", line 142, in
from .fem.assembling import (assemble, assemble_system, assemble_multimesh,
File "/Users/sverek/.julia/conda/3/lib/python3.7/site-packages/dolfin/fem/assembling.py", line 34, in
from dolfin.fem.form import Form
File "/Users/sverek/.julia/conda/3/lib/python3.7/site-packages/dolfin/fem/form.py", line 12, in
from dolfin.jit.jit import dolfin_pc, ffc_jit
File "/Users/sverek/.julia/conda/3/lib/python3.7/site-packages/dolfin/jit/jit.py", line 18, in
raise RuntimeError("Could not find DOLFIN pkg-config file. Please make sure appropriate paths are set.")

Stacktrace:
[1] pyimport(::String) at /Users/sverek/.julia/packages/PyCall/BcTLp/src/PyCall.jl:547
[2] pyimport_conda(::String, ::String, ::String) at /Users/sverek/.julia/packages/PyCall/BcTLp/src/PyCall.jl:711
[3] init() at /Users/sverek/.julia/packages/FEniCS/LQXLe/src/FEniCS.jl:27
[4] _include_from_serialized(::String, ::Array{Any,1}) at ./loading.jl:697
[5] _require_search_from_serialized(::Base.PkgId, ::String) at ./loading.jl:782
[6] _require(::Base.PkgId) at ./loading.jl:1007
[7] require(::Base.PkgId) at ./loading.jl:928
[8] require(::Module, ::Symbol) at ./loading.jl:923
during initialization of module FEniCS
caused by [exception 1]
PyError (PyImport_ImportModule) <class 'RuntimeError'>
RuntimeError('Could not find DOLFIN pkg-config file. Please make sure appropriate paths are set.')
File "/Users/sverek/.julia/conda/3/lib/python3.7/site-packages/fenics/init.py", line 7, in
from dolfin import *
File "/Users/sverek/.julia/conda/3/lib/python3.7/site-packages/dolfin/init.py", line 142, in
from .fem.assembling import (assemble, assemble_system, assemble_multimesh,
File "/Users/sverek/.julia/conda/3/lib/python3.7/site-packages/dolfin/fem/assembling.py", line 34, in
from dolfin.fem.form import Form
File "/Users/sverek/.julia/conda/3/lib/python3.7/site-packages/dolfin/fem/form.py", line 12, in
from dolfin.jit.jit import dolfin_pc, ffc_jit
File "/Users/sverek/.julia/conda/3/lib/python3.7/site-packages/dolfin/jit/jit.py", line 18, in
raise RuntimeError("Could not find DOLFIN pkg-config file. Please make sure appropriate paths are set.")

Stacktrace:
[1] pyimport(::String) at /Users/sverek/.julia/packages/PyCall/BcTLp/src/PyCall.jl:547
[2] pyimport_conda(::String, ::String, ::String) at /Users/sverek/.julia/packages/PyCall/BcTLp/src/PyCall.jl:705
[3] init() at /Users/sverek/.julia/packages/FEniCS/LQXLe/src/FEniCS.jl:27
[4] _include_from_serialized(::String, ::Array{Any,1}) at ./loading.jl:697
[5] _require_search_from_serialized(::Base.PkgId, ::String) at ./loading.jl:782
[6] _require(::Base.PkgId) at ./loading.jl:1007
[7] require(::Base.PkgId) at ./loading.jl:928
[8] require(::Module, ::Symbol) at ./loading.jl:923
`

Same behavior with FEniCS or FEniCS#master

Julia Version 1.5.2
Commit 539f3ce943 (2020-09-23 23:17 UTC)
Platform Info:
OS: macOS (x86_64-apple-darwin18.7.0)
CPU: Intel(R) Core(TM) i7-8569U CPU @ 2.80GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-9.0.1 (ORCJIT, skylake)

Plotting issue

Can we have better plotting instructions in the README? I am willing do provide a PR, if you tell me a recomended way of plotting.
Just doing FEniCS.Plot(U) merely displays PyObject <matplotlib.tri.tricontour.TriContourSet object at 0x7f3e802bd630> for me.

In order to get a plot I can do

using PyCall
using FEniCS
plt = pyimport("matplotlib").pyplot
FEniCS.Plot(U)
plt.show()

Is that the intended way to do things?

User Expression broken in FEniCS 2018.1

FEniCS 2018.1 changed how UserExpressions work (due to the switch to pybind11), see, e.g., https://www.allanswered.com/post/jrmxq/expression-with-cpp-code-behaviour-changed-with-2018-1-0-dev0pybind11/, https://www.allanswered.com/post/jrmxq/expression-with-cpp-code-behaviour-changed-with-2018-1-0-dev0pybind11/. It seems that this also impacts how Expressions are propagated in Julia: The following line from the README.md no longer works with FEniCS.jl (although it does work in Python and using PyCall!)

u_D = Expression("1+x[0]*x[0]+2*x[1]*x[1]", degree=2)

instead giving

ERROR: PyError ($(Expr(:escape, :(ccall(#= /home/clason/.julia/packages/PyCall/WcrLS/src/pyfncall.jl:101 =# @pysym(:PyObject_Call), PyPtr, (PyPtr, PyPtr, PyPtr), o, pyargsptr, kw))))) <class 'RuntimeError'>
RuntimeError('Must supply C++ code to Expression. You may want to use UserExpression',)
  File "/opt/miniconda/envs/fenicsproject/lib/python3.6/site-packages/dolfin/function/expression.py", line 369, in __init__
    raise RuntimeError("Must supply C++ code to Expression. You may want to use UserExpression")

Stacktrace:
 [1] pyerr_check at /home/clason/.julia/packages/PyCall/WcrLS/src/exception.jl:60 [inlined]
 [2] pyerr_check at /home/clason/.julia/packages/PyCall/WcrLS/src/exception.jl:64 [inlined]
 [3] macro expansion at /home/clason/.julia/packages/PyCall/WcrLS/src/exception.jl:84 [inlined]
 [4] __pycall!(::PyCall.PyObject, ::Ptr{PyCall.PyObject_struct}, ::PyCall.PyObject, ::PyCall.PyObject) at /home/clason/.julia/packages/PyCall/WcrLS/src/pyfncall.jl:101
 [5] _pycall! at /home/clason/.julia/packages/PyCall/WcrLS/src/pyfncall.jl:62 [inlined]
 [6] macro expansion at /home/clason/.julia/packages/PyCall/WcrLS/src/exception.jl:84 [inlined]
 [7] _pycall!(::PyCall.PyObject, ::PyCall.PyObject, ::Tuple{}, ::Int64, ::PyCall.PyObject) at /home/clason/.julia/packages/PyCall/WcrLS/src/pyfncall.jl:28
 [8] _pycall!(::PyCall.PyObject, ::PyCall.PyObject, ::Tuple{}, ::Base.Iterators.Pairs{Symbol,Any,NTuple{8,Symbol},NamedTuple{(:cppcode, :element, :cell, :domain, :degree, :name, :label, :mpi_comm),Tuple{String,Nothing,Nothing,Nothing,Int64,Nothing,Nothing,Nothing}}}) at /home/clason/.julia/packages/PyCall/WcrLS/src/pyfncall.jl:16
 [9] #call#89 at /home/clason/.julia/packages/PyCall/WcrLS/src/pyfncall.jl:147 [inlined]
 [10] PyObject at ./none:0 [inlined]
 [11] #Expression#13(::Nothing, ::Nothing, ::Nothing, ::Int64, ::Nothing, ::Nothing, ::Nothing, ::Type, ::String) at /home/clason/.julia/packages/FEniCS/MA1xs/src/jfem.jl:74
 [12] (::getfield(Core, Symbol("#kw#Type")))(::NamedTuple{(:degree,),Tuple{Int64}}, ::Type{Expression}, ::String) at ./none:0
 [13] top-level scope at none:0

It would also help to prominently note in the README which FEniCS version this package is compatible with (and maybe test the version when using FEniCS and warn if it's not the right one).

Symbols instead of strings

Small API point, but symbols are normally used in Julian APIs because comparisons are easier (and they generate nicer typed code, amongst other things). So instead of "left", the user-exposed API should expect :left. You can then internally call string(x) to turn it into a string to pass to Python.

Unsatisfiable requirements detected for package FEniCS on Julia 1.0.0

I am trying to add FEniCS.jl using an existing FEniCS 2018.1.0 installation (from official FEniCS PPA) on Ubuntu 18.04. Unfortunately, I get this error:

ERROR: Unsatisfiable requirements detected for package FEniCS [186dfeec]:
 FEniCS [186dfeec] log:
 ├─possible versions are: [0.0.1-0.0.2, 0.1.0] or uninstalled
 ├─restricted to versions * by an explicit requirement, leaving only versions [0.0.1-0.0.2, 0.1.0]
 └─restricted by julia compatibility requirements to versions: uninstalled — no versions left
Stacktrace:
 [1] #propagate_constraints!#61(::Bool, ::Function, ::Pkg.GraphType.Graph, ::Set{Int64}) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.0/Pkg/src/GraphType.jl:1005
 [2] propagate_constraints! at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.0/Pkg/src/GraphType.jl:946 [inlined]
 [3] #simplify_graph!#121(::Bool, ::Function, ::Pkg.GraphType.Graph, ::Set{Int64}) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.0/Pkg/src/GraphType.jl:1460
 [4] simplify_graph! at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.0/Pkg/src/GraphType.jl:1460 [inlined]
 [5] macro expansion at ./logging.jl:311 [inlined]
 [6] resolve_versions!(::Pkg.Types.Context, ::Array{Pkg.Types.PackageSpec,1}) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.0/Pkg/src/Operations.jl:339
 [7] #add_or_develop#58(::Array{Base.UUID,1}, ::Function, ::Pkg.Types.Context, ::Array{Pkg.Types.PackageSpec,1}) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.0/Pkg/src/Operations.jl:1163
 [8] #add_or_develop at ./none:0 [inlined]
 [9] #add_or_develop#13(::Symbol, ::Bool, ::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::Function, ::Pkg.Types.Context, ::Array{Pkg.Types.PackageSpec,1}) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.0/Pkg/src/API.jl:64
 [10] #add_or_develop at ./none:0 [inlined]
 [11] #add_or_develop#12 at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.0/Pkg/src/API.jl:29 [inlined]
 [12] #add_or_develop at ./none:0 [inlined]
 [13] #add_or_develop#11(::Base.Iterators.Pairs{Symbol,Symbol,Tuple{Symbol},NamedTuple{(:mode,),Tuple{Symbol}}}, ::Function, ::Array{String,1}) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.0/Pkg/src/API.jl:28
 [14] #add_or_develop at ./none:0 [inlined]
 [15] #add_or_develop#10 at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.0/Pkg/src/API.jl:27 [inlined]
 [16] #add_or_develop at ./none:0 [inlined]
 [17] #add#18 at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.0/Pkg/src/API.jl:69 [inlined]
 [18] add(::String) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.0/Pkg/src/API.jl:69
 [19] top-level scope at none:0

Minimal steps to reproduce error on fresh Julia 1.0.0 installation from binary:

$ mv ~/.julia ~/.juliaTemp
$ julia
julia> ENV["PYTHON"] = "/usr/bin/python3"
julia> using Pkg
julia> Pkg.add("PyCall")
julia> Pkg.add("FEniCS")

On Julia 0.6.4 I can install FEniCS.jl without any issue.

TagBot trigger issue

This issue is used to trigger TagBot; feel free to unsubscribe.

If you haven't already, you should update your TagBot.yml to include issue comment triggers.
Please see this post on Discourse for instructions and more details.

If you'd like for me to do this for you, comment TagBot fix on this issue.
I'll open a PR within a few hours, please be patient!

Expression fails with "this project has asked CMake to find a package configuration file provided by "DOLFIN", but CMake did not find one."

Environment:

julia> Pkg.status("FEniCS")
 - FEniCS                        0.1.0

julia> versioninfo()
Julia Version 0.6.2
Commit d386e40c17 (2017-12-13 18:08 UTC)
Platform Info:
  OS: macOS (x86_64-apple-darwin14.5.0)
  CPU: Intel(R) Core(TM) i7-7567U CPU @ 3.50GHz
  WORD_SIZE: 64
  BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Prescott)
  LAPACK: libopenblas64_
  LIBM: libopenlibm
  LLVM: libLLVM-3.9.1 (ORCJIT, broadwell)

Steps to reproduce:

using FEniCS
mesh = UnitSquareMesh(8,8)
V = FunctionSpace(mesh,"P",1)
u_D = Expression("1+x[0]*x[0]+2*x[1]*x[1]", degree=2)

Unexpected error message:

ERROR: PyError (ccall(@pysym(:PyObject_Call), PyPtr, (PyPtr, PyPtr, PyPtr), o, arg, kw)) <type 'exceptions.RuntimeError'>
RuntimeError("In instant.recompile: The module did not compile with command 'cmake -DDEBUG=TRUE .', see '/Users/cmey/.cache/instant/python2.7/error/dolfin_13c8f1f6cddc673505d96f856bef922a9fa66419/compile.log'",)
  File "/Users/cmey/.julia/v0.6/Conda/deps/usr/lib/python2.7/site-packages/dolfin/functions/expression.py", line 679, in __new__
    mpi_comm=kwargs.get("mpi_comm"))
  File "/Users/cmey/.julia/v0.6/Conda/deps/usr/lib/python2.7/site-packages/dolfin/compilemodules/expressions.py", line 266, in compile_expressions
    mpi_comm=mpi_comm)
  File "/Users/cmey/.julia/v0.6/Conda/deps/usr/lib/python2.7/site-packages/dolfin/compilemodules/expressions.py", line 183, in compile_expression_code
    mpi_comm=mpi_comm)
  File "/Users/cmey/.julia/v0.6/Conda/deps/usr/lib/python2.7/site-packages/dolfin/compilemodules/jit.py", line 70, in mpi_jit
    return local_jit(*args, **kwargs)
  File "/Users/cmey/.julia/v0.6/Conda/deps/usr/lib/python2.7/site-packages/dolfin/compilemodules/compilemodule.py", line 603, in compile_extension_module
    **instant_kwargs)
  File "/Users/cmey/.julia/v0.6/Conda/deps/usr/lib/python2.7/site-packages/instant/build.py", line 577, in build_module
    build_system)
  File "/Users/cmey/.julia/v0.6/Conda/deps/usr/lib/python2.7/site-packages/instant/build.py", line 158, in recompile
    instant_error(msg % (cmd, compile_log_filename_dest))
  File "/Users/cmey/.julia/v0.6/Conda/deps/usr/lib/python2.7/site-packages/instant/output.py", line 96, in instant_error
    raise RuntimeError(text)

Error log (compile.log) says:

-- The C compiler identification is AppleClang 9.0.0.9000039
-- The CXX compiler identification is AppleClang 9.0.0.9000039
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Error at CMakeLists.txt:12 (FIND_PACKAGE):
  By not providing "FindDOLFIN.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "DOLFIN", but
  CMake did not find one.

  Could not find a package configuration file provided by "DOLFIN" with any
  of the following names:

    DOLFINConfig.cmake
    dolfin-config.cmake

  Add the installation prefix of "DOLFIN" to CMAKE_PREFIX_PATH or set
  "DOLFIN_DIR" to a directory containing one of the above files.  If "DOLFIN"
  provides a separate development package or SDK, be sure it has been
  installed.

It looks like I need to manually install DOLFIN. Is that expected or should it get installed automatically during Pkg.add("FEniCS")?
If the former, any pointers on how to install it on macOS? It looks like it's not available on brew.

Best,
Christophe

get_array should return sparse matrix

At the moment, the get_array function returns a full Array{Float64,2}, which is not really a reasonable option for any practical use beyond toy problems. Can the get_array function be modified to return a SparseMatrixCSC{Float64,Int64} instead?

For reference, here's how I do the same on the FEniCS/SciPy interface:

import scipy.sparse as sp
parameters['linear_algebra_backend'] = 'Eigen'                                    
def assemble_csr(a,bc=None):                                                           
    A = assemble(a)                                                               
    bc.apply(A)                                                                   
    row,col,val = as_backend_type(A).data()                                       
    return sp.csr_matrix((val,col,row))                                           

I believe the same should work for FEniCS-to-Julia.

Export FEniCS.Function as FeFunction

Exporting FEniCS's Function as Function leads to a clash with Base.Function and requires awkward FEniCS.Function in user code. It would be more in keeping with the rest of the nomenclature (TrialFunction, TestFunction) if this was actually only exported as FeFunction (or similar).

An analogous point could be made about the other clashing exports such as Plot (FePlot).

PyError: 'pkg-config is not installed'

Fresh installation of Julia 1.0.

ERROR: PyError (PyImport_ImportModule) <class 'OSError'>
OSError('pkg-config is not installed',)
  File "/Users/aterenin/.julia/packages/Conda/m7vem/deps/usr/lib/python3.6/site-packages/fenics/__init__.py", line 7, in <module>
    from dolfin import *
  File "/Users/aterenin/.julia/packages/Conda/m7vem/deps/usr/lib/python3.6/site-packages/dolfin/__init__.py", line 140, in <module>
    from .fem.assembling import (assemble, assemble_system, assemble_multimesh,
  File "/Users/aterenin/.julia/packages/Conda/m7vem/deps/usr/lib/python3.6/site-packages/dolfin/fem/assembling.py", line 34, in <module>
    from dolfin.fem.form import Form
  File "/Users/aterenin/.julia/packages/Conda/m7vem/deps/usr/lib/python3.6/site-packages/dolfin/fem/form.py", line 12, in <module>
    from dolfin.jit.jit import dolfin_pc, ffc_jit
  File "/Users/aterenin/.julia/packages/Conda/m7vem/deps/usr/lib/python3.6/site-packages/dolfin/jit/jit.py", line 15, in <module>
    if pkgconfig.exists("dolfin"):
  File "/Users/aterenin/.julia/packages/Conda/m7vem/deps/usr/lib/python3.6/site-packages/pkgconfig/pkgconfig.py", line 62, in _wrapper
    raise EnvironmentError("pkg-config is not installed")

What can I do to debug this?

problem running the example

Sorry for asking so many questions is so many different packages of Julia but I have one more to throughout there.

First, I think it's pretty exciting that Julia is trying to run FEniCS, and I am very keen to give this a try and maybe even contribute to it if I can.

I tried to add and build FEniCS, like I think was stated in the tutorial, but when I first tried "using FEniCS" I got an error.

It seemed to me that I should try installing mshr, which I tried but failed with the suggestion that I found in the error message.

Building PyCall seemed to help so that now I can do "using FEniCS" without any error. However, when I go to the next line in the tutorial I get an error.

Again, sorry for all the questions, but can someone maybe point me in the right direction? I realize that the FEM example might make this unnecessary but I thought I might be able to compare them and see which one works better for me.

Any thoughts would be greatly appreciated.

julia> using FEniCS
ERROR: LoadError: LoadError: PyError (ccall(@pysym(:PyImport_ImportModule), PyPtr, (Cstring,), name)

The Python package mshr could not be found by pyimport. Usually this means
that you did not install mshr in the Python version being used by PyCall.

PyCall is currently configured to use the Julia-specific Python distribution
installed by the Conda.jl package.  To install the mshr module, you can
use `pyimport_conda("mshr", PKG)`, where PKG is the Anaconda
package the contains the module mshr, or alternatively you can use the
Conda package directly (via `using Conda` followed by `Conda.add` etcetera).

Alternatively, if you want to use a different Python distribution on your
system, such as a system-wide Python (as opposed to the Julia-specific Python),
you can re-configure PyCall with that Python.   As explained in the PyCall
documentation, set ENV["PYTHON"] to the path/name of the python executable
you want to use, run Pkg.build("PyCall"), and re-launch Julia.

) <type 'exceptions.ImportError'>
ImportError('No module named mshr',)

Stacktrace:
 [1] pyerr_check at /home/fpoulin/.julia/v0.6/PyCall/src/exception.jl:56 [inlined]
 [2] pyerr_check at /home/fpoulin/.julia/v0.6/PyCall/src/exception.jl:61 [inlined]
 [3] macro expansion at /home/fpoulin/.julia/v0.6/PyCall/src/exception.jl:81 [inlined]
 [4] pyimport(::String) at /home/fpoulin/.julia/v0.6/PyCall/src/PyCall.jl:374
 [5] include_from_node1(::String) at ./loading.jl:569
 [6] include(::String) at ./sysimg.jl:14
 [7] include_from_node1(::String) at ./loading.jl:569
 [8] eval(::Module, ::Any) at ./boot.jl:235
 [9] _require(::Symbol) at ./loading.jl:483
 [10] require(::Symbol) at ./loading.jl:398
while loading /home/fpoulin/.julia/v0.6/FEniCS/src/jmesh.jl, in expression starting on line 467
while loading /home/fpoulin/.julia/v0.6/FEniCS/src/FEniCS.jl, in expression starting on line 35

julia> pyimport_conda("mshr", PKG)
ERROR: UndefVarError: pyimport_conda not defined

julia> using Conda

julia> pyimport_conda("mshr", PKG)
ERROR: UndefVarError: pyimport_conda not defined

julia> Pkg.build("PyCall")
INFO: Building Conda
INFO: Building PyCall
INFO: PyCall is using /home/fpoulin/.julia/v0.6/Conda/deps/usr/bin/python (Python 2.7.13) at /home/fpoulin/.julia/v0.6/Conda/deps/usr/bin/python, libpython = /home/fpoulin/.julia/v0.6/Conda/deps/usr/lib/libpython2.7
INFO: /home/fpoulin/.julia/v0.6/PyCall/deps/deps.jl has not changed
INFO: /home/fpoulin/.julia/v0.6/PyCall/deps/PYTHON has not changed

julia> pyimport_conda("mshr", PKG)
ERROR: UndefVarError: pyimport_conda not defined

julia> using FEniCS

julia> mesh = UnitSquareMesh(8,8) 
ERROR: UndefVarError: UnitSquareMesh not defined

Single quotes in README example are not valid Julia

The line vtkfile = File('poisson/solution.pvd') has Python quotes, to make it valid Julia you should change this to double quotes. I'm just being picky here but since it's the introductory example, a complete newbie (to Julia) might not know what's wrong.

Also, guys!! Amazing job!! Julia is my favourite language but it's been a while since I can use it in my research. I see so much development of the libraries, including yours, that I will be pushing now to be a Julian again :)

Using DirichletBC

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?

Evaluating the FEM solution at a new point

In the python FEniCS evaluation of a solution object u at some new set of coordinates (x, y) works as:

u_new = u(x, y)

The Julia wrapper yields an error on this. Ben Thompson (https://github.com/tbenthompson) wrote the following function to allow for interior evaluation using a known solution object:

function interior_eval(u, x, y)
    py"""
    def G(u, x, y):
        return u(x, y)
    """
    py"G"(u.pyobject, x, y)
end

which can be used in julia as:

u_new = interior_eval(u, x, y)

and it has worked very well for me!

Get CI working

High on the priority list is to get CI working. I am not sure how, but we should check what the other FEniCS.jl had to do to make it work.

Is Fenics.jl based upon the newer `Fenicsx` library, or on legacy `Fenics`?

Hello. I was just looking at the Fenics website, and it mentions a newer version of the software called Fenicsx. The newer software was started around 2019 and is supposed to have a bunch of improvement on legacy Fenics. I was just wondering if Fenics.jl is based upon the legacy Fenics package, or the newer Fenicsx package.

I am just reading through the Fenics python tutorials, but I wanted to make sure that I am using the python version of Fenics that corresponds to the Julia version of Fenics.jl, otherwise things might get out of sync.

Outdated compat entries

Hi,

I just installed FEniCS.jl for the first time and noticed that it caused quite a few downgrades.
In particular this line,

Requires = "0.5, 1.0"

appears problematic. I assume any version of Requires in 1 < v < 2 should be fine?

Expression Class

Hello.
When attempting to import the https://fenicsproject.org/olddocs/dolfin/2016.2.0/python/programmers-reference/functions/expression/Expression.html , the error below can be shown. I've tried searching for the error message online, but have had no luck. I cannot also track down the log file. I believe (but cannot be sure) that it is a precompilation error in FEniCS, as the DOLFIN JIT compiler is being called with these commands.
EDIT: I have been informed that the expression class is written in C++, so maybe it needs a different wrapper?
Running these 3 lines of code should be enough to reproduce the error.

using PyCall
@pyimport fenics
test = fenics.Expression("A*sin(x[0]) + B*cos(x[1])")

LoadError: PyError (ccall(@pysym(:PyObject_Call), PyPtr, (PyPtr, PyPtr, PyPtr), o, arg, C_NULL)) <type 'exceptions.RuntimeError'>
RuntimeError("In instant.recompile: The module did not compile with command 'cmake -DDEBUG=TRUE .', see '/home/ysimillides/.cache/instant/python2.7/error/dolfin_30bdf4cb51714b187b95e13cb07aeaf2529b443b/compile.log'",)
File "/home/ysimillides/.julia/v0.6/Conda/deps/usr/lib/python2.7/site-packages/dolfin/functions/expression.py", line 679, in new
mpi_comm=kwargs.get("mpi_comm"))
File "/home/ysimillides/.julia/v0.6/Conda/deps/usr/lib/python2.7/site-packages/dolfin/compilemodules/expressions.py", line 266, in compile_expressions
mpi_comm=mpi_comm)
File "/home/ysimillides/.julia/v0.6/Conda/deps/usr/lib/python2.7/site-packages/dolfin/compilemodules/expressions.py", line 183, in compile_expression_code
mpi_comm=mpi_comm)
File "/home/ysimillides/.julia/v0.6/Conda/deps/usr/lib/python2.7/site-packages/dolfin/compilemodules/jit.py", line 70, in mpi_jit
return local_jit(*args, **kwargs)
File "/home/ysimillides/.julia/v0.6/Conda/deps/usr/lib/python2.7/site-packages/dolfin/compilemodules/compilemodule.py", line 603, in compile_extension_module
**instant_kwargs)
File "/home/ysimillides/.julia/v0.6/Conda/deps/usr/lib/python2.7/site-packages/instant/build.py", line 577, in build_module
build_system)
File "/home/ysimillides/.julia/v0.6/Conda/deps/usr/lib/python2.7/site-packages/instant/build.py", line 158, in recompile
instant_error(msg % (cmd, compile_log_filename_dest))
File "/home/ysimillides/.julia/v0.6/Conda/deps/usr/lib/python2.7/site-packages/instant/output.py", line 96, in instant_error
raise RuntimeError(text)
while loading /home/ysimillides/FEniCS.jl/src/jfem.jl, in expression starting on line 40
pyerr_check at exception.jl:56 [inlined]
pyerr_check at exception.jl:61 [inlined]
macro expansion at exception.jl:81 [inlined]
#_pycall#66(::Array{Any,1}, ::Function, ::PyCall.PyObject, ::String, ::Vararg{String,N} where N) at PyCall.jl:620
_pycall(::PyCall.PyObject, ::String, ::Vararg{String,N} where N) at PyCall.jl:608
#pycall#70(::Array{Any,1}, ::Function, ::PyCall.PyObject, ::Type{PyCall.PyAny}, ::String, ::Vararg{String,N} where N) at PyCall.jl:642
pycall(::PyCall.PyObject, ::Type{PyCall.PyAny}, ::String, ::Vararg{String,N} where N) at PyCall.jl:642
#call#71(::Array{Any,1}, ::PyCall.PyObject, ::String, ::Vararg{String,N} where N) at PyCall.jl:645
FEniCS.Expression(::String) at jfem.jl:24
include_string(::String, ::String) at loading.jl:515
include_string(::Module, ::String, ::String) at Compat.jl:1492
(::Atom.##55#58{String,String})() at eval.jl:73
withpath(::Atom.##55#58{String,String}, ::String) at utils.jl:30
withpath(::Function, ::String) at eval.jl:38
macro expansion at eval.jl:71 [inlined]
(::Atom.##54#57{Dict{String,Any}})() at task.jl:80

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.