Skip to content

Add a cell-centered finite volume example on polygonal meshes - #4592

Merged
lindsayad merged 3 commits into
libMesh:develfrom
lindsayad:finite-volume-example
Oct 16, 2026
Merged

lindsayad merged 3 commits into
libMesh:develfrom
lindsayad:finite-volume-example

Conversation

@lindsayad

Copy link
Copy Markdown
Member

Adds examples/finite_volume/finite_volume_ex1, the first example in a new finite_volume category. It solves steady advection-diffusion with a cell-centered finite volume method (CONSTANT MONOMIAL) on a build_square(C0POLYGON) mesh, and reports the centroid-sampled L2 error under uniform refinement for a manufactured solution.

Least-squares cell gradients provide a non-orthogonal correction to the two-point diffusive flux and a linear reconstruction for second-order upwind advection. Face fluxes therefore reach the face neighbors of both adjacent cells, so the example sets DofMap::default_coupling() to two layers before building the mesh, which also keeps the needed ghost elements on a distributed mesh. The observed convergence rate is 2, and errors match across serial, parallel, and --distributed-mesh runs.

🤖 Generated with Claude Code

@roystgnr roystgnr left a comment

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.

Going to add some more recipes to be safe, but at first glance this looks good.

libMesh::out << "Grid size " << grid_size << ": " << mesh.n_active_elem()
<< " cells, centroid L2 error " << error;
if (level)
libMesh::out << ", convergence rate " << std::log2(previous_error / error);

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.

Could we add some asserts here? Even something weak enough to be robust under different Real precisions can be useful for catching future errors.

@moosebuild

moosebuild commented Oct 7, 2026 •

Copy link
Copy Markdown

Job Coverage, step Generate coverage on de17003 wanted to post the following:

Coverage

No coverage report(s) were found for the base commit ab2aa4d.
Full coverage report

This comment will be updated on new commits.

lindsayad and others added 3 commits October 15, 2026 14:30
finite_volume_ex1 solves a steady advection-diffusion problem with a
CONSTANT MONOMIAL variable on the C0Polygon paving produced by
build_square(C0POLYGON), and reports second-order convergence of the
centroid-sampled error for a manufactured solution.

Least-squares cell gradients supply a non-orthogonal correction to the
two-point diffusive flux, which the slanted hexagon faces require for
consistency, and a linear reconstruction for second-order upwind
advection. Each face flux then depends on the face neighbors of both
adjacent cells, so the example sets DofMap::default_coupling() to two
layers before building the mesh. This also gives the geometric ghosting
a distributed mesh needs, and the example produces the same errors
with replicated and distributed meshes in serial and parallel.

The example starts a new finite_volume example category.

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
…pected

Co-Authored-By: Claude <noreply@anthropic.com>
@lindsayad
lindsayad force-pushed the finite-volume-example branch from 4aefc6e to de17003 Compare October 15, 2026 22:14
@lindsayad
lindsayad merged commit 9e5b0b8 into libMesh:devel Oct 16, 2026
26 of 30 checks passed
@lindsayad
lindsayad deleted the finite-volume-example branch October 16, 2026 17:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants