MCPcopy Create free account
hub / github.com/DedalusProject/dedalus / test_curl_implicit_FFF

Function test_curl_implicit_FFF

dedalus/tests/test_cartesian_operators.py:320–349  ·  view source on GitHub ↗

Test implicit evaluation of 3D periodic curl operator for correctness.

(basis, N, dealias, dtype)

Source from the content-addressed store, hash-verified

318@pytest.mark.parametrize('dealias', dealias_range)
319@pytest.mark.parametrize('dtype', dtype_range)
320def test_curl_implicit_FFF(basis, N, dealias, dtype):
321 """Test implicit evaluation of 3D periodic curl operator for correctness."""
322 c, d, b, r = basis(N, dealias, dtype)
323 # ABC vector field
324 k = 2 * np.pi * np.array([1/Lx, 1/Ly, 1/Lz])
325 f = d.VectorField(c, bases=b)
326 f.preset_scales(dealias)
327 f['g'][0] = np.sin(k[2]*r[2]) + np.cos(k[1]*r[1])
328 f['g'][1] = np.sin(k[0]*r[0]) + np.cos(k[2]*r[2])
329 f['g'][2] = np.sin(k[1]*r[1]) + np.cos(k[0]*r[0])
330 g = d.VectorField(c, bases=b)
331 g.preset_scales(dealias)
332 g['g'][0] = k[2]*np.sin(k[2]*r[2]) + k[1]*np.cos(k[1]*r[1])
333 g['g'][1] = k[0]*np.sin(k[0]*r[0]) + k[2]*np.cos(k[2]*r[2])
334 g['g'][2] = k[1]*np.sin(k[1]*r[1]) + k[0]*np.cos(k[0]*r[0])
335 # Helmholtz LBVP
336 u = d.VectorField(c, name='u', bases=b)
337 phi = d.Field(name='phi', bases=b)
338 tau1 = d.VectorField(c, name='tau1')
339 tau2 = d.Field(name='tau2')
340 problem = d3.LBVP([u, phi, tau1, tau2], namespace=locals())
341 problem.add_equation("curl(u) + grad(phi) + tau1 = g")
342 problem.add_equation("div(u) + tau2 = 0")
343 problem.add_equation("integ(phi) = 0")
344 problem.add_equation("integ(comp(u,index=0,comp=c['x'])) = 0")
345 problem.add_equation("integ(comp(u,index=0,comp=c['y'])) = 0")
346 problem.add_equation("integ(comp(u,index=0,comp=c['z'])) = 0")
347 solver = problem.build_solver()
348 solver.solve()
349 assert np.allclose(u['c'], f['c'])
350
351
352@pytest.mark.parametrize('basis', [build_FFC])

Callers

nothing calls this directly

Calls 7

arrayMethod · 0.80
VectorFieldMethod · 0.80
preset_scalesMethod · 0.80
FieldMethod · 0.80
add_equationMethod · 0.80
build_solverMethod · 0.80
solveMethod · 0.45

Tested by

no test coverage detected