-
Notifications
You must be signed in to change notification settings - Fork 190
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Broadcasting for AbstractField, AbstractReducedField, and AbstractOpe…
…rations (#1596) * Changes fourth type parameter of AbstractField to architecture * Adds architecture property to all fields * Updates set! for new AbstractField type parameters * Update constructor for AveragedField * Adds architecture property to BuoyancyField * Fixes cpudata * set! for GPU fields is identitcal for arrays and functions * Technical debt *sigh* * Subtype abstract array * Refactors AbstractField infrastructure to subtype AbstractArray * Implements copyto! for in-place broadcasting to dest::AbstractField * Remove spurious setindex! for Field * Adds back manual reduction functions (hopefully we can get rid of these eventually) * Only reduce fields backed by concrete data * Adds 2d, 1d, and 0d Cartesian indexing for ReducedFields, and more flexible broadcast_2d! kernel * Expand definitions of Base.similar for AbstractField and AbstractReducedField * Dont copy boundary conditions in similar * Removes calls to parent() in conjugate gradient iteration * Dont test that similar fields have the same boundary conditions * Cleans up AveragedField test for different Float types * Fields take eltype from grid * Fixes typo in KernelComputedField constructor * Update fill_halo_regions dispatch now that Field<:AbstractArray * Move fill_halo_regions for fields to AbstractField * Adds some rudimentary broadcasting test for Fields * Dont convert arrays to tuples * Cleans up KernelComputedField * Adds show method for kernelComputedField * Better docstring for Field * Fixes bug in test for broadcasting with ReducedField * Simplifies KernelComputedField tests * Different kernels for different 2d configurations * Converts broadcasted to abstract operations where appropriate * Needed eval after all * AbstractOperations lists are symbols? * Disambiguate distributed Field constructor * Get AbstractGrid into Distributed * Provide rules for broadcasting Fields with Arrays * Import missing functions and types from Base.Broadcast * Adds a new function at(loc, op) for changing the location of AbstractOperations * Its not a derivative _operation_..." * Attempts to insert logic to insert locations into broadcasted field expressions * Refactors AbstractOperations to be more broadly useful in broadcasting * Improvements to braodcasting field operations * Fixes bug in broadcasting test for ReducedField * Dont use BroadcastStyle just yet until we can get it working * Defines linear indexing and fill! for fields * Redefine checkbounds for AbstractField * Starts implementing new checkbounds pending appropriate parentaxes function for fields * BuoyancyField is backed by data * Banishes parent() from preconditioned_conjugate_gradient_solver * Import AbstractDataField into Buoyancy * Specifies fill_halo_regions to OffsetArray for distributed models * More general location inference for binary operations * Add identity to list of unary operators * Adds additional type parameter to zero field * Revert "Adds additional type parameter to zero field" This reverts commit 1a77150. * Dont restrict i, j, k to integer * Field getindex over data getindex * Introduces "stubborn" binary operations * Converts Broadcasted to AbstractOperations when destination is a field * Cleans up doc strings and adapt_structure for AbstractOperations * Fix some scoping issues with interpolation wrapper for at macro * Move interpolate_operation definition to at.jl * No need to throw errors for operations at Nothing location * Computations with AveragedField might work? * Adds incremental build up of AveragedField operations testing * Dont interpolate unecessarily * Bugfix in abstract operations tests * Cleans up merge issues in AbstractOperations * Use custom binary op function for getindex * No more test skip in abstrsct operations tests! * Holy typo * Fix merge-added typo; * Move broadcasting tests to simulation group * Add new test group for abstract operations and broadcasting * Updates testset description to include broadcasting * Fixes superfluous include(at.jl) * Infer whether broadcast requires interpolation or not * More broadcasting tests including for interpolation * Creates new binary operator functions to help type inference * Broadcasting shenanigans * Fixes bugs in broadcasting tests * Finds BroadcastStyle name * Defines fallback for interpolate_operation * Polish off interpolation for broadcasting * Updates broadcasting tests * Field takes eltype from grid * Test a few unaries but not all * interpolate_identity is officially a unary * Test explicit set of unaries * Update unary_operations.jl * Update kelvin_helmholtz_instability.jl * Removes wrong comments * Bump version * No need for needs_interpolation
- Loading branch information
Showing
39 changed files
with
611 additions
and
315 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
src/AbstractOperations/broadcasting_abstract_operations.jl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import Oceananigans.Fields: broadcasted_to_abstract_operation | ||
|
||
using Base.Broadcast: Broadcasted | ||
using Base: identity | ||
|
||
const BroadcastedIdentity = Broadcasted{<:Any, <:Any, typeof(identity), <:Any} | ||
|
||
broadcasted_to_abstract_operation(loc, grid, bc::BroadcastedIdentity) = | ||
interpolate_operation(loc, Tuple(broadcasted_to_abstract_operation(loc, grid, a) for a in bc.args)...) | ||
|
||
broadcasted_to_abstract_operation(loc, grid, op::AbstractOperation) = at(loc, op) | ||
|
||
function broadcasted_to_abstract_operation(loc, grid, bc::Broadcasted{<:Any, <:Any, <:Any, <:Any}) | ||
abstract_op = bc.f(loc, Tuple(broadcasted_to_abstract_operation(loc, grid, a) for a in bc.args)...) | ||
return interpolate_operation(loc, abstract_op) # For "stubborn" BinaryOperations | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
dd1f949
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JuliaRegistrator register
dd1f949
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Registration pull request created: JuliaRegistries/General/34911
After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.
This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via: