Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Towards making DataOutFaces work with simplices. #12859

Merged
merged 3 commits into from
Oct 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion source/numerics/data_out.cc
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ DataOut<dim, spacedim>::build_one_patch(
// explicitly given
patch.points_are_available = true;

// then resize the patch.data member in order to have enough memory for
// then size the patch.data member in order to have enough memory for
// the quadrature points as well, and copy the quadrature points there
const std::vector<Point<spacedim>> &q_points =
fe_patch_values.get_quadrature_points();
Expand Down
68 changes: 37 additions & 31 deletions source/numerics/data_out_faces.cc
Original file line number Diff line number Diff line change
Expand Up @@ -99,31 +99,41 @@ DataOutFaces<dim, spacedim>::build_one_patch(
internal::DataOutFacesImplementation::ParallelData<dim, spacedim> &data,
DataOutBase::Patch<patch_dim, patch_spacedim> & patch)
{
Assert(cell_and_face->first->is_locally_owned(), ExcNotImplemented());
const cell_iterator cell = cell_and_face->first;
const unsigned int face_number = cell_and_face->second;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just introducing variables for cell and face here, rather than having to go through the tuple every time.


// we use the mapping to transform the vertices. However, the mapping works
Assert(cell->is_locally_owned(), ExcNotImplemented());

// First set the kind of object we are dealing with here in the 'patch'
// object.
patch.reference_cell = cell->face(face_number)->reference_cell();
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is new: Setting the reference cell for the patch corresponding to this one face.


// We use the mapping to transform the vertices. However, the mapping works
// on cells, not faces, so transform the face vertex to a cell vertex, that
// to a unit cell vertex and then, finally, that to the mapped vertex. In
// most cases this complicated procedure will be the identity.
for (unsigned int vertex = 0;
vertex < GeometryInfo<dim - 1>::vertices_per_cell;
++vertex)
patch.vertices[vertex] =
data.mapping_collection[0].transform_unit_to_real_cell(
cell_and_face->first,
GeometryInfo<dim>::unit_cell_vertex(
GeometryInfo<dim>::face_to_cell_vertices(
cell_and_face->second,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This block was just hard to read, so I split it up into several individual statements that name intermediate variables. It also uses GeometryInfo, which works for hypercube cells but not for other kinds of cells. So I replace by the corresponding ReferenceCell functions to generalize the code.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new test is failing. I guess it is due to vertex < GeometryInfo<dim - 1>::vertices_per_cell.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it's actually much more complex. I'll have to do substantial more work.

Let me move the failing test to the tests/fail directory for now. Outputting data via DataOutFaces does not currently work correctly, and there no reason to have a test that produces crazy output we know is broken hold up otherwise useful patches.

for (const unsigned int vertex : cell->face(face_number)->vertex_indices())
{
const Point<dim> vertex_reference_coordinates =
cell->reference_cell().template vertex<dim>(
cell->reference_cell().face_to_cell_vertices(
face_number,
vertex,
cell_and_face->first->face_orientation(cell_and_face->second),
cell_and_face->first->face_flip(cell_and_face->second),
cell_and_face->first->face_rotation(cell_and_face->second))));
cell->face_orientation(face_number) +
4 * cell->face_flip(face_number) +
2 * cell->face_rotation(face_number)));
Comment on lines +122 to +124
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll add a getter function that returns a combined version. Such kind of code should not be spread over whole library.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great idea!


const Point<dim> vertex_real_coordinates =
data.mapping_collection[0].transform_unit_to_real_cell(
cell, vertex_reference_coordinates);

patch.vertices[vertex] = vertex_real_coordinates;
}


if (data.n_datasets > 0)
{
data.reinit_all_fe_values(this->dof_data,
cell_and_face->first,
cell_and_face->second);
data.reinit_all_fe_values(this->dof_data, cell, face_number);
const FEValuesBase<dim> &fe_patch_values = data.get_present_fe_values(0);

const unsigned int n_q_points = fe_patch_values.n_quadrature_points;
Expand All @@ -132,9 +142,9 @@ DataOutFaces<dim, spacedim>::build_one_patch(
Assert(patch.space_dim == dim, ExcInternalError());
const std::vector<Point<dim>> &q_points =
fe_patch_values.get_quadrature_points();
// resize the patch.data member in order to have enough memory for the
// size the patch.data member in order to have enough memory for the
// quadrature points as well
patch.data.reinit(data.n_datasets + dim, patch.data.size(1));
patch.data.reinit(data.n_datasets + dim, q_points.size());
// set the flag indicating that for this cell the points are explicitly
// given
patch.points_are_available = true;
Expand Down Expand Up @@ -194,9 +204,9 @@ DataOutFaces<dim, spacedim>::build_one_patch(
this_fe_patch_values.get_normal_vectors();

const typename DoFHandler<dim, spacedim>::active_cell_iterator
dh_cell(&cell_and_face->first->get_triangulation(),
cell_and_face->first->level(),
cell_and_face->first->index(),
dh_cell(&cell->get_triangulation(),
cell->level(),
cell->index(),
this->dof_data[dataset]->dof_handler);
data.patch_values_scalar.template set_cell<dim>(dh_cell);

Expand Down Expand Up @@ -237,9 +247,9 @@ DataOutFaces<dim, spacedim>::build_one_patch(
this_fe_patch_values.get_normal_vectors();

const typename DoFHandler<dim, spacedim>::active_cell_iterator
dh_cell(&cell_and_face->first->get_triangulation(),
cell_and_face->first->level(),
cell_and_face->first->index(),
dh_cell(&cell->get_triangulation(),
cell->level(),
cell->index(),
this->dof_data[dataset]->dof_handler);
data.patch_values_system.template set_cell<dim>(dh_cell);

Expand Down Expand Up @@ -294,15 +304,14 @@ DataOutFaces<dim, spacedim>::build_one_patch(
// belongs in order to access the cell data. this is not readily
// available, so choose the following rather inefficient way:
Assert(
cell_and_face->first->is_active(),
cell->is_active(),
ExcMessage(
"The current function is trying to generate cell-data output "
"for a face that does not belong to an active cell. This is "
"not supported."));
const unsigned int cell_number = std::distance(
this->triangulation->begin_active(),
typename Triangulation<dim, spacedim>::active_cell_iterator(
cell_and_face->first));
typename Triangulation<dim, spacedim>::active_cell_iterator(cell));

const double value = this->cell_data[dataset]->get_cell_data_value(
cell_number,
Expand Down Expand Up @@ -395,9 +404,6 @@ DataOutFaces<dim, spacedim>::build_patches(
update_flags);
DataOutBase::Patch<patch_dim, patch_spacedim> sample_patch;
sample_patch.n_subdivisions = n_subdivisions;
sample_patch.data.reinit(n_datasets,
Utilities::fixed_power<patch_dim>(n_subdivisions +
1));

// now build the patches in parallel
WorkStream::run(
Expand Down