Skip to content
Snippets Groups Projects

Add 2D field plotter and parameter reduction operators

Merged Jean-Baptiste Keck requested to merge (removed):multilayer_quasi_geostrophic into master
1 file
+ 24
4
Compare changes
  • Side-by-side
  • Inline
@@ -25,11 +25,11 @@ def compute(args):
from hysop.constants import Implementation, AdvectionCriteria
from hysop.operators import DirectionalAdvection, Advection, \
PoissonCurl, AdaptiveTimeStep, \
PoissonCurl, AdaptiveTimeStep, FieldPlotter2D, \
MinMaxFieldStatistics, StrangSplitting
from hysop.methods import SpaceDiscretization, Remesh, TimeIntegrator, \
ComputeGranularity, Interpolation
ComputeGranularity, Interpolation, Backend
from hysop.symbolic import space_symbols
@@ -164,6 +164,21 @@ def compute(args):
adapt_dt.push_advection_criteria(lcfl=args.lcfl, Finf=min_max_W.Finf,
criteria=AdvectionCriteria.W_INF)
# Field plotter
if args.plot_vorticity:
def fig_title(simulation):
return f'Fields at t={simulation.time:2.2e}, iteration={simulation.current_iteration}, dt={simulation.time_step:2.2e}s'
plot_fields = FieldPlotter2D(name='plot',
figsize=(16,6), shape=(1,3), add_colorbars=True, symmetric_cbar=True,
fields=(velo[0], velo[1], vorti), variables=npts, fig_title=fig_title,
update_frequency=args.plot_freq, save_frequency=args.plot_freq,
force_backend=Backend.OPENCL if impl is Implementation.OPENCL else None,
**extra_op_kwds)
else:
plot_fields = None
# Create the problem we want to solve and insert our
# directional splitting subgraph and the standard operators.
# The method dictionnary passed to this graph will be dispatched
@@ -177,9 +192,14 @@ def compute(args):
}
)
problem = Problem(method=method)
problem.insert(poisson, advec, min_max_U, min_max_W, adapt_dt)
problem.insert(poisson, advec, min_max_U, min_max_W, adapt_dt, plot_fields)
problem.build(args)
if plot_fields is not None:
plot_fields.axes[0,0].set_title('Velocity Ux')
plot_fields.axes[0,1].set_title('Velocity Uy')
plot_fields.axes[0,2].set_title('Vorticity ω')
# If a visu_rank was provided, and show_graph was set,
# display the graph on the given process rank.
if args.display_graph:
@@ -280,7 +300,7 @@ if __name__ == '__main__':
help=('Plot the vorticity component during simulation. ' +
'Simulation will stop at each time of interest and ' +
'the plot will be updated every specified freq iterations.'))
graphical_io.add_argument('-pf', '--plot-freq', type=int, default=10,
graphical_io.add_argument('-pf', '--plot-freq', type=int, default=100,
dest='plot_freq',
help=('Plot frequency in terms of iterations.'
+ ' Use 0 to disable frequency based plotting.'))
Loading