Skip to content

Commit

Permalink
Small change
Browse files Browse the repository at this point in the history
  • Loading branch information
JordiManyer committed Aug 24, 2023
1 parent 5272bd6 commit cd28c90
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 15 deletions.
28 changes: 15 additions & 13 deletions src/cavity.jl
Original file line number Diff line number Diff line change
@@ -1,25 +1,23 @@

function cavity(;
backend = nothing,
np = nothing,
np = 1,
title = "Cavity",
path = ".",
kwargs...)

if isa(backend,Nothing)
@assert isa(np,Nothing)
@assert np == 1
info, t = _cavity(;title=title,path=path,kwargs...)
else
@assert backend [:sequential,:mpi]
@assert !isa(np,Nothing)
np = isa(np,Int) ? (np,) : np
if backend == :sequential
info,t = with_debug() do distribute
_cavity(;distribute=distribute,rank_partition=np,title=title,path=path,kwargs...)
_cavity(;distribute=distribute,np=np,title=title,path=path,kwargs...)
end
else
info,t = with_mpi() do distribute
_cavity(;distribute=distribute,rank_partition=np,title=title,path=path,kwargs...)
_cavity(;distribute=distribute,np=np,title=title,path=path,kwargs...)
end
end
end
Expand All @@ -38,7 +36,7 @@ end

function _cavity(;
distribute=nothing,
rank_partition=nothing,
np=1,
nc=(4,4,4),
ν=1.0,
ρ=1.0,
Expand All @@ -52,19 +50,17 @@ function _cavity(;
title="Cavity",
path='.',
solver=:julia,
solver_params=default_solver_params(solver),
verbose=true,
)

@assert length(nc) == 3
is_serial = isa(distribute,Nothing)

if is_serial
@assert isa(rank_partition,Nothing)
rank_partition = (1,)
distribute = DebugArray
end
@assert is_serial || (length(rank_partition) == length(nc))
parts = distribute(LinearIndices((prod(rank_partition),)))
parts = distribute(LinearIndices((np,)))

t = PTimer(parts,verbose=verbose)
tic!(t, barrier=true)
Expand All @@ -84,7 +80,9 @@ function _cavity(;
if is_serial
model = simplexify(CartesianDiscreteModel(domain, nc))
else
model = simplexify(CartesianDiscreteModel(parts,rank_partition,domain, nc))
# simplexify() is not implemented for DistributedDiscreteModel
rank_partition = (np,1,1)
model = CartesianDiscreteModel(parts,rank_partition,domain, nc)
end
Ω = Interior(model)

Expand Down Expand Up @@ -120,7 +118,8 @@ function _cavity(;
:j => Dict(:tags => "insulating", :values => ji),
),
:k => 2,
=> 0.0 # Augmented-Lagragian term
=> 0.0, # Augmented-Lagragian term
:solver_params => solver_params,
)

params = add_default_params(_params)
Expand Down Expand Up @@ -243,3 +242,6 @@ function block_gmres_solver(op,U,V,Ω,params)
return [ūh, p̄h, j̄h, φ̄h]
end

function default_solver_params(solver::Symbol)
return Dict()
end
4 changes: 2 additions & 2 deletions test/cavity_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ using GridapMHD

GridapMHD.cavity()
GridapMHD.cavity(solver=:block_gmres)
#GridapMHD.cavity(np=(2,2),backend=:sequential)
#GridapMHD.cavity(np=(2,2),backend=:mpi)
GridapMHD.cavity(np=2,backend=:sequential)
#GridapMHD.cavity(np=2,backend=:mpi)

end # module

0 comments on commit cd28c90

Please sign in to comment.