diff --git a/.github/workflows/SpellCheck.yml b/.github/workflows/SpellCheck.yml index fb3dd77..4801375 100644 --- a/.github/workflows/SpellCheck.yml +++ b/.github/workflows/SpellCheck.yml @@ -11,3 +11,5 @@ jobs: uses: actions/checkout@v4 - name: Check spelling uses: crate-ci/typos@v1.24.3 + with: + config: typos.toml # specify the custom config file diff --git a/docs/dev_env_info.md b/docs/dev_env_info.md new file mode 100644 index 0000000..895b99c --- /dev/null +++ b/docs/dev_env_info.md @@ -0,0 +1,262 @@ +# Development Environment Information + +## Recent Update + +The hardware has been updated for this project recently. The new NVIDIA GeForce Series has been launched to continue implementation and testing of this project. Here is the detailed environment information for this project now. + +The following shows the specific CPU information. + +```Bash +huiyu@huiyuxps15:~$ lscpu +Architecture: x86_64 + CPU op-mode(s): 32-bit, 64-bit + Address sizes: 46 bits physical, 48 bits virtual + Byte Order: Little Endian +CPU(s): 20 + On-line CPU(s) list: 0-19 +Vendor ID: GenuineIntel + Model name: 13th Gen Intel(R) Core(TM) i9-13900H + CPU family: 6 + Model: 186 + Thread(s) per core: 2 + Core(s) per socket: 10 + Socket(s): 1 + Stepping: 2 + BogoMIPS: 5990.39 + Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse ss + e2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc rep_good nopl xtopology tsc_reliable nonstop + _tsc cpuid pni pclmulqdq vmx ssse3 fma cx16 sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_time + r aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch ssbd ibrs ibpb stibp ibrs_enha + nced tpr_shadow vnmi ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid rdsee + d adx smap clflushopt clwb sha_ni xsaveopt xsavec xgetbv1 xsaves avx_vnni umip waitpkg gfni vae + s vpclmulqdq rdpid movdiri movdir64b fsrm md_clear serialize flush_l1d arch_capabilities +Virtualization features: + Virtualization: VT-x + Hypervisor vendor: Microsoft + Virtualization type: full +Caches (sum of all): + L1d: 480 KiB (10 instances) + L1i: 320 KiB (10 instances) + L2: 12.5 MiB (10 instances) + L3: 24 MiB (1 instance) +Vulnerabilities: + Gather data sampling: Not affected + Itlb multihit: Not affected + L1tf: Not affected + Mds: Not affected + Meltdown: Not affected + Mmio stale data: Not affected + Retbleed: Mitigation; Enhanced IBRS + Spec rstack overflow: Not affected + Spec store bypass: Mitigation; Speculative Store Bypass disabled via prctl and seccomp + Spectre v1: Mitigation; usercopy/swapgs barriers and __user pointer sanitization + Spectre v2: Mitigation; Enhanced IBRS, IBPB conditional, RSB filling, PBRSB-eIBRS SW sequence + Srbds: Not affected + Tsx async abort: Not affected +``` + +The following shows the specific GPU information. + +```Bash +huiyu@huiyuxps15:~$ nvidia-smi +Thu May 16 17:26:16 2024 ++---------------------------------------------------------------------------------------+ +| NVIDIA-SMI 545.23.07 Driver Version: 546.12 CUDA Version: 12.3 | +|-----------------------------------------+----------------------+----------------------+ +| GPU Name Persistence-M | Bus-Id Disp.A | Volatile Uncorr. ECC | +| Fan Temp Perf Pwr:Usage/Cap | Memory-Usage | GPU-Util Compute M. | +| | | MIG M. | +|=========================================+======================+======================| +| 0 NVIDIA GeForce RTX 4060 ... On | 00000000:01:00.0 Off | N/A | +| N/A 43C P3 11W / 45W | 0MiB / 8188MiB | 0% Default | +| | | N/A | ++-----------------------------------------+----------------------+----------------------+ + ++---------------------------------------------------------------------------------------+ +| Processes: | +| GPU GI CI PID Type Process name GPU Memory | +| ID ID Usage | +|=======================================================================================| +| No running processes found | ++---------------------------------------------------------------------------------------+ +``` + +## Legacy (AWS) + +This project were implemented and tested on AWS EC2 instances. So far, types of EC2 instances used in this project include: `p3.2xlarge` (single-GPU) and `g4dn.12xlarge` (multi-GPU). For more information about the EC2 instances, please refer to [AWS EC2 Instance Types](https://aws.amazon.com/ec2/instance-types/). + +The following information is about the environment of the EC2 instances used in this project. + +### AWS `p3.2xlarge` +The following shows the specific CPU information of the `p3.2xlarge` instance used in this project. + +```Bash +ubuntu@ip-172-31-7-163:~/trixi_cuda$ lscpu +Architecture: x86_64 + CPU op-mode(s): 32-bit, 64-bit + Address sizes: 46 bits physical, 48 bits virtual + Byte Order: Little Endian +CPU(s): 8 + On-line CPU(s) list: 0-7 +Vendor ID: GenuineIntel + Model name: Intel(R) Xeon(R) CPU E5-2686 v4 @ 2.30GHz + CPU family: 6 + Model: 79 + Thread(s) per core: 2 + Core(s) per socket: 4 + Socket(s): 1 + Stepping: 1 + CPU max MHz: 3000.0000 + CPU min MHz: 1200.0000 + BogoMIPS: 4600.04 + Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscal + l nx pdpe1gb rdtscp lm constant_tsc rep_good nopl xtopology nonstop_tsc cpuid aperfmperf tsc_known_freq pni + pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdra + nd hypervisor lahf_lm abm 3dnowprefetch cpuid_fault invpcid_single pti fsgsbase bmi1 hle avx2 smep bmi2 erm + s invpcid rtm rdseed adx xsaveopt +Virtualization features: + Hypervisor vendor: Xen + Virtualization type: full +Caches (sum of all): + L1d: 128 KiB (4 instances) + L1i: 128 KiB (4 instances) + L2: 1 MiB (4 instances) + L3: 45 MiB (1 instance) +NUMA: + NUMA node(s): 1 + NUMA node0 CPU(s): 0-7 +Vulnerabilities: + Itlb multihit: KVM: Mitigation: VMX unsupported + L1tf: Mitigation; PTE Inversion + Mds: Vulnerable: Clear CPU buffers attempted, no microcode; SMT Host state unknown + Meltdown: Mitigation; PTI + Mmio stale data: Vulnerable: Clear CPU buffers attempted, no microcode; SMT Host state unknown + Retbleed: Not affected + Spec store bypass: Vulnerable + Spectre v1: Mitigation; usercopy/swapgs barriers and __user pointer sanitization + Spectre v2: Mitigation; Retpolines, STIBP disabled, RSB filling, PBRSB-eIBRS Not affected + Srbds: Not affected + Tsx async abort: Vulnerable: Clear CPU buffers attempted, no microcode; SMT Host state unknown +``` + +The following shows the specific GPU information of the `p3.2xlarge` instance used in this project. + +```Bash +ubuntu@ip-172-31-7-163:~/trixi_cuda$ nvidia-smi +Sat Aug 26 00:38:06 2023 ++---------------------------------------------------------------------------------------+ +| NVIDIA-SMI 530.30.02 Driver Version: 530.30.02 CUDA Version: 12.1 | +|-----------------------------------------+----------------------+----------------------+ +| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC | +| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. | +| | | MIG M. | +|=========================================+======================+======================| +| 0 Tesla V100-SXM2-16GB On | 00000000:00:1E.0 Off | 0 | +| N/A 47C P0 25W / 300W| 0MiB / 16384MiB | 0% Default | +| | | N/A | ++-----------------------------------------+----------------------+----------------------+ + ++---------------------------------------------------------------------------------------+ +| Processes: | +| GPU GI CI PID Type Process name GPU Memory | +| ID ID Usage | +|=======================================================================================| +| No running processes found | ++---------------------------------------------------------------------------------------+ +``` + +### AWS `g4dn.12xlarge` +The following shows the specific CPU information of the `g4dn.12xlarge` instance used in this project. + +```Bash +ubuntu@ip-172-31-4-230:~/trixi_cuda$ lscpu +Architecture: x86_64 + CPU op-mode(s): 32-bit, 64-bit + Address sizes: 46 bits physical, 48 bits virtual + Byte Order: Little Endian +CPU(s): 48 + On-line CPU(s) list: 0-47 +Vendor ID: GenuineIntel + Model name: Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz + CPU family: 6 + Model: 85 + Thread(s) per core: 2 + Core(s) per socket: 24 + Socket(s): 1 + Stepping: 7 + BogoMIPS: 4999.99 + Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clf + lush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc arch + _perfmon rep_good nopl xtopology nonstop_tsc cpuid aperfmperf tsc_known_fre + q pni pclmulqdq monitor ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popc + nt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dno + wprefetch invpcid_single pti fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms i + nvpcid mpx avx512f avx512dq rdseed adx smap clflushopt clwb avx512cd avx512 + bw avx512vl xsaveopt xsavec xgetbv1 xsaves ida arat pku ospke avx512_vnni +Virtualization features: + Hypervisor vendor: KVM + Virtualization type: full +Caches (sum of all): + L1d: 768 KiB (24 instances) + L1i: 768 KiB (24 instances) + L2: 24 MiB (24 instances) + L3: 35.8 MiB (1 instance) +NUMA: + NUMA node(s): 1 + NUMA node0 CPU(s): 0-47 +Vulnerabilities: + Gather data sampling: Unknown: Dependent on hypervisor status + Itlb multihit: KVM: Mitigation: VMX unsupported + L1tf: Mitigation; PTE Inversion + Mds: Vulnerable: Clear CPU buffers attempted, no microcode; SMT Host state unkno + wn + Meltdown: Mitigation; PTI + Mmio stale data: Vulnerable: Clear CPU buffers attempted, no microcode; SMT Host state unkno + wn + Retbleed: Vulnerable + Spec rstack overflow: Not affected + Spec store bypass: Vulnerable + Spectre v1: Mitigation; usercopy/swapgs barriers and __user pointer sanitization + Spectre v2: Mitigation; Retpolines, STIBP disabled, RSB filling, PBRSB-eIBRS Not affect + ed + Srbds: Not affected + Tsx async abort: Not affected +``` + +The following shows the specific GPU information of the `g4dn.12xlarge` instance used in this project. + +```Bash +ubuntu@ip-172-31-4-230:~/trixi_cuda$ nvidia-smi +Sat Dec 30 20:19:54 2023 ++---------------------------------------------------------------------------------------+ +| NVIDIA-SMI 545.23.08 Driver Version: 545.23.08 CUDA Version: 12.3 | +|-----------------------------------------+----------------------+----------------------+ +| GPU Name Persistence-M | Bus-Id Disp.A | Volatile Uncorr. ECC | +| Fan Temp Perf Pwr:Usage/Cap | Memory-Usage | GPU-Util Compute M. | +| | | MIG M. | +|=========================================+======================+======================| +| 0 Tesla T4 On | 00000000:00:1B.0 Off | 0 | +| N/A 20C P8 8W / 70W | 2MiB / 15360MiB | 0% Default | +| | | N/A | ++-----------------------------------------+----------------------+----------------------+ +| 1 Tesla T4 On | 00000000:00:1C.0 Off | 0 | +| N/A 20C P8 10W / 70W | 2MiB / 15360MiB | 0% Default | +| | | N/A | ++-----------------------------------------+----------------------+----------------------+ +| 2 Tesla T4 On | 00000000:00:1D.0 Off | 0 | +| N/A 21C P8 9W / 70W | 2MiB / 15360MiB | 0% Default | +| | | N/A | ++-----------------------------------------+----------------------+----------------------+ +| 3 Tesla T4 On | 00000000:00:1E.0 Off | 0 | +| N/A 20C P8 9W / 70W | 2MiB / 15360MiB | 0% Default | +| | | N/A | ++-----------------------------------------+----------------------+----------------------+ + ++---------------------------------------------------------------------------------------+ +| Processes: | +| GPU GI CI PID Type Process name GPU Memory | +| ID ID Usage | +|=======================================================================================| +| No running processes found | ++---------------------------------------------------------------------------------------+ +``` \ No newline at end of file diff --git a/examples/euler_shockcapturing_1d.jl b/examples/euler_shockcapturing_1d.jl new file mode 100644 index 0000000..c298191 --- /dev/null +++ b/examples/euler_shockcapturing_1d.jl @@ -0,0 +1,65 @@ +using Trixi, TrixiGPU +using OrdinaryDiffEq + +# The example is taken from the Trixi.jl + +############################################################################### +# semidiscretization of the compressible Euler equations + +equations = CompressibleEulerEquations1D(1.4) + +initial_condition = initial_condition_weak_blast_wave + +surface_flux = flux_lax_friedrichs +volume_flux = flux_shima_etal +basis = LobattoLegendreBasis(3) +indicator_sc = IndicatorHennemannGassner(equations, basis, + alpha_max = 0.5, + alpha_min = 0.001, + alpha_smooth = true, + variable = density_pressure) +volume_integral = VolumeIntegralShockCapturingHG(indicator_sc; + volume_flux_dg = volume_flux, + volume_flux_fv = surface_flux) +solver = DGSEM(basis, surface_flux, volume_integral) + +coordinates_min = -2.0 +coordinates_max = 2.0 +mesh = TreeMesh(coordinates_min, coordinates_max, + initial_refinement_level = 5, + n_cells_max = 10_000) + +semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) + +############################################################################### +# ODE solvers, callbacks etc. + +tspan = (0.0, 1.0) +ode = semidiscretize_gpu(semi, tspan) # from TrixiGPU.jl + +summary_callback = SummaryCallback() + +analysis_interval = 100 +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) + +alive_callback = AliveCallback(analysis_interval = analysis_interval) + +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) + +stepsize_callback = StepsizeCallback(cfl = 0.8) + +callbacks = CallbackSet(summary_callback, + analysis_callback, alive_callback, + save_solution, + stepsize_callback) + +############################################################################### +# run the simulation + +sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false), + dt = 1.0, # solve needs some value here but it will be overwritten by the stepsize_callback + save_everystep = false, callback = callbacks); +summary_callback() # print the timer summary diff --git a/examples/euler_shockcapturing_2d.jl b/examples/euler_shockcapturing_2d.jl new file mode 100644 index 0000000..ea8c9cc --- /dev/null +++ b/examples/euler_shockcapturing_2d.jl @@ -0,0 +1,64 @@ +using Trixi, TrixiGPU +using OrdinaryDiffEq + +# The example is taken from the Trixi.jl + +############################################################################### +# semidiscretization of the compressible Euler equations + +equations = CompressibleEulerEquations2D(1.4) + +initial_condition = initial_condition_weak_blast_wave + +surface_flux = flux_lax_friedrichs +volume_flux = flux_shima_etal +basis = LobattoLegendreBasis(3) +indicator_sc = IndicatorHennemannGassner(equations, basis, + alpha_max = 0.5, + alpha_min = 0.001, + alpha_smooth = true, + variable = density_pressure) +volume_integral = VolumeIntegralShockCapturingHG(indicator_sc; + volume_flux_dg = volume_flux, + volume_flux_fv = surface_flux) +solver = DGSEM(basis, surface_flux, volume_integral) + +coordinates_min = (-2.0, -2.0) +coordinates_max = (2.0, 2.0) +mesh = TreeMesh(coordinates_min, coordinates_max, + initial_refinement_level = 5, + n_cells_max = 10_000) + +semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) + +############################################################################### +# ODE solvers, callbacks etc. + +tspan = (0.0, 1.0) +ode = semidiscretize_gpu(semi, tspan) # from TrixiGPU.jl + +summary_callback = SummaryCallback() + +analysis_interval = 100 +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) + +alive_callback = AliveCallback(analysis_interval = analysis_interval) + +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) + +stepsize_callback = StepsizeCallback(cfl = 1.0) + +callbacks = CallbackSet(summary_callback, stepsize_callback, + save_solution, + analysis_callback, alive_callback) + +############################################################################### +# run the simulation + +sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false), + dt = 1.0, # solve needs some value here but it will be overwritten by the stepsize_callback + save_everystep = false, callback = callbacks); +summary_callback() # print the timer summary diff --git a/examples/euler_shockcapturing_3d.jl b/examples/euler_shockcapturing_3d.jl new file mode 100644 index 0000000..52f57d9 --- /dev/null +++ b/examples/euler_shockcapturing_3d.jl @@ -0,0 +1,67 @@ +using Trixi, TrixiGPU +using OrdinaryDiffEq + +# The example is taken from the Trixi.jl + +############################################################################### +# semidiscretization of the compressible Euler equations + +equations = CompressibleEulerEquations3D(1.4) + +initial_condition = initial_condition_weak_blast_wave + +surface_flux = flux_ranocha # OBS! Using a non-dissipative flux is only sensible to test EC, +# but not for real shock simulations +volume_flux = flux_ranocha +polydeg = 3 +basis = LobattoLegendreBasis(polydeg) +indicator_sc = IndicatorHennemannGassner(equations, basis, + alpha_max = 0.5, + alpha_min = 0.001, + alpha_smooth = true, + variable = density_pressure) +volume_integral = VolumeIntegralShockCapturingHG(indicator_sc; + volume_flux_dg = volume_flux, + volume_flux_fv = surface_flux) +solver = DGSEM(basis, surface_flux, volume_integral) + +coordinates_min = (-2.0, -2.0, -2.0) +coordinates_max = (2.0, 2.0, 2.0) +mesh = TreeMesh(coordinates_min, coordinates_max, + initial_refinement_level = 3, + n_cells_max = 100_000) + +semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) + +############################################################################### +# ODE solvers, callbacks etc. + +tspan = (0.0, 0.4) +ode = semidiscretize_gpu(semi, tspan) # from TrixiGPU.jl + +summary_callback = SummaryCallback() + +analysis_interval = 100 +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) + +alive_callback = AliveCallback(analysis_interval = analysis_interval) + +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) + +stepsize_callback = StepsizeCallback(cfl = 1.4) + +callbacks = CallbackSet(summary_callback, + analysis_callback, alive_callback, + save_solution, + stepsize_callback) + +############################################################################### +# run the simulation + +sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false), + dt = 1.0, # solve needs some value here but it will be overwritten by the stepsize_callback + save_everystep = false, callback = callbacks); +summary_callback() # print the timer summary diff --git a/examples/eulermulti_ec_1d.jl b/examples/eulermulti_ec_1d.jl new file mode 100644 index 0000000..98ef4f9 --- /dev/null +++ b/examples/eulermulti_ec_1d.jl @@ -0,0 +1,58 @@ +using Trixi, TrixiGPU +using OrdinaryDiffEq + +# The example is taken from the Trixi.jl + +############################################################################### +# semidiscretization of the compressible Euler multicomponent equations +equations = CompressibleEulerMulticomponentEquations1D(gammas = (1.4, 1.4, 1.4), + gas_constants = (0.4, 0.4, 0.4)) + +initial_condition = initial_condition_weak_blast_wave + +volume_flux = flux_ranocha +solver = DGSEM(polydeg = 3, surface_flux = flux_ranocha, + volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) + +coordinates_min = (-2.0,) +coordinates_max = (2.0,) +mesh = TreeMesh(coordinates_min, coordinates_max, + initial_refinement_level = 5, + n_cells_max = 10_000) + +semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) + +############################################################################### +# ODE solvers, callbacks etc. + +tspan = (0.0, 0.4) +ode = semidiscretize_gpu(semi, tspan) # from TrixiGPU.jl + +summary_callback = SummaryCallback() + +analysis_interval = 100 + +analysis_callback = AnalysisCallback(semi, interval = analysis_interval, + extra_analysis_integrals = (Trixi.density,)) + +alive_callback = AliveCallback(analysis_interval = analysis_interval) + +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) + +stepsize_callback = StepsizeCallback(cfl = 0.8) + +callbacks = CallbackSet(summary_callback, + analysis_callback, alive_callback, + save_solution, + stepsize_callback) + +############################################################################### +# run the simulation + +sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false), + dt = 1.0, # solve needs some value here but it will be overwritten by the stepsize_callback + save_everystep = false, callback = callbacks); +summary_callback() # print the timer summary diff --git a/examples/eulermulti_ec_2d.jl b/examples/eulermulti_ec_2d.jl new file mode 100644 index 0000000..ad28a1c --- /dev/null +++ b/examples/eulermulti_ec_2d.jl @@ -0,0 +1,58 @@ +using Trixi, TrixiGPU +using OrdinaryDiffEq + +# The example is taken from the Trixi.jl + +############################################################################### +# semidiscretization of the compressible Euler multicomponent equations +equations = CompressibleEulerMulticomponentEquations2D(gammas = 1.4, + gas_constants = 0.4) + +initial_condition = initial_condition_weak_blast_wave + +volume_flux = flux_ranocha +solver = DGSEM(polydeg = 3, surface_flux = flux_ranocha, + volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) + +coordinates_min = (-2.0, -2.0) +coordinates_max = (2.0, 2.0) +mesh = TreeMesh(coordinates_min, coordinates_max, + initial_refinement_level = 5, + n_cells_max = 10_000) + +semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) + +############################################################################### +# ODE solvers, callbacks etc. + +tspan = (0.0, 0.4) +ode = semidiscretize_gpu(semi, tspan) # from TrixiGPU.jl + +summary_callback = SummaryCallback() + +analysis_interval = 100 + +analysis_callback = AnalysisCallback(semi, interval = analysis_interval, + extra_analysis_integrals = (Trixi.density,)) + +alive_callback = AliveCallback(analysis_interval = analysis_interval) + +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) + +stepsize_callback = StepsizeCallback(cfl = 1.0) + +callbacks = CallbackSet(summary_callback, + analysis_callback, alive_callback, + save_solution, + stepsize_callback) + +############################################################################### +# run the simulation + +sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false), + dt = 1.0, # solve needs some value here but it will be overwritten by the stepsize_callback + save_everystep = false, callback = callbacks); +summary_callback() # print the timer summary diff --git a/examples/shallowwater_dirichlet_1d.jl b/examples/shallowwater_dirichlet_1d.jl new file mode 100644 index 0000000..276f002 --- /dev/null +++ b/examples/shallowwater_dirichlet_1d.jl @@ -0,0 +1,79 @@ +using Trixi, TrixiGPU +using OrdinaryDiffEq + +# The example is taken from the Trixi.jl + +############################################################################### +# Semidiscretization of the shallow water equations + +equations = ShallowWaterEquations1D(gravity_constant = 1.0, H0 = 3.0) + +# An initial condition with constant total water height and zero velocities to test well-balancedness. +function initial_condition_well_balancedness(x, t, equations::ShallowWaterEquations1D) + # Set the background values + H = equations.H0 + v = 0.0 + + b = (1.5 / exp(0.5 * ((x[1] - 1.0)^2)) + 0.75 / exp(0.5 * ((x[1] + 1.0)^2))) + + return prim2cons(SVector(H, v, b), equations) +end + +initial_condition = initial_condition_well_balancedness + +boundary_condition = BoundaryConditionDirichlet(initial_condition) + +############################################################################### +# Get the DG approximation space + +volume_flux = (flux_wintermeyer_etal, flux_nonconservative_wintermeyer_etal) +solver = DGSEM(polydeg = 4, + surface_flux = (flux_hll, + flux_nonconservative_fjordholm_etal), + volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) + +############################################################################### +# Get the TreeMesh and setup a periodic mesh + +coordinates_min = 0.0 +coordinates_max = sqrt(2.0) +mesh = TreeMesh(coordinates_min, coordinates_max, + initial_refinement_level = 3, + n_cells_max = 10_000, + periodicity = false) + +# create the semi discretization object +semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, + boundary_conditions = boundary_condition) + +############################################################################### +# ODE solvers, callbacks etc. + +tspan = (0.0, 100.0) +ode = semidiscretize_gpu(semi, tspan) # from TrixiGPU.jl + +summary_callback = SummaryCallback() + +analysis_interval = 1000 +analysis_callback = AnalysisCallback(semi, interval = analysis_interval, + save_analysis = true, + extra_analysis_integrals = (lake_at_rest_error,)) + +alive_callback = AliveCallback(analysis_interval = analysis_interval) + +save_solution = SaveSolutionCallback(interval = 1000, + save_initial_solution = true, + save_final_solution = true) + +stepsize_callback = StepsizeCallback(cfl = 1.0) + +callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, save_solution, + stepsize_callback) + +############################################################################### +# run the simulation + +sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false), + dt = 1.0, # solve needs some value here but it will be overwritten by the stepsize_callback + save_everystep = false, callback = callbacks); +summary_callback() # print the timer summary diff --git a/examples/shallowwater_dirichlet_2d.jl b/examples/shallowwater_dirichlet_2d.jl new file mode 100644 index 0000000..f3e02e2 --- /dev/null +++ b/examples/shallowwater_dirichlet_2d.jl @@ -0,0 +1,63 @@ +using Trixi, TrixiGPU +using OrdinaryDiffEq + +# The example is taken from the Trixi.jl + +############################################################################### +# Semidiscretization of the shallow water equations + +equations = ShallowWaterEquations2D(gravity_constant = 9.81) + +initial_condition = initial_condition_convergence_test + +boundary_condition = BoundaryConditionDirichlet(initial_condition) + +############################################################################### +# Get the DG approximation space + +volume_flux = (flux_wintermeyer_etal, flux_nonconservative_wintermeyer_etal) +solver = DGSEM(polydeg = 3, + surface_flux = (flux_lax_friedrichs, flux_nonconservative_fjordholm_etal), + volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) + +############################################################################### +# Get the TreeMesh and setup a periodic mesh + +coordinates_min = (0.0, 0.0) +coordinates_max = (sqrt(2.0), sqrt(2.0)) +mesh = TreeMesh(coordinates_min, coordinates_max, + initial_refinement_level = 3, + n_cells_max = 10_000, + periodicity = false) + +# create the semi discretization object +semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, + boundary_conditions = boundary_condition, + source_terms = source_terms_convergence_test) + +############################################################################### +# ODE solvers, callbacks etc. + +tspan = (0.0, 1.0) +ode = semidiscretize_gpu(semi, tspan) # from TrixiGPU.jl + +summary_callback = SummaryCallback() + +analysis_interval = 500 +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) + +alive_callback = AliveCallback(analysis_interval = analysis_interval) + +save_solution = SaveSolutionCallback(interval = 200, + save_initial_solution = true, + save_final_solution = true) + +callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, save_solution) + +############################################################################### +# run the simulation + +# use a Runge-Kutta method with automatic (error based) time step size control +sol = solve(ode, RDPK3SpFSAL49(); abstol = 1.0e-8, reltol = 1.0e-8, + ode_default_options()..., callback = callbacks); +summary_callback() # print the timer summary diff --git a/examples/shallowwater_ec_1d.jl b/examples/shallowwater_ec_1d.jl new file mode 100644 index 0000000..c3cbd27 --- /dev/null +++ b/examples/shallowwater_ec_1d.jl @@ -0,0 +1,95 @@ +using Trixi, TrixiGPU +using OrdinaryDiffEq + +# The example is taken from the Trixi.jl + +using OrdinaryDiffEq +using Trixi + +############################################################################### +# Semidiscretization of the shallow water equations with a discontinuous +# bottom topography function + +equations = ShallowWaterEquations1D(gravity_constant = 9.81) + +# Initial condition with a truly discontinuous water height, velocity, and bottom +# topography function as an academic testcase for entropy conservation. +# The errors from the analysis callback are not important but `∑∂S/∂U ⋅ Uₜ` should +# be around machine roundoff. +# Works as intended for TreeMesh1D with `initial_refinement_level=4`. If the mesh +# refinement level is changed the initial condition below may need changed as well to +# ensure that the discontinuities lie on an element interface. +function initial_condition_ec_discontinuous_bottom(x, t, equations::ShallowWaterEquations1D) + # Set the background values + H = 4.25 + v = 0.0 + b = sin(x[1]) # arbitrary continuous function + + # Setup the discontinuous water height and velocity + if x[1] >= 0.125 && x[1] <= 0.25 + H = 5.0 + v = 0.1882 + end + + # Setup a discontinuous bottom topography + if x[1] >= -0.25 && x[1] <= -0.125 + b = 2.0 + 0.5 * sin(2.0 * pi * x[1]) + end + + return prim2cons(SVector(H, v, b), equations) +end + +initial_condition = initial_condition_ec_discontinuous_bottom + +############################################################################### +# Get the DG approximation space + +volume_flux = (flux_wintermeyer_etal, flux_nonconservative_wintermeyer_etal) +solver = DGSEM(polydeg = 4, + surface_flux = (flux_fjordholm_etal, flux_nonconservative_fjordholm_etal), + volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) + +############################################################################### +# Get the TreeMesh and setup a periodic mesh + +coordinates_min = -1.0 +coordinates_max = 1.0 +mesh = TreeMesh(coordinates_min, coordinates_max, + initial_refinement_level = 4, + n_cells_max = 10_000) + +# Create the semi discretization object +semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) + +############################################################################### +# ODE solver + +tspan = (0.0, 2.0) +ode = semidiscretize_gpu(semi, tspan) # from TrixiGPU.jl + +############################################################################### +# Callbacks + +summary_callback = SummaryCallback() + +analysis_interval = 100 +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) + +alive_callback = AliveCallback(analysis_interval = analysis_interval) + +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true) + +stepsize_callback = StepsizeCallback(cfl = 1.0) + +callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, save_solution, + stepsize_callback) + +############################################################################### +# run the simulation + +sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false), + dt = 1.0, # solve needs some value here but it will be overwritten by the stepsize_callback + save_everystep = false, callback = callbacks); +summary_callback() # print the timer summary diff --git a/examples/shallowwater_ec_2d.jl b/examples/shallowwater_ec_2d.jl new file mode 100644 index 0000000..9853a51 --- /dev/null +++ b/examples/shallowwater_ec_2d.jl @@ -0,0 +1,120 @@ +using Trixi, TrixiGPU +using OrdinaryDiffEq + +# The example is taken from the Trixi.jl + +############################################################################### +# semidiscretization of the shallow water equations with a discontinuous +# bottom topography function + +equations = ShallowWaterEquations2D(gravity_constant = 9.81) + +# Note, this initial condition is used to compute errors in the analysis callback but the initialization is +# overwritten by `initial_condition_ec_discontinuous_bottom` below. +initial_condition = initial_condition_weak_blast_wave + +############################################################################### +# Get the DG approximation space + +volume_flux = (flux_wintermeyer_etal, flux_nonconservative_wintermeyer_etal) +solver = DGSEM(polydeg = 4, + surface_flux = (flux_fjordholm_etal, flux_nonconservative_fjordholm_etal), + volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) + +############################################################################### +# Get the TreeMesh and setup a periodic mesh + +coordinates_min = (-1.0, -1.0) +coordinates_max = (1.0, 1.0) +mesh = TreeMesh(coordinates_min, coordinates_max, + initial_refinement_level = 2, + n_cells_max = 10_000) + +# Create the semi discretization object +semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) + +############################################################################### +# ODE solver + +tspan = (0.0, 2.0) +ode = semidiscretize_gpu(semi, tspan) # from TrixiGPU.jl + +############################################################################### +# Workaround to set a discontinuous bottom topography and initial condition for debugging and testing. + +# alternative version of the initial conditinon used to setup a truly discontinuous +# bottom topography function and initial condition for this academic testcase of entropy conservation. +# The errors from the analysis callback are not important but `∑∂S/∂U ⋅ Uₜ` should be around machine roundoff +# In contrast to the usual signature of initial conditions, this one get passed the +# `element_id` explicitly. In particular, this initial conditions works as intended +# only for the TreeMesh2D with initial_refinement_level=2. +function initial_condition_ec_discontinuous_bottom(x, t, element_id, + equations::ShallowWaterEquations2D) + # Set up polar coordinates + inicenter = SVector(0.7, 0.7) + x_norm = x[1] - inicenter[1] + y_norm = x[2] - inicenter[2] + r = sqrt(x_norm^2 + y_norm^2) + phi = atan(y_norm, x_norm) + sin_phi, cos_phi = sincos(phi) + + # Set the background values + H = 4.25 + v1 = 0.0 + v2 = 0.0 + b = 0.0 + + # setup the discontinuous water height and velocities + if element_id == 10 + H = 5.0 + v1 = 0.1882 * cos_phi + v2 = 0.1882 * sin_phi + end + + # Setup a discontinuous bottom topography using the element id number + if element_id == 7 + b = 2.0 + 0.5 * sin(2.0 * pi * x[1]) + 0.5 * cos(2.0 * pi * x[2]) + end + + return prim2cons(SVector(H, v1, v2, b), equations) +end + +# point to the data we want to augment +u = Trixi.wrap_array(ode.u0, semi) +# reset the initial condition +for element in eachelement(semi.solver, semi.cache) + for j in eachnode(semi.solver), i in eachnode(semi.solver) + x_node = Trixi.get_node_coords(semi.cache.elements.node_coordinates, equations, + semi.solver, i, j, element) + u_node = initial_condition_ec_discontinuous_bottom(x_node, first(tspan), element, + equations) + Trixi.set_node_vars!(u, u_node, equations, semi.solver, i, j, element) + end +end + +############################################################################### +# Callbacks + +summary_callback = SummaryCallback() + +analysis_interval = 100 +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) + +alive_callback = AliveCallback(analysis_interval = analysis_interval) + +save_solution = SaveSolutionCallback(dt = 0.2, + save_initial_solution = true, + save_final_solution = true) + +stepsize_callback = StepsizeCallback(cfl = 1.0) + +callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, save_solution, + stepsize_callback) + +############################################################################### +# run the simulation + +sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false), + dt = 1.0, # solve needs some value here but it will be overwritten by the stepsize_callback + save_everystep = false, callback = callbacks); +summary_callback() # print the timer summary diff --git a/examples/shallowwater_source_terms_1d.jl b/examples/shallowwater_source_terms_1d.jl new file mode 100644 index 0000000..9cc384e --- /dev/null +++ b/examples/shallowwater_source_terms_1d.jl @@ -0,0 +1,60 @@ +using Trixi, TrixiGPU +using OrdinaryDiffEq + +# The example is taken from the Trixi.jl + +############################################################################### +# Semidiscretization of the shallow water equations + +equations = ShallowWaterEquations1D(gravity_constant = 9.81) + +initial_condition = initial_condition_convergence_test + +############################################################################### +# Get the DG approximation space + +volume_flux = (flux_wintermeyer_etal, flux_nonconservative_wintermeyer_etal) +solver = DGSEM(polydeg = 3, + surface_flux = (flux_lax_friedrichs, flux_nonconservative_fjordholm_etal), + volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) + +############################################################################### +# Get the TreeMesh and setup a periodic mesh + +coordinates_min = 0.0 +coordinates_max = sqrt(2.0) +mesh = TreeMesh(coordinates_min, coordinates_max, + initial_refinement_level = 3, + n_cells_max = 10_000, + periodicity = true) + +# create the semi discretization object +semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, + source_terms = source_terms_convergence_test) + +############################################################################### +# ODE solvers, callbacks etc. + +tspan = (0.0, 1.0) +ode = semidiscretize_gpu(semi, tspan) # from TrixiGPU.jl + +summary_callback = SummaryCallback() + +analysis_interval = 500 +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) + +alive_callback = AliveCallback(analysis_interval = analysis_interval) + +save_solution = SaveSolutionCallback(interval = 200, + save_initial_solution = true, + save_final_solution = true) + +callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, save_solution) + +############################################################################### +# run the simulation + +# use a Runge-Kutta method with automatic (error based) time step size control +sol = solve(ode, RDPK3SpFSAL49(); abstol = 1.0e-8, reltol = 1.0e-8, + ode_default_options()..., callback = callbacks); +summary_callback() # print the timer summary diff --git a/examples/shallowwater_source_terms_2d.jl b/examples/shallowwater_source_terms_2d.jl new file mode 100644 index 0000000..a2145c7 --- /dev/null +++ b/examples/shallowwater_source_terms_2d.jl @@ -0,0 +1,60 @@ +using Trixi, TrixiGPU +using OrdinaryDiffEq + +# The example is taken from the Trixi.jl + +############################################################################### +# semidiscretization of the shallow water equations + +equations = ShallowWaterEquations2D(gravity_constant = 9.81) + +initial_condition = initial_condition_convergence_test # MMS EOC test + +############################################################################### +# Get the DG approximation space + +volume_flux = (flux_wintermeyer_etal, flux_nonconservative_wintermeyer_etal) +solver = DGSEM(polydeg = 3, + surface_flux = (flux_lax_friedrichs, flux_nonconservative_fjordholm_etal), + volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) + +############################################################################### +# Get the TreeMesh and setup a periodic mesh + +coordinates_min = (0.0, 0.0) +coordinates_max = (sqrt(2.0), sqrt(2.0)) +mesh = TreeMesh(coordinates_min, coordinates_max, + initial_refinement_level = 3, + n_cells_max = 10_000, + periodicity = true) + +# create the semi discretization object +semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, + source_terms = source_terms_convergence_test) + +############################################################################### +# ODE solvers, callbacks etc. + +tspan = (0.0, 1.0) +ode = semidiscretize_gpu(semi, tspan) # from TrixiGPU.jl + +summary_callback = SummaryCallback() + +analysis_interval = 500 +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) + +alive_callback = AliveCallback(analysis_interval = analysis_interval) + +save_solution = SaveSolutionCallback(interval = 200, + save_initial_solution = true, + save_final_solution = true) + +callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, save_solution) + +############################################################################### +# run the simulation + +# use a Runge-Kutta method with automatic (error based) time step size control +sol = solve(ode, RDPK3SpFSAL49(); abstol = 1.0e-8, reltol = 1.0e-8, + ode_default_options()..., callback = callbacks); +summary_callback() # print the timer summary diff --git a/test/test_shallowwater_nonperiodic.jl b/test/test_shallowwater_dirichlet.jl similarity index 100% rename from test/test_shallowwater_nonperiodic.jl rename to test/test_shallowwater_dirichlet.jl diff --git a/typos.toml b/typos.toml new file mode 100644 index 0000000..e3e12b9 --- /dev/null +++ b/typos.toml @@ -0,0 +1,4 @@ +[files] +extend-exclude = [ + "docs/dev_env_info.md" +]