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
Assert that the incoming cell is Cartesian in MappingCartesian #13748
Assert that the incoming cell is Cartesian in MappingCartesian #13748
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. I have a few suggestions for improvement below.
source/fe/mapping_cartesian.cc
Outdated
|
||
|
||
/** | ||
* Return whether the incoming cell is a Cartesian. This is determined by |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* Return whether the incoming cell is a Cartesian. This is determined by | |
* Return whether the incoming cell is of Cartesian shape. This is determined by |
source/fe/mapping_cartesian.cc
Outdated
for (unsigned int v : cell->vertex_indices()) | ||
{ | ||
const double tolerance = 1e-14; | ||
if (cell->vertex(v).distance(bounding_box.vertex(v)) > tolerance) | ||
return false; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Neat check - I would have done it differently but this is certainly the most elegant way to check this property. 👍
source/fe/mapping_cartesian.cc
Outdated
const auto bounding_box = cell->bounding_box(); | ||
for (unsigned int v : cell->vertex_indices()) | ||
{ | ||
const double tolerance = 1e-14; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be better to use relative tolerances:
const double tolerance = 1e-14; | |
const double tolerance = 1e-14 * cell->diameter(); |
(I note that this call is somewhat expensive, but this is only used for assertions anyway so we can afford it.)
/rebuild |
source/fe/mapping_cartesian.cc
Outdated
is_cartesian(const CellType &cell) | ||
{ | ||
const auto bounding_box = cell->bounding_box(); | ||
for (unsigned int v : cell->vertex_indices()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for (unsigned int v : cell->vertex_indices()) | |
for (const unsigned int v : cell->vertex_indices()) |
template <class CellType> | ||
bool | ||
is_cartesian(const CellType &cell) | ||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would first check if the cell is a hypercube.
source/fe/mapping_cartesian.cc
Outdated
bool | ||
is_cartesian(const CellType &cell) | ||
{ | ||
const auto bounding_box = cell->bounding_box(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No sure if going via bb is right way. Wouldn't it be easier to go through each direction and compare the points?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know. I can't figure out something easier right now, at least. I think I would just end up with something very similar to what is already in the bounding_box()
function:
https://www.dealii.org/developer/doxygen/deal.II/tria__accessor_8cc_source.html#l01616
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's keep it like this!
703af27
to
3dc8884
Compare
3dc8884
to
c2e38b7
Compare
No description provided.