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

Negative det in MappingFE on some simplex mesh #13346

Closed
zjiaqi2018 opened this issue Feb 7, 2022 · 6 comments
Closed

Negative det in MappingFE on some simplex mesh #13346

zjiaqi2018 opened this issue Feb 7, 2022 · 6 comments

Comments

@zjiaqi2018
Copy link
Contributor

I imported a triangular mesh using read_msh(), but got negative det:

--------------------------------------------------------
An error occurred in line <1236> of file </home/jiaqi2/dealii/dealii/source/fe/mapping_fe.cc> in function
    dealii::CellSimilarity::Similarity dealii::MappingFE<dim, spacedim>::fill_fe_values(const typename dealii::Triangulation<dim, spacedim>::cell_iterator&, dealii::CellSimilarity::Similarity, const dealii::Quadrature<dim>&, const typename dealii::Mapping<dim, spacedim>::InternalDataBase&, dealii::internal::FEValuesImplementation::MappingRelatedData<dim, spacedim>&) const [with int dim = 2; int spacedim = 2; typename dealii::Triangulation<dim, spacedim>::cell_iterator = dealii::TriaIterator<dealii::CellAccessor<2, 2> >; typename dealii::Mapping<dim, spacedim>::InternalDataBase = dealii::Mapping<2, 2>::InternalDataBase]
The violated condition was: 
    det > 1e-12 * Utilities::fixed_power<dim>( cell->diameter() / std::sqrt(double(dim)))
Additional information: 
    The image of the mapping applied to cell with center [0.119706
    0.189866] is distorted. The cell geometry or the mapping are invalid,
    giving a non-positive volume fraction of -0.00946307 in quadrature
    point 0.

Stacktrace:
-----------
#0  /home/jiaqi2/dealii/installed/lib/libdeal_II.g.so.10.0.0-pre: dealii::MappingFE<2, 2>::fill_fe_values(dealii::TriaIterator<dealii::CellAccessor<2, 2> > const&, dealii::CellSimilarity::Similarity, dealii::Quadrature<2> const&, dealii::Mapping<2, 2>::InternalDataBase const&, dealii::internal::FEValuesImplementation::MappingRelatedData<2, 2>&) const
#1  /home/jiaqi2/dealii/installed/lib/libdeal_II.g.so.10.0.0-pre: dealii::FEValues<2, 2>::do_reinit()
#2  /home/jiaqi2/dealii/installed/lib/libdeal_II.g.so.10.0.0-pre: void dealii::FEValues<2, 2>::reinit<false>(dealii::TriaIterator<dealii::DoFCellAccessor<2, 2, false> > const&)
#3  /home/jiaqi2/dealii/installed/lib/libdeal_II.g.so.10.0.0-pre: void dealii::hp::FEValues<2, 2>::reinit<false>(dealii::TriaIterator<dealii::DoFCellAccessor<2, 2, false> > const&, unsigned int, unsigned int, unsigned int)
#4  ./hptest: test(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)
#5  ./hptest: main
--------------------------------------------------------

@peterrum said that the mesh has normal showing in the negative z direction, which leads to the negative determinant. The mesh has to be reoriented, which should be simple in 2D, but complicated in 3D.

This is the mesh
image

This is a test that reproduces this
https://github.com/zjiaqi2018/read-msh

@drwells
Copy link
Member

drwells commented Feb 7, 2022

This is a known bug (or rather, something we have not implemented yet):

// TODO: the functions below (GridTools::delete_unused_vertices(),
// GridTools::invert_all_negative_measure_cells(),
// GridTools::consistently_order_cells()) need to be
// revisited for simplex/mixed meshes

@drwells
Copy link
Member

drwells commented Feb 7, 2022

I am cautiously optimistic, since its not possible to tangle a tetrahedron like it is a hexahedron, that we can implement these functions ourselves for simplices without too much trouble. In particular, in 2D, it should suffice to switch the order of two vertices for a negative triangle to get things working correctly.

@peterrum
Copy link
Member

peterrum commented Feb 7, 2022

This is a known bug (or rather, something we have not implemented yet):

I would have hoped that the mesh-generation tools are doing this themselves...

@drwells
Copy link
Member

drwells commented Feb 7, 2022

I recall seeing a gmsh example once that set all the cells to have (in our opinion) negative measure: in this particular case I suspect that by changing two columns of vertex numbers in the input file we can use the file without problems.

I'm not sure how GMSH sets the orientation convention but I think it is consistent between elements.

@tjhei
Copy link
Member

tjhei commented Feb 7, 2022

I'm not sure how GMSH sets the orientation convention but I think it is consistent between elements.

It is not. Even with quads in 2d GMSH sometimes produces meshes with all negative or all positive measure. If you mesh a mesh with two pieces, this can also happen in the same file. We fail to read it right now. My student will open a PR with a fix soon. Maybe I should create an issue now... See #13347

@drwells
Copy link
Member

drwells commented Dec 6, 2022

The previous PRs fixed this so lets close the issue.

@drwells drwells closed this as completed Dec 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants