Skip to content
This repository has been archived by the owner on Mar 1, 2023. It is now read-only.

Add DGModel outer constructor #1654

Merged
merged 1 commit into from
Oct 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
18 changes: 18 additions & 0 deletions src/Driver/driver_configs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -583,3 +583,21 @@ Establishing single stack configuration for %s
SingleStackSpecificInfo(),
)
end

import ..DGMethods: DGModel

"""
DGModel(driver_config; kwargs...)

Initialize a [`DGModel`](@ref) given a
[`DriverConfiguration`](@ref) and keyword
arguments supported by [`DGModel`](@ref).
"""
DGModel(driver_config; kwargs...) = DGModel(
driver_config.bl,
driver_config.grid,
driver_config.numerical_flux_first_order,
driver_config.numerical_flux_second_order,
driver_config.numerical_flux_gradient;
kwargs...,
)
15 changes: 2 additions & 13 deletions src/Driver/solver_configs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,6 @@ function SolverConfiguration(

bl = driver_config.bl
grid = driver_config.grid
numerical_flux_first_order = driver_config.numerical_flux_first_order
numerical_flux_second_order = driver_config.numerical_flux_second_order
numerical_flux_gradient = driver_config.numerical_flux_gradient

# Create the DG model and initialize the ODE state. If we're restarting,
# use state data from the checkpoint.
Expand All @@ -124,11 +121,7 @@ function SolverConfiguration(
dg.state_auxiliary .= state_auxiliary
else
dg = DGModel(
bl,
grid,
numerical_flux_first_order,
numerical_flux_second_order,
numerical_flux_gradient;
driver_config;
state_auxiliary = state_auxiliary,
direction = direction,
diffusion_direction = diffdir,
Expand All @@ -147,11 +140,7 @@ function SolverConfiguration(
dg = driver_config.config_info.dg
else
dg = DGModel(
bl,
grid,
numerical_flux_first_order,
numerical_flux_second_order,
numerical_flux_gradient;
driver_config;
fill_nan = Settings.debug_init,
direction = direction,
diffusion_direction = diffdir,
Expand Down
8 changes: 1 addition & 7 deletions test/Driver/mms3.jl
Original file line number Diff line number Diff line change
Expand Up @@ -181,13 +181,7 @@ function main()
ClimateMachine.invoke!(solver_config)

# test correctness
dg = DGModel(
model,
grid,
RusanovNumericalFlux(),
CentralNumericalFluxSecondOrder(),
CentralNumericalFluxGradient(),
)
dg = DGModel(driver_config)
Qe = init_ode_state(dg, timeend)
result = euclidean_distance(Q₀, Qe)
@test result ≈ expected_result
Expand Down
6 changes: 1 addition & 5 deletions test/Land/Model/haverkamp_implicit_test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,7 @@ haverkamp_dataset_path = get_data_folder(haverkamp_dataset)
Q = solver_config.Q

vdg = DGModel(
driver_config.bl,
driver_config.grid,
driver_config.numerical_flux_first_order,
driver_config.numerical_flux_second_order,
driver_config.numerical_flux_gradient,
driver_config;
state_auxiliary = dg.state_auxiliary,
direction = VerticalDirection(),
)
Expand Down
6 changes: 1 addition & 5 deletions tutorials/Atmos/burgers_single_stack_bjfnk.jl
Original file line number Diff line number Diff line change
Expand Up @@ -475,11 +475,7 @@ dg = solver_config.dg
Q = solver_config.Q

vdg = DGModel(
driver_config.bl,
driver_config.grid,
driver_config.numerical_flux_first_order,
driver_config.numerical_flux_second_order,
driver_config.numerical_flux_gradient,
driver_config;
state_auxiliary = dg.state_auxiliary,
direction = VerticalDirection(),
)
Expand Down