On 7/26/23 02:59, 'maurice rohracker' via deal.II User Group wrote:
>
> In a parallel distributed code, similar to step-42, we use a/dealii::Vector/
> of /n_active_cells()/ to compute the error indicators of the locally owned
> cells. (This can easily be used in e.g.
> /dealii::parallel::distributed::GridRefinement::
> refine_and_coarsen_fixed_number()/)
> As we want to add an additional criterion based on the minimum and maximum
> error indicator to mark cells, we need the global minimum and maximum value.
> Is there a smart way to get the global minimum based on the minimum of all
> processes of all locally owned cells? Using /std::min_element/ does not care
> about locally owned cells and so the results are wrong.
You can get the local min/max via a loop of the form
double min=std::numeric_limits<double>::max(),
max=std::numeric_limits<double>::smallest(),
for (auto &cell : triangulation.active_cell_iterators())
if (cell->is_locally_owned())
min = std::min (min, vec(cell->active_cell_index()));
...same for max...
and then compute the global min and max via Utilities::min()/max().
Best
W.
--
------------------------------------------------------------------------
Wolfgang Bangerth email:
bang...@colostate.edu
www:
http://www.math.colostate.edu/~bangerth/