Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add cubed sphere test cases #199

Open
wants to merge 97 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 95 commits
Commits
Show all changes
97 commits
Select commit Hold shift + click to select a range
d5ecc49
add getter for number of dofs
benegee Feb 22, 2024
72709e5
change trixi_load_cell_average
benegee Feb 22, 2024
71ba4bf
fix: ensure Int32
benegee Feb 23, 2024
9c83b05
adapt reference value
benegee Feb 23, 2024
5b3960b
add getter for all dofs values
benegee Feb 23, 2024
3e31f4a
adapt next value
benegee Feb 23, 2024
2d45c62
add trixi_store_in_database
benegee Feb 26, 2024
92d817a
add trixi_ndofs_element
benegee Feb 26, 2024
530f5cc
add tests
benegee Feb 26, 2024
c7d38d4
add missing parts in tests
benegee Feb 26, 2024
ba00c6f
fix tests
benegee Feb 26, 2024
cdf6e5e
deallocate first
benegee Feb 26, 2024
aa6d8c7
add trixi_load_prim to Fortran API
benegee Feb 26, 2024
cf43795
reference value
benegee Feb 26, 2024
dda491a
get doxygen right
benegee Feb 26, 2024
35513ac
Merge branch 'main' into more-data-access
sloede Feb 26, 2024
bf0b732
Merge branch 'main' into bg/store-in-database
benegee Feb 28, 2024
b864850
add trixi_get_time, trixi_load_node_coordinates
benegee Feb 29, 2024
9430f2d
implement source terms controller
benegee Feb 29, 2024
5956a78
libelixir with source terms via database
benegee Feb 29, 2024
ccd23fc
change Array to Vector
benegee Feb 29, 2024
1be73d9
spelling
benegee Feb 29, 2024
584a674
libelixir for baroclinic instability
benegee Feb 29, 2024
7c82c90
remove method only required by steady state correction
benegee Mar 4, 2024
d1850a7
Update LibTrixi.jl/examples/libelixir_p4est3d_euler_baroclinic_instab…
benegee Mar 4, 2024
fd103d9
Merge branch 'main' into bg/baroclinic-instability
benegee Mar 4, 2024
6170610
Merge branch 'more-data-access' into bg/store-in-database
benegee Mar 7, 2024
94cc1c7
Merge branch 'more-data-access' of github.com:trixi-framework/libtrix…
benegee Mar 7, 2024
7dbb2c6
make everything more consistent!
benegee Mar 7, 2024
7906080
use const double *
benegee Mar 8, 2024
ff6ac54
Merge branch 'main' into more-data-access
benegee Mar 11, 2024
dfea9e4
Merge branch 'main' into more-data-access
sloede Apr 18, 2024
017e166
Merge branch 'bg/store-in-database' of github.com:trixi-framework/lib…
benegee May 13, 2024
f534175
Merge branch 'main' into more-data-access
benegee May 13, 2024
8b6a81f
Merge branch 'more-data-access' into bg/store-in-database
benegee May 13, 2024
f96436b
missed merge conflict
benegee May 13, 2024
b76ca70
transpose calloc args
benegee May 13, 2024
37b88a1
Merge branch 'main' into more-data-access
benegee Jun 25, 2024
95ba0cc
Merge branch 'more-data-access' into bg/store-in-database
benegee Jun 28, 2024
44ffad8
Merge branch 'bg/store-in-database' into bg/baroclinic-instability
benegee Jun 28, 2024
b40a2a1
add functions to get quadrature information
benegee Jul 24, 2024
e4d6901
update CI badge URL
benegee Jul 24, 2024
66ee664
Merge branch 'main' into more-data-access
benegee Jul 24, 2024
3f665f0
Merge branch 'more-data-access' into bg/store-in-database
benegee Jul 24, 2024
3a0387b
remove load_node_coordinates
benegee Jul 24, 2024
49394c7
Merge branch 'bg/store-in-database' into bg/baroclinic-instability
benegee Jul 24, 2024
9bc76b4
add baroclinic instability elixir and controller
benegee Jul 24, 2024
110219d
fix
benegee Jul 25, 2024
ade7e73
clean up
benegee Jul 25, 2024
6627b97
add get_t8code_forest to Fortran interface
benegee Jul 26, 2024
2550872
format
benegee Jul 26, 2024
211de01
Merge branch 'more-data-access' into bg/store-in-database
benegee Jul 26, 2024
08daf22
add trixi_store_in_database to Fortran interface
benegee Jul 26, 2024
e7ab9eb
Merge branch 'bg/store-in-database' into bg/baroclinic-instability
benegee Jul 26, 2024
6672d9c
add fortran controller for baroclinic test case
benegee Jul 26, 2024
e48dcb2
remove parameter t
Aug 29, 2024
00e4914
spelling
benegee Aug 29, 2024
312e979
Merge branch 'main' into bg/store-in-database
benegee Nov 18, 2024
a175a04
adapt min version according to main CMakeLists.txt
benegee Nov 18, 2024
d5fd61f
missed while merging
benegee Nov 18, 2024
4449a82
Merge branch 'main' into bg/store-in-database
benegee Nov 19, 2024
0a359b1
change default argument for DataBase parameter
benegee Nov 19, 2024
0351ea9
Merge branch 'bg/store-in-database' into bg/baroclinic-instability
benegee Nov 19, 2024
7b654a4
remove deprecated export
benegee Nov 19, 2024
41ab02a
test for get_time
benegee Nov 19, 2024
6bda669
add tests for trixi_store_in_database
benegee Nov 19, 2024
a8c573e
need Int32
benegee Nov 19, 2024
5a33b95
cannot compare Refs
benegee Nov 19, 2024
378dc90
check based on address
benegee Nov 19, 2024
8c36455
relax error tolerance
benegee Nov 19, 2024
f28d802
remove deprecated example
benegee Nov 19, 2024
d95de39
Merge branch 'bg/store-in-database' into bg/baroclinic-instability
benegee Nov 20, 2024
492d1c4
new cubed sphere examples
benegee Nov 20, 2024
272a0a2
remove deprecated libelixir
benegee Nov 20, 2024
9e36f4e
unify naming of libelixirs
benegee Nov 20, 2024
c6ec30a
fixes
benegee Nov 20, 2024
b866b8b
adapt index.md to README.md
benegee Nov 20, 2024
ac1b653
change to non-adaptive time integrator
benegee Nov 20, 2024
58444f3
missing controlers in ci checks
benegee Nov 20, 2024
5f02f44
Merge branch 'main' into bg/baroclinic-instability
benegee Nov 27, 2024
218cd91
use zeros in initial data
benegee Nov 27, 2024
47a2e4c
missing renamings
benegee Nov 27, 2024
8bd1b23
time not needed anymore
benegee Nov 27, 2024
85f882c
tuned simulation parameters
benegee Nov 27, 2024
49fa815
itree and ielement need to be 0-based
benegee Nov 27, 2024
5cf1aec
one more to free
benegee Nov 28, 2024
8ccad7b
ouch...
benegee Nov 28, 2024
5599568
less output
benegee Nov 28, 2024
142e6a2
typo in docstring
benegee Nov 28, 2024
8794de7
adopt new t8code ForestWrapper
benegee Dec 17, 2024
b7bd4c4
Merge branch 'main' into bg/baroclinic-instability
benegee Dec 17, 2024
5f5fe48
switch to newest t8code release
benegee Dec 17, 2024
f341561
cubed sphere stuff only works with latest Trixi release
benegee Dec 20, 2024
889f990
missed renaming
benegee Dec 20, 2024
63ece7a
enable t8code for package compiler as well
benegee Dec 20, 2024
90312a1
review
benegee Jan 7, 2025
b379e50
filter out baroclinic example
benegee Jan 7, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 28 additions & 16 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ jobs:
- '1.10'
- '1.11'
t8code_version:
- '3.0.0'
- '3.0.1'
include:
- os: ubuntu-latest
test_type: coverage
arch: x64
julia_version: '1.11'
t8code_version: '3.0.0'
t8code_version: '3.0.1'
env:
# Necessary for HDF5 to play nice with Julia
LD_PRELOAD: /lib/x86_64-linux-gnu/libcurl.so.4
Expand Down Expand Up @@ -170,9 +170,7 @@ jobs:
--t8code-library ../t8code-local/prefix/lib/libt8.so \
--julia-depot ~/.julia \
--force
cp ../install/share/libtrixi/LibTrixi.jl/examples/libelixir_tree1d_dgsem_advection_basic.jl .
cp ../install/share/libtrixi/LibTrixi.jl/examples/libelixir_p4est2d_dgsem_euler_sedov.jl .
cp ../install/share/libtrixi/LibTrixi.jl/examples/libelixir_t8code_2d_dgsem_advection_amr.jl .
cp ../install/share/libtrixi/LibTrixi.jl/examples/libelixir_* .

- name: Initialize project directory (test_type == 'package-compiler')
if: ${{ matrix.test_type == 'package-compiler' }}
Expand All @@ -198,6 +196,7 @@ jobs:
cd build
cmake .. -DCMAKE_INSTALL_PREFIX=../install \
-DCMAKE_BUILD_TYPE=Debug \
-DT8CODE_ROOT=$PWD/../t8code-local/prefix \
Copy link
Member

Choose a reason for hiding this comment

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

Why?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good catch!
At some point I ran t8code elixirs also with PC, but not anymore.
Removed this line.

-DUSE_PACKAGE_COMPILER=ON \
-DJULIA_PROJECT_PATH=$PWD/../libtrixi-julia

Expand All @@ -215,7 +214,7 @@ jobs:
./build.sh
mpirun -n 2 ./build/trixi_controller_simple_c \
../../libtrixi-julia \
../../LibTrixi.jl/examples/libelixir_p4est2d_dgsem_euler_sedov.jl
../../LibTrixi.jl/examples/libelixir_p4est2d_euler_sedov.jl
env:
LIBTRIXI_DEBUG: all

Expand All @@ -240,14 +239,19 @@ jobs:
if: ${{ matrix.test_type == 'regular' || matrix.test_type == 'coverage' }}
run: |
cd libtrixi-julia
../build/examples/trixi_controller_simple_c . libelixir_tree1d_dgsem_advection_basic.jl
../build/examples/trixi_controller_simple_f . libelixir_tree1d_dgsem_advection_basic.jl
../build/examples/trixi_controller_simple_c . libelixir_p4est2d_dgsem_euler_sedov.jl
../build/examples/trixi_controller_simple_f . libelixir_p4est2d_dgsem_euler_sedov.jl
../build/examples/trixi_controller_data_c . libelixir_t8code_2d_dgsem_advection_amr.jl
../build/examples/trixi_controller_data_f . libelixir_t8code_2d_dgsem_advection_amr.jl
../build/examples/trixi_controller_t8code_c . libelixir_t8code_2d_dgsem_advection_amr.jl
../build/examples/trixi_controller_t8code_f . libelixir_t8code_2d_dgsem_advection_amr.jl
# all controllers
../build/examples/trixi_controller_simple_c . libelixir_tree1d_advection_basic.jl
../build/examples/trixi_controller_simple_f . libelixir_tree1d_advection_basic.jl
../build/examples/trixi_controller_data_c . libelixir_t8code2d_advection_amr.jl
../build/examples/trixi_controller_data_f . libelixir_t8code2d_advection_amr.jl
../build/examples/trixi_controller_t8code_c . libelixir_t8code2d_advection_amr.jl
../build/examples/trixi_controller_t8code_f . libelixir_t8code2d_advection_amr.jl
../build/examples/trixi_controller_baroclinic_c . libelixir_t8code3d_euler_baroclinic_instability.jl
../build/examples/trixi_controller_baroclinic_f . libelixir_t8code3d_euler_baroclinic_instability.jl
mpirun -n 2 ../build/examples/trixi_controller_mpi_c . libelixir_p4est2d_euler_sedov.jl
mpirun -n 2 ../build/examples/trixi_controller_mpi_f . libelixir_p4est2d_euler_sedov.jl
# remaining libelixirs
../build/examples/trixi_controller_simple_c . libelixir_t8code3d_euler_tracer.jl
env:
LIBTRIXI_DEBUG: all

Expand All @@ -257,7 +261,7 @@ jobs:
cd build/examples
mpirun -n 2 trixi_controller_simple_c \
../../libtrixi-julia \
../../LibTrixi.jl/examples/libelixir_p4est2d_dgsem_euler_sedov.jl
../../LibTrixi.jl/examples/libelixir_p4est2d_euler_sedov.jl
env:
LIBTRIXI_DEBUG: all

Expand All @@ -277,7 +281,15 @@ jobs:
"../build/examples/trixi_controller_t8code_c" \
"../build/examples/trixi_controller_t8code_c ." \
"../build/examples/trixi_controller_t8code_f" \
"../build/examples/trixi_controller_t8code_f ."
"../build/examples/trixi_controller_t8code_f ." \
"../build/examples/trixi_controller_baroclinic_c" \
"../build/examples/trixi_controller_baroclinic_c ." \
"../build/examples/trixi_controller_baroclinic_f" \
"../build/examples/trixi_controller_baroclinic_f ." \
"../build/examples/trixi_controller_mpi_c" \
"../build/examples/trixi_controller_mpi_c ." \
"../build/examples/trixi_controller_mpi_f" \
"../build/examples/trixi_controller_mpi_f ."
do
$command
if [ $? -ne 2 ]; then
Expand Down
2 changes: 1 addition & 1 deletion LibTrixi.jl/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Trixi = "a7f1ee26-1774-49b1-8366-f1abc58fbfcb"
MPI = "0.20.13"
OrdinaryDiffEq = "6.53.2"
Pkg = "1.8"
Trixi = "0.7.16, 0.8, 0.9"
Trixi = "0.9.12"
julia = "1.8"

[preferences.OrdinaryDiffEq]
Expand Down
4 changes: 2 additions & 2 deletions LibTrixi.jl/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ run, and finalize a simulation by running the following code:
```julia
julia> using LibTrixi

julia> libelixir = pkgdir(LibTrixi, "examples", "libelixir_tree1d_dgsem_advection_basic.jl")
"/path/to/libtrixi/LibTrixi.jl/examples/libelixir_tree1d_dgsem_advection_basic.jl"
julia> libelixir = pkgdir(LibTrixi, "examples", "libelixir_tree1d_advection_basic.jl")
"/path/to/libtrixi/LibTrixi.jl/examples/libelixir_tree1d_advection_basic.jl"

julia> handle = trixi_initialize_simulation(libelixir); # initialize a new simulation setup

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,43 @@ using LinearAlgebra
using LibTrixi


# Callable struct holding vectors with source terms
struct SourceTerm
nnodesdim::Int
registry::LibTrixiDataRegistry
end

# We overwrite Trixi.jl's internal method here such that it calls source_terms with indices
function Trixi.calc_sources!(du, u, t, source_terms::SourceTerm,
equations::CompressibleEulerEquations3D, dg::DG, cache)
@unpack node_coordinates = cache.elements
Trixi.@threaded for element in eachelement(dg, cache)
for k in eachnode(dg), j in eachnode(dg), i in eachnode(dg)
u_local = Trixi.get_node_vars(u, equations, dg, i, j, k, element)
du_local = source_terms(u_local, i, j, k, element, t, equations)
#x_local = Trixi.get_node_coords(node_coordinates, equations, dg,
# i, j, k, element)
#du_local_ref = source_terms_baroclinic_instability(u_local, x_local, t,
# equations)
Trixi.add_to_node_vars!(du, du_local, equations, dg, i, j, k, element)
end
end
return nothing
end

@inline function (source::SourceTerm)(u, i, j, k, element, t,
equations::CompressibleEulerEquations3D)
@unpack nnodesdim = source
index_global = (element-1) * nnodesdim^3 + (k-1) * nnodesdim^2 + (j-1) * nnodesdim + i
du2::Vector{Float64} = source.registry[1]
du3::Vector{Float64} = source.registry[2]
du4::Vector{Float64} = source.registry[3]
du5::Vector{Float64} = source.registry[4]
return SVector(zero(eltype(u)), du2[index_global], du3[index_global],
du4[index_global], du5[index_global])
end


# Initial condition for an idealized baroclinic instability test
# https://doi.org/10.1002/qj.2241, Section 3.2 and Appendix A
function initial_condition_baroclinic_instability(x, t,
Expand Down Expand Up @@ -193,38 +230,51 @@ end
# The function to create the simulation state needs to be named `init_simstate`
function init_simstate()

###############################################################################
# Setup for the baroclinic instability test
# compressible euler equations
gamma = 1.4
equations = CompressibleEulerEquations3D(gamma)

###############################################################################
# semidiscretization of the problem

# setup of the problem
initial_condition = initial_condition_baroclinic_instability

boundary_conditions = Dict(:inside => boundary_condition_slip_wall,
:outside => boundary_condition_slip_wall)

# This is a good estimate for the speed of sound in this example.
# Other values between 300 and 400 should work as well.
# estimate for the speed of sound
surface_flux = FluxLMARS(340)
volume_flux = flux_kennedy_gruber
solver = DGSEM(polydeg = 5, surface_flux = surface_flux,
volume_integral = VolumeIntegralFluxDifferencing(volume_flux))

trees_per_cube_face = (16, 8)
mesh = Trixi.P4estMeshCubedSphere(trees_per_cube_face..., 6.371229e6, 30000.0,
polydeg = 5, initial_refinement_level = 0)
# for nice results, use 4 and 8 here
lat_lon_levels = 2
layers = 4
mesh = Trixi.T8codeMeshCubedSphere(lat_lon_levels, layers, 6.371229e6, 30000.0,
polydeg = 5, initial_refinement_level = 0)

# create the data registry and three vectors for the source terms
benegee marked this conversation as resolved.
Show resolved Hide resolved
registry = LibTrixiDataRegistry(undef, 4)

nnodesdim = Trixi.nnodes(solver)
nnodes = nnodesdim^3
nelements = Trixi.ncells(mesh)

# provide some data because calc_sources! will already be called during initialization
zero_data = zeros(Float64, nelements*nnodes)
registry[1] = zero_data
registry[2] = zero_data
registry[3] = zero_data
registry[4] = zero_data
Copy link
Member

Choose a reason for hiding this comment

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

The current implementation does not seem correct. All entries of registry are assigned the same vector zero_data, i.e., they point to a single data structure.

I see that they will be overwritten later again. However, my feeling is that it would be better to make sure that this is not accidentally considered a valid implementation:

Suggested change
# provide some data because calc_sources! will already be called during initialization
zero_data = zeros(Float64, nelements*nnodes)
registry[1] = zero_data
registry[2] = zero_data
registry[3] = zero_data
registry[4] = zero_data
# provide some data because calc_sources! will already be called during initialization
# Note: the data pointers in the registry will be overwritten before the first real use
zero_data = zeros(Float64, nelements*nnodes)
registry[1] = zero_data
registry[2] = zero_data
registry[3] = zero_data
registry[4] = zero_data

Copy link
Member

Choose a reason for hiding this comment

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

As a side note, I am starting to wonder if storage for source terms should maybe live on the Trixi.jl side instead of the C side. This goes against previous statements I made, and I wouldn't change it now before we have gathered more experience with it. However, it seems to me that it is overly convoluted this way, especially since it's effectively Trixi.jl that needs and controls the memory, not the C side

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

True! I now allocate separate arrays to avoid confusion.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The argument for memory management on C side was that some large software frameworks have their own storage pool and would like to use it.


source_term_data_registry = SourceTerm(nnodesdim, registry)

semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver,
source_terms = source_terms_baroclinic_instability,
source_terms = source_term_data_registry,
boundary_conditions = boundary_conditions)

###############################################################################
# ODE solvers, callbacks etc.

tspan = (0.0, 12 * 24 * 60 * 60.0) # time in seconds for 12 days#
# for nice results, use 10 days
days = 0.02
tspan = (0.0, days * 24 * 60 * 60.0)

ode = semidiscretize(semi, tspan)

Expand All @@ -235,33 +285,24 @@ function init_simstate()

alive_callback = AliveCallback(analysis_interval = analysis_interval)

save_solution = SaveSolutionCallback(interval = 5000,
save_solution = SaveSolutionCallback(interval = 500,
save_initial_solution = true,
save_final_solution = true,
solution_variables = cons2prim,
output_directory = "out_baroclinic",)
output_directory = "out_baroclinic")

callbacks = CallbackSet(summary_callback,
analysis_callback,
alive_callback,
save_solution)


###############################################################################
# create the time integrator

# OrdinaryDiffEq's `integrator`
# Use a Runge-Kutta method with automatic (error based) time step size control
integrator = init(ode, RDPK3SpFSAL49();
# use a Runge-Kutta method with automatic (error based) time step size control
integrator = init(ode, RDPK3SpFSAL49(thread = OrdinaryDiffEq.False());
abstol = 1.0e-6, reltol = 1.0e-6,
ode_default_options()...,
callback = callbacks,
maxiters=5e5);

###############################################################################
# Create simulation state
ode_default_options()..., callback = callbacks, maxiters=1e7);

simstate = SimulationState(semi, integrator)
# create simulation state
simstate = SimulationState(semi, integrator, registry)

return simstate
end
124 changes: 124 additions & 0 deletions LibTrixi.jl/examples/libelixir_t8code3d_euler_tracer.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
# A manufactured solution of a circular wind with constant angular velocity
# on a planetary-sized cubed sphere mesh with a blob detected by AMR
#
# Note that this libelixir is based on an elixir by Erik Faulhaber for Trixi.jl
# Source: https://github.com/trixi-framework/Trixi.jl/blob/main/examples/p4est_3d_dgsem/elixir_euler_circular_wind_nonconforming.jl

using OrdinaryDiffEq
using Trixi
using LinearAlgebra
using LibTrixi


function initial_condition_circular_wind(x, t, equations::CompressibleEulerEquations3D)
radius_earth = 6.371229e6
lambda, phi, r = cart_to_sphere(x)

p = 1e5
v1 = -10 * x[2] / radius_earth
v2 = 10 * x[1] / radius_earth
v3 = 0.0
rho = 1.0 + 0.1 * exp(-50 * ((lambda-1.0)^2/2.0 + (phi-0.4)^2)) +
0.08 * exp(-100 * ((lambda-0.8)^2/4.0 + (phi-0.5)^2))

return prim2cons(SVector(rho, v1, v2, v3, p), equations)
end

@inline function source_terms_circular_wind(u, x, t,
equations::CompressibleEulerEquations3D)
radius_earth = 6.371229e6
rho = u[1]

du1 = 0.0
du2 = -rho * (10 / radius_earth) * (10 * x[1] / radius_earth)
du3 = -rho * (10 / radius_earth) * (10 * x[2] / radius_earth)
du4 = 0.0
du5 = 0.0

return SVector(du1, du2, du3, du4, du5)
end

function cart_to_sphere(x)
r = norm(x)
lambda = atan(x[2], x[1])
if lambda < 0
lambda += 2 * pi
end
phi = asin(x[3] / r)

return lambda, phi, r
end


# The function to create the simulation state needs to be named `init_simstate`
function init_simstate()

# compressible Euler equations
gamma = 1.4
equations = CompressibleEulerEquations3D(gamma)

# setup of the problem
initial_condition = initial_condition_circular_wind

boundary_conditions = Dict(:inside => boundary_condition_slip_wall,
:outside => boundary_condition_slip_wall)

# estimate for speed of sound
surface_flux = FluxLMARS(374)
solver = DGSEM(polydeg = 3, surface_flux = surface_flux)

# increase trees_per_cube_face to 4 to get nicer results
lat_lon_levels = 2
layers = 1
mesh = Trixi.T8codeMeshCubedSphere(lat_lon_levels, layers, 6.371229e6, 30000.0,
polydeg = 3, initial_refinement_level = 0)

semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver,
source_terms = source_terms_circular_wind,
boundary_conditions = boundary_conditions)

# increase number of days
days = 0.1
tspan = (0.0, days * 24 * 60 * 60.0)

ode = semidiscretize(semi, tspan)

summary_callback = SummaryCallback()

analysis_interval = 5000
analysis_callback = AnalysisCallback(semi, interval = analysis_interval)

alive_callback = AliveCallback(analysis_interval = analysis_interval)

save_solution = SaveSolutionCallback(interval = 2000,
save_initial_solution = true,
save_final_solution = true,
solution_variables = cons2prim,
output_directory = "out_tracer")

amr_controller = ControllerThreeLevel(semi, IndicatorMax(semi, variable = first),
base_level = 0,
med_level = 1, med_threshold = 1.004,
max_level = 3, max_threshold = 1.11)

amr_callback = AMRCallback(semi, amr_controller,
interval = 2000,
adapt_initial_condition = true,
adapt_initial_condition_only_refine = true)

callbacks = CallbackSet(summary_callback,
analysis_callback,
alive_callback,
amr_callback,
save_solution)

# use a Runge-Kutta method with automatic (error based) time step size control
integrator = init(ode, RDPK3SpFSAL49(thread = OrdinaryDiffEq.False());
abstol = 1.0e-6, reltol = 1.0e-6,
ode_default_options()..., callback = callbacks, maxiters=1e7);

# create simulation state
simstate = SimulationState(semi, integrator)

return simstate
end
Loading
Loading