MCPcopy Create free account
hub / github.com/NGSolve/ngsolve / test_code_generation_volume_terms

Function test_code_generation_volume_terms

tests/pytest/test_code_generation.py:7–38  ·  view source on GitHub ↗
(unit_mesh_3d)

Source from the content-addressed store, hash-verified

5
6@pytest.mark.slow
7def test_code_generation_volume_terms(unit_mesh_3d):
8 fes = L2(unit_mesh_3d, order=5)
9 gfu = GridFunction(fes)
10
11 cfvec = CF((1,)*10)
12 cf10 = InnerProduct(cfvec, cfvec)
13
14 cf_tensor3 = CF(tuple(range(1,25)), dims=(2,3,4))
15 cf_tensor = InnerProduct(cf_tensor3, cf_tensor3)
16
17 # piecewise polynomials - also test interpolation on L2 space and the resulting GridFunction
18 functions = [x,y,x*y, specialcf.mesh_size, CoefficientFunction((x,y)).Norm()**2, Id(3)[:,2][2], cf10, cf_tensor]
19
20 for cf in functions:
21 gfu.Set(cf)
22 # should all give the same results
23 cfs = [ cf.Compile(), cf.Compile(True, wait=True), gfu, gfu.Compile(), gfu.Compile(True, wait=True) ]
24
25 for f in cfs:
26 assert Integrate( (cf-f)*(cf-f), unit_mesh_3d) == approx(0)
27
28 cf8x8 = CoefficientFunction( tuple(range(8*8)), dims=(8,8) )
29 functions = [sin(x)*y, exp(x)+y*y*y, (1+x)**(1+y), cf8x8[1::3, 2:6], cf8x8[:,3], cf8x8[:,1:8:2]]
30 for cf in functions:
31 cfs = [ cf.Compile(), cf.Compile(True, wait=True)]
32 for f in cfs:
33 assert Integrate( Norm(cf-f), unit_mesh_3d) == approx(0)
34
35 cf = atan2(1+x,1+y)
36 cfs = [ cf.Compile(), cf.Compile(True, wait=True, maxderiv=0)]
37 for f in cfs:
38 assert Integrate( (cf-f)*(cf-f), unit_mesh_3d) == approx(0)
39
40@pytest.mark.slow
41def test_code_generation_boundary_terms(unit_mesh_3d):

Callers 1

Calls 10

IdClass · 0.85
NormFunction · 0.85
GridFunctionClass · 0.50
InnerProductFunction · 0.50
CoefficientFunctionClass · 0.50
sinFunction · 0.50
expFunction · 0.50
NormMethod · 0.45
SetMethod · 0.45
CompileMethod · 0.45

Tested by

no test coverage detected