Upgrade from version 2016.2 to 2017 now produces std::bad_alloc error
auto rectangle = std::make_shared<mshr::Rectangle>(dolfin::Point(-width, height, 0.0), dolfin::Point(width, -height, 0.0)); auto circle = std::make_shared<mshr::Circle>(dolfin::Point(0.0, 0.0, 0.0), size_obj); auto difference = std::make_shared<mshr::CSGDifference>(rectangle, circle); auto mesh = mshr::generate_mesh(difference, precision);
The compilation was successful and I could solve the problem. Now I upgraded to the newest 2017 version and the same code that used to work now produces a
std::bad_alloc error when I try to launch the solution.
terminate called after throwing an instance of 'std::bad_alloc' what(): std::bad_alloc
I tried declaring a rectangular mesh without the circular hole and it works, so the problem must be in the
difference object or in the
What changed between the version that now makes the code fail?
rectangle, I used upper left and lower right corners to define it.
Simply using lower right and upper right ones (i.e.
auto rectangle = std::make_shared<mshr::Rectangle>(dolfin::Point(-width, -height, 0.0), dolfin::Point(width, height, 0.0));) will produce the correct mesh.
Maybe there are precise specifications about mshr::Rectangle that I did not bother to read that specify this point :/
EDIT: the official bitbucket page states "Create rectangle defined by two opposite corners." and in fact the rectangular mesh is correctly created with whichever choice of opposite corners.
Problems start when using
mshr::CSGDifference, for which the opposite corners must be precisely chosen.
I tried to create a mesh for a rectengular domain with/without circular hole using the code shown above. For both cases, the compilation fails while linking the executables. For the case with hole, the following error occurs:
[ 25%] Building CXX object CMakeFiles/demo_poisson.dir/main.cpp.o [ 50%] Linking CXX executable demo_poisson CMakeFiles/demo_poisson.dir/main.cpp.o: In function `void __gnu_cxx::new_allocator<mshr::CSGDifference>::construct<mshr::CSGDifference, std::shared_ptr<mshr::Rectangle>&, std::shared_ptr<mshr::Circle>&>(mshr::CSGDifference*, std::shared_ptr<mshr::Rectangle>&, std::shared_ptr<mshr::Circle>&)': /usr/include/c++/6/ext/new_allocator.h:120: undefined reference to `mshr::CSGDifference::CSGDifference(std::shared_ptr<mshr::CSGGeometry>, std::shared_ptr<mshr::CSGGeometry>)'
Any idea what goes wrong?