Skip to content

MOLE.jl: New Grids module - #411

Open
valeriabarra wants to merge 3 commits into
mainfrom
valeria/mole-jl-grids-module
Open

MOLE.jl: New Grids module#411
valeriabarra wants to merge 3 commits into
mainfrom
valeria/mole-jl-grids-module

Conversation

@valeriabarra

Copy link
Copy Markdown
Collaborator

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

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

Description

This PR adds a Grids module for the MOLE.jl Julia implementation. This contains new functions, tests, and documentation. A follow-up PR will be created to make the Operators compatible (and retro-compatible) with the new Grid module.

Related Issues & Documents

Added/updated tests?

_We encourage you to test all code included with MOLE, including examples.

  • 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

@valeriabarra valeriabarra self-assigned this Jul 2, 2026
@valeriabarra valeriabarra added Enhancement New feature or request MOLE.jl MOLE-2.0 Ideas and issues relating to the MOLE 2.0 development branch and or update. labels Jul 2, 2026
@codecov

codecov Bot commented Jul 2, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.70815% with 10 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
julia/MOLE.jl/src/Grids/validate_grid.jl 94.31% 10 Missing ⚠️

📢 Thoughts on this report? Let us know!

@valeriabarra
valeriabarra requested a review from joehellmers July 2, 2026 21:16
@valeriabarra
valeriabarra force-pushed the valeria/mole-jl-grids-module branch from 9dcc97f to f8a2ae9 Compare July 7, 2026 16:59
@valeriabarra

Copy link
Copy Markdown
Collaborator Author

@Tony-Drummond and @joehellmers , can you still review this PR? Thank you

@valeriabarra
valeriabarra force-pushed the valeria/mole-jl-grids-module branch 2 times, most recently from 6261599 to 6da444b Compare July 22, 2026 16:30
@valeriabarra
valeriabarra force-pushed the valeria/mole-jl-grids-module branch from 6da444b to 22319dc Compare August 4, 2026 16:25
@valeriabarra

Copy link
Copy Markdown
Collaborator Author

@joehellmers , @Tony-Drummond , are you still able to review this PR?
The Julia formatter action that is failing is a fluke. Locally for me the formatter passes. Thanks

@github-actions

Copy link
Copy Markdown

This pull request has had no activity for 14 days. It will be marked stale in 14 days if there is no further activity.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a Julia Grids module for constructing and validating computational grids.

Changes:

  • Adds grid types, coordinate generation, validation, and constructors.
  • Supports uniform grids, boundary metadata, and 2D curvilinear grids.
  • Adds documentation and automated tests.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
docs/src/index.md Documents the Grids API.
src/MOLE.jl Loads the new module.
src/Grids/Grids.jl Defines module exports and includes.
src/Grids/coordinates.jl Generates grid coordinates.
src/Grids/make_grid.jl Adds grid constructors.
src/Grids/topologies.jl Defines grid data structures.
src/Grids/validate_grid.jl Implements validation and normalization.
test/runtests.jl Registers grid tests.
test/Grids/make_grid.jl Tests grid construction.
test/Grids/validate_grid.jl Tests validation and edge cases.
Suppressed comments (3)

julia/MOLE.jl/src/Grids/validate_grid.jl:257

  • The 2D partial fallback drops all valid supplied values (m, n, and any available spacing or boundary data), leaving only dim and topology. Preserve and validate the fields that are present so the returned object can actually be completed incrementally.
    return Grid{Float64}(dim = 2, topology = topology)

julia/MOLE.jl/src/Grids/validate_grid.jl:314

  • The 3D partial fallback discards m, n, o, and any supplied spacing or boundary values. A partial grid should retain and validate its present fields rather than returning an empty shell, otherwise subsequent makeGrid(grid) calls cannot recover the user's definition.
    return Grid{Float64}(dim = 3, topology = topology)

julia/MOLE.jl/src/Grids/validate_grid.jl:209

  • If either m or n is absent, this partial-grid branch calls the parametric Grid{T} constructor without a type-bearing value from which T can be inferred. Thus validateGrid(Dict(:dim=>2, :topology=>:curvilinear); allowPartial=true) throws instead of returning a partial grid. Specify an element type here (consistent with the other partial branches), while separately retaining any supplied fields.
        return Grid(dim = 2, topology = :curvilinear)

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

end

dim = get(raw, :dim, _infer_dim(raw))
topology = Symbol(get(raw, :topology, _infer_topology(raw)))

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you. Explicit topology values are now validated and carried through the complete normalization paths. An explicit :periodic topology is preserved and, when no boundary coefficients are supplied, marks all coordinate directions periodic. Explicit topology values that conflict with supplied boundary metadata now raise an ArgumentError, and unsupported symbols are rejected even for partial grids. Regression tests cover these cases.

Comment on lines +145 to +146
elseif any(haskey(raw, k) for k in (:x, :y, :z))
return :nonuniform
)
end

return Grid{Float64}(dim = 1, topology = topology)
Comment on lines +205 to +207
if topology == :curvilinear
if haskey(raw, :m) && haskey(raw, :n)
return _normalize_curvilinear_2d(raw, bc_raw)
end

faces, centers = _coordinates_curvilinear_2d(nodes)
bc = _normalize_bc(bc_raw, 4)
function _validate_positive_spacing(value, name)
value = float(value)

if value <= 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Enhancement New feature or request MOLE.jl MOLE-2.0 Ideas and issues relating to the MOLE 2.0 development branch and or update.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MOLE.jl: Add new Grids module

2 participants