MCPcopy Create free account
hub / github.com/FEniCS/dolfinx / mark_maximum

Function mark_maximum

cpp/dolfinx/refinement/mark.h:32–57  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

30/// max(marker).
31template <std::floating_point T>
32std::vector<std::int32_t> mark_maximum(std::span<const T> marker, T theta,
33 MPI_Comm comm)
34{
35 if ((theta <= 0) || (theta >= 1))
36 throw std::invalid_argument("Theta needs to fullfill 0 < θ < 1.");
37
38 T max = marker.empty() ? std::numeric_limits<T>::lowest()
39 : std::ranges::max(marker);
40 MPI_Allreduce(MPI_IN_PLACE, &max, 1, dolfinx::MPI::mpi_t<T>, MPI_MAX, comm);
41
42 auto mark = [=](T e) { return e > theta * max; };
43
44 std::vector<std::int32_t> indices;
45 indices.reserve(std::ranges::count_if(marker, mark));
46
47 for (std::int32_t i = 0; i < static_cast<std::int32_t>(marker.size()); ++i)
48 {
49 if (mark(marker[i]))
50 indices.push_back(i);
51 }
52
53 spdlog::info("Marking (max) {} / {} (local) entities.", indices.size(),
54 marker.size());
55
56 return indices;
57}
58
59} // namespace dolfinx::refinement

Callers 1

declare_refinementFunction · 0.85

Calls 1

sizeMethod · 0.45

Tested by

no test coverage detected