()
| 208 | |
| 209 | @pytest.mark.slow |
| 210 | def test_code_gen(): |
| 211 | mesh = Mesh(unit_cube.GenerateMesh(maxh=0.3)) |
| 212 | |
| 213 | VEC = VectorH1(mesh,order=1) |
| 214 | Phi,Psi = VEC.TnT() |
| 215 | gfvh = GridFunction(VEC) |
| 216 | gfvh.Set(CF( (x,y*x,x*y*z) ),definedon=mesh.Boundaries(".*")) |
| 217 | gfh = GridFunction(H1(mesh,order=1)) |
| 218 | gfh.Set(x*y*z,definedon=mesh.Boundaries(".*")) |
| 219 | |
| 220 | gfhc = GridFunction(HCurl(mesh,order=1)) |
| 221 | gfhc.Set(CF( (x,y*x,x*y*z) ),definedon=mesh.Boundaries(".*")) |
| 222 | gfhd = GridFunction(HDivSurface(mesh,order=1)) |
| 223 | gfhd.Set(CF( (x,y*x,x*y*z) ),definedon=mesh.Boundaries(".*")) |
| 224 | |
| 225 | |
| 226 | n = specialcf.normal(3) |
| 227 | |
| 228 | functions = [(CF(1)*ds).DiffShape(Psi),(Trace(Grad(n))*ds).DiffShape(Psi),(CF(1)*ds(element_boundary=True)).DiffShape(Psi), (Trace(Grad(gfvh).Trace())*ds).DiffShape(Psi), ((Grad(gfh).Trace())**2*ds).DiffShape(Psi), (curl(gfhc).Trace()*gfhc.Trace()*ds).DiffShape(Psi),(div(gfhd).Trace()*gfhd.Trace()*gfhd.Trace()*ds).DiffShape(Psi)] |
| 229 | |
| 230 | |
| 231 | for cf in functions: |
| 232 | cfs = [ cf.Compile(), cf.Compile(True, wait=True)] |
| 233 | for f in cfs: |
| 234 | lf = BilinearForm(VEC) |
| 235 | lf += Variation(cf-f) |
| 236 | assert lf.Energy(gfvh.vec) == approx(0) |
| 237 | |
| 238 | return |
| 239 | |
| 240 | if __name__ == "__main__": |
| 241 | test_diff() |
no test coverage detected