Skip to content

Conversation

@rouson
Copy link

@rouson rouson commented Jan 2, 2026

What type of PR is this? (check all applicable)

  • Refactor
  • Feature
  • Bug Fix
  • Optimization
  • Example
  • Documentation

Description

This PR

  1. Adds 2nd- and 4th-order 1D mimetic quadrature schemes supporting the calculation of each of the three terms in the Extended Gauss Divergence Theorem (EGDT):
associate(dV => f%dV, dA => v%dA())
  residual = .SSS. (v .dot. .grad. f)*dV + .SSS. (f * .div. v)*dV - .SS. (f .x. (v .dot. dA))
end associate

where .SS. and .SSS. represent double and triple integrals over the problem domain and its bounding surface, respectively, where the residual vanishes in exact representation; and where other operators perform the like-named operations.
2. Adds unit tests verifying the accuracy and convergence of the added quadratures,
3. Adds an example demonstrating the evaluation of the EGDT residual.
4. Works around bugs in the Intel ifx, GNU gfortran, and LLVM flang compilers.
5. Adds new types to the UML class diagram in doc/fortran-classes.md.

Related Issues & Documents

N.A.

QA Instructions, Screenshots, Recordings

fpm test --compiler flang-new --flag "-DASSERTIONS" 
fpm run --example extended-gauss-divergence --compiler flang-new --flag "-DASSERTIONS"
fpm run --example div-grad-laplacian-1D --compiler flang-new --flag "-DASSERTIONS"
fpm run --example print-assembled-1D-operators --compiler flang-new --flag "-DASSERTIONS"

or see src/fortran/README.md corresponding fpm commands with other compilers.

Added/updated tests?

  • Yes
  • No, and this is why: please replace this line with details on why tests
    have not been included
  • I need help with writing tests

Read Contributing Guide and Code of Conduct

[optional] What gif best describes this PR or how it makes you feel?

🐈‍⬛

rouson added 7 commits January 1, 2026 22:06
This commit adopts a newer version of the Julienne dependency
for a fix in reporting test execution times when compiling with
LLVM flang.
Given properly initialized `vector_1D_t v` and `scalar_1D_t f` objects,
this commit adds types, type-bound functions, and operators supporting
the evaluation of the following residual formed from the extended
Gauss Divergence Theorem of Castillo & Miranda (2013):

```fortran
  associate(dV => f%dV, dA => v%dA())
    residual = .SSS. (v .dot. .grad. f)*dV + .SSS. (f * .div. v)*dV - .SS. (f .x. (v .dot. dA))
  end associate
```
where `.SS.` and `.SSS.` represent double and triple integrals over the problem domain
and its bounding surface, respectively.

feat(tensors_1D_t): add dV, dA calculators

This commit

1. Adds a dV generic binding to tensor_1D_t for computing
   differential volumes for volume integration.  In 1D,
   volume integrals are calculated on a per-unit-of-normal-
   surface-area basis so dV = dx*dy*dz = dx(1)(1).
2. Adds a dA procedure binding to vector_1D_t for computing
   surface-area differentials for surface integrals involving
   the dot product of a vector with a surface-normal. In 1D,
   surface integrals are calculated on a per-unit-of-normal-
   surface basis so dA = dy*dz = 1.

build(ifx): work around ifx bugs

1. Symptom: crashing surface-integral unit test at grid resolutions
   above ~413 points. Fix: when ifx is detected, reduce grid points
   to 400 and slightly increase the error tolerance.
2. Symptom: test hangs if the `gradient_1D_t` type has a `weights`
   generic binding associated with the grandparent `tensor_1D_t`
   type's `gradient_1D_weights` binding.  Fix: when ifx is detected,
   move the generic binding up to the parent `vector_1D_t` type.

build(gfortran): work around gfortran issues

1. To eliminate gfortran 13-14 internal compiler errors on Ubuntu in CI,
   replace two `weights` generic binding invocations with invocations of
   the corresponding type-bound functions: `gradient_1D_weights` and
   `divergence_1D_weights`.
2. To work around missing featuers in gfortran 13-14, remove do-concurrent
   type-specs and locality specifiers when gfortran is detected.
The tests exhibit the following numerical integration behaviors:

1. At 500-cell resolution,
   a. 2nd-order quadrature converges quadratically: O(dx^2),
   b. 4th-order quadrature converges linearly: O(dx), and
   c. 4th-order quadrature yields maximum absolute errors roughly,
      three orders of magnitude smaller than the 2nd-order scheme.
2. At even just a 20-cell resolution, 2nd- and 4th-order schemes
   satisfy the discrete Extended Gauss Divergence Theorem down to
   a residual near machine zero: ~10^-14.

This commit adds passing tests that check the 1D equivalents of
the following three integral terms in the extended Gauss divergence
theorem using 2nd & 4th-order mimetic quadratures.

refact(tensors_1D): absorb child procs

This commit moves the gradient_1D_weights and divergence_1D_weights
type-bound procedures up to the parent tensor_1D_t type, making
these procedures accessible via any tensor_1D_t child type. This
facilitates assembly of the B boundary matrix required for
inner products corresponding to surface integrals of the form

   .SS. (v*f) = <Bv,f>

for a vector_1D_t v and a scalar_1D_t f.  Previously, the weights
functions were bound to the gradient_1D_t and divergence_1D_t
types and were thus inaccessible in a calculation not involving
those types.  Now the multiplication operator above can query its
operands for the weights and use them to consturct B via

   B = QD + (G^T)*P, Eq. (6) of Corbino & Castillo (2020)
This commit adds optional arguments that can be used to print only
specific terms in the extended Gauss Divergence Theorem example.
The default behavior is still that all terms are computed, printed,
and summed to produce a residual.

   Usage:
     fpm run \
     --example extended-gauss-divergence \
     --compiler flang-new \
     --flag "-O3" \
     -- [--help|-h] | [[--cells <integer>] [--order <integer>] [--xmin <double precision>] [--xmax <double precision>] [--div|d] [--grad|g] [--vf|f]]

    where pipes (|) separate square-bracketed optional arguments and angular brackets indicate user input values.

fix(integral): .SSS. (f * .div. v)*dV

This commit zero-extends divergence_1D_t values when computing
f * .div. v to match the array sizes of the operands.

feat(example): increase resolution, fmt output, work around gfortran bug

This commit edits print-assembled-1D-operators.F90 to

1. Raise the grid resolution above the new minimum of 16 as
   required for computing the gradient quadrature weights
   when constructing a `gradient_1D_t` object and
2. Adds a `stop` statement to work arounnd an apparent
   gfortran bug: a malloc error.

This commit edits div-grad-laplacian-1D.F90 to

1. Raise the grid resolution above the new minimum of 16 for
   as reqiured for computing the quadrature weights (which are not
   used in this program) when defining a `gradient_1D_t` object and
2. Improve the program output format.

doc(example): Gauss divergence theorem AI prompt
This commit adds optional arguments that can be used to print only
specific terms in the extended Gauss Divergence Theorem example.
The default behavior is still that all terms are computed, printed,
and summed to produce a residual.

   Usage:
     fpm run \
     --example extended-gauss-divergence \
     --compiler flang-new \
     --flag "-O3" \
     -- [--help|-h] | [[--cells <integer>] [--order <integer>] [--xmin <double precision>] [--xmax <double precision>] [--div|d] [--grad|g] [--vf|f]]

    where pipes (|) separate square-bracketed optional arguments and angular brackets indicate user input values.

fix(integral): .SSS. (f * .div. v)*dV

This commit zero-extends divergence_1D_t values when computing
f * .div. v to match the array sizes of the operands.

feat(example): increase resolution, fmt output, work around gfortran bug

This commit edits print-assembled-1D-operators.F90 to

1. Raise the grid resolution above the new minimum of 16 as
   required for computing the gradient quadrature weights
   when constructing a `gradient_1D_t` object and
2. Adds a `stop` statement to work arounnd an apparent
   gfortran bug: a malloc error.

This commit edits div-grad-laplacian-1D.F90 to

1. Raise the grid resolution above the new minimum of 16 for
   as reqiured for computing the quadrature weights (which are not
   used in this program) when defining a `gradient_1D_t` object and
2. Improve the program output format.

doc(example): Gauss divergence theorem AI prompt
@rouson
Copy link
Author

rouson commented Jan 3, 2026

@joehellmers this is ready for review. I don't have the ability designate you as a reviewer.

@jbrzensk please resend the invitation to collaborate on this repository. I just tried to accept the previous invitation, but I think it has expired.

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