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

error: empty mesh using mshr

0 votes

Hi all,
i would like to create a mesh as the union of different geometries using the mshr library. When i work with positive coordinates i don't have any troubles, but if i change the sign of the coordinates the next error appears:

<Union>
{
  <Rectangle with first corner at (<Point x = 0 y = 0 z = 0>) and second corner at (<Point x = -3 y = -3 z = 0>)>
  <Rectangle with first corner at (<Point x = -1 y = -1 z = 0>) and second corner at (<Point x = -2 y = -2 z = 0>)>
}
<Mesh of topological dimension 2 (triangles) with 10 vertices and 0 cells, ordered>
*** Warning: Mesh is empty, unable to create entities of dimension 0.
*** Warning: Mesh is empty, unable to create entities of dimension 1.
*** Warning: Mesh is empty, unable to create entities of dimension 2.
*** Warning: Mesh is empty, unable to create connectivity 0 --> 0.
*** Warning: Mesh is empty, unable to create connectivity 0 --> 1.
*** Warning: Mesh is empty, unable to create connectivity 0 --> 2.

A sample of the code to reproduce the error is the next (The same warning message can be obtain running the materials mshr demo):

#include <dolfin.h>
#include <mshr.h>

using namespace dolfin;

int main()
{
  set_log_level(20);  

  // Define 2D geometry
  mshr::Rectangle rect1(Point(0.0, 0.0), Point(-3.0, -3.0));
  mshr::Rectangle rect2(Point(-1.0, -1.0), Point(-2.0, -2.0));

  std::shared_ptr<mshr::CSGGeometry> g2d = rect1 + rect2;
  g2d->set_subdomain(1, rect1);
  g2d->set_subdomain(2, rect2);

  // Test printing
  info(*g2d, true);

  // Generate and plot mesh
  Mesh mesh;
  mshr::generate(mesh, *g2d, 16);
  cout << "Done generating mesh" << endl;
  info(mesh);
  mesh.init();
  plot(mesh, "2D mesh");
  interactive();

  return 0;
}

Currently i'm using fenics 1.6.

Any idea why this happens?

Thanks in advance!

asked Jan 20, 2016 by hernan_mella FEniCS Expert (19,460 points)
edited Jan 22, 2016 by hernan_mella

Hi, I think this should be reported as a bug on the mshr's issue tracker.

...