Skip to content

Features: 2D/3D types, operators, output, examples, & plotting scripts#32

Merged
rouson merged 36 commits into
BerkeleyLab:mainfrom
rouson:develop
Jun 1, 2026
Merged

Features: 2D/3D types, operators, output, examples, & plotting scripts#32
rouson merged 36 commits into
BerkeleyLab:mainfrom
rouson:develop

Conversation

@rouson

@rouson rouson commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

This pull request

  • Adds and tests types, type-bound operators, and constructors:
    • Public types: scalar_2D_t, vector_2D_t, scalar_3D_t, vector_3D_t
      gradient_2D_t, gradient_3Dt, divergence_2D_t, divergence_3D_t
    • Private types: tensors_2D_t, tensors_3D_t, gradient_2Dt
    • Multiplication for double-precision-value and devergence_2D operands
    • Operators .div. for vector_2D_t and vector_3D_tand .grad.for
      scalar_2D_t and vector_3D_t
    • An addition operator(+) for scalar_1D operands
    • Constructors for a constant vector_1D_t
    • Grid-location calculatorsn the new 2D and 3D types
    • Makes differential operator constructors elemental to support 2D and 3D types
    • Type-bound to_file functions that generate comma-separated value (CSV) files
    • Gnuplot scripts that plot 2D scalar fields as surfaces and 2D vector fields as arrows.
  • Aggregates consistency & conformability checks for scalar_1D_t, tensor_2D_t, scalar_2D_t, vector_2D_t, gradient_2D_t, and divergence_2D_t where
    • The tensor_2D_t functions are private and are inherited/used by the other listed types
    • Each of the other types has consistent and conformable generic bindings
    • Consistency functions assert that
      • The corresponding values_ component is allocated
      • The remaining components are consistent in size with the spatial dimension and consistent in value with each other, e.g., that the number of cells is sufficient for the order of accuracy.
  • Invokes the new consistency and conformability functions throughout the submodules
    {tensor,scalar,vector,gradient,divergence}_2D_s, where these invocations check pre- and/or post-conditions for each module procedure.
  • Handles chores:
    • Remove --separate-compilation with lfortran in CI testing
    • Update lfortran version to latest in the README.md file
    • Remove unused variables
    • Remove gfortran workarounds
    • Add .DS_Store file(s) and a scratch subdirectory to .gitignore
  • Fixes
    • Make tensors_1D_m module procedure cell_centers_1D public
  • Adds example programs and coresponding gnuplot scripts that plot program results
    • A 2D potential-flow sink
    • A 2D potential-flow vortex
    • Scalar- and vector-field gnuplot scripts

rouson and others added 30 commits May 31, 2026 20:59
This commit hoists the 1D scalar grid locations calculator up from
scalar_1D_s to tensors_1D_m, renames it from "scalar_1D_grid_locations"
to "cell_centers_extended_1D", and makes it public in anticipation of
wider use in multidimensional calculations.
This commit hoists the 1D vector grid locations calculator up from
vector_1D_s to tensors_1D_m, renames it from "faces" to "faces_1D",
and makes it public in anticipation of wider use in multidimensional
calculations.
The commit contains the first passing test of a 2D differential
operator: .grad. correctly computes a gradient_2D_t when given
a scalar_2D_t operand.
This commit increases the rank of the tensor_2D_t values_ component
to facilitate storing tensors of rank up to and including rank 4.
This commit tests the .grad. operator with a scalar_2D_t defined
as the biquadratic function

  z = 1 - 2*x + 3*x**2 - x*y/5 + 3*y**2 - 2*y

which has the gradient

  g = [-2 + 6*x - y/5, -x/5 + 6*y - 2]

on the domain cells=[30,20], x_min=[-1D0,1D0], x_max=[9D0,4D0].
This commit adds
1. A scalar_2D_t "to_file" type-bound procedure that creates a
   Juliennne file_t object containing points for a surface plot,
2. An scalar-surface example that creates a scalar and saves it
   to example/scripts/scalar-surface.csv, and
3. A scalar-surface.gnuplot script that plots the surface and
   saves it to scalar-surface.gif.
This commit adds
1. A vector_1D constructor for constant vector fields and
2. A vector_2D grid calculator.
This commit
1. Adds public scalar_3D_t and vector_3D_t types and a supporting
   private tensors_3D_t type and
2. A passing unit test for the gradient of a 3D scalar field.
This commit
1. Updates the scalar-surface plot example to also output files
   that can be used to plot the gradient of the surface,
2. Redefines the surface so that it corresponds to a velocity
   potential defining an irrotational vortex,
3. Adds a script that plots the resulting velocity vield and the
   expected velocity field.
This commit gathers a pattern of scalar_1D_t operand conformability
assertions into one function and calls that function where
applicable.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
rouson added 6 commits May 31, 2026 20:59
This commit adds type-bound consistency- and conformability-
checking functions to the following types:

- tensor_2D_t
- scalar_2D_t
- vector_2D_t
- gradient_2D_t
- divergence_2D_t

where the tensor_2D_t functions are private and are inherited and
used by the other listed types and where each of the other types
has `consistent` and `conformable` generic bindings.  Consistency
functions assert that the values_ component is allocated and that
the remaining components are consistent in size with the spatial
dimension and consistent in value with each other, e.g., that the
number of cells is sufficient for the order of accuracy.

Calls to the new functions are distributed throughout the
{tensor,scalar,vector,gradient,divergence}_2D_s submodules as
effective pre- and/or post-conditions for each module procedure.
@rouson rouson changed the title Features: 2D and 3D gradients and divergences and examples Features: 2D/3D operators, output, plotting scripts, & examples Jun 1, 2026
@rouson rouson changed the title Features: 2D/3D operators, output, plotting scripts, & examples Features: 2D/3D operators, output, plotting, & examples Jun 1, 2026
@rouson rouson changed the title Features: 2D/3D operators, output, plotting, & examples Features: 2D/3D types, operators, output, examples, & plotting scripts Jun 1, 2026
@rouson rouson merged commit d3f8c5a into BerkeleyLab:main Jun 1, 2026
10 of 13 checks passed
@rouson rouson deleted the develop branch June 1, 2026 05:37
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