11module Projection
22using Gridap
3+ using GridapPETSc
4+
35using GridapDistributed
46using CSV, DelimitedFiles
57using DataFrames
68using Parameters
79using PartitionedArrays
810using SegregatedVMSSolver
911using SegregatedVMSSolver. ParametersDef
12+ using SegregatedVMSSolver. SolverOptions
1013using SegregatedVMSSolver. Interfaces
1114using SegregatedVMSSolver. CreateProblem
15+ using SegregatedVMSSolver. MatrixCreation
1216using SegregatedVMSSolver. ExportUtility: write_to_csv
1317
1418
@@ -20,8 +24,8 @@ export compute_VMS2_error
2024
2125function 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