27 template <
int dim,
int spacedim>
39 template <
int dim,
int spacedim>
42 const std::pair<float, float> &coefficients)
44 return [coefficients](
48 std::trunc(coefficients.first *
49 std::pow(future_fe.n_dofs_per_cell(), coefficients.second));
53 static_cast<float>(std::numeric_limits<unsigned int>::max()),
55 "Cannot cast determined weight for this cell to unsigned int!"));
57 return static_cast<unsigned int>(result);
63 template <
int dim,
int spacedim>
66 const std::vector<std::pair<float, float>> &coefficients)
68 return [coefficients](
72 for (
const auto &pair : coefficients)
74 pair.first *
std::pow(future_fe.n_dofs_per_cell(), pair.second);
75 result = std::trunc(result);
79 static_cast<float>(std::numeric_limits<unsigned int>::max()),
81 "Cannot cast determined weight for this cell to unsigned int!"));
83 return static_cast<unsigned int>(result);
91 template <
int dim,
int spacedim>
92 std::vector<unsigned int>
97 std::vector<unsigned int> precomputed_weights;
98 precomputed_weights.reserve(fe_collection.
size());
101 for (
const auto &fe : fe_collection)
102 precomputed_weights.push_back(weighting_function(dummy, fe));
104 return precomputed_weights;
111 template <
int dim,
int spacedim>
116 reinit(dof_handler, weighting_function);
121 template <
int dim,
int spacedim>
124 const std::vector<unsigned int> &precomputed_weights)
126 reinit(dof_handler, precomputed_weights);
131 template <
int dim,
int spacedim>
134 connection.disconnect();
139 template <
int dim,
int spacedim>
145 connection.disconnect();
148 make_weighting_callback(dof_handler, weighting_function));
153 template <
int dim,
int spacedim>
157 const std::vector<unsigned int> &precomputed_weights)
159 connection.disconnect();
162 make_weighting_callback(dof_handler, precomputed_weights));
169 template <
int dim,
int spacedim>
170 std::function<
unsigned int(
171 const typename ::Triangulation<dim, spacedim>::cell_iterator &cell,
184 "parallel::CellWeights requires a parallel::TriangulationBase object."));
186 return [&dof_handler, tria, weighting_function](
187 const typename ::Triangulation<dim, spacedim>::cell_iterator
191 cell, status, dof_handler, *tria, weighting_function);
197 template <
int dim,
int spacedim>
200 const typename ::Triangulation<dim, spacedim>::cell_iterator &cell_,
210 "Triangulation associated with the DoFHandler has changed!"));
229 fe_index = cell->future_fe_index();
235 for (
const auto &child : cell->child_iterators())
236 Assert(child->is_active() && child->coarsen_flag_set(),
240 fe_index = ::internal::hp::DoFHandlerImplementation::
241 dominated_future_fe_on_children<dim, spacedim>(cell);
250 return weighting_function(cell, dof_handler.
get_fe(fe_index));
255 template <
int dim,
int spacedim>
256 std::function<
unsigned int(
257 const typename ::Triangulation<dim, spacedim>::cell_iterator &cell,
261 const std::vector<unsigned int> &precomputed_weights)
271 "parallel::CellWeights requires a parallel::TriangulationBase object."));
274 return [&dof_handler, tria, precomputed_weights](
275 const typename ::Triangulation<dim, spacedim>::cell_iterator
279 cell, status, dof_handler, *tria, precomputed_weights);
285 template <
int dim,
int spacedim>
288 const typename ::Triangulation<dim, spacedim>::cell_iterator &cell_,
292 const std::vector<unsigned int> &precomputed_weights)
298 "Triangulation associated with the DoFHandler has changed!"));
318 fe_index = cell->future_fe_index();
324 for (
const auto &child : cell->child_iterators())
325 Assert(child->is_active() && child->coarsen_flag_set(),
329 fe_index = ::internal::hp::DoFHandlerImplementation::
330 dominated_future_fe_on_children<dim, spacedim>(cell);
339 return precomputed_weights[fe_index];
345#include "distributed/cell_weights.inst"
@ children_will_be_coarsened
const hp::FECollection< dim, spacedim > & get_fe_collection() const
const FiniteElement< dim, spacedim > & get_fe(const types::fe_index index=0) const
const Triangulation< dim, spacedim > & get_triangulation() const
unsigned int size() const
static unsigned int weighting_callback(const typename ::Triangulation< dim, spacedim >::cell_iterator &cell, const CellStatus status, const DoFHandler< dim, spacedim > &dof_handler, const parallel::TriangulationBase< dim, spacedim > &triangulation, const WeightingFunction &weighting_function)
static WeightingFunction constant_weighting(const unsigned int factor=1)
std::function< unsigned int(const typename DoFHandler< dim, spacedim >::cell_iterator &, const FiniteElement< dim, spacedim > &)> WeightingFunction
static WeightingFunction ndofs_weighting(const std::pair< float, float > &coefficients)
void reinit(const DoFHandler< dim, spacedim > &dof_handler, const WeightingFunction &weighting_function)
static std::function< unsigned int(const typename ::Triangulation< dim, spacedim >::cell_iterator &cell, const CellStatus status)> make_weighting_callback(const DoFHandler< dim, spacedim > &dof_handler, const WeightingFunction &weighting_function)
static std::vector< unsigned int > precompute_weights(const hp::FECollection< dim, spacedim > &fe_collection, const WeightingFunction &weighting_function)
#define DEAL_II_NAMESPACE_OPEN
constexpr bool running_in_debug_mode()
#define DEAL_II_NAMESPACE_CLOSE
#define DEAL_II_ASSERT_UNREACHABLE()
#define Assert(cond, exc)
static ::ExceptionBase & ExcMessage(std::string arg1)
static ::ExceptionBase & ExcInconsistentCoarseningFlags()
typename ActiveSelector::cell_iterator cell_iterator
constexpr types::fe_index invalid_fe_index
::VectorizedArray< Number, width > pow(const ::VectorizedArray< Number, width > &, const Number p)
unsigned short int fe_index