Skip to content

Commit

Permalink
Add different setup
Browse files Browse the repository at this point in the history
  • Loading branch information
agdestein committed Dec 21, 2023
1 parent f1d8151 commit 7665b11
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 16 deletions.
5 changes: 3 additions & 2 deletions scratch/multigrid.jl
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,10 @@ get_params(nles) = (;
tburn = T(0.05),
tsim = T(0.5),
Δt = T(1e-4),
nles,
ndns = 2048,
nles = map(n -> (n, n), nles),
ndns = (2048, 2048),
ArrayType,
PSolver = SpectralPressureSolver,
)

params_train = (; get_params([64, 128, 256])..., savefreq = 5);
Expand Down
7 changes: 4 additions & 3 deletions scratch/train_model.jl
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,15 @@ params = (;
D = 2,
Re = T(6_000),
lims = (T(0), T(1)),
nles = [nles],
# ndns = 512,
ndns = 1024,
nles = [(nles, nles)],
# ndns = (512, 512),
ndns = (1024, 1024),
tburn = T(0.05),
tsim = T(0.5),
Δt = T(1e-4),
savefreq = 5,
ArrayType,
PSolver = SpectralPressureSolver,
)

# Create LES data from DNS
Expand Down
33 changes: 22 additions & 11 deletions src/closures/create_les_data.jl
Original file line number Diff line number Diff line change
Expand Up @@ -105,42 +105,53 @@ function create_les_data(
T;
D = 2,
Re = T(2_000),
lims = (T(0), T(1)),
nles = [64],
ndns = 256,
lims = ntuple-> (T(0), T(1)), D),
nles = [ntuple-> 64, D)],
ndns = ntuple-> 256, D),
tburn = T(0.1),
tsim = T(0.1),
Δt = T(1e-4),
PSolver = SpectralPressureSolver,
savefreq = 1,
ArrayType = Array,
ic_params = (;),
icfunc = (setup, psolver) -> random_field(setup, T(0); psolver),
boundary_conditions = ntuple-> (PeriodicBC(), PeriodicBC()), D),
)
compression = @. ndns ÷ nles
@assert all(@.(compression * nles == ndns))

# Build setup and assemble operators
dns = Setup(ntuple-> LinRange(lims..., ndns + 1), D)...; Re, ArrayType)
dns = Setup(
ntuple-> LinRange(lims[α]..., ndns[α] + 1), D)...;
Re,
boundary_conditions,
ArrayType,
)
les = [
Setup(ntuple-> LinRange(lims..., nles + 1), D)...; Re, ArrayType) for
nles in nles
Setup(
ntuple-> LinRange(lims[α], nles[α] + 1), D)...;
Re,
boundary_conditions,
ArrayType,
) for nles in nles
]

# Since the grid is uniform and identical for x and y, we may use a specialized
# spectral pressure solver
psolver = SpectralPressureSolver(dns)
psolver_les = SpectralPressureSolver.(les)
psolver = PSolver(dns)
psolver_les = PSolver.(les)

# Number of time steps to save
nt = round(Int, tsim / Δt)
Δt = tsim / nt

# datasize = Base.summarysize(filtered) / 1e6
datasize =
(nt ÷ savefreq + 1) * sum(nles .^ D) * 3 * 2 * length(bitstring(zero(T))) / 8 / 1e6
(nt ÷ savefreq + 1) * sum(prod.(nles)) * D * 2 * length(bitstring(zero(T))) / 8 / 1e6
@info "Generating $datasize Mb of LES data"

# Initial conditions
u₀ = random_field(dns, T(0); psolver, ic_params...)
u₀ = icfunc(dns, psolver)

# Random body force
# force_dns =
Expand Down

0 comments on commit 7665b11

Please sign in to comment.