@@ -18,7 +18,10 @@ include("TestPoissonCommon.jl")
1818
1919# read mesh and relevant quantities
2020
21- function test_poisson_direct (use_condensed)
21+ function test_poisson_dirichlet (
22+ dev, use_condensed,
23+ nsolver, lsolver
24+ )
2225 mesh = UnstructuredMesh (mesh_file)
2326 V = FunctionSpace (mesh, H1Field, Lagrange)
2427 physics = Poisson ()
@@ -34,29 +37,41 @@ function test_poisson_direct(use_condensed)
3437 DirichletBC (:u , :sset_4 , bc_func),
3538 ]
3639
37- # direct solver test
3840 # setup the parameters
39- @show p = create_parameters (mesh, asm, physics, props; dirichlet_bcs= dbcs)
41+ p = create_parameters (mesh, asm, physics, props; dirichlet_bcs= dbcs)
42+
43+ if dev != cpu
44+ p = p |> dev
45+ asm = asm |> dev
46+ end
4047
4148 # setup solver and integrator
42- solver = NewtonSolver ( DirectLinearSolver (asm))
49+ solver = nsolver ( lsolver (asm))
4350 integrator = QuasiStaticIntegrator (solver)
4451 evolve! (integrator, p)
4552
53+ if dev != cpu
54+ p = p |> cpu
55+ end
56+
57+ U = p. h1_field
58+
4659 pp = PostProcessor (mesh, output_file, u)
4760 write_times (pp, 1 , 0.0 )
48- write_field (pp, 1 , (" u" ,), p . h1_field )
61+ write_field (pp, 1 , (" u" ,), U )
4962 close (pp)
5063
5164 if ! Sys. iswindows ()
5265 @test exodiff (output_file, gold_file)
5366 end
5467 rm (output_file; force= true )
5568 display (solver. timer)
56-
5769end
5870
59- function test_poisson_direct_neumman (use_condensed)
71+ function test_poisson_neumann (
72+ dev, use_condensed,
73+ nsolver, lsolver
74+ )
6075 mesh = UnstructuredMesh (mesh_file)
6176 V = FunctionSpace (mesh, H1Field, Lagrange)
6277 physics = Poisson ()
@@ -77,123 +92,86 @@ function test_poisson_direct_neumman(use_condensed)
7792
7893 # direct solver test
7994 # setup the parameters
80- @show p = create_parameters (
95+ p = create_parameters (
8196 mesh, asm, physics, props;
8297 dirichlet_bcs= dbcs,
8398 neumann_bcs= nbcs
8499 )
85100
101+ if dev != cpu
102+ p = p |> dev
103+ asm = asm |> dev
104+ end
105+
86106 # setup solver and integrator
87- solver = NewtonSolver ( DirectLinearSolver (asm))
107+ solver = nsolver ( lsolver (asm))
88108 integrator = QuasiStaticIntegrator (solver)
89109 evolve! (integrator, p)
90110
91- pp = PostProcessor (mesh, output_file, u)
92- write_times (pp, 1 , 0.0 )
93- write_field (pp, 1 , (" u" ,), p. h1_field)
94- close (pp)
95-
96- if ! Sys. iswindows ()
97- @test exodiff (output_file, gold_file)
111+ if dev != cpu
112+ p = p |> cpu
98113 end
99- rm (output_file; force= true )
100- display (solver. timer)
101-
102- end
103-
104- function test_poisson_iterative (use_condensed)
105- mesh = UnstructuredMesh (mesh_file)
106- V = FunctionSpace (mesh, H1Field, Lagrange)
107- physics = Poisson ()
108- props = create_properties (physics)
109- u = ScalarFunction (V, :u )
110- asm = SparseMatrixAssembler (u; use_condensed)
111-
112- # setup and update bcs
113- dbcs = DirichletBC[
114- DirichletBC (:u , :sset_1 , bc_func),
115- DirichletBC (:u , :sset_2 , bc_func),
116- DirichletBC (:u , :sset_3 , bc_func),
117- DirichletBC (:u , :sset_4 , bc_func),
118- ]
119-
120- # iterative solver test
121- # setup the parameters
122- p = create_parameters (mesh, asm, physics, props; dirichlet_bcs= dbcs)
123-
124- # setup solver and integrator
125- solver = NewtonSolver (IterativeLinearSolver (asm, :CgSolver ))
126- integrator = QuasiStaticIntegrator (solver)
127- @time evolve! (integrator, p)
128114
129- display (solver. timer)
115+ # TODO make a neumann gold file
116+ # U = p.h1_field
130117
131- pp = PostProcessor (mesh, output_file, u)
132- write_times (pp, 1 , 0.0 )
133- write_field (pp, 1 , (" u" ,), p . h1_field )
134- close (pp)
118+ # pp = PostProcessor(mesh, output_file, u)
119+ # write_times(pp, 1, 0.0)
120+ # write_field(pp, 1, ("u",), U )
121+ # close(pp)
135122
136- if ! Sys. iswindows ()
137- @test exodiff (output_file, gold_file)
138- end
139- rm (output_file; force= true )
123+ # if !Sys.iswindows()
124+ # @test exodiff(output_file, gold_file)
125+ # end
126+ # rm(output_file; force=true)
140127 display (solver. timer)
141128end
142129
143- @time test_poisson_direct (false )
144- @time test_poisson_direct (false )
145- @time test_poisson_direct (true )
146- @time test_poisson_direct (true )
147- # @time test_poisson_direct_neumman()
148- # @time test_poisson_direct_neumman()
149- @time test_poisson_iterative (false )
150- @time test_poisson_iterative (false )
151- @time test_poisson_iterative (true )
152- @time test_poisson_iterative (true )
153-
154- # # condensed test
155- # mesh = UnstructuredMesh(mesh_file)
156- # V = FunctionSpace(mesh, H1Field, Lagrange)
157- # physics = Poisson()
158- # u = ScalarFunction(V, :u)
159- # asm = SparseMatrixAssembler(H1Field, u)
160- # # pp = PostProcessor(mesh, output_file, u)
161-
162- # # setup and update bcs
163- # dbcs = DirichletBC[
164- # DirichletBC(asm.dof, :u, :sset_1, bc_func),
165- # DirichletBC(asm.dof, :u, :sset_2, bc_func),
166- # DirichletBC(asm.dof, :u, :sset_3, bc_func),
167- # DirichletBC(asm.dof, :u, :sset_4, bc_func),
168- # ]
169- # update_dofs!(asm, dbcs; use_condensed=true)
170- # Uu = create_unknowns(asm)
171- # Ubc = create_bcs(asm, H1Field)
172- # U = create_field(asm, H1Field)
173- # update_field!(U, asm, Uu, Ubc)
174- # update_field_bcs!(U, asm.dof, dbcs, 0.)
175- # assemble!(asm, physics, U, :residual_and_stiffness)
176- # K = stiffness(asm)
177- # G = constraint_matrix(asm)
178- # # @time H = (G + I) * K
179- # K[asm.dof.H1_bc_dofs, asm.dof.H1_bc_dofs] .= 1.
180- # # R = G * residual(asm)
181- # # R = G * asm.residual_storage.vals
182- # R = asm.residual_storage
183- # R[asm.dof.H1_bc_dofs] .= 0.
184- # ΔUu = -K \ R.vals
185- # U.vals .= U.vals .+ ΔUu
186- # assemble!(asm, physics, U, :residual_and_stiffness)
187- # K = stiffness(asm)
188- # G = constraint_matrix(asm)
189- # # @time H = (G + I) * K
190- # K[asm.dof.H1_bc_dofs, asm.dof.H1_bc_dofs] .= 1.
191- # # R = G * residual(asm)
192- # # R = G * asm.residual_storage.vals
193- # R = asm.residual_storage
194- # R[asm.dof.H1_bc_dofs] .= 0.
195- # ΔUu = -K \ R.vals
196- # U.vals .= U.vals .+ ΔUu
197- # U
198- # # @time H = G * K + G * I
199- # # @time H = G * K
130+ # function test_poisson_iterative(dev, use_condensed)
131+ # mesh = UnstructuredMesh(mesh_file)
132+ # V = FunctionSpace(mesh, H1Field, Lagrange)
133+ # physics = Poisson()
134+ # props = create_properties(physics)
135+ # u = ScalarFunction(V, :u)
136+ # asm = SparseMatrixAssembler(u; use_condensed)
137+
138+ # # setup and update bcs
139+ # dbcs = DirichletBC[
140+ # DirichletBC(:u, :sset_1, bc_func),
141+ # DirichletBC(:u, :sset_2, bc_func),
142+ # DirichletBC(:u, :sset_3, bc_func),
143+ # DirichletBC(:u, :sset_4, bc_func),
144+ # ]
145+
146+ # # iterative solver test
147+ # # setup the parameters
148+ # p = create_parameters(mesh, asm, physics, props; dirichlet_bcs=dbcs)
149+
150+ # if dev != cpu
151+ # p = p |> dev
152+ # asm = asm |> dev
153+ # end
154+
155+ # # setup solver and integrator
156+ # solver = NewtonSolver(IterativeLinearSolver(asm, :CgSolver))
157+ # integrator = QuasiStaticIntegrator(solver)
158+ # @time evolve!(integrator, p)
159+
160+ # display(solver.timer)
161+
162+ # if dev != cpu
163+ # p = p |> cpu
164+ # end
165+
166+ # U = p.h1_field
167+ # pp = PostProcessor(mesh, output_file, u)
168+ # write_times(pp, 1, 0.0)
169+ # write_field(pp, 1, ("u",), U)
170+ # close(pp)
171+
172+ # if !Sys.iswindows()
173+ # @test exodiff(output_file, gold_file)
174+ # end
175+ # rm(output_file; force=true)
176+ # display(solver.timer)
177+ # end
0 commit comments