Skip to content

2D and 3D gradients and divergences and potential vortex example#28

Open
rouson wants to merge 27 commits into
BerkeleyLab:mainfrom
rouson:scalar-2D-3D-gradient
Open

2D and 3D gradients and divergences and potential vortex example#28
rouson wants to merge 27 commits into
BerkeleyLab:mainfrom
rouson:scalar-2D-3D-gradient

Conversation

@rouson
Copy link
Copy Markdown
Contributor

@rouson rouson commented May 18, 2026

This PR adds

  • Public 2D and 3D scalar, vector, gradient, and divergence types with

    • Abstract interfaces for initialization:
      • scalar_1D_initializer_i
      • vector_1D_initializer_i
      • divergence_1D_initializer_i
    • Type-bound operators:
      • .grad. for 2D and 3D scalars
      • .div. for 2D and 3D vectors
    • Generic bindings:
      • to_file, grid, and values for 2D and 3D scalars, vectors, and divergences
      • gradients inherit the above bindings from their parent vectors.
  • Passing unit tests for

    • 2D and 3D gradients of a scalar field
    • 2D and 3D divergences of a vector field
  • An example program demonstrating

    • A 2D scalar function that defines a potential vortex and
    • The gradient of that function that defines a velocity vector field.
  • Gnuplot scripts that plot

    • 2D scalar fields as surfaces
    • 2D vector fields as arrows
  • New constructors for 1D, 2D, and 3D scalar, vector, and divergence fields.

rouson added 20 commits May 19, 2026 20:26
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.
@bonachea bonachea force-pushed the scalar-2D-3D-gradient branch from 5ec9ce8 to f3cc871 Compare May 20, 2026 03:27
@rouson rouson changed the title 2D and 3D gradients and potential vortex example 2D and 3D gradients and divergences and potential vortex example May 26, 2026
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