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

Function test_diff

tests/pytest/test_shapeoptimization.py:102–117  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

100
101
102def test_diff():
103 mesh = Mesh(unit_square.GenerateMesh(maxh=0.1))
104
105 X = CF( (x,y) ).MakeVariable()
106 F = Id(2).MakeVariable()
107
108 uD = CF( X[1]*(1-X[1])-X[0]*(1-X[0]) )
109
110 assert sqrt(Integrate((uD.Diff(X, CF( (2,3*x) )) - (-2*(1-2*x) + 3*x*(1-2*y)))**2,mesh)) < 1e-15
111 var = CF( (x,y,-x,x*y), dims=(2,2))
112
113 cf = F*CF( (1,1) )*CF( (3,5) )
114 assert sqrt(Integrate((cf.Diff(F, var) - var*CF( (1,1) )*CF( (3,5) ))**2,mesh)) < 1e-15
115 cf = F.trans*CF( (1,1) )*CF( (3,5) )
116 assert sqrt(Integrate((cf.Diff(F, var) - var.trans*CF( (1,1) )*CF( (3,5) ))**2,mesh)) < 1e-15
117 return
118
119def test_shapeopt_2d():
120 # return # disable tests

Callers 1

Calls 3

IdClass · 0.85
sqrtFunction · 0.50
DiffMethod · 0.45

Tested by

no test coverage detected