On 2/6/21 2:30 PM, Corbin Foucart wrote:
Thank you for the fast and clear answer, Wolfgang.
Just add such a hash function for Point. It's true that two nearby points
will
have different hash values, but that shouldn't stop you from using hashes if
you query the same points over and over.
This is definitely doable.
We would love to see the corresponding patch to deal.II then :-)
The C++ standard is (maybe oddly) written in a way that suggests that one
should specialize std::hash. Take a look at
https://en.cppreference.com/w/cpp/utility/hash
I'm curious about this; if the material ID physically represents a
location-based quantity (e.g., which vertical column of fluid as specified by
a surface mesh), how come you recommend using the iteration order to specify
it? Unless I'm misunderstanding what you mean by logic position of the cell
w/r/t a cell iterator...
What I meant to say is this: because floating point numbers can not be
computed in a stable way, it is often tricky to use them as indices or as the
basis of a hash lookup. If I understand you correctly, what you wanted to do
is something like
std::map<Point<dim>, MyProperty> property_map;
for (auto cell : ...)
{
MyProperty prop;
prop = some_function(depends on the location of 'cell');
property_map[cell->center()] = prop;
}
This is tricky because of the lookup based on a floating point number (the
'center' location of the cell). A better design might be
std::map<cell_iterator, MyProperty> property_map;
for (auto cell : ...)
{
MyProperty prop;
prop = some_function(depends on the location of 'cell');
property_map[cell] = prop;
}
You're still computing the property based on the location of the cell, but
you're storing it based on something that's conceptually an integer.
Best
W.
--
------------------------------------------------------------------------
Wolfgang Bangerth email: [email protected]
www: http://www.math.colostate.edu/~bangerth/
--
The deal.II project is located at http://www.dealii.org/
For mailing list/forum options, see
https://groups.google.com/d/forum/dealii?hl=en
---
You received this message because you are subscribed to the Google Groups "deal.II User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/dealii/fcda4f03-5f78-f3b8-0e87-64f165cff3e4%40colostate.edu.