Skip to content

2D advection/diffusion equation solver#39

Open
rouson wants to merge 47 commits into
BerkeleyLab:mainfrom
rouson:2D-advection-diffusion
Open

2D advection/diffusion equation solver#39
rouson wants to merge 47 commits into
BerkeleyLab:mainfrom
rouson:2D-advection-diffusion

Conversation

@rouson

@rouson rouson commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

No description provided.

rouson added 30 commits July 5, 2026 17:27
This commit
1. Adds an operator(.dot.) generic binding to vector_2D_t
2. Makes the interpolator_1D_t child type constructors
   elemental to support the .dot. procedure definition.
3. Appends "_extended" to the interpolator_1D_t's center_values
   type-bound procedure name to better describe the result.
This commit adds a work-in-progress example of
a 2D advection/diffusion equation solver along
with the supporting infrastructure.
This commit fixes an issue with storing data on staggered grids,
wherein the number and layout of the points across the
spatial domain varies depending on the type of information.

The commit
1. Refactors the tensor_2D_t type, replacing its 6D values_ array
   component with a 4D points_2D_t array component containing a
   2D values_ array component.
2. Adjusts the tensor_2D_m module and the corresponding submodules
   accordingly.
3. Defines a new scalar_product_2D_t type to store, for example,
   the dot product of two vector_2D_t objects.  Dot products
   produce values at cell centers only, which necessitates a
   different storage format from that of scalar_2D_t objects.
   The latter also stores boundary values.
4. Refactors divergence_2D_t so it extends scalar_product_2D_t.

What works
----------
`fpm build --compiler flang --profile release`

To Do
-----
Fix `fpm test ...`
import the required Julienne operators and fix an operand name
This commit fixes the manifest to list Julienne under [dependencies]
rather than [dev-dependencies] to ensure Julienne builds with
`fpm build` too rather than only  with `fpm test`.  This is required
because the Formal library uses Julienne features, including
assertions, types, and format strings.
This commit replaces the 2D potential-flow vortex example with
a 2D potential-flow stagnation-point example.  The change fixes an
that corrupted the vortex results near the y axes, presumably due
to the singularity at the origin.  The stagnation-point flow
field has no singularities and the numerical result closely
matches the sampled analytical gradient of the corresponding scalar
potential.
This commit improves the plotting of vector fields saved by the
2D-stagnation-point example program.  Now all vectors are
normalized to the same length.  Vector magnitudes remain color-
coded.  This change addresses an issue that made plots difficult
to interpret because many vectors were being scaled such that they
overlapped with several neighboring vectors.
This commit finishes fixing dot (scalar) products of 2D vectors,
including replacing vector_2D_at_cell_centers with
vector_2D_co_located_components.  This commit ensures that both
2D vector components are available at all points required for
computing a scalar result, including corner values.
This commit fixes the 2D vector-field gnuplot script.  Previous
version of the script processed the header incorrectly, leading to
one stray vector, an incorrect title, and incorrect axis labels.
Replace component names with single vector name:

"vector_x, vector_y" -> "vector"
rouson added 14 commits July 5, 2026 17:27
This commit renames scalar_product_2D_t to divergence_2D_t and
removes the previous divergence_2D_t, which trivially extended
scalar_product_2D_t.
This commit finishes defining the operators required for expressing
the two-dimensional (2D) advection/diffusion equation:

    ds_dt = .div. (D * .grad. s) - (v .dot. .grad. s)

where

* D is a constant, double-precision molecular diffusion coefficient
* s is a scalar_2D_t advected/diffused scalar field
* v is a vector_2D_t prescribed advection velocity field
* ds_dt is the time derivative of s
* .div. is the divergence operator
* .grad. is the gradient operator
* .dot. is the dot-product operator
This commit finishes defining the operators required for expressing
the Runge-Kutta time advancement schemes such as explicit Euler:

    s = s + dt * d_dt(s, v)

where

* dt is a constant, double-precision time step
* s is a scalar_2D_t advected/diffused scalar field
* v is a vector_2D_t prescribed advection velocity field
* d_dt(s, v) is the time derivative of s for a given v
This commit removes all files that support 3D data structures and
algorithms.  The 3D code will need a redesign analogous to the
recent redesign of the 2D code.  That process will likly be most
natural and straightforward if the 2D files are copied and
modified for 3D.
@rouson rouson force-pushed the 2D-advection-diffusion branch from 4bb3fdd to 614c0eb Compare July 6, 2026 17:42
@rouson rouson force-pushed the 2D-advection-diffusion branch from 614c0eb to f32e10f Compare July 6, 2026 17:47
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