From 6a3791338698ec4f59228483e59bd03edead39dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franck=20P=C3=A9rignon?= <franck.perignon@imag.fr> Date: Fri, 28 Feb 2014 10:34:26 +0000 Subject: [PATCH] Update NSDebug + postProcess file --- Examples/NSDebug.py | 48 +++++++++++++++++++++-------- Examples/postNSBluff.py | 67 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 102 insertions(+), 13 deletions(-) create mode 100644 Examples/postNSBluff.py diff --git a/Examples/NSDebug.py b/Examples/NSDebug.py index bbc6095af..7ed53df66 100755 --- a/Examples/NSDebug.py +++ b/Examples/NSDebug.py @@ -134,14 +134,19 @@ distr = {} distr['fft2curl'] = Redistribute([velo], op['penalization'], op['curl']) distr['curl2fft'] = Redistribute([vorti], op['curl'], op['poisson']) -# 1 - Curl_fft to stretching (velocity only) -distr['Curl2Str'] = Redistribute([velo], op['curl'], op['stretching']) -# 2 - Advection to stretching (vorticity only) -distr['Advec2Str_v'] = Redistribute([velo], op['advection'], op['stretching']) -distr['Advec2Str_w'] = Redistribute([vorti], op['advection'], op['stretching']) +# 1 - Curl to stretching (velocity only) +#distr['curl2str'] = Redistribute([velo], op['curl'], op['stretching']) +# 2 - Advection to stretching +# velocity only +#distr['adv2str_v'] = Redistribute([velo], op['advection'], op['stretching']) +# vorticity only +#distr['adv2str_w'] = Redistribute([vorti], op['advection'], op['stretching']) +# Both +distr['adv2str'] = Redistribute([velo, vorti], + op['advection'], op['stretching']) # 3 - Stretching to Diffusion -distr['Str2diff'] = Redistribute([vorti], op['stretching'], op['diffusion']) -distr['Curl2Advec'] = Redistribute([vorti], op['curl'], op['advection']) +distr['str2diff'] = Redistribute([vorti], op['stretching'], op['diffusion']) +distr['curl2adv'] = Redistribute([velo, vorti], op['curl'], op['advection']) for ope in distr.values(): ope.discretize() @@ -215,6 +220,8 @@ def initFields_mode1(): distr['curl2fft'].apply(simu) # From this point both velocity and vorticity are initialized # on topofft and on topocurl + # Remark : we only need to initialize v on topocurl + # w computation and distribution is there just on test purpose. ## Call initialization initFields_mode1() @@ -236,7 +243,10 @@ for mon in monitors.values(): ## Note Franck : tests init ok, same values on both topologies, for v and w. - +# === After init === +# +# v init on topocurl (which may be equal to topofft) +# # === Definition of the 'one-step' sequence of operators === # # 1 - w = curl(v), topocurl @@ -247,21 +257,33 @@ for mon in monitors.values(): # 6 - v = correction(v, w), topofft # 7 - v = penalization(v), topofft # -fullseq = ['curl', 'printerCurl', 'advection', 'stretching', 'diffusion', - 'reprojection', 'poisson', 'correction', 'energy', 'forces', - 'printerFFT'] +# Required bridges : +# 1 --> 2 : (v,w) on topo-advec +# 2 --> 3 : (v,w) on topostr +# 3 --> 4 : w on topofft +# 7 --> 1 : v on topocurl + +fullseq = ['curl', 'printerCurl', # in: v, out : w both on topocurl + 'curl2adv', 'advection', # in: v,w out: w, on topoadvec + 'adv2str', 'stretching', # in: v,w out: w on topostr + # in: w, out: v, w on topofft + 'str2diff', 'diffusion', 'reprojection', 'poisson', 'correction', + 'penalization', 'energy', 'forces', 'printerFFT', + 'fft2curl' # Back to topocurl for v + ] def run(sequence): for name in sequence: assert allops.keys().count(name) > 0 or distr.keys().count(name) > 0\ - or monitors.keys().count(name) > 0 + or monitors.keys().count(name) > 0, 'unknow key:' + name allops[name].apply(simu) seq = fullseq simu.initialize() while not simu.isOver: - simu.printState() + if topocurl.rank == 0: + simu.printState() run(seq) simu.advance() diff --git a/Examples/postNSBluff.py b/Examples/postNSBluff.py new file mode 100644 index 000000000..6a7280e57 --- /dev/null +++ b/Examples/postNSBluff.py @@ -0,0 +1,67 @@ +import scitools.filetable as ft +import matplotlib.pyplot as plt + + +def plotEnergyEnstrophy(filename): + ff = open(filename) + data = ft.read(ff) + time = data[:, 0] + energy = data[:, 1] + enstrophy = data[:, 2] + plt.subplot(211) + plt.plot(time, energy, '+-', label='energy') + plt.xlabel('time') + plt.subplot(212) + plt.plot(time, enstrophy, '+-', label='enstrophy') + plt.xlabel('time') + plt.legend() + plt.suptitle('Results from simu in:' + filename) + plt.show() + + +def plotDragAndLift(filename): + ff = open(filename) + data = ft.read(ff) + time = data[:, 0] + drag = data[:, 1] + lift = data[:, 2:] + plt.subplot(211) + plt.plot(time, drag, '+-', label='drag') + plt.xlabel('time') + plt.subplot(212) + for i in xrange(lift.shape[1]): + plt.plot(time, lift[:, i], '+-', label='lift' + str(i)) + plt.xlabel('time') + plt.legend() + plt.suptitle('Results from simu in:' + filename) + plt.show() + + +def plotReprojection(filename): + ff = open(filename) + data = ft.read(ff) + time = data[:, 0] + crit = data[:, 1] + counter = data[:, 2] + d1 = data[:, 3] + d2 = data[:, 4] + plt.subplot(221) + plt.plot(time, crit, '+-', label='criterion') + plt.xlabel('time') + plt.subplot(222) + plt.plot(time, d1, '+-', label='d1') + plt.xlabel('time') + plt.subplot(223) + plt.plot(time, d2, '+-', label='d2') + plt.xlabel('time') + plt.legend() + plt.suptitle('Results from simu in:' + filename) + plt.show() + +plt.ioff() +direc = 'NSDebug' +nprocs = 1 +fileroot = direc + '/p' + str(nprocs) + '/' +plotEnergyEnstrophy(fileroot + 'energy_enstrophy') +plotDragAndLift(fileroot + 'drag_and_lift') + -- GitLab