From 8f5adc13f107a04e79d4e112009a598f5bf20df6 Mon Sep 17 00:00:00 2001 From: huiyuxie Date: Mon, 23 Sep 2024 12:24:39 -1000 Subject: [PATCH] Rename API --- README.md | 2 +- examples/advection_basic_1d.jl | 2 +- examples/advection_basic_2d.jl | 2 +- examples/advection_basic_3d.jl | 2 +- examples/advection_mortar_2d.jl | 2 +- examples/advection_mortar_3d.jl | 2 +- examples/euler_ec_1d.jl | 2 +- examples/euler_ec_2d.jl | 2 +- examples/euler_ec_3d.jl | 2 +- examples/euler_shockcapturing_1d.jl | 2 +- examples/euler_shockcapturing_2d.jl | 2 +- examples/euler_shockcapturing_3d.jl | 2 +- examples/euler_source_terms_1d.jl | 2 +- examples/euler_source_terms_2d.jl | 2 +- examples/euler_source_terms_3d.jl | 2 +- examples/eulermulti_ec_1d.jl | 2 +- examples/eulermulti_ec_2d.jl | 2 +- examples/hypdiff_nonperiodic_1d.jl | 2 +- examples/hypdiff_nonperiodic_2d.jl | 2 +- examples/hypdiff_nonperiodic_3d.jl | 2 +- examples/shallowwater_dirichlet_1d.jl | 2 +- examples/shallowwater_dirichlet_2d.jl | 2 +- examples/shallowwater_ec_1d.jl | 2 +- examples/shallowwater_ec_2d.jl | 2 +- examples/shallowwater_source_terms_1d.jl | 2 +- examples/shallowwater_source_terms_2d.jl | 2 +- src/TrixiCUDA.jl | 4 +++- .../semidiscretization_hyperbolic.jl | 14 +++++++------- src/solvers/solvers.jl | 2 +- test/test_script.jl | 4 ++-- 30 files changed, 39 insertions(+), 37 deletions(-) diff --git a/README.md b/README.md index 43f6548..e21c7cd 100644 --- a/README.md +++ b/README.md @@ -77,7 +77,7 @@ semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition_convergen ############################################################################### # ODE solvers, callbacks etc. -ode = semidiscretize_gpu(semi, (0.0, 1.0)) # from TrixiCUDA.jl +ode = semidiscretizeGPU(semi, (0.0, 1.0)) # from TrixiCUDA.jl summary_callback = SummaryCallback() diff --git a/examples/advection_basic_1d.jl b/examples/advection_basic_1d.jl index 2a31644..6de0fda 100644 --- a/examples/advection_basic_1d.jl +++ b/examples/advection_basic_1d.jl @@ -28,7 +28,7 @@ semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition_convergen # ODE solvers, callbacks etc. # Create ODE problem with time span from 0.0 to 1.0 -ode = semidiscretize_gpu(semi, (0.0, 1.0)) # from TrixiCUDA.jl +ode = semidiscretizeGPU(semi, (0.0, 1.0)) # from TrixiCUDA.jl # At the beginning of the main loop, the SummaryCallback prints a summary of the simulation setup # and resets the timers diff --git a/examples/advection_basic_2d.jl b/examples/advection_basic_2d.jl index 5e7b098..e9b6b0f 100644 --- a/examples/advection_basic_2d.jl +++ b/examples/advection_basic_2d.jl @@ -28,7 +28,7 @@ semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition_convergen # ODE solvers, callbacks etc. # Create ODE problem with time span from 0.0 to 1.0 -ode = semidiscretize_gpu(semi, (0.0, 1.0)) # from TrixiCUDA.jl +ode = semidiscretizeGPU(semi, (0.0, 1.0)) # from TrixiCUDA.jl # At the beginning of the main loop, the SummaryCallback prints a summary of the simulation setup # and resets the timers diff --git a/examples/advection_basic_3d.jl b/examples/advection_basic_3d.jl index e716835..c0962f9 100644 --- a/examples/advection_basic_3d.jl +++ b/examples/advection_basic_3d.jl @@ -28,7 +28,7 @@ semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition_convergen # ODE solvers, callbacks etc. # Create ODE problem with time span from 0.0 to 1.0 -ode = semidiscretize_gpu(semi, (0.0, 1.0)) # from TrixiCUDA.jl +ode = semidiscretizeGPU(semi, (0.0, 1.0)) # from TrixiCUDA.jl # At the beginning of the main loop, the SummaryCallback prints a summary of the simulation setup # and resets the timers diff --git a/examples/advection_mortar_2d.jl b/examples/advection_mortar_2d.jl index 4c17a51..e18e8a3 100644 --- a/examples/advection_mortar_2d.jl +++ b/examples/advection_mortar_2d.jl @@ -27,7 +27,7 @@ semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) # ODE solvers, callbacks etc. tspan = (0.0, 1.0) -ode = semidiscretize_gpu(semi, tspan) # from TrixiCUDA.jl +ode = semidiscretizeGPU(semi, tspan) # from TrixiCUDA.jl summary_callback = SummaryCallback() diff --git a/examples/advection_mortar_3d.jl b/examples/advection_mortar_3d.jl index 2c7c71f..1de239e 100644 --- a/examples/advection_mortar_3d.jl +++ b/examples/advection_mortar_3d.jl @@ -30,7 +30,7 @@ semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) # ODE solvers, callbacks etc. tspan = (0.0, 5.0) -ode = semidiscretize_gpu(semi, tspan) # from TrixiCUDA.jl +ode = semidiscretizeGPU(semi, tspan) # from TrixiCUDA.jl summary_callback = SummaryCallback() diff --git a/examples/euler_ec_1d.jl b/examples/euler_ec_1d.jl index 5a32374..b00045d 100644 --- a/examples/euler_ec_1d.jl +++ b/examples/euler_ec_1d.jl @@ -25,7 +25,7 @@ semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) # ODE solvers, callbacks etc. tspan = (0.0, 0.4) -ode = semidiscretize_gpu(semi, tspan) # from TrixiCUDA.jl +ode = semidiscretizeGPU(semi, tspan) # from TrixiCUDA.jl summary_callback = SummaryCallback() diff --git a/examples/euler_ec_2d.jl b/examples/euler_ec_2d.jl index 1dab39e..b90b48c 100644 --- a/examples/euler_ec_2d.jl +++ b/examples/euler_ec_2d.jl @@ -27,7 +27,7 @@ semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, # ODE solvers, callbacks etc. tspan = (0.0, 0.4) -ode = semidiscretize_gpu(semi, tspan) # from TrixiCUDA.jl +ode = semidiscretizeGPU(semi, tspan) # from TrixiCUDA.jl summary_callback = SummaryCallback() diff --git a/examples/euler_ec_3d.jl b/examples/euler_ec_3d.jl index 70c118e..9894557 100644 --- a/examples/euler_ec_3d.jl +++ b/examples/euler_ec_3d.jl @@ -26,7 +26,7 @@ semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) # ODE solvers, callbacks etc. tspan = (0.0, 0.4) -ode = semidiscretize_gpu(semi, tspan) # from TrixiCUDA.jl +ode = semidiscretizeGPU(semi, tspan) # from TrixiCUDA.jl summary_callback = SummaryCallback() diff --git a/examples/euler_shockcapturing_1d.jl b/examples/euler_shockcapturing_1d.jl index 03db761..bf7fb1b 100644 --- a/examples/euler_shockcapturing_1d.jl +++ b/examples/euler_shockcapturing_1d.jl @@ -35,7 +35,7 @@ semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) # ODE solvers, callbacks etc. tspan = (0.0, 1.0) -ode = semidiscretize_gpu(semi, tspan) # from TrixiCUDA.jl +ode = semidiscretizeGPU(semi, tspan) # from TrixiCUDA.jl summary_callback = SummaryCallback() diff --git a/examples/euler_shockcapturing_2d.jl b/examples/euler_shockcapturing_2d.jl index 2eae8ed..8da8c79 100644 --- a/examples/euler_shockcapturing_2d.jl +++ b/examples/euler_shockcapturing_2d.jl @@ -35,7 +35,7 @@ semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) # ODE solvers, callbacks etc. tspan = (0.0, 1.0) -ode = semidiscretize_gpu(semi, tspan) # from TrixiCUDA.jl +ode = semidiscretizeGPU(semi, tspan) # from TrixiCUDA.jl summary_callback = SummaryCallback() diff --git a/examples/euler_shockcapturing_3d.jl b/examples/euler_shockcapturing_3d.jl index 457105e..fef1328 100644 --- a/examples/euler_shockcapturing_3d.jl +++ b/examples/euler_shockcapturing_3d.jl @@ -37,7 +37,7 @@ semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) # ODE solvers, callbacks etc. tspan = (0.0, 0.4) -ode = semidiscretize_gpu(semi, tspan) # from TrixiCUDA.jl +ode = semidiscretizeGPU(semi, tspan) # from TrixiCUDA.jl summary_callback = SummaryCallback() diff --git a/examples/euler_source_terms_1d.jl b/examples/euler_source_terms_1d.jl index 8389c7a..e4ef214 100644 --- a/examples/euler_source_terms_1d.jl +++ b/examples/euler_source_terms_1d.jl @@ -27,7 +27,7 @@ semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, # ODE solvers, callbacks etc. tspan = (0.0, 2.0) -ode = semidiscretize_gpu(semi, tspan) # from TrixiCUDA.jl +ode = semidiscretizeGPU(semi, tspan) # from TrixiCUDA.jl summary_callback = SummaryCallback() diff --git a/examples/euler_source_terms_2d.jl b/examples/euler_source_terms_2d.jl index e28153c..fe02312 100644 --- a/examples/euler_source_terms_2d.jl +++ b/examples/euler_source_terms_2d.jl @@ -24,7 +24,7 @@ semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, # ODE solvers, callbacks etc. tspan = (0.0, 2.0) -ode = semidiscretize_gpu(semi, tspan) # from TrixiCUDA.jl +ode = semidiscretizeGPU(semi, tspan) # from TrixiCUDA.jl summary_callback = SummaryCallback() diff --git a/examples/euler_source_terms_3d.jl b/examples/euler_source_terms_3d.jl index b6a403c..c3fac7b 100644 --- a/examples/euler_source_terms_3d.jl +++ b/examples/euler_source_terms_3d.jl @@ -26,7 +26,7 @@ semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, # ODE solvers, callbacks etc. tspan = (0.0, 5.0) -ode = semidiscretize_gpu(semi, tspan) # from TrixiCUDA.jl +ode = semidiscretizeGPU(semi, tspan) # from TrixiCUDA.jl summary_callback = SummaryCallback() diff --git a/examples/eulermulti_ec_1d.jl b/examples/eulermulti_ec_1d.jl index 03fd861..498692e 100644 --- a/examples/eulermulti_ec_1d.jl +++ b/examples/eulermulti_ec_1d.jl @@ -26,7 +26,7 @@ semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) # ODE solvers, callbacks etc. tspan = (0.0, 0.4) -ode = semidiscretize_gpu(semi, tspan) # from TrixiCUDA.jl +ode = semidiscretizeGPU(semi, tspan) # from TrixiCUDA.jl summary_callback = SummaryCallback() diff --git a/examples/eulermulti_ec_2d.jl b/examples/eulermulti_ec_2d.jl index 0db5c01..55b4e03 100644 --- a/examples/eulermulti_ec_2d.jl +++ b/examples/eulermulti_ec_2d.jl @@ -26,7 +26,7 @@ semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) # ODE solvers, callbacks etc. tspan = (0.0, 0.4) -ode = semidiscretize_gpu(semi, tspan) # from TrixiCUDA.jl +ode = semidiscretizeGPU(semi, tspan) # from TrixiCUDA.jl summary_callback = SummaryCallback() diff --git a/examples/hypdiff_nonperiodic_1d.jl b/examples/hypdiff_nonperiodic_1d.jl index b4b1b58..b418676 100644 --- a/examples/hypdiff_nonperiodic_1d.jl +++ b/examples/hypdiff_nonperiodic_1d.jl @@ -29,7 +29,7 @@ semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, # ODE solvers, callbacks etc. tspan = (0.0, 5.0) -ode = semidiscretize_gpu(semi, tspan) # from TrixiCUDA.jl +ode = semidiscretizeGPU(semi, tspan) # from TrixiCUDA.jl summary_callback = SummaryCallback() diff --git a/examples/hypdiff_nonperiodic_2d.jl b/examples/hypdiff_nonperiodic_2d.jl index 622e5e2..a47f44c 100644 --- a/examples/hypdiff_nonperiodic_2d.jl +++ b/examples/hypdiff_nonperiodic_2d.jl @@ -32,7 +32,7 @@ semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, # ODE solvers, callbacks etc. tspan = (0.0, 5.0) -ode = semidiscretize_gpu(semi, tspan) # from TrixiCUDA.jl +ode = semidiscretizeGPU(semi, tspan) # from TrixiCUDA.jl summary_callback = SummaryCallback() diff --git a/examples/hypdiff_nonperiodic_3d.jl b/examples/hypdiff_nonperiodic_3d.jl index 03afb06..f19e364 100644 --- a/examples/hypdiff_nonperiodic_3d.jl +++ b/examples/hypdiff_nonperiodic_3d.jl @@ -33,7 +33,7 @@ semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, # ODE solvers, callbacks etc. tspan = (0.0, 5.0) -ode = semidiscretize_gpu(semi, tspan) # from TrixiCUDA.jl +ode = semidiscretizeGPU(semi, tspan) # from TrixiCUDA.jl summary_callback = SummaryCallback() diff --git a/examples/shallowwater_dirichlet_1d.jl b/examples/shallowwater_dirichlet_1d.jl index 609287a..bd78b0b 100644 --- a/examples/shallowwater_dirichlet_1d.jl +++ b/examples/shallowwater_dirichlet_1d.jl @@ -39,7 +39,7 @@ semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, # ODE solvers, callbacks etc. tspan = (0.0, 1.0) -ode = semidiscretize_gpu(semi, tspan) # from TrixiCUDA.jl +ode = semidiscretizeGPU(semi, tspan) # from TrixiCUDA.jl summary_callback = SummaryCallback() diff --git a/examples/shallowwater_dirichlet_2d.jl b/examples/shallowwater_dirichlet_2d.jl index baedfdf..f79c478 100644 --- a/examples/shallowwater_dirichlet_2d.jl +++ b/examples/shallowwater_dirichlet_2d.jl @@ -39,7 +39,7 @@ semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, # ODE solvers, callbacks etc. tspan = (0.0, 1.0) -ode = semidiscretize_gpu(semi, tspan) # from TrixiCUDA.jl +ode = semidiscretizeGPU(semi, tspan) # from TrixiCUDA.jl summary_callback = SummaryCallback() diff --git a/examples/shallowwater_ec_1d.jl b/examples/shallowwater_ec_1d.jl index c06d6fb..6fba164 100644 --- a/examples/shallowwater_ec_1d.jl +++ b/examples/shallowwater_ec_1d.jl @@ -65,7 +65,7 @@ semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) # ODE solver tspan = (0.0, 2.0) -ode = semidiscretize_gpu(semi, tspan) # from TrixiCUDA.jl +ode = semidiscretizeGPU(semi, tspan) # from TrixiCUDA.jl ############################################################################### # Callbacks diff --git a/examples/shallowwater_ec_2d.jl b/examples/shallowwater_ec_2d.jl index fa60e2a..3116031 100644 --- a/examples/shallowwater_ec_2d.jl +++ b/examples/shallowwater_ec_2d.jl @@ -37,7 +37,7 @@ semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) # ODE solver tspan = (0.0, 2.0) -ode = semidiscretize_gpu(semi, tspan) # from TrixiCUDA.jl +ode = semidiscretizeGPU(semi, tspan) # from TrixiCUDA.jl ############################################################################### # Workaround to set a discontinuous bottom topography and initial condition for debugging and testing. diff --git a/examples/shallowwater_source_terms_1d.jl b/examples/shallowwater_source_terms_1d.jl index fc1ba40..b00faca 100644 --- a/examples/shallowwater_source_terms_1d.jl +++ b/examples/shallowwater_source_terms_1d.jl @@ -36,7 +36,7 @@ semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, # ODE solvers, callbacks etc. tspan = (0.0, 1.0) -ode = semidiscretize_gpu(semi, tspan) # from TrixiCUDA.jl +ode = semidiscretizeGPU(semi, tspan) # from TrixiCUDA.jl summary_callback = SummaryCallback() diff --git a/examples/shallowwater_source_terms_2d.jl b/examples/shallowwater_source_terms_2d.jl index 272c5cd..78c24bd 100644 --- a/examples/shallowwater_source_terms_2d.jl +++ b/examples/shallowwater_source_terms_2d.jl @@ -36,7 +36,7 @@ semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, # ODE solvers, callbacks etc. tspan = (0.0, 1.0) -ode = semidiscretize_gpu(semi, tspan) # from TrixiCUDA.jl +ode = semidiscretizeGPU(semi, tspan) # from TrixiCUDA.jl summary_callback = SummaryCallback() diff --git a/src/TrixiCUDA.jl b/src/TrixiCUDA.jl index dcdb717..8104442 100644 --- a/src/TrixiCUDA.jl +++ b/src/TrixiCUDA.jl @@ -28,10 +28,12 @@ include("auxiliary/auxiliary.jl") include("semidiscretization/semidiscretization.jl") include("solvers/solvers.jl") +# Change to use the Base.log and Base.sqrt - need to be fixed to avoid outputs set_log_type!("log_Base") set_sqrt_type!("sqrt_Base") # Export the public APIs -export semidiscretize_gpu +export SemidiscretizationHyperbolicGPU +export semidiscretizeGPU end diff --git a/src/semidiscretization/semidiscretization_hyperbolic.jl b/src/semidiscretization/semidiscretization_hyperbolic.jl index 9f9008a..593c74b 100644 --- a/src/semidiscretization/semidiscretization_hyperbolic.jl +++ b/src/semidiscretization/semidiscretization_hyperbolic.jl @@ -1,10 +1,10 @@ -function SemidiscretizationHyperbolic_gpu(mesh, equations, initial_condition, solver; - source_terms = nothing, - boundary_conditions = boundary_condition_periodic, - # `RealT` is used as real type for node locations etc. - # while `uEltype` is used as element type of solutions etc. - RealT = real(solver), uEltype = RealT, - initial_cache = NamedTuple()) +function SemidiscretizationHyperbolicGPU(mesh, equations, initial_condition, solver; + source_terms = nothing, + boundary_conditions = boundary_condition_periodic, + # `RealT` is used as real type for node locations etc. + # while `uEltype` is used as element type of solutions etc. + RealT = real(solver), uEltype = RealT, + initial_cache = NamedTuple()) @assert ndims(mesh) == ndims(equations) # cache = (; create_cache(mesh, equations, solver, RealT, uEltype)..., diff --git a/src/solvers/solvers.jl b/src/solvers/solvers.jl index e6afb1c..a23c178 100644 --- a/src/solvers/solvers.jl +++ b/src/solvers/solvers.jl @@ -17,7 +17,7 @@ function rhs_gpu!(du_ode, u_ode, semi::SemidiscretizationHyperbolic, t) end # Ref: `semidiscretize` function in Trixi.jl -function semidiscretize_gpu(semi::SemidiscretizationHyperbolic, tspan) +function semidiscretizeGPU(semi::SemidiscretizationHyperbolic, tspan) u0_ode = compute_coefficients(first(tspan), semi) iip = true diff --git a/test/test_script.jl b/test/test_script.jl index c243e5c..e6e890d 100644 --- a/test/test_script.jl +++ b/test/test_script.jl @@ -11,5 +11,5 @@ coordinates_max = 1.0 mesh = TreeMesh(coordinates_min, coordinates_max, initial_refinement_level = 4, n_cells_max = 30_000) -semi = TrixiCUDA.SemidiscretizationHyperbolic_gpu(mesh, equations, - initial_condition_convergence_test, solver) +semi = TrixiCUDA.SemidiscretizationHyperbolicGPU(mesh, equations, + initial_condition_convergence_test, solver)