Dear All, How do I instruct Firedrake about the dimension of the problem when using external mesh from gmsh? I had a working code with utility mesh. I changed: mesh = RectangleMesh(nx, nz, Lx, Lz) V = VectorFunctionSpace(mesh, "CG", 1) to: mesh = Mesh("mesh.msh") V = VectorFunctionSpace(mesh, "CG", 1, dim=2) yet I get the error at further expressions that worked previously: ... File "/home/mmtjs/work/programs/lin_coupled_fd_2d/lib/beam.py", line 73, in initialize_solvers + self.mu * ( fd.inner( delX, delv_B + fd.transpose(delv_B) ) ) File "/opt/firedrake/1510/lib/python2.7/site-packages/ufl/exproperators.py", line 177, in _add return Sum(self, o) File "/opt/firedrake/1510/lib/python2.7/site-packages/ufl/algebra.py", line 55, in __new__ error("Can't add expressions with different shapes.") File "/opt/firedrake/1510/lib/python2.7/site-packages/ufl/log.py", line 151, in error raise self._exception_type(self._format_raw(*message)) ufl.log.UFLException: Can't add expressions with different shapes. Thank you, Tomasz
On 17/02/16 14:36, Tomasz Salwa [RPG] wrote:
Dear All,
How do I instruct Firedrake about the dimension of the problem when using external mesh from gmsh?
I had a working code with utility mesh. I changed:
mesh = RectangleMesh(nx, nz, Lx, Lz)
V = VectorFunctionSpace(mesh, "CG", 1)
to:
mesh = Mesh("mesh.msh")
Is this a 3-D mesh, or a 2-D mesh?
V = VectorFunctionSpace(mesh, "CG", 1, dim=2)
yet I get the error at further expressions that worked previously:
...
File "/home/mmtjs/work/programs/lin_coupled_fd_2d/lib/beam.py", line 73, in initialize_solvers + self.mu * ( fd.inner( delX, delv_B + fd.transpose(delv_B) ) )
Is delv_B a tensor? If so, what is its shape? It's possible that if you have a 3D mesh and build a 2D VectorFunctionSpace then if you have: f = grad(Function(V)) f will have shape (3, 2) whereas transpose(f) will have shape (2, 3). So clearly those don't match. Lawrence
Dear Lawrence It's 2D. Similar to wave_tank.geo in your examples. But: ... v = TestFunction(V) delv_B = nabla_grad(v) delv_B.shape = (1, 2) ... while it should be (2,2). Tomasz ________________________________________ From: firedrake-bounces@imperial.ac.uk <firedrake-bounces@imperial.ac.uk> on behalf of Lawrence Mitchell <lawrence.mitchell@imperial.ac.uk> Sent: 17 February 2016 15:00 To: firedrake@imperial.ac.uk Subject: Re: [firedrake] dimension with external mesh On 17/02/16 14:36, Tomasz Salwa [RPG] wrote:
Dear All,
How do I instruct Firedrake about the dimension of the problem when using external mesh from gmsh?
I had a working code with utility mesh. I changed:
mesh = RectangleMesh(nx, nz, Lx, Lz)
V = VectorFunctionSpace(mesh, "CG", 1)
to:
mesh = Mesh("mesh.msh")
Is this a 3-D mesh, or a 2-D mesh?
V = VectorFunctionSpace(mesh, "CG", 1, dim=2)
yet I get the error at further expressions that worked previously:
...
File "/home/mmtjs/work/programs/lin_coupled_fd_2d/lib/beam.py", line 73, in initialize_solvers + self.mu * ( fd.inner( delX, delv_B + fd.transpose(delv_B) ) )
Is delv_B a tensor? If so, what is its shape? It's possible that if you have a 3D mesh and build a 2D VectorFunctionSpace then if you have: f = grad(Function(V)) f will have shape (3, 2) whereas transpose(f) will have shape (2, 3). So clearly those don't match. Lawrence
On 17/02/16 15:19, Tomasz Salwa [RPG] wrote:
Dear Lawrence
It's 2D. Similar to wave_tank.geo in your examples. But: ... v = TestFunction(V) delv_B = nabla_grad(v) delv_B.shape = (1, 2) ... while it should be (2,2).
OK, after you make the mesh, what does: print repr(mesh.ufl_cell()) return? Can you send the geo file you use? Lawrence
Attached. print repr(mesh.ufl_cell()) returns: Cell('interval', 1) ________________________________________ From: firedrake-bounces@imperial.ac.uk <firedrake-bounces@imperial.ac.uk> on behalf of Lawrence Mitchell <lawrence.mitchell@imperial.ac.uk> Sent: 17 February 2016 15:23 To: firedrake@imperial.ac.uk Subject: Re: [firedrake] dimension with external mesh On 17/02/16 15:19, Tomasz Salwa [RPG] wrote:
Dear Lawrence
It's 2D. Similar to wave_tank.geo in your examples. But: ... v = TestFunction(V) delv_B = nabla_grad(v) delv_B.shape = (1, 2) ... while it should be (2,2).
OK, after you make the mesh, what does: print repr(mesh.ufl_cell()) return? Can you send the geo file you use? Lawrence
On 17/02/16 15:28, Tomasz Salwa [RPG] wrote:
Attached.
print repr(mesh.ufl_cell()) returns:
Cell('interval', 1)
OK, this is your problem. The mesh is actually a mesh of intervals. Looking at your geo file, I see you need to add a physical surface, otherwise only the physical line is meshed. Something like: Physical Surface(6) = {6}; Then when I generate and read in the mesh, I get quadrilateral cells. Cheers, Lawrence
Thank you. Still something wrong, now I'm getting this: File "/home/mmtjs/work/programs/lin_coupled_fd_2d/lib/beam.py", line 49, in build_function_spaces self.V = fd.VectorFunctionSpace(self.mesh, "CG", 1) File "/opt/firedrake/1510/lib/python2.7/site-packages/PyOP2-0.11.0_388_gde0c811-py2.7-linux-x86_64.egg/pyop2/caching.py", line 161, in __new__ obj = make_obj() File "/opt/firedrake/1510/lib/python2.7/site-packages/PyOP2-0.11.0_388_gde0c811-py2.7-linux-x86_64.egg/pyop2/caching.py", line 142, in make_obj obj.__init__(*args, **kwargs) File "/opt/firedrake/1510/lib/python2.7/site-packages/firedrake/functionspace.py", line 613, in __init__ mesh.init() File "/opt/firedrake/1510/lib/python2.7/site-packages/firedrake/mesh.py", line 475, in init self._callback(self) File "/opt/firedrake/1510/lib/python2.7/site-packages/firedrake/mesh.py", line 438, in callback self._coordinate_fs = functionspace.VectorFunctionSpace(self, "Lagrange", 1) File "/opt/firedrake/1510/lib/python2.7/site-packages/PyOP2-0.11.0_388_gde0c811-py2.7-linux-x86_64.egg/pyop2/caching.py", line 161, in __new__ obj = make_obj() File "/opt/firedrake/1510/lib/python2.7/site-packages/PyOP2-0.11.0_388_gde0c811-py2.7-linux-x86_64.egg/pyop2/caching.py", line 142, in make_obj obj.__init__(*args, **kwargs) File "/opt/firedrake/1510/lib/python2.7/site-packages/firedrake/functionspace.py", line 615, in __init__ super(VectorFunctionSpace, self).__init__(mesh, element, name, dim=dim, rank=1) File "/opt/firedrake/1510/lib/python2.7/site-packages/firedrake/functionspace.py", line 140, in __init__ dmplex.get_facet_nodes(mesh.exterior_facets.facet_cell, File "/opt/firedrake/1510/lib/python2.7/site-packages/PyOP2-0.11.0_388_gde0c811-py2.7-linux-x86_64.egg/pyop2/utils.py", line 64, in __get__ obj.__dict__[self.__name__] = result = self.fget(obj) File "/opt/firedrake/1510/lib/python2.7/site-packages/firedrake/mesh.py", line 505, in exterior_facets boundary_ids, unique_markers=unique_ids) File "/opt/firedrake/1510/lib/python2.7/site-packages/firedrake/mesh.py", line 54, in __init__ "Every marker has to be contained in unique_markers" AssertionError: Every marker has to be contained in unique_markers ________________________________________ From: firedrake-bounces@imperial.ac.uk <firedrake-bounces@imperial.ac.uk> on behalf of Lawrence Mitchell <lawrence.mitchell@imperial.ac.uk> Sent: 17 February 2016 15:34 To: firedrake@imperial.ac.uk Subject: Re: [firedrake] dimension with external mesh On 17/02/16 15:28, Tomasz Salwa [RPG] wrote:
Attached.
print repr(mesh.ufl_cell()) returns:
Cell('interval', 1)
OK, this is your problem. The mesh is actually a mesh of intervals. Looking at your geo file, I see you need to add a physical surface, otherwise only the physical line is meshed. Something like: Physical Surface(6) = {6}; Then when I generate and read in the mesh, I get quadrilateral cells. Cheers, Lawrence
On 17/02/16 15:47, Tomasz Salwa [RPG] wrote:
Thank you. Still something wrong, now I'm getting this:
File "/home/mmtjs/work/programs/lin_coupled_fd_2d/lib/beam.py", line 49, in build_function_spaces self.V = fd.VectorFunctionSpace(self.mesh, "CG", 1) File "/opt/firedrake/1510/lib/python2.7/site-packages/PyOP2-0.11.0_388_gde0c811-py2.7-linux-x86_64.egg/pyop2/caching.py", line 161, in __new__ obj = make_obj() File "/opt/firedrake/1510/lib/python2.7/site-packages/PyOP2-0.11.0_388_gde0c811-py2.7-linux-x86_64.egg/pyop2/caching.py", line 142, in make_obj obj.__init__(*args, **kwargs) File "/opt/firedrake/1510/lib/python2.7/site-packages/firedrake/functionspace.py", line 613, in __init__ mesh.init() File "/opt/firedrake/1510/lib/python2.7/site-packages/firedrake/mesh.py", line 475, in init self._callback(self) File "/opt/firedrake/1510/lib/python2.7/site-packages/firedrake/mesh.py", line 438, in callback self._coordinate_fs = functionspace.VectorFunctionSpace(self, "Lagrange", 1) File "/opt/firedrake/1510/lib/python2.7/site-packages/PyOP2-0.11.0_388_gde0c811-py2.7-linux-x86_64.egg/pyop2/caching.py", line 161, in __new__ obj = make_obj() File "/opt/firedrake/1510/lib/python2.7/site-packages/PyOP2-0.11.0_388_gde0c811-py2.7-linux-x86_64.egg/pyop2/caching.py", line 142, in make_obj obj.__init__(*args, **kwargs) File "/opt/firedrake/1510/lib/python2.7/site-packages/firedrake/functionspace.py", line 615, in __init__ super(VectorFunctionSpace, self).__init__(mesh, element, name, dim=dim, rank=1) File "/opt/firedrake/1510/lib/python2.7/site-packages/firedrake/functionspace.py", line 140, in __init__ dmplex.get_facet_nodes(mesh.exterior_facets.facet_cell, File "/opt/firedrake/1510/lib/python2.7/site-packages/PyOP2-0.11.0_388_gde0c811-py2.7-linux-x86_64.egg/pyop2/utils.py", line 64, in __get__ obj.__dict__[self.__name__] = result = self.fget(obj) File "/opt/firedrake/1510/lib/python2.7/site-packages/firedrake/mesh.py", line 505, in exterior_facets boundary_ids, unique_markers=unique_ids) File "/opt/firedrake/1510/lib/python2.7/site-packages/firedrake/mesh.py", line 54, in __init__ "Every marker has to be contained in unique_markers" AssertionError: Every marker has to be contained in unique_markers
This sounds like somehow your mesh file is corrupted (or invalid). Is it the same geo as before? Can you send the gmsh command you used to create it? Lawrence
Same file with your added line. I use: gmsh -2 mesh.geo ________________________________________ From: firedrake-bounces@imperial.ac.uk <firedrake-bounces@imperial.ac.uk> on behalf of Lawrence Mitchell <lawrence.mitchell@imperial.ac.uk> Sent: 17 February 2016 15:57 To: firedrake@imperial.ac.uk Subject: Re: [firedrake] dimension with external mesh On 17/02/16 15:47, Tomasz Salwa [RPG] wrote:
Thank you. Still something wrong, now I'm getting this:
File "/home/mmtjs/work/programs/lin_coupled_fd_2d/lib/beam.py", line 49, in build_function_spaces self.V = fd.VectorFunctionSpace(self.mesh, "CG", 1) File "/opt/firedrake/1510/lib/python2.7/site-packages/PyOP2-0.11.0_388_gde0c811-py2.7-linux-x86_64.egg/pyop2/caching.py", line 161, in __new__ obj = make_obj() File "/opt/firedrake/1510/lib/python2.7/site-packages/PyOP2-0.11.0_388_gde0c811-py2.7-linux-x86_64.egg/pyop2/caching.py", line 142, in make_obj obj.__init__(*args, **kwargs) File "/opt/firedrake/1510/lib/python2.7/site-packages/firedrake/functionspace.py", line 613, in __init__ mesh.init() File "/opt/firedrake/1510/lib/python2.7/site-packages/firedrake/mesh.py", line 475, in init self._callback(self) File "/opt/firedrake/1510/lib/python2.7/site-packages/firedrake/mesh.py", line 438, in callback self._coordinate_fs = functionspace.VectorFunctionSpace(self, "Lagrange", 1) File "/opt/firedrake/1510/lib/python2.7/site-packages/PyOP2-0.11.0_388_gde0c811-py2.7-linux-x86_64.egg/pyop2/caching.py", line 161, in __new__ obj = make_obj() File "/opt/firedrake/1510/lib/python2.7/site-packages/PyOP2-0.11.0_388_gde0c811-py2.7-linux-x86_64.egg/pyop2/caching.py", line 142, in make_obj obj.__init__(*args, **kwargs) File "/opt/firedrake/1510/lib/python2.7/site-packages/firedrake/functionspace.py", line 615, in __init__ super(VectorFunctionSpace, self).__init__(mesh, element, name, dim=dim, rank=1) File "/opt/firedrake/1510/lib/python2.7/site-packages/firedrake/functionspace.py", line 140, in __init__ dmplex.get_facet_nodes(mesh.exterior_facets.facet_cell, File "/opt/firedrake/1510/lib/python2.7/site-packages/PyOP2-0.11.0_388_gde0c811-py2.7-linux-x86_64.egg/pyop2/utils.py", line 64, in __get__ obj.__dict__[self.__name__] = result = self.fget(obj) File "/opt/firedrake/1510/lib/python2.7/site-packages/firedrake/mesh.py", line 505, in exterior_facets boundary_ids, unique_markers=unique_ids) File "/opt/firedrake/1510/lib/python2.7/site-packages/firedrake/mesh.py", line 54, in __init__ "Every marker has to be contained in unique_markers" AssertionError: Every marker has to be contained in unique_markers
This sounds like somehow your mesh file is corrupted (or invalid). Is it the same geo as before? Can you send the gmsh command you used to create it? Lawrence
On 17/02/16 16:06, Tomasz Salwa [RPG] wrote:
Same file with your added line. I use: gmsh -2 mesh.geo
Ah, OK. If you provide a marker for one of the external boundaries of your mesh, you need to do so for all of them. You currently have: Physical Line(3) = {1}; If you also set physical lines for the geometric lines 2 through 4 in a similar manner, then things should work. Or, if you don't need to apply boundary conditions to any of the walls individually (and therefore don't need to distinguish between them), then you can delete that one Physical Line. Lawrence I
Great, works now! Thank you. Sorry that it was actually more gmsh than FD issue... Tomasz ________________________________________ From: firedrake-bounces@imperial.ac.uk <firedrake-bounces@imperial.ac.uk> on behalf of Lawrence Mitchell <lawrence.mitchell@imperial.ac.uk> Sent: 17 February 2016 16:19 To: firedrake@imperial.ac.uk Subject: Re: [firedrake] dimension with external mesh On 17/02/16 16:06, Tomasz Salwa [RPG] wrote:
Same file with your added line. I use: gmsh -2 mesh.geo
Ah, OK. If you provide a marker for one of the external boundaries of your mesh, you need to do so for all of them. You currently have: Physical Line(3) = {1}; If you also set physical lines for the geometric lines 2 through 4 in a similar manner, then things should work. Or, if you don't need to apply boundary conditions to any of the walls individually (and therefore don't need to distinguish between them), then you can delete that one Physical Line. Lawrence I
participants (2)
- 
                
                Lawrence Mitchell
- 
                
                Tomasz Salwa [RPG]