@@ -6,8 +6,12 @@ function run_operator_tests()
66 println (" ============================" )
77 error = test_derivatives2D ()
88 @test error < 1.0e-14
9+ error = test_derivatives2D_hdiv ()
10+ @test error < 1.0e-14
911 error = test_derivatives3D ()
1012 @test error < 1.0e-14
13+ error = test_derivatives3D_hdiv ()
14+ @test error < 1.0e-14
1115 test_reconstructions ()
1216 end
1317end
@@ -79,8 +83,7 @@ function test_derivatives2D()
7983 xgrid = grid_triangle ([- 1.0 0.0 ; 1.0 0.0 ; 0.0 1.0 ]' )
8084
8185 # # define P2-Courant finite element space
82- FEType = H1P2{2 , 2 }
83- FES = FESpace {FEType} (xgrid)
86+ FES = FESpace {H1P2{2, 2}} (xgrid)
8487 show (devnull , FES)
8588
8689 # # get midpoint quadrature rule for constants
@@ -140,6 +143,52 @@ function test_derivatives2D()
140143end
141144
142145
146+ function test_derivatives2D_hdiv ()
147+ # # define test function and expected operator evals
148+ function testf (result, qpinfo)
149+ x = qpinfo. x
150+ result[1 ] = x[1 ]^ 2
151+ return result[2 ] = 3 * x[2 ]^ 2 + x[1 ] * x[2 ]
152+ end
153+
154+ # # expected values of operators in cell midpoint
155+ expected_curl2 = [1 / 3 ]
156+
157+ # # define grid = a single non-refenrece triangle
158+ xgrid = grid_triangle ([- 1.0 0.0 ; 1.0 0.0 ; 0.0 1.0 ]' )
159+
160+ # # define P2-Courant finite element space
161+ FES = FESpace {HDIVBDM2{2}} (xgrid)
162+ show (devnull , FES)
163+
164+ # # get midpoint quadrature rule for constants
165+ qf = QuadratureRule {Float64, Triangle2D} (0 )
166+
167+ # # define FE basis Evaluator for Hessian
168+ FEBE_curl2 = FEEvaluator (FES, Curl2D, qf)
169+
170+ # # update on cell 1
171+ update_basis! (FEBE_curl2, 1 )
172+
173+ # # interpolate quadratic testfunction
174+ Iu = FEVector (FES)
175+ interpolate! (Iu[1 ], testf)
176+
177+ # # check if operator evals have the correct length
178+ @assert size (FEBE_curl2. cvals, 1 ) == length (expected_curl2)
179+
180+ # compute derivatives
181+ curl2 = zeros (Float64, 1 )
182+ eval_febe! (curl2, FEBE_curl2, Iu. entries[FES[CellDofs][:, 1 ]], 1 )
183+
184+ # # compute errors to expected values
185+ error_curl2 = sqrt (sum ((curl2 - expected_curl2) .^ 2 ))
186+ println (" EG = Triangle2D | operator = Curl2 | error = $error_curl2 " )
187+
188+ return maximum ([error_curl2])
189+ end
190+
191+
143192function test_derivatives3D ()
144193 # # define test function and expected operator evals
145194 function testf (result, qpinfo)
@@ -220,3 +269,53 @@ function test_derivatives3D()
220269
221270 return maximum ([error_curl3, error_L, error_H, error_symH, error_symH2])
222271end
272+
273+
274+ function test_derivatives3D_hdiv ()
275+ # # define test function and expected operator evals
276+ function testf (result, qpinfo)
277+ x = qpinfo. x
278+ result[1 ] = x[2 ]
279+ result[2 ] = 3 * x[3 ]
280+ return result[3 ] = x[2 ]
281+ end
282+
283+ # # expected values of operators in cell midpoint
284+ expected_curl3 = [1 - 3 , 0 , - 1 ]
285+
286+ # # define grid = a single non-refenrece triangle
287+ xgrid = reference_domain (Tetrahedron3D)
288+ xgrid[Coordinates][:, 2 ] = [2 , 0 , 0 ]
289+
290+ # # define P2-Courant finite element space
291+ FES = FESpace {HDIVRT1{3}} (xgrid)
292+ show (devnull , FES)
293+
294+ # # get midpoint quadrature rule for constants
295+ qf = QuadratureRule {Float64, Tetrahedron3D} (0 )
296+
297+ # # define FE basis Evaluator for Hessian
298+ FEBE_curl3 = FEEvaluator (FES, Curl3D, qf)
299+
300+ # # update on cell 1
301+ update_basis! (FEBE_curl3, 1 )
302+
303+ # # interpolate quadratic testfunction
304+ Iu = FEVector (FES)
305+ interpolate! (Iu[1 ], testf)
306+
307+ # # check if operator evals have the correct length
308+ @assert size (FEBE_curl3. cvals, 1 ) == length (expected_curl3)
309+
310+ # # eval 2nd order derivatives at only quadrature point 1
311+ # # since function is quadratic this should be constant
312+ curl3 = zeros (Float64, 3 )
313+ eval_febe! (curl3, FEBE_curl3, Iu. entries[FES[CellDofs][:, 1 ]], 1 )
314+ @info curl3
315+
316+ # # compute errors to expected values
317+ error_curl3 = sqrt (sum ((curl3 - expected_curl3) .^ 2 ))
318+ println (" EG = Tetrahedron3D | operator = Curl3 | error = $error_curl3 " )
319+
320+ return maximum ([error_curl3])
321+ end
0 commit comments