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

BoxMesh vs mshr: which one should I use?

0 votes

Dear all,

I need to create in C++ a simple parallelepiped, and I find two options:

// Create a temporary mesh
dolfin::Mesh tmp = dolfin::BoxMesh(0.0, 0.0, 0.0, conf.lengthx, conf.lengthy, conf.lengthz,
                                   std::round(conf.lengthx / conf.cellsizex),
                                   std::round(conf.lengthy / conf.cellsizey),
                                   std::round(conf.lengthz / conf.cellsizez));

mshr::Box b(dolfin::Point(0.0, 0.0, 0.0), dolfin::Point(conf.lengthx, conf.lengthy, conf.lengthz));

mshr::CSGCGALMeshGenerator3D generator;

generator.parameters["mesh_resolution"] = -1.0;
generator.parameters["cell_size"] = conf.cellsizex; // Non uniform on different axes: how?

generator.generate(b, tmp);

As you can see I can:

  • use dolfin::BoxMesh and set all parameters
  • use mshr::CSGCGALMeshGenerator3D

As far as I understand, mshr is to be used, but how can I generate a box with diverse number of cells (or cell sizes) on each direction?

Thanks!

asked Jul 2, 2016 by senseiwa FEniCS User (2,620 points)
...