Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#The main things needed to wrap and use the FEniCS package are access to
#functions and their attributes. Occasionally *types* may also be defined to allow
#easier use and function overloading. fenicspycall is used to access attributes and fenicsclass is used to define types(classes in FEniCS).
#These can be found in the FEniCS.jl main file.
#Assuming we now want to define the Mesh Class found here https://fenicsproject.org/olddocs/dolfin/1.5.0/python/programmers-reference/cpp/mesh/Mesh.html .
#We simply call @fenicsclass Mesh . If we want to access their attributes we can simply create access to them as follows
#hmin(mesh::Mesh) = fenicspycall(mesh, :hmin)
#Now we may wish to create access to the function https://fenicsproject.org/olddocs/dolfin/1.5.0/python/programmers-reference/cpp/mesh/UnitSquareMesh.html .
#We define the function along with its required attributes as follows. As we want the returned function to be a "Mesh" we give it the required type.
#UnitSquareMesh(nx::Int, ny::Int, diagonal::Union{String,Symbol}="right") = Mesh(fenics.UnitSquareMesh(nx, ny, diagonal))
#We can see how all of this works together below
using FEniCS
@fenicsclass Mesh
hmin(mesh::Mesh) = fenicspycall(mesh, :hmin)
UnitSquareMesh(nx::Int, ny::Int, diagonal::Union{String,Symbol}="right") = Mesh(fenics.UnitSquareMesh(nx, ny, diagonal))
squaremesh = UnitSquareMesh(10,10,left)
hm = hmin(squaremesh)
print(hm)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.