Skip to content

Commit

Permalink
Removed MHDFEoperator and PETScSolvers fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
JordiManyer committed Dec 27, 2023
1 parent 6faaafa commit 2b08eb7
Show file tree
Hide file tree
Showing 14 changed files with 139 additions and 249 deletions.
194 changes: 105 additions & 89 deletions Manifest.toml

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ GridapPETSc = "bcdc36c2-0c3e-11ea-095a-c9dadae499f1"
GridapSolvers = "6d3209ee-5e3c-4db7-a716-942eb12ed534"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
MPI = "da04e1cc-30fd-572f-bb4f-1f8673147195"
P4est_wrapper = "3743d7c0-8adf-11ea-380b-7d33b0ecc1da"
PackageCompiler = "9b87118b-4619-50d2-8e1e-99f35a4d4d9d"
PartitionedArrays = "5a9dfac6-5c52-46f7-8278-5e2210713be9"
Profile = "9abbd945-dff8-562f-b5e8-e1ebf5ef1b79"
Expand Down
52 changes: 0 additions & 52 deletions src/FEOperators.jl

This file was deleted.

3 changes: 1 addition & 2 deletions src/GridapMHD.jl
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ using GridapPETSc.PETSC

using GridapSolvers
using GridapSolvers.LinearSolvers
using GridapSolvers.LinearSolvers: allocate_col_vector, allocate_row_vector
using GridapSolvers.LinearSolvers: allocate_in_domain, allocate_in_range

using PartitionedArrays
using PartitionedArrays: getany
Expand All @@ -45,7 +45,6 @@ include("Li2019/Li2019.jl")
# Main driver
include("Fixes.jl")
include("ExtraFunctions.jl")
include("FEOperators.jl")
include("parameters.jl")
include("Main.jl")

Expand Down
3 changes: 1 addition & 2 deletions src/Li2019/Li2019.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,9 @@ using GridapPETSc

using GridapSolvers
using GridapSolvers.LinearSolvers
using GridapSolvers.LinearSolvers: allocate_col_vector, allocate_row_vector
using GridapSolvers.LinearSolvers: allocate_in_domain, allocate_in_range

include("NLSolvers.jl")
include("PETScLinearSolvers.jl")

include("blocks.jl")
include("preconditioner.jl")
Expand Down
2 changes: 1 addition & 1 deletion src/Li2019/NLSolvers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
function Gridap.Algebra.solve!(x::AbstractVector,nls::NewtonRaphsonSolver,op::NonlinearOperator,cache::Nothing)
b = residual(op, x)
A = jacobian(op, x)
dx = allocate_col_vector(A)
dx = allocate_in_domain(A)
ns = numerical_setup(symbolic_setup(nls.ls, A), A)

Gridap.Algebra._solve_nr!(x,A,b,dx,ns,nls,op)
Expand Down
67 changes: 0 additions & 67 deletions src/Li2019/PETScLinearSolvers.jl

This file was deleted.

8 changes: 4 additions & 4 deletions src/Li2019/preconditioner.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ mutable struct LI2019_NS <: Gridap.Algebra.NumericalSetup
end

function allocate_caches(solver::Li2019_Preconditioner,A::AbstractBlockMatrix)
du = allocate_col_vector(A[Block(1,1)])
dp = allocate_col_vector(A[Block(2,2)])
dj = allocate_col_vector(A[Block(3,3)])
= allocate_col_vector(A[Block(4,4)])
du = allocate_in_domain(A[Block(1,1)])
dp = allocate_in_domain(A[Block(2,2)])
dj = allocate_in_domain(A[Block(3,3)])
= allocate_in_domain(A[Block(4,4)])
return du, dp, dj, dφ
end

Expand Down
6 changes: 3 additions & 3 deletions src/Li2019/solver.jl
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ function test_preconditioner(op,P)
# Test preconditioner
i_am_main(parts) && println(repeat("=",50))
ns = numerical_setup(symbolic_setup(P,A),A)
x = allocate_col_vector(A)
x = allocate_in_domain(A)
solve!(x,ns,b)
e = norm(x)
i_am_main(parts) && println("P error: ",e)
Expand All @@ -168,8 +168,8 @@ function test_block_solvers(parts,block_solvers,block_mats)

function test_solver(s,m)
ns = numerical_setup(symbolic_setup(s,m),m)
x = allocate_col_vector(m)
b = allocate_col_vector(m)
x = allocate_in_domain(m)
b = allocate_in_domain(m)
fill!(b,1.0)
x = solve!(x,ns,b)
return norm(b - m*x)
Expand Down
20 changes: 7 additions & 13 deletions src/Main.jl
Original file line number Diff line number Diff line change
Expand Up @@ -291,8 +291,13 @@ end
function weak_form(params,k)

fluid = params[:fluid]
Ωf = _interior(params[:model],fluid[:domain])
dΩf = Measure(Ωf,2*k)
Ωf = _interior(params[:model],fluid[:domain])
dΩf = Measure(Ωf,2*k)

α, β, γ, σf = fluid[], fluid[], fluid[], fluid[]
f = fluid[:f]
B = fluid[:B]
ζ = params[]

solid = params[:solid]
if solid !== nothing
Expand All @@ -301,14 +306,6 @@ function weak_form(params,k)
σs = solid[]
end

α = fluid[]
β = fluid[]
γ = fluid[]
f = fluid[:f]
B = fluid[:B]
σf = fluid[]
ζ = params[]

bcs = params[:bcs]

params_φ = []
Expand Down Expand Up @@ -466,6 +463,3 @@ function a_B(x,dy,γ,B,dΩ)
v_u, v_p, v_j, v_φ = dy
( -*(j×B)v_u) - (u×B)v_j )*
end



10 changes: 5 additions & 5 deletions test/dev/Dj_solver.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ using Gridap.ReferenceFEs
function test_smoother(s,D_j)
ns = numerical_setup(symbolic_setup(s,D_j),D_j)

b = GridapSolvers.allocate_col_vector(D_j)
x = GridapSolvers.allocate_col_vector(D_j)
y = GridapSolvers.allocate_row_vector(D_j)
b = GridapSolvers.allocate_in_domain(D_j)
x = GridapSolvers.allocate_in_domain(D_j)
y = GridapSolvers.allocate_in_range(D_j)

fill!(b,1.0)
y = b - D_j*x
Expand All @@ -24,8 +24,8 @@ end
function test_solver(s,D_j)
ns = numerical_setup(symbolic_setup(s,D_j),D_j)

b = GridapSolvers.allocate_col_vector(D_j)
x = GridapSolvers.allocate_col_vector(D_j)
b = GridapSolvers.allocate_in_domain(D_j)
x = GridapSolvers.allocate_in_domain(D_j)

fill!(b,1.0)
solve!(x,ns,b)
Expand Down
14 changes: 7 additions & 7 deletions test/dev/Dj_solver_gmg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ end
function test_solver(s,D_j)
ns = numerical_setup(symbolic_setup(s,D_j),D_j)

b = GridapSolvers.allocate_col_vector(D_j)
x = GridapSolvers.allocate_col_vector(D_j)
b = GridapSolvers.allocate_in_domain(D_j)
x = GridapSolvers.allocate_in_domain(D_j)

fill!(b,1.0)
solve!(x,ns,b)
Expand All @@ -117,9 +117,9 @@ end

function test_smoother(s,D_j)
ns = numerical_setup(symbolic_setup(s,D_j),D_j)
b = GridapSolvers.allocate_col_vector(D_j)
x = GridapSolvers.allocate_col_vector(D_j)
r = GridapSolvers.allocate_row_vector(D_j)
b = GridapSolvers.allocate_in_domain(D_j)
x = GridapSolvers.allocate_in_domain(D_j)
r = GridapSolvers.allocate_in_range(D_j)
fill!(b,1.0)
fill!(x,1.0)
mul!(r,D_j,x)
Expand Down Expand Up @@ -226,12 +226,12 @@ gmg = GMGLinearSolver(mh,
solver = FGMRESSolver(100,gmg;rtol=1e-6,verbose=true)

ns = numerical_setup(symbolic_setup(solver,A),A)
x = GridapSolvers.allocate_col_vector(A)
x = GridapSolvers.allocate_in_domain(A)
solve!(x,ns,b)


Pl = LinearSolvers.IdentitySolver()
solver2 = GMRESSolver(1000;Pl=Pl,rtol=1e-6,verbose=true)
ns2 = numerical_setup(symbolic_setup(solver2,A),A)
x2 = GridapSolvers.allocate_col_vector(A)
x2 = GridapSolvers.allocate_in_domain(A)
solve!(x2,ns2,b)
4 changes: 2 additions & 2 deletions test/dev/Dj_solver_petsc.jl
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ end
function test_solver(s,D_j)
ns = numerical_setup(symbolic_setup(s,D_j),D_j)

b = GridapSolvers.allocate_col_vector(D_j)
x = GridapSolvers.allocate_col_vector(D_j)
b = GridapSolvers.allocate_in_domain(D_j)
x = GridapSolvers.allocate_in_domain(D_j)

fill!(b,1.0)
solve!(x,ns,b)
Expand Down
4 changes: 2 additions & 2 deletions test/dev/Lp_solver.jl
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ a_dg(p,v_p) = a_cg(p,v_p) + aΛ(p,v_p) + aΓ(p,v_p)
Δp = assemble_matrix(a_dg,U_p,V_p)

# Solver
b = GridapSolvers.allocate_col_vector(Δp)
x = GridapSolvers.allocate_col_vector(Δp)
b = GridapSolvers.allocate_in_domain(Δp)
x = GridapSolvers.allocate_in_domain(Δp)

fill!(x,0.0)
fill!(b,1.0)
Expand Down

0 comments on commit 2b08eb7

Please sign in to comment.