Skip to content

Commit 7e48316

Browse files
committed
update projection options
1 parent b9ea24e commit 7e48316

File tree

4 files changed

+26
-14
lines changed

4 files changed

+26
-14
lines changed

examples/2D/TaylorGreen2D.jl

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ t0 = 0.0
1212
dt = 0.01
1313
tF = 2.5
1414
vortex_diameter = 1.0
15-
N = 16
15+
N = 32
1616
Re = 1600
1717
D = 2
1818

@@ -22,8 +22,6 @@ rank_partition = (2,2)
2222

2323

2424

25-
26-
2725
solver_options = petsc_options(; vel_ksp="gmres", vel_pc="gamg", pres_ksp="cg", pres_pc="gamg")
2826

2927
sprob = StabilizedProblem(VMS(3))
@@ -33,7 +31,7 @@ physicalp = PhysicalParameters(Re=Re, c=vortex_diameter)
3331
solverp = SolverParameters(matrix_freq_update=1, Number_Skip_Expansion=10e6, M=40,
3432
petsc_options=solver_options)
3533
exportp = ExportParameters(printinitial=true, printmodel=true,
36-
vtu_export = ["uh","ph","uh_analytic", "ph_analytic"], extra_export=["VelocityError","PressureError"])
34+
vtu_export = ["uh","ph","uh_analytic", "ph_analytic"], extra_export=["VelocityError","PressureError"], projection_timesteps=[dt, 2*dt, 10*dt, 20*dt])
3735

3836

3937

src/Commons/Equations/StabilizedEquations.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,10 @@ function segregated_equations(u_adv,params::Dict{Symbol,Any},simcase::Simulation
5050

5151
rhs(v) = 0.0
5252

53-
if typeof(simcase) <: TaylorGreen
54-
writevtk(Ω, "Stab_$dt", nsubcells=order, cellfields=["tm"=>Tm, "tc"=>Tc] )
55-
@info "Exporting Stabilization Parameters"
56-
end
53+
# if typeof(simcase) <: TaylorGreen
54+
# writevtk(Ω, "Stab_$dt", nsubcells=order, cellfields=["tm"=>Tm, "tc"=>Tc] )
55+
# @info "Exporting Stabilization Parameters"
56+
# end
5757

5858
return Tuu,Tpu,Auu,Aup,Apu,App,ML,S,rhs
5959

src/Commons/ParametersDef/Params.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,8 @@ const ALLOWED_VTU_EXPORTS = ["uh", "ph", "uh_analytic", "ph_analytic","uh_avg",
138138
vtu_export::Vector{String} = ["uh","ph"]
139139

140140
extra_export::Vector{String} = String[]
141+
projection_timesteps::Vector{Float64} = Float64[]
142+
141143
@assert all(x -> x in ALLOWED_EXTRA_EXPORTS, extra_export) "Invalid value in extra_export. Allowed values:$ALLOWED_EXTRA_EXPORTS"
142144

143145

src/Commons/Projection.jl

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
module Projection
22
using Gridap
3+
using GridapPETSc
4+
35
using GridapDistributed
46
using CSV, DelimitedFiles
57
using DataFrames
68
using Parameters
79
using PartitionedArrays
810
using SegregatedVMSSolver
911
using SegregatedVMSSolver.ParametersDef
12+
using SegregatedVMSSolver.SolverOptions
1013
using SegregatedVMSSolver.Interfaces
1114
using SegregatedVMSSolver.CreateProblem
15+
using SegregatedVMSSolver.MatrixCreation
1216
using SegregatedVMSSolver.ExportUtility: write_to_csv
1317

1418

@@ -20,8 +24,8 @@ export compute_VMS2_error
2024

2125
function compute_VMS2_error(uh_fine, simcase::TaylorGreen{Periodic},params::Dict{Symbol,Any}, tn::Real)
2226
@unpack U, dΩ, degree,parts = params
23-
@sunpack D = simcase
24-
if D == 2
27+
@sunpack D, projection_timesteps = simcase
28+
if D == 2 && !isempty( intersect(projection_timesteps, tn))
2529
ubar, uprime = project_solution(uh_fine, simcase, params, tn)
2630
norm_cross, norm_re, eps_cross, eps_re = compute_stresses(ubar, uprime, dΩ)
2731
write_apriori_analysis(tn, D, norm_cross, norm_re, eps_cross, eps_re, parts)
@@ -37,10 +41,12 @@ function create_coarse_spaces(params,simcase,order::Int64)
3741
@unpack model = params
3842
simcase_coarse = deepcopy(simcase)
3943
# simcase_coarse.meshp.meshinfo.N .= ones(Int64, D) .* Int(ceil(N[1] / 2))
40-
simcase_coarse.sprob.method.order = order -1
44+
simcase_coarse.sprob.method.order = 1
4145
boundary_conditions = create_boundary_conditions(simcase)
4246
Vc, Uc, _, _ = creation_fe_spaces(simcase_coarse, model, boundary_conditions)
4347
merge!(params,Dict(:Uc=>Uc, :Vc=>Vc))
48+
mkpath("Projections")
49+
4450
end
4551

4652
@unpack Vc, Uc = params
@@ -63,16 +69,22 @@ function project_solution(uh_fine, simcase::TaylorGreen{Periodic}, params::Dict{
6369

6470
Vc, Uc = create_coarse_spaces(params,simcase,order)
6571

72+
6673
#L2 projection of uh_fine solution on lower order dimensional space (same mesh)
6774
# Build weak form
6875
a(u,v) = ( u v )dΩ
6976
l(v) = ( uh_fine v )dΩ
7077

7178
# Assemble and solve
72-
op = AffineFEOperator(a,l,Uc(tn),Vc(tn))
73-
ubar = solve(op)
79+
op_proj = AffineFEOperator(a,l,Uc(tn),Vc(tn))
80+
solver_proj = PETScLinearSolver(pres_kspsetup)
81+
82+
ubar = solve(solver_proj,op_proj)
83+
84+
@info "Projection ubar computed"
85+
save_path= joinpath("Projections", "TGV_$(D)D_$(tn)_projections")
7486

75-
println("ubar - solved")
87+
writevtk(Ω, save_path, nsubcells=order, cellfields=["uh_fine"=>uh_fine, "uh_projected"=>ubar])
7688

7789
uprime = uh_fine - ubar
7890

0 commit comments

Comments
 (0)