Skip to content

Commit

Permalink
Merge pull request #49 from ysimillides/master
Browse files Browse the repository at this point in the history
Docker addition
  • Loading branch information
ChrisRackauckas committed Jul 10, 2018
2 parents 35e5fc9 + 055be1e commit c27e629
Show file tree
Hide file tree
Showing 23 changed files with 414 additions and 131 deletions.
39 changes: 18 additions & 21 deletions .travis.yml
Expand Up @@ -5,29 +5,26 @@ os:
julia:
- 0.6
- nightly
matrix:
allow_failures:
- julia: nightly
sudo: required

dist: trusty
env:
# Make PyCall use the right python version (where dolfin is installed)
- PYTHON=/usr/bin/python2

sudo: required

services:
- docker

before_install:
# Install FEniCS (but don't do an 'apt-get upgrade' as this will timeout the process)
- sudo add-apt-repository ppa:fenics-packages/fenics -y
- sudo apt-get update -q
- sudo apt-get install fenics -y
#- docker pull quay.io/fenicsproject/stable:latest
#- docker run -ti quay.io/fenicsproject/stable:latest
- echo "**** pulling Docker image"
- docker pull ysimillides/fenics-julia-docker
- chmod +x travis_docker_test_script.sh
notifications:
email: false
# uncomment the following lines to override the default test script
#script:
# - if [[ -a .git/shallow ]]; then git fetch --unshallow; fi
# - julia -e 'Pkg.clone(pwd()); Pkg.build("FEniCS"); Pkg.test("FEniCS"; coverage=true)'
script:
- echo "**** running Docker"
- docker run --env-file travis_docker_env.list -t -a STDOUT -a STDIN -a STDERR -v $PWD:/mnt ysimillides/fenics-julia-docker /mnt/travis_docker_test_script.sh $TRAVIS_JULIA_VERSION
after_success:
# push coverage results to Coveralls
- julia -e 'cd(Pkg.dir("FEniCS")); Pkg.add("Coverage"); using Coverage; Coveralls.submit(Coveralls.process_folder())'
# push coverage results to Codecov
- julia -e 'cd(Pkg.dir("FEniCS")); Pkg.add("Coverage"); using Coverage; Codecov.submit(Codecov.process_folder())'
# push coverage results to Coveralls, .cov files were copied back by script above
- echo "**** submitting coverage information"
- julia -e 'Pkg.add("Coverage"); using Coverage; Codecov.submit(Codecov.process_folder())'
- julia -e 'Pkg.add("Coverage"); using Coverage; Coveralls.submit(Coveralls.process_folder())'

19 changes: 14 additions & 5 deletions README.md
Expand Up @@ -3,7 +3,7 @@
[![Join the chat at https://gitter.im/JuliaDiffEq/Lobby](https://badges.gitter.im/JuliaDiffEq/Lobby.svg)](https://gitter.im/JuliaDiffEq/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![Build Status](https://travis-ci.org/JuliaDiffEq/FEniCS.jl.svg?branch=master)](https://travis-ci.org/JuliaDiffEq/FEniCS.jl)
[![Coverage Status](https://coveralls.io/repos/github/JuliaDiffEq/FEniCS.jl/badge.svg?branch=master)](https://coveralls.io/github/JuliaDiffEq/FEniCS.jl?branch=master)
[![codecov.io](http://codecov.io/github/ChrisRackauckas/FEniCS.jl/coverage.svg?branch=master)](http://codecov.io/github/ChrisRackauckas/FEniCS.jl?branch=master)
[![codecov.io](http://codecov.io/github/JuliaDiffEq/FEniCS.jl/coverage.svg?branch=master)](http://codecov.io/github/JuliaDiffEq/FEniCS.jl?branch=master)

FEniCS.jl is a wrapper for the FEniCS library for finite element discretizations
of PDEs. This wrapper includes three parts:
Expand All @@ -17,11 +17,20 @@ DifferentialEquations.jl ecosystem. [Paraview](https://www.paraview.org/) can al

## Installation Instructions

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

1. Clone the package into Julia. This can be done via Pkg.add("FEniCS").
2. Proceed to build the package via Pkg.build("FEniCS").
3. Should be available to use. Due to the fact that FEniCS.jl uses the conda distribution to install and use FEniCS, the installation provided will not currently work on Windows based systems due to the fact that a Windows Conda distribution is not currently supported by [FEniCS](https://fenicsproject.org/download/).
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](https://www.docker.com/) and then run the following command

```sh
docker run -ti ysimillides/fenics-julia-docker
```
and once inside, 'julia' can be accessed by calling
```sh
julia
```
Once inside the julia environment, simply add FEniCS with Pkg.add("FEniCS"). All other dependencies are handled by the docker image.

Note: Any suggestions/improvements/comments etc are always welcomed and can be made either on GitHub or via the gitter channel above.
This wrapper was originally started via the [Google Summer of Code program](https://summerofcode.withgoogle.com/projects/#5988523772477440) along with the help of Chris Rackauckas and Bart Janssens.
Expand Down
2 changes: 1 addition & 1 deletion REQUIRE
@@ -1,3 +1,3 @@
julia 0.6
PyCall
Conda
PyPlot
43 changes: 0 additions & 43 deletions appveyor.yml

This file was deleted.

12 changes: 3 additions & 9 deletions deps/build.jl
@@ -1,22 +1,16 @@
using PyCall
using Conda

if PyCall.conda
Conda.add_channel("conda-forge")
Conda.add("fenics")
else
try
pyimport("fenics")
catch ee
typeof(ee) <: PyCall.PyError || rethrow(ee)
warn("""
Python Dependancies not installed
Please either:
- Rebuild PyCall to use Conda, by running in the julia REPL:
- `ENV["PYTHON"]=""; Pkg.build("PyCall"); Pkg.build("FEniCS")`
- Or install the depencences separately
- Rebuild PyCall using the path to FEniCS using
- `ENV["PYTHON"]="/path/to/FEniCS"; Pkg.build("PyCall"); Pkg.build("FEniCS")`
- Or install the Dependancies using the Docker image provided
"""
)
end

end
11 changes: 9 additions & 2 deletions src/FEniCS.jl
@@ -1,9 +1,10 @@
module FEniCS
using PyCall
using Requires
@pyimport fenics

#the below code is an adaptation of aleadev.FEniCS.jl
import Base: size, length, show, *, +, -,/, repr, dot, cross, div,Function, sqrt
import Base: size, length, show, *, +, -,/, repr, dot, cross, div,Function, sqrt,split,write
abstract type
fenicsobject
end #creates placeholder for the fenicsobject type
Expand All @@ -28,18 +29,24 @@ export fenicsclass
str(obj::fenicsobject) = fenicspycall(obj, :__str__)
repr(obj::fenicsobject) = fenicspycall(obj, :__repr__)
show(io::IO, obj::fenicsobject) = show(io, str(obj))
Docs.getdoc(obj::fenicsobject) = obj.pyobject[:__doc__]
export str, repr

include("jmesh.jl") #this file contains the mesh functions
include("jfem.jl") #this file contains the fem functions
include("jmisc.jl") #this file contains various miscallaneous functions to assist with solving etc
include("jsolve.jl") #this file contains the solver functions/routines
#include("jplot.jl") #this file contains the plotting functionality
include("jinterface.jl")
@require PyPlot include("jplot.jl")
@require ProgressMeter begin
using ProgressMeter
end
try
pyimport("mshr")
include("fmshr.jl") #this file contains various geometrical objects using the mshr package
catch ee
print("mshr has not been included")
end


end #module
25 changes: 24 additions & 1 deletion src/fmshr.jl
Expand Up @@ -14,11 +14,34 @@ Sphere(centre,radius) = Geometry(mshr.Sphere(centre,radius))

#we generate the mesh of some geometrical objects
generate_mesh(geom_object::Geometry,size::Int)=Mesh(mshr.generate_mesh(geom_object.pyobject,size))
export Circle,Rectangle,Ellipse,Box,Cone,Sphere,generate_mesh


#operator overloading for Geometry types so we can create composite shapes
+(geom_object1::Geometry, geom_object2::Geometry) = Geometry(geom_object1.pyobject[:__add__](geom_object2.pyobject))
-(geom_object1::Geometry, geom_object2::Geometry) = Geometry(geom_object1.pyobject[:__sub__](geom_object2.pyobject))
*(geom_object1::Geometry, geom_object2::Geometry) = Geometry(geom_object1.pyobject[:__mul__](geom_object2.pyobject))

export Circle,Rectangle,Ellipse,Box,Cone,Sphere,generate_mesh
set_subdomain(object::Geometry,degree,domain2) = fenicspycall(object, :set_subdomain,degree,domain2.pyobject)
"""
Extrude2D
Extrudes a 2D geometry to 3D
"""
Extrude2D(object::Geometry,thickness) = Geometry(mshr.Extrude2D(object.pyobject,thickness))
export set_subdomain, Extrude2D

CSGUnion(geom_object1::Geometry, geom_object2::Geometry) = Geometry(mshr.CSGUnion(geom_object1.pyobject,geom_object2.pyobject))
CSGIntersection(geom_object1::Geometry, geom_object2::Geometry) = Geometry(mshr.CSGIntersection(geom_object1.pyobject,geom_object2.pyobject))
CSGDifference(geom_object1::Geometry, geom_object2::Geometry) = Geometry(mshr.CSGDifference(geom_object1.pyobject,geom_object2.pyobject))

CSGScaling(geom_object1::Geometry, scale) = Geometry(mshr.CSGScaling(geom_object1.pyobject,scale))

CSGRotation(geom_object1::Geometry, angle) = Geometry(mshr.CSGRotation(geom_object1.pyobject,angle))
CSGRotation(geom_object1::Geometry, point, angle) = Geometry(mshr.CSGRotation(geom_object1.pyobject,point, angle))
CSGRotation(geom_object1::Geometry, point_axis, point_center, angle) = Geometry(mshr.CSGRotation(geom_object1.pyobject, point_axis, point_center, angle))


CSGTranslation(geom_object1::Geometry, translation_point) = Geometry(mshr.CSGTranslation(geom_object1.pyobject, translation_point))

export CSGUnion, CSGIntersection, CSGDifference, CSGScaling, CSGRotation, CSGTranslation
36 changes: 33 additions & 3 deletions src/jfem.jl
@@ -1,6 +1,6 @@
#These are the commands to define the Fem class, and assemble the Matrix in Julia
#full documentation of the API from FEniCS can be found in the link below
#http://fenics.readthedocs.io/projects/Expression/en/latest/api-doc/Expression.html
#http://fenics.readthedocs.io/projects/UFL/en/latest/api-doc/Expression.html
#Tests for these can be found in the test_jfem.jl file.


Expand Down Expand Up @@ -97,7 +97,7 @@ export dx, ds,dS,dP
+(expr::Union{Expression,Function}, expr2::Union{Expression,Function}) = Expression(expr.pyobject[:__add__](expr2.pyobject) )

-(expr::Union{Expression,Function}, expr2::Real) = Expression(expr.pyobject[:__sub__](expr2) )
-(expr::Real, expr2::Union{Expression,Function}) = Expression(expr2.pyobject[:__sub__](expr) )
-(expr::Real, expr2::Union{Expression,Function}) = -1*(Expression(expr2.pyobject[:__sub__](expr) ))
-(expr::Union{Expression,Function}, expr2::Union{Expression,Function}) = Expression(expr.pyobject[:__sub__](expr2.pyobject) )

/(expr::Union{Expression,Function}, expr2::Real) = Expression(expr.pyobject[:__div__](expr2) )
Expand Down Expand Up @@ -169,6 +169,35 @@ apply(bcs, matrix::Matrix) = fenicspycall(BoundaryCondition(bcs), :apply, matrix

export apply

function assemble_system_julia(a::Expression,L::Expression)
A_fenics,b_fenics = fenics.assemble_system(a.pyobject,L.pyobject)
A = A_fenics[:array]()
b = b_fenics[:array]()
return A,b
end

function assemble_system_julia(a::Expression,L::Expression,bc)
A_fenics,b_fenics = fenics.assemble_system(a.pyobject,L.pyobject,bc)
A = A_fenics[:array]()
b = b_fenics[:array]()
return A,b
end

function assemble_system_julia(a::Expression,L::Expression,bc::BoundaryCondition)
A_fenics,b_fenics = fenics.assemble_system(a.pyobject,L.pyobject,bc)
A = A_fenics[:array]()
b = b_fenics[:array]()
return A,b
end

##add assemble_system to FEniCS objects for solving

function assemble_system(a::Expression,L::Expression)
A_fenics,b_fenics = fenics.assemble_system(a.pyobject,L.pyobject)
A = Matrix(A_fenics)
b = Matrix(b_fenics)
return A,b
end

function assemble_system(a::Expression,L::Expression,bc)
A_fenics,b_fenics = fenics.assemble_system(a.pyobject,L.pyobject,bc)
Expand All @@ -184,7 +213,8 @@ function assemble_system(a::Expression,L::Expression,bc::BoundaryCondition)
return A,b
end

export assemble_system

export assemble_system, assemble_system_julia


"""
Expand Down

0 comments on commit c27e629

Please sign in to comment.