def pod_info(coors_dim, eigenvectors, path, comm, rank, size): pod = Vectors() pod.P = np.vstack([eigenvectors.P.transpose(), coors_dim.transpose()]).transpose() pod.u = np.vstack([eigenvectors.u.transpose(), coors_dim.transpose()]).transpose() pod.v = np.vstack([eigenvectors.v.transpose(), coors_dim.transpose()]).transpose() pod.w = np.vstack([eigenvectors.w.transpose(), coors_dim.transpose()]).transpose() pod.T = np.vstack([eigenvectors.T.transpose(), coors_dim.transpose()]).transpose() # print "Number of POD obtained: " # print "For Pressure: %i" % eigenvalues.P.size # print "For U velocity: %i" % eigenvalues.u.size # print "For V velocity: %i" % eigenvalues.v.size # print "For W velocity: %i" % eigenvalues.w.size # print "For Temperature: %i" % eigenvalues.T.size print "-----------------------" print "--- OUTPUTTING PODS ---" print "-----------------------" for p in range(size): if rank == p: if rank == 0: fp = open(path + 'pod_pi.dat', 'wb') np.savetxt(fp, pod.P) fp.close() ftau = open(path + 'pod_tau.dat', 'wb') np.savetxt(ftau, pod.T) ftau.close() fu = open(path + 'pod_u.dat', 'wb') np.savetxt(fu, pod.u) fu.close() fv = open(path + 'pod_v.dat', 'wb') np.savetxt(fv, pod.v) fv.close() fw = open(path + 'pod_w.dat', 'wb') np.savetxt(fw, pod.w) fw.close() else: fp = open(path + 'pod_pi.dat', 'ab') np.savetxt(fp, pod.P) fp.close() ftau = open(path + 'pod_tau.dat', 'ab') np.savetxt(fp, pod.T) ftau.close() fu = open(path + 'pod_u.dat', 'ab') np.savetxt(fp, pod.u) fu.close() fv = open(path + 'pod_v.dat', 'ab') np.savetxt(fp, pod.v) fv.close() fw = open(path + 'pod_w.dat', 'ab') np.savetxt(fp, pod.w) fw.close() comm.Barrier() argumentop = 'python ./mode_plotter.py --file_pod pod_pi.dat --path ' + path[: -1] + ' --name pod_obtenido_pi --pod' argumentot = 'python ./mode_plotter.py --file_pod pod_tau.dat --path ' + path[: -1] + ' --name pod_obtenido_tau --pod' argumentou = 'python ./mode_plotter.py --file_pod pod_u.dat --path ' + path[: -1] + ' --name pod_obtenido_u --pod' argumentov = 'python ./mode_plotter.py --file_pod pod_v.dat --path ' + path[: -1] + ' --name pod_obtenido_v --pod' argumentow = 'python ./mode_plotter.py --file_pod pod_w.dat --path ' + path[: -1] + ' --name pod_obtenido_w --pod' os.system(argumentop) os.system(argumentou) os.system(argumentov) os.system(argumentow) os.system(argumentot) plot_velocity_field_files( 'Pods_vectorial_', path, path + 'pod_u.dat', path + 'pod_v.dat', )
def variables_info(coors, dimless_homogeneous_vars, name, path, new_indexes, snapshots_path, comm, rank, size): pod = Vectors() pod.P = np.vstack([ dimless_homogeneous_vars.P[ new_indexes.get_local_inner_indices(), :].transpose(), coors.coors_dim_rounded[ new_indexes.get_local_inner_indices(), :].transpose() ]).transpose() pod.u = np.vstack([ dimless_homogeneous_vars.u[ new_indexes.get_local_inner_indices(), :].transpose(), coors.coors_dim_rounded[ new_indexes.get_local_inner_indices(), :].transpose() ]).transpose() pod.v = np.vstack([ dimless_homogeneous_vars.v[ new_indexes.get_local_inner_indices(), :].transpose(), coors.coors_dim_rounded[ new_indexes.get_local_inner_indices(), :].transpose() ]).transpose() pod.w = np.vstack([ dimless_homogeneous_vars.w[ new_indexes.get_local_inner_indices(), :].transpose(), coors.coors_dim_rounded[ new_indexes.get_local_inner_indices(), :].transpose() ]).transpose() pod.T = np.vstack([ dimless_homogeneous_vars.T[ new_indexes.get_local_inner_indices(), :].transpose(), coors.coors_dim_rounded[ new_indexes.get_local_inner_indices(), :].transpose() ]).transpose() # print "Number of POD obtained: " # print "For Pressure: %i" % eigenvalues.P.size # print "For U velocity: %i" % eigenvalues.u.size # print "For V velocity: %i" % eigenvalues.v.size # print "For W velocity: %i" % eigenvalues.w.size # print "For Temperature: %i" % eigenvalues.T.size if rank == 0: print "------------------------------------------------" print "--- OUTPUTTING VARIABLES ---" print "------------------------------------------------" for p in range(size): if rank == p: if rank == 0: fp = open(path + name + 'pi.dat', 'wb') np.savetxt(fp, pod.P) fp.close() ftau = open(path + name + 'tau.dat', 'wb') np.savetxt(ftau, pod.T) ftau.close() fu = open(path + name + 'u.dat', 'wb') np.savetxt(fu, pod.u) fu.close() fv = open(path + name + 'v.dat', 'wb') np.savetxt(fv, pod.v) fv.close() fw = open(path + name + 'w.dat', 'wb') np.savetxt(fw, pod.w) fw.close() else: fp = open(path + name + 'pi.dat', 'ab') np.savetxt(fp, pod.P) fp.close() ftau = open(path + name + 'tau.dat', 'ab') np.savetxt(ftau, pod.T) ftau.close() fu = open(path + name + 'u.dat', 'ab') np.savetxt(fu, pod.u) fu.close() fv = open(path + name + 'v.dat', 'ab') np.savetxt(fv, pod.v) fv.close() fw = open(path + name + 'w.dat', 'ab') np.savetxt(fw, pod.w) fw.close() comm.Barrier() #modeploter_function(path, file_pod, name, pod_yes=False, dir=2, dx=0.000625): files_pod = [ name + 'pi.dat', name + 'tau.dat', name + 'u.dat', name + 'v.dat', name + 'w.dat' ] names = [name + 'pi', name + 'tau', name + 'u', name + 'v', name + 'w'] # argumentos.append('python ./mode_plotter.py --file_pod '+name+'pi.dat --path ' + path[:-1] + ' --name '+name+'pi --pod') # argumentos.append('python ./mode_plotter.py --file_pod '+name+'tau.dat --path ' + path[:-1] + ' --name '+name+'tau --pod') # argumentos.append('python ./mode_plotter.py --file_pod '+name+'u.dat --path ' + path[:-1] + ' --name '+name+'u --pod') # argumentos.append('python ./mode_plotter.py --file_pod '+name+'v.dat --path ' + path[:-1] + ' --name '+name+'v --pod') # argumentos.append('python ./mode_plotter.py --file_pod '+name+'w.dat --path ' + path[:-1] + ' --name '+name+'w --pod') # for p in range(len(files_pod)): # if p%size==rank: # # os.system(argumentos[p]) # modeploter_function(path, files_pod[p], names[p], True, False) # # os.system(argumentop) # # os.system(argumentou) # # os.system(argumentov) # # os.system(argumentow) # # os.system(argumentot) # # if rank==len(files_pod)%size: # plot_velocity_field_files('Vels_database_', path, path+name+'u.dat', path+name+'v.dat', snapshots_path) for p in range(len(files_pod)): if rank == 0: # os.system(argumentos[p]) modeploter_function(path, files_pod[p], names[p], True, False) plot_velocity_field_files('Vels_database_', path, path + name + 'u.dat', path + name + 'v.dat', snapshots_path)