Help understanding MappingQ(2) for curved elements

45 views
Skip to first unread message

Matteo Malvestiti

unread,
Jan 26, 2025, 5:06:34 AM1/26/25
to deal.II User Group
Good morning,
I've been following the instructions on step-38 to use curved elements.
Problem is: only the elements at the boundary get curved (see attached photo).

Here is a simple test program:

// Mesh
const std::string filename = "../mesh.msh";
std::ifstream input_file(filename);
Triangulation<2,2> triangulation;
GridIn<2> grid_in;
grid_in.attach_triangulation(triangulation);
grid_in.read_msh(input_file);

//Manifold
const Point<2> center(0.0, 0.0);
SphericalManifold<2,2> circular_manifold(center);
triangulation.reset_all_manifolds();
triangulation.set_all_manifold_ids(0);
triangulation.set_manifold (0, circular_manifold);

// DoFHandler, Mapping, and FE
DoFHandler<2,2> dof_handler(triangulation);
MappingQ<2,2> mapping(2);
const FE_Q<2,2> fe(1);
dof_handler.distribute_dofs(fe);

// Output
DataOut<2> data_out;
data_out.attach_dof_handler(dof_handler);
data_out.build_patches(mapping, 5);
std::ofstream out("output_mesh.vtu");
data_out.write(out, DataOutBase::vtu);

I'm surely doing something wrong, any hint?

I leave a zip file attached with all the necessary to compile and run this snippet of code.

curved_only_along_boundaries.png
MappingQ_Bug.zip

Peter Munch

unread,
Jan 26, 2025, 5:10:37 AM1/26/25
to deal.II User Group
Hi Matteo,

it is probably only the output. DataOut::build_patches() has an additional parameter that specifies the curved region (https://www.dealii.org/developer/doxygen/deal.II/classDataOut.html#a1303b5d99f10f3fae984e7d406cfeb37). Select CurvedCellRegion::curved_inner_cells. 

Best,
Peter

Matteo Malvestiti

unread,
Jan 26, 2025, 5:22:03 AM1/26/25
to deal.II User Group
Thanks a lot,
That solved the issue!

I really appreciate your help.

For future readers, here is the correct call to build_patches():
data_out.build_patches(mapping, 5, DataOut<2,2>::CurvedCellRegion::curved_inner_cells);

Best regards,
Matteo Malvestiti
Reply all
Reply to author
Forward
0 new messages