I'm having trouble with manually saving state after manipulating a field variable within a time loop. I'm trying to perform a time step, do some operation on the field, and then save the resulting state.
...
problem = d3.IVP([u], namespace=locals())
...
solver = problem.build_solver(d3.RK222)
...
analysis = solver.evaluator.add_file_handler("data", max_writes=max_writes, mode="overwrite")
analysis.add_tasks(solver.state, layout='g')
while solver.proceed:
solver.step(time_step)
u['g'] = np.abs(u['g'])
if solver.iteration % save_cadence == 0:
solver.evaluator.evaluate_handlers([analysis], iteration=solver.iteration, sim_time=solver.sim_time)
...
But the evaluator still saves negative values of u.
Is there an obvious fix and/or better way of doing this kind of thing?
If not I'll make a minimal working example of exactly what I'm trying to do.
Cheers,
Sid