@@ -360,100 +360,100 @@ end
360360# ---
361361
362362# +++ Known-value function tests
363- # function test_uniform_strain_flow(grid; model_type=NonhydrostaticModel, closure=ScalarDiffusivity(ν=1), α=1)
364- # model = model_type(; grid, closure)
365- # u₀(x, y, z) = +α*x
366- # v₀(x, y, z) = -α*y
367- # set!(model, u=u₀, v=v₀, w=0, enforce_incompressibility=false)
368-
369- # u, v, w = model.velocities
370-
371- # @compute ε = Field(KineticEnergyDissipationRate(model))
372- # @compute S = Field(StrainRateTensorModulus(model))
373- # @compute Ω = Field(VorticityTensorModulus(model))
374- # @compute q = Field(QVelocityGradientTensorInvariant(model))
375-
376- # idxs = (model.grid.Nx÷2, model.grid.Ny÷2, model.grid.Nz÷2) # Get a value far from boundaries
377-
378- # if model.closure isa Tuple
379- # @compute ν_field = Field(sum(viscosity(model.closure, model.diffusivity_fields)))
380- # else
381- # ν_field = viscosity(model.closure, model.diffusivity_fields)
382- # end
383-
384- # CUDA.@allowscalar begin
385- # ν = ν_field isa Number ? ν_field : getindex(ν_field, idxs...)
386-
387- # @test getindex(S, idxs...) ≈ √2*α
388- # @test getindex(Ω, idxs...) ≈ 0
389- # @test getindex(q, idxs...) ≈ (getindex(Ω, idxs...)^2 - getindex(S, idxs...)^2)/2 ≈ -α^2
390- # @test getindex(ε, idxs...) ≈ 2 * ν * getindex(S, idxs...)^2
391- # end
392-
393- # return nothing
394- # end
395-
396- # function test_solid_body_rotation_flow(grid; model_type=NonhydrostaticModel, closure=ScalarDiffusivity(ν=1), ζ=1)
397- # model = model_type(; grid, closure)
398- # u₀(x, y, z) = +ζ*y / 2
399- # v₀(x, y, z) = -ζ*x / 2
400- # set!(model, u=u₀, v=v₀, w=0, enforce_incompressibility=false)
401-
402- # u, v, w = model.velocities
403-
404- # @compute ε = Field(KineticEnergyDissipationRate(model))
405- # @compute S = Field(StrainRateTensorModulus(model))
406- # @compute Ω = Field(VorticityTensorModulus(model))
407- # @compute q = Field(QVelocityGradientTensorInvariant(model))
408-
409- # idxs = (model.grid.Nx÷2, model.grid.Ny÷2, model.grid.Nz÷2) # Get a value far from boundaries
410-
411- # if model.closure isa Tuple
412- # @compute ν_field = Field(sum(viscosity(model.closure, model.diffusivity_fields)))
413- # else
414- # ν_field = viscosity(model.closure, model.diffusivity_fields)
415- # end
416-
417- # CUDA.@allowscalar begin
418- # ν = ν_field isa Number ? ν_field : getindex(ν_field, idxs...)
419-
420- # @test getindex(S, idxs...) ≈ 0
421- # @test getindex(Ω, idxs...) ≈ ζ/√2
422- # @test getindex(q, idxs...) ≈ (getindex(Ω, idxs...)^2 - getindex(S, idxs...)^2)/2 ≈ ζ^2/4
423- # @test getindex(ε, idxs...) ≈ 0
424- # end
425- # end
426-
427- # function test_uniform_shear_flow(grid; model_type=NonhydrostaticModel, closure=ScalarDiffusivity(ν=1), σ=1)
428- # model = model_type(; grid, closure)
429- # u₀(x, y, z) = +σ * y
430- # set!(model, u=u₀, v=0, w=0, enforce_incompressibility=false)
431-
432- # u, v, w = model.velocities
433-
434- # @compute ε = Field(KineticEnergyDissipationRate(model))
435- # @compute S = Field(StrainRateTensorModulus(model))
436- # @compute Ω = Field(VorticityTensorModulus(model))
437- # @compute q = Field(QVelocityGradientTensorInvariant(model))
438-
439- # idxs = (model.grid.Nx÷2, model.grid.Ny÷2, model.grid.Nz÷2) # Get a value far from boundaries
440-
441- # if model.closure isa Tuple
442- # @compute ν_field = Field(sum(viscosity(model.closure, model.diffusivity_fields)))
443- # else
444- # ν_field = viscosity(model.closure, model.diffusivity_fields)
445- # end
446-
447- # CUDA.@allowscalar begin
448- # ν = ν_field isa Number ? ν_field : getindex(ν_field, idxs...)
449-
450- # @test getindex(S, idxs...) ≈ σ/√2
451- # @test getindex(Ω, idxs...) ≈ σ/√2
452- # @test ≈(getindex(q, idxs...), (getindex(Ω, idxs...)^2 - getindex(S, idxs...)^2)/2, atol=eps())
453- # @test ≈(getindex(q, idxs...), 0, atol=eps())
454- # @test getindex(ε, idxs...) ≈ 2 * ν * getindex(S, idxs...)^2
455- # end
456- # end
363+ function test_uniform_strain_flow (grid; model_type= NonhydrostaticModel, closure= ScalarDiffusivity (ν= 1 ), α= 1 )
364+ model = model_type (; grid, closure)
365+ u₀ (x, y, z) = + α* x
366+ v₀ (x, y, z) = - α* y
367+ set! (model, u= u₀, v= v₀, w= 0 , enforce_incompressibility= false )
368+
369+ u, v, w = model. velocities
370+
371+ @compute ε = Field (KineticEnergyDissipationRate (model))
372+ @compute S = Field (StrainRateTensorModulus (model))
373+ @compute Ω = Field (VorticityTensorModulus (model))
374+ @compute q = Field (QVelocityGradientTensorInvariant (model))
375+
376+ idxs = (model. grid. Nx÷ 2 , model. grid. Ny÷ 2 , model. grid. Nz÷ 2 ) # Get a value far from boundaries
377+
378+ if model. closure isa Tuple
379+ @compute ν_field = Field (sum (viscosity (model. closure, model. diffusivity_fields)))
380+ else
381+ ν_field = viscosity (model. closure, model. diffusivity_fields)
382+ end
383+
384+ CUDA. @allowscalar begin
385+ ν = ν_field isa Number ? ν_field : getindex (ν_field, idxs... )
386+
387+ @test getindex (S, idxs... ) ≈ √ 2 * α
388+ @test getindex (Ω, idxs... ) ≈ 0
389+ @test getindex (q, idxs... ) ≈ (getindex (Ω, idxs... )^ 2 - getindex (S, idxs... )^ 2 )/ 2 ≈ - α^ 2
390+ @test getindex (ε, idxs... ) ≈ 2 * ν * getindex (S, idxs... )^ 2
391+ end
392+
393+ return nothing
394+ end
395+
396+ function test_solid_body_rotation_flow (grid; model_type= NonhydrostaticModel, closure= ScalarDiffusivity (ν= 1 ), ζ= 1 )
397+ model = model_type (; grid, closure)
398+ u₀ (x, y, z) = + ζ* y / 2
399+ v₀ (x, y, z) = - ζ* x / 2
400+ set! (model, u= u₀, v= v₀, w= 0 , enforce_incompressibility= false )
401+
402+ u, v, w = model. velocities
403+
404+ @compute ε = Field (KineticEnergyDissipationRate (model))
405+ @compute S = Field (StrainRateTensorModulus (model))
406+ @compute Ω = Field (VorticityTensorModulus (model))
407+ @compute q = Field (QVelocityGradientTensorInvariant (model))
408+
409+ idxs = (model. grid. Nx÷ 2 , model. grid. Ny÷ 2 , model. grid. Nz÷ 2 ) # Get a value far from boundaries
410+
411+ if model. closure isa Tuple
412+ @compute ν_field = Field (sum (viscosity (model. closure, model. diffusivity_fields)))
413+ else
414+ ν_field = viscosity (model. closure, model. diffusivity_fields)
415+ end
416+
417+ CUDA. @allowscalar begin
418+ ν = ν_field isa Number ? ν_field : getindex (ν_field, idxs... )
419+
420+ @test getindex (S, idxs... ) ≈ 0
421+ @test getindex (Ω, idxs... ) ≈ ζ/√ 2
422+ @test getindex (q, idxs... ) ≈ (getindex (Ω, idxs... )^ 2 - getindex (S, idxs... )^ 2 )/ 2 ≈ ζ^ 2 / 4
423+ @test getindex (ε, idxs... ) ≈ 0
424+ end
425+ end
426+
427+ function test_uniform_shear_flow (grid; model_type= NonhydrostaticModel, closure= ScalarDiffusivity (ν= 1 ), σ= 1 )
428+ model = model_type (; grid, closure)
429+ u₀ (x, y, z) = + σ * y
430+ set! (model, u= u₀, v= 0 , w= 0 , enforce_incompressibility= false )
431+
432+ u, v, w = model. velocities
433+
434+ @compute ε = Field (KineticEnergyDissipationRate (model))
435+ @compute S = Field (StrainRateTensorModulus (model))
436+ @compute Ω = Field (VorticityTensorModulus (model))
437+ @compute q = Field (QVelocityGradientTensorInvariant (model))
438+
439+ idxs = (model. grid. Nx÷ 2 , model. grid. Ny÷ 2 , model. grid. Nz÷ 2 ) # Get a value far from boundaries
440+
441+ if model. closure isa Tuple
442+ @compute ν_field = Field (sum (viscosity (model. closure, model. diffusivity_fields)))
443+ else
444+ ν_field = viscosity (model. closure, model. diffusivity_fields)
445+ end
446+
447+ CUDA. @allowscalar begin
448+ ν = ν_field isa Number ? ν_field : getindex (ν_field, idxs... )
449+
450+ @test getindex (S, idxs... ) ≈ σ/√ 2
451+ @test getindex (Ω, idxs... ) ≈ σ/√ 2
452+ @test ≈ (getindex (q, idxs... ), (getindex (Ω, idxs... )^ 2 - getindex (S, idxs... )^ 2 )/ 2 , atol= eps ())
453+ @test ≈ (getindex (q, idxs... ), 0 , atol= eps ())
454+ @test getindex (ε, idxs... ) ≈ 2 * ν * getindex (S, idxs... )^ 2
455+ end
456+ end
457457# ---
458458
459459model_kwargs = (buoyancy = Buoyancy (model= BuoyancyTracer ()),
@@ -475,50 +475,50 @@ model_types = (NonhydrostaticModel, HydrostaticFreeSurfaceModel)
475475@testset " Oceanostics" begin
476476 for grid in grids
477477 for model_type in model_types
478- # for closure in closures
479- # @info "Testing $model_type on grid and with closure" grid closure
480- # model = model_type(; grid, closure, model_kwargs...)
478+ for closure in closures
479+ @info " Testing $model_type on grid and with closure" grid closure
480+ model = model_type (; grid, closure, model_kwargs... )
481481
482- # @info "Testing velocity-only diagnostics"
483- # test_vel_only_diagnostics(model)
482+ @info " Testing velocity-only diagnostics"
483+ test_vel_only_diagnostics (model)
484484
485- # @info "Testing buoyancy diagnostics"
486- # test_buoyancy_diagnostics(model)
485+ @info " Testing buoyancy diagnostics"
486+ test_buoyancy_diagnostics (model)
487487
488- # if model isa NonhydrostaticModel
489- # @info "Testing pressure terms"
490- # test_pressure_term(model)
488+ if model isa NonhydrostaticModel
489+ @info " Testing pressure terms"
490+ test_pressure_term (model)
491491
492- # @info "Testing buoyancy production term"
493- # test_buoyancy_production_term(grid; model_type)
494- # end
492+ @info " Testing buoyancy production term"
493+ test_buoyancy_production_term (grid; model_type)
494+ end
495495
496- # @info "Testing energy dissipation rate terms"
497- # test_ke_dissipation_rate_terms(grid; model_type, closure)
496+ @info " Testing energy dissipation rate terms"
497+ test_ke_dissipation_rate_terms (grid; model_type, closure)
498498
499499
500- # if model_type == NonhydrostaticModel
501- # @info "Testing energy dissipation rate terms"
502- # test_momentum_advection_term(grid; model_type)
500+ if model_type == NonhydrostaticModel
501+ @info " Testing energy dissipation rate terms"
502+ test_momentum_advection_term (grid; model_type)
503503
504- # @info "Testing forcing terms"
505- # test_ke_forcing_term(grid; model_type)
504+ @info " Testing forcing terms"
505+ test_ke_forcing_term (grid; model_type)
506506
507- # @info "Testing uniform strain flow"
508- # test_uniform_strain_flow(grid; model_type, closure, α=3)
507+ @info " Testing uniform strain flow"
508+ test_uniform_strain_flow (grid; model_type, closure, α= 3 )
509509
510- # @info "Testing solid body rotation flow"
511- # test_solid_body_rotation_flow(grid; model_type, closure, ζ=3)
510+ @info " Testing solid body rotation flow"
511+ test_solid_body_rotation_flow (grid; model_type, closure, ζ= 3 )
512512
513- # @info "Testing uniform shear flow"
514- # test_uniform_shear_flow(grid; model_type, closure, σ=3)
515- # end
513+ @info " Testing uniform shear flow"
514+ test_uniform_shear_flow (grid; model_type, closure, σ= 3 )
515+ end
516516
517- # @info "Testing tracer variance terms"
518- # model = model_type(; grid, closure, model_kwargs...)
519- # test_tracer_diagnostics(model)
517+ @info " Testing tracer variance terms"
518+ model = model_type (; grid, closure, model_kwargs... )
519+ test_tracer_diagnostics (model)
520520
521- # end
521+ end
522522 @info " Testing error throws for invalid buoyancy models"
523523 for buoyancy in invalid_buoyancy_models
524524
0 commit comments