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

MatrixFree: check that JxW is not negative #16317

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

peterrum
Copy link
Member

@peterrum peterrum commented Dec 3, 2023

In a follow-up PR, I would like to extend it like

Assert(det >
1e-12 * Utilities::fixed_power<dim>(
cell->diameter() / std::sqrt(double(dim))),
(typename Mapping<dim, spacedim>::ExcDistortedMappedCell(
cell->center(), det, point)));

But for that I access to the cells.

@peterrum
Copy link
Member Author

peterrum commented Dec 3, 2023

@nfehn Could you check if this assert is triggered for your mesh?

@nfehn
Copy link
Contributor

nfehn commented Dec 4, 2023

I think this is a very helpful check.

@nfehn Could you check if this assert is triggered for your mesh?

Yes, it is.

@@ -2309,6 +2332,11 @@ namespace internal
1. :
my_data.descriptor[0].quadrature.weight(q));

#ifdef DEBUG
for (unsigned int v = 0; v < n_lanes_d; ++v)
Assert(JxW[v] > 0.0, ExcInternalError());
Copy link
Contributor

Choose a reason for hiding this comment

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

I wondered whether this exc message is clear, i.e. points to an invalid Jacobian determinant on faces? One might argue that JxW is basic FE language, so this is probably a matter of taste.

Copy link
Member

Choose a reason for hiding this comment

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

I don't think this message should ever trigger, as opposed to the one in line 1254 above, because JxW is computed as

  JxW = boundary_form.norm() * my_data.descriptor[0].quadrature.weight(q);

so here we have a norm that cannot be negative and a quadrature weight that should be non-negative. So here I would guess it is ok.

Copy link
Member Author

Choose a reason for hiding this comment

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

@kronbichler Thank you for the explanation! But the value could be 0, couldn't it? Furthermore, the check for the cell not only checks whether the value is positive but also that it is not too small. Unfortunately, I could not find such a check for faces in MappingQ (maybe I missed it).

Should we remove this assert? The chance is quite high that assert for the cell is triggered.

Copy link
Member

Choose a reason for hiding this comment

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

I don't think there is a check for the faces in terms of "sufficient" positivity. I would personally choose something like the other assertion you introduced above, with the difference to use Utilities::fixed_power<dim-1>(edge_length), i.e., one power less. It can trigger for really anisotropic faces (aspect ratio larger than 1e5), but I think that is ok.

@@ -1152,10 +1152,12 @@ namespace internal
typename VectorizedDouble>
void
Copy link
Contributor

Choose a reason for hiding this comment

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

When looking at the code, I realized that the documentation for the other function below (dealing with faces), see comment https://github.com/dealii/dealii/pull/16317/files#r1413627125, seems to be the same as here for the cells? This could be something one wants to change in the future. Of course this is somewhat unrelated to the present PR.

@bangerth
Copy link
Member

bangerth commented Jan 2, 2024

/rebuild

@peterrum
Copy link
Member Author

peterrum commented Jan 3, 2024

@kronbichler Do you have an idea why matrix_free/matrix_vector_hessians_general_faces.debug is triggering the assert? matrix_free/matrix_vector_hessians_general_cells.debug is not. The only difference is that one sets mapping_update_flags_inner_faces and the other mapping_update_flags.

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.

None yet

4 participants