Skip to content

New models in sumfem.models.dg - #33

Open
jorgensd wants to merge 2 commits into
mainfrom
dokken/extend-dg-models-with-more-least-square-penalty
Open

jorgensd wants to merge 2 commits into
mainfrom
dokken/extend-dg-models-with-more-least-square-penalty

Conversation

@jorgensd

@jorgensd jorgensd commented Dec 1, 2026 •

Copy link
Copy Markdown
Member

New models

Generic

Model What it adds Why
InteriorFlux $\sum_F \int_F \hat{F}\, [\![w]\!] \,\mathrm{d}s$ for a given flux $\hat{F}$ through the interior facets One place for the pairing of a numerical flux with the test function. The DG fluxes below only build $\hat{F}$.
BoundaryMisfit (in models/boundary.py) $\frac{1}{2} \int_\Gamma w\, e \cdot e \,\mathrm{d}s$ for a misfit $e$ and a weight $w$ A condition $e = 0$ on the boundary, held in the least-squares sense. Not specific to DG.
NormalVelocityJump $\sum_F \int_F [\![\boldsymbol{\beta}]\!] \cdot \mathbf{n}\, \lbrace u\, w \rbrace \,\mathrm{d}s$ The facet part of the divergence of a discontinuous discrete velocity, e.g. $-K/\mu\, \nabla p_h$ of a P1 pressure
DivergenceCorrection The sum of a Source of $u\, \nabla \cdot \boldsymbol{\beta}$ and NormalVelocityJump Removes the source that a discrete flow with $\nabla \cdot \boldsymbol{\beta}_h \neq 0$ adds to the conservative upwind form. Without it, a uniform concentration piles up where a Taylor–Hood or Darcy flow converges. The DG half-cell needs it because its migration drift must stay conservative.

Boundary terms of piecewise constants

Model What it adds Why
TwoPointDirichlet (a BoundaryFlux) Inflow $q = -\frac{\kappa}{\delta_K} (u - g)$ The boundary value, split out of TwoPointFlux. A closed boundary leaves it out.
NonOrthogonalDirichletCorrection (a BoundaryFlux) Inflow $q = \kappa\, \mathbf{k}_\Gamma \cdot \mathbf{G}$ The boundary half of NonOrthogonalCorrection
LeastSquaresDirichletMisfit (a BoundaryMisfit) $e = \mathbf{G}_K \cdot (\mathbf{x} - \mathbf{c}_K) - (g - u_K)$, $w = 1 / (\lvert \mathbf{x} - \mathbf{c}_K \rvert^2 \lvert F \rvert)$ The boundary half of LeastSquaresMisfit
LeastSquaresNeumannMisfit (a BoundaryMisfit) $e = \mathbf{n} \cdot \mathbf{G}_K$, $w = 1 / \lvert F \rvert$ Without it, a cell in a wall corner can lack neighbours in enough directions, which leaves $\mathbf{G}_K$ undetermined (the half-cell's walls and outlet)

The correction removes

$$ s(u, w) = \sum_K \int_K u, \nabla \cdot \boldsymbol{\beta}, w ,\mathrm{d}x - \sum_F \int_F [![\boldsymbol{\beta}]!] \cdot \mathbf{n}, \lbrace u, w \rbrace ,\mathrm{d}s, $$

the difference between the conservative and the convective upwind forms, found by summation by parts.

Changed (breaking)

  • TwoPointFlux, NonOrthogonalCorrection and LeastSquaresMisfit now hold only the interior-facet terms. Their boundary arguments (value, markers) moved to the boundary models above.
  • TwoPointFlux, UpwindFlux and NonOrthogonalCorrection are subclasses of InteriorFlux, and InflowBoundary is a subclass of BoundaryFlux. Their forms are unchanged.
  • Terms pair with the test function through ufl.inner, and the misfits square as $\mathrm{inner}(e, e)$, the sumfem convention. The forms are unchanged in real mode.

Tests

  • The two-point comparison against plain UFL sums all six DG0 pieces.
  • The least-squares gradient of $u = x$ is $(1, 0)$ in every cell when the walls are fitted.
  • Conservative form + DivergenceCorrection equals the convective form for a constant, a diverging and a piecewise-constant velocity.

| Model | What it adds | Why |
|---|---|---|
| `TwoPointDirichlet` | The two-point flux from a cell's centroid to a boundary value, $`\sum_{F \subset \Gamma} \int_F \frac{\kappa}{\delta_K} (u - g)\, w \,\mathrm{d}s`$ | Split out of `TwoPointFlux`, so a boundary value is its own model, as `NitscheDirichlet` is for `WeightedInteriorPenalty`. A closed boundary leaves it out. |
| `NonOrthogonalDirichletCorrection` | The non-orthogonal correction on boundary facets with a value, $`-\sum_{F \subset \Gamma} \int_F \kappa\, \mathbf{k}_\Gamma \cdot \mathbf{G}\, w \,\mathrm{d}s`$ | The boundary half of `NonOrthogonalCorrection`, needed only where `TwoPointDirichlet` is |
| `LeastSquaresDirichletMisfit` | The fit of the cell gradient $`\mathbf{G}_K`$ to the boundary value $`g`$ at the facet point $`\mathbf{x}`$ | The boundary half of `LeastSquaresMisfit` |
| `LeastSquaresNeumannMisfit` | The fit of $`\mathbf{n} \cdot \mathbf{G} = 0`$ on walls, $`\sum_{F \subset \Gamma_N} \frac{1}{2} (\mathbf{n} \cdot \mathbf{G}_K)^2`$ | Without it, a cell in a wall corner can lack neighbours in enough directions, which leaves $`\mathbf{G}_K`$ undetermined (the half-cell's walls and outlet) |
| `NormalVelocityJump` | $`j(u, w) = \sum_F \int_F [\![\boldsymbol{\beta}]\!] \cdot \mathbf{n}\, \lbrace u\, w \rbrace \,\mathrm{d}s`$ | The facet part of the divergence of a discontinuous discrete velocity, e.g. $`-K/\mu\, \nabla p_h`$ of a P1 pressure, whose divergence inside each cell is zero |
| `DivergenceCorrection` | The sum of a `Source` of $`u\, \nabla \cdot \boldsymbol{\beta}`$ and `NormalVelocityJump` | Removes the source that a discrete flow with $`\nabla \cdot \boldsymbol{\beta}_h \neq 0`$ adds to the conservative upwind form. Without it, a uniform concentration piles up where a Taylor–Hood or Darcy flow converges. With it, the conservative form equals the convective one for any velocity. The DG half-cell needs this because its migration drift must stay conservative. |

The correction removes

$$
s(u, w) = \sum_K \int_K u\, \nabla \cdot \boldsymbol{\beta}\, w \,\mathrm{d}x - \sum_F \int_F [\![\boldsymbol{\beta}]\!] \cdot \mathbf{n}\, \lbrace u\, w \rbrace \,\mathrm{d}s,
$$

the difference between the conservative and the convective upwind forms, found by summation by parts.

## Changed (breaking)

- `TwoPointFlux`, `NonOrthogonalCorrection` and `LeastSquaresMisfit` now hold only the interior-facet terms. Their boundary arguments (`value`, `markers`) moved to the Dirichlet models above, so that each model is one term.
- Terms pair with the test function through `ufl.inner`, and the misfits square as $`\mathrm{inner}(e, e)`$, the sumfem convention. The forms are unchanged in real mode.

## Tests

- The two-point comparison against plain UFL sums all six DG0 pieces.
- The least-squares gradient of $`u = x`$ is $`(1, 0)`$ in every cell when the walls are fitted.
- Conservative form + `DivergenceCorrection` equals the convective form for a constant, a diverging and a piecewise-constant velocity.

This branch has not been deployed

No deployments
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.

1 participant