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

Remove Quadrature(unsigned int) from the public interface. #17017

Merged
merged 4 commits into from
May 25, 2024

Conversation

bangerth
Copy link
Member

Fixes #16818.

This is strictly speaking an incompatible change. I don't think there should be many places where someone creates a correctly sized but otherwise invalid quadrature object, so the impact is likely small to zero.

I did think about alternatives. The obvious one is the introduction of a default constructor Quadrature() and removing the default value from the constructor in question here, followed by marking the latter as deprecated. That could work to retain backward compatibility. But because derived classes uniformly seem to be using this constructor, once we remove deprecated functions, we have to remember that this one cannot be removed but must be made protected instead. That just seemed unnecessary use of brain power, so I decided that the impact here is small enough to warrant outright removal.

@bangerth bangerth added this to the Release 9.6 milestone May 13, 2024
@kronbichler
Copy link
Member

We need to address the error

/home/runner/work/dealii/dealii/include/deal.II/matrix_free/fe_remote_evaluation.h:1192:19: error: calling a protected constructor of class 'dealii::Quadrature<2>' [clang-diagnostic-error]

This was recently introduced by @jh66637 in #16394 - any comments on how to address this? I think it would make sense to not store quadrature formulas but merely points (depending on how the consumer site looks like), or fill the quadrature objects with one of the other constructors.

@bangerth
Copy link
Member Author

The code you point out looks like this:

                // Insert a quadrature rule of correct size into the global
                // quadrature vector. First check that each face is only
                // considered once.
                Assert(global_quadrature_vector[bface].size() == 0,
                       ExcMessage(
                         "Quadrature for given face already provided."));

                global_quadrature_vector[bface] =
                  Quadrature<dim>(phi.n_q_points);

I think it's worth pointing out that what one ends up with here is a quadrature object with phi.n_q_point quadrature points that are all at the origin, and zero weights. This is a prescription for bugs (which is how I found out about this constructor to begin with). In other places we would initialize points and weights with signaling_nans, but here we don't.

In other words, I think that the design used here is broken. The object as initialized is unusable. We shouldn't create it. I don't know where that is, but assume that points and weights are set somewhere else, and we should leave resizing to the correct size to the place where we do the initialization of points and weights.

I'm afraid I have no overview of this code. Could someone help me with this location?

@kronbichler
Copy link
Member

I can definitely help if @jh66637 is busy, let us wait for a day or two (as my schedule is overly crowded today and tomorrow).

Comment on lines 1 to 2
Changed: The Quadrature class used to have a constructor that took an
integer argument. This was error prone because it was easy to accidentally
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Changed: The Quadrature class used to have a constructor that took an
integer argument. This was error prone because it was easy to accidentally
Changed: The Quadrature class used to have a constructor that took an
integer argument. This was error-prone because it was easy to accidentally

@jh66637
Copy link
Contributor

jh66637 commented May 14, 2024

@bangerth @kronbichler The reason I used this is the following: We only need the size of the quadrature objects. At some point I pointed out, that we have to decide if we keep the interface similar to FERemoteEvaluationCommunicator::reinit_faces() which requires a vector of quadratures or simply hand over a vector of quadrature sizes. I didn't find the respective comment, but at that time there was no opinion on how to proceed, and I kept it the way the function was written initially.

Long story short, we can simply replace

FERemoteEvaluationCommunicator::reinit_faces(..., const std::vector<std::vector<Quadrature<dim - 1>>> &quadrature_vector)

by

FERemoteEvaluationCommunicator::reinit_faces(..., const std::vector<std::vector<unsigned int>> &quadrature_sizes)

and similar for all overloads. This functionality is quite new, was in no release and is probably not used by a lot of people, so this can be easily changed in my opinion. I can do that in a separate PR if you want to, or you can do it with this PR. What do you prefer?

@bangerth
Copy link
Member Author

Since you know the code, I'd love if you could make that change in a separate PR. Once that's merged, I can rebase the current one. Thank you in advance!

@jh66637
Copy link
Contributor

jh66637 commented May 14, 2024

Since you know the code, I'd love if you could make that change in a separate PR.

I will try to find the time tomorrow :)

@bangerth
Copy link
Member Author

Now ready given that the one place where this failed has been addressed in #17032.

@masterleinad
Copy link
Member

There are still failing tests:

The following tests FAILED:
61 - simplex/data_out_write_gnuplot_01.debug (Failed)
62 - simplex/data_out_write_gnuplot_02.debug (Failed)
63 - simplex/data_out_write_gnuplot_03.debug (Failed)
68 - simplex/data_out_write_vtk_01.debug (Failed)
69 - simplex/data_out_write_vtk_02.debug (Failed)
155 - simplex/step-23.debug (Failed)
156 - simplex/step-31.debug (Failed)
163 - test_dependency/simplex.step-67.debug.executable (Failed)
164 - simplex/step-67.mpirun=1.debug (Not Run)
165 - simplex/step-67.mpirun=2.debug (Not Run)

@bangerth bangerth force-pushed the quadrature branch 2 times, most recently from 6f3f10d to cd2dd9e Compare May 23, 2024 03:32
@bangerth
Copy link
Member Author

I made it to work now.

Copy link
Member

@marcfehling marcfehling left a comment

Choose a reason for hiding this comment

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

One less pitfall. Very nice!

You can also use the default constructor in the tests.

tests/base/quadrature_is_tensor_product.cc Show resolved Hide resolved
tests/hp/fe_nothing_dominates_01.cc Show resolved Hide resolved
tests/hp/fe_nothing_dominates_01.cc Show resolved Hide resolved
tests/hp/fe_nothing_dominates_02.cc Show resolved Hide resolved
tests/hp/fe_nothing_dominates_02.cc Show resolved Hide resolved
@marcfehling marcfehling merged commit cc3619e into dealii:master May 25, 2024
16 checks passed
@bangerth bangerth deleted the quadrature branch May 25, 2024 22:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove constructor Quadrature(unsigned int).
5 participants