*/
virtual ~FEValuesBase() override;
+ /**
+ * Explicitly allow to check for cell similarity. By default, this is only
+ * enabled when the number of threads is 1.
+ */
+ void
+ allow_check_for_cell_similarity(bool allow);
/// @name Access to shape function values
///
*/
dealii::internal::FEValuesViews::Cache<dim, spacedim> fe_values_views_cache;
+ /**
+ * Whether checking for cell similarity is allowed.
+ */
+ bool check_for_cell_similarity_allowed;
+
// Make the view classes friends of this class, since they access internal
// data.
template <int, int>
, fe(&fe, typeid(*this).name())
, cell_similarity(CellSimilarity::Similarity::none)
, fe_values_views_cache(*this)
+ , check_for_cell_similarity_allowed(MultithreadInfo::n_threads() == 1)
{
Assert(n_q_points > 0,
ExcMessage("There is nothing useful you can do with an FEValues "
+template <int dim, int spacedim>
+void
+FEValuesBase<dim, spacedim>::allow_check_for_cell_similarity(bool allow)
+{
+ check_for_cell_similarity_allowed = allow;
+}
+
+
+
namespace internal
{
// put shape function part of get_function_xxx methods into separate
// initialized to the first cell the thread sees. As this number might
// different between different runs (after all, the tasks are scheduled
// dynamically onto threads), this slight deviation leads to difference in
- // roundoff errors that propagate through the program. Therefore, we need to
- // disable CellSimilarity in case there is more than one thread in the
- // problem. This will likely not affect many MPI test cases as there
+ // roundoff errors that propagate through the program. Therefore, we
+ // disable CellSimilarity by default in case there is more than one thread in
+ // the problem. This will likely not affect many MPI test cases as there
// multithreading is disabled on default, but in many other situations
// because we rarely explicitly set the number of threads.
- //
- // TODO: Is it reasonable to introduce a flag "unsafe" in the constructor of
- // FEValues to re-enable this feature?
- if (MultithreadInfo::n_threads() > 1)
+ if (!check_for_cell_similarity_allowed)
{
cell_similarity = CellSimilarity::none;
return;