Skip to content
Open
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
14 changes: 6 additions & 8 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ type_page = [
"Gas"=>"type_gas.md",
"Physical space"=>"type_physical_space.md",
"Velocity space"=>"type_velocity_space.md",
"Output"=>"type_output.md"
"Output"=>"type_output.md",
]
methods_page = [
"Running a simulation"=>"methods_solve.md",
Expand All @@ -20,7 +20,7 @@ methods_page = [
"Parallel"=>"methods_parallel.md",
"Theory"=>"methods_theory.md",
"Finalization"=>"methods_finalize.md",
"IO"=>"methods_io.md"
"IO"=>"methods_io.md",
]
makedocs(;
sitename = "KitAMR.jl",
Expand All @@ -33,13 +33,11 @@ makedocs(;
"Tutorial"=>"tutorial.md",
"Cluster deployment"=>"cluster_deployment.md",
"Index"=>"index_internal.md",
"Limitations"=>"limitations.md"
],
"Limitations"=>"limitations.md",
],
# format = Documenter.HTML(; collapselevel=1),
checkdocs = :none,
format = Documenter.HTML()
format = Documenter.HTML(),
)

deploydocs(;devbranch = "main",
repo = "github.com/CFDML/KitAMR.jl.git",
)
deploydocs(; devbranch = "main", repo = "github.com/CFDML/KitAMR.jl.git")
57 changes: 26 additions & 31 deletions example/Riemann_problem/rp_1D.jl
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
using KitAMR,MPI
using KitAMR, MPI
MPI.Init()
function Sod_init(midpoint,kinfo)
if midpoint[1]<0.
return [1.,0.,0.,0.5]
function Sod_init(midpoint, kinfo)
if midpoint[1]<0.0
return [1.0, 0.0, 0.0, 0.5]
else
return [0.125,0.,0.,0.625]
return [0.125, 0.0, 0.0, 0.625]
end
end


solver = Solver(;
DIM = 2, NDF = 2,
DIM = 2,
NDF = 2,
CFL = 0.4,
AMR_PS_MAXLEVEL = 3,
AMR_VS_MAXLEVEL = 3,
Expand All @@ -22,37 +23,31 @@ solver = Solver(;
# time_marching = CIP_Marching,
time_marching = Euler,
# time_marching = CAIDVM_Marching,
max_sim_time = 20.,
max_sim_time = 20.0,
)
gas = Gas(;
K = 1.0,
Kn = 0.001,
ω = 0.81,
ωᵣ = 0.81,
)
output = Output(
gas = Gas(; K = 1.0, Kn = 0.001, ω = 0.81, ωᵣ = 0.81)
output = Output(solver;)
udf = UDF(;)
config = Configure(
solver;
)
udf = UDF(;
)
config = Configure(solver;
geometry = [-2.,2.,-0.5,0.5],
trees_num = [32,8],
quadrature = [-7.,7.,-7.,7.],
vs_trees_num = [8,8],
geometry = [-2.0, 2.0, -0.5, 0.5],
trees_num = [32, 8],
quadrature = [-7.0, 7.0, -7.0, 7.0],
vs_trees_num = [8, 8],
IC = PCoordFn(Sod_init),
domain = [
Domain(UniformOutflow,1),Domain(UniformOutflow,2),
Domain(Period,3),Domain(Period,4)
],
Domain(UniformOutflow, 1),
Domain(UniformOutflow, 2),
Domain(Period, 3),
Domain(Period, 4),
],
output = output,
gas = gas,
user_defined = udf
user_defined = udf,
)

p4est,ka = initialize(config; prerefine_steps = 1, prerefine_recursive = true);
solve!(p4est, ka;
ps_interval = 20, vs_interval = 20, partition_interval = 20)
save_result(p4est,ka)
finalize!(p4est,ka)
p4est, ka = initialize(config; prerefine_steps = 1, prerefine_recursive = true);
solve!(p4est, ka; ps_interval = 20, vs_interval = 20, partition_interval = 20)
save_result(p4est, ka)
finalize!(p4est, ka)
MPI.Finalize()
26 changes: 10 additions & 16 deletions example/Riemann_problem/rp_2D.jl
Original file line number Diff line number Diff line change
Expand Up @@ -40,29 +40,24 @@ solver = Solver(;
max_sim_time = 0.25,
)

gas = Gas(;
K = 1.0,
Kn = 0.001,
ω = 0.81,
ωᵣ = 0.81,
)
gas = Gas(; K = 1.0, Kn = 0.001, ω = 0.81, ωᵣ = 0.81)

output = Output(
solver;
)
output = Output(solver;)

udf = UDF(;
)
udf = UDF(;)

config = Configure(solver;
config = Configure(
solver;
geometry = [-0.5, 0.5, -0.5, 0.5],
trees_num = [16, 16],
quadrature = [-5.0, 5.0, -5.0, 5.0],
vs_trees_num = [8, 8],
IC = PCoordFn(Riemann_2D_init),
domain = [
Domain(UniformOutflow, 1), Domain(UniformOutflow, 2),
Domain(UniformOutflow, 3), Domain(UniformOutflow, 4),
Domain(UniformOutflow, 1),
Domain(UniformOutflow, 2),
Domain(UniformOutflow, 3),
Domain(UniformOutflow, 4),
],
output = output,
gas = gas,
Expand All @@ -71,8 +66,7 @@ config = Configure(solver;

p4est, ka = initialize(config; prerefine_steps = 5, prerefine_reinit_ic = true)

solve!(p4est, ka;
ps_interval = 40, vs_interval = 40, partition_interval = 40)
solve!(p4est, ka; ps_interval = 40, vs_interval = 40, partition_interval = 40)
save_result(p4est, ka)
finalize!(p4est, ka)
MPI.Finalize()
63 changes: 33 additions & 30 deletions example/X38/X38_julia.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using KitAMR,MPI
using KitAMR, MPI
include("./X38_udf.jl")

MPI.Init() # MPI initialization. Mandatory for a paralleled program using MPI.
Expand All @@ -10,53 +10,56 @@ MPI.Init() # MPI initialization. Mandatory for a paralleled program using MPI.
Configuration by directly construct `Configure` struct.
=#
solver = Solver(;
DIM = 3, NDF = 1,
DIM = 3,
NDF = 1,
AMR_PS_MAXLEVEL = 4,
AMR_DYNAMIC_PS_MAXLEVEL = 4,
AMR_VS_MAXLEVEL = 3,
PS_DYNAMIC_AMR = true,
VS_DYNAMIC_AMR = true,
flux = CAIDVM,
time_marching = CAIDVM_Marching,
max_sim_time = 20.,
)
gas = Gas(;
K = 0.0,
Kn = 0.275,
ω = 0.81,
ωᵣ = 0.81,
T_ref = 273/56,
max_sim_time = 20.0,
)
gas = Gas(; K = 0.0, Kn = 0.275, ω = 0.81, ωᵣ = 0.81, T_ref = 273/56)
output = Output(solver)
udf = UDF(;
dynamic_ps_refine_flag = amr_region
)
config = Configure(solver;
geometry = [-4.0,5.0,-4.0,4.0,-4.0,4.0],
trees_num = [16,16,16],
quadrature = [-14.2,21.3,-17.75,17.75,-17.75,17.75],
vs_trees_num = [10,10,10],
udf = UDF(; dynamic_ps_refine_flag = amr_region)
config = Configure(
solver;
geometry = [-4.0, 5.0, -4.0, 4.0, -4.0, 4.0],
trees_num = [16, 16, 16],
quadrature = [-14.2, 21.3, -17.75, 17.75, -17.75, 17.75],
vs_trees_num = [10, 10, 10],
IC = PCoordFn(X38_buffer_IC),
domain = [
Domain(SuperSonicInflow,1,
[1.,8.0*sqrt(5/6),0.,0.,1.0]),Domain(UniformOutflow,2),Domain(UniformOutflow,3),
Domain(UniformOutflow,4),Domain(UniformOutflow,5),Domain(UniformOutflow,6)
],
IB = [Triangles(Maxwellian,"./example/X38/X38_normalized.stl",true,1.5,[1.,0.,0.,0.,56/300])],
Domain(SuperSonicInflow, 1, [1.0, 8.0*sqrt(5/6), 0.0, 0.0, 1.0]),
Domain(UniformOutflow, 2),
Domain(UniformOutflow, 3),
Domain(UniformOutflow, 4),
Domain(UniformOutflow, 5),
Domain(UniformOutflow, 6),
],
IB = [
Triangles(
Maxwellian,
"./example/X38/X38_normalized.stl",
true,
1.5,
[1.0, 0.0, 0.0, 0.0, 56/300],
),
],
output = output,
gas = gas,
user_defined = udf
user_defined = udf,
)
# ----------------------------------------------------------------------------------------------------

p4est,ka = initialize(config; prerefine_steps = 0) # Initialization for `KitAMR_Data`.
p4est, ka = initialize(config; prerefine_steps = 0) # Initialization for `KitAMR_Data`.
#=
Run the time-stepping loop. `max_sim_time` is set in the `Solver` above; `solve!`
terminates (and lands the last step) exactly on it via `reached_max_time` / `limit_Δt!`.
=#
solve!(p4est, ka;
ps_interval = 40, vs_interval = 40, partition_interval = 40)
save_result(p4est,ka) # Save converging results.
finalize!(p4est,ka) # Finalize `p4est` things. Release the memory managed by `C`.
solve!(p4est, ka; ps_interval = 40, vs_interval = 40, partition_interval = 40)
save_result(p4est, ka) # Save converging results.
finalize!(p4est, ka) # Finalize `p4est` things. Release the memory managed by `C`.
MPI.Finalize() # MPI finalization. Mandatory for a paralleled program using MPI.

21 changes: 13 additions & 8 deletions example/X38/X38_text.jl
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
using KitAMR,MPI
using KitAMR, MPI
include("./X38_udf.jl")
MPI.Init()
config = KitAMR.read_config("./example/X38/configure_X38.txt")
p4est,ka = KitAMR.initialize(config);
p4est, ka = KitAMR.initialize(config);
KitAMR.listen_for_save!()
i = 0
while !KitAMR.reached_max_time(ka) # max_sim_time is read from the config file
global i += 1
if MPI.Comm_rank(MPI.COMM_WORLD)==0
@show i
end
KitAMR.adaptive_mesh_refinement!(p4est,ka;ps_interval = 40, vs_interval=40,partition_interval=40)
KitAMR.adaptive_mesh_refinement!(
p4est,
ka;
ps_interval = 40,
vs_interval = 40,
partition_interval = 40,
)
KitAMR.limit_Δt!(ka) # shrink Δt to land exactly on the next animation frame / max_sim_time
KitAMR.update_slope!(ka)
KitAMR.slope_exchange!(p4est, ka)
Expand All @@ -20,11 +26,10 @@ while !KitAMR.reached_max_time(ka) # max_sim_time is read from the config file
KitAMR.flux!(ka)
KitAMR.iterate!(ka)
KitAMR.data_exchange!(p4est, ka)
check_for_animsave!(p4est,ka) # write a frame if this step landed on a frame time
check_for_animsave!(p4est, ka) # write a frame if this step landed on a frame time
KitAMR.check_for_convergence(ka)&&break
KitAMR.check!(p4est,ka)
KitAMR.check!(p4est, ka)
end
KitAMR.save_result(p4est,ka)
KitAMR.finalize!(p4est,ka)
KitAMR.save_result(p4est, ka)
KitAMR.finalize!(p4est, ka)
MPI.Finalize()

14 changes: 7 additions & 7 deletions example/X38/X38_udf.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using LinearAlgebra
function amr_region(ps_data,level,ka) # dynamic
function amr_region(ps_data, level, ka) # dynamic
midpoint = ps_data.midpoint
ds = ps_data.ds
L = 1.0
Expand All @@ -8,16 +8,16 @@ function amr_region(ps_data,level,ka) # dynamic
end
return false
end
function X38_buffer_IC(midpoint::Vector{Float64},kinfo::KInfo)
function X38_buffer_IC(midpoint::Vector{Float64}, kinfo::KInfo)
ib = kinfo.config.IB[1]
Ma = 8.
Ma = 8.0
T0 = 1.0
Tw = 300/56
_,distance = KitAMR.nn(ib.tkdt.kdt,midpoint)
_, distance = KitAMR.nn(ib.tkdt.kdt, midpoint)
R = 0.3
if distance > R
return [1.0,Ma*√(5/6),0.,0.,1/T0]
return [1.0, Ma*√(5/6), 0.0, 0.0, 1/T0]
else
return [1.0,distance*Ma*√(5/6)/R,0.,0.,1.0/(T0+(R-distance)*(Tw-T0)/R)]
return [1.0, distance*Ma*√(5/6)/R, 0.0, 0.0, 1.0/(T0+(R-distance)*(Tw-T0)/R)]
end
end
end
16 changes: 8 additions & 8 deletions example/X38/model_transform.jl
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
using FileIO, MeshIO, GeometryBasics
mesh = load("./example/X38/X38-surface-fine.stl")
points = [x[i] for i in 1:3, x in mesh.position]
mins = minimum(points,dims=2)
maxes = maximum(points,dims=2)
points = [x[i] for i = 1:3, x in mesh.position]
mins = minimum(points, dims = 2)
maxes = maximum(points, dims = 2)
L = maximum(maxes-mins)
α = -π/9# AOA 20 degrees
Rot = [cos(α) -sin(α) 0;sin(α) cos(α) 0;0 0 1.]
normalized_points = Rot*points./L
normalized_position = [Point(x[1],x[2],x[3]) for x in eachcol(normalized_points)]
new_mesh = Mesh(normalized_position,mesh.faces)
save("./example/X38/X38_normalized.stl",new_mesh)
Rot = [cos(α) -sin(α) 0; sin(α) cos(α) 0; 0 0 1.0]
normalized_points = Rot*points ./ L
normalized_position = [Point(x[1], x[2], x[3]) for x in eachcol(normalized_points)]
new_mesh = Mesh(normalized_position, mesh.faces)
save("./example/X38/X38_normalized.stl", new_mesh)
Loading