Skip to content

Add equidistribution marking#4187

Open
schnellerhase wants to merge 7 commits intomainfrom
schnellerhase/equidistribution-marking
Open

Add equidistribution marking#4187
schnellerhase wants to merge 7 commits intomainfrom
schnellerhase/equidistribution-marking

Conversation

@schnellerhase
Copy link
Copy Markdown
Contributor

@schnellerhase schnellerhase commented Apr 27, 2026

Implements an equidistribution marking criterion for AFEM schemes, i.e. for $\theta \in (0, 1)$ and a marker $\eta \in \mathbb{R}^N$, computes

$$ \mathcal{I} = \left\{ i \ | \ \eta_i > \theta \frac{|\eta|_2}{\sqrt{N}} \right\}. $$

Work towards #4141.

Fixes #3133.

@schnellerhase schnellerhase self-assigned this Apr 27, 2026
@schnellerhase schnellerhase added the enhancement New feature or request label Apr 27, 2026
@schnellerhase schnellerhase force-pushed the schnellerhase/equidistribution-marking branch 2 times, most recently from be3bfe6 to ad9ef0a Compare April 29, 2026 21:20
@schnellerhase schnellerhase changed the base branch from schnellerhase/maximum-marking to main April 29, 2026 21:20
@schnellerhase schnellerhase force-pushed the schnellerhase/equidistribution-marking branch from ad9ef0a to cf5dfc4 Compare April 29, 2026 21:43
@schnellerhase schnellerhase force-pushed the schnellerhase/equidistribution-marking branch from cf5dfc4 to c4a2bdb Compare April 29, 2026 21:46
@schnellerhase schnellerhase marked this pull request as ready for review April 29, 2026 21:47
Comment thread cpp/dolfinx/refinement/mark.h Outdated
Comment thread cpp/dolfinx/refinement/mark.h Outdated
/// @param[in] theta Parameter, 0 < θ < 1
/// @param[in] comm Communicator over which the total marker is computed.
/// @return Indices (local) of marker elements, which satisfy: marker_i ≥ θ
/// (sum_i marker_i^2)^1/2 / N^1/2.
Copy link
Copy Markdown
Member

@jhale jhale Apr 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please correct me if I'm wrong, but there is probably no need to do so many square root operations - assuming markers/indicators and theta are always positive, you can square both sides:

marker_i^2 ≥ θ^2 (sum_i marker_i^2) / N.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's true but we would sacrifice the shared code path of mark_threshold. Since it's 2x sqrt's not critical?

Copy link
Copy Markdown
Member

@jhale jhale Apr 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really - in the vast majority of cases I'm familiar with, one naturally assembles the square of the entity estimator, so your approach effectively requires the user to do many square roots outside this function.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See e.g. https://doi.org/10.1016/j.camwa.2022.11.009 eq A.1, A.4, 3.15 (which should really be squared on both sides).

count = comm.allreduce(marker.size)
assert np.allclose(
marked_cells,
np.argwhere(marker > theta * norm / np.sqrt(count)).flatten(),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If my square-rootless version is correct, still keep this alternative version as-is in the test.

Comment thread cpp/dolfinx/refinement/mark.h Outdated
spdlog::info("Marking (max) {} / {} (local) entities.", indices.size(),
/// @brief Equidistribution marking of a marker.
///
/// @param[in] marker Input marker (local) - usually an error indicator per
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The terminology is non-standard. Marker is normally denoted eta and called an error indicator per entity.

Furthermore, and see my comment below, it is usually most efficient to take eta_i^2 - this often saves a square root in user code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Parallel marking algorithm

2 participants