-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #70 from gridap/darcy_driver
Darcy driver
- Loading branch information
Showing
10 changed files
with
147 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
using Gridap | ||
using GridapDistributed | ||
using GridapPETSc | ||
using GridapPETSc: PetscScalar, PetscInt, PETSC | ||
using SparseMatricesCSR | ||
using PartitionedArrays | ||
|
||
function main(parts) | ||
|
||
if PETSC.MatMumpsSetIcntl_handle[] == C_NULL | ||
@info "Skipping DarcyTests since petsc is not configured with mumps." | ||
return nothing | ||
end | ||
|
||
domain = (0,1,0,1) | ||
partition = (100,100) | ||
model = CartesianDiscreteModel(parts,domain,partition) | ||
|
||
k = 1 | ||
reffe_u = ReferenceFE(raviart_thomas,Float64,k) | ||
reffe_p = ReferenceFE(lagrangian,Float64,k) | ||
|
||
V = FESpace(model,reffe_u,dirichlet_tags=[5,6]) | ||
Q = FESpace(model,reffe_p,conformity=:L2) | ||
|
||
uD = VectorValue(0.0,0.0) | ||
U = TrialFESpace(V,uD) | ||
P = TrialFESpace(Q) | ||
|
||
Y = MultiFieldFESpace([V, Q]) | ||
X = MultiFieldFESpace([U, P]) | ||
|
||
Ω = Interior(model) | ||
degree = 2 | ||
dΩ = Measure(Ω,degree) | ||
|
||
neumanntags = [8,] | ||
Γ = Boundary(model,tags=neumanntags) | ||
dΓ = Measure(Γ,degree) | ||
|
||
kinv1 = TensorValue(1.0,0.0,0.0,1.0) | ||
|
||
σ(u) =kinv1⋅u | ||
|
||
a((u,p), (v,q)) = ∫(v⋅(σ∘u) - (∇⋅v)*p + q*(∇⋅u) + 0*p*q)dΩ | ||
n_Γ = get_normal_vector(Γ) | ||
h = -1.0 | ||
|
||
b((v,q)) = ∫((v⋅n_Γ)*h)dΓ | ||
|
||
op = AffineFEOperator(a,b,X,Y) | ||
|
||
options = "-ksp_error_if_not_converged true -ksp_converged_reason -ksp_type preonly -pc_type lu -pc_factor_mat_solver_type mumps" | ||
xh = GridapPETSc.with(args=split(options)) do | ||
ls = PETScLinearSolver() | ||
xh = solve(ls,op) | ||
end | ||
uh, ph = xh | ||
|
||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
include("../DarcyTests.jl") | ||
nparts = (2,2) | ||
prun(main,mpi,nparts) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module DarcyTestsRun | ||
include("mpiexec.jl") | ||
run_mpi_driver(procs=4,file="DarcyTests.jl") | ||
end # module |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
module DarcyDriver | ||
|
||
using Gridap | ||
using GridapPETSc | ||
using GridapPETSc: PetscScalar, PetscInt, PETSC | ||
using SparseMatricesCSR | ||
|
||
options = "-ksp_converged_reason -ksp_monitor -ksp_type preonly -pc_type lu -pc_factor_mat_solver_type mumps" | ||
|
||
out = GridapPETSc.with(args=split(options)) do | ||
|
||
if PETSC.MatMumpsSetIcntl_handle[] == C_NULL | ||
@info "Skipping DarcyDriver since petsc is not configured with mumps." | ||
return nothing | ||
end | ||
|
||
domain = (0,1,0,1) | ||
partition = (100,100) | ||
model = CartesianDiscreteModel(domain,partition) | ||
|
||
k = 1 | ||
reffe_u = ReferenceFE(raviart_thomas,Float64,k) | ||
reffe_p = ReferenceFE(lagrangian,Float64,k) | ||
|
||
V = FESpace(model,reffe_u,dirichlet_tags=[5,6]) | ||
Q = FESpace(model,reffe_p,conformity=:L2) | ||
|
||
uD = VectorValue(0.0,0.0) | ||
U = TrialFESpace(V,uD) | ||
P = TrialFESpace(Q) | ||
|
||
Y = MultiFieldFESpace([V, Q]) | ||
X = MultiFieldFESpace([U, P]) | ||
|
||
Ω = Interior(model) | ||
degree = 2 | ||
dΩ = Measure(Ω,degree) | ||
|
||
neumanntags = [8,] | ||
Γ = Boundary(model,tags=neumanntags) | ||
dΓ = Measure(Γ,degree) | ||
|
||
kinv1 = TensorValue(1.0,0.0,0.0,1.0) | ||
kinv2 = TensorValue(100.0,90.0,90.0,100.0) | ||
|
||
function σ(x,u) | ||
if ((abs(x[1]-0.5) <= 0.1) && (abs(x[2]-0.5) <= 0.1)) | ||
return kinv2⋅u | ||
else | ||
return kinv1⋅u | ||
end | ||
end | ||
|
||
px = get_physical_coordinate(Ω) | ||
a((u,p), (v,q)) = ∫(v⋅(σ∘(px,u)) - (∇⋅v)*p + q*(∇⋅u) + 0*p*q)dΩ | ||
n_Γ = get_normal_vector(Γ) | ||
h = -1.0 | ||
|
||
b((v,q)) = ∫((v⋅n_Γ)*h)dΓ | ||
|
||
op = AffineFEOperator(a,b,X,Y) | ||
ls = PETScLinearSolver() | ||
xh = solve(ls,op) | ||
uh, ph = xh | ||
|
||
end | ||
|
||
end # module |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters