Skip to content

Commit

Permalink
Merge #696
Browse files Browse the repository at this point in the history
696: Revert part of #689 r=simonbyrne a=simonbyrne

#689 lost some previous changes in the rebase.

- [X] Code follows the [style guidelines](https://clima.github.io/ClimateMachine.jl/latest/DevDocs/CodeStyle/) OR N/A.
- [X] Unit tests are included OR N/A.
- [X] Code is exercised in an integration test OR N/A.
- [X] Documentation has been added/updated OR N/A.


Co-authored-by: Simon Byrne <[email protected]>
  • Loading branch information
bors[bot] and simonbyrne authored Apr 30, 2022
2 parents edb7718 + 8e420cd commit f9b6194
Show file tree
Hide file tree
Showing 7 changed files with 94 additions and 183 deletions.
10 changes: 10 additions & 0 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,16 @@ steps:
queue: central
slurm_ntasks: 1

- label: ":computer: test implicit_stencil"
key: "cpu_implicit_stencil"
command:
- "julia -O0 --color=yes --check-bounds=yes --project=test test/Operators/finitedifference/implicit_stencils.jl"
- "julia --color=yes --check-bounds=yes --project=test test/Operators/finitedifference/opt_implicit_stencils.jl"
agents:
config: cpu
queue: central
slurm_ntasks: 1

- label: ":flower_playing_cards: unit tests"
key: "gpu_unittests"
command:
Expand Down
37 changes: 4 additions & 33 deletions .github/workflows/Linux-UnitTests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,40 +36,11 @@ jobs:
version: ${{ matrix.julia-version }}

- name: Cache artifacts
uses: actions/cache@v1
env:
cache-name: cache-artifacts
with:
path: ~/.julia/artifacts
key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ hashFiles('**/Project.toml') }}
restore-keys: |
${{ runner.os }}-test-${{ env.cache-name }}-
${{ runner.os }}-test-
${{ runner.os }}-
- name: Install Project Packages
run: |
julia --color=yes --project -e 'using Pkg; Pkg.instantiate()'
julia --color=yes --project -e 'using Pkg; Pkg.precompile(;strict=true)'
julia --color=yes --project -e 'using Pkg; Pkg.status()'
- name: Project Manifest
run: |
julia --color=no --project -e 'using Pkg; Pkg.status(mode=Pkg.PKGMODE_MANIFEST)'
- name: Install Project Test Packages
run: |
julia --color=yes --project=test -e 'using Pkg; Pkg.develop(path=pwd()); Pkg.instantiate()'
julia --color=yes --project=test -e 'using Pkg; Pkg.precompile(;strict=true)'
julia --color=yes --project=test -e 'using Pkg; Pkg.status()'
uses: julia-actions/cache@v1

- name: Project Test Manifest
run: |
julia --color=no --project=test -e 'using Pkg; Pkg.status(mode=Pkg.PKGMODE_MANIFEST)'
- name: Build package
uses: julia-actions/julia-buildpkg@v1

- name: Run Unit Tests
env:
TEST_MODULES: ${{ matrix.test-modules }}
run: |
julia --color=yes --check-bounds=yes --project=test test/runtests.jl
uses: julia-actions/julia-runtest@v1
continue-on-error: ${{ matrix.version == 'nightly' }}
40 changes: 5 additions & 35 deletions .github/workflows/OS-UnitTests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,49 +42,19 @@ jobs:
- 'Manifest.toml'
- name: Set up Julia
uses: julia-actions/setup-julia@latest
uses: julia-actions/setup-julia@v1
if: steps.filter.outputs.run_test == 'true'
with:
version: 1.7

- name: Cache artifacts
uses: actions/cache@v1
uses: julia-actions/cache@v1
if: steps.filter.outputs.run_test == 'true'
env:
cache-name: cache-artifacts
with:
path: ~/.julia/artifacts
key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ hashFiles('**/Project.toml') }}
restore-keys: |
${{ runner.os }}-test-${{ env.cache-name }}-
${{ runner.os }}-test-
${{ runner.os }}-
- name: Install Project Packages
if: steps.filter.outputs.run_test == 'true'
run: |
julia --color=yes --project -e 'using Pkg; Pkg.instantiate()'
julia --color=yes --project -e 'using Pkg; Pkg.precompile(;strict=true)'
julia --color=yes --project -e 'using Pkg; Pkg.status()'
- name: Project Manifest
if: steps.filter.outputs.run_test == 'true'
run: |
julia --color=no --project -e 'using Pkg; Pkg.status(mode=Pkg.PKGMODE_MANIFEST)'
- name: Install Project Test Packages
if: steps.filter.outputs.run_test == 'true'
run: |
julia --color=yes --project=test -e 'using Pkg; Pkg.develop(path=pwd()); Pkg.instantiate()'
julia --color=yes --project=test -e 'using Pkg; Pkg.precompile(;strict=true)'
julia --color=yes --project=test -e 'using Pkg; Pkg.status()'

- name: Project Test Manifest
- name: Build package
uses: julia-actions/julia-buildpkg@v1
if: steps.filter.outputs.run_test == 'true'
run: |
julia --color=no --project=test -e 'using Pkg; Pkg.status(mode=Pkg.PKGMODE_MANIFEST)'

- name: Run Unit Tests
uses: julia-actions/julia-runtest@v1
if: steps.filter.outputs.run_test == 'true'
run: |
julia --color=yes --check-bounds=yes --project=test test/runtests.jl
54 changes: 27 additions & 27 deletions examples/plane/limiters_advection.jl
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,11 @@ const ymin = -2π # domain y lower bound
const ymax = 2π # domain y upper bound
const ρ₀ = 1.0 # air density
const D₄ = 0.0 # hyperdiffusion coefficient
const u0 = π / 2 # angular velocity
const r0 = (xmax - xmin) / 6 # bells radius
const end_time = 2 * pi # simulation period in seconds
const dt = 1e-3
const n_steps = Int(div(end_time, dt))
const end_time = 2π # simulation period in seconds
const dt = end_time / 8000
const n_steps = Int(round(end_time / dt))
const flow_center =
Geometry.XYPoint(xmin + (xmax - xmin) / 2, ymin + (ymax - ymin) / 2)
const bell_centers = [
Expand Down Expand Up @@ -121,16 +122,6 @@ for (k, ne) in enumerate(ne_seq)
coords = Fields.coordinate_field(space)
Δh[k] = (xmax - xmin) / ne

# Initialize simple uniform rotational flow
u = map(coords) do coord
x, y = coord.x, coord.y

u₁ = -(y - flow_center.y)
u₂ = (x - flow_center.x)

Geometry.UVVector(u₁, u₂)
end

# Initialize state
y0 = map(coords) do coord
x, y = coord.x, coord.y
Expand Down Expand Up @@ -184,6 +175,19 @@ for (k, ne) in enumerate(ne_seq)
# Set up operators
grad = Operators.Gradient()
wdiv = Operators.WeakDivergence()
end_time = parameters.end_time

# Define the flow
coords = Fields.coordinate_field(axes(y.ρq))
u = map(coords) do coord
local y
x, y = coord.x, coord.y

uu = -u0 * (y - flow_center.y) * cospi(t / end_time)
uv = u0 * (x - flow_center.x) * cospi(t / end_time)

Geometry.UVVector(uu, uv)
end

# Compute min_Q[] and max_Q[] that will be needed later in the stage limiter
space = parameters.space
Expand Down Expand Up @@ -221,10 +225,9 @@ for (k, ne) in enumerate(ne_seq)
@. ystar.ρq = -D₄ * wdiv(y.ρ * grad(ystar.ρq))

# Add advective flux divergence
@. dy.ρ = beta * dy.ρ - alpha * wdiv(y.ρ * u) # contintuity equation
@. dy.ρ = beta * dy.ρ - alpha * wdiv(y.ρ * u) # contintuity equation
@. dy.ρq = beta * dy.ρq - alpha * wdiv(y.ρq * u) + alpha * ystar.ρq # advection of tracers equation


min_Q = parameters.min_Q
max_Q = parameters.max_Q

Expand All @@ -242,10 +245,10 @@ for (k, ne) in enumerate(ne_seq)
Spaces.weighted_dss!(dy.ρq)
end


# Set up RHS function
ystar = copy(y0)
parameters = (space = space, min_Q = min_Q, max_Q = max_Q)
parameters =
(space = space, min_Q = min_Q, max_Q = max_Q, end_time = end_time)
f!(ystar, y0, parameters, 0.0, dt, 1)

# Solve the ODE
Expand All @@ -265,15 +268,13 @@ for (k, ne) in enumerate(ne_seq)
progress_message = (dt, u, p, t) -> t,
)

L1err[k] =
norm(
(sol.u[end].ρq ./ sol.u[end].ρ .- y0.ρq ./ y0.ρ) ./ (y0.ρq ./ y0.ρ),
1,
) / norm(ones(space), 1)
L2err[k] =
norm(
(sol.u[end].ρq ./ sol.u[end].ρ .- y0.ρq ./ y0.ρ) ./ (y0.ρq ./ y0.ρ),
) / norm(ones(space))
L1err[k] = norm(
(sol.u[end].ρq ./ sol.u[end].ρ .- y0.ρq ./ y0.ρ) ./ (y0.ρq ./ y0.ρ),
1,
)
L2err[k] = norm(
(sol.u[end].ρq ./ sol.u[end].ρ .- y0.ρq ./ y0.ρ) ./ (y0.ρq ./ y0.ρ),
)
Linferr[k] = norm(
(sol.u[end].ρq ./ sol.u[end].ρ .- y0.ρq ./ y0.ρ) ./ (y0.ρq ./ y0.ρ),
Inf,
Expand All @@ -298,7 +299,6 @@ for (k, ne) in enumerate(ne_seq)
)
end


# Print convergence rate info
conv = convergence_rate(L2err, Δh)
@info "Converge rates for this test case are: ", conv
Expand Down
45 changes: 3 additions & 42 deletions src/Fields/Fields.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,7 @@ import ..slab, ..slab_args, ..column, ..column_args, ..level
import ..DataLayouts: DataLayouts, AbstractData, DataStyle
import ..Domains
import ..Topologies
import ..Spaces:
Spaces,
AbstractSpace,
SpectralElementSpace1D,
SpectralElementSpace2D,
ExtrudedFiniteDifferenceSpace
import ..Spaces: Spaces, AbstractSpace
import ..Geometry: Geometry, Cartesian12Vector
import ..Utilities: PlusHalf

Expand Down Expand Up @@ -316,43 +311,9 @@ which reduces to
```
"""
function Spaces.weighted_dss!(
field::Field{V, S},
ghost_buffer = nothing, # added for compatibility
) where {V, S <: SpectralElementSpace1D}
Spaces.weighted_dss!(field_values(field), axes(field))
return field
end

function Spaces.weighted_dss!(
field::Field{V, S},
ghost_buffer = Spaces.create_ghost_buffer(field),
) where {V, S <: SpectralElementSpace2D}
Spaces.weighted_dss!(field_values(field), axes(field), ghost_buffer)
return field
end

function Spaces.weighted_dss!(
field::Field{V, S},
ghost_buffer = nothing, # added for compatibility
) where {
V,
ST,
H <: SpectralElementSpace1D,
S <: ExtrudedFiniteDifferenceSpace{ST, H},
}
Spaces.weighted_dss!(field_values(field), axes(field))
return field
end

function Spaces.weighted_dss!(
field::Field{V, S},
field::Field,
ghost_buffer = Spaces.create_ghost_buffer(field),
) where {
V,
ST,
H <: SpectralElementSpace2D,
S <: ExtrudedFiniteDifferenceSpace{ST, H},
}
)
Spaces.weighted_dss!(field_values(field), axes(field), ghost_buffer)
return field
end
Expand Down
1 change: 0 additions & 1 deletion test/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ BlockArrays = "8e7c35d0-a365-5155-bbbb-fb81a777f24e"
CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba"
ClimaComms = "3a4d1b5c-c61d-41fd-a00a-5873ba7a1b0d"
ClimaCommsMPI = "5f86816e-8b66-43b2-912e-75384f99de49"
ClimaCore = "d414da3d-4745-48bb-8d80-42e94e092884"
Combinatorics = "861a8166-3701-5b0c-9a16-15d98fcdc6aa"
CubedSphere = "7445602f-e544-4518-8976-18f8e8ae6cdb"
DiffEqBase = "2b5f629d-d688-5b77-993f-72d75c75574e"
Expand Down
Loading

2 comments on commit f9b6194

@simonbyrne
Copy link
Member

Choose a reason for hiding this comment

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

@JuliaRegistrator
Copy link

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/59396

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:

git tag -a v0.10.1 -m "<description of version>" f9b61940e81a6fd96e75f21706985e8892b7f312
git push origin v0.10.1

Please sign in to comment.