Skip to content

Commit

Permalink
Add ConformalCubedSphere grid via MultiRegion module (#2867)
Browse files Browse the repository at this point in the history
* show methods

* get_grid_name

* fix typo in CubedSpherePartition

* get_grid_name

* remove CubedSpheres module

* fix tests

* use MultiRegion to load cs32 grid; move test to test_multi_region_cubed_sphere.jl

* add functionality to load MultiRegion ConformalCubedSphere from file

* let go of CubedSpheres module

* let go of CubedSpheres module

* better show for OrthogonalSphericalShellGrid

* some code cleanup

* drop OldConformalCubedSphereGrid

* drop warning from OrthogonalSphericalShellGrid

* add connectivity information in docstring

* add warning

* better docstring

* add example for how to find connectivities

* only support equal x-y CubedSpherePartitions

* add data dependencies + cleanup

* cleanup

* docstring for CubedSpherePartition

* some cleanup

* add util functions

* nuke duplicate method

* add getindex(::MultiRegionGrid, i)

* add CubedSphereField + export

* end with newline

* adds return nothing to avoid ambiguity

* add missing comma

* minor cleanup

* adds utilities for coordinate transformations on sphere

* extend vertices methods to work with all locations

* add validation + plotting example

* some code cleanup

* fix docstrings

* fix docstring

* convert arrays to proper array type

* arch -> architecture

* allow OrthogonalSphericalShellGrid to have stretched z

* simplify

* add ConformalCubedSphereGrid alias

* add cubed_sphere_field.jl

* better allignment

* add Δzᵃᵃᶜ, Δzᵃᵃᶠ to OSSG from file

* alignment

* define alias ZRegOrthogonalSphericalShellGrid

* fix Δz spacings for OSSG

* adapt Δz

* reduce parameter pressure in fill_halo

* fill flipped halos

* pcg for csg

* add with_halos

* total_size

* pass panel topology

* make domain aware of the topology

* apply regionally

* with_halo returns grid

* updates

* add ==

* cleanup CubedSphereConnectivity + inner constructor + docstring

* minor cleanup and code alignment

* drop Suppresson

* create grid metrics BUT without halos

* Completely overhaul grid utils

* no fallback for total_length

* no empty line

* fix OSSG tests

* OSSG respect their topology + cleaner construction

* fixes and cleanup

* use add_halo utility

* more robust add_halos + more examples

* better show for OSSG

* cleaner inner constructors

* updates

* central_angle -> Distances.spherical_angle

* delete stray s

* cleaner Δx, Δy using haversine

* add Distances

* generalize coordinate transform utils

* remove CubedSphere module

* it solVes :)

* don't instantiate

* change tabs to spaces

* minor cleanup

* remove spaces

* add return nothing

* introduce Connectivity

* update ubedSphereConnectivity syntax in doctest

* add getproperty methods

* refactor CubedSphereConnectivity

* Oceananigans.Architecture -> Oceananigans.Architectures

* validate panel index function

* allowscalar for grid equality

* add back center_str

* fix show(io, ::OSSG)

* Update src/Solvers/preconditioned_conjugate_gradient_solver.jl

Co-authored-by: Simone Silvestri <[email protected]>

* better docs

* more args passing around for PCG

* fix doctests

* keep the decimal

* fill coordinates halos for cubedspheregrid

* fix bugs

* some cleanup

* don't allow different halo size in horizontal or different topology

* don't allow different halo size in horizontal or different topology

* don't allow different halo size in horizontal or different topology

* add clarification

* resolve conflicts

* add Distances

* fix show

* quick fix

* alignment

* fix bug

* alignment

* minor cleanup

* alignment

* alignment

* refactor connectivity

* resolve another conflict

* remove spaces

* code formatting

* add neighbors

* use λ/φnodes

* allowscalars

* cleanup compact_data!

* better doc

* code alignment

* cleanup, return nothings, fix docs

* NonTrivialConnectivity -> NonTrivialCubedSphereConnectivity

* fix mistake when filling both east-west or north-south halos for MCBC

* enhance ConformalCubedSphere docstring

* upgrade test to check for proper orientation of halos

* fix doctest

* cleanup

* fix single halo filling methods

* Added unit tests to check u and v halos

(a) Added unit tests to verify if the halos for the zonal (u) and meridional (v)
    velocity fields defined at the fcc and cfc locations on each of the 6
    single-layer orthogonal spherical shell grids (panels) constituting a
    conformal cubed sphere grid (with 1 region in each panel) have been filled
    out correctly.

(b) As expected, all 48 unit tests for u and v on the 4 sides of each of the 6
    panels failed, since the halos for these fields have not yet been specified.

* first implementation of u, v fill halos

* simply tests

* add methods for correcting halo filling for u, v

* needs grid

* begins->begin

* use halo filling trick for grid

* Added a multi-region tracer advection test case

It is not working, most probably due to an error associated with
PrescribedVelocityFields on the conformal cubed sphere grid.

* fixed gpu problem

* small bugfix

* gpu friendlieness

* Created tracer advection animation on cubed sphere

(a) Renamed the script multi_region_cubedsphere.jl to
    multi_region_cubed_sphere.jl;
(b) Wrapped the testing of the heatsphere! and heatlatlon! plotting
    functions of multi_region_cubed_sphere.jl into a function;
(c) Imported the function heatsphere! from multi_region_cubed_sphere.jl to
    multi_region_tracer_advection.jl to create an animation of the tracer
    advection on the cubed sphere;
(d) Wrapped the testing of the multi region tracer advection of
    multi_region_tracer_advection.jl into a function;
(e) Since the velocities are still zero, the tracer does not advect yet.

* fix some tests + replace_velocity_halo!

* bugfix

* fix fallback method name

* bugfix

* resolve w julia v1.8.5

* merge main

* unmodulify

* some updates

* don't inline figs

* add inbounds

* Modified halo checks to consider index shift

(a) In the process of completing the u and v halos, it is crucial to consider
    not only the potential exchange of the u and v values and the reversal of
    their signs, but also the possibility of an offset in their indices by one.
    This commit addresses the latter scenario, an aspect that was not factored
    into the halo checks previously.

(b) iOutside the tests, an error is encountered while accessing an array element
    with index out of bounds, which will be fixed in a later commit.

* remove stray spaces

* cleaner

* metaprogrammed metric halo filling, but still not right for fc, cf

* add signed kwarg

* Fixed keyword argument error

* Condensed functions

(a) Consolidated the functions get_halo_data, get_halo_data_subset, and
    get_halo_data_endpoint into two streamlined functions: get_range_of_indices
    and get_halo_data. This modification enhances the organization of the
    test/test_multi_region_cubed_sphere.jl script.

(b) Created a new function get_boundary_indices to retrieve boundary indices,
    their endpoints, or subsets excluding one endpoint.

* code alignment

* some fixes

* use default CubedSpherePartition

* add connectivity in partition

* Redefined plotting functions

(a) Enclosed the testing of the multi-region plotting functions within a
    function;

(b) Redefined these plotting functions to be applied regionally to prevent
    prefixing calls to these functions with @apply_regionally;

(c) Replaced looping over the regions at some places with @apply_regionally.

* Removed print statement

* Switched panel to initialize tracer advection

(a) Initialized the conformal cubed sphere tracer advection test case with a
    Gaussian bump centered at (the center of) panel 5 facing the viewer in a
    GeoMakie animation;

(b) Customized the above-mentioned Gaussian function.

* Increased the range of Gaussian initial condition

* add connectivity property in MultiRegionGrid

* Tracer advects along the equator of cubed sphere!

* fix doctest

* clean up show methods

* minor reorganization

* add rotation in connectivity

* Prescribed zonal velocity = cosine of latitude

* Enhanced configuration of the initial condition

* compute derivative of CubedSphereField

* fixed computation on multiregion fields

* another try in filling velocities

* Fixed rotation direction

Corrected rotation direction from counterclockwise (↺) to clockwise (↻) for
find_west_connectivity if from_side is North().

* velocity halo filliing tests pass on a grid with 1 halo point

* velocity halo filliing tests pass on a grid with ANY halo points

* bit of cleanup

* Modified prescribed velocity for tracer advection

* trying to advect a tracer

* fill halos for coordinates

* bit of cleanup + only 2 halo fillings are required

* more cleanup

* add connectivity for X/YPartition

* simplify

* remove test-related packages

* cleanup

* Update validation/multi_region/multi_region_tracer_advection.jl

Co-authored-by: Gregory L. Wagner <[email protected]>

* Minor modifications

* Update src/AbstractOperations/kernel_function_operation.jl

Co-authored-by: Simone Silvestri <[email protected]>

* fill halos for metrics + fix Azffa bug in OSSG

* 2 fill halos are enough

* split tests

* add test for total Az area

* not working for R>1

* fix typo

* resolve

* fixed location(a, dim)

* Halos still not filled everywhere for face fields

* Modified  multi_region_cubed_sphere.jl script

* fill velocity halos

* Update src/Models/HydrostaticFreeSurfaceModels/update_hydrostatic_free_surface_model_state.jl

Co-authored-by: Simone Silvestri <[email protected]>

* replace_horizontal_velocity_halos! only for FullyConnected OSSG

* some allowscalars + 3 halo fillings

* convert doctests to examples

* fix doctests

* gpu friendly

* Delete proposal.jl

* Delete multi_region_cubed_sphere_derivatives.jl

* Delete multi_region_tracer_advection.jl

---------

Co-authored-by: simone-silvestri <[email protected]>
Co-authored-by: Gregory Wagner <[email protected]>
Co-authored-by: Simone Silvestri <[email protected]>
Co-authored-by: Sid <[email protected]>
  • Loading branch information
5 people authored Jul 27, 2023
1 parent fcfdb25 commit 2447ea7
Show file tree
Hide file tree
Showing 83 changed files with 3,296 additions and 3,844 deletions.
2 changes: 1 addition & 1 deletion .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ steps:
architecture: CPU
depends_on: "init_cpu"

- label: "🦾 cpu distributed sovers tests"
- label: "🦾 cpu distributed solvers tests"
env:
JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER"
TEST_GROUP: "distributed_solvers"
Expand Down
14 changes: 13 additions & 1 deletion Manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

julia_version = "1.9.2"
manifest_format = "2.0"
project_hash = "9044a5920a57a78e707ac7490810d9c46b9bc546"
project_hash = "ea620612cb5f84093b962d4345aa7d1b1271739c"

[[deps.AbstractFFTs]]
deps = ["LinearAlgebra"]
Expand Down Expand Up @@ -157,6 +157,12 @@ version = "1.0.0"
deps = ["Printf"]
uuid = "ade2ca70-3891-5945-98fb-dc099432e06a"

[[deps.Distances]]
deps = ["LinearAlgebra", "SparseArrays", "Statistics", "StatsAPI"]
git-tree-sha1 = "49eba9ad9f7ead780bfb7ee319f962c811c6d3b2"
uuid = "b4f34e82-e78d-54a5-968a-f98e89d6e8f7"
version = "0.10.8"

[[deps.Distributed]]
deps = ["Random", "Serialization", "Sockets"]
uuid = "8ba89e20-285c-5b6f-9357-94700520ee1b"
Expand Down Expand Up @@ -676,6 +682,12 @@ deps = ["LinearAlgebra", "SparseArrays"]
uuid = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
version = "1.9.0"

[[deps.StatsAPI]]
deps = ["LinearAlgebra"]
git-tree-sha1 = "45a7769a04a3cf80da1c1c7c60caf932e6f4c9f7"
uuid = "82ae8749-77ed-4fe6-ae5f-f523153014b0"
version = "1.6.0"

[[deps.Strided]]
deps = ["LinearAlgebra", "StridedViews", "TupleTools"]
git-tree-sha1 = "b32eadf6ac726a790567fdc872b63117712e16a8"
Expand Down
2 changes: 2 additions & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba"
Crayons = "a8cc5b0e-0ffa-5ad4-8c14-923d3ee1735f"
CubedSphere = "7445602f-e544-4518-8976-18f8e8ae6cdb"
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
Distances = "b4f34e82-e78d-54a5-968a-f98e89d6e8f7"
DocStringExtensions = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae"
FFTW = "7a1cc6ca-52ef-59f5-83cd-3a7055c09341"
Glob = "c27321d9-0574-5035-807b-f59d2c89b15c"
Expand Down Expand Up @@ -39,6 +40,7 @@ Adapt = "3"
CUDA = "4"
Crayons = "4"
CubedSphere = "0.1, 0.2"
Distances = "0.10"
DocStringExtensions = "0.8, 0.9"
FFTW = "1"
Glob = "1.3"
Expand Down
40 changes: 22 additions & 18 deletions docs/Manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -271,9 +271,9 @@ version = "0.9.3"

[[deps.Documenter]]
deps = ["ANSIColoredPrinters", "Base64", "Dates", "DocStringExtensions", "IOCapture", "InteractiveUtils", "JSON", "LibGit2", "Logging", "Markdown", "REPL", "Test", "Unicode"]
git-tree-sha1 = "58fea7c536acd71f3eef6be3b21c0df5f3df88fd"
git-tree-sha1 = "39fd748a73dce4c05a9655475e437170d8fb1b67"
uuid = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
version = "0.27.24"
version = "0.27.25"

[[deps.DocumenterCitations]]
deps = ["Bibliography", "DataStructures", "Documenter", "Markdown", "Unicode"]
Expand Down Expand Up @@ -355,9 +355,9 @@ uuid = "7b1f6079-737a-58dc-b8bc-7a2ca5c1b5ee"

[[deps.FillArrays]]
deps = ["LinearAlgebra", "Random", "SparseArrays", "Statistics"]
git-tree-sha1 = "0b3b52afd0f87b0a3f5ada0466352d125c9db458"
git-tree-sha1 = "2250347838b28a108d1967663cba57bfb3c02a58"
uuid = "1a297f60-69ca-5386-bcde-b61e274b549b"
version = "1.2.1"
version = "1.3.0"

[[deps.FixedPointNumbers]]
deps = ["Statistics"]
Expand Down Expand Up @@ -876,9 +876,9 @@ version = "0.5.4"

[[deps.OffsetArrays]]
deps = ["Adapt"]
git-tree-sha1 = "82d7c9e310fe55aa54996e6f7f94674e2a38fcb4"
git-tree-sha1 = "2ac17d29c523ce1cd38e27785a7d23024853a4bb"
uuid = "6fe1bfb0-de20-5000-8ca7-80f57d26f881"
version = "1.12.9"
version = "1.12.10"

[[deps.Ogg_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
Expand Down Expand Up @@ -1232,10 +1232,14 @@ uuid = "cae243ae-269e-4f55-b966-ac2d0dc13c15"
version = "0.1.1"

[[deps.StaticArrays]]
deps = ["LinearAlgebra", "Random", "StaticArraysCore", "Statistics"]
git-tree-sha1 = "832afbae2a45b4ae7e831f86965469a24d1d8a83"
deps = ["LinearAlgebra", "Random", "StaticArraysCore"]
git-tree-sha1 = "0da7e6b70d1bb40b1ace3b576da9ea2992f76318"
uuid = "90137ffa-7385-5640-81b9-e52037218182"
version = "1.5.26"
version = "1.6.0"
weakdeps = ["Statistics"]

[deps.StaticArrays.extensions]
StaticArraysStatisticsExt = "Statistics"

[[deps.StaticArraysCore]]
git-tree-sha1 = "6b7ba252635a5eff6a0b0664a41ee140a1c9e72a"
Expand Down Expand Up @@ -1397,16 +1401,16 @@ uuid = "aed1982a-8fda-507f-9586-7b0439959a61"
version = "1.1.34+0"

[[deps.Xorg_libX11_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg", "Xorg_libxcb_jll", "Xorg_xtrans_jll"]
git-tree-sha1 = "5be649d550f3f4b95308bf0183b82e2582876527"
deps = ["Artifacts", "JLLWrappers", "Libdl", "Xorg_libxcb_jll", "Xorg_xtrans_jll"]
git-tree-sha1 = "afead5aba5aa507ad5a3bf01f58f82c8d1403495"
uuid = "4f6342f7-b3d2-589e-9d20-edeb45f2b2bc"
version = "1.6.9+4"
version = "1.8.6+0"

[[deps.Xorg_libXau_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
git-tree-sha1 = "4e490d5c960c314f33885790ed410ff3a94ce67e"
deps = ["Artifacts", "JLLWrappers", "Libdl"]
git-tree-sha1 = "6035850dcc70518ca32f012e46015b9beeda49d8"
uuid = "0c0b7dd1-d40b-584c-a123-a41640f87eec"
version = "1.0.9+4"
version = "1.0.11+0"

[[deps.Xorg_libXdmcp_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl"]
Expand All @@ -1433,10 +1437,10 @@ uuid = "14d82f49-176c-5ed1-bb49-ad3f5cbd8c74"
version = "0.1.1+0"

[[deps.Xorg_libxcb_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg", "XSLT_jll", "Xorg_libXau_jll", "Xorg_libXdmcp_jll", "Xorg_libpthread_stubs_jll"]
git-tree-sha1 = "daf17f441228e7a3833846cd048892861cff16d6"
deps = ["Artifacts", "JLLWrappers", "Libdl", "XSLT_jll", "Xorg_libXau_jll", "Xorg_libXdmcp_jll", "Xorg_libpthread_stubs_jll"]
git-tree-sha1 = "b4bfde5d5b652e22b9c790ad00af08b6d042b97d"
uuid = "c7cfdc94-dc32-55de-ac96-5a1b8d977c5b"
version = "1.13.0+3"
version = "1.15.0+0"

[[deps.Xorg_xtrans_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl"]
Expand Down
90 changes: 55 additions & 35 deletions src/AbstractOperations/at.jl
Original file line number Diff line number Diff line change
Expand Up @@ -58,52 +58,72 @@ indices(f::Function) = default_indices(3)
indices(f::Number) = default_indices(3)

"""
interpolate_indices(operands..., loc_operation = abstract_operation_location)
intersect_indices(loc, operands...)
Utility to propagate operands' indices in `AbstractOperations`s with multiple operands
(`BinaryOperation`s and `MultiaryOperation`s).
Utility to compute the intersection of `operands' indices.
"""
function interpolate_indices(args...; loc_operation = (Center, Center, Center))
idxs = Any[:, :, :]
for i in 1:3
for arg in args
idxs[i] = interpolate_index(indices(arg)[i], idxs[i], location(arg)[i], loc_operation[i])
end
end
function intersect_indices(loc, operands...)

return Tuple(idxs)
idx1 = compute_index_intersection(Colon(), loc[1], operands...; dim=1)
idx2 = compute_index_intersection(Colon(), loc[2], operands...; dim=2)
idx3 = compute_index_intersection(Colon(), loc[3], operands...; dim=3)

return (idx1, idx2, idx3)
end

interpolate_index(::Colon, ::Colon, args...) = Colon()
interpolate_index(::Colon, b::UnitRange, args...) = b

instantiate(T::Type) = T()
instantiate(t) = t
# Fallback for `KernelFunctionOperation`s with no argument
compute_index_intersection(::Colon, to_loc; kw...) = Colon()

function interpolate_index(a::UnitRange, ::Colon, loc, new_loc)
a = corrected_index(a, instantiate(loc), instantiate(new_loc))
compute_index_intersection(to_idx, to_loc, op; dim) =
_compute_index_intersection(to_idx, indices(op)[dim],
to_loc, location(op, dim))

# Abstract operations that require an interpolation of a sliced fields are not supported!
first(a) > last(a) && throw(ArgumentError("Cannot interpolate a sliced field from $loc to $(new_loc)!"))
return a
"""Compute index intersection recursively for `dim`ension ∈ (1, 2, 3)."""
function compute_index_intersection(to_idx, to_loc, op1, op2, more_ops...; dim)
new_to_idx = _compute_index_intersection(to_idx, indices(op1)[dim], to_loc, location(op1, dim))
return compute_index_intersection(new_to_idx, to_loc, op2, more_ops...; dim)
end

function interpolate_index(a::UnitRange, b::UnitRange, loc, new_loc)
a = corrected_index(a, instantiate(loc), instantiate(new_loc))
# Life is pretty simple in this case.
_compute_index_intersection(to_idx::Colon, from_idx::Colon, args...) = Colon()

# Because `from_idx` imposes no restrictions, we just return `to_idx`.
_compute_index_intersection(to_idx::UnitRange, from_idx::Colon, args...) = to_idx

# Abstract operations that require an interpolation of a sliced fields are not supported!
first(a) > last(a) && throw(ArgumentError("Cannot interpolate a sliced field from $loc to $(new_loc)!"))
# This time we account for the possible range-reducing effect of interpolation on `from_idx`.
function _compute_index_intersection(to_idx::Colon, from_idx::UnitRange, to_loc, from_loc)
shifted_idx = restrict_index_for_interpolation(from_idx, from_loc, to_loc)
validate_shifted_index(shifted_idx)
return shifted_idx
end

# Compute the intersection of two index ranges
function _compute_index_intersection(to_idx::UnitRange, from_idx::UnitRange, to_loc, from_loc)
shifted_idx = restrict_index_for_interpolation(from_idx, from_loc, to_loc)
validate_shifted_index(shifted_idx)

indices = UnitRange(max(first(a), first(b)), min(last(a), last(b)))
range_intersection = UnitRange(max(first(shifted_idx), first(to_idx)), min(last(shifted_idx), last(to_idx)))

# Abstract operations between parallel non-intersecating windowed fields are not supported
first(indices) > last(indices) && throw(ArgumentError("BinaryOperation operand indices $(a) and $(b) do not intersect!"))
return indices
# Check validity of the intersection index range
first(range_intersection) > last(range_intersection) &&
throw(ArgumentError("Indices $(from_idx) and $(to_idx) interpolated from $(from_loc) to $(to_loc) do not intersect!"))

return range_intersection
end

# Windowed fields interpolated from `Center`s to `Face`s lose the first index.
# Viceverse, windowed fields interpolated from `Face`s to `Center`s lose the last index
corrected_index(a, ::Face, ::Face) = UnitRange(first(a), last(a) )
corrected_index(a, ::Center, ::Center) = UnitRange(first(a), last(a) )
corrected_index(a, ::Face, ::Center) = UnitRange(first(a), last(a)-1)
corrected_index(a, ::Center, ::Face) = UnitRange(first(a)+1, last(a) )
validate_shifted_index(shifted_idx) = first(shifted_idx) > last(shifted_idx) &&
throw(ArgumentError("Cannot compute index intersection for indices $(from_idx) interpolating from $(from_loc) to $(to_loc)!"))

"""
restrict_index_for_interpolation(from_idx, from_loc, to_loc)
Return a "restricted" index range for the result of interpolating from
`from_loc` to `to_loc`, over the index range `from_idx`:
* Windowed fields interpolated from `Center`s to `Face`s lose the first index.
* Conversely, windowed fields interpolated from `Face`s to `Center`s lose the last index
"""
restrict_index_for_interpolation(from_idx, ::Type{Face}, ::Type{Face}) = UnitRange(first(from_idx), last(from_idx))
restrict_index_for_interpolation(from_idx, ::Type{Center}, ::Type{Center}) = UnitRange(first(from_idx), last(from_idx))
restrict_index_for_interpolation(from_idx, ::Type{Face}, ::Type{Center}) = UnitRange(first(from_idx), last(from_idx)-1)
restrict_index_for_interpolation(from_idx, ::Type{Center}, ::Type{Face}) = UnitRange(first(from_idx)+1, last(from_idx))
2 changes: 1 addition & 1 deletion src/AbstractOperations/binary_operations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ end
# Recompute location of binary operation
@inline at(loc, β::BinaryOperation) = β.op(loc, at(loc, β.a), at(loc, β.b))

indices::BinaryOperation) = interpolate_indices.a, β.b; loc_operation = location(β))
indices::BinaryOperation) = construct_regionally(intersect_indices, location(β), β.a, β.b)

"""Create a binary operation for `op` acting on `a` and `b` at `Lc`, where
`a` and `b` have location `La` and `Lb`."""
Expand Down
4 changes: 2 additions & 2 deletions src/AbstractOperations/computed_field.jl
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ function Field(operand::AbstractOperation;
loc = location(operand)
indices = validate_indices(indices, loc, grid)

boundary_conditions = FieldBoundaryConditions(indices, boundary_conditions)
@apply_regionally boundary_conditions = FieldBoundaryConditions(indices, boundary_conditions)

if isnothing(data)
data = new_data(grid, loc, indices)
Expand All @@ -63,7 +63,7 @@ Compute `comp.operand` and store the result in `comp.data`.
"""
function compute!(comp::ComputedField, time=nothing)
# First compute `dependencies`:
@apply_regionally compute_at!(comp.operand, time)
compute_at!(comp.operand, time)

# Now perform the primary computation
@apply_regionally compute_computed_field!(comp)
Expand Down
8 changes: 4 additions & 4 deletions src/AbstractOperations/conditional_operations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ struct ConditionalOperation{LX, LY, LZ, O, F, G, C, M, T} <: AbstractOperation{L
condition :: C
mask :: M

function ConditionalOperation{LX, LY, LZ}(operand::O, func::F, grid::G, condition::C, mask::M) where {LX, LY, LZ, O, F, G, C, M}
T = eltype(operand)
return new{LX, LY, LZ, O, F, G, C, M, T}(operand, func, grid, condition, mask)
end
function ConditionalOperation{LX, LY, LZ}(operand::O, func::F, grid::G, condition::C, mask::M) where {LX, LY, LZ, O, F, G, C, M}
T = eltype(operand)
return new{LX, LY, LZ, O, F, G, C, M, T}(operand, func, grid, condition, mask)
end
end

"""
Expand Down
2 changes: 1 addition & 1 deletion src/AbstractOperations/kernel_function_operation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ struct KernelFunctionOperation{LX, LY, LZ, G, T, K, D} <: AbstractOperation{LX,
end

@inline Base.getindex::KernelFunctionOperation, i, j, k) = κ.kernel_function(i, j, k, κ.grid, κ.arguments...)
indices::KernelFunctionOperation) = interpolate_indices.arguments...; loc_operation = location(κ))
indices::KernelFunctionOperation) = construct_regionally(intersect_indices, location(κ), κ.arguments...)
compute_at!::KernelFunctionOperation, time) = Tuple(compute_at!(d, time) for d in κ.arguments)

"Adapt `KernelFunctionOperation` to work on the GPU via CUDAnative and CUDAdrv."
Expand Down
2 changes: 1 addition & 1 deletion src/AbstractOperations/multiary_operations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ end
##### MultiaryOperation construction
#####

indices::MultiaryOperation) = interpolate_indices.args...; loc_operation = location(Π))
indices::MultiaryOperation) = construct_regionally(intersect_indices, location(Π), Π.args...)

function _multiary_operation(L, op, args, Largs, grid)
= Tuple(interpolation_operator(La, L) for La in Largs)
Expand Down
2 changes: 1 addition & 1 deletion src/Advection/weno_interpolants.jl
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ julia> calc_weno_stencil(2, :right, :x)
dir == :y ?
:(@inbounds ψ(i, j + $c, k, args...)) :
:(@inbounds ψ(i, j, k + $c, args...))
else
else
stencil_point[idx] = dir == :x ?
:(@inbounds ψ[i + $c, j, k]) :
dir == :y ?
Expand Down
4 changes: 2 additions & 2 deletions src/BoundaryConditions/boundary_condition.jl
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ const OBC = BoundaryCondition{<:Open}
const VBC = BoundaryCondition{<:Value}
const GBC = BoundaryCondition{<:Gradient}
const ZFBC = BoundaryCondition{Flux, Nothing} # "zero" flux
const MCBC = BoundaryCondition{<:MultiRegionCommunication}
const DCBC = BoundaryCondition{<:DistributedCommunication}
const MCBC = BoundaryCondition{<:MultiRegionCommunication}
const DCBC = BoundaryCondition{<:DistributedCommunication}

# More readable BC constructors for the public API.
PeriodicBoundaryCondition() = BoundaryCondition(Periodic, nothing)
Expand Down
Loading

0 comments on commit 2447ea7

Please sign in to comment.