This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

rectangle and box mesh

0 votes

Hello. I have problem with rectangle and boxmesh. If I use the code for rectangle:

mesh = RectangleMesh(-3.0, 2.0, 7.0, 6.0, 10, 10, "right/left")
print("Plotting a RectangleMesh")
plot(mesh, title="Rectangle (right/left)")

and this code for box:

 mesh = BoxMesh(0.0, 0.0, 0.0, 10.0, 4.0, 2.0, 10, 10, 10)
 print("Plotting a BoxMesh") plot(mesh, title="Box")
 interactive()

I get error. What is wrong? Can someone help me, so the code to the meshes can work. Regards stargirl5.

asked Oct 8, 2015 by stargirl5 FEniCS Novice (160 points)

Can you post the error?

The error if I run rectanglemesh is:

Traceback (most recent call last):
  File "me.py", line 6, in <module>
    mesh = RectangleMesh(0.0, 0.0, 10.0, 4.0, 10, 10)
  File "/usr/lib/python2.7/dist-packages/dolfin/cpp/mesh.py", line 9220, in __init__
    _mesh.RectangleMesh_swiginit(self,_mesh.new_RectangleMesh(*args))
TypeError: in method 'MPI_Comm', argument 1 of type 'new_RectangleMesh'

And if I run boxmesh I got that error:

Traceback (most recent call last):
  File "me.py", line 6, in <module>
    mesh = BoxMesh(0.0, 0.0, 0.0, 10.0, 4.0, 2.0, 10, 10, 10)
  File "/usr/lib/python2.7/dist-packages/dolfin/cpp/mesh.py", line 9103, in __init__
    _mesh.BoxMesh_swiginit(self,_mesh.new_BoxMesh(*args))
NotImplementedError: Wrong number or type of arguments for overloaded function 'new_BoxMesh'.
  Possible C/C++ prototypes are:
    dolfin::BoxMesh::BoxMesh(dolfin::Point const &,dolfin::Point const &,std::size_t,std::size_t,std::size_t)
    dolfin::BoxMesh::BoxMesh(MPI_Comm,dolfin::Point const &,dolfin::Point const &,std::size_t,std::size_t,std::size_t)

1 Answer

0 votes

The syntax has been changed in the latest version:

mesh = RectangleMesh(Point(-3,2), Point(7, 6), 10, 10, "right/left")

should work, I think.

answered Oct 8, 2015 by chris_richardson FEniCS Expert (31,740 points)

That works fo the rectanglemesh. Thanks, but what about the BoxMesh? It will still not work

The syntask for the boxmesh will not work:

mesh = BoxMesh(Point(0.0),Point(0.0),Point(0.0),Point(10.0),Point(4.0),Point(2.0), 10,10,10,"right/left")
print("Plotting a BoxMesh")
plot(mesh, title="Box")
interactive()
BoxMesh(Point(0,0,0), Point(1,2,3), 10, 20, 30)

It should be:

BoxMesh(Point(0.0, 0.0, 0.0), Point(10., 4., 2.), 10, 10, 10)
...