Thank you Andrew for your help. I am a bit sorry to see CircleMesh go away but if it only gave a structured mesh, then I can see the advantage to using gmsh. Also, I should really learn how to use gmsh better, so this will force me to do just that.
I looked around for circle.geo but couldn't find it in the repo.
I found another version of circle.geo that seems to build a circle. It is copied here
L = 10;I am not sure why the origin needs to be included but it does give the correct shape at least.
dx = 1;
Point(1) = { 0, 0, 0, dx};
Point(2) = { L, 0, 0, dx};
Point(3) = {-L, 0, 0, dx};
Point(4) = { 0, L, 0, dx};
Point(5) = { 0,-L, 0, dx};
Circle(1) = {3,1,5};
Circle(2) = {5,1,2};
Circle(3) = {2,1,4};
Circle(4) = {4,1,3};
Line Loop(5) = {1,2,3,4};
Plane Surface(6) = {5};
Unfortunately, when I try importing this in firedrake using
from firedrake import *
#gmsh -2 circle.geo
mesh = Mesh("circle.msh")
I get the error
Traceback (most recent call last):
File "test.py", line 7, in <module>
mesh = Mesh("circle.msh")
File "<decorator-gen-261>", line 2, in Mesh
File "/home/fpoulin/software/firedrake/src/PyOP2/pyop2/ profiling.py", line 61, in wrapper
return f(*args, **kwargs)
File "/home/fpoulin/software/firedrake/src/firedrake/ firedrake/mesh.py", line 1259, in Mesh
topology = MeshTopology(plex, name=name, reorder=reorder, distribute=distribute)
File "<decorator-gen-259>", line 2, in __init__
File "/home/fpoulin/software/firedrake/src/PyOP2/pyop2/ profiling.py", line 61, in wrapper
return f(*args, **kwargs)
File "/home/fpoulin/software/firedrake/src/firedrake/ firedrake/mesh.py", line 348, in __init__
dmplex.validate_mesh(plex)
File "firedrake/dmplex.pyx", line 1009, in firedrake.dmplex.validate_mesh (firedrake/dmplex.c:14063)
ValueError: Provided mesh has some entities not reachable by traversing cells (maybe rogue vertices?)
Can you point out what I'm doing wrong? Or where to find the circle.geo?
Also, I tried use gmsh in firedrake as commented above and that didn't work. Should gmsh work in the latest version?
Cheers, Francis
------------------
Francis Poulin
Associate Professor
Department of Applied Mathematics
University of Waterloo
email: fpoulin@uwaterloo.ca
Web: https://uwaterloo.ca/poulin-research-group/
Telephone: +1 519 888 4567 x32637
From: firedrake-bounces@imperial.ac.uk [firedrake-bounces@imperial.ac.uk ] on behalf of Andrew McRae [A.T.T.McRae@bath.ac.uk]
Sent: Sunday, March 19, 2017 8:07 AM
To: firedrake@imperial.ac.uk
Subject: Re: [firedrake] circles in firedrake?
AndrewBest,We used to have a CircleMesh in Firedrake, but it was removed in this commit. If I recall correctly, this is because we outsourced the creation of that mesh to gmsh, but the gmsh-from-Python packages are no longer available with newer versions of Ubuntu.That commit has a small gmsh snippet (.geo). You could manually run this through gmsh to build a mesh (.msh), and load this in to your firedrake script: mesh = Mesh("circle.msh"). Note that this CircleMesh (and, IIRC, FEniCS's equivalent) give a "structured" mesh with radial lines, and correspondingly small cells in the middle. If this is undesirable, you might be better off making a simple unstructured circle mesh in gmsh and loading it in.
Regarding the code you gave in your email, I think this has also worked just fine. However, the built-in Firedrake plotting functionality only seems to support 2D triangle and "unstructured" quadrilateral cells, rather than the "interval x interval" cells created by an extruded mesh. (I suspect this was an accidental omission)
If you instead do File("temp.pvd").write(U) and open the result in Paraview, I'm sure it would look fine. Of course, if you use this to get a circular mesh, it will also have small cells at the centre.
On 18 March 2017 at 17:29, Francis Poulin <fpoulin@uwaterloo.ca> wrote:
Hello,
I want to define my mesh to be a circle. In Fenics I know there is a command called CircleMesh that makes this very easy.
Q1) Is there a simple way of doing this in Firedrake?
I looked around and see how circlemanifoldmesh can do this with help for ExtrudedMesh. I found some code that can make a ring and I tried running it myself and defining a function on that mesh. Unfortunately, I get an error, see below.
Q2) If one needs to use CircleManifoldMesh is there something else one needs to do to use a circular geometry as your mesh?
Below are the lines that I tried and the error
>>> from firedrake import *
>>> m = CircleManifoldMesh(20, radius=2)
>>> mesh = ExtrudedMesh(m, 5, extrusion_type='radial')
>>> x = SpatialCoordinate(mesh)
>>> V = FunctionSpace(mesh,'CG',1)
>>> U = Function(V).interpolate(-(pow(x[0]-0.5,2) + pow(x[1]-0.5,2)))
>>> plot(U);
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/fpoulin/software/firedrake/src/firedrake/firedrake/ plot.py", line 308, in plot
**kwargs)
File "/home/fpoulin/software/firedrake/src/firedrake/firedrake/ plot.py", line 502, in two_dimension_plot
num_sample_points)
File "/home/fpoulin/software/firedrake/src/firedrake/firedrake/ plot.py", line 457, in _two_dimension_triangle_func_v al
raise RuntimeError("Unsupported Functionality")
RuntimeError: Unsupported Functionality
------------------
Francis Poulin
Associate Professor
Department of Applied Mathematics
University of Waterloo
email: fpoulin@uwaterloo.ca
Web: https://uwaterloo.ca/poulin-research-group/
Telephone: +1 519 888 4567 x32637