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

Function test_trace_implicit

dedalus/tests/test_cartesian_operators.py:171–187  ·  view source on GitHub ↗

Test implicit evaluation of trace operator for correctness.

(basis, N, dealias, dtype)

Source from the content-addressed store, hash-verified

169@pytest.mark.parametrize('dealias', dealias_range)
170@pytest.mark.parametrize('dtype', dtype_range)
171def test_trace_implicit(basis, N, dealias, dtype):
172 """Test implicit evaluation of trace operator for correctness."""
173 c, d, b, r = basis(N, dealias, dtype)
174 # Random scalar field
175 f = d.Field(bases=b)
176 f.fill_random(layout='g')
177 # Trace LBVP
178 u = d.Field(bases=b)
179 I = d.TensorField((c,c))
180 dim = len(r)
181 for i in range(dim):
182 I['g'][i,i] = 1
183 problem = d3.LBVP([u], namespace=locals())
184 problem.add_equation("trace(I*u) = dim*f")
185 solver = problem.build_solver()
186 solver.solve()
187 assert np.allclose(u['c'], f['c'])
188
189
190@pytest.mark.parametrize('basis', [build_FF, build_FC, build_CC, build_FFF, build_FFC])

Callers

nothing calls this directly

Calls 6

fill_randomMethod · 0.95
FieldMethod · 0.80
TensorFieldMethod · 0.80
add_equationMethod · 0.80
build_solverMethod · 0.80
solveMethod · 0.45

Tested by

no test coverage detected