diff --git a/Metafor/Mparams/Metafor_call.py b/Metafor/Mparams/Metafor_call.py index a4d2a31e082c7b9409985893c353c62d0428abd6..2b4e9cde4a4f3312374bf0920d7f8c21d7fe6d22 100644 --- a/Metafor/Mparams/Metafor_call.py +++ b/Metafor/Mparams/Metafor_call.py @@ -16,6 +16,7 @@ # limitations under the License. +from __future__ import print_function import numpy as np import os import shutil @@ -28,7 +29,7 @@ def Metafor_call(d): import shlex, subprocess import platform command_line = d['Metafor_exe'] + ' -nogui' - print command_line + print(command_line) args = shlex.split(command_line) fileout = open('Metafor.log','w') diff --git a/Metafor/Mparams/TaskManager.py b/Metafor/Mparams/TaskManager.py index ba913f013f478fa42e3927256786396b8b77963a..319ab695143d21a4d1adaaff2767d9e44173b735 100644 --- a/Metafor/Mparams/TaskManager.py +++ b/Metafor/Mparams/TaskManager.py @@ -16,6 +16,7 @@ # limitations under the License. +from __future__ import print_function import tbox import math @@ -37,13 +38,13 @@ try: siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") def enum(*sequential, **named): enums = dict(zip(sequential, range(len(sequential))), **named) @@ -98,12 +99,12 @@ class Master: global rank if rank!=0: raise Exception("this routine should be called with MPI rank=0") - if verb: print "[%d] starting master" % rank + if verb: print("[%d] starting master" % rank) ##----------------------------------------- for s in self.slaves: - if verb: print "[%d] sending wake-up signal to worker %d" % (rank,s) + if verb: print("[%d] sending wake-up signal to worker %d" % (rank,s)) comm.send(None, dest=s, tag=tags.WAKEUP) ################################################# @@ -128,7 +129,7 @@ class Master: from params.src.monomials_1norm import phi from params.src.monomials_1norm import compute_n_max n_max = compute_n_max(N,d) - print n_max + print(n_max) if surrogate_parameters['training_points'] == 'gauss': import params.src.gauss as tp elif surrogate_parameters['training_points'] == 'gamma': @@ -157,7 +158,7 @@ class Master: else: X, w = tp.grid(M) - print X + print(X) @@ -195,7 +196,7 @@ class Master: source = status.Get_source() tag = status.Get_tag() if tag == tags.READY: - if verb: print "[0] worker %d is ready" % source + if verb: print("[0] worker %d is ready" % source) ################################################# @@ -203,7 +204,7 @@ class Master: if surrogate_parameters['training_points'] == 'precomputed': if normalisation == False: for j in range(0,d): - print X[0][0] + print(X[0][0]) xi[j] = X[i[j]][j] else: means = surrogate_parameters['means'] @@ -224,7 +225,7 @@ class Master: xi = tp.f_mapping(xi_in,d,means,variances,correlations,surrogate_parameters['f_mapping_method']) - print xi + print(xi) elif normalisation == True: for j in range(0,d): xi[j] = X[i[j],j] @@ -261,7 +262,7 @@ class Master: if surrogate_parameters['training_points'] != 'precomputed': for j in range(0,d): tmp = xi[j] - print tmp + print(tmp) parameters[P_name[j]] = tmp if surrogate_parameters['training_points'] == 'precomputed': @@ -294,22 +295,22 @@ class Master: job = Job(parameters, name, xi, m_i) - if verb: print "[0] sending job to %d" % source + if verb: print("[0] sending job to %d" % source) comm.send(job, dest=source, tag=tags.START) # ------------------- - p,i = indices.next(p,i,M,d) + p,i = indices.my_next(p,i,M,d) m_i = m_i+1 else: ################################################# - if verb: print "[%d] exit %d" % (rank,source) + if verb: print("[%d] exit %d" % (rank,source)) comm.send(None, dest=source, tag=tags.EXIT) elif tag==tags.DONE: - if verb: print "[0] worker %d gives me its results" % source + if verb: print("[0] worker %d gives me its results" % source) ################################################# m_ii = data.m_i @@ -323,7 +324,7 @@ class Master: elif tag==tags.EXIT: closed_workers+=1 - if verb: print "[0] worker %d exited (%d worker(s) still running)" % (source, num_workers-closed_workers) + if verb: print("[0] worker %d exited (%d worker(s) still running)" % (source, num_workers-closed_workers)) ##----------------------------------------- @@ -340,7 +341,7 @@ class Master: def killslaves(self): global rank for s in self.slaves: - if verb: print "[%d] sending suicide job to %d" % (rank,s) + if verb: print("[%d] sending suicide job to %d" % (rank,s)) comm.send(None, dest=s, tag=tags.SUICIDE) @@ -358,32 +359,32 @@ class Worker: if self.rank==0: raise Exception("this routine should be called with MPI rank!=0") - if verb: print "[%d] starting worker" % self.rank + if verb: print("[%d] starting worker" % self.rank) timers = fwk.Timers() timers['total'].start() while True: comm.recv(source=0, tag=mpi.ANY_TAG, status=status) tag = status.Get_tag() if tag==tags.WAKEUP: - if verb: print "[%d] waking up" % self.rank + if verb: print("[%d] waking up" % self.rank) while True: comm.send(None, dest=0, tag=tags.READY) job = comm.recv(source=0, tag=mpi.ANY_TAG, status=status) tag = status.Get_tag() if tag==tags.START: - if verb: print "[%d] starting job" % self.rank + if verb: print("[%d] starting job" % self.rank) name = str(job.m_i)+'_'+job.name timers[name].start() job.execute() timers[name].stop() - if verb: print "[%d] sending job results" % self.rank + if verb: print("[%d] sending job results" % self.rank) comm.send(job, dest=0, tag=tags.DONE) elif tag==tags.EXIT: - if verb: print "[%d] sending exit confirmation" % self.rank + if verb: print("[%d] sending exit confirmation" % self.rank) comm.send(None, dest=0, tag=tags.EXIT) timers['total'].stop() - print timers + print(timers) break elif tag==tags.SUICIDE: - if verb: print "[%d] I'm dying..." % self.rank + if verb: print("[%d] I'm dying..." % self.rank) break diff --git a/Metafor/Mparams/sequential.py b/Metafor/Mparams/sequential.py index 637169053f2fa663680ab37f4be6c1b1295b3e72..4b90691d377a5452160e0a3f99dddc334ea7ab6b 100644 --- a/Metafor/Mparams/sequential.py +++ b/Metafor/Mparams/sequential.py @@ -16,6 +16,7 @@ # limitations under the License. +from __future__ import print_function import numpy as np import os import shutil @@ -140,7 +141,7 @@ def evaluate(parameters, surrogate_parameters, images_parameters): m_i = m_i + 1 - p,i = indices.next(p,i,M,d) + p,i = indices.my_next(p,i,M,d) #------------------ @@ -283,7 +284,7 @@ def Z_evaluate(parameters, surrogate_parameters): m_i = m_i + 1 - p,i = indices.next(p,i,M,d) + p,i = indices.my_next(p,i,M,d) return Z, W_sr, Xi, Xi2 @@ -329,12 +330,12 @@ def scatterplot(sol, surrogate_parameters, images_parameters): X = np.array(b_new) tmp = np.shape(X) - print tmp + print(tmp) m_max = tmp[0] - print max(X[:,0]) - print min(X[:,0]) - print max(X[:,1]) - print min(X[:,1]) + print(max(X[:,0])) + print(min(X[:,0])) + print(max(X[:,1])) + print(min(X[:,1])) xi = np.zeros((d,)) @@ -368,7 +369,7 @@ def scatterplot(sol, surrogate_parameters, images_parameters): for j in range(0,d): xi_tp[m_i,j] = xi[j] m_i = m_i + 1 - p,i = indices.next(p,i,M,d) + p,i = indices.my_next(p,i,M,d) plot.scatters(xi_tp,sol,d,fig,ax, True,m_i) Image['fig'] = fig diff --git a/Metafor/Mparams/surrogate.py b/Metafor/Mparams/surrogate.py index 7837a358eed1f958191bbd6fc5ec5e75f49d535c..7b519f5f2284c49588989af56d9ae920770ba9a8 100644 --- a/Metafor/Mparams/surrogate.py +++ b/Metafor/Mparams/surrogate.py @@ -16,6 +16,7 @@ # limitations under the License. +from __future__ import print_function import numpy as np import os import shutil @@ -116,7 +117,7 @@ def surrogate_creation(sol, Z, W_sr, surrogate_parameters, Image, images_paramet if solver == 'QR': W_srZ = np.dot(W_sr,Z) - print np.linalg.cond(W_srZ) + print(np.linalg.cond(W_srZ)) Q, R = np.linalg.qr(W_srZ) rhs = np.dot(np.transpose(Q),np.dot(W_sr,sol)) s_hat = np.linalg.solve(R, rhs) @@ -128,7 +129,7 @@ def surrogate_creation(sol, Z, W_sr, surrogate_parameters, Image, images_paramet if solver == 'sp': W_srZ = np.dot(W_sr,Z) ZWZ = np.dot(np.transpose(W_srZ),W_srZ) - print np.linalg.cond(ZWZ) + print(np.linalg.cond(ZWZ)) rhs = np.dot(np.transpose(W_srZ),np.dot(W_sr,sol)) import scipy.sparse.linalg s_hat = scipy.sparse.linalg.spsolve(ZWZ, rhs, 'NATURAL', False) @@ -139,7 +140,7 @@ def surrogate_creation(sol, Z, W_sr, surrogate_parameters, Image, images_paramet if solver == 'numpy_linalg': W_srZ = np.dot(W_sr,Z) ZWZ = np.dot(np.transpose(W_srZ),W_srZ) - print np.linalg.cond(ZWZ) + print(np.linalg.cond(ZWZ)) rhs = np.dot(np.transpose(W_srZ),np.dot(W_sr,sol)) s_hat = np.linalg.solve(ZWZ, rhs) for i in range(0,m1): @@ -149,7 +150,7 @@ def surrogate_creation(sol, Z, W_sr, surrogate_parameters, Image, images_paramet if solver == 'scipy_linalg': W_srZ = np.dot(W_sr,Z) ZWZ = np.dot(np.transpose(W_srZ),W_srZ) - print np.linalg.cond(ZWZ) + print(np.linalg.cond(ZWZ)) rhs = np.dot(np.transpose(W_srZ),np.dot(W_sr,sol)) import scipy.sparse.linalg s_hat = scipy.linalg.solve(ZWZ, rhs) @@ -160,12 +161,12 @@ def surrogate_creation(sol, Z, W_sr, surrogate_parameters, Image, images_paramet if solver == 'scipy_lu': W_srZ = np.dot(W_sr,Z) ZWZ = np.dot(np.transpose(W_srZ),W_srZ) - print np.linalg.cond(ZWZ) + print(np.linalg.cond(ZWZ)) rhs = np.dot(np.transpose(W_srZ),np.dot(W_sr,sol)) import scipy.sparse.linalg PL, U = scipy.linalg.lu(ZWZ,True) - print np.linalg.cond(PL) - print np.linalg.cond(U) + print(np.linalg.cond(PL)) + print(np.linalg.cond(U)) tmp = scipy.linalg.solve(PL,rhs) s_hat = scipy.linalg.solve(U,tmp) for i in range(0,m1): @@ -175,7 +176,7 @@ def surrogate_creation(sol, Z, W_sr, surrogate_parameters, Image, images_paramet if solver == 'minres': W_srZ = np.dot(W_sr,Z) ZWZ = np.dot(np.transpose(W_srZ),W_srZ) - print np.linalg.cond(ZWZ) + print(np.linalg.cond(ZWZ)) rhs = np.dot(np.transpose(W_srZ),np.dot(W_sr,sol)) import scipy.sparse.linalg s_hat, info = scipy.sparse.linalg.minres(ZWZ, rhs) @@ -186,7 +187,7 @@ def surrogate_creation(sol, Z, W_sr, surrogate_parameters, Image, images_paramet if solver == 'gmres': W_srZ = np.dot(W_sr,Z) ZWZ = np.dot(np.transpose(W_srZ),W_srZ) - print np.linalg.cond(ZWZ) + print(np.linalg.cond(ZWZ)) rhs = np.dot(np.transpose(W_srZ),np.dot(W_sr,sol)) import scipy.sparse.linalg s_hat, info = scipy.sparse.linalg.gmres(ZWZ, rhs) @@ -197,7 +198,7 @@ def surrogate_creation(sol, Z, W_sr, surrogate_parameters, Image, images_paramet if solver == 'lgmres': W_srZ = np.dot(W_sr,Z) ZWZ = np.dot(np.transpose(W_srZ),W_srZ) - print np.linalg.cond(ZWZ) + print(np.linalg.cond(ZWZ)) rhs = np.dot(np.transpose(W_srZ),np.dot(W_sr,sol)) import scipy.sparse.linalg s_hat, info = scipy.sparse.linalg.lgmres(ZWZ, rhs) @@ -207,7 +208,7 @@ def surrogate_creation(sol, Z, W_sr, surrogate_parameters, Image, images_paramet if solver == 'lsqr': W_srZ = np.dot(W_sr,Z) - print np.linalg.cond(W_srZ) + print(np.linalg.cond(W_srZ)) rhs = np.dot(W_sr,sol) import scipy.sparse.linalg s_hat, istop, itn, r1norm, r2norm, anorm, acond, arnorm, xnorm, var = scipy.sparse.linalg.lsqr(W_srZ, rhs) @@ -217,28 +218,28 @@ def surrogate_creation(sol, Z, W_sr, surrogate_parameters, Image, images_paramet if solver == 'lsmr': W_srZ = np.dot(W_sr,Z) - print np.linalg.cond(W_srZ) + print(np.linalg.cond(W_srZ)) rhs = np.dot(W_sr,sol) import scipy.sparse.linalg s_hat, lstop, itn, normr, normar, norma, conda, normx = scipy.sparse.linalg.lsmr(W_srZ, rhs,1e045) - print lstop - print itn - print normr - print normar - print norma - print conda - print normx + print(lstop) + print(itn) + print(normr) + print(normar) + print(norma) + print(conda) + print(normx) for i in range(0,m1): for j in range(0,m2): surrogate[i,j] = np.dot(np.transpose(phi_tmp[i,j,:]),s_hat) if solver == 'lstsq': W_srZ = np.dot(W_sr,Z) - print np.linalg.cond(W_srZ) + print(np.linalg.cond(W_srZ)) rhs = np.dot(W_sr,sol) import scipy.linalg s_hat, residues, rank, s = scipy.linalg.lstsq(W_srZ, rhs) - print rank + print(rank) for i in range(0,m1): for j in range(0,m2): surrogate[i,j] = np.dot(np.transpose(phi_tmp[i,j,:]),s_hat) @@ -296,8 +297,8 @@ def surrogate_4d(sol, Z, W_sr, s_hat, surrogate_parameters, Image, images_parame c_min = sol.min() c_max = sol.max() - print index_c - print point_c + print(index_c) + print(point_c) for c in range(0,n_c): X = np.zeros((m1,m2)) @@ -305,7 +306,7 @@ def surrogate_4d(sol, Z, W_sr, s_hat, surrogate_parameters, Image, images_parame Z = np.zeros((m1,m2)) xi0 = point_c[c] - print index_c[c] + print(index_c[c]) for i in range(0,m1): for j in range(0,m2): xi = np.zeros((d,)) diff --git a/Metafor/config/bord01_config1.py b/Metafor/config/bord01_config1.py index e02cd47f19b959b7bdc9ae6d28adc2013b773789..ac998ec172c2562e94ea3055f5988570ade4b299 100644 --- a/Metafor/config/bord01_config1.py +++ b/Metafor/config/bord01_config1.py @@ -16,6 +16,7 @@ # limitations under the License. +from __future__ import print_function import numpy as np import os import shutil @@ -89,9 +90,9 @@ def main(): if mp.AvailableComputedResults(): if tm.rank == 0: - print "the master/sol.json file will be loaded" - print "the master/Z.json file will be loaded" - print "the master/W_sr.json file will be loaded" + print("the master/sol.json file will be loaded") + print("the master/Z.json file will be loaded") + print("the master/W_sr.json file will be loaded") sol, Z, W_sr = mp.LoadComputedResults() from Metafor.Mparams.sequential import scatterplot diff --git a/Metafor/config/bord01_config10.py b/Metafor/config/bord01_config10.py index 49e1e4d1b6bbb714f364742e4f908fa915a87da4..4151661f5fa56ca5d6ff211343c99a049146083d 100644 --- a/Metafor/config/bord01_config10.py +++ b/Metafor/config/bord01_config10.py @@ -16,6 +16,7 @@ # limitations under the License. +from __future__ import print_function import numpy as np import os import shutil @@ -150,29 +151,29 @@ def main(): W_srZsigma_max[m_i,p_i] = s2.max() W_srZsigma_min[m_i,p_i] = s2.min() - print 'Condition number of Z' - print Zcond - print 'Rank of ZZ' - print ZZrank - print 'Determinant of ZZ' - print ZZdet - - print 'Maximal singular value of Z' - print Zsigma_max - print 'Minimal singular value of Z' - print Zsigma_min - - print 'Condition number of W_srZ' - print W_srZcond - print 'Rank of ZWZ' - print ZWZrank - print 'Determinant of ZWZ' - print ZWZdet - - print 'Maximal singular value of W_srZ' - print W_srZsigma_max - print 'Minimal singular value of W_srZ' - print W_srZsigma_min + print('Condition number of Z') + print(Zcond) + print('Rank of ZZ') + print(ZZrank) + print('Determinant of ZZ') + print(ZZdet) + + print('Maximal singular value of Z') + print(Zsigma_max) + print('Minimal singular value of Z') + print(Zsigma_min) + + print('Condition number of W_srZ') + print(W_srZcond) + print('Rank of ZWZ') + print(ZWZrank) + print('Determinant of ZWZ') + print(ZWZdet) + + print('Maximal singular value of W_srZ') + print(W_srZsigma_max) + print('Minimal singular value of W_srZ') + print(W_srZsigma_min) ''' else: if tm.rank == 0: diff --git a/Metafor/config/bord01_config11.py b/Metafor/config/bord01_config11.py index bce77978a7a84e188ace053385cbf01f44690400..becde72e92c4a493681dd4e42fe4db8586bea5a5 100644 --- a/Metafor/config/bord01_config11.py +++ b/Metafor/config/bord01_config11.py @@ -16,6 +16,7 @@ # limitations under the License. +from __future__ import print_function import numpy as np import os import shutil @@ -155,33 +156,33 @@ def main(): W_srZsigma_max[nst_i,m_i] = s2.max() W_srZsigma_min[nst_i,m_i] = s2.min() - print 'Max of abs(Xi2)' - print Xi2max - print 'Min of abs(Xi2)' - print Xi2min - print 'Condition number of Z' - print Zcond - print 'Rank of ZZ' - print ZZrank - print 'Determinant of ZZ' - print ZZdet - - print 'Maximal singular value of Z' - print Zsigma_max - print 'Minimal singular value of Z' - print Zsigma_min - - print 'Condition number of W_srZ' - print W_srZcond - print 'Rank of ZWZ' - print ZWZrank - print 'Determinant of ZWZ' - print ZWZdet - - print 'Maximal singular value of W_srZ' - print W_srZsigma_max - print 'Minimal singular value of W_srZ' - print W_srZsigma_min + print('Max of abs(Xi2)') + print(Xi2max) + print('Min of abs(Xi2)') + print(Xi2min) + print('Condition number of Z') + print(Zcond) + print('Rank of ZZ') + print(ZZrank) + print('Determinant of ZZ') + print(ZZdet) + + print('Maximal singular value of Z') + print(Zsigma_max) + print('Minimal singular value of Z') + print(Zsigma_min) + + print('Condition number of W_srZ') + print(W_srZcond) + print('Rank of ZWZ') + print(ZWZrank) + print('Determinant of ZWZ') + print(ZWZdet) + + print('Maximal singular value of W_srZ') + print(W_srZsigma_max) + print('Minimal singular value of W_srZ') + print(W_srZsigma_min) ''' else: if tm.rank == 0: diff --git a/Metafor/config/bord01_config12.py b/Metafor/config/bord01_config12.py index 3d057ebdbe43301c2f776401973d25f26be7595c..9c86ce9b97ba1c5ad7e9704d99b79b8aa9db563f 100644 --- a/Metafor/config/bord01_config12.py +++ b/Metafor/config/bord01_config12.py @@ -16,6 +16,7 @@ # limitations under the License. +from __future__ import print_function import numpy as np import os import shutil @@ -93,9 +94,9 @@ def main(): if mp.AvailableComputedResults(): if tm.rank == 0: - print "the master/sol.json file will be loaded" - print "the master/Z.json file will be loaded" - print "the master/W_sr.json file will be loaded" + print("the master/sol.json file will be loaded") + print("the master/Z.json file will be loaded") + print("the master/W_sr.json file will be loaded") sol, Z, W_sr = mp.LoadComputedResults() from Metafor.Mparams.sequential import scatterplot diff --git a/Metafor/config/bord01_config13.py b/Metafor/config/bord01_config13.py index 5ec31a0ff14fdf8ac8e3798246b520c3ff7c7c73..aa3a8f0223e967ad7b9bfe5b00671dd359a974f9 100644 --- a/Metafor/config/bord01_config13.py +++ b/Metafor/config/bord01_config13.py @@ -16,6 +16,7 @@ # limitations under the License. +from __future__ import print_function import numpy as np import os import shutil @@ -95,9 +96,9 @@ def main(): if mp.AvailableComputedResults(): if tm.rank == 0: - print "the master/sol.json file will be loaded" - print "the master/Z.json file will be loaded" - print "the master/W_sr.json file will be loaded" + print("the master/sol.json file will be loaded") + print("the master/Z.json file will be loaded") + print("the master/W_sr.json file will be loaded") sol, Z, W_sr = mp.LoadComputedResults() @@ -158,15 +159,15 @@ def main(): max_w_residual[i] = np.abs(w_res).max() min_w_residual[i] = np.abs(w_res).min() ''' - print i + print(i) #import matplotlib.pyplot as plt #plt.semilogy(nstddeviation, cond) #plt.show() - print 'Condition number of W_srZ' - print cond.T - print 'nstddeviation' - print nstddeviation.T + print('Condition number of W_srZ') + print(cond.T) + print('nstddeviation') + print(nstddeviation.T) #''' surrogate_parameters['nstddeviation'] = 2.6281407 @@ -179,13 +180,13 @@ def main(): Image = scatterplot(sol, surrogate_parameters, images_parameters) s_hat_w = surrogate_creation(sol, Z, W_sr, surrogate_parameters, Image, images_parameters) - print s_hat_w.T + print(s_hat_w.T) W_sr = np.eye(W_sr.shape[0]) Image = scatterplot(sol, surrogate_parameters, images_parameters) s_hat_wout = surrogate_creation(sol, Z, W_sr, surrogate_parameters, Image, images_parameters) - print s_hat_wout.T + print(s_hat_wout.T) ## --------------------------- from params.src.monomials_1norm import phi @@ -205,7 +206,7 @@ def main(): xi_s = np.zeros((2,n_MC)) for i in range(0,n_MC): if np.mod(i,1000) == 0: - print i + print(i) xi_in = np.random.normal(0., 1., 2) diff --git a/Metafor/config/bord01_config2.py b/Metafor/config/bord01_config2.py index 8ba6a1d2ff53f2cfabc4f7f62fcf00f8c9c01963..3c540e9a75923ef13a4a9b01347c92c5bd2d7f73 100644 --- a/Metafor/config/bord01_config2.py +++ b/Metafor/config/bord01_config2.py @@ -16,6 +16,7 @@ # limitations under the License. +from __future__ import print_function import numpy as np import os import shutil @@ -84,9 +85,9 @@ def main(): if mp.AvailableComputedResults(): if tm.rank == 0: - print "the master/sol.json file will be loaded" - print "the master/Z.json file will be loaded" - print "the master/W_sr.json file will be loaded" + print("the master/sol.json file will be loaded") + print("the master/Z.json file will be loaded") + print("the master/W_sr.json file will be loaded") sol, Z, W_sr = mp.LoadComputedResults() from Metafor.Mparams.sequential import scatterplot diff --git a/Metafor/config/bord01_config3.py b/Metafor/config/bord01_config3.py index be01735f5261c8306b6b12094d72ab050cfd8a64..36d44319cf3fcc24c4d597b29655506c6a3aa916 100644 --- a/Metafor/config/bord01_config3.py +++ b/Metafor/config/bord01_config3.py @@ -16,6 +16,7 @@ # limitations under the License. +from __future__ import print_function import numpy as np import os import shutil @@ -84,9 +85,9 @@ def main(): if mp.AvailableComputedResults(): if tm.rank == 0: - print "the master/sol.json file will be loaded" - print "the master/Z.json file will be loaded" - print "the master/W_sr.json file will be loaded" + print("the master/sol.json file will be loaded") + print("the master/Z.json file will be loaded") + print("the master/W_sr.json file will be loaded") sol, Z, W_sr = mp.LoadComputedResults() from Metafor.Mparams.sequential import scatterplot diff --git a/Metafor/config/bord01_config4.py b/Metafor/config/bord01_config4.py index eb6d2424952382d377721a0bbe191a92ad3c39d9..352761fa66d492aa5c4062a525006e8146ab2428 100644 --- a/Metafor/config/bord01_config4.py +++ b/Metafor/config/bord01_config4.py @@ -16,6 +16,7 @@ # limitations under the License. +from __future__ import print_function import numpy as np import os import shutil @@ -92,9 +93,9 @@ def main(): if mp.AvailableComputedResults(): if tm.rank == 0: - print "the master/sol.json file will be loaded" - print "the master/Z.json file will be loaded" - print "the master/W_sr.json file will be loaded" + print("the master/sol.json file will be loaded") + print("the master/Z.json file will be loaded") + print("the master/W_sr.json file will be loaded") sol, Z, W_sr = mp.LoadComputedResults() if 1: @@ -111,7 +112,7 @@ def main(): W_srZ = np.dot(W_sr,Z) cond[i-1] = np.linalg.cond(W_srZ) - print cond + print(cond) from Metafor.Mparams.sequential import scatterplot diff --git a/Metafor/config/bord01_config5.py b/Metafor/config/bord01_config5.py index 31009774fab6b377f6907758788444ecf4a18f0c..9f821b344d9e91a1f6ea6b1cae8b23f727497432 100644 --- a/Metafor/config/bord01_config5.py +++ b/Metafor/config/bord01_config5.py @@ -16,6 +16,7 @@ # limitations under the License. +from __future__ import print_function import numpy as np import os import shutil @@ -84,9 +85,9 @@ def main(): if mp.AvailableComputedResults(): if tm.rank == 0: - print "the master/sol.json file will be loaded" - print "the master/Z.json file will be loaded" - print "the master/W_sr.json file will be loaded" + print("the master/sol.json file will be loaded") + print("the master/Z.json file will be loaded") + print("the master/W_sr.json file will be loaded") sol, Z, W_sr = mp.LoadComputedResults() from Metafor.Mparams.sequential import scatterplot diff --git a/Metafor/config/bord01_config6.py b/Metafor/config/bord01_config6.py index cf58e190f5a4f34d2df548a8fa202c3a289ed815..f022087d9584b47e23ef6563e173fa552670b037 100644 --- a/Metafor/config/bord01_config6.py +++ b/Metafor/config/bord01_config6.py @@ -16,6 +16,7 @@ # limitations under the License. +from __future__ import print_function import numpy as np import os import shutil @@ -84,9 +85,9 @@ def main(): if mp.AvailableComputedResults(): if tm.rank == 0: - print "the master/sol.json file will be loaded" - print "the master/Z.json file will be loaded" - print "the master/W_sr.json file will be loaded" + print("the master/sol.json file will be loaded") + print("the master/Z.json file will be loaded") + print("the master/W_sr.json file will be loaded") sol, Z, W_sr = mp.LoadComputedResults() from Metafor.Mparams.sequential import scatterplot diff --git a/Metafor/config/bord01_config7.py b/Metafor/config/bord01_config7.py index b59dfadc34f11ec1f0014425c556e81d1a3f097e..4f3ddbda1c661c3524c69577c9b592e20a37a41a 100644 --- a/Metafor/config/bord01_config7.py +++ b/Metafor/config/bord01_config7.py @@ -16,6 +16,7 @@ # limitations under the License. +from __future__ import print_function import numpy as np import os import shutil @@ -92,9 +93,9 @@ def main(): if mp.AvailableComputedResults(): if tm.rank == 0: - print "the master/sol.json file will be loaded" - print "the master/Z.json file will be loaded" - print "the master/W_sr.json file will be loaded" + print("the master/sol.json file will be loaded") + print("the master/Z.json file will be loaded") + print("the master/W_sr.json file will be loaded") sol, Z, W_sr = mp.LoadComputedResults() if 1: @@ -110,8 +111,8 @@ def main(): TMP = Z1.shape #print Z[5,0:TMP[1]] - Z1[5,0:TMP[1]] - print Z[5,:] - print Z1[5,:] + print(Z[5,:]) + print(Z1[5,:]) from Metafor.Mparams.sequential import scatterplot Image = scatterplot(sol, surrogate_parameters, images_parameters) diff --git a/Metafor/config/bord01_config8.py b/Metafor/config/bord01_config8.py index 9292a1f7691160df9148a12a61780372c2de632e..b9ba750851854438bae62c24ecfe2fb105fa24aa 100644 --- a/Metafor/config/bord01_config8.py +++ b/Metafor/config/bord01_config8.py @@ -16,6 +16,7 @@ # limitations under the License. +from __future__ import print_function import numpy as np import os import shutil @@ -98,9 +99,9 @@ def main(): if mp.AvailableComputedResults(): if tm.rank == 0: - print "the master/sol.json file will be loaded" - print "the master/Z.json file will be loaded" - print "the master/W_sr.json file will be loaded" + print("the master/sol.json file will be loaded") + print("the master/Z.json file will be loaded") + print("the master/W_sr.json file will be loaded") sol, Z, W_sr = mp.LoadComputedResults() from Metafor.Mparams.sequential import scatterplot diff --git a/Metafor/config/bord01_config9.py b/Metafor/config/bord01_config9.py index 2515d2ee500ce9a9b96fb4f2004868ce2cce058b..de7ed6062e519de3b46b7923cbeaed1b9b5c4e20 100644 --- a/Metafor/config/bord01_config9.py +++ b/Metafor/config/bord01_config9.py @@ -16,6 +16,7 @@ # limitations under the License. +from __future__ import print_function import numpy as np import os import shutil @@ -92,9 +93,9 @@ def main(): if mp.AvailableComputedResults(): if tm.rank == 0: - print "the master/sol.json file will be loaded" - print "the master/Z.json file will be loaded" - print "the master/W_sr.json file will be loaded" + print("the master/sol.json file will be loaded") + print("the master/Z.json file will be loaded") + print("the master/W_sr.json file will be loaded") sol, Z, W_sr = mp.LoadComputedResults() @@ -155,15 +156,15 @@ def main(): max_w_residual[i] = np.abs(w_res).max() min_w_residual[i] = np.abs(w_res).min() ''' - print i + print(i) #import matplotlib.pyplot as plt #plt.semilogy(nstddeviation, cond) #plt.show() - print 'Condition number of W_srZ' - print cond.T - print 'nstddeviation' - print nstddeviation.T + print('Condition number of W_srZ') + print(cond.T) + print('nstddeviation') + print(nstddeviation.T) #''' surrogate_parameters['nstddeviation'] = 2.6281407 # 6.32653061 @@ -176,13 +177,13 @@ def main(): Image = scatterplot(sol, surrogate_parameters, images_parameters) s_hat_w = surrogate_creation(sol, Z, W_sr, surrogate_parameters, Image, images_parameters) - print s_hat_w.T + print(s_hat_w.T) W_sr = np.eye(W_sr.shape[0]) Image = scatterplot(sol, surrogate_parameters, images_parameters) s_hat_wout = surrogate_creation(sol, Z, W_sr, surrogate_parameters, Image, images_parameters) - print s_hat_wout.T + print(s_hat_wout.T) ## --------------------------- from params.src.monomials_1norm import phi @@ -202,7 +203,7 @@ def main(): xi_s = np.zeros((2,n_MC)) for i in range(0,n_MC): if np.mod(i,1000) == 0: - print i + print(i) xi_in = np.random.normal(0., 1., 2) diff --git a/Metafor/config/bord01_numericalSA.py b/Metafor/config/bord01_numericalSA.py index 0808e04d6b28eca254614d60be1adc2559a61536..067e1b5a9049ef5067b913bdc187087f53e7bffe 100644 --- a/Metafor/config/bord01_numericalSA.py +++ b/Metafor/config/bord01_numericalSA.py @@ -16,6 +16,7 @@ # limitations under the License. +from __future__ import print_function import numpy as np import os import shutil @@ -97,9 +98,9 @@ def main(): if mp.AvailableComputedResults(): if tm.rank == 0: - print "the master/sol.json file will be loaded" - print "the master/Z.json file will be loaded" - print "the master/W_sr.json file will be loaded" + print("the master/sol.json file will be loaded") + print("the master/Z.json file will be loaded") + print("the master/W_sr.json file will be loaded") sol, Z, W_sr = mp.LoadComputedResults() @@ -160,15 +161,15 @@ def main(): max_w_residual[i] = np.abs(w_res).max() min_w_residual[i] = np.abs(w_res).min() ''' - print i + print(i) #import matplotlib.pyplot as plt #plt.semilogy(nstddeviation, cond) #plt.show() - print 'Condition number of W_srZ' - print cond.T - print 'nstddeviation' - print nstddeviation.T + print('Condition number of W_srZ') + print(cond.T) + print('nstddeviation') + print(nstddeviation.T) #''' surrogate_parameters['nstddeviation'] = 2.6281407 @@ -181,13 +182,13 @@ def main(): Image = scatterplot(sol, surrogate_parameters, images_parameters) s_hat_w = surrogate_creation(sol, Z, W_sr, surrogate_parameters, Image, images_parameters) - print s_hat_w.T + print(s_hat_w.T) W_sr = np.eye(W_sr.shape[0]) Image = scatterplot(sol, surrogate_parameters, images_parameters) s_hat_wout = surrogate_creation(sol, Z, W_sr, surrogate_parameters, Image, images_parameters) - print s_hat_wout.T + print(s_hat_wout.T) ## --------------------------- from params.src.monomials_1norm import phi @@ -207,7 +208,7 @@ def main(): xi_s = np.zeros((2,n_MC)) for i in range(0,n_MC): if np.mod(i,1000) == 0: - print i + print(i) xi_in = np.random.normal(0., 1., 2) diff --git a/Metafor/config/mirror01_config1.py b/Metafor/config/mirror01_config1.py index 1e4365ac8d7fe05005f6c8d0e53309c6db365e39..5eb867a51bc9044889c634f9a1bf0bc3125d309a 100644 --- a/Metafor/config/mirror01_config1.py +++ b/Metafor/config/mirror01_config1.py @@ -16,6 +16,7 @@ # limitations under the License. +from __future__ import print_function import numpy as np import os import shutil @@ -103,9 +104,9 @@ def main(): if mp.AvailableComputedResults(): if tm.rank == 0: - print "the master/sol.json file will be loaded" - print "the master/Z.json file will be loaded" - print "the master/W_sr.json file will be loaded" + print("the master/sol.json file will be loaded") + print("the master/Z.json file will be loaded") + print("the master/W_sr.json file will be loaded") sol, Z, W_sr = mp.LoadComputedResults() from Metafor.Mparams.sequential import scatterplot diff --git a/Metafor/config/mirror01_config2.py b/Metafor/config/mirror01_config2.py index 600b548a7fc5903d1018fef29909d7eae4c3d9ed..8d9508ac23bc05fcd3717abb7052b5ae51aecd1b 100644 --- a/Metafor/config/mirror01_config2.py +++ b/Metafor/config/mirror01_config2.py @@ -16,6 +16,7 @@ # limitations under the License. +from __future__ import print_function import numpy as np import os import shutil @@ -103,9 +104,9 @@ def main(): if mp.AvailableComputedResults(): if tm.rank == 0: - print "the master/sol.json file will be loaded" - print "the master/Z.json file will be loaded" - print "the master/W_sr.json file will be loaded" + print("the master/sol.json file will be loaded") + print("the master/Z.json file will be loaded") + print("the master/W_sr.json file will be loaded") sol, Z, W_sr = mp.LoadComputedResults() from Metafor.Mparams.sequential import scatterplot diff --git a/Metafor/config/mirror01_config3.py b/Metafor/config/mirror01_config3.py index 95703c9ce1fd52dc6669e92430848f6c2528258e..a5f3d39e46dc7143b406770e1a56a89e73920f36 100644 --- a/Metafor/config/mirror01_config3.py +++ b/Metafor/config/mirror01_config3.py @@ -16,6 +16,7 @@ # limitations under the License. +from __future__ import print_function import numpy as np import os import shutil @@ -103,9 +104,9 @@ def main(): if mp.AvailableComputedResults(): if tm.rank == 0: - print "the master/sol.json file will be loaded" - print "the master/Z.json file will be loaded" - print "the master/W_sr.json file will be loaded" + print("the master/sol.json file will be loaded") + print("the master/Z.json file will be loaded") + print("the master/W_sr.json file will be loaded") sol, Z, W_sr = mp.LoadComputedResults() from Metafor.Mparams.sequential import scatterplot diff --git a/Metafor/config/mirror02_config2.py b/Metafor/config/mirror02_config2.py index 14114523c99a8e14e5f26bc328842936e608f2b8..86aacbd34951cd0854009a6c9ff4fd49f1c7d3b5 100644 --- a/Metafor/config/mirror02_config2.py +++ b/Metafor/config/mirror02_config2.py @@ -16,6 +16,7 @@ # limitations under the License. +from __future__ import print_function import numpy as np import os import shutil @@ -103,9 +104,9 @@ def main(): if mp.AvailableComputedResults(): if tm.rank == 0: - print "the master/sol.json file will be loaded" - print "the master/Z.json file will be loaded" - print "the master/W_sr.json file will be loaded" + print("the master/sol.json file will be loaded") + print("the master/Z.json file will be loaded") + print("the master/W_sr.json file will be loaded") sol, Z, W_sr = mp.LoadComputedResults() from Metafor.Mparams.sequential import scatterplot diff --git a/Metafor/config/omega01_config1.py b/Metafor/config/omega01_config1.py index b25aabce399f2c3aaffd1dbad801f996491d64dc..a07d7a29ff9cedafd96e9b813d979f31fe92bc0f 100644 --- a/Metafor/config/omega01_config1.py +++ b/Metafor/config/omega01_config1.py @@ -16,6 +16,7 @@ # limitations under the License. +from __future__ import print_function import numpy as np import os import shutil @@ -84,9 +85,9 @@ def main(): if mp.AvailableComputedResults(): if tm.rank == 0: - print "the master/sol.json file will be loaded" - print "the master/Z.json file will be loaded" - print "the master/W_sr.json file will be loaded" + print("the master/sol.json file will be loaded") + print("the master/Z.json file will be loaded") + print("the master/W_sr.json file will be loaded") sol, Z, W_sr = mp.LoadComputedResults() from Metafor.Mparams.sequential import scatterplot diff --git a/Metafor/config/omega01_test.py b/Metafor/config/omega01_test.py index e38c73b1dfc389068bc738d17292c7d10fc1d22a..951e59d7039d8bf13f7b684701071c9aec05714a 100644 --- a/Metafor/config/omega01_test.py +++ b/Metafor/config/omega01_test.py @@ -16,6 +16,7 @@ # limitations under the License. +from __future__ import print_function import numpy as np import os import shutil @@ -84,9 +85,9 @@ def main(): if mp.AvailableComputedResults(): if tm.rank == 0: - print "the master/sol.json file will be loaded" - print "the master/Z.json file will be loaded" - print "the master/W_sr.json file will be loaded" + print("the master/sol.json file will be loaded") + print("the master/Z.json file will be loaded") + print("the master/W_sr.json file will be loaded") sol, Z, W_sr = mp.LoadComputedResults() from Metafor.Mparams.sequential import scatterplot diff --git a/Metafor/config/tube01_config1.py b/Metafor/config/tube01_config1.py index c168abc3089602dff4017d098cb32d6ac02cab15..a424b44ba69e52a304bcb586919079cf586f67d3 100644 --- a/Metafor/config/tube01_config1.py +++ b/Metafor/config/tube01_config1.py @@ -16,6 +16,7 @@ # limitations under the License. +from __future__ import print_function import numpy as np import os import shutil @@ -84,9 +85,9 @@ def main(): if mp.AvailableComputedResults(): if tm.rank == 0: - print "the master/sol.json file will be loaded" - print "the master/Z.json file will be loaded" - print "the master/W_sr.json file will be loaded" + print("the master/sol.json file will be loaded") + print("the master/Z.json file will be loaded") + print("the master/W_sr.json file will be loaded") sol, Z, W_sr = mp.LoadComputedResults() from Metafor.Mparams.sequential import scatterplot diff --git a/Metafor/config/tube01_config2.py b/Metafor/config/tube01_config2.py index aa6043f1d4cb978dda0d246df2e00066b38514d3..aded86db1ca5cd8749d58a94d7be9c01111b3cec 100644 --- a/Metafor/config/tube01_config2.py +++ b/Metafor/config/tube01_config2.py @@ -16,6 +16,7 @@ # limitations under the License. +from __future__ import print_function import numpy as np import os import shutil @@ -84,9 +85,9 @@ def main(): if mp.AvailableComputedResults(): if tm.rank == 0: - print "the master/sol.json file will be loaded" - print "the master/Z.json file will be loaded" - print "the master/W_sr.json file will be loaded" + print("the master/sol.json file will be loaded") + print("the master/Z.json file will be loaded") + print("the master/W_sr.json file will be loaded") sol, Z, W_sr = mp.LoadComputedResults() from Metafor.Mparams.sequential import scatterplot diff --git a/Metafor/config/tube01_test.py b/Metafor/config/tube01_test.py index f8419f974d2fe66552e634efa858e54411011493..b5bb9f499b9e780bff1e14e510007d338393f137 100644 --- a/Metafor/config/tube01_test.py +++ b/Metafor/config/tube01_test.py @@ -16,6 +16,7 @@ # limitations under the License. +from __future__ import print_function import numpy as np import os import shutil @@ -84,9 +85,9 @@ def main(): if mp.AvailableComputedResults(): if tm.rank == 0: - print "the master/sol.json file will be loaded" - print "the master/Z.json file will be loaded" - print "the master/W_sr.json file will be loaded" + print("the master/sol.json file will be loaded") + print("the master/Z.json file will be loaded") + print("the master/W_sr.json file will be loaded") sol, Z, W_sr = mp.LoadComputedResults() from Metafor.Mparams.sequential import scatterplot diff --git a/Metafor/models/bord01/tombeBord.py b/Metafor/models/bord01/tombeBord.py index a685f9b1f87c8dc0579caff2cbf4cbd90b95a528..3586f7909f5d43ea290e1f0fbe2bf6b3cede0fe6 100644 --- a/Metafor/models/bord01/tombeBord.py +++ b/Metafor/models/bord01/tombeBord.py @@ -1,267 +1,268 @@ # -*- coding: latin-1; -*- -# $Id: tombeBordEas2D.py 1422 2011-03-24 08:38:18Z papeleux $ -################################################# -# Tombe de bord # -#===============================================# -################################################# -from wrap import * -import math - -metafor = None - -def getMetafor(_parameters={}): - global metafor - if not metafor : - ''' - params = {'npgdy':50} - params.update(_parameters) - metafor = buildMetafor(params) - ''' - metafor = buildMetafor(_parameters) - return metafor - -def buildMetafor(p={}): - #-- parametres par defaut : - parameters = { - 'NIPDETA' : 2, # nbre de pts de Gauss selon l'epaisseur - 'Young' : 210000.0, - 'Poisson' : 0.3, - 'sigEl0' : 420.0, - 'ih_H' : 1500.0, - 'nx' : 60, - 'ny' : 6, - 'Thickness' : 1.0, - 'Rm' : 3.0, # rayon matrice - 'Rt' : 1.0, # rayon outil - 'Gap' : 1.0, - 'nbArch' : 1, - 'peno' : 5e+05, - 'peta' : 5e+04, - 'mu_sta' : 0.1, - 'mu_dyn' : 0.1, - 'NRTol' : 1e-04, - 'PEAS' : 1e-06 - } - - print p - parameters.update(p) - metafor = Metafor() - domain = metafor.getDomain() - - geometry = domain.getGeometry() - geometry.setDimPlaneStrain(1.0) - #-- dimension du maillage - X0 = -3.0 - Y0 = 0.0 - Z0 = 0.0 - Lx = 20.0 - Th = parameters['Thickness'] - nx1 = parameters['nx'] - nx2 = parameters['nx'] - ny = parameters['ny'] - # Tool - Rm = parameters['Rm'] # Rm : rayon Matrice - Rt = parameters['Rt'] # Rt : rayon Tool - Gap = parameters['Gap'] # Jeu matrice - poincon - Lp = 3.0 # longueur du poincon - - #-- maillage -- - Lx1 = Lx/2.0 #-2*X0 + (math.pi/2.0) * Rm - Lx2 = Lx - Lx1 - from toolbox.meshedGeometry2D import createRectangleSameId - createRectangleSameId(domain, nx1, ny, Lx1, Th, X0, Y0, 0) - from toolbox.meshedGeometry2D import addQuadrangle2X - addQuadrangle2X(domain, 100, nx2, ny, Lx2, Th, X0+Lx1, Y0, - 2, 3, 2) - #-- Fonctions d'evolution -- - FCT_CHA = PieceWiseLinearFunction() - FCT_CHA.setData(0.0, 0.0) - FCT_CHA.setData(10.0, 1.0) - FCT_CHA.setData(20.0 , 0.0) - #Outils de mise a forme - from apps.toolbox.formingTools import createFlangingTools2D - createFlangingTools2D(domain, 1000, (X0-1), Y0, Rm, Rt, Gap, Th, Lp, Lx,-Lx, FCT_CHA) - - prp_c1 = ElementProperties(Contact2DElement) - prp_c1.put(MATERIAL, 1001) - prp_c1.put(AREAINCONTACT,AIC_ONCE) - - interactionset = domain.getInteractionSet() - curveset = geometry.getCurveSet() - wireset = geometry.getWireSet() - sideset = geometry.getSideSet() - - wireset.add( Wire(201, [curveset(1), curveset(101)]) ) - wireset.add( Wire(202, [curveset(3), curveset(103)]) ) - - #Outil 1 : Matrice - ci1 = RdContactInteraction(1) - ci1.setTool(wireset(1001)) - ci1.push(wireset(201)) - ci1.addProperty(prp_c1) - interactionset.add(ci1) - - #Outil 2 : Poincon - ci2 = RdContactInteraction(2) - ci2.setTool(wireset(1101)) - ci2.push(wireset(202)) - ci2.addProperty(prp_c1) - interactionset.add(ci2) - - #Outil 3 : Serre-Flanc - ci3 = RdContactInteraction(3) - ci3.setTool(wireset(1201)) - ci3.push(curveset(3)) - ci3.addProperty(prp_c1) - interactionset.add(ci3) - - #-- FieldApplicator -- - app001 = FieldApplicator(99) - app001.push(sideset( 1)) - interactionset.add(app001) - - app101 = FieldApplicator(101) - app101.push(sideset(101)) - interactionset.add(app101) - - #-- Fnn - Loadings -- - loadingset = domain.getLoadingSet() - loadingset.define(curveset(4), Field1D(TX,RE)) - loadingset.define(curveset(4), Field1D(TY,RE)) - - #-- Materiaux -- - materset = domain.getMaterialSet() - materlawset = domain.getMaterialLawSet() - materset.define(1, EvpIsoHHypoMaterial) - materset(1).put(MASS_DENSITY, 8900.0E-12) - materset(1).put(ELASTIC_MODULUS, parameters['Young']) - materset(1).put(POISSON_RATIO, parameters['Poisson']) - materset(1).put(YIELD_NUM, 2) - ''' - materlawset.define(1, RambergOsgoodIsotropicHardening) - materlawset(1).put(IH_SIGEL, 330.3) - materlawset(1).put(IH_A, 591.72) - materlawset(1).put(IH_N, 5.35) - ''' - materlawset.define(2, LinearIsotropicHardening) - materlawset(2).put(IH_SIGEL, parameters['sigEl0']) - materlawset(2).put(IH_H, parameters['ih_H']) - - - materset.define(1001, CoulombContactMaterial) - mat1001 = materset(1001) - mat1001.put(PEN_NORMALE, parameters['peno']) - mat1001.put(PEN_TANGENT, parameters['peta']) - mat1001.put(PROF_CONT, 0.9) - mat1001.put(COEF_FROT_STA, parameters['mu_sta']) # usually between 0.3 and 0.6 for dry materials - mat1001.put(COEF_FROT_DYN, parameters['mu_dyn']) - - #-- Propelem -- - prp001 = ElementProperties(Volume2DElement) - prp001.put(CAUCHYMECHVOLINTMETH, VES_CMVIM_EAS) - prp001.put(MATERIAL, 1) - prp001.put(NIPDETA, parameters['NIPDETA']) - prp001.put(EASS, 2) - prp001.put(EASV, 2) - prp001.put(PEAS, parameters['PEAS']) - prp001.put(VERBOSE, True) - interactionset(99).addProperty(prp001) - - prp101 = ElementProperties(Volume2DElement) - prp101.put(CAUCHYMECHVOLINTMETH, VES_CMVIM_EAS) - prp101.put(MATERIAL, 1) - prp101.put(NIPDETA, parameters['NIPDETA']) - prp101.put(EASS, 2) - prp101.put(EASV, 2) - prp101.put(PEAS, parameters['PEAS']) - prp101.put(VERBOSE, True) - interactionset(101).addProperty(prp101) - - # - - mim = metafor.getMechanicalIterationManager() - mim.setResidualComputationMethod(Method4ResidualComputation()) - mim.setResidualTolerance(parameters['NRTol']) - - #-- tsm -- - tsm = metafor.getTimeStepManager() - tsm.setInitialTime(0.0, 1e-4) - tsm.setNextTime(10.0, parameters['nbArch'], 1.0) - tsm.setNextTime(20.0, parameters['nbArch'], 1.0) - - # Time Integration - ti = AlphaGeneralizedTimeIntegration(metafor) - metafor.setTimeIntegration(ti) - - # Courbes - valuesmanager = metafor.getValuesManager() - pointset = geometry.getPointSet() - curveset = geometry.getCurveSet() - valuesmanager.add(1, MiscValueExtractor(metafor,EXT_T),'time') - ave1 = AngleValueExtractor(Axe(curveset(1003)),Axe(pointset(2),pointset(102))) - valuesmanager.add(11,ave1,'Angle1') - - # Objective Function - # ------------------ - objectivefunctionset = metafor.getObjectiveFunctionSet() - - Index = 2000 - X0 = -10.0 - dX0 = 3.0 - Y0 = -10.0 - Z0 = 0.0 - Rm = 4.0 - Ll = 50.0 - alphaDeg = 80.0 - - alphaRad = alphaDeg * math.pi / 180.0 - cosAlphaDemi = math.cos(alphaRad / 2.0) - sinAlphaDemi = math.sin(alphaRad / 2.0) - cosAlpha = math.cos(alphaRad) - sinAlpha = math.sin(alphaRad) - cos90moinsAlpha = math.cos(math.pi / 2.0 - alphaRad) - sinAlpha = math.sin(alphaRad) - - from toolbox.domainTools import getGeoReferences - [pointset, curveset, wireset, surfaceset, sideset, skinset, volumeset] = getGeoReferences(domain) - piDemi = math.asin(1) - C45 = math.cos(piDemi/2.0) - Z0 = 0.0 - - # Outil 1 : matrice - pointset.define(Index + 1, X0 - dX0, Y0, Z0) - pointset.define(Index + 2, X0, Y0, Z0) - pointset.define(Index + 3, X0 + (Rm * sinAlphaDemi), (Y0 - Rm * (1.0-cosAlphaDemi)), Z0) - pointset.define(Index + 4, X0 + (Rm * sinAlpha), (Y0 - Rm * (1.0-cosAlpha)), Z0) - pointset.define(Index + 5, X0 + (Rm * sinAlpha + Ll * cosAlpha), (Y0 - Rm * (1.0 - cosAlpha) - Ll * sinAlpha), Z0) - pointset.define(Index + 6, X0 - dX0 , (Y0 + 2.0), Z0) - - curveset.add( Line(Index + 1, pointset(Index + 1), pointset(Index + 2) )) - curveset.add( Arc(Index + 2, pointset(Index + 2), pointset(Index + 3), pointset(Index + 4) )) - curveset.add( Line(Index + 3, pointset(Index + 4), pointset(Index + 5) )) - curveset.add( Line(Index + 4, pointset(Index + 6), pointset(Index + 1) )) - - wireset.add(MultiProjWire(Index + 1, [curveset(Index+i) for i in (1, 2, 3)])) - wireset.add(Wire(Index+2, [curveset(1), curveset(101)])) - - sve1 = ShapeValueExtractor(wireset(Index+1), wireset(Index+2)) - sve1.setTriedreRef(Triedre(pointset(Index+1),pointset(Index+2),pointset(Index+6))) - sve1.setTriedreMesh(Triedre(pointset(1),pointset(1002),pointset(4))) - - valuesmanager.add(12,sve1,'shape1') - valuesmanager.add(13,sve1,NormOperator(),'shape2') - - sof1 = ValueExtractorObjectiveFunction(1,ave1) - objectivefunctionset.add(sof1) - sof2 = ValueExtractorObjectiveFunction(2,sve1) - objectivefunctionset.add(sof2) - - # Verification des Objective Function in .res File - testSuite = metafor.getTestSuiteChecker() - testSuite.checkObjectiveFunction(2) - testSuite.checkExtractor(11) - testSuite.checkExtractor(12,0) - testSuite.checkExtractor(12,5) - testSuite.checkExtractor(13) - - return metafor +# $Id: tombeBordEas2D.py 1422 2011-03-24 08:38:18Z papeleux $ +################################################# +# Tombe de bord # +#===============================================# +################################################# +from __future__ import print_function +from wrap import * +import math + +metafor = None + +def getMetafor(_parameters={}): + global metafor + if not metafor : + ''' + params = {'npgdy':50} + params.update(_parameters) + metafor = buildMetafor(params) + ''' + metafor = buildMetafor(_parameters) + return metafor + +def buildMetafor(p={}): + #-- parametres par defaut : + parameters = { + 'NIPDETA' : 2, # nbre de pts de Gauss selon l'epaisseur + 'Young' : 210000.0, + 'Poisson' : 0.3, + 'sigEl0' : 420.0, + 'ih_H' : 1500.0, + 'nx' : 60, + 'ny' : 6, + 'Thickness' : 1.0, + 'Rm' : 3.0, # rayon matrice + 'Rt' : 1.0, # rayon outil + 'Gap' : 1.0, + 'nbArch' : 1, + 'peno' : 5e+05, + 'peta' : 5e+04, + 'mu_sta' : 0.1, + 'mu_dyn' : 0.1, + 'NRTol' : 1e-04, + 'PEAS' : 1e-06 + } + + print(p) + parameters.update(p) + metafor = Metafor() + domain = metafor.getDomain() + + geometry = domain.getGeometry() + geometry.setDimPlaneStrain(1.0) + #-- dimension du maillage + X0 = -3.0 + Y0 = 0.0 + Z0 = 0.0 + Lx = 20.0 + Th = parameters['Thickness'] + nx1 = parameters['nx'] + nx2 = parameters['nx'] + ny = parameters['ny'] + # Tool + Rm = parameters['Rm'] # Rm : rayon Matrice + Rt = parameters['Rt'] # Rt : rayon Tool + Gap = parameters['Gap'] # Jeu matrice - poincon + Lp = 3.0 # longueur du poincon + + #-- maillage -- + Lx1 = Lx/2.0 #-2*X0 + (math.pi/2.0) * Rm + Lx2 = Lx - Lx1 + from toolbox.meshedGeometry2D import createRectangleSameId + createRectangleSameId(domain, nx1, ny, Lx1, Th, X0, Y0, 0) + from toolbox.meshedGeometry2D import addQuadrangle2X + addQuadrangle2X(domain, 100, nx2, ny, Lx2, Th, X0+Lx1, Y0, + 2, 3, 2) + #-- Fonctions d'evolution -- + FCT_CHA = PieceWiseLinearFunction() + FCT_CHA.setData(0.0, 0.0) + FCT_CHA.setData(10.0, 1.0) + FCT_CHA.setData(20.0 , 0.0) + #Outils de mise a forme + from apps.toolbox.formingTools import createFlangingTools2D + createFlangingTools2D(domain, 1000, (X0-1), Y0, Rm, Rt, Gap, Th, Lp, Lx,-Lx, FCT_CHA) + + prp_c1 = ElementProperties(Contact2DElement) + prp_c1.put(MATERIAL, 1001) + prp_c1.put(AREAINCONTACT,AIC_ONCE) + + interactionset = domain.getInteractionSet() + curveset = geometry.getCurveSet() + wireset = geometry.getWireSet() + sideset = geometry.getSideSet() + + wireset.add( Wire(201, [curveset(1), curveset(101)]) ) + wireset.add( Wire(202, [curveset(3), curveset(103)]) ) + + #Outil 1 : Matrice + ci1 = RdContactInteraction(1) + ci1.setTool(wireset(1001)) + ci1.push(wireset(201)) + ci1.addProperty(prp_c1) + interactionset.add(ci1) + + #Outil 2 : Poincon + ci2 = RdContactInteraction(2) + ci2.setTool(wireset(1101)) + ci2.push(wireset(202)) + ci2.addProperty(prp_c1) + interactionset.add(ci2) + + #Outil 3 : Serre-Flanc + ci3 = RdContactInteraction(3) + ci3.setTool(wireset(1201)) + ci3.push(curveset(3)) + ci3.addProperty(prp_c1) + interactionset.add(ci3) + + #-- FieldApplicator -- + app001 = FieldApplicator(99) + app001.push(sideset( 1)) + interactionset.add(app001) + + app101 = FieldApplicator(101) + app101.push(sideset(101)) + interactionset.add(app101) + + #-- Fnn - Loadings -- + loadingset = domain.getLoadingSet() + loadingset.define(curveset(4), Field1D(TX,RE)) + loadingset.define(curveset(4), Field1D(TY,RE)) + + #-- Materiaux -- + materset = domain.getMaterialSet() + materlawset = domain.getMaterialLawSet() + materset.define(1, EvpIsoHHypoMaterial) + materset(1).put(MASS_DENSITY, 8900.0E-12) + materset(1).put(ELASTIC_MODULUS, parameters['Young']) + materset(1).put(POISSON_RATIO, parameters['Poisson']) + materset(1).put(YIELD_NUM, 2) + ''' + materlawset.define(1, RambergOsgoodIsotropicHardening) + materlawset(1).put(IH_SIGEL, 330.3) + materlawset(1).put(IH_A, 591.72) + materlawset(1).put(IH_N, 5.35) + ''' + materlawset.define(2, LinearIsotropicHardening) + materlawset(2).put(IH_SIGEL, parameters['sigEl0']) + materlawset(2).put(IH_H, parameters['ih_H']) + + + materset.define(1001, CoulombContactMaterial) + mat1001 = materset(1001) + mat1001.put(PEN_NORMALE, parameters['peno']) + mat1001.put(PEN_TANGENT, parameters['peta']) + mat1001.put(PROF_CONT, 0.9) + mat1001.put(COEF_FROT_STA, parameters['mu_sta']) # usually between 0.3 and 0.6 for dry materials + mat1001.put(COEF_FROT_DYN, parameters['mu_dyn']) + + #-- Propelem -- + prp001 = ElementProperties(Volume2DElement) + prp001.put(CAUCHYMECHVOLINTMETH, VES_CMVIM_EAS) + prp001.put(MATERIAL, 1) + prp001.put(NIPDETA, parameters['NIPDETA']) + prp001.put(EASS, 2) + prp001.put(EASV, 2) + prp001.put(PEAS, parameters['PEAS']) + prp001.put(VERBOSE, True) + interactionset(99).addProperty(prp001) + + prp101 = ElementProperties(Volume2DElement) + prp101.put(CAUCHYMECHVOLINTMETH, VES_CMVIM_EAS) + prp101.put(MATERIAL, 1) + prp101.put(NIPDETA, parameters['NIPDETA']) + prp101.put(EASS, 2) + prp101.put(EASV, 2) + prp101.put(PEAS, parameters['PEAS']) + prp101.put(VERBOSE, True) + interactionset(101).addProperty(prp101) + + # + + mim = metafor.getMechanicalIterationManager() + mim.setResidualComputationMethod(Method4ResidualComputation()) + mim.setResidualTolerance(parameters['NRTol']) + + #-- tsm -- + tsm = metafor.getTimeStepManager() + tsm.setInitialTime(0.0, 1e-4) + tsm.setNextTime(10.0, parameters['nbArch'], 1.0) + tsm.setNextTime(20.0, parameters['nbArch'], 1.0) + + # Time Integration + ti = AlphaGeneralizedTimeIntegration(metafor) + metafor.setTimeIntegration(ti) + + # Courbes + valuesmanager = metafor.getValuesManager() + pointset = geometry.getPointSet() + curveset = geometry.getCurveSet() + valuesmanager.add(1, MiscValueExtractor(metafor,EXT_T),'time') + ave1 = AngleValueExtractor(Axe(curveset(1003)),Axe(pointset(2),pointset(102))) + valuesmanager.add(11,ave1,'Angle1') + + # Objective Function + # ------------------ + objectivefunctionset = metafor.getObjectiveFunctionSet() + + Index = 2000 + X0 = -10.0 + dX0 = 3.0 + Y0 = -10.0 + Z0 = 0.0 + Rm = 4.0 + Ll = 50.0 + alphaDeg = 80.0 + + alphaRad = alphaDeg * math.pi / 180.0 + cosAlphaDemi = math.cos(alphaRad / 2.0) + sinAlphaDemi = math.sin(alphaRad / 2.0) + cosAlpha = math.cos(alphaRad) + sinAlpha = math.sin(alphaRad) + cos90moinsAlpha = math.cos(math.pi / 2.0 - alphaRad) + sinAlpha = math.sin(alphaRad) + + from toolbox.domainTools import getGeoReferences + [pointset, curveset, wireset, surfaceset, sideset, skinset, volumeset] = getGeoReferences(domain) + piDemi = math.asin(1) + C45 = math.cos(piDemi/2.0) + Z0 = 0.0 + + # Outil 1 : matrice + pointset.define(Index + 1, X0 - dX0, Y0, Z0) + pointset.define(Index + 2, X0, Y0, Z0) + pointset.define(Index + 3, X0 + (Rm * sinAlphaDemi), (Y0 - Rm * (1.0-cosAlphaDemi)), Z0) + pointset.define(Index + 4, X0 + (Rm * sinAlpha), (Y0 - Rm * (1.0-cosAlpha)), Z0) + pointset.define(Index + 5, X0 + (Rm * sinAlpha + Ll * cosAlpha), (Y0 - Rm * (1.0 - cosAlpha) - Ll * sinAlpha), Z0) + pointset.define(Index + 6, X0 - dX0 , (Y0 + 2.0), Z0) + + curveset.add( Line(Index + 1, pointset(Index + 1), pointset(Index + 2) )) + curveset.add( Arc(Index + 2, pointset(Index + 2), pointset(Index + 3), pointset(Index + 4) )) + curveset.add( Line(Index + 3, pointset(Index + 4), pointset(Index + 5) )) + curveset.add( Line(Index + 4, pointset(Index + 6), pointset(Index + 1) )) + + wireset.add(MultiProjWire(Index + 1, [curveset(Index+i) for i in (1, 2, 3)])) + wireset.add(Wire(Index+2, [curveset(1), curveset(101)])) + + sve1 = ShapeValueExtractor(wireset(Index+1), wireset(Index+2)) + sve1.setTriedreRef(Triedre(pointset(Index+1),pointset(Index+2),pointset(Index+6))) + sve1.setTriedreMesh(Triedre(pointset(1),pointset(1002),pointset(4))) + + valuesmanager.add(12,sve1,'shape1') + valuesmanager.add(13,sve1,NormOperator(),'shape2') + + sof1 = ValueExtractorObjectiveFunction(1,ave1) + objectivefunctionset.add(sof1) + sof2 = ValueExtractorObjectiveFunction(2,sve1) + objectivefunctionset.add(sof2) + + # Verification des Objective Function in .res File + testSuite = metafor.getTestSuiteChecker() + testSuite.checkObjectiveFunction(2) + testSuite.checkExtractor(11) + testSuite.checkExtractor(12,0) + testSuite.checkExtractor(12,5) + testSuite.checkExtractor(13) + + return metafor diff --git a/Metafor/models/bord01/tombeBord_old.py b/Metafor/models/bord01/tombeBord_old.py index d316e3cf3937c23714a188ee369051128508c920..99dc92bfdc8343b0bc4d085e8aa1fc6c94b812e1 100644 --- a/Metafor/models/bord01/tombeBord_old.py +++ b/Metafor/models/bord01/tombeBord_old.py @@ -1,247 +1,248 @@ -# -*- coding: latin-1; -*- -# $Id: tombeBordEas2D.py 1422 2011-03-24 08:38:18Z papeleux $ -################################################# -# Tombe de bord # -#===============================================# -################################################# -from wrap import * -import math - -metafor = None - -def getMetafor(_parameters={}): - global metafor - if not metafor : - ''' - params = {'npgdy':50} - params.update(_parameters) - metafor = buildMetafor(params) - ''' - metafor = buildMetafor(_parameters) - return metafor - -def buildMetafor(p={}): - #-- parametres par defaut : - parameters = {'NIPDETA': 6, 'Young':210000.0,'Poisson':0.3, - 'sigEl0':420.0,'ih_H':1500.0, - 'npgdy': 16,'nx':35,'ny':8, - 'Thickness':1.0,'Rm':3.0,'Rt':1.0, - 'Gap':1.0,'nbArch':1, - 'peno':1e+08, 'mu_sta':0.6, 'mu_dyn':0.6, - 'NRTol':1e-07} - - print p - parameters.update(p) - metafor = Metafor() - domain = metafor.getDomain() - - geometry = domain.getGeometry() - geometry.setDimPlaneStrain(1.0) - #-- dimension du maillage - X0 = -3.0 - Y0 = 0.0 - Z0 = 0.0 - Lx = 20.0 - Th = parameters['Thickness'] - nx1 = parameters['nx'] - nx2 = parameters['nx'] - ny = parameters['ny'] - # Tool - Rm = parameters['Rm'] #Rm : rayon Matrice - Rt = parameters['Rt'] #Rt : rayon Tool - Gap = parameters['Gap'] #Jeu matrice - poincon - Lp = 3.0 #longueur du poincon - - #-- maillage -- - Lx1 = -2*X0 + (math.pi/2.0) * Rm - Lx2 = Lx - Lx1 - from toolbox.meshedGeometry2D import createRectangleSameId - createRectangleSameId(domain, nx1, ny, Lx1, Th, X0, Y0, 0) - from toolbox.meshedGeometry2D import addQuadrangle2X - addQuadrangle2X(domain, 100, nx2, ny, Lx2, Th, X0+Lx1, Y0, - 2, 3, 2) - #-- Fonctions d'evolution -- - FCT_CHA = PieceWiseLinearFunction() - FCT_CHA.setData(0.0, 0.0) - FCT_CHA.setData(10.0, 1.0) - FCT_CHA.setData(20.0 , 0.0) - #Outils de mise a forme - from apps.toolbox.formingTools import createFlangingTools2D - createFlangingTools2D(domain, 1000, (X0-1), Y0, Rm, Rt, Gap, Th, Lp, Lx,-Lx, FCT_CHA) - - prp_c1 = ElementProperties(Contact2DElement) - prp_c1.put(MATERIAL, 1001) - prp_c1.put(AREAINCONTACT,AIC_ONCE) - - interactionset = domain.getInteractionSet() - curveset = geometry.getCurveSet() - wireset = geometry.getWireSet() - sideset = geometry.getSideSet() - - wireset.add( Wire(201, [curveset(1), curveset(101)]) ) - wireset.add( Wire(202, [curveset(3), curveset(103)]) ) - #Outil 1 : Matrice - ci1 = RdContactInteraction(1) - ci1.setTool(wireset(1001)) - ci1.push(wireset(201)) - ci1.addProperty(prp_c1) - interactionset.add(ci1) - #Outil 2 : Poincon - ci2 = RdContactInteraction(2) - ci2.setTool(wireset(1101)) - ci2.push(wireset(202)) - ci2.addProperty(prp_c1) - interactionset.add(ci2) - #Outil 3 : Serre-Flanc - ci3 = RdContactInteraction(3) - ci3.setTool(wireset(1201)) - ci3.push(curveset(3)) - ci3.addProperty(prp_c1) - interactionset.add(ci3) - #-- FieldApplicator -- - app001 = FieldApplicator(99) - app001.push(sideset( 1)) - interactionset.add(app001) - - app101 = FieldApplicator(101) - app101.push(sideset(101)) - interactionset.add(app101) - #-- Fnn - Loadings -- - loadingset = domain.getLoadingSet() - loadingset.define(curveset(4), Field1D(TX,RE)) - loadingset.define(curveset(4), Field1D(TY,RE)) - - #-- Materiaux -- - materset = domain.getMaterialSet() - materlawset = domain.getMaterialLawSet() - materset.define(1, EvpIsoHHypoMaterial) - materset(1).put(MASS_DENSITY, 8900.0E-12) - materset(1).put(ELASTIC_MODULUS, parameters['Young']) - materset(1).put(POISSON_RATIO, parameters['Poisson']) - materset(1).put(YIELD_NUM, 2) - ''' - materlawset.define(1, RambergOsgoodIsotropicHardening) - materlawset(1).put(IH_SIGEL, 330.3) - materlawset(1).put(IH_A, 591.72) - materlawset(1).put(IH_N, 5.35) - ''' - materlawset.define(2, LinearIsotropicHardening) - materlawset(2).put(IH_SIGEL, parameters['sigEl0']) - materlawset(2).put(IH_H, parameters['ih_H']) - - - materset.define(1001, CoulombContactMaterial) - mat1001 = materset(1001) - mat1001.put(PEN_NORMALE, parameters['peno']) - mat1001.put(PEN_TANGENT, 1e+06) - mat1001.put(PROF_CONT, 0.9) - mat1001.put(COEF_FROT_STA, parameters['mu_sta']) # usually between 0.3 and 0.6 for dry materials - mat1001.put(COEF_FROT_DYN, parameters['mu_dyn']) - - #-- Propelem -- - prp001 = ElementProperties(Volume2DElement) - prp001.put(CAUCHYMECHVOLINTMETH, VES_CMVIM_EAS) - prp001.put(MATERIAL, 1) - prp001.put(NIPDETA, parameters['NIPDETA']) - prp001.put(EASS, 2) - prp001.put(EASV, 4) - prp001.put(VERBOSE, True) - interactionset(99).addProperty(prp001) - - prp101 = ElementProperties(Volume2DElement) - prp101.put(CAUCHYMECHVOLINTMETH, VES_CMVIM_EAS) - prp101.put(MATERIAL, 1) - prp101.put(NIPDETA, parameters['NIPDETA']) - prp101.put(EASS, 2) - prp101.put(EASV, 4) - prp101.put(VERBOSE, True) - interactionset(101).addProperty(prp101) - - # - - mim = metafor.getMechanicalIterationManager() - mim.setResidualTolerance(parameters['NRTol']) - - #-- tsm -- - tsm = metafor.getTimeStepManager() - tsm.setInitialTime(0.0, 0.1) - tsm.setNextTime(10.0, parameters['nbArch'], 1.0) - tsm.setNextTime(20.0, parameters['nbArch'], 1.0) - - #Time Integration - ti = AlphaGeneralizedTimeIntegration(metafor) - ti.setAlphaM(-0.97) - ti.setAlphaF(0.01) - metafor.setTimeIntegration(ti) - - #Courbes - valuesmanager = metafor.getValuesManager() - pointset = geometry.getPointSet() - curveset = geometry.getCurveSet() - valuesmanager.add(1, MiscValueExtractor(metafor,EXT_T),'time') - ave1 = AngleValueExtractor(Axe(curveset(1003)),Axe(pointset(2),pointset(102))) - valuesmanager.add(11,ave1,'Angle1') - - # Objective Function : - #--------------------- - objectivefunctionset = metafor.getObjectiveFunctionSet() - - Index = 2000 - X0 = -10.0 - dX0 = 3.0 - Y0 = -10.0 - Z0 = 0.0 - Rm = 4.0 - Ll = 50.0 - alphaDeg = 80.0 - - alphaRad = alphaDeg * math.pi / 180.0 - cosAlphaDemi = math.cos(alphaRad / 2.0) - sinAlphaDemi = math.sin(alphaRad / 2.0) - cosAlpha = math.cos(alphaRad) - sinAlpha = math.sin(alphaRad) - cos90moinsAlpha = math.cos(math.pi / 2.0 - alphaRad) - sinAlpha = math.sin(alphaRad) - - from toolbox.domainTools import getGeoReferences - [pointset, curveset, wireset, surfaceset, sideset, skinset, volumeset] = getGeoReferences(domain) - piDemi = math.asin(1) - C45 = math.cos(piDemi/2.0) - Z0 = 0.0 - # Outil 1 : matrice - pointset.define(Index + 1, X0 - dX0, Y0, Z0) - pointset.define(Index + 2, X0, Y0, Z0) - pointset.define(Index + 3, X0 + (Rm * sinAlphaDemi), (Y0 - Rm * (1.0-cosAlphaDemi)), Z0) - pointset.define(Index + 4, X0 + (Rm * sinAlpha), (Y0 - Rm * (1.0-cosAlpha)), Z0) - pointset.define(Index + 5, X0 + (Rm * sinAlpha + Ll * cosAlpha), (Y0 - Rm * (1.0 - cosAlpha) - Ll * sinAlpha), Z0) - pointset.define(Index + 6, X0 - dX0 , (Y0 + 2.0), Z0) - - curveset.add( Line(Index + 1, pointset(Index + 1), pointset(Index + 2) )) - curveset.add( Arc(Index + 2, pointset(Index + 2), pointset(Index + 3), pointset(Index + 4) )) - curveset.add( Line(Index + 3, pointset(Index + 4), pointset(Index + 5) )) - curveset.add( Line(Index + 4, pointset(Index + 6), pointset(Index + 1) )) - - wireset.add(MultiProjWire(Index + 1, [curveset(Index+i) for i in (1, 2, 3)])) - wireset.add(Wire(Index+2, [curveset(1), curveset(101)])) - - sve1 = ShapeValueExtractor(wireset(Index+1), wireset(Index+2)) - sve1.setTriedreRef(Triedre(pointset(Index+1),pointset(Index+2),pointset(Index+6))) - sve1.setTriedreMesh(Triedre(pointset(1),pointset(1002),pointset(4))) - - valuesmanager.add(12,sve1,'shape1') - valuesmanager.add(13,sve1,NormOperator(),'shape2') - - sof1 = ValueExtractorObjectiveFunction(1,ave1) - objectivefunctionset.add(sof1) - sof2 = ValueExtractorObjectiveFunction(2,sve1) - objectivefunctionset.add(sof2) - - # Verification des Objective Function in .res File - testSuite = metafor.getTestSuiteChecker() - testSuite.checkObjectiveFunction(2) - testSuite.checkExtractor(11) - testSuite.checkExtractor(12,0) - testSuite.checkExtractor(12,5) - testSuite.checkExtractor(13) - - return metafor +# -*- coding: latin-1; -*- +# $Id: tombeBordEas2D.py 1422 2011-03-24 08:38:18Z papeleux $ +################################################# +# Tombe de bord # +#===============================================# +################################################# +from __future__ import print_function +from wrap import * +import math + +metafor = None + +def getMetafor(_parameters={}): + global metafor + if not metafor : + ''' + params = {'npgdy':50} + params.update(_parameters) + metafor = buildMetafor(params) + ''' + metafor = buildMetafor(_parameters) + return metafor + +def buildMetafor(p={}): + #-- parametres par defaut : + parameters = {'NIPDETA': 6, 'Young':210000.0,'Poisson':0.3, + 'sigEl0':420.0,'ih_H':1500.0, + 'npgdy': 16,'nx':35,'ny':8, + 'Thickness':1.0,'Rm':3.0,'Rt':1.0, + 'Gap':1.0,'nbArch':1, + 'peno':1e+08, 'mu_sta':0.6, 'mu_dyn':0.6, + 'NRTol':1e-07} + + print(p) + parameters.update(p) + metafor = Metafor() + domain = metafor.getDomain() + + geometry = domain.getGeometry() + geometry.setDimPlaneStrain(1.0) + #-- dimension du maillage + X0 = -3.0 + Y0 = 0.0 + Z0 = 0.0 + Lx = 20.0 + Th = parameters['Thickness'] + nx1 = parameters['nx'] + nx2 = parameters['nx'] + ny = parameters['ny'] + # Tool + Rm = parameters['Rm'] #Rm : rayon Matrice + Rt = parameters['Rt'] #Rt : rayon Tool + Gap = parameters['Gap'] #Jeu matrice - poincon + Lp = 3.0 #longueur du poincon + + #-- maillage -- + Lx1 = -2*X0 + (math.pi/2.0) * Rm + Lx2 = Lx - Lx1 + from toolbox.meshedGeometry2D import createRectangleSameId + createRectangleSameId(domain, nx1, ny, Lx1, Th, X0, Y0, 0) + from toolbox.meshedGeometry2D import addQuadrangle2X + addQuadrangle2X(domain, 100, nx2, ny, Lx2, Th, X0+Lx1, Y0, + 2, 3, 2) + #-- Fonctions d'evolution -- + FCT_CHA = PieceWiseLinearFunction() + FCT_CHA.setData(0.0, 0.0) + FCT_CHA.setData(10.0, 1.0) + FCT_CHA.setData(20.0 , 0.0) + #Outils de mise a forme + from apps.toolbox.formingTools import createFlangingTools2D + createFlangingTools2D(domain, 1000, (X0-1), Y0, Rm, Rt, Gap, Th, Lp, Lx,-Lx, FCT_CHA) + + prp_c1 = ElementProperties(Contact2DElement) + prp_c1.put(MATERIAL, 1001) + prp_c1.put(AREAINCONTACT,AIC_ONCE) + + interactionset = domain.getInteractionSet() + curveset = geometry.getCurveSet() + wireset = geometry.getWireSet() + sideset = geometry.getSideSet() + + wireset.add( Wire(201, [curveset(1), curveset(101)]) ) + wireset.add( Wire(202, [curveset(3), curveset(103)]) ) + #Outil 1 : Matrice + ci1 = RdContactInteraction(1) + ci1.setTool(wireset(1001)) + ci1.push(wireset(201)) + ci1.addProperty(prp_c1) + interactionset.add(ci1) + #Outil 2 : Poincon + ci2 = RdContactInteraction(2) + ci2.setTool(wireset(1101)) + ci2.push(wireset(202)) + ci2.addProperty(prp_c1) + interactionset.add(ci2) + #Outil 3 : Serre-Flanc + ci3 = RdContactInteraction(3) + ci3.setTool(wireset(1201)) + ci3.push(curveset(3)) + ci3.addProperty(prp_c1) + interactionset.add(ci3) + #-- FieldApplicator -- + app001 = FieldApplicator(99) + app001.push(sideset( 1)) + interactionset.add(app001) + + app101 = FieldApplicator(101) + app101.push(sideset(101)) + interactionset.add(app101) + #-- Fnn - Loadings -- + loadingset = domain.getLoadingSet() + loadingset.define(curveset(4), Field1D(TX,RE)) + loadingset.define(curveset(4), Field1D(TY,RE)) + + #-- Materiaux -- + materset = domain.getMaterialSet() + materlawset = domain.getMaterialLawSet() + materset.define(1, EvpIsoHHypoMaterial) + materset(1).put(MASS_DENSITY, 8900.0E-12) + materset(1).put(ELASTIC_MODULUS, parameters['Young']) + materset(1).put(POISSON_RATIO, parameters['Poisson']) + materset(1).put(YIELD_NUM, 2) + ''' + materlawset.define(1, RambergOsgoodIsotropicHardening) + materlawset(1).put(IH_SIGEL, 330.3) + materlawset(1).put(IH_A, 591.72) + materlawset(1).put(IH_N, 5.35) + ''' + materlawset.define(2, LinearIsotropicHardening) + materlawset(2).put(IH_SIGEL, parameters['sigEl0']) + materlawset(2).put(IH_H, parameters['ih_H']) + + + materset.define(1001, CoulombContactMaterial) + mat1001 = materset(1001) + mat1001.put(PEN_NORMALE, parameters['peno']) + mat1001.put(PEN_TANGENT, 1e+06) + mat1001.put(PROF_CONT, 0.9) + mat1001.put(COEF_FROT_STA, parameters['mu_sta']) # usually between 0.3 and 0.6 for dry materials + mat1001.put(COEF_FROT_DYN, parameters['mu_dyn']) + + #-- Propelem -- + prp001 = ElementProperties(Volume2DElement) + prp001.put(CAUCHYMECHVOLINTMETH, VES_CMVIM_EAS) + prp001.put(MATERIAL, 1) + prp001.put(NIPDETA, parameters['NIPDETA']) + prp001.put(EASS, 2) + prp001.put(EASV, 4) + prp001.put(VERBOSE, True) + interactionset(99).addProperty(prp001) + + prp101 = ElementProperties(Volume2DElement) + prp101.put(CAUCHYMECHVOLINTMETH, VES_CMVIM_EAS) + prp101.put(MATERIAL, 1) + prp101.put(NIPDETA, parameters['NIPDETA']) + prp101.put(EASS, 2) + prp101.put(EASV, 4) + prp101.put(VERBOSE, True) + interactionset(101).addProperty(prp101) + + # + + mim = metafor.getMechanicalIterationManager() + mim.setResidualTolerance(parameters['NRTol']) + + #-- tsm -- + tsm = metafor.getTimeStepManager() + tsm.setInitialTime(0.0, 0.1) + tsm.setNextTime(10.0, parameters['nbArch'], 1.0) + tsm.setNextTime(20.0, parameters['nbArch'], 1.0) + + #Time Integration + ti = AlphaGeneralizedTimeIntegration(metafor) + ti.setAlphaM(-0.97) + ti.setAlphaF(0.01) + metafor.setTimeIntegration(ti) + + #Courbes + valuesmanager = metafor.getValuesManager() + pointset = geometry.getPointSet() + curveset = geometry.getCurveSet() + valuesmanager.add(1, MiscValueExtractor(metafor,EXT_T),'time') + ave1 = AngleValueExtractor(Axe(curveset(1003)),Axe(pointset(2),pointset(102))) + valuesmanager.add(11,ave1,'Angle1') + + # Objective Function : + #--------------------- + objectivefunctionset = metafor.getObjectiveFunctionSet() + + Index = 2000 + X0 = -10.0 + dX0 = 3.0 + Y0 = -10.0 + Z0 = 0.0 + Rm = 4.0 + Ll = 50.0 + alphaDeg = 80.0 + + alphaRad = alphaDeg * math.pi / 180.0 + cosAlphaDemi = math.cos(alphaRad / 2.0) + sinAlphaDemi = math.sin(alphaRad / 2.0) + cosAlpha = math.cos(alphaRad) + sinAlpha = math.sin(alphaRad) + cos90moinsAlpha = math.cos(math.pi / 2.0 - alphaRad) + sinAlpha = math.sin(alphaRad) + + from toolbox.domainTools import getGeoReferences + [pointset, curveset, wireset, surfaceset, sideset, skinset, volumeset] = getGeoReferences(domain) + piDemi = math.asin(1) + C45 = math.cos(piDemi/2.0) + Z0 = 0.0 + # Outil 1 : matrice + pointset.define(Index + 1, X0 - dX0, Y0, Z0) + pointset.define(Index + 2, X0, Y0, Z0) + pointset.define(Index + 3, X0 + (Rm * sinAlphaDemi), (Y0 - Rm * (1.0-cosAlphaDemi)), Z0) + pointset.define(Index + 4, X0 + (Rm * sinAlpha), (Y0 - Rm * (1.0-cosAlpha)), Z0) + pointset.define(Index + 5, X0 + (Rm * sinAlpha + Ll * cosAlpha), (Y0 - Rm * (1.0 - cosAlpha) - Ll * sinAlpha), Z0) + pointset.define(Index + 6, X0 - dX0 , (Y0 + 2.0), Z0) + + curveset.add( Line(Index + 1, pointset(Index + 1), pointset(Index + 2) )) + curveset.add( Arc(Index + 2, pointset(Index + 2), pointset(Index + 3), pointset(Index + 4) )) + curveset.add( Line(Index + 3, pointset(Index + 4), pointset(Index + 5) )) + curveset.add( Line(Index + 4, pointset(Index + 6), pointset(Index + 1) )) + + wireset.add(MultiProjWire(Index + 1, [curveset(Index+i) for i in (1, 2, 3)])) + wireset.add(Wire(Index+2, [curveset(1), curveset(101)])) + + sve1 = ShapeValueExtractor(wireset(Index+1), wireset(Index+2)) + sve1.setTriedreRef(Triedre(pointset(Index+1),pointset(Index+2),pointset(Index+6))) + sve1.setTriedreMesh(Triedre(pointset(1),pointset(1002),pointset(4))) + + valuesmanager.add(12,sve1,'shape1') + valuesmanager.add(13,sve1,NormOperator(),'shape2') + + sof1 = ValueExtractorObjectiveFunction(1,ave1) + objectivefunctionset.add(sof1) + sof2 = ValueExtractorObjectiveFunction(2,sve1) + objectivefunctionset.add(sof2) + + # Verification des Objective Function in .res File + testSuite = metafor.getTestSuiteChecker() + testSuite.checkObjectiveFunction(2) + testSuite.checkExtractor(11) + testSuite.checkExtractor(12,0) + testSuite.checkExtractor(12,5) + testSuite.checkExtractor(13) + + return metafor diff --git a/Metafor/models/mirror01/mirror.py b/Metafor/models/mirror01/mirror.py index 0529b06a76956f0504806dc35b6ea8251b6b2c5f..118f9697f25839a5adb1a5939869a6a9b7464b3c 100644 --- a/Metafor/models/mirror01/mirror.py +++ b/Metafor/models/mirror01/mirror.py @@ -4,6 +4,7 @@ # # +from __future__ import absolute_import from wrap import * metafor = None @@ -17,7 +18,7 @@ def getMetafor(_parameters): global metafor if metafor: return metafor metafor = Metafor() - from parameters_file import * + from .parameters_file import * parameters = getParameters(_parameters) domain = metafor.getDomain() diff --git a/Metafor/models/omega01/EmboutOmega.py b/Metafor/models/omega01/EmboutOmega.py index c68b5f10a13c9aee7dd976cc23e578b3275ec3b2..32c6593d81caf4d2159b609cde9b1866ff6954c4 100644 --- a/Metafor/models/omega01/EmboutOmega.py +++ b/Metafor/models/omega01/EmboutOmega.py @@ -1,582 +1,583 @@ -# -*- coding: latin-1; -*- -# $Id: $ -################################################# -# -################################################# -#-- Initialisation python -from wrap import * -import math -metafor = None - -#========================================================================= -# -def getParameters(_parameters): - parameters = {} - # Paramètres serre-Flanc - parameters['forceSF'] = 1500.0 # Force de serrage du serre-Flanc - parameters['amortissement'] = 5.0e-7 # Paramètre d'amortissement - #paramètres contact - parameters['peno'] = 1.0e4 - parameters['mu'] = 0.12 - # Données matériau tôle - parameters['rho'] = 7.8e-9 # densité - parameters['Young'] = 210000.0 # Module de Young - parameters['poisson'] = 0.3 # Coef Poisson - - parameters['trac_Rm'] = 625 # Données matériau - parameters['trac_R02'] = 369 # Données matériau - parameters['trac_n'] = 0.194 # Données matériau - - # Géométrie - maillage du Flanc - parameters['nx'] = 135 - parameters['ny'] = 2 - parameters['Lx'] = 135. - parameters['Ly'] = 1. - parameters['nipX'] = 2 - parameters['nipY'] = 2 - - # Géométrie de la Matrice - parameters['Y0M'] = 0.0 - parameters['LxM1'] = 50.0 - #parameters['LxM2'] = post traité - parameters['LxM3'] = 140.0 - parameters['LyM'] = 61.1 - parameters['rM1'] = 10.0 - parameters['rM2'] = 10.0 - parameters['thetaM'] = 80.0 - parameters['ddyM'] = 1.0 - - # Géométrie du Poincon - parameters['Y0P'] = parameters['Ly'] - parameters['LxP1'] = 49.9 - parameters['rP1'] = 8.9 - parameters['rP2'] = 11.1 - parameters['rP3'] = 5.0 - parameters['LyP'] = 61.1 #0.110000002E+01+0.590441971E+02 - parameters['thetaP'] = 80.0 - parameters['ddyP'] = parameters['LyP'] - - # Géométrie du Serre Flanc - parameters['X0SF'] = 85.8 - parameters['rSF'] = 2.0 - parameters['Y0SF'] = parameters['Ly'] + parameters['rSF'] - parameters['LxSF'] = 50.0 - parameters['ddySF'] = 0.01 # déplacement initial du serre-Flanc - - # Paramètres du calcul - #parameters['ndyn'] = 0 - parameters['ndyn'] = 2 - parameters['prec'] = 1.0e-4 - - parameters['cmvim'] = VES_CMVIM_SRI - parameters['PEAS'] = 1.0e-8 - - - - # Mise à jour des parametres par defaut avec les parametres passés - parameters.update(_parameters) - # - #Ne pas remonter ce qui est ci dessous au dessus parameters.update(_parameters) - parameters['ih_n'] = parameters['trac_n'] # Krupkowsky - parameters['ih_k'] = parameters['trac_Rm']*math.exp(parameters['trac_n'])/ math.pow(parameters['trac_n'], parameters['trac_n']) # Krupkowsky - parameters['ih_evpl0'] = math.pow((parameters['trac_R02']/parameters['ih_k']), (1.0/parameters['trac_n']) )-0.002 # Krupkowsky : evpl0 - - print "ih_n = ", parameters['ih_n'] - print "ih_k = ", parameters['ih_k'] - print "ih_evpl0 = ", parameters['ih_evpl0'] - - parameters['thetaMRad'] = parameters['thetaM'] * math.pi / 180.0 - parameters['thetaPRad'] = parameters['thetaP'] * math.pi / 180.0 - - lxm2 = parameters['LxM1'] + parameters['rM1'] * math.sin(parameters['thetaMRad']) - lxm2 += (parameters['LyM'] - (parameters['rM1'] + parameters['rM2']) * (1.0-math.cos(parameters['thetaMRad']))) / math.tan(parameters['thetaMRad']) - lxm2 += parameters['rM2'] * math.sin(parameters['thetaMRad']) - parameters['LxM2'] = lxm2 - - lxp2 = parameters['LxP1'] + parameters['rP1'] * math.sin(parameters['thetaPRad']) - lxp2 += (parameters['LyP'] - (parameters['rP1'] + parameters['rP2']) * (1.0-math.cos(parameters['thetaPRad']))) / math.tan(parameters['thetaPRad']) - lxp2 += parameters['rP2'] * math.sin(parameters['thetaPRad']) - parameters['LxP2'] = lxp2 - #parameters['LxM2'] = parameters['LxM1'] + (parameters['LyM'] - parameters['rM2'] * (1.0-math.cos(parameters['thetaMRad']))) / math.tan(parameters['thetaMRad']) + parameters['rM1']*math.sin(parameters['thetaMRad']) - # Calcul des paramètres dépendant des paramètres de base - return parameters -#========================================================================= - - -def getMetafor(_parameters={}): - global metafor - if metafor: return metafor - p = getParameters(_parameters) - metafor = Metafor() - domain = metafor.getDomain() - geometry = domain.getGeometry() - geometry.setDimPlaneStrain(1.0) - - #-- maillage -- - from toolbox.meshedGeometry2D import createRectangleSameId - createRectangleSameId(domain, p['nx'], p['ny'], p['Lx'], p['Ly'], 0.0, 0.0, 0) - - # Géométrie des outils : matrice - pset = geometry.getPointSet() - p1001 = pset.define(1001, -1.0, p['Y0M']-p['LyM']) - p1002 = pset.define(1002, p['LxM1'], p['Y0M']-p['LyM']) - p1003 = pset.define(1003, p['LxM1']+p['rM1']*math.sin(p['thetaMRad']/2.0), p['Y0M']-p['LyM']+p['rM1']*(1.-math.cos(p['thetaMRad']/2.0))) - p1004 = pset.define(1004, p['LxM1']+p['rM1']*math.sin(p['thetaMRad']), p['Y0M']-p['LyM']+p['rM1']*(1.-math.cos(p['thetaMRad']))) - p1005 = pset.define(1005, p['LxM2']-p['rM2']*math.sin(p['thetaMRad']), p['Y0M']-p['rM2']*(1.-math.cos(p['thetaMRad']))) - p1006 = pset.define(1006, p['LxM2']-p['rM2']*math.sin(p['thetaMRad']/2.0), p['Y0M']-p['rM2']*(1.-math.cos(p['thetaMRad']/2.))) - p1007 = pset.define(1007, p['LxM2'], p['Y0M']) - p1008 = pset.define(1008, p['LxM3'], p['Y0M']) - - # curves - cset = geometry.getCurveSet() - c1001 = cset.add(Line(1001, p1001, p1002)) - c1002 = cset.add(Arc( 1002, p1002, p1003, p1004)) - c1003 = cset.add(Line(1003, p1004, p1005)) - c1004 = cset.add(Arc( 1004, p1005, p1006, p1007)) - c1005 = cset.add(Line(1005, p1007, p1008)) - - wset = geometry.getWireSet() - #w1001 = wset.add(Wire(1001,[c1001, c1002, c1003, c1004])) - w1001 = wset.add(Wire(1001,[c1005, c1004, c1003, c1002, c1001])) - sidset = geometry.getSideSet() - sid1001 = sidset.add(Side(1001,[w1001, ])) - - # Géométrie des outils : poincon - p2001 = pset.define(2001, -1.0, p['Y0P']) - p2002 = pset.define(2002, p['LxP1'], p['Y0P']) - p2003 = pset.define(2003, p['LxP1']+p['rP1']*math.sin(p['thetaPRad']/2.0), p['Y0P']+p['rP1']*(1.-math.cos(p['thetaPRad']/2.0))) - p2004 = pset.define(2004, p['LxP1']+p['rP1']*math.sin(p['thetaPRad']), p['Y0P']+p['rP1']*(1.-math.cos(p['thetaPRad'])) ) - #p2005 = pset.define(2005, p['LxP1']+p['rP1']*math.sin(p['thetaPRad'])+p['LyP']*math.cos(p['thetaPRad']), p['Y0P']+p['rP1']*(1.-math.cos(p['thetaPRad']))+p['LyP']*math.sin(p['thetaPRad'])) - p2005 = pset.define(2005, p['LxP2']-p['rP2']*math.sin(p['thetaPRad']), p['Y0P']+p['LyP']-p['rP2']*(1.-math.cos(p['thetaPRad']))) - p2006 = pset.define(2006, p['LxP2']-p['rP2']*math.sin(p['thetaPRad']/2.0), p['Y0P']+p['LyP']-p['rP2']*(1.-math.cos(p['thetaPRad']/2.))) - p2007 = pset.define(2007, p['LxP2'], p['Y0P']+p['LyP']) - p2008 = pset.define(2008, p['LxP2']+p['rP3']*math.sin(math.pi/4.0), p['Y0P']+p['LyP']+p['rP3']*(1.-math.cos(math.pi/4.0))) - p2009 = pset.define(2009, p['LxP2']+p['rP3']*math.sin(math.pi/2.0), p['Y0P']+p['LyP']+p['rP3']*(1.-math.cos(math.pi/2.0))) - - - # curves - cset = geometry.getCurveSet() - c2001 = cset.add(Line(2001, p2001, p2002)) - c2002 = cset.add(Arc( 2002, p2002, p2003, p2004)) - c2003 = cset.add(Line(2003, p2004, p2005)) - c2004 = cset.add(Arc( 2004, p2005, p2006, p2007)) - c2005 = cset.add(Arc( 2005, p2007, p2008, p2009)) - wset = geometry.getWireSet() - w2001 = wset.add(Wire(2001,[c2001, c2002, c2003, c2004, c2005])) - sidset = geometry.getSideSet() - sid2001 = sidset.add(Side(2001,[w2001, ])) - - # Géométrie des outils : Serre-Flanc - - p3001 = pset.define(3001, p['X0SF'], p['Y0SF']) - p3002 = pset.define(3002, p['X0SF']+p['rSF']*(1.0-math.cos(math.pi/3.)), p['Y0SF']-p['rSF']*math.sin(math.pi/3.)) - p3003 = pset.define(3003, p['X0SF']+p['rSF'], p['Y0SF']-p['rSF']) - p3004 = pset.define(3004, p['X0SF']+p['LxSF']-p['rSF'], p['Y0SF']-p['rSF']) - p3005 = pset.define(3005, p['X0SF']+p['LxSF']-p['rSF']*(1.0-math.cos(math.pi/3.)), p['Y0SF']-p['rSF']*math.sin(math.pi/3.)) - p3006 = pset.define(3006, p['X0SF']+p['LxSF'], p['Y0SF']) - - # curves - cset = geometry.getCurveSet() - c3001 = cset.add(Arc(3001, p3001, p3002, p3003)) - c3002 = cset.add(Line(3002, p3003, p3004)) - c3003 = cset.add(Arc( 3003, p3004, p3005, p3006)) - wset = geometry.getWireSet() - w3001 = wset.add(Wire(3001,[c3001, c3002, c3003])) - sidset = geometry.getSideSet() - sid3001 = sidset.add(Side(3001,[w3001, ])) - - # == SCHEMA D'INTEGRATION ====================================================================== - # Schéma d'intégration 0 : QS / 1 : Expl / 2 : Implicite dynamique - # Time Integration - if p['ndyn'] == 0 : - ti=QuasiStaticTimeIntegration(metafor) - metafor.setTimeIntegration(ti) - elif p['ndyn'] == 2 : - ti = AlphaGeneralizedTimeIntegration(metafor) - metafor.setTimeIntegration(ti) - else: - raise Exception("Unknown time integration") - mim = metafor.getMechanicalIterationManager() - mim.setResidualComputationMethod(Method4ResidualComputation(100.0)) - mim.setResidualTolerance(p['prec'] ) - mim.setMaxNbOfIterations(10) - #mim.setVerbose() - - - tsm = metafor.getTimeStepManager() - stages = metafor.getStageManager() - tsm.setInitialTime(0.0, 0.01) - tsm.setNextTime(0.1, 1, 0.01) - tsm.setNextTime(1., 1, 0.01) - tsm.setNextTime(2., 1, 0.1) - tsm.setNextTime(3., 1, 0.01) - tsm.setNextTime(10., 1, 0.1) - - # == Matériaux == - materials = domain.getMaterialSet() - mat1 = materials.define (1, EvpIsoHHypoMaterial) - mat1.put(MASS_DENSITY, p['rho']) # tonne/mm^3 - mat1.put(ELASTIC_MODULUS, p['Young']) # MPa - mat1.put(POISSON_RATIO, p['poisson']) - mat1.put(YIELD_NUM, 1) - matLawSet = domain.getMaterialLawSet() - matlaw = matLawSet.define(1, KrupkowskyIsotropicHardening) - matlaw.put(IH_EVPL0, p['ih_evpl0']) - matlaw.put(IH_K, p['ih_k']) - matlaw.put(IH_N, p['ih_n']) - - # Elements - prp1 = ElementProperties(Volume2DElement) - prp1.put(MATERIAL, 1) - prp1.put(CAUCHYMECHVOLINTMETH , p['cmvim']) - if p['cmvim'] == VES_CMVIM_EAS: - prp1.put(EASS, 2) - prp1.put(EASV, 2) - app = FieldApplicator(1) - app.push(sidset(1)) - app.addProperty(prp1) - domain.getInteractionSet().add(app) - ''' - # Elements - mat2 = materials.define (2, DampingMaterial) - mat2.put(SPRING_FC, 0.0) #.0001) - - prp2 = ElementProperties(Damping2DElement) - prp2.put(MATERIAL, 2) - prp2.put(STIFFMETHOD, STIFF_NUMERIC) - app2 = FieldApplicator(2) - app2.push(sidset(1)) - app2.addProperty(prp2) - domain.getInteractionSet().add(app2) - - app2.deactivate(stages[0]) - app2.activate(stages[4]) - ''' - - # == FIXATION ================================================================================== - fctM = PieceWiseLinearFunction() - fctM.setData(0.0, 0.0) - fctM.setData(1.0, 0.0) - fctM.setData(2.0, 0.0) - fctM.setData(3.0, 0.0) - - fctP = PieceWiseLinearFunction() - fctP.setData(0.0, -0.01) - fctP.setData(0.1, -0.01) - fctP.setData(1.0, 1.0) - fctP.setData(2.0, 0.0) - fctP.setData(3.0, 0.0) - - - inicond = metafor.getInitialConditionSet() - loads = domain.getLoadingSet() - loads.define(cset(4),Field1D(TX,RE)) - fP1 = loads.define(pset(1),Field1D(TY,RE)) - fP1.deactivate(stages[0]) - fP1.activate(stages[3]) - - - loads.define(w1001,Field1D(TY,RE), -p['ddyM'], fctM , TOTAL_LOAD) - loads.define(w2001,Field1D(TY,RE), -p['ddyP'], fctP , TOTAL_LOAD) - - p['pilotF'] = True - if p['pilotF'] : - - mesher = RigidToolMesher(w3001) - mesher.execute() - loads.define(w3001,Field1D(TX,RE)) - - fctSF = PieceWiseLinearFunction() - fctSF.setData(0.0, 0.0) - fctSF.setData(0.1, 1.0) - fctSF.setData(1.0, 1.0) - fctSF.setData(1.5, 1.0) - fctSF.setData(2.0, 1.0) - fctSF.setData(3.0, 1.0) - - TYSFLoad = loads.define(w3001,Field1D(TY,RE), -p['ddySF'],fctSF, INCREMENTAL_LOAD) - TYSFLoad.deactivate(stages[0]) - TYSFLoad.activate(stages[2]) - - fctForceSF = PieceWiseLinearFunction() - fctForceSF.setData(0.0, 0.0) - fctForceSF.setData(0.1, 1.0) - fctForceSF.setData(1.0, 1.0) - fctForceSF.setData(2.0, 1.0) - fctForceSF.setData(3.0, 1.0) - - GYFSLoad = loads.define(w3001,Field1D(TY,GF2), p['forceSF'], fctForceSF, TOTAL_LOAD)# force driven - - #GYFSLoad.deactivate(stages[0]) - #GYFSLoad.activate(stages[1]) - GYFSLoad.deactivate(stages[2]) - - else : - fctSF = PieceWiseLinearFunction() - fctSF.setData(0.0, 0.0) - fctSF.setData(0.1, 1.0) - fctSF.setData(1.0, 1.0) - fctSF.setData(2.0, 1.0) - fctSF.setData(3.0, 1.0) - TYSFLoad = loads.define(w3001,Field1D(TY,RE), -p['ddySF'],fctSF, TOTAL_LOAD) - - # == Contact == - - fctPeno = PieceWiseLinearFunction() - fctPeno.setData(0.0, 0.5) - fctPeno.setData(0.1, 1.0) - fctPeno.setData(1.0, 1.0) - fctPeno.setData(2.0, 1.0) - fctPeno.setData(3.0, 0.0) - fctPeno.setData(4.0, 0.0) - - mat1001 = materials.define(1001, CoulombContactMaterial) - mat1001.put(PEN_NORMALE, p['peno']) - mat1001.depend(PEN_NORMALE, fctPeno, Field(TM)) - mat1001.put(PEN_TANGENT, p['peno']*p['mu']) - mat1001.depend(PEN_TANGENT, fctPeno, Field(TM)) - mat1001.put(COEF_FROT_STA, p['mu']) - mat1001.put(COEF_FROT_DYN, p['mu']) - mat1001.put(PROF_CONT, 0.95*p['rM2'] ) - - prp_c1 = ElementProperties(Contact2DElement) - prp_c1.put(MATERIAL, 1001) - prp_c1.put(AREAINCONTACT,AIC_ONCE) - - - fctPeno2 = PieceWiseLinearFunction() - fctPeno2.setData(0.0, 0.5) - fctPeno2.setData(0.1, 1.0) - fctPeno2.setData(2.0, 1.0) - fctPeno2.setData(2.5, 0.01) - fctPeno2.setData(3.0, 0.0) - fctPeno2.setData(4.0, 0.0) - - mat1002 = materials.define(1002, CoulombContactMaterial) - mat1002.put(PEN_NORMALE, p['peno']) - mat1002.depend(PEN_NORMALE, fctPeno2, Field(TM)) - mat1002.put(PEN_TANGENT, p['peno']*p['mu']) - mat1002.depend(PEN_TANGENT, fctPeno, Field(TM)) - mat1002.put(COEF_FROT_STA, p['mu']) - mat1002.put(COEF_FROT_DYN, p['mu']) - mat1002.put(PROF_CONT, 0.95*p['rSF'] ) - prp_c2 = ElementProperties(Contact2DElement) - prp_c2.put(MATERIAL, 1002) - prp_c2.put(AREAINCONTACT,AIC_ONCE) - - fctPeno3 = PieceWiseLinearFunction() - fctPeno3.setData(0.0, 0.5) - fctPeno3.setData(0.1, 1.0) - fctPeno3.setData(2.0, 1.0) - fctPeno3.setData(2.5, 0.0) - fctPeno3.setData(3.0, 0.0) - fctPeno3.setData(4.0, 0.0) - - mat1003 = materials.define(1003, CoulombContactMaterial) - mat1003.put(PEN_NORMALE, p['peno']) - mat1003.depend(PEN_NORMALE, fctPeno3, Field(TM)) - mat1003.put(PEN_TANGENT, p['peno']*p['mu']) - mat1003.depend(PEN_TANGENT, fctPeno, Field(TM)) - mat1003.put(COEF_FROT_STA, p['mu']) - mat1003.put(COEF_FROT_DYN, p['mu']) - mat1003.put(PROF_CONT, 0.95*p['rP3'] ) - prp_c3 = ElementProperties(Contact2DElement) - prp_c3.put(MATERIAL, 1003) - prp_c3.put(AREAINCONTACT,AIC_ONCE) - - - #Outil 1 : Matrice - - ci1 = RdContactInteraction(1001) - ci1.setTool(w1001) - ci1.push(cset(1)) - ci1.addProperty(prp_c1) - domain.getInteractionSet().add(ci1) - #Outil 2 : Poincon - ci2 = RdContactInteraction(2001) - ci2.setTool(w2001) - ci2.push(cset(3)) - ci2.addProperty(prp_c2) - domain.getInteractionSet().add(ci2) - #Outil 3 : Serre-Flanc - if p['pilotF'] : - ci3 = FdRdContactInteraction(3001) - else : - ci3 = RdContactInteraction(3001) - ci3.setTool(w3001) - ci3.push(cset(3)) - ci3.addProperty(prp_c3) - domain.getInteractionSet().add(ci3) - - - ci1.deactivate(stages[4]) - ci2.deactivate(stages[4]) - ci3.deactivate(stages[4]) - - valuesmanager = metafor.getValuesManager() - valuesmanager.add(1, MiscValueExtractor(metafor,EXT_T),'time') - valuesmanager.add(2, IFNodalValueExtractor(pset(1), IF_EVMS), 'evms_p1') - valuesmanager.add(11, DbNodalValueExtractor(pset(2), Field1D(TX,RE)), 'TX_p2') - valuesmanager.add(12, DbNodalValueExtractor(pset(2), Field1D(TY,RE)), 'TY_p2') - valuesmanager.add(13, DbNodalValueExtractor(pset(2), Field1D(TX,GV)), 'VX_p2') - valuesmanager.add(14, DbNodalValueExtractor(pset(2), Field1D(TY,GV)), 'VY_p2') - - valuesmanager.add(16, DbNodalValueExtractor(pset(2001), Field1D(TY,RE)), 'TY_Poincon') - valuesmanager.add(17, DbNodalValueExtractor(pset(3001), Field1D(TY,RE)), 'TY_SerreFlanc') - - - objFSet = metafor.getObjectiveFunctionSet() - objFSet.add(SpringBackObjF(1, metafor, 11, 12, 1, 2.0, 10.0) ) - objFSet.add(LastVelocity(2, metafor, 13, 14, 1, 10.0) ) - - testSuite = metafor.getTestSuiteChecker() - testSuite.checkObjectiveFunction(1) - testSuite.checkObjectiveFunction(2) - -# valuesmanager.add(21, InteractionValueExtractor(ci1, TX, GEN_EXT_FORC), 'FX_Matrice') -# valuesmanager.add(22, InteractionValueExtractor(ci1, TY, GEN_EXT_FORC), 'FY_Matrice') -# valuesmanager.add(23, InteractionValueExtractor(ci2, TX, GEN_EXT_FORC), 'FX_Poincon') -# valuesmanager.add(24, InteractionValueExtractor(ci2, TY, GEN_EXT_FORC), 'FY_Poincon') -# valuesmanager.add(25, InteractionValueExtractor(ci3, TX, GEN_EXT_FORC), 'FX_SerreFlan') -# valuesmanager.add(26, InteractionValueExtractor(ci3, TY, GEN_EXT_FORC), 'FY_SerreFlan') - valuesmanager.add(21, ContactForceValueExtractor(ci1, TX, TOTAL_FORCE), SumOperator(), 'FX_Matrice') - valuesmanager.add(22, ContactForceValueExtractor(ci1, TY, TOTAL_FORCE), SumOperator(), 'FY_Matrice') - valuesmanager.add(23, ContactForceValueExtractor(ci2, TX, TOTAL_FORCE), SumOperator(), 'FX_Poincon') - valuesmanager.add(24, ContactForceValueExtractor(ci2, TY, TOTAL_FORCE), SumOperator(), 'FY_Poincon') - valuesmanager.add(25, ContactForceValueExtractor(ci3, TX, TOTAL_FORCE), SumOperator(), 'FX_SerreFlan') - valuesmanager.add(26, ContactForceValueExtractor(ci3, TY, TOTAL_FORCE), SumOperator(), 'FY_SerreFlan') - - valuesmanager.add(31, NormalGapValueExtractor(ci1), MaxOperator(), 'GapMaxMatrice') - valuesmanager.add(32, NormalGapValueExtractor(ci2), MaxOperator(), 'GapMaxPoincon') - valuesmanager.add(33, NormalGapValueExtractor(ci3), MaxOperator(), 'GapMaxSerreFlanc') - - cur1 = VectorDataCurve(1, valuesmanager.getDataVector(1), valuesmanager.getDataVector(11),valuesmanager.getDataVector(11).getName()) - cur2 = VectorDataCurve(2, valuesmanager.getDataVector(1), valuesmanager.getDataVector(12),valuesmanager.getDataVector(12).getName()) - cur3 = VectorDataCurve(3, valuesmanager.getDataVector(1), valuesmanager.getDataVector(16),valuesmanager.getDataVector(16).getName()) - cur4 = VectorDataCurve(4, valuesmanager.getDataVector(1), valuesmanager.getDataVector(17),valuesmanager.getDataVector(17).getName()) - - cur11 = VectorDataCurve(1, valuesmanager.getDataVector(1), valuesmanager.getDataVector(21), valuesmanager.getDataVector(21).getName()) - cur12 = VectorDataCurve(2, valuesmanager.getDataVector(1), valuesmanager.getDataVector(22), valuesmanager.getDataVector(22).getName()) - cur13 = VectorDataCurve(3, valuesmanager.getDataVector(1), valuesmanager.getDataVector(23), valuesmanager.getDataVector(23).getName()) - cur14 = VectorDataCurve(4, valuesmanager.getDataVector(1), valuesmanager.getDataVector(24), valuesmanager.getDataVector(24).getName()) - cur15 = VectorDataCurve(5, valuesmanager.getDataVector(1), valuesmanager.getDataVector(25), valuesmanager.getDataVector(25).getName()) - cur16 = VectorDataCurve(6, valuesmanager.getDataVector(1), valuesmanager.getDataVector(26), valuesmanager.getDataVector(26).getName()) - - cur31 = VectorDataCurve(31, valuesmanager.getDataVector(1), valuesmanager.getDataVector(31),valuesmanager.getDataVector(31).getName()) - cur32 = VectorDataCurve(32, valuesmanager.getDataVector(1), valuesmanager.getDataVector(32),valuesmanager.getDataVector(32).getName()) - cur33 = VectorDataCurve(33, valuesmanager.getDataVector(1), valuesmanager.getDataVector(33),valuesmanager.getDataVector(33).getName()) - - - dataCurveSet1 = DataCurveSet() - dataCurveSet1.add(cur1) - dataCurveSet1.add(cur2) - dataCurveSet1.add(cur3) - dataCurveSet1.add(cur4) - - dataCurveSet2 = DataCurveSet() - dataCurveSet2.add(cur11) - dataCurveSet2.add(cur12) - dataCurveSet2.add(cur13) - dataCurveSet2.add(cur14) - dataCurveSet2.add(cur15) - dataCurveSet2.add(cur16) - - dataCurveSet3 = DataCurveSet() - dataCurveSet3.add(cur31) - dataCurveSet3.add(cur32) - dataCurveSet3.add(cur33) - - try: - winc1 = VizWin() - winc1.add(dataCurveSet1) - metafor.addObserver(winc1) - - winc2 = VizWin() - winc2.add(dataCurveSet2) - metafor.addObserver(winc2) - - winc3 = VizWin() - winc3.add(dataCurveSet3) - metafor.addObserver(winc3) - except NameError: - pass - - - solman = metafor.getSolverManager(); - try: - solman.setSolver(DSSolver()); - except NameError: - pass - - return metafor - - -class SpringBackObjF(PythonObjectiveFunction): - def __init__(self,_no, _meta, _noPtTXRe, _noPtTYRe, _noTime , _time1, _time2) : - print "SpringBackObjF : __init__" - PythonObjectiveFunction.__init__(self,_no,_meta) - self.noPtTXRe = _noPtTXRe - self.noPtTYRe = _noPtTYRe - self.noTime = _noTime - self.time1 = _time1 - self.time2 = _time2 - - print "SpringBackObjF : __init__ finished" - - def __del__(self): - print "SpringBackObjectiveFunction : __del__" - print "callToDestructor of SpringBackObjectiveFunction not allowed. Add SpringBackObjectiveFunction.__disown__()" - raw_input('') - exit(1) - - def compute(self, meta): - print "entering SpringBackObjF compute" - valuesmanager = meta.getValuesManager() - curTX = VectorDataCurve(1, valuesmanager.getDataVector(self.noTime), valuesmanager.getDataVector(self.noPtTXRe)) - curTY = VectorDataCurve(2, valuesmanager.getDataVector(self.noTime), valuesmanager.getDataVector(self.noPtTYRe)) - - DX = curTX.eval(self.time2) - curTX.eval(self.time1) - DY = curTY.eval(self.time2) - curTY.eval(self.time1) - print "TX(%f) = %f \t TX(%f) = %f \t DX = %f "% (self.time1, curTX.eval(self.time1), self.time2, curTX.eval(self.time2), DX) - print "TY(%f) = %f \t TY(%f) = %f \t DY = %f "% (self.time1, curTY.eval(self.time1), self.time2, curTY.eval(self.time2), DY) - springBack = math.sqrt(DX*DX+DY*DY) - print "SpringBack = ", springBack - - - SpringBackfile = open('SpringBack.ascii','w') - SpringBackfile.write(str(springBack)) - SpringBackfile.close() - - return springBack - -class LastVelocity(PythonObjectiveFunction): - def __init__(self,_no, _meta, _noPtTXGV, _noPtTYGV, _noTime, _time) : - print "LastVelocity : __init__" - PythonObjectiveFunction.__init__(self,_no,_meta) - self.noPtTXGV = _noPtTXGV - self.noPtTYGV = _noPtTYGV - self.noTime = _noTime - self.time = _time - - print "LastVelocity : __init__ finished" - - def __del__(self): - print "LastVelocity : __del__" - print "callToDestructor of LastVelocity not allowed. Add LastVelocity.__disown__()" - raw_input('') - exit(1) - - def compute(self, meta): - print "entering LastVelocity compute" - valuesmanager = meta.getValuesManager() - curVX = VectorDataCurve(1, valuesmanager.getDataVector(self.noTime), valuesmanager.getDataVector(self.noPtTXGV)) - curVY = VectorDataCurve(2, valuesmanager.getDataVector(self.noTime), valuesmanager.getDataVector(self.noPtTYGV)) - - VX = curVX.eval(self.time) - VY = curVY.eval(self.time) - print "VX(%f) = %f "% (self.time, VX) - print "VY(%f) = %f "% (self.time, VY) - Veloc = math.sqrt(VX*VX+VY*VY) - print "Veloc = ", Veloc - return Veloc - +# -*- coding: latin-1; -*- +# $Id: $ +################################################# +# +################################################# +#-- Initialisation python +from __future__ import print_function +from wrap import * +import math +metafor = None + +#========================================================================= +# +def getParameters(_parameters): + parameters = {} + # Paramètres serre-Flanc + parameters['forceSF'] = 1500.0 # Force de serrage du serre-Flanc + parameters['amortissement'] = 5.0e-7 # Paramètre d'amortissement + #paramètres contact + parameters['peno'] = 1.0e4 + parameters['mu'] = 0.12 + # Données matériau tôle + parameters['rho'] = 7.8e-9 # densité + parameters['Young'] = 210000.0 # Module de Young + parameters['poisson'] = 0.3 # Coef Poisson + + parameters['trac_Rm'] = 625 # Données matériau + parameters['trac_R02'] = 369 # Données matériau + parameters['trac_n'] = 0.194 # Données matériau + + # Géométrie - maillage du Flanc + parameters['nx'] = 135 + parameters['ny'] = 2 + parameters['Lx'] = 135. + parameters['Ly'] = 1. + parameters['nipX'] = 2 + parameters['nipY'] = 2 + + # Géométrie de la Matrice + parameters['Y0M'] = 0.0 + parameters['LxM1'] = 50.0 + #parameters['LxM2'] = post traité + parameters['LxM3'] = 140.0 + parameters['LyM'] = 61.1 + parameters['rM1'] = 10.0 + parameters['rM2'] = 10.0 + parameters['thetaM'] = 80.0 + parameters['ddyM'] = 1.0 + + # Géométrie du Poincon + parameters['Y0P'] = parameters['Ly'] + parameters['LxP1'] = 49.9 + parameters['rP1'] = 8.9 + parameters['rP2'] = 11.1 + parameters['rP3'] = 5.0 + parameters['LyP'] = 61.1 #0.110000002E+01+0.590441971E+02 + parameters['thetaP'] = 80.0 + parameters['ddyP'] = parameters['LyP'] + + # Géométrie du Serre Flanc + parameters['X0SF'] = 85.8 + parameters['rSF'] = 2.0 + parameters['Y0SF'] = parameters['Ly'] + parameters['rSF'] + parameters['LxSF'] = 50.0 + parameters['ddySF'] = 0.01 # déplacement initial du serre-Flanc + + # Paramètres du calcul + #parameters['ndyn'] = 0 + parameters['ndyn'] = 2 + parameters['prec'] = 1.0e-4 + + parameters['cmvim'] = VES_CMVIM_SRI + parameters['PEAS'] = 1.0e-8 + + + + # Mise à jour des parametres par defaut avec les parametres passés + parameters.update(_parameters) + # + #Ne pas remonter ce qui est ci dessous au dessus parameters.update(_parameters) + parameters['ih_n'] = parameters['trac_n'] # Krupkowsky + parameters['ih_k'] = parameters['trac_Rm']*math.exp(parameters['trac_n'])/ math.pow(parameters['trac_n'], parameters['trac_n']) # Krupkowsky + parameters['ih_evpl0'] = math.pow((parameters['trac_R02']/parameters['ih_k']), (1.0/parameters['trac_n']) )-0.002 # Krupkowsky : evpl0 + + print("ih_n = ", parameters['ih_n']) + print("ih_k = ", parameters['ih_k']) + print("ih_evpl0 = ", parameters['ih_evpl0']) + + parameters['thetaMRad'] = parameters['thetaM'] * math.pi / 180.0 + parameters['thetaPRad'] = parameters['thetaP'] * math.pi / 180.0 + + lxm2 = parameters['LxM1'] + parameters['rM1'] * math.sin(parameters['thetaMRad']) + lxm2 += (parameters['LyM'] - (parameters['rM1'] + parameters['rM2']) * (1.0-math.cos(parameters['thetaMRad']))) / math.tan(parameters['thetaMRad']) + lxm2 += parameters['rM2'] * math.sin(parameters['thetaMRad']) + parameters['LxM2'] = lxm2 + + lxp2 = parameters['LxP1'] + parameters['rP1'] * math.sin(parameters['thetaPRad']) + lxp2 += (parameters['LyP'] - (parameters['rP1'] + parameters['rP2']) * (1.0-math.cos(parameters['thetaPRad']))) / math.tan(parameters['thetaPRad']) + lxp2 += parameters['rP2'] * math.sin(parameters['thetaPRad']) + parameters['LxP2'] = lxp2 + #parameters['LxM2'] = parameters['LxM1'] + (parameters['LyM'] - parameters['rM2'] * (1.0-math.cos(parameters['thetaMRad']))) / math.tan(parameters['thetaMRad']) + parameters['rM1']*math.sin(parameters['thetaMRad']) + # Calcul des paramètres dépendant des paramètres de base + return parameters +#========================================================================= + + +def getMetafor(_parameters={}): + global metafor + if metafor: return metafor + p = getParameters(_parameters) + metafor = Metafor() + domain = metafor.getDomain() + geometry = domain.getGeometry() + geometry.setDimPlaneStrain(1.0) + + #-- maillage -- + from toolbox.meshedGeometry2D import createRectangleSameId + createRectangleSameId(domain, p['nx'], p['ny'], p['Lx'], p['Ly'], 0.0, 0.0, 0) + + # Géométrie des outils : matrice + pset = geometry.getPointSet() + p1001 = pset.define(1001, -1.0, p['Y0M']-p['LyM']) + p1002 = pset.define(1002, p['LxM1'], p['Y0M']-p['LyM']) + p1003 = pset.define(1003, p['LxM1']+p['rM1']*math.sin(p['thetaMRad']/2.0), p['Y0M']-p['LyM']+p['rM1']*(1.-math.cos(p['thetaMRad']/2.0))) + p1004 = pset.define(1004, p['LxM1']+p['rM1']*math.sin(p['thetaMRad']), p['Y0M']-p['LyM']+p['rM1']*(1.-math.cos(p['thetaMRad']))) + p1005 = pset.define(1005, p['LxM2']-p['rM2']*math.sin(p['thetaMRad']), p['Y0M']-p['rM2']*(1.-math.cos(p['thetaMRad']))) + p1006 = pset.define(1006, p['LxM2']-p['rM2']*math.sin(p['thetaMRad']/2.0), p['Y0M']-p['rM2']*(1.-math.cos(p['thetaMRad']/2.))) + p1007 = pset.define(1007, p['LxM2'], p['Y0M']) + p1008 = pset.define(1008, p['LxM3'], p['Y0M']) + + # curves + cset = geometry.getCurveSet() + c1001 = cset.add(Line(1001, p1001, p1002)) + c1002 = cset.add(Arc( 1002, p1002, p1003, p1004)) + c1003 = cset.add(Line(1003, p1004, p1005)) + c1004 = cset.add(Arc( 1004, p1005, p1006, p1007)) + c1005 = cset.add(Line(1005, p1007, p1008)) + + wset = geometry.getWireSet() + #w1001 = wset.add(Wire(1001,[c1001, c1002, c1003, c1004])) + w1001 = wset.add(Wire(1001,[c1005, c1004, c1003, c1002, c1001])) + sidset = geometry.getSideSet() + sid1001 = sidset.add(Side(1001,[w1001, ])) + + # Géométrie des outils : poincon + p2001 = pset.define(2001, -1.0, p['Y0P']) + p2002 = pset.define(2002, p['LxP1'], p['Y0P']) + p2003 = pset.define(2003, p['LxP1']+p['rP1']*math.sin(p['thetaPRad']/2.0), p['Y0P']+p['rP1']*(1.-math.cos(p['thetaPRad']/2.0))) + p2004 = pset.define(2004, p['LxP1']+p['rP1']*math.sin(p['thetaPRad']), p['Y0P']+p['rP1']*(1.-math.cos(p['thetaPRad'])) ) + #p2005 = pset.define(2005, p['LxP1']+p['rP1']*math.sin(p['thetaPRad'])+p['LyP']*math.cos(p['thetaPRad']), p['Y0P']+p['rP1']*(1.-math.cos(p['thetaPRad']))+p['LyP']*math.sin(p['thetaPRad'])) + p2005 = pset.define(2005, p['LxP2']-p['rP2']*math.sin(p['thetaPRad']), p['Y0P']+p['LyP']-p['rP2']*(1.-math.cos(p['thetaPRad']))) + p2006 = pset.define(2006, p['LxP2']-p['rP2']*math.sin(p['thetaPRad']/2.0), p['Y0P']+p['LyP']-p['rP2']*(1.-math.cos(p['thetaPRad']/2.))) + p2007 = pset.define(2007, p['LxP2'], p['Y0P']+p['LyP']) + p2008 = pset.define(2008, p['LxP2']+p['rP3']*math.sin(math.pi/4.0), p['Y0P']+p['LyP']+p['rP3']*(1.-math.cos(math.pi/4.0))) + p2009 = pset.define(2009, p['LxP2']+p['rP3']*math.sin(math.pi/2.0), p['Y0P']+p['LyP']+p['rP3']*(1.-math.cos(math.pi/2.0))) + + + # curves + cset = geometry.getCurveSet() + c2001 = cset.add(Line(2001, p2001, p2002)) + c2002 = cset.add(Arc( 2002, p2002, p2003, p2004)) + c2003 = cset.add(Line(2003, p2004, p2005)) + c2004 = cset.add(Arc( 2004, p2005, p2006, p2007)) + c2005 = cset.add(Arc( 2005, p2007, p2008, p2009)) + wset = geometry.getWireSet() + w2001 = wset.add(Wire(2001,[c2001, c2002, c2003, c2004, c2005])) + sidset = geometry.getSideSet() + sid2001 = sidset.add(Side(2001,[w2001, ])) + + # Géométrie des outils : Serre-Flanc + + p3001 = pset.define(3001, p['X0SF'], p['Y0SF']) + p3002 = pset.define(3002, p['X0SF']+p['rSF']*(1.0-math.cos(math.pi/3.)), p['Y0SF']-p['rSF']*math.sin(math.pi/3.)) + p3003 = pset.define(3003, p['X0SF']+p['rSF'], p['Y0SF']-p['rSF']) + p3004 = pset.define(3004, p['X0SF']+p['LxSF']-p['rSF'], p['Y0SF']-p['rSF']) + p3005 = pset.define(3005, p['X0SF']+p['LxSF']-p['rSF']*(1.0-math.cos(math.pi/3.)), p['Y0SF']-p['rSF']*math.sin(math.pi/3.)) + p3006 = pset.define(3006, p['X0SF']+p['LxSF'], p['Y0SF']) + + # curves + cset = geometry.getCurveSet() + c3001 = cset.add(Arc(3001, p3001, p3002, p3003)) + c3002 = cset.add(Line(3002, p3003, p3004)) + c3003 = cset.add(Arc( 3003, p3004, p3005, p3006)) + wset = geometry.getWireSet() + w3001 = wset.add(Wire(3001,[c3001, c3002, c3003])) + sidset = geometry.getSideSet() + sid3001 = sidset.add(Side(3001,[w3001, ])) + + # == SCHEMA D'INTEGRATION ====================================================================== + # Schéma d'intégration 0 : QS / 1 : Expl / 2 : Implicite dynamique + # Time Integration + if p['ndyn'] == 0 : + ti=QuasiStaticTimeIntegration(metafor) + metafor.setTimeIntegration(ti) + elif p['ndyn'] == 2 : + ti = AlphaGeneralizedTimeIntegration(metafor) + metafor.setTimeIntegration(ti) + else: + raise Exception("Unknown time integration") + mim = metafor.getMechanicalIterationManager() + mim.setResidualComputationMethod(Method4ResidualComputation(100.0)) + mim.setResidualTolerance(p['prec'] ) + mim.setMaxNbOfIterations(10) + #mim.setVerbose() + + + tsm = metafor.getTimeStepManager() + stages = metafor.getStageManager() + tsm.setInitialTime(0.0, 0.01) + tsm.setNextTime(0.1, 1, 0.01) + tsm.setNextTime(1., 1, 0.01) + tsm.setNextTime(2., 1, 0.1) + tsm.setNextTime(3., 1, 0.01) + tsm.setNextTime(10., 1, 0.1) + + # == Matériaux == + materials = domain.getMaterialSet() + mat1 = materials.define (1, EvpIsoHHypoMaterial) + mat1.put(MASS_DENSITY, p['rho']) # tonne/mm^3 + mat1.put(ELASTIC_MODULUS, p['Young']) # MPa + mat1.put(POISSON_RATIO, p['poisson']) + mat1.put(YIELD_NUM, 1) + matLawSet = domain.getMaterialLawSet() + matlaw = matLawSet.define(1, KrupkowskyIsotropicHardening) + matlaw.put(IH_EVPL0, p['ih_evpl0']) + matlaw.put(IH_K, p['ih_k']) + matlaw.put(IH_N, p['ih_n']) + + # Elements + prp1 = ElementProperties(Volume2DElement) + prp1.put(MATERIAL, 1) + prp1.put(CAUCHYMECHVOLINTMETH , p['cmvim']) + if p['cmvim'] == VES_CMVIM_EAS: + prp1.put(EASS, 2) + prp1.put(EASV, 2) + app = FieldApplicator(1) + app.push(sidset(1)) + app.addProperty(prp1) + domain.getInteractionSet().add(app) + ''' + # Elements + mat2 = materials.define (2, DampingMaterial) + mat2.put(SPRING_FC, 0.0) #.0001) + + prp2 = ElementProperties(Damping2DElement) + prp2.put(MATERIAL, 2) + prp2.put(STIFFMETHOD, STIFF_NUMERIC) + app2 = FieldApplicator(2) + app2.push(sidset(1)) + app2.addProperty(prp2) + domain.getInteractionSet().add(app2) + + app2.deactivate(stages[0]) + app2.activate(stages[4]) + ''' + + # == FIXATION ================================================================================== + fctM = PieceWiseLinearFunction() + fctM.setData(0.0, 0.0) + fctM.setData(1.0, 0.0) + fctM.setData(2.0, 0.0) + fctM.setData(3.0, 0.0) + + fctP = PieceWiseLinearFunction() + fctP.setData(0.0, -0.01) + fctP.setData(0.1, -0.01) + fctP.setData(1.0, 1.0) + fctP.setData(2.0, 0.0) + fctP.setData(3.0, 0.0) + + + inicond = metafor.getInitialConditionSet() + loads = domain.getLoadingSet() + loads.define(cset(4),Field1D(TX,RE)) + fP1 = loads.define(pset(1),Field1D(TY,RE)) + fP1.deactivate(stages[0]) + fP1.activate(stages[3]) + + + loads.define(w1001,Field1D(TY,RE), -p['ddyM'], fctM , TOTAL_LOAD) + loads.define(w2001,Field1D(TY,RE), -p['ddyP'], fctP , TOTAL_LOAD) + + p['pilotF'] = True + if p['pilotF'] : + + mesher = RigidToolMesher(w3001) + mesher.execute() + loads.define(w3001,Field1D(TX,RE)) + + fctSF = PieceWiseLinearFunction() + fctSF.setData(0.0, 0.0) + fctSF.setData(0.1, 1.0) + fctSF.setData(1.0, 1.0) + fctSF.setData(1.5, 1.0) + fctSF.setData(2.0, 1.0) + fctSF.setData(3.0, 1.0) + + TYSFLoad = loads.define(w3001,Field1D(TY,RE), -p['ddySF'],fctSF, INCREMENTAL_LOAD) + TYSFLoad.deactivate(stages[0]) + TYSFLoad.activate(stages[2]) + + fctForceSF = PieceWiseLinearFunction() + fctForceSF.setData(0.0, 0.0) + fctForceSF.setData(0.1, 1.0) + fctForceSF.setData(1.0, 1.0) + fctForceSF.setData(2.0, 1.0) + fctForceSF.setData(3.0, 1.0) + + GYFSLoad = loads.define(w3001,Field1D(TY,GF2), p['forceSF'], fctForceSF, TOTAL_LOAD)# force driven + + #GYFSLoad.deactivate(stages[0]) + #GYFSLoad.activate(stages[1]) + GYFSLoad.deactivate(stages[2]) + + else : + fctSF = PieceWiseLinearFunction() + fctSF.setData(0.0, 0.0) + fctSF.setData(0.1, 1.0) + fctSF.setData(1.0, 1.0) + fctSF.setData(2.0, 1.0) + fctSF.setData(3.0, 1.0) + TYSFLoad = loads.define(w3001,Field1D(TY,RE), -p['ddySF'],fctSF, TOTAL_LOAD) + + # == Contact == + + fctPeno = PieceWiseLinearFunction() + fctPeno.setData(0.0, 0.5) + fctPeno.setData(0.1, 1.0) + fctPeno.setData(1.0, 1.0) + fctPeno.setData(2.0, 1.0) + fctPeno.setData(3.0, 0.0) + fctPeno.setData(4.0, 0.0) + + mat1001 = materials.define(1001, CoulombContactMaterial) + mat1001.put(PEN_NORMALE, p['peno']) + mat1001.depend(PEN_NORMALE, fctPeno, Field(TM)) + mat1001.put(PEN_TANGENT, p['peno']*p['mu']) + mat1001.depend(PEN_TANGENT, fctPeno, Field(TM)) + mat1001.put(COEF_FROT_STA, p['mu']) + mat1001.put(COEF_FROT_DYN, p['mu']) + mat1001.put(PROF_CONT, 0.95*p['rM2'] ) + + prp_c1 = ElementProperties(Contact2DElement) + prp_c1.put(MATERIAL, 1001) + prp_c1.put(AREAINCONTACT,AIC_ONCE) + + + fctPeno2 = PieceWiseLinearFunction() + fctPeno2.setData(0.0, 0.5) + fctPeno2.setData(0.1, 1.0) + fctPeno2.setData(2.0, 1.0) + fctPeno2.setData(2.5, 0.01) + fctPeno2.setData(3.0, 0.0) + fctPeno2.setData(4.0, 0.0) + + mat1002 = materials.define(1002, CoulombContactMaterial) + mat1002.put(PEN_NORMALE, p['peno']) + mat1002.depend(PEN_NORMALE, fctPeno2, Field(TM)) + mat1002.put(PEN_TANGENT, p['peno']*p['mu']) + mat1002.depend(PEN_TANGENT, fctPeno, Field(TM)) + mat1002.put(COEF_FROT_STA, p['mu']) + mat1002.put(COEF_FROT_DYN, p['mu']) + mat1002.put(PROF_CONT, 0.95*p['rSF'] ) + prp_c2 = ElementProperties(Contact2DElement) + prp_c2.put(MATERIAL, 1002) + prp_c2.put(AREAINCONTACT,AIC_ONCE) + + fctPeno3 = PieceWiseLinearFunction() + fctPeno3.setData(0.0, 0.5) + fctPeno3.setData(0.1, 1.0) + fctPeno3.setData(2.0, 1.0) + fctPeno3.setData(2.5, 0.0) + fctPeno3.setData(3.0, 0.0) + fctPeno3.setData(4.0, 0.0) + + mat1003 = materials.define(1003, CoulombContactMaterial) + mat1003.put(PEN_NORMALE, p['peno']) + mat1003.depend(PEN_NORMALE, fctPeno3, Field(TM)) + mat1003.put(PEN_TANGENT, p['peno']*p['mu']) + mat1003.depend(PEN_TANGENT, fctPeno, Field(TM)) + mat1003.put(COEF_FROT_STA, p['mu']) + mat1003.put(COEF_FROT_DYN, p['mu']) + mat1003.put(PROF_CONT, 0.95*p['rP3'] ) + prp_c3 = ElementProperties(Contact2DElement) + prp_c3.put(MATERIAL, 1003) + prp_c3.put(AREAINCONTACT,AIC_ONCE) + + + #Outil 1 : Matrice + + ci1 = RdContactInteraction(1001) + ci1.setTool(w1001) + ci1.push(cset(1)) + ci1.addProperty(prp_c1) + domain.getInteractionSet().add(ci1) + #Outil 2 : Poincon + ci2 = RdContactInteraction(2001) + ci2.setTool(w2001) + ci2.push(cset(3)) + ci2.addProperty(prp_c2) + domain.getInteractionSet().add(ci2) + #Outil 3 : Serre-Flanc + if p['pilotF'] : + ci3 = FdRdContactInteraction(3001) + else : + ci3 = RdContactInteraction(3001) + ci3.setTool(w3001) + ci3.push(cset(3)) + ci3.addProperty(prp_c3) + domain.getInteractionSet().add(ci3) + + + ci1.deactivate(stages[4]) + ci2.deactivate(stages[4]) + ci3.deactivate(stages[4]) + + valuesmanager = metafor.getValuesManager() + valuesmanager.add(1, MiscValueExtractor(metafor,EXT_T),'time') + valuesmanager.add(2, IFNodalValueExtractor(pset(1), IF_EVMS), 'evms_p1') + valuesmanager.add(11, DbNodalValueExtractor(pset(2), Field1D(TX,RE)), 'TX_p2') + valuesmanager.add(12, DbNodalValueExtractor(pset(2), Field1D(TY,RE)), 'TY_p2') + valuesmanager.add(13, DbNodalValueExtractor(pset(2), Field1D(TX,GV)), 'VX_p2') + valuesmanager.add(14, DbNodalValueExtractor(pset(2), Field1D(TY,GV)), 'VY_p2') + + valuesmanager.add(16, DbNodalValueExtractor(pset(2001), Field1D(TY,RE)), 'TY_Poincon') + valuesmanager.add(17, DbNodalValueExtractor(pset(3001), Field1D(TY,RE)), 'TY_SerreFlanc') + + + objFSet = metafor.getObjectiveFunctionSet() + objFSet.add(SpringBackObjF(1, metafor, 11, 12, 1, 2.0, 10.0) ) + objFSet.add(LastVelocity(2, metafor, 13, 14, 1, 10.0) ) + + testSuite = metafor.getTestSuiteChecker() + testSuite.checkObjectiveFunction(1) + testSuite.checkObjectiveFunction(2) + +# valuesmanager.add(21, InteractionValueExtractor(ci1, TX, GEN_EXT_FORC), 'FX_Matrice') +# valuesmanager.add(22, InteractionValueExtractor(ci1, TY, GEN_EXT_FORC), 'FY_Matrice') +# valuesmanager.add(23, InteractionValueExtractor(ci2, TX, GEN_EXT_FORC), 'FX_Poincon') +# valuesmanager.add(24, InteractionValueExtractor(ci2, TY, GEN_EXT_FORC), 'FY_Poincon') +# valuesmanager.add(25, InteractionValueExtractor(ci3, TX, GEN_EXT_FORC), 'FX_SerreFlan') +# valuesmanager.add(26, InteractionValueExtractor(ci3, TY, GEN_EXT_FORC), 'FY_SerreFlan') + valuesmanager.add(21, ContactForceValueExtractor(ci1, TX, TOTAL_FORCE), SumOperator(), 'FX_Matrice') + valuesmanager.add(22, ContactForceValueExtractor(ci1, TY, TOTAL_FORCE), SumOperator(), 'FY_Matrice') + valuesmanager.add(23, ContactForceValueExtractor(ci2, TX, TOTAL_FORCE), SumOperator(), 'FX_Poincon') + valuesmanager.add(24, ContactForceValueExtractor(ci2, TY, TOTAL_FORCE), SumOperator(), 'FY_Poincon') + valuesmanager.add(25, ContactForceValueExtractor(ci3, TX, TOTAL_FORCE), SumOperator(), 'FX_SerreFlan') + valuesmanager.add(26, ContactForceValueExtractor(ci3, TY, TOTAL_FORCE), SumOperator(), 'FY_SerreFlan') + + valuesmanager.add(31, NormalGapValueExtractor(ci1), MaxOperator(), 'GapMaxMatrice') + valuesmanager.add(32, NormalGapValueExtractor(ci2), MaxOperator(), 'GapMaxPoincon') + valuesmanager.add(33, NormalGapValueExtractor(ci3), MaxOperator(), 'GapMaxSerreFlanc') + + cur1 = VectorDataCurve(1, valuesmanager.getDataVector(1), valuesmanager.getDataVector(11),valuesmanager.getDataVector(11).getName()) + cur2 = VectorDataCurve(2, valuesmanager.getDataVector(1), valuesmanager.getDataVector(12),valuesmanager.getDataVector(12).getName()) + cur3 = VectorDataCurve(3, valuesmanager.getDataVector(1), valuesmanager.getDataVector(16),valuesmanager.getDataVector(16).getName()) + cur4 = VectorDataCurve(4, valuesmanager.getDataVector(1), valuesmanager.getDataVector(17),valuesmanager.getDataVector(17).getName()) + + cur11 = VectorDataCurve(1, valuesmanager.getDataVector(1), valuesmanager.getDataVector(21), valuesmanager.getDataVector(21).getName()) + cur12 = VectorDataCurve(2, valuesmanager.getDataVector(1), valuesmanager.getDataVector(22), valuesmanager.getDataVector(22).getName()) + cur13 = VectorDataCurve(3, valuesmanager.getDataVector(1), valuesmanager.getDataVector(23), valuesmanager.getDataVector(23).getName()) + cur14 = VectorDataCurve(4, valuesmanager.getDataVector(1), valuesmanager.getDataVector(24), valuesmanager.getDataVector(24).getName()) + cur15 = VectorDataCurve(5, valuesmanager.getDataVector(1), valuesmanager.getDataVector(25), valuesmanager.getDataVector(25).getName()) + cur16 = VectorDataCurve(6, valuesmanager.getDataVector(1), valuesmanager.getDataVector(26), valuesmanager.getDataVector(26).getName()) + + cur31 = VectorDataCurve(31, valuesmanager.getDataVector(1), valuesmanager.getDataVector(31),valuesmanager.getDataVector(31).getName()) + cur32 = VectorDataCurve(32, valuesmanager.getDataVector(1), valuesmanager.getDataVector(32),valuesmanager.getDataVector(32).getName()) + cur33 = VectorDataCurve(33, valuesmanager.getDataVector(1), valuesmanager.getDataVector(33),valuesmanager.getDataVector(33).getName()) + + + dataCurveSet1 = DataCurveSet() + dataCurveSet1.add(cur1) + dataCurveSet1.add(cur2) + dataCurveSet1.add(cur3) + dataCurveSet1.add(cur4) + + dataCurveSet2 = DataCurveSet() + dataCurveSet2.add(cur11) + dataCurveSet2.add(cur12) + dataCurveSet2.add(cur13) + dataCurveSet2.add(cur14) + dataCurveSet2.add(cur15) + dataCurveSet2.add(cur16) + + dataCurveSet3 = DataCurveSet() + dataCurveSet3.add(cur31) + dataCurveSet3.add(cur32) + dataCurveSet3.add(cur33) + + try: + winc1 = VizWin() + winc1.add(dataCurveSet1) + metafor.addObserver(winc1) + + winc2 = VizWin() + winc2.add(dataCurveSet2) + metafor.addObserver(winc2) + + winc3 = VizWin() + winc3.add(dataCurveSet3) + metafor.addObserver(winc3) + except NameError: + pass + + + solman = metafor.getSolverManager(); + try: + solman.setSolver(DSSolver()); + except NameError: + pass + + return metafor + + +class SpringBackObjF(PythonObjectiveFunction): + def __init__(self,_no, _meta, _noPtTXRe, _noPtTYRe, _noTime , _time1, _time2) : + print("SpringBackObjF : __init__") + PythonObjectiveFunction.__init__(self,_no,_meta) + self.noPtTXRe = _noPtTXRe + self.noPtTYRe = _noPtTYRe + self.noTime = _noTime + self.time1 = _time1 + self.time2 = _time2 + + print("SpringBackObjF : __init__ finished") + + def __del__(self): + print("SpringBackObjectiveFunction : __del__") + print("callToDestructor of SpringBackObjectiveFunction not allowed. Add SpringBackObjectiveFunction.__disown__()") + raw_input('') + exit(1) + + def compute(self, meta): + print("entering SpringBackObjF compute") + valuesmanager = meta.getValuesManager() + curTX = VectorDataCurve(1, valuesmanager.getDataVector(self.noTime), valuesmanager.getDataVector(self.noPtTXRe)) + curTY = VectorDataCurve(2, valuesmanager.getDataVector(self.noTime), valuesmanager.getDataVector(self.noPtTYRe)) + + DX = curTX.eval(self.time2) - curTX.eval(self.time1) + DY = curTY.eval(self.time2) - curTY.eval(self.time1) + print("TX(%f) = %f \t TX(%f) = %f \t DX = %f "% (self.time1, curTX.eval(self.time1), self.time2, curTX.eval(self.time2), DX)) + print("TY(%f) = %f \t TY(%f) = %f \t DY = %f "% (self.time1, curTY.eval(self.time1), self.time2, curTY.eval(self.time2), DY)) + springBack = math.sqrt(DX*DX+DY*DY) + print("SpringBack = ", springBack) + + + SpringBackfile = open('SpringBack.ascii','w') + SpringBackfile.write(str(springBack)) + SpringBackfile.close() + + return springBack + +class LastVelocity(PythonObjectiveFunction): + def __init__(self,_no, _meta, _noPtTXGV, _noPtTYGV, _noTime, _time) : + print("LastVelocity : __init__") + PythonObjectiveFunction.__init__(self,_no,_meta) + self.noPtTXGV = _noPtTXGV + self.noPtTYGV = _noPtTYGV + self.noTime = _noTime + self.time = _time + + print("LastVelocity : __init__ finished") + + def __del__(self): + print("LastVelocity : __del__") + print("callToDestructor of LastVelocity not allowed. Add LastVelocity.__disown__()") + raw_input('') + exit(1) + + def compute(self, meta): + print("entering LastVelocity compute") + valuesmanager = meta.getValuesManager() + curVX = VectorDataCurve(1, valuesmanager.getDataVector(self.noTime), valuesmanager.getDataVector(self.noPtTXGV)) + curVY = VectorDataCurve(2, valuesmanager.getDataVector(self.noTime), valuesmanager.getDataVector(self.noPtTYGV)) + + VX = curVX.eval(self.time) + VY = curVY.eval(self.time) + print("VX(%f) = %f "% (self.time, VX)) + print("VY(%f) = %f "% (self.time, VY)) + Veloc = math.sqrt(VX*VX+VY*VY) + print("Veloc = ", Veloc) + return Veloc + diff --git a/fdtd/tests/fdtd.py b/fdtd/tests/fdtd.py index 14a814565aaedb52313109732cc6dbbd66e8b4bd..e411ec80456b21a2949f5b60ced7fad659573d8f 100755 --- a/fdtd/tests/fdtd.py +++ b/fdtd/tests/fdtd.py @@ -16,12 +16,13 @@ # limitations under the License. +from __future__ import print_function import fdtd as fd def main(): p = fd.Problem() - print p + print(p) if __name__ == "__main__": main() diff --git a/flow/scripts/config.py b/flow/scripts/config.py index 525c16ff888d4bea604c7e5c34a0a151d44c65f0..5a3744cf285cbc77c4e12ff43108b652975a34d7 100644 --- a/flow/scripts/config.py +++ b/flow/scripts/config.py @@ -19,6 +19,7 @@ # @brief Base class for configuration # @authors Adrien Crovato +from __future__ import print_function import flow as f import tbox import tbox.gmsh as gmsh @@ -40,16 +41,16 @@ class Config: try: import tboxVtk Writer = tboxVtk.VtkExport - print "Found VTK libraries! Results will be saved in VTK format.\n" + print("Found VTK libraries! Results will be saved in VTK format.\n") except: Writer = tbox.GmshExport - print "VTK libraries not found! Results will be saved in gmsh format.\n" + print("VTK libraries not found! Results will be saved in gmsh format.\n") else: Writer = tbox.GmshExport - print "Results will be saved in gmsh format.\n" + print("Results will be saved in gmsh format.\n") # mesh the airfoil - print ccolors.ANSI_BLUE + 'Meshing the airfoil...' + ccolors.ANSI_RESET + print(ccolors.ANSI_BLUE + 'Meshing the airfoil...' + ccolors.ANSI_RESET) self.msh = gmsh.MeshLoader(p['File'],__file__).execute(**p['Pars']) if p['Dim'] == 2: mshCrck = tbox.MshCrack(self.msh, p['Dim']) @@ -69,7 +70,7 @@ class Config: tbox.GmshExport(self.msh).save(self.msh.name) del mshCrck self.mshWriter = Writer(self.msh) - print '\n' + print('\n') # initialize the problem self.pbl = f.Problem(self.msh, p['Dim'], 0., p['M_inf'], p['S_ref'], p['c_ref'], p['x_ref'], p['y_ref'], p['z_ref']) @@ -109,7 +110,7 @@ class Config: self.pbl.add(f.Wake(self.msh, [p['Wakes'][i], p['Wakes'][i]+'_', p['Fluid'], p['TeTips'][i]])) # initialize the solver - print ccolors.ANSI_BLUE + 'Initializing the solver...' + ccolors.ANSI_RESET + print(ccolors.ANSI_BLUE + 'Initializing the solver...' + ccolors.ANSI_RESET) if p['NSolver'] == 'Picard': self.solver = f.Picard(self.pbl) self.solver.relax = p['Relaxation'] diff --git a/flow/scripts/polar.py b/flow/scripts/polar.py index 48cbbdd0d6464ce0d283e399911521b3649d1331..96901709df9d4cbbc7c2675b5553591985d736b2 100644 --- a/flow/scripts/polar.py +++ b/flow/scripts/polar.py @@ -20,6 +20,7 @@ # Compute lift and polar curves # @authors Adrien Crovato +from __future__ import print_function import math import flow.utils as fU import tbox.utils as tU @@ -47,7 +48,7 @@ class Polar(Config): self.Cls = [] self.Cds = [] self.Cms = [] - print ccolors.ANSI_BLUE + 'Sweeping AoA from', self.alphas[0], 'to', self.alphas[-1], ccolors.ANSI_RESET + print(ccolors.ANSI_BLUE + 'Sweeping AoA from', self.alphas[0], 'to', self.alphas[-1], ccolors.ANSI_RESET) for alpha in self.alphas: # define current angle of attack and freestream velocity alpha = alpha*math.pi/180 @@ -60,12 +61,12 @@ class Polar(Config): self.phiInfFun.update(alpha) self.velInfFun.update(-U_inf[0], -U_inf[1], -U_inf[2]) # run the solver and save the results - print ccolors.ANSI_BLUE + 'Running the solver for', alpha*180/math.pi, 'degrees', ccolors.ANSI_RESET + print(ccolors.ANSI_BLUE + 'Running the solver for', alpha*180/math.pi, 'degrees', ccolors.ANSI_RESET) self.tms["solver"].start() self.solver.run() self.tms["solver"].stop() self.solver.save(ac, self.mshWriter) - print '\n' + print('\n') # extract Cp if self.alphas[0] == self.alphas[-1]: if self.dim == 2: @@ -82,17 +83,17 @@ class Polar(Config): def disp(self): # display results - print ccolors.ANSI_BLUE + 'Airfoil polar' + ccolors.ANSI_RESET - print " M alpha Cl Cd Cm" + print(ccolors.ANSI_BLUE + 'Airfoil polar' + ccolors.ANSI_RESET) + print(" M alpha Cl Cd Cm") i = 0 while i < len(self.alphas): - print "{0:8.2f} {1:8.1f} {2:8.4f} {3:8.4f} {4:8.4f}".format(self.mach, self.alphas[i], self.Cls[i], self.Cds[i], self.Cms[i]) + print("{0:8.2f} {1:8.1f} {2:8.4f} {3:8.4f} {4:8.4f}".format(self.mach, self.alphas[i], self.Cls[i], self.Cds[i], self.Cms[i])) i = i+1 - print '\n' + print('\n') # display timers self.tms["total"].stop() - print ccolors.ANSI_BLUE + 'CPU statistics' + ccolors.ANSI_RESET - print self.tms + print(ccolors.ANSI_BLUE + 'CPU statistics' + ccolors.ANSI_RESET) + print(self.tms) # plot results if self.alphas[0] != self.alphas[-1]: tU.plot(self.alphas, self.Cls, "alpha", "Cl", "") diff --git a/flow/scripts/trim.py b/flow/scripts/trim.py index eeaf76c0806e9173ee3414787a3d9013d7458d22..9130de1befbd2d15bed57fa5c07c2bcbd70a20a2 100644 --- a/flow/scripts/trim.py +++ b/flow/scripts/trim.py @@ -20,6 +20,7 @@ # Find the angle of attack to match a specified lift coefficient # @authors Adrien Crovato +from __future__ import print_function import math import flow.utils as fU import tbox.utils as tU @@ -48,7 +49,7 @@ class Trim(Config): it = 0 while True: # define current angle of attack and freestream velocity - print ccolors.ANSI_BLUE + 'Setting AoA to', self.alpha*180/math.pi, ccolors.ANSI_RESET + print(ccolors.ANSI_BLUE + 'Setting AoA to', self.alpha*180/math.pi, ccolors.ANSI_RESET) if self.dim == 2: U_inf = [math.cos(self.alpha), math.sin(self.alpha), 0.] else: @@ -78,7 +79,7 @@ class Trim(Config): # save results self.solver.save(0, self.mshWriter) - print '\n' + print('\n') # extract Cp if self.dim == 2: Cp = fU.extract(self.bnd.groups[0].tag.elems, self.solver.Cp) @@ -88,11 +89,11 @@ class Trim(Config): def disp(self): # display results - print ccolors.ANSI_BLUE + 'Trim analysis' + ccolors.ANSI_RESET - print " M alpha dCl Cl Cd Cm" - print "{0:8.2f} {1:8.1f} {2:8.4f} {3:8.4f} {4:8.4f} {5:8.4f}".format(self.mach, self.alpha*180/math.pi, self.dCl, self.solver.Cl, self.solver.Cd, self.solver.Cm) - print '\n' + print(ccolors.ANSI_BLUE + 'Trim analysis' + ccolors.ANSI_RESET) + print(" M alpha dCl Cl Cd Cm") + print("{0:8.2f} {1:8.1f} {2:8.4f} {3:8.4f} {4:8.4f} {5:8.4f}".format(self.mach, self.alpha*180/math.pi, self.dCl, self.solver.Cl, self.solver.Cd, self.solver.Cm)) + print('\n') # display timers self.tms["total"].stop() - print ccolors.ANSI_BLUE + 'CPU statistics' + ccolors.ANSI_RESET - print self.tms + print(ccolors.ANSI_BLUE + 'CPU statistics' + ccolors.ANSI_RESET) + print(self.tms) diff --git a/flow/tests/adjoint.py b/flow/tests/adjoint.py index ea45849990086917c282fd633d83e08f76d475e8..f7bd50216d62a456c5f492723bd4d715b14d9010 100644 --- a/flow/tests/adjoint.py +++ b/flow/tests/adjoint.py @@ -25,6 +25,7 @@ # This test is provided to ensure that the adjoint solver runs. # Mesh refinement may have to be performed to obtain physical results. +from __future__ import print_function import math import flow as flo import flow.utils as floU @@ -50,7 +51,7 @@ def main(): dim = len(U_inf) # mesh the geometry - print ccolors.ANSI_BLUE + 'PyMeshing...' + ccolors.ANSI_RESET + print(ccolors.ANSI_BLUE + 'PyMeshing...' + ccolors.ANSI_RESET) tms['msh'].start() pars = {'xLgt' : 5, 'yLgt' : 5, 'msF' : 1., 'msTe' : 0.0075, 'msLe' : 0.0075} msh = gmsh.MeshLoader("../models/n0012.geo",__file__).execute(**pars) @@ -84,7 +85,7 @@ def main(): tms['pre'].stop() # solve problem - print ccolors.ANSI_BLUE + 'PySolving...' + ccolors.ANSI_RESET + print(ccolors.ANSI_BLUE + 'PySolving...' + ccolors.ANSI_RESET) tms['solver'].start() solver = flo.Newton(pbl) floD.initNewton(solver) @@ -103,22 +104,22 @@ def main(): Cp = floU.extract(bnd.groups[0].tag.elems, solver.Cp) tboxU.write(Cp, 'Cp_airfoil.dat', '%1.5e', ', ', 'x, y, z, Cp', '') # display results - print ccolors.ANSI_BLUE + 'PyRes...' + ccolors.ANSI_RESET - print ' M alpha Cl Cd Cm' - print '{0:8.2f} {1:8.1f} {2:8.4f} {3:8.4f} {4:8.4f}'.format(M_inf, alpha*180/math.pi, solver.Cl, solver.Cd, solver.Cm) + print(ccolors.ANSI_BLUE + 'PyRes...' + ccolors.ANSI_RESET) + print(' M alpha Cl Cd Cm') + print('{0:8.2f} {1:8.1f} {2:8.4f} {3:8.4f} {4:8.4f}'.format(M_inf, alpha*180/math.pi, solver.Cl, solver.Cd, solver.Cm)) # display timers tms['total'].stop() - print ccolors.ANSI_BLUE + 'PyTiming...' + ccolors.ANSI_RESET - print 'CPU statistics' - print tms + print(ccolors.ANSI_BLUE + 'PyTiming...' + ccolors.ANSI_RESET) + print('CPU statistics') + print(tms) # check results - print ccolors.ANSI_BLUE + 'PyTesting...' + ccolors.ANSI_RESET - print 'No test defined for adjoint solver yet.' + print(ccolors.ANSI_BLUE + 'PyTesting...' + ccolors.ANSI_RESET) + print('No test defined for adjoint solver yet.') # eof - print '' + print('') if __name__ == "__main__": main() diff --git a/flow/tests/bli.py b/flow/tests/bli.py index 902eb21f0a85542d858848f29f3a16c78b30c70d..04c3d9670938a59ae11d5e2190558d2222976d93 100644 --- a/flow/tests/bli.py +++ b/flow/tests/bli.py @@ -24,6 +24,7 @@ # This test is provided to ensure that the solver works properly. # Mesh refinement may have to be performed to obtain physical results. +from __future__ import print_function import math import flow as flo import flow.utils as floU @@ -51,7 +52,7 @@ def main(): dim = len(U_inf) # mesh the geometry - print ccolors.ANSI_BLUE + 'PyMeshing...' + ccolors.ANSI_RESET + print(ccolors.ANSI_BLUE + 'PyMeshing...' + ccolors.ANSI_RESET) tms['msh'].start() pars = {'xLgt' : 5, 'yLgt' : 5, 'msF' : 1., 'msTe' : 0.0075, 'msLe' : 0.0075} msh = gmsh.MeshLoader("../models/n0012.geo",__file__).execute(**pars) @@ -86,7 +87,7 @@ def main(): tms['pre'].stop() # solve inviscid problem - print ccolors.ANSI_BLUE + 'PySolving...' + ccolors.ANSI_RESET + print(ccolors.ANSI_BLUE + 'PySolving...' + ccolors.ANSI_RESET) tms['solver'].start() isolver = flo.Newton(pbl) floD.initNewton(isolver) @@ -99,22 +100,22 @@ def main(): Cp = floU.extract(bnd.groups[0].tag.elems, isolver.Cp) tboxU.write(Cp, 'Cp_airfoil.dat', '%1.5e', ', ', 'x, y, z, Cp', '') # display results - print ccolors.ANSI_BLUE + 'PyRes...' + ccolors.ANSI_RESET - print ' M alpha Cl Cd Cm' - print '{0:8.2f} {1:8.1f} {2:8.4f} {3:8.4f} {4:8.4f}'.format(M_inf, alpha*180/math.pi, isolver.Cl, isolver.Cd, isolver.Cm) + print(ccolors.ANSI_BLUE + 'PyRes...' + ccolors.ANSI_RESET) + print(' M alpha Cl Cd Cm') + print('{0:8.2f} {1:8.1f} {2:8.4f} {3:8.4f} {4:8.4f}'.format(M_inf, alpha*180/math.pi, isolver.Cl, isolver.Cd, isolver.Cm)) # display timers tms['total'].stop() - print ccolors.ANSI_BLUE + 'PyTiming...' + ccolors.ANSI_RESET - print 'CPU statistics' - print tms + print(ccolors.ANSI_BLUE + 'PyTiming...' + ccolors.ANSI_RESET) + print('CPU statistics') + print(tms) # visualize solution and plot results floD.initViewer(pbl) tboxU.plot(Cp[:,0], Cp[:,3], 'x', 'Cp', 'Cl = {0:.{3}f}, Cd = {1:.{3}f}, Cm = {2:.{3}f}'.format(isolver.Cl, isolver.Cd, isolver.Cm, 4), True) # check results - print ccolors.ANSI_BLUE + 'PyTesting...' + ccolors.ANSI_RESET + print(ccolors.ANSI_BLUE + 'PyTesting...' + ccolors.ANSI_RESET) tests = CTests() if M_inf == 0 and alpha == 0*math.pi/180: tests.add(CTest('min(Cp)', min(Cp[:,3]), -0.41, 1e-1)) # TODO check value and tolerance @@ -124,7 +125,7 @@ def main(): tests.run() # eof - print '' + print('') if __name__ == "__main__": main() diff --git a/flow/tests/cylinder.py b/flow/tests/cylinder.py index 4384b9068133df936ab32774bb52c83908347805..5b118fb1d6c92d28b3bb631760b95ffc1cc26217 100644 --- a/flow/tests/cylinder.py +++ b/flow/tests/cylinder.py @@ -24,6 +24,7 @@ # This test is provided to ensure that the solver works properly. # Mesh refinement may have to be performed to obtain physical results. +from __future__ import print_function import math import flow as flo import flow.default as floD @@ -54,7 +55,7 @@ def main(): nms = 0.1 # nearfield mesh size # mesh the geometry - print ccolors.ANSI_BLUE + 'PyMeshing...' + ccolors.ANSI_RESET + print(ccolors.ANSI_BLUE + 'PyMeshing...' + ccolors.ANSI_RESET) tms['msh'].start() pars = {'dmt' : dmt, 'lgt' : lgt, 'hgt' : hgt, 'msN' : nms, 'msF' : fms} msh = gmsh.MeshLoader("../models/cylinder.geo",__file__).execute(**pars) @@ -88,7 +89,7 @@ def main(): tms['pre'].stop() # solve problem - print ccolors.ANSI_BLUE + 'PySolving...' + ccolors.ANSI_RESET + print(ccolors.ANSI_BLUE + 'PySolving...' + ccolors.ANSI_RESET) tms['picard'].start() solver0 = flo.Picard(pbl) floD.initPicard(solver0) @@ -144,15 +145,15 @@ def main(): # display timers tms['total'].stop() - print ccolors.ANSI_BLUE + 'PyTiming...' + ccolors.ANSI_RESET - print 'CPU statistics' - print tms + print(ccolors.ANSI_BLUE + 'PyTiming...' + ccolors.ANSI_RESET) + print('CPU statistics') + print(tms) # visualize solution floD.initViewer(pbl) # check results - print ccolors.ANSI_BLUE + 'PyTesting...' + ccolors.ANSI_RESET + print(ccolors.ANSI_BLUE + 'PyTesting...' + ccolors.ANSI_RESET) if not cnvrgd0 or not cnvrgd1: raise Exception(ccolors.ANSI_RED + 'Flow solver failed to converge!' + ccolors.ANSI_RESET) tests = CTests() @@ -165,7 +166,7 @@ def main(): tests.run() # eof - print '' + print('') if __name__ == "__main__": main() diff --git a/flow/tests/cylinder2D5.py b/flow/tests/cylinder2D5.py index ed5c1837d1c7c2c1a70d891ea3f27946c045c0a6..2671c8f9f84bd8258b99d04cbf0f46b296df7309 100644 --- a/flow/tests/cylinder2D5.py +++ b/flow/tests/cylinder2D5.py @@ -24,6 +24,7 @@ # This test is provided to ensure that the solver works properly. # Mesh refinement may have to be performed to obtain physical results. +from __future__ import print_function import math import flow as flo import flow.default as floD @@ -56,7 +57,7 @@ def main(): nms = 0.1 # nearfield mesh size # mesh the geometry - print ccolors.ANSI_BLUE + 'PyMeshing...' + ccolors.ANSI_RESET + print(ccolors.ANSI_BLUE + 'PyMeshing...' + ccolors.ANSI_RESET) tms["msh"].start() pars = {'dmt' : dmt, 'lgt' : lgt, 'wdt' : wdt, 'hgt' : hgt, 'msN' : nms, 'msF' : fms} msh = gmsh.MeshLoader("../models/cylinder_2D5.geo",__file__).execute(**pars) @@ -89,7 +90,7 @@ def main(): tms['pre'].stop() # solve problem - print ccolors.ANSI_BLUE + 'PySolving...' + ccolors.ANSI_RESET + print(ccolors.ANSI_BLUE + 'PySolving...' + ccolors.ANSI_RESET) tms['solver'].start() solver = flo.Newton(pbl) floD.initNewton(solver) @@ -134,15 +135,15 @@ def main(): # display timers tms['total'].stop() - print ccolors.ANSI_BLUE + 'PyTiming...' + ccolors.ANSI_RESET - print 'CPU statistics' - print tms + print(ccolors.ANSI_BLUE + 'PyTiming...' + ccolors.ANSI_RESET) + print('CPU statistics') + print(tms) # visualize solution floD.initViewer(pbl) # check results - print ccolors.ANSI_BLUE + 'PyTesting...' + ccolors.ANSI_RESET + print(ccolors.ANSI_BLUE + 'PyTesting...' + ccolors.ANSI_RESET) if (not cnvrgd): raise Exception(ccolors.ANSI_RED + 'Flow solver failed to converge!' + ccolors.ANSI_RESET) tests = CTests() @@ -152,7 +153,7 @@ def main(): tests.run() # eof - print '' + print('') if __name__ == "__main__": main() diff --git a/flow/tests/cylinder3.py b/flow/tests/cylinder3.py index 62c208f2e3a6d7d11cd635b677e443365d577238..7649106589539ad2d90be7a29568480bfe11e7e1 100644 --- a/flow/tests/cylinder3.py +++ b/flow/tests/cylinder3.py @@ -24,6 +24,7 @@ # This test is provided to ensure that the solver works properly. # Mesh refinement may have to be performed to obtain physical results. +from __future__ import print_function import math import flow as flo import flow.utils as floU @@ -59,7 +60,7 @@ def main(): nms = 0.1 # nearfield mesh size # mesh the geometry - print ccolors.ANSI_BLUE + 'PyMeshing...' + ccolors.ANSI_RESET + print(ccolors.ANSI_BLUE + 'PyMeshing...' + ccolors.ANSI_RESET) tms['msh'].start() pars = {'dmt' : dmt, 'spn' : spn, 'tpt' : tpt, 'lgt' : lgt, 'wdt' : wdt, 'hgt' : hgt, 'msN' : nms, 'msF' : fms} msh = gmsh.MeshLoader("../models/cylinder_3.geo",__file__).execute(**pars) @@ -93,7 +94,7 @@ def main(): tms['pre'].stop() # solve problem - print ccolors.ANSI_BLUE + 'PySolving...' + ccolors.ANSI_RESET + print(ccolors.ANSI_BLUE + 'PySolving...' + ccolors.ANSI_RESET) tms['solver'].start() solver = flo.Newton(pbl) floD.initNewton(solver) @@ -138,15 +139,15 @@ def main(): # display timers tms['total'].stop() - print ccolors.ANSI_BLUE + 'PyTiming...' + ccolors.ANSI_RESET - print 'CPU statistics' - print tms + print(ccolors.ANSI_BLUE + 'PyTiming...' + ccolors.ANSI_RESET) + print('CPU statistics') + print(tms) # visualize solution floD.initViewer(pbl) # check results - print ccolors.ANSI_BLUE + 'PyTesting...' + ccolors.ANSI_RESET + print(ccolors.ANSI_BLUE + 'PyTesting...' + ccolors.ANSI_RESET) if (not cnvrgd): raise Exception(ccolors.ANSI_RED + 'Flow solver failed to converge!' + ccolors.ANSI_RESET) tests = CTests() @@ -156,7 +157,7 @@ def main(): tests.run() # eof - print '' + print('') if __name__ == "__main__": main() diff --git a/flow/tests/lift.py b/flow/tests/lift.py index 905ff85ae3a156dc64a8a247ea627c5b2cf29e78..77313eadaca425360e280a288bdbc0347f5a0dcc 100644 --- a/flow/tests/lift.py +++ b/flow/tests/lift.py @@ -24,6 +24,7 @@ # This test is provided to ensure that the solver works properly. # Mesh refinement may have to be performed to obtain physical results. +from __future__ import print_function import math import flow as flo import flow.utils as floU @@ -49,7 +50,7 @@ def main(): dim = len(U_inf) # mesh the geometry - print ccolors.ANSI_BLUE + 'PyMeshing...' + ccolors.ANSI_RESET + print(ccolors.ANSI_BLUE + 'PyMeshing...' + ccolors.ANSI_RESET) tms['msh'].start() pars = {'xLgt' : 5, 'yLgt' : 5, 'msF' : 1., 'msTe' : 0.0075, 'msLe' : 0.0075} msh = gmsh.MeshLoader("../models/n0012.geo",__file__).execute(**pars) @@ -81,7 +82,7 @@ def main(): tms['pre'].stop() # solve problem - print ccolors.ANSI_BLUE + 'PySolving...' + ccolors.ANSI_RESET + print(ccolors.ANSI_BLUE + 'PySolving...' + ccolors.ANSI_RESET) tms['solver'].start() solver = flo.Newton(pbl) floD.initNewton(solver) @@ -93,22 +94,22 @@ def main(): Cp = floU.extract(bnd.groups[0].tag.elems, solver.Cp) tboxU.write(Cp, 'Cp_airfoil.dat', '%1.5e', ', ', 'x, y, z, Cp', '') # display results - print ccolors.ANSI_BLUE + 'PyRes...' + ccolors.ANSI_RESET - print ' M alpha Cl Cd Cm' - print '{0:8.2f} {1:8.1f} {2:8.4f} {3:8.4f} {4:8.4f}'.format(M_inf, alpha*180/math.pi, solver.Cl, solver.Cd, solver.Cm) + print(ccolors.ANSI_BLUE + 'PyRes...' + ccolors.ANSI_RESET) + print(' M alpha Cl Cd Cm') + print('{0:8.2f} {1:8.1f} {2:8.4f} {3:8.4f} {4:8.4f}'.format(M_inf, alpha*180/math.pi, solver.Cl, solver.Cd, solver.Cm)) # display timers tms['total'].stop() - print ccolors.ANSI_BLUE + 'PyTiming...' + ccolors.ANSI_RESET - print 'CPU statistics' - print tms + print(ccolors.ANSI_BLUE + 'PyTiming...' + ccolors.ANSI_RESET) + print('CPU statistics') + print(tms) # visualize solution and plot results floD.initViewer(pbl) tboxU.plot(Cp[:,0], Cp[:,3], 'x', 'Cp', 'Cl = {0:.{3}f}, Cd = {1:.{3}f}, Cm = {2:.{3}f}'.format(solver.Cl, solver.Cd, solver.Cm, 4), True) # check results - print ccolors.ANSI_BLUE + 'PyTesting...' + ccolors.ANSI_RESET + print(ccolors.ANSI_BLUE + 'PyTesting...' + ccolors.ANSI_RESET) tests = CTests() if M_inf == 0 and alpha == 3*math.pi/180: tests.add(CTest('min(Cp)', min(Cp[:,3]), -1.1, 1.5e-1)) @@ -124,7 +125,7 @@ def main(): tests.run() # eof - print '' + print('') if __name__ == "__main__": main() diff --git a/flow/tests/lift3.py b/flow/tests/lift3.py index 42fe993f3a4ed0933f226599ef0ee65821452ba7..300048398f7182cc2633ca541a6eb39d24e36730 100644 --- a/flow/tests/lift3.py +++ b/flow/tests/lift3.py @@ -24,6 +24,7 @@ # This test is provided to ensure that the solver works properly. # Mesh refinement may have to be performed to obtain physical results. +from __future__ import print_function import math import flow as flo import flow.utils as floU @@ -57,7 +58,7 @@ def main(): nms = 0.02 # nearfield mesh size # mesh the geometry - print ccolors.ANSI_BLUE + 'PyMeshing...' + ccolors.ANSI_RESET + print(ccolors.ANSI_BLUE + 'PyMeshing...' + ccolors.ANSI_RESET) tms['msh'].start() pars = {'spn' : spn, 'lgt' : lgt, 'wdt' : wdt, 'hgt' : hgt, 'msLe' : nms, 'msTe' : nms, 'msF' : fms} msh = gmsh.MeshLoader("../models/n0012_3.geo",__file__).execute(**pars) @@ -89,7 +90,7 @@ def main(): tms['pre'].stop() # solve problem - print ccolors.ANSI_BLUE + 'PySolving...' + ccolors.ANSI_RESET + print(ccolors.ANSI_BLUE + 'PySolving...' + ccolors.ANSI_RESET) tms['solver'].start() solver = flo.Newton(pbl) floD.initNewton(solver) @@ -99,15 +100,15 @@ def main(): # display timers tms['total'].stop() - print ccolors.ANSI_BLUE + 'PyTiming...' + ccolors.ANSI_RESET - print 'CPU statistics' - print tms + print(ccolors.ANSI_BLUE + 'PyTiming...' + ccolors.ANSI_RESET) + print('CPU statistics') + print(tms) # visualize solution floD.initViewer(pbl) # check results - print ccolors.ANSI_BLUE + 'PyTesting...' + ccolors.ANSI_RESET + print(ccolors.ANSI_BLUE + 'PyTesting...' + ccolors.ANSI_RESET) tests = CTests() if alpha == 3*math.pi/180 and M_inf == 0.3 and spn == 1.0: tests.add(CTest('CL', solver.Cl, 0.135, 5e-2)) @@ -117,7 +118,7 @@ def main(): tests.run() # eof - print '' + print('') if __name__ == "__main__": main() diff --git a/flow/tests/meshDef.py b/flow/tests/meshDef.py index 7f5f7b614667314ad989b456dbcd22cff766f321..0d2040a1e85742d6fdf5d2a7f6eefe9895f1fbcb 100644 --- a/flow/tests/meshDef.py +++ b/flow/tests/meshDef.py @@ -24,6 +24,7 @@ # This test is provided to ensure that the solver works properly. # Mesh refinement may have to be performed to obtain physical results. +from __future__ import print_function import numpy as np import flow as flo import flow.utils as floU @@ -54,7 +55,7 @@ def main(): dy = 0.5 # mesh the geometry - print ccolors.ANSI_BLUE + 'PyMeshing...' + ccolors.ANSI_RESET + print(ccolors.ANSI_BLUE + 'PyMeshing...' + ccolors.ANSI_RESET) tms['msh'].start() pars = {'xLgt' : 5, 'yLgt' : 5, 'msF' : 1., 'msTe' : 0.01, 'msLe' : 0.01} msh = gmsh.MeshLoader("../models/n0012.geo",__file__).execute(**pars) @@ -118,7 +119,7 @@ def main(): tms['pre'].stop() # solver problem for 0°AOA - print ccolors.ANSI_BLUE + 'PySolving...' + ccolors.ANSI_RESET + print(ccolors.ANSI_BLUE + 'PySolving...' + ccolors.ANSI_RESET) tms['solver0'].start() solver = flo.Newton(pbl) floD.initNewton(solver) @@ -126,7 +127,7 @@ def main(): tms['solver0'].stop() # deform the mesh (dummy rotation + translation) - print ccolors.ANSI_BLUE + 'PyDeforming...' + ccolors.ANSI_RESET + print(ccolors.ANSI_BLUE + 'PyDeforming...' + ccolors.ANSI_RESET) tms['deform'].start() floD.initMeshDeformer(mshDef) mshDef.savePos() @@ -147,14 +148,14 @@ def main(): tms['deform'].stop() # solve problem for alfa AOA - print ccolors.ANSI_BLUE + 'PySolving...' + ccolors.ANSI_RESET + print(ccolors.ANSI_BLUE + 'PySolving...' + ccolors.ANSI_RESET) tms['solver1'].start() solver.run() solver.save(0, gmshWriter) tms['solver1'].stop() # compute reference solution - print ccolors.ANSI_BLUE + 'PySolving...' + ccolors.ANSI_RESET + print(ccolors.ANSI_BLUE + 'PySolving...' + ccolors.ANSI_RESET) tms['solver_ref'].start() solver_ref = flo.Newton(pbl_ref) floD.initNewton(solver_ref) @@ -168,31 +169,31 @@ def main(): Cp_ref = floU.extract(bnd_ref.groups[0].tag.elems, solver_ref.Cp) tboxU.write(Cp, 'Cp_airfoil_ref.dat', '%1.5e', ', ', 'x, y, z, Cp', '') # display results - print ccolors.ANSI_BLUE + 'PyRes...' + ccolors.ANSI_RESET - print ' case M alpha Cl Cd Cm' - print ' true {0:8.2f} {1:8.1f} {2:8.4f} {3:8.4f} {4:8.4f}'.format(M_inf, alfa*180/np.pi, solver.Cl, solver.Cd, solver.Cm) - print ' ref {0:8.2f} {1:8.1f} {2:8.4f} {3:8.4f} {4:8.4f}'.format(M_inf, alfa*180/np.pi, solver_ref.Cl, solver_ref.Cd, solver_ref.Cm) - print 'Cm will differ unless dx and dy are set to 0...' + print(ccolors.ANSI_BLUE + 'PyRes...' + ccolors.ANSI_RESET) + print(' case M alpha Cl Cd Cm') + print(' true {0:8.2f} {1:8.1f} {2:8.4f} {3:8.4f} {4:8.4f}'.format(M_inf, alfa*180/np.pi, solver.Cl, solver.Cd, solver.Cm)) + print(' ref {0:8.2f} {1:8.1f} {2:8.4f} {3:8.4f} {4:8.4f}'.format(M_inf, alfa*180/np.pi, solver_ref.Cl, solver_ref.Cd, solver_ref.Cm)) + print('Cm will differ unless dx and dy are set to 0...') # display timers tms["total"].stop() - print ccolors.ANSI_BLUE + 'PyTiming...' + ccolors.ANSI_RESET - print "CPU statistics" - print tms + print(ccolors.ANSI_BLUE + 'PyTiming...' + ccolors.ANSI_RESET) + print("CPU statistics") + print(tms) # visualize solution and plot results tboxU.plot(Cp[:,0], Cp[:,3], 'x', 'Cp', 'Cl = {0:.{3}f}, Cd = {1:.{3}f}, Cm = {2:.{3}f}'.format(solver.Cl, solver.Cd, solver.Cm, 4), True) tboxU.plot(Cp_ref[:,0], Cp_ref[:,3], 'x', 'Cp', 'Cl = {0:.{3}f}, Cd = {1:.{3}f}, Cm = {2:.{3}f}'.format(solver_ref.Cl, solver_ref.Cd, solver_ref.Cm, 4), True) # check results - print ccolors.ANSI_BLUE + 'PyTesting...' + ccolors.ANSI_RESET + print(ccolors.ANSI_BLUE + 'PyTesting...' + ccolors.ANSI_RESET) tests = CTests() tests.add(CTest('min(Cp)', min(Cp[:,3]), min(Cp_ref[:,3]), 5e-2)) tests.add(CTest('Cl', solver.Cl, solver_ref.Cl, 5e-2)) tests.run() # eof - print '' + print('') if __name__ == "__main__": main() diff --git a/flow/tests/meshDef3.py b/flow/tests/meshDef3.py index cf7393b6a0dced4c4553c7dc2c4f0dcc253120fc..5a04160d98122d6d3dc404d6dc4eab67caea46b6 100644 --- a/flow/tests/meshDef3.py +++ b/flow/tests/meshDef3.py @@ -24,6 +24,7 @@ # This test is provided to ensure that the solver works properly. # Mesh refinement may have to be performed to obtain physical results. +from __future__ import print_function import numpy as np import flow as flo import flow.utils as floU @@ -62,7 +63,7 @@ def main(): dz_max = 0.2*spn # mesh an airfoil - print ccolors.ANSI_BLUE + 'PyMeshing...' + ccolors.ANSI_RESET + print(ccolors.ANSI_BLUE + 'PyMeshing...' + ccolors.ANSI_RESET) tms['msh'].start() pars = {'spn' : spn, 'lgt' : lgt, 'wdt' : wdt, 'hgt' : hgt, 'msLe' : nms, 'msTe' : nms, 'msF' : fms} msh = gmsh.MeshLoader("../models/n0012_3.geo",__file__).execute(**pars) @@ -102,7 +103,7 @@ def main(): tms['pre'].stop() # solver problem for 0°AOA - print ccolors.ANSI_BLUE + 'PySolving...' + ccolors.ANSI_RESET + print(ccolors.ANSI_BLUE + 'PySolving...' + ccolors.ANSI_RESET) tms['solver0'].start() solver = flo.Newton(pbl) floD.initNewton(solver) @@ -110,7 +111,7 @@ def main(): tms['solver0'].stop() # deform the mesh (dummy rotation + bending) - print ccolors.ANSI_BLUE + 'PyDeforming...' + ccolors.ANSI_RESET + print(ccolors.ANSI_BLUE + 'PyDeforming...' + ccolors.ANSI_RESET) tms['deform'].start() floD.initMeshDeformer(mshDef) mshDef.savePos() @@ -131,25 +132,25 @@ def main(): tms['deform'].stop() # solve problem for alfa AOA - print ccolors.ANSI_BLUE + 'PySolving...' + ccolors.ANSI_RESET + print(ccolors.ANSI_BLUE + 'PySolving...' + ccolors.ANSI_RESET) tms['solver1'].start() solver.run() solver.save(0, gmshWriter) tms['solver1'].stop() # display results - print ccolors.ANSI_BLUE + 'PyRes...' + ccolors.ANSI_RESET - print ' case M alpha Cl Cd Cm' - print ' true {0:8.2f} {1:8.1f} {2:8.4f} {3:8.4f} {4:8.4f}'.format(M_inf, alfa*180/np.pi, solver.Cl, solver.Cd, solver.Cm) + print(ccolors.ANSI_BLUE + 'PyRes...' + ccolors.ANSI_RESET) + print(' case M alpha Cl Cd Cm') + print(' true {0:8.2f} {1:8.1f} {2:8.4f} {3:8.4f} {4:8.4f}'.format(M_inf, alfa*180/np.pi, solver.Cl, solver.Cd, solver.Cm)) # display timers tms['total'].stop() - print ccolors.ANSI_BLUE + 'PyTiming...' + ccolors.ANSI_RESET - print 'CPU statistics' - print tms + print(ccolors.ANSI_BLUE + 'PyTiming...' + ccolors.ANSI_RESET) + print('CPU statistics') + print(tms) # check results - print ccolors.ANSI_BLUE + 'PyTesting...' + ccolors.ANSI_RESET + print(ccolors.ANSI_BLUE + 'PyTesting...' + ccolors.ANSI_RESET) tests = CTests() if alfa == 3*np.pi/180 and M_inf == 0.3 and spn == 1.0: tests.add(CTest('CL', solver.Cl, 0.135, 5e-1)) @@ -157,7 +158,7 @@ def main(): tests.run() # eof - print '' + print('') if __name__ == "__main__": main() diff --git a/flow/tests/nonlift.py b/flow/tests/nonlift.py index 8019017fb7921d36fa822c118676ce961e52505c..6e6b2ae3c462daba4770a7964d0f01148b1c05b8 100644 --- a/flow/tests/nonlift.py +++ b/flow/tests/nonlift.py @@ -25,6 +25,7 @@ # Mesh refinement may have to be performed to obtain physical results. # The residual might not fully converge if this test is used with gmsh4 +from __future__ import print_function import math import flow as flo import flow.utils as floU @@ -50,7 +51,7 @@ def main(): dim = len(U_inf) # mesh the geometry - print ccolors.ANSI_BLUE + 'PyMeshing...' + ccolors.ANSI_RESET + print(ccolors.ANSI_BLUE + 'PyMeshing...' + ccolors.ANSI_RESET) tms['msh'].start() pars = {'xLgt' : 5, 'yLgt' : 5, 'msF' : 1., 'msTe' : 0.01, 'msLe' : 0.01} msh = gmsh.MeshLoader("../models/n0012.geo",__file__).execute(**pars) @@ -80,7 +81,7 @@ def main(): tms['pre'].stop() # solve problem - print ccolors.ANSI_BLUE + 'PySolving...' + ccolors.ANSI_RESET + print(ccolors.ANSI_BLUE + 'PySolving...' + ccolors.ANSI_RESET) tms['solver'].start() solver = flo.Newton(pbl) floD.initNewton(solver) @@ -92,22 +93,22 @@ def main(): Cp = floU.extract(bnd.groups[0].tag.elems, solver.Cp) tboxU.write(Cp, 'Cp_airfoil.dat', '%1.5e', ', ', 'x, y, z, Cp', '') # display results - print ccolors.ANSI_BLUE + 'PyRes...' + ccolors.ANSI_RESET - print ' M alpha Cl Cd Cm' - print '{0:8.2f} {1:8.1f} {2:8.4f} {3:8.4f} {4:8.4f}'.format(M_inf, alpha*180/math.pi, solver.Cl, solver.Cd, solver.Cm) + print(ccolors.ANSI_BLUE + 'PyRes...' + ccolors.ANSI_RESET) + print(' M alpha Cl Cd Cm') + print('{0:8.2f} {1:8.1f} {2:8.4f} {3:8.4f} {4:8.4f}'.format(M_inf, alpha*180/math.pi, solver.Cl, solver.Cd, solver.Cm)) # display timers tms['total'].stop() - print ccolors.ANSI_BLUE + 'PyTiming...' + ccolors.ANSI_RESET - print 'CPU statistics' - print tms + print(ccolors.ANSI_BLUE + 'PyTiming...' + ccolors.ANSI_RESET) + print('CPU statistics') + print(tms) # visualize solution and plot results floD.initViewer(pbl) tboxU.plot(Cp[:,0], Cp[:,3], 'x', 'Cp', 'Cl = {0:.{3}f}, Cd = {1:.{3}f}, Cm = {2:.{3}f}'.format(solver.Cl, solver.Cd, solver.Cm, 4), True) # check results - print ccolors.ANSI_BLUE + 'PyTesting...' + ccolors.ANSI_RESET + print(ccolors.ANSI_BLUE + 'PyTesting...' + ccolors.ANSI_RESET) tests = CTests() if M_inf == 0: tests.add(CTest('min(Cp)', min(Cp[:,3]), -0.405, 5e-2)) @@ -121,7 +122,7 @@ def main(): tests.run() # eof - print '' + print('') if __name__ == "__main__": main() diff --git a/flow/validation/agard.py b/flow/validation/agard.py index b3da5f08bc4a235f8e35896288ebd2edc4686fe1..0d2480404ff8c8e20ad3ce3b00fa2ab2749933ad 100644 --- a/flow/validation/agard.py +++ b/flow/validation/agard.py @@ -19,6 +19,7 @@ # @brief Compute flow around the Agard445 wing at 1 degrees AOA and Mach 0.80 # @authors Adrien Crovato +from __future__ import print_function import numpy as np import flow as flo import flow.utils as floU @@ -65,7 +66,7 @@ def main(): fms = 1.0 # farfield mesh size # mesh the wing - print ccolors.ANSI_BLUE + 'PyMeshing...' + ccolors.ANSI_RESET + print(ccolors.ANSI_BLUE + 'PyMeshing...' + ccolors.ANSI_RESET) tms['msh'].start() pars = {'xL' : lgt, 'yL' : wdt, 'zL' : hgt, 'xO' : xO, 'zO' : zO, 'msLeRt' : rlems, 'msTeRt' : rtems, 'msLeTp' : tlems, 'msTeTp' : ttems, 'msF' : fms} msh = gmsh.MeshLoader("../models/agard445.geo",__file__).execute(**pars) @@ -93,7 +94,7 @@ def main(): tms['pre'].stop() # solve problem - print ccolors.ANSI_BLUE + 'PySolving...' + ccolors.ANSI_RESET + print(ccolors.ANSI_BLUE + 'PySolving...' + ccolors.ANSI_RESET) tms['solver'].start() solver = flo.Newton(pbl) floD.initNewton(solver) @@ -111,19 +112,19 @@ def main(): # display timers tms['total'].stop() - print ccolors.ANSI_BLUE + 'PyTiming...' + ccolors.ANSI_RESET - print 'CPU statistics' - print tms + print(ccolors.ANSI_BLUE + 'PyTiming...' + ccolors.ANSI_RESET) + print('CPU statistics') + print(tms) # check results - print ccolors.ANSI_BLUE + 'PyTesting...' + ccolors.ANSI_RESET + print(ccolors.ANSI_BLUE + 'PyTesting...' + ccolors.ANSI_RESET) tests = CTests() tests.add(CTest('CL', solver.Cl, 0.062, 1e-1)) tests.add(CTest('CD', solver.Cd, 0.0006, 1e-1)) tests.run() # eof - print '' + print('') if __name__ == "__main__": main() \ No newline at end of file diff --git a/flow/validation/onera.py b/flow/validation/onera.py index 4704b6c13cf6660390be75ab6ba0e6dc4adcdf6e..132a434e4dc725d1cd4dbe3b7782da3053e4bbf1 100644 --- a/flow/validation/onera.py +++ b/flow/validation/onera.py @@ -19,6 +19,7 @@ # @brief Compute flow around the Onera M6 wing at 3 degrees AOA and Mach 0.84 # @authors Adrien Crovato +from __future__ import print_function import numpy as np import flow as flo import flow.utils as floU @@ -63,7 +64,7 @@ def main(): ttems = 0.008 # tip trailing mesh size # mesh the wing - print ccolors.ANSI_BLUE + 'PyMeshing...' + ccolors.ANSI_RESET + print(ccolors.ANSI_BLUE + 'PyMeshing...' + ccolors.ANSI_RESET) tms['msh'].start() pars = {'lgt' : lgt, 'wdt' : wdt, 'hgt' : hgt, 'msLeRt' : rlems, 'msTeRt' : rtems, 'msLeTp' : tlems, 'msTeTp' : ttems, 'msF' : fms} msh = gmsh.MeshLoader("../models/oneraM6.geo",__file__).execute(**pars) @@ -91,7 +92,7 @@ def main(): tms['pre'].stop() # solve problem - print ccolors.ANSI_BLUE + 'PySolving...' + ccolors.ANSI_RESET + print(ccolors.ANSI_BLUE + 'PySolving...' + ccolors.ANSI_RESET) tms['solver'].start() solver = flo.Newton(pbl) floD.initNewton(solver) @@ -109,12 +110,12 @@ def main(): # display timers tms['total'].stop() - print ccolors.ANSI_BLUE + 'PyTiming...' + ccolors.ANSI_RESET - print 'CPU statistics' - print tms + print(ccolors.ANSI_BLUE + 'PyTiming...' + ccolors.ANSI_RESET) + print('CPU statistics') + print(tms) # check results - print ccolors.ANSI_BLUE + 'PyTesting...' + ccolors.ANSI_RESET + print(ccolors.ANSI_BLUE + 'PyTesting...' + ccolors.ANSI_RESET) tests = CTests() tests.add(CTest('CL', solver.Cl, 0.29, 1e-1)) tests.add(CTest('CD', solver.Cd, 0.011, 1e-1)) @@ -122,7 +123,7 @@ def main(): tests.run() # eof - print '' + print('') if __name__ == "__main__": main() diff --git a/flow/viscous/coupler.py b/flow/viscous/coupler.py index 7d2dfbac5fed1bd15492edc12fd70d0ce6cf7c34..7f699a3af361d47d833e97a5cb6d2d38117f2110 100644 --- a/flow/viscous/coupler.py +++ b/flow/viscous/coupler.py @@ -19,6 +19,7 @@ # @brief Viscous-inviscid coupler # @authors Adrien Crovato, Amaury Bilocq +from __future__ import print_function import numpy as np from fwk.coloring import ccolors @@ -37,7 +38,7 @@ class Coupler(): it = 0 converged = False # temp while True: - print ccolors.ANSI_BLUE + 'Iteration: ', it, ccolors.ANSI_RESET + print(ccolors.ANSI_BLUE + 'Iteration: ', it, ccolors.ANSI_RESET) # run inviscid solver self.isolver.run() # get velocity at edge of BL from inviscid solver and update viscous solver @@ -59,4 +60,4 @@ class Coupler(): # save results self.isolver.save(0, self.writer) - print '\n' + print('\n') diff --git a/flow/viscous/solver.py b/flow/viscous/solver.py index 5ab6aab0ba4169ee4f8c19cef8ef617907b33ab9..dc7378677e4cd5bc5cd60f6418d063a2a9868dc3 100644 --- a/flow/viscous/solver.py +++ b/flow/viscous/solver.py @@ -19,6 +19,7 @@ # @brief Boundary Layer Equations viscous solver # @authors Adrien Crovato, Amaury Bilocq +from __future__ import print_function import numpy as np class Solver(): @@ -35,7 +36,7 @@ class Solver(): def run(self): ''' Solve BLE ''' - print '--- I am a fake BL solver and I am setting dummy blowing velocities! ---' + print('--- I am a fake BL solver and I am setting dummy blowing velocities! ---') # 6th order fitting of delta_star for naca 0012 at alpha = 0, from XFoil a = 0.000054925976379640116 b = 0.007407077078697043 diff --git a/fwk/__init__.py b/fwk/__init__.py index a00ce2bd1d899dcd1bc8ca5d7e6ca5dce6996fd4..d5e6ab6955e58157920612b41781e7732bb9e3c9 100644 --- a/fwk/__init__.py +++ b/fwk/__init__.py @@ -1,7 +1,11 @@ # -*- coding: utf-8 -*- # fwk MODULE initialization file -import wutils +from __future__ import absolute_import +# -*- coding: utf-8 -*- +# fwk MODULE initialization file + +from . import wutils wutils.findbins('fwk') from fwkw import * diff --git a/fwk/testing.py b/fwk/testing.py index 1d4b30347f1a3c18a74d51431b11ed175fef0a7e..e4409501d5321e089d747bb9df103639acef8d50 100644 --- a/fwk/testing.py +++ b/fwk/testing.py @@ -17,7 +17,9 @@ # testing classes (for ctest) -from coloring import ccolors +from __future__ import print_function +from __future__ import absolute_import +from .coloring import ccolors class CTest: def __init__(self, name, val, expected, maxdiff=1e-10, refval=0.0, forceabs=False): @@ -46,8 +48,8 @@ class CTest: typ='abs' percent = '%f' % self.maxdiff - print "[CTest] %s = %f (expected %f +/- %s)" % \ - (self.name, self.val, self.expected, percent) + print("[CTest] %s = %f (expected %f +/- %s)" % \ + (self.name, self.val, self.expected, percent)) if diff<=self.maxdiff: sgn = '<=' @@ -56,7 +58,7 @@ class CTest: sgn = '>' ok = False info = "wrong!" - print "\t%s diff = %e %s %e [%s]" % (typ, diff, sgn, self.maxdiff, info) + print("\t%s diff = %e %s %e [%s]" % (typ, diff, sgn, self.maxdiff, info)) return ok class CTests: diff --git a/fwk/tests/timers.py b/fwk/tests/timers.py index 48ef7217221c4759a30c987186554f604d0b96b0..8f11e46e0c8d3db96561ce239f97e043e93ba664 100644 --- a/fwk/tests/timers.py +++ b/fwk/tests/timers.py @@ -17,48 +17,49 @@ # basic test of timers +from __future__ import print_function import fwk from time import sleep delay = 0.2 -print '-'*79 -print "Timer - a simple Timer" -print '-'*79 +print('-'*79) +print("Timer - a simple Timer") +print('-'*79) timer = fwk.Timer() timer.start() for i in range(3): sleep(delay) - print timer + print(timer) timer.stop() sleep(delay) -print timer +print(timer) -print '-'*79 -print "Times - a cpu time (usr, real, kernel)" -print '-'*79 +print('-'*79) +print("Times - a cpu time (usr, real, kernel)") +print('-'*79) times = timer.read() -print "it lasted %f secs" % times.getReal().sec() -print "CPU time = %f secs" % times.getUser().sec() +print("it lasted %f secs" % times.getReal().sec()) +print("CPU time = %f secs" % times.getUser().sec()) -print "once again..." +print("once again...") #print "it lasted %f secs" % timer.read().getReal().sec() # plante car retour de read() desalloue lors de sec(). #print "CPU time = %f secs" % timer.read().getUser().sec() -print '-'*79 -print "HMSTime - conversion from sec to HMS" -print '-'*79 +print('-'*79) +print("HMSTime - conversion from sec to HMS") +print('-'*79) nsec = 100000 -print "%s secs equals to %s" % (nsec, fwk.HMSTime(nsec)) +print("%s secs equals to %s" % (nsec, fwk.HMSTime(nsec))) -print '-'*79 -print "Timers - list of Timers" -print '-'*79 +print('-'*79) +print("Timers - list of Timers") +print('-'*79) timers = fwk.Timers() timers['cpu1'].start() @@ -67,5 +68,5 @@ timers['cpu2'].start() sleep(delay) timers['cpu3'].start() sleep(delay) -print timers +print(timers) diff --git a/fwk/wutils.py b/fwk/wutils.py index 204a9e8de340ab406220b6baf39793cd1f4f62f1..2ecb7df3c281889ac0309950301ad1efaddde050 100644 --- a/fwk/wutils.py +++ b/fwk/wutils.py @@ -17,6 +17,7 @@ # Python utilities +from __future__ import print_function try: # permet d'importer les .so de mkl à partir d'un module python import sys,DLFCN sys.setdlopenflags(DLFCN.RTLD_NOW|DLFCN.RTLD_GLOBAL) @@ -37,12 +38,12 @@ def findbins(modname, dirB=['build','wavesB'], verb=False): # changer wavesB en try: __import__(modwrap) #import fwkw if verb: - print "[findbins] module %s already in the PYTHONPATH!" % modwrap + print("[findbins] module %s already in the PYTHONPATH!" % modwrap) return # nothing to do except: pass if verb: - print "[findbins] module %s is not in the PYTHONPATH!" % modwrap + print("[findbins] module %s is not in the PYTHONPATH!" % modwrap) # the module is not in the pythonpath # let's look for a folder called "dirB" in parent directories @@ -54,13 +55,13 @@ def findbins(modname, dirB=['build','wavesB'], verb=False): # changer wavesB en for dir in dirB: spath = os.path.join(path,dir) if verb: - print "[findbins] path = ", path - print "[findbins] spath = ", spath - print "[findbins] os.path.isdir(spath) = ", os.path.isdir(spath) + print("[findbins] path = ", path) + print("[findbins] spath = ", spath) + print("[findbins] os.path.isdir(spath) = ", os.path.isdir(spath)) if(os.path.isdir(spath)): found = True if verb: - print "[findbins] break with ",dir + print("[findbins] break with ",dir) break uppath = os.path.split(path)[0] if(path==uppath): @@ -70,7 +71,7 @@ def findbins(modname, dirB=['build','wavesB'], verb=False): # changer wavesB en if found == True : # to break the while ... break if verb: - print "[findbins] spath=", spath + print("[findbins] spath=", spath) # build a list of possible directories (libpath) @@ -78,32 +79,32 @@ def findbins(modname, dirB=['build','wavesB'], verb=False): # changer wavesB en pyexe = os.path.basename(sys.executable) if verb: - print "[findbins] pyexe=", pyexe + print("[findbins] pyexe=", pyexe) libpath = [] if pyexe.find('_d.exe')>=0: - print "[findbins] looking for win/debug libs" + print("[findbins] looking for win/debug libs") libpath.append(os.path.join(spath, 'bin/Debug'.replace('/',os.sep))) if 'GCC' in sys.version: # windows+gcc = mingw => needs to append lib dir to PATH os.environ['PATH'] += ';' + os.path.join(spath, 'bin') elif pyexe.find('.exe')>=0: - print "[findbins] looking for win/release libs" + print("[findbins] looking for win/release libs") libpath.append(os.path.join(spath, 'bin/Release'.replace('/',os.sep))) libpath.append(os.path.join(spath, 'bin/RelWithDebInfo'.replace('/',os.sep))) if 'GCC' in sys.version: # windows+gcc = mingw => needs to append lib dir to PATH os.environ['PATH'] += ';' + os.path.join(spath, 'bin') else: - print "[findbins] looking for linux/mingw libs" + print("[findbins] looking for linux/mingw libs") libpath.append( os.path.join(spath, 'bin') ) # also for win-mingw # check the paths one by one for p in libpath: if os.path.isdir(p): if verb: - print "[findbins] adding %s to sys.path" % p + print("[findbins] adding %s to sys.path" % p) sys.path.append(p) if verb: - print "[findbins] sys.path =", sys.path + print("[findbins] sys.path =", sys.path) break else: raise Exception("[findbins] '%s' not found!" % libpath) @@ -111,7 +112,7 @@ def findbins(modname, dirB=['build','wavesB'], verb=False): # changer wavesB en #exec("import %s" % modwrap) #mod = sys.modules[modwrap] mod = __import__(modwrap) - print '[findbins] loading ', mod.__file__ + print('[findbins] loading ', mod.__file__) # initialisations initMKL(1) @@ -140,10 +141,10 @@ def initMKL(nthreads): os.environ['OMP_DYNAMIC'] = 'FALSE' # display variables for s in ['OMP_', 'MKL', 'KMP']: - print '* %s environment:' % s + print('* %s environment:' % s) for key, value in os.environ.iteritems(): if s in key: - print '\t%s = %s' % (key, value) + print('\t%s = %s' % (key, value)) # ------------------------------------------------------------------------------ @@ -169,8 +170,8 @@ def setupwdir(testname): # builds the name of the workspace folder #print "__file__=",__file__ dir1=os.path.abspath(os.path.dirname(__file__)+os.sep+"..")+os.sep - print "dir1=",dir1 - print "testname=",testname + print("dir1=",dir1) + print("testname=",testname) common = os.path.commonprefix( (testname, dir1) ) #print "common=", common resdir = testname[len(common):].replace(os.sep,"_") @@ -182,10 +183,10 @@ def setupwdir(testname): # rank0 is in charge of creating the folder... args = parseargs() if not os.path.isdir(wdir): - print "creating", wdir + print("creating", wdir) os.makedirs(wdir) elif os.path.isdir(wdir) and args.clean: - print 'cleaning', wdir + print('cleaning', wdir) import shutil for f in os.listdir(wdir): fpth = os.path.join(wdir, f) diff --git a/heat/broken/heat_multiscale.py b/heat/broken/heat_multiscale.py index 5afac095d768b7724cb042b713c9bff2993a2ef8..6750cfab98a5c86b315341f6ec042f8b31b37cb1 100755 --- a/heat/broken/heat_multiscale.py +++ b/heat/broken/heat_multiscale.py @@ -2,6 +2,7 @@ # -*- coding: utf-8 -*- # 1er test multiscale (sans MPI) +from __future__ import print_function import heat as h import tbox import tbox.gmsh as gmsh @@ -10,7 +11,7 @@ import math class MicroModel(tbox.Fct2UdU): def __init__(self): tbox.Fct2UdU.__init__(self) - print "[m] creation of the micro model" + print("[m] creation of the micro model") self.msh = gmsh.MeshLoader("heat_ms_micro.geo", __file__).execute() self.pbl = h.Problem(self.msh) @@ -38,11 +39,11 @@ class MicroModel(tbox.Fct2UdU): dTnorm=math.sqrt(dTxM*dTxM+dTyM*dTyM) if verb: - print "-"*10 - print "**solving micro problem..." - print "[m] TM =",TM - print "[m] dTxM =",dTxM - print "[m] dTyM =",dTyM + print("-"*10) + print("**solving micro problem...") + print("[m] TM =",TM) + print("[m] dTxM =",dTxM) + print("[m] dTyM =",dTyM) #if dTxM==0: dTxM=1e-5 #if dTyM==0: dTyM=1e-5 @@ -54,8 +55,8 @@ class MicroModel(tbox.Fct2UdU): qMy = self.p.qM.x[1] if verb: - print "[m] qMx =", qMx - print "[m] qMy =", qMy + print("[m] qMx =", qMx) + print("[m] qMy =", qMy) dTnorm = math.sqrt(dTxM*dTxM+dTyM*dTyM) qnorm = math.sqrt(qMx*qMx+qMy*qMy) @@ -67,7 +68,7 @@ class MicroModel(tbox.Fct2UdU): #print ps ang = math.acos(ps) - print "ang=", ang, "ampl=", ampl + print("ang=", ang, "ampl=", ampl) #print "qMx=", qMx, "ampl*dT=", dTxM*ampl, "res=", qMx-dTxM*ampl cos = math.cos(ang) sin = math.sin(ang) @@ -82,7 +83,7 @@ class MicroModel(tbox.Fct2UdU): k[0,1]=K12 if verb: - print k + print(k) def main(): diff --git a/heat/broken/honeycomb_jalil.py b/heat/broken/honeycomb_jalil.py index 06a6c8d8fc48b5d1b8c40a75b0c10461cdb85c04..8cda4d5db66e9bcc8ad2fa79f9348d17db948f91 100755 --- a/heat/broken/honeycomb_jalil.py +++ b/heat/broken/honeycomb_jalil.py @@ -2,6 +2,7 @@ # -*- coding: utf-8 -*- # test periodic BCs +from __future__ import print_function import heat as h import tbox import tbox.gmsh as gmsh @@ -45,7 +46,7 @@ def main(): solver.restol = 1e-6 solver.start() - print "mean flux=", p.qM + print("mean flux=", p.qM) from heat.viewer import GUI GUI().open('honeycomb_jalil') diff --git a/heat/broken/jalil1.py b/heat/broken/jalil1.py index 020fd3aa2a4558f46ab6a3b4b547e6efee01a665..04b068f3e0ef942de08f013f20458bb961eed84e 100755 --- a/heat/broken/jalil1.py +++ b/heat/broken/jalil1.py @@ -4,6 +4,7 @@ # exc: mpiexec.openmpi -n 12 ./jalil1.py +from __future__ import print_function import heat as h import tbox import tbox.gmsh as gmsh @@ -37,7 +38,7 @@ class Job: class MicroModel(tbox.Fct2UdU): def __init__(self): tbox.Fct2UdU.__init__(self) - print "[m] creation of the micro model" + print("[m] creation of the micro model") self.msh = gmsh.MeshLoader("jalil1_micro.geo", __file__).execute() self.pbl = h.Problem(self.msh) @@ -70,8 +71,8 @@ class MicroModel(tbox.Fct2UdU): qMy = self.p.qM.x[1] if self.verb: - print "[m] qMx =", qMx - print "[m] qMy =", qMy + print("[m] qMx =", qMx) + print("[m] qMy =", qMy) # convert flux to an anisotropic conductivity "k(2,2)" dTnorm=math.sqrt(dTxM*dTxM+dTyM*dTyM) @@ -105,9 +106,9 @@ class MicroModel(tbox.Fct2UdU): dTnorm=math.sqrt(dTxM*dTxM+dTyM*dTyM) if self.verb: - print "[m] TM =",TM - print "[m] dTxM =",dTxM - print "[m] dTyM =",dTyM + print("[m] TM =",TM) + print("[m] dTxM =",dTxM) + print("[m] dTyM =",dTyM) if self.ijob==0: job = Job(TM, dTxM, dTyM) @@ -170,7 +171,7 @@ class MicroModel(tbox.Fct2UdU): if i==njobs: break job = self.jobs[i] jlist.append( (job,s) ) - if self.verb: print "[%d] sending job #%d to %s.." % (rank,i,s) + if self.verb: print("[%d] sending job #%d to %s.." % (rank,i,s)) comm.send(job, dest = s) i+=1 @@ -179,9 +180,9 @@ class MicroModel(tbox.Fct2UdU): #receive jobs for (job,s) in jlist: - if self.verb: print "[%d] waiting job from %d.." % (rank,s) + if self.verb: print("[%d] waiting job from %d.." % (rank,s)) job2 = comm.recv(source = s) - if self.verb: print "[%d] job received from %d!" % (rank,s) + if self.verb: print("[%d] job received from %d!" % (rank,s)) job.K11=job2.K11 job.K22=job2.K22 job.K12=job2.K12 @@ -193,7 +194,7 @@ def main(): myk = MicroModel() # chaque process a son objet "modèle micro" (distinct) if rank==0: - if myk.verb: print "[%d] démarrage du modèle macro" % rank + if myk.verb: print("[%d] démarrage du modèle macro" % rank) msh = gmsh.MeshLoader("jalil1_corner.geo", __file__).execute() pbl = h.Problem(msh) @@ -212,7 +213,7 @@ def main(): slaves=range(1,siz) for s in slaves: job=Job(0,0,0); job.killme=True - if myk.verb: print "[%d] sending suicide job to %d" % (rank,s) + if myk.verb: print("[%d] sending suicide job to %d" % (rank,s)) comm.send(job, dest = s) from heat.viewer import GUI @@ -220,23 +221,23 @@ def main(): else: myk.verb=False - if myk.verb: print "[%d] démarrage d'un modèle micro" % rank + if myk.verb: print("[%d] démarrage d'un modèle micro" % rank) while True: # attend un gradient et cree un job - if myk.verb: print "[%d] waiting job from 0.." % rank + if myk.verb: print("[%d] waiting job from 0.." % rank) job = comm.recv(source = 0) # recoit un job if job.killme: - if myk.verb: print "[%d] Aaargl!" % rank + if myk.verb: print("[%d] Aaargl!" % rank) break - if myk.verb: print "[%d] job received from 0!" % rank + if myk.verb: print("[%d] job received from 0!" % rank) myk.execute(job) # execute le job - if myk.verb: print "[%d] sending job to 0.." % rank + if myk.verb: print("[%d] sending job to 0.." % rank) comm.send(job, dest = 0) # envoie le resultat - if myk.verb: print "[%d] job sent to 0.." % rank + if myk.verb: print("[%d] job sent to 0.." % rank) if __name__ == "__main__": main() - print "[%d] end." % rank + print("[%d] end." % rank) diff --git a/heat/broken/jalil1_micro.py b/heat/broken/jalil1_micro.py index e5e75a93b734ba35b35f01740336c593496f6771..41e774cf7ef848a36a49d7dba02371c9d6859207 100755 --- a/heat/broken/jalil1_micro.py +++ b/heat/broken/jalil1_micro.py @@ -2,6 +2,7 @@ # -*- coding: utf-8 -*- # simple RVE with 2 materials for testing periodic BCs +from __future__ import print_function import heat as h import tbox import tbox.gmsh as gmsh @@ -24,7 +25,7 @@ def main(): p = h.Periodic(pbl, TM, dTxM, dTyM) solver.start() - print "flux=", p.qM + print("flux=", p.qM) from heat.viewer import GUI GUI().open('jalil1_micro') diff --git a/heat/broken/jalil2.py b/heat/broken/jalil2.py index 547bfdae95031b3b67c15fc71c5ebf8999836609..fc86dbe20df6275306adb1408ffd9ad237f8a0da 100755 --- a/heat/broken/jalil2.py +++ b/heat/broken/jalil2.py @@ -5,6 +5,7 @@ # mpiexec.openmpi --bycore --bind-to-core -n 6 ./run.py heat/tests/jalil2.py +from __future__ import print_function import heat as h import tbox import tbox.gmsh as gmsh @@ -16,13 +17,13 @@ try: rank = comm.rank siz = comm.size name = mpi.Get_processor_name() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") class Job: """ Class containing data transmitted between MPI procs @@ -48,7 +49,7 @@ class MicroModel(tbox.Fct2UdU): creation du micro modele """ tbox.Fct2UdU.__init__(self) - print "[m] creation of the micro model" + print("[m] creation of the micro model") self.msh = gmsh.MeshLoader("jalil2_honey.geo", __file__).execute() self.pbl = h.Problem(self.msh) @@ -102,8 +103,8 @@ class MicroModel(tbox.Fct2UdU): qMy = self.p.qM.x[1] if self.verb: - print "[m] qMx =", qMx - print "[m] qMy =", qMy + print("[m] qMx =", qMx) + print("[m] qMy =", qMy) # convert flux to an anisotropic conductivity "k(2,2)" dTnorm=math.sqrt(dTxM*dTxM+dTyM*dTyM) @@ -137,9 +138,9 @@ class MicroModel(tbox.Fct2UdU): dTnorm=math.sqrt(dTxM*dTxM+dTyM*dTyM) if self.verb: - print "[m] TM =",TM - print "[m] dTxM =",dTxM - print "[m] dTyM =",dTyM + print("[m] TM =",TM) + print("[m] dTxM =",dTxM) + print("[m] dTyM =",dTyM) job = self.jbz.get((elem.no,npg)) if job: # job existe deja, on le modifie @@ -155,7 +156,7 @@ class MicroModel(tbox.Fct2UdU): job = self.jbz.get((elem.no,npg)) if not job: - print "[m] job", (elem.no,npg), "not found!" + print("[m] job", (elem.no,npg), "not found!") #else: # print "[m] job", (elem.no,npg), "OK!" k[0,0]=job.K11 @@ -184,13 +185,13 @@ class MicroModel(tbox.Fct2UdU): jlist=[] for s in slaves: try: - jobk = it.next() # get next job + jobk = next(it) # get next job except: break job = self.jbz[jobk] jlist.append( (job,s) ) if self.verb: - print "[%d] sending job %s to %s.." % (rank,jobk,s) + print("[%d] sending job %s to %s.." % (rank,jobk,s)) comm.send(job, dest = s) if not jlist: # plus de job? @@ -198,9 +199,9 @@ class MicroModel(tbox.Fct2UdU): #receive jobs for (job,s) in jlist: - if self.verb: print "[%d] waiting job from %d.." % (rank,s) + if self.verb: print("[%d] waiting job from %d.." % (rank,s)) job2 = comm.recv(source = s) - if self.verb: print "[%d] job received from %d!" % (rank,s) + if self.verb: print("[%d] job received from %d!" % (rank,s)) job.K11=job2.K11 job.K22=job2.K22 job.K12=job2.K12 @@ -214,7 +215,7 @@ def main(): # faire en sorte que le rank0 charge le micro en 1er if rank==0: - if myk.verb: print "[%d] démarrage du modèle macro" % rank + if myk.verb: print("[%d] démarrage du modèle macro" % rank) msh = gmsh.MeshLoader("jalil1_corner.geo", __file__).execute() pbl = h.Problem(msh) @@ -233,7 +234,7 @@ def main(): slaves=range(1,siz) for s in slaves: job=Job((0,0),0,0,0); job.killme=True - if myk.verb: print "[%d] sending suicide job to %d" % (rank,s) + if myk.verb: print("[%d] sending suicide job to %d" % (rank,s)) comm.send(job, dest = s) from heat.viewer import GUI @@ -241,24 +242,24 @@ def main(): else: myk.verb=False - if myk.verb: print "[%d] démarrage d'un modèle micro" % rank + if myk.verb: print("[%d] démarrage d'un modèle micro" % rank) while True: # attend un gradient et cree un job - if myk.verb: print "[%d] waiting for job from 0.." % rank + if myk.verb: print("[%d] waiting for job from 0.." % rank) job = comm.recv(source = 0) # recoit un job if job.killme: - if myk.verb: print "[%d] Aaargl!" % rank + if myk.verb: print("[%d] Aaargl!" % rank) break - if myk.verb: print "[%d] job received from 0!" % rank + if myk.verb: print("[%d] job received from 0!" % rank) myk.execute(job) # execute le job - if myk.verb: print "[%d] sending job results to 0.." % rank + if myk.verb: print("[%d] sending job results to 0.." % rank) comm.send(job, dest = 0) # envoie le resultat - if myk.verb: print "[%d] job results sent to 0.." % rank + if myk.verb: print("[%d] job results sent to 0.." % rank) if __name__ == "__main__": main() - print "[%d] end." % rank + print("[%d] end." % rank) diff --git a/heat/broken/jalil2_honey.py b/heat/broken/jalil2_honey.py index 13daa4d2e079f8d67f7c7e6ed11134d780f72275..2fc2d910cae0ee54f1defb868395a1bfe22e9851 100755 --- a/heat/broken/jalil2_honey.py +++ b/heat/broken/jalil2_honey.py @@ -2,6 +2,7 @@ # -*- coding: utf-8 -*- # simple RVE with 2 materials for testing periodic BCs +from __future__ import print_function import heat as h import tbox import tbox.gmsh as gmsh @@ -45,7 +46,7 @@ def main(): p= h.Periodic(pbl, TM, dTxM, dTyM) solver.start() - print "flux=", p.qM + print("flux=", p.qM) from heat.viewer import GUI GUI().open('jalil2_honey') diff --git a/heat/fe2.py b/heat/fe2.py index 505ea048d7fbdbe3e00b476027993f48b81e7ba2..be8b60f4f72f2cf3da0446e063e3fd1fe7976dd3 100755 --- a/heat/fe2.py +++ b/heat/fe2.py @@ -18,6 +18,7 @@ # FE² for "heat" - version "MPI task pull" +from __future__ import print_function import heat as h import tbox import math @@ -31,13 +32,13 @@ try: siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") def barrier(): if comm: @@ -83,8 +84,8 @@ class Job: qMy = fem.p.qM.x[1] if verb: - print "[%d] qMx = %f" % (rank,qMx) - print "[%d] qMy = %f" % (rank,qMy) + print("[%d] qMx = %f" % (rank,qMx)) + print("[%d] qMy = %f" % (rank,qMy)) # convert flux to an anisotropic conductivity "k(2,2)" dTnorm = math.sqrt(dTxM*dTxM+dTyM*dTyM) @@ -122,7 +123,7 @@ class FE2(tbox.Fct2UdU): self.fem = femicro # micro model (utile uniqt si 1 thread) self.jbz = {} # list of jobs - if verb: print "[%d] creation of the micro model" % rank + if verb: print("[%d] creation of the micro model" % rank) def eval(self, elem, npg, u, gradu, k, fake): # tjs exécuté par rank#0 """ @@ -142,9 +143,9 @@ class FE2(tbox.Fct2UdU): dTnorm=math.sqrt(dTxM*dTxM+dTyM*dTyM) if verb: - print "[m] TM =",TM - print "[m] dTxM =",dTxM - print "[m] dTyM =",dTyM + print("[m] TM =",TM) + print("[m] dTxM =",dTxM) + print("[m] dTyM =",dTyM) job = self.jbz.get((elem.no,npg)) if job: # job existe deja, on le modifie @@ -159,7 +160,7 @@ class FE2(tbox.Fct2UdU): job = self.jbz.get((elem.no,npg)) if not job: - print "[m] job", (elem.no,npg), "not found!" + print("[m] job", (elem.no,npg), "not found!") k[0,0] = job.K11 k[1,1] = job.K22 k[1,0] = job.K21 @@ -170,7 +171,7 @@ class FE2(tbox.Fct2UdU): import sys sys.stdout.flush() - if verb: print "[0] looping on %d jobs" % len(self.jbz) + if verb: print("[0] looping on %d jobs" % len(self.jbz)) # version 1 proc (master works alone) if siz==1: @@ -185,7 +186,7 @@ class FE2(tbox.Fct2UdU): slaves=range(1,siz) for s in slaves: - if verb: print "[0] sending wake-up signal to worker", s + if verb: print("[0] sending wake-up signal to worker", s) comm.send(None, dest=s, tag=tags.WAKEUP) num_workers = siz-1 @@ -197,24 +198,24 @@ class FE2(tbox.Fct2UdU): source = status.Get_source() tag = status.Get_tag() if tag == tags.READY: - if verb: print "[0] worker %d is ready" % source + if verb: print("[0] worker %d is ready" % source) # worker is ready - send a new task job = None try: - jobk = it.next() # get next job + jobk = next(it) # get next job job = self.jbz[jobk] except: pass if job: - if verb: print "[0] sending job to %d" % source + if verb: print("[0] sending job to %d" % source) comm.send(job, dest=source, tag=tags.START) else: - if verb: print "[0] job list is empty! sending EXIT to %d" % source + if verb: print("[0] job list is empty! sending EXIT to %d" % source) comm.send(None, dest=source, tag=tags.EXIT) # other workers are still calculating... # master should wait for them elif tag==tags.DONE: - if verb: print "[0] worker %d gives me its results" % source + if verb: print("[0] worker %d gives me its results" % source) # worker has done its job - get the results job = self.jbz[data.id] job.K11=data.K11 @@ -223,9 +224,9 @@ class FE2(tbox.Fct2UdU): job.K21=data.K21 elif tag==tags.EXIT: closed_workers+=1 - if verb: print "[0] worker %d exited (%d worker(s) still running)" % (source, num_workers-closed_workers) + if verb: print("[0] worker %d exited (%d worker(s) still running)" % (source, num_workers-closed_workers)) - if verb: print "[0] done." + if verb: print("[0] done.") class Master: """ @@ -241,7 +242,7 @@ class Master: global rank if rank!=0: raise Exception("this routine should be called with MPI rank=0") - if verb: print "[%d] starting master" % rank + if verb: print("[%d] starting master" % rank) self.macro.solver.start(self.macro.gmshWriter) self.killslaves() @@ -250,14 +251,14 @@ class Master: from fwk.wutils import parseargs args = parseargs() if not args.nogui: - print "\n<CLOSE gmsh to quit!>" + print("\n<CLOSE gmsh to quit!>") from heat.viewer import GUI GUI().open(self.macro.msh.name) def killslaves(self): slaves=range(1,siz) for s in slaves: - if verb: print "[%d] sending suicide job to %d" % (rank,s) + if verb: print("[%d] sending suicide job to %d" % (rank,s)) comm.send(None, dest=s, tag=tags.SUICIDE) @@ -276,29 +277,29 @@ class Worker: if rank==0: raise Exception("this routine should be called with MPI rank!=0") - if verb: print "[%d] starting worker" % rank + if verb: print("[%d] starting worker" % rank) while True: comm.recv(source=0, tag=mpi.ANY_TAG, status=status) tag = status.Get_tag() if tag==tags.WAKEUP: - if verb: print "[%d] waking up" % rank + if verb: print("[%d] waking up" % rank) while True: comm.send(None, dest=0, tag=tags.READY) job = comm.recv(source=0, tag=mpi.ANY_TAG, status=status) tag = status.Get_tag() if tag==tags.START: - if verb: print "[%d] starting job" % rank + if verb: print("[%d] starting job" % rank) job.execute(self.micro) - if verb: print "[%d] sending job results" % rank + if verb: print("[%d] sending job results" % rank) comm.send(job, dest=0, tag=tags.DONE) elif tag==tags.EXIT: - if verb: print "[%d] sending exit confirmation" % rank + if verb: print("[%d] sending exit confirmation" % rank) comm.send(None, dest=0, tag=tags.EXIT) break elif tag==tags.SUICIDE: - if verb: print "[%d] I'm dying..." % rank + if verb: print("[%d] I'm dying..." % rank) if rank==2: - print self.micro.solver.tms + print(self.micro.solver.tms) break diff --git a/heat/tests/periodic/lincomb.py b/heat/tests/periodic/lincomb.py index 5bb48c537ac53f5f7c9c0b6557707fe48c773b9c..6f3f00c0f4fa58c10799a6e02b4de8cfd5258ead 100755 --- a/heat/tests/periodic/lincomb.py +++ b/heat/tests/periodic/lincomb.py @@ -20,6 +20,7 @@ # from the linear combination of 2 calculations (2 perpendicular gradients) # then, checks if the resulting flux is the same as a direct calculation +from __future__ import print_function import heat as h import heat.utils as u import tbox @@ -82,8 +83,8 @@ def main(): dTyM0 = 0.2 q1i,q2i = solve(TM0, dTxM0, dTyM0) - print "flux along x dir = ", q1i - print "flux along y dir = ", q2i + print("flux along x dir = ", q1i) + print("flux along y dir = ", q2i) # ------------- linear combination ---------------- @@ -94,8 +95,8 @@ def main(): dTyM = 0.0 K11,K21 = solve(TM, dTxM, dTyM) - print "flux along x dir = ", K11 - print "flux along y dir = ", K21 + print("flux along x dir = ", K11) + print("flux along y dir = ", K21) # ------------------------------------------------- @@ -104,8 +105,8 @@ def main(): dTyM = 1.0 # <= gradY =1 K12,K22 = solve(TM, dTxM, dTyM) - print "flux along x dir = ", K12 - print "flux along y dir = ", K22 + print("flux along x dir = ", K12) + print("flux along y dir = ", K22) # ------------------------------------------------- # try to calculate the first flux @@ -115,13 +116,13 @@ def main(): q1 = K11*dTxM0 + K12*dTyM0 q2 = K21*dTxM0 + K22*dTyM0 - print - print "K=[[", K11, ",", K12,"]" - print " [", K21, ",", K22,"]]\n" + print() + print("K=[[", K11, ",", K12,"]") + print(" [", K21, ",", K22,"]]\n") - print "q (linear combination) =",q1,q2 - print "qi (direct calculation) =",q1i,q2i - print chrono + print("q (linear combination) =",q1,q2) + print("qi (direct calculation) =",q1i,q2i) + print(chrono) tests = CTests() tests.add(CTest('q-qi (x)', abs(q1-q1i), 0.0, 1e-6)) diff --git a/heat/tests/periodic/lincomb_fast.py b/heat/tests/periodic/lincomb_fast.py index a6f64fb0265b66432a2eda88675cd6b1ebb54374..840d02d546e4196bca083b1f978fcb437724557a 100755 --- a/heat/tests/periodic/lincomb_fast.py +++ b/heat/tests/periodic/lincomb_fast.py @@ -18,6 +18,7 @@ # A NETTOYER +from __future__ import print_function import heat as h import heat.utils as u import tbox @@ -94,14 +95,14 @@ def main(): q1 = K11*dTxM+K12*dTyM q2 = K21*dTxM+K22*dTyM - print - print "K=[[", -K11, ",", -K12,"]" - print " [", -K21, ",", -K22,"]]" - print "q =", q1, q2 - print "qi =", q1i, q2i - print + print() + print("K=[[", -K11, ",", -K12,"]") + print(" [", -K21, ",", -K22,"]]") + print("q =", q1, q2) + print("qi =", q1i, q2i) + print() chrono.stop() - print chrono + print(chrono) tests = CTests() tests.add(CTest('q-qi (x)', abs(q1-q1i), 0.0, 1e-6)) diff --git a/mirrors/attic/loop_old.py b/mirrors/attic/loop_old.py index ab1bb36a3530569dedffd4338f32d69bfcbe7659..52c2d027e806a369720f6e00ed6c8d91ecb651f0 100755 --- a/mirrors/attic/loop_old.py +++ b/mirrors/attic/loop_old.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- +from __future__ import print_function import numpy as np import time from params.src.func import grid @@ -56,9 +57,9 @@ if __name__ == "__main__": f.write('Sigma_vm_max = ' + str(Sol[i]) + '.\n') f.write('====================\n') - print >>f,w - print >>f,t - print >>f,Sol + print(w, file=f) + print(t, file=f) + print(Sol, file=f) date2 = time.strftime("%d/%m/%Y") hour2 = time.strftime("%H:%M:%S") diff --git a/mirrors/attic/loop_old2.py b/mirrors/attic/loop_old2.py index 0bdde342ac341002e1bc6c137d12cf5d3beff519..cbbab9770939de69b81d68d867e6c74d7f87a441 100755 --- a/mirrors/attic/loop_old2.py +++ b/mirrors/attic/loop_old2.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- +from __future__ import print_function import numpy as np import time @@ -75,8 +76,8 @@ def main(): X, W = grid(M) - print M - print X + print(M) + print(X) m_max = 1 n_max = 1 @@ -84,8 +85,8 @@ def main(): m_max = m_max*M[j] n_max = n_max*N[j] - print m_max - print n_max + print(m_max) + print(n_max) i = np.zeros((d,), dtype =np.int) i_zero = np.zeros((d,), dtype =np.int) @@ -172,7 +173,7 @@ def main(): for j in range(0,n_max): s_hat = s_hat + np.dot(np.transpose(U[:,j]),np.dot(W_sr,sol))*V[:,j]/S[j,j] - print s_hat + print(s_hat) #------------------ diff --git a/mirrors/broken/NISP_Leg_cond.py b/mirrors/broken/NISP_Leg_cond.py index 97c6a1e1dc86a367ab3c175077c45cd7e02c9bbb..9e81374044d9a28d6e735f5c3c039a9dd2058226 100755 --- a/mirrors/broken/NISP_Leg_cond.py +++ b/mirrors/broken/NISP_Leg_cond.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- +from __future__ import print_function import numpy as np import time import os @@ -35,7 +36,7 @@ def main(): ax.set_xlabel('d [-]') ax.set_ylabel('n [-]') #ax.set_zscale('log') - print cond + print(cond) plt.show() if __name__ == "__main__": diff --git a/mirrors/broken/mirrors01.py b/mirrors/broken/mirrors01.py index cca3d094f452cba36c3f7f6bd64b07bb3e66c522..772001a70e850501cde10287e7d6a6ad8ee7d190 100755 --- a/mirrors/broken/mirrors01.py +++ b/mirrors/broken/mirrors01.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- +from __future__ import print_function import mirrors as m import tbox import tbox.gmsh as gmsh @@ -8,7 +9,7 @@ import fwk.wutils as wu from fwk.coloring import ccolors def main(): - print ccolors.ANSI_RED + "mirrors01_ansys.msh contains inverted Tri3 elements. Test will fail!" + ccolors.ANSI_RESET + print(ccolors.ANSI_RED + "mirrors01_ansys.msh contains inverted Tri3 elements. Test will fail!" + ccolors.ANSI_RESET) loader = gmsh.MeshLoader("mirrors01_ansys.msh",__file__) msh = loader.execute() #print msh @@ -58,8 +59,8 @@ def main(): solver.start() for i in range(0,len(pbl.ANSYSSol)): - print pbl.ANSYSSol[i].diff_abs - print pbl.ANSYSSol[i].diff_rel + print(pbl.ANSYSSol[i].diff_abs) + print(pbl.ANSYSSol[i].diff_rel) if not args.nogui: from mirrors.viewer import GUI diff --git a/mirrors/broken/mirrors_test_battery.py b/mirrors/broken/mirrors_test_battery.py index 927149b96aeabb1bb4d9a4fc92cca8f4927e5d4d..a5e7e9dc2baae328376f2873d7ea921c480b58cf 100755 --- a/mirrors/broken/mirrors_test_battery.py +++ b/mirrors/broken/mirrors_test_battery.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- +from __future__ import print_function import time import mirrors as m import tbox @@ -10,7 +11,7 @@ from fwk.coloring import ccolors def main(): - print ccolors.ANSI_RED + "One of the meshes contains inverted Tri3 elements. Test will fail!" + ccolors.ANSI_RESET + print(ccolors.ANSI_RED + "One of the meshes contains inverted Tri3 elements. Test will fail!" + ccolors.ANSI_RESET) pbl_vector = [] @@ -156,24 +157,24 @@ def main(): if print_mesh_info == 1: f.write('Mesh informations:\n') - print >> f, pbl_vector[i].msh + print(pbl_vector[i].msh, file=f) f.write('~ ~ ~ ~ ~ ~ ~\n') if print_problem_info == 1: f.write('Problem informations:\n') - print >> f, pbl_vector[i] + print(pbl_vector[i], file=f) f.write('~ ~ ~ ~ ~ ~ ~\n') solver = m.Solver(pbl_vector[i],nb_of_process) if print_solver_info == 1: f.write('Solver informations:\n') - print >> f, solver + print(solver, file=f) f.write('~ ~ ~ ~ ~ ~ ~\n') solver.start() if print_tms == 1: - print >> f, solver.tms + print(solver.tms, file=f) f.write('~ ~ ~ ~ ~ ~ ~\n') if print_diff ==1: diff --git a/mirrors/figs/LSP.py b/mirrors/figs/LSP.py index 8cfad38a90d56fc765f7258c33a1e44974231943..56ee72cc372afdade86b39b7e2918b8b1a866c7b 100755 --- a/mirrors/figs/LSP.py +++ b/mirrors/figs/LSP.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- +from __future__ import print_function import numpy as np import matplotlib.pyplot as plt @@ -25,8 +26,8 @@ def main(): plt.xlabel('i') plt.ylabel('sigma_i') - print V.shape - print Z.shape + print(V.shape) + print(Z.shape) plt.subplot(1,3,3) ZV = np.dot(Z,np.transpose(V)) diff --git a/mirrors/figs/LSP_2.py b/mirrors/figs/LSP_2.py index 9080a9fcd525834f80295989670547dcb8fcfe75..97df03f8df7035dd85569a54e90f2ff4d8263c5a 100755 --- a/mirrors/figs/LSP_2.py +++ b/mirrors/figs/LSP_2.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- +from __future__ import print_function import numpy as np import matplotlib.pyplot as plt @@ -31,8 +32,8 @@ def main(): plt.xlabel('i') plt.ylabel('sigma_i') - print V.shape - print Z.shape + print(V.shape) + print(Z.shape) plt.subplot(1,3,3) ZV = np.dot(Z,np.transpose(V)) diff --git a/mirrors/figs/numpy_matplotlib01.py b/mirrors/figs/numpy_matplotlib01.py index 9f083f9c2a25fff57071acca42cd02af105d96f7..66b319647743278904bf2d2065cf41b011dc223f 100755 --- a/mirrors/figs/numpy_matplotlib01.py +++ b/mirrors/figs/numpy_matplotlib01.py @@ -1,19 +1,20 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- +from __future__ import print_function import numpy as np import matplotlib.pyplot as plt def main(): a = np.random.randn(3,3) - print a + print(a) U, s, V = np.linalg.svd(a, full_matrices=True) - print U.shape, V.shape, s.shape + print(U.shape, V.shape, s.shape) S = np.zeros((3,3)) S[:3,:3] = np.diag(s) - print np.allclose(a, np.dot(U, np.dot(S,V))) - print a - np.dot(U, np.dot(S,V)) - print s + print(np.allclose(a, np.dot(U, np.dot(S,V)))) + print(a - np.dot(U, np.dot(S,V))) + print(s) plt.plot([1,2,3,4]) plt.ylabel('some numbers') diff --git a/mirrors/mparams/mparams.py b/mirrors/mparams/mparams.py index cec5f4e95e1f5251dd9917194ee33ce9fec10a71..3e15d0bc2187dc7c862f680a2324818e4d707dd1 100755 --- a/mirrors/mparams/mparams.py +++ b/mirrors/mparams/mparams.py @@ -16,6 +16,7 @@ # limitations under the License. +from __future__ import print_function import numpy as np import os import shutil @@ -177,7 +178,7 @@ def main(): W[m_i,m_i] = W[m_i,m_i]*w[i[j],j] W_sr[m_i,m_i] = np.sqrt(W[m_i,m_i]) - p,i = indices.next(p,i,M,d) + p,i = indices.my_next(p,i,M,d) m_i = m_i + 1 @@ -322,8 +323,8 @@ def main(): write.col(f, np.diag(ZWZ), n_max) write.col(f, V[:,1], n_max) - print max(np.diag(ZWZ)) - print max(s) + print(max(np.diag(ZWZ))) + print(max(s)) #---------------------- write.sol(f, sol, m_max) diff --git a/mirrors/tests/mparams/loop.py b/mirrors/tests/mparams/loop.py index ed60efca4de80a6bcff21047b00a9a5f17582523..6325763ba73f5dca907247b7b466cb7d9c3d25a7 100755 --- a/mirrors/tests/mparams/loop.py +++ b/mirrors/tests/mparams/loop.py @@ -16,6 +16,7 @@ # limitations under the License. +from __future__ import print_function import numpy as np import time import os @@ -101,8 +102,8 @@ def main(): X, w = grid(M) - print M - print X + print(M) + print(X) m_max = 1 n_max = 1 @@ -110,8 +111,8 @@ def main(): m_max = m_max*M[j] n_max = n_max*N[j] - print m_max - print n_max + print(m_max) + print(n_max) i = np.zeros((d,), dtype =np.int) i_zero = np.zeros((d,), dtype =np.int) @@ -279,13 +280,13 @@ def main(): plt.savefig('SVD.png', bbox_inches = 'tight') os.chdir('..') - print s_hat + print(s_hat) - print >> f, M - print >> f, Z - print >> f, X - print >> f, sol - print >> f, s_hat + print(M, file=f) + print(Z, file=f) + print(X, file=f) + print(sol, file=f) + print(s_hat, file=f) date2 = time.strftime("%d/%m/%Y") hour2 = time.strftime("%H:%M:%S") diff --git a/mirrors/tests/mparams/loop2.py b/mirrors/tests/mparams/loop2.py index 74ce61362b669a0a8b837fa1b5699c98f6f07917..17e1a251694148fd60009f3de705a68f45d3775a 100755 --- a/mirrors/tests/mparams/loop2.py +++ b/mirrors/tests/mparams/loop2.py @@ -16,6 +16,7 @@ # limitations under the License. +from __future__ import print_function import numpy as np import time import os @@ -101,16 +102,16 @@ def main(): X, W = grid(M) - print M - print X + print(M) + print(X) m_max = 1 n_max = math.factorial(N[0]+d)/(math.factorial(N[0])*math.factorial(d)) for j in range(0,d): m_max = m_max*M[j] - print m_max - print n_max + print(m_max) + print(n_max) i = np.zeros((d,), dtype =np.int) i_zero = np.zeros((d,), dtype =np.int) @@ -261,13 +262,13 @@ def main(): plt.savefig('SVD.png', bbox_inches = 'tight') os.chdir('..') - print s_hat + print(s_hat) - print >> f, M - print >> f, Z - print >> f, X - print >> f, sol - print >> f, s_hat + print(M, file=f) + print(Z, file=f) + print(X, file=f) + print(sol, file=f) + print(s_hat, file=f) date2 = time.strftime("%d/%m/%Y") hour2 = time.strftime("%H:%M:%S") diff --git a/mirrors/tests/mparams/loop3.py b/mirrors/tests/mparams/loop3.py index af02d5ffcdaee7430cba6b4f7e99a2bae0caf6bd..c74c41adeba81799c510acdb844328a6f78bbacf 100755 --- a/mirrors/tests/mparams/loop3.py +++ b/mirrors/tests/mparams/loop3.py @@ -16,6 +16,7 @@ # limitations under the License. +from __future__ import print_function import numpy as np import time import os @@ -110,8 +111,8 @@ def main(): X, w = grid(M) - print M - print X + print(M) + print(X) m_max = 1 n_max = 1 #math.factorial(N[0]+d)/(math.factorial(N[0])*math.factorial(d)) @@ -119,8 +120,8 @@ def main(): m_max = m_max*M[j] n_max = n_max*N[j] - print m_max - print n_max + print(m_max) + print(n_max) i = np.zeros((d,), dtype =np.int) i_zero = np.zeros((d,), dtype =np.int) @@ -212,7 +213,7 @@ def main(): #print Z #print W_sr - print np.dot(np.dot(np.transpose(Z),W),Z) + print(np.dot(np.dot(np.transpose(Z),W),Z)) W_srZ = np.dot(W_sr,Z) U, s, V_t = np.linalg.svd(W_srZ, full_matrices=True) @@ -281,13 +282,13 @@ def main(): plt.savefig('SVD.png', bbox_inches = 'tight') os.chdir('..') - print s_hat + print(s_hat) - print >> f, M - print >> f, Z - print >> f, X - print >> f, sol - print >> f, s_hat + print(M, file=f) + print(Z, file=f) + print(X, file=f) + print(sol, file=f) + print(s_hat, file=f) date2 = time.strftime("%d/%m/%Y") hour2 = time.strftime("%H:%M:%S") diff --git a/mirrors/tests/mparams/loop4.py b/mirrors/tests/mparams/loop4.py index 3f9d6ec84d3b5c1c6e703fdb37b873910ae7c8bb..0edf2510d7c545b30ae950660a6d286d0bd847e5 100755 --- a/mirrors/tests/mparams/loop4.py +++ b/mirrors/tests/mparams/loop4.py @@ -16,6 +16,7 @@ # limitations under the License. +from __future__ import print_function import numpy as np import time import os @@ -110,8 +111,8 @@ def main(): X, w = grid(M) - print M - print X + print(M) + print(X) m_max = 1 n_max = 1 #math.factorial(N[0]+d)/(math.factorial(N[0])*math.factorial(d)) @@ -119,8 +120,8 @@ def main(): m_max = m_max*M[j] n_max = n_max*N[j] - print m_max - print n_max + print(m_max) + print(n_max) i = np.zeros((d,), dtype =np.int) i_zero = np.zeros((d,), dtype =np.int) @@ -216,9 +217,9 @@ def main(): b = np.dot(np.dot(np.transpose(Z),W),sol) s_hat = np.linalg.solve(A,b) - print A.shape - print b.shape - print s_hat.shape + print(A.shape) + print(b.shape) + print(s_hat.shape) #------------------ @@ -262,13 +263,13 @@ def main(): current_title.set_text('Surrogate model with k = ' + str(jj+1)) ax.set_zlim3d(np.amin(sol)-1.,np.amax(sol)+1.) - print s_hat + print(s_hat) - print >> f, M - print >> f, Z - print >> f, X - print >> f, sol - print >> f, s_hat + print(M, file=f) + print(Z, file=f) + print(X, file=f) + print(sol, file=f) + print(s_hat, file=f) date2 = time.strftime("%d/%m/%Y") hour2 = time.strftime("%H:%M:%S") diff --git a/mirrors/tests/mparams/loop5.py b/mirrors/tests/mparams/loop5.py index f1ded2fe5300fb4c9556eb65825278cbcec3c7ec..b37ee5173e12cc21057b3df6e9ec453c12e05189 100755 --- a/mirrors/tests/mparams/loop5.py +++ b/mirrors/tests/mparams/loop5.py @@ -16,6 +16,7 @@ # limitations under the License. +from __future__ import print_function import numpy as np import time import os @@ -105,8 +106,8 @@ def main(): X, w = grid(M) - print M - print X + print(M) + print(X) m_max = 1 n_max = 1 #math.factorial(N[0]+d)/(math.factorial(N[0])*math.factorial(d)) @@ -114,8 +115,8 @@ def main(): m_max = m_max*M[j] n_max = n_max*N[j] - print m_max - print n_max + print(m_max) + print(n_max) i = np.zeros((d,), dtype =np.int) i_zero = np.zeros((d,), dtype =np.int) @@ -284,13 +285,13 @@ def main(): plt.savefig('SVD.png', bbox_inches = 'tight') os.chdir('..') - print s_hat + print(s_hat) - print >> f, M - print >> f, Z - print >> f, X - print >> f, sol - print >> f, s_hat + print(M, file=f) + print(Z, file=f) + print(X, file=f) + print(sol, file=f) + print(s_hat, file=f) date2 = time.strftime("%d/%m/%Y") hour2 = time.strftime("%H:%M:%S") diff --git a/mirrors/tests/mparams/loop6.py b/mirrors/tests/mparams/loop6.py index 99722ef942b1d7a54db48ac0956f68e84fd56835..e5cc443f03d86adcd86b0d50404fe04652012d83 100755 --- a/mirrors/tests/mparams/loop6.py +++ b/mirrors/tests/mparams/loop6.py @@ -16,6 +16,7 @@ # limitations under the License. +from __future__ import print_function import numpy as np import time import os @@ -106,8 +107,8 @@ def main(): X, w = grid(M) - print M - print X + print(M) + print(X) m_max = 1 n_max = 1 #math.factorial(N[0]+d)/(math.factorial(N[0])*math.factorial(d)) @@ -115,8 +116,8 @@ def main(): m_max = m_max*M[j] n_max = n_max*N[j] - print m_max - print n_max + print(m_max) + print(n_max) i = np.zeros((d,), dtype =np.int) i_zero = np.zeros((d,), dtype =np.int) @@ -181,7 +182,7 @@ def main(): xi[j] = X[i[j],j] xi[j] = Dom_min[j] + (Dom_max[j] - Dom_min[j])*(xi[j]+1.)/2. - print xi + print(xi) Z[m_i,:] = np.transpose(phi(xi,N,n_max,d)) sol[m_i] = model(xi,f,d,fig,ax,imported_sol,m_i) @@ -283,13 +284,13 @@ def main(): plt.savefig('SVD.png', bbox_inches = 'tight') os.chdir('..') - print s_hat + print(s_hat) - print >> f, M - print >> f, Z - print >> f, X - print >> f, sol - print >> f, s_hat + print(M, file=f) + print(Z, file=f) + print(X, file=f) + print(sol, file=f) + print(s_hat, file=f) date2 = time.strftime("%d/%m/%Y") hour2 = time.strftime("%H:%M:%S") diff --git a/mirrors/tests/mparams/loop7.py b/mirrors/tests/mparams/loop7.py index e15e86b31d5d60ad33f45337fe4931af886afac6..48b9b01c28ce1667b323b4c2ee1eb5f7af561a9d 100755 --- a/mirrors/tests/mparams/loop7.py +++ b/mirrors/tests/mparams/loop7.py @@ -16,6 +16,7 @@ # limitations under the License. +from __future__ import print_function import numpy as np import time import os @@ -105,8 +106,8 @@ def main(): X, w = grid(M) - print M - print X + print(M) + print(X) m_max = 1 n_max = 1 #math.factorial(N[0]+d)/(math.factorial(N[0])*math.factorial(d)) @@ -114,8 +115,8 @@ def main(): m_max = m_max*M[j] n_max = n_max*N[j] - print m_max - print n_max + print(m_max) + print(n_max) i = np.zeros((d,), dtype =np.int) i_zero = np.zeros((d,), dtype =np.int) @@ -178,7 +179,7 @@ def main(): xi[j] = X[i[j],j] xi[j] = Dom_min[j] + (Dom_max[j] - Dom_min[j])*(xi[j]+1.)/2. - print xi + print(xi) Z[m_i,:] = np.transpose(phi(xi,N,n_max,d)) sol[m_i] = model(xi,f,d,fig,ax,imported_sol,m_i) diff --git a/mirrors/tests/mparams/loop8.py b/mirrors/tests/mparams/loop8.py index d1a0656a1559c77993ab243cf7c44929c7c49d56..90a07fa601e483f501ad2cc7f0bcbcce32a8cf88 100755 --- a/mirrors/tests/mparams/loop8.py +++ b/mirrors/tests/mparams/loop8.py @@ -16,6 +16,7 @@ # limitations under the License. +from __future__ import print_function import numpy as np import time import os @@ -105,8 +106,8 @@ def main(): X, w = grid(M) - print M - print X + print(M) + print(X) m_max = 1 n_max = 1 #math.factorial(N[0]+d)/(math.factorial(N[0])*math.factorial(d)) @@ -114,8 +115,8 @@ def main(): m_max = m_max*M[j] n_max = n_max*N[j] - print m_max - print n_max + print(m_max) + print(n_max) i = np.zeros((d,), dtype =np.int) i_zero = np.zeros((d,), dtype =np.int) diff --git a/mirrors/tests/mparams/mparams.py b/mirrors/tests/mparams/mparams.py index a47875ee767f4d428e886a0f6cd9e532f740ff66..83393490c0df3a67fb821132826e4dbb598765ed 100755 --- a/mirrors/tests/mparams/mparams.py +++ b/mirrors/tests/mparams/mparams.py @@ -177,7 +177,7 @@ def main(): W[m_i,m_i] = W[m_i,m_i]*w[i[j],j] W_sr[m_i,m_i] = np.sqrt(W[m_i,m_i]) - p,i = indices.next(p,i,M,d) + p,i = indices.my_next(p,i,M,d) m_i = m_i + 1 W_srZ = np.dot(W_sr,Z) diff --git a/mirrors/viewer.py b/mirrors/viewer.py index 5d6011033a91b19dbe472115d00978c42eee78a5..b322d63ec778b39ce89c562ae14bd07734b5e6cf 100644 --- a/mirrors/viewer.py +++ b/mirrors/viewer.py @@ -16,6 +16,7 @@ # limitations under the License. +from __future__ import print_function import os, os.path class GUI: @@ -49,7 +50,7 @@ class GUI: optfile=optfile2 cmd="gmsh %s %s %s" % (mshfile, posfile, optfile) - print "cmd=",cmd + print("cmd=",cmd) os.system(cmd) def defopt(self,fname='default.opt'): diff --git a/mrstlnos/CMAME_tests/model.py b/mrstlnos/CMAME_tests/model.py index 95cfb2a8975801ff3e1971301ce9e156be0f1fde..9b6e0dd36f8eaba5df996f1268743d3759fb3461 100644 --- a/mrstlnos/CMAME_tests/model.py +++ b/mrstlnos/CMAME_tests/model.py @@ -1,5 +1,6 @@ #!/usr/bin/env python +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -161,7 +162,7 @@ class plate_model: self.slv = m.IterativeSolver(self.pbl,k,self.solverList,3, self.useEP, self.ensemble_size) self.slv.start() f = open('timers.txt', 'w') - print >>f, self.slv.getTimers() + print(self.slv.getTimers(), file=f) f.closed def main(): @@ -172,13 +173,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") args=parseargs() diff --git a/mrstlnos/CMAME_tests/plate.py b/mrstlnos/CMAME_tests/plate.py index 1cc6ce35ef49fa74e5853357f547eb394ff8091b..203efb0694404ff782bea1ed4a00f5e3f3488870 100644 --- a/mrstlnos/CMAME_tests/plate.py +++ b/mrstlnos/CMAME_tests/plate.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos.CMAME_tests.model as model import mrstlnos as m @@ -25,13 +26,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") args=parseargs() diff --git a/mrstlnos/CMAME_tests/plate_MC_GS_case_1.py b/mrstlnos/CMAME_tests/plate_MC_GS_case_1.py index ed1361cded82a0a961d015bf806b8d44193fe75e..4e98ec79b2de519d20af6482f0abc336372b3d14 100644 --- a/mrstlnos/CMAME_tests/plate_MC_GS_case_1.py +++ b/mrstlnos/CMAME_tests/plate_MC_GS_case_1.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos.CMAME_tests.model as model import mrstlnos as m @@ -55,13 +56,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") args=parseargs() diff --git a/mrstlnos/CMAME_tests/plate_MC_GS_case_2.py b/mrstlnos/CMAME_tests/plate_MC_GS_case_2.py index 3c25b96c1ea3fe38ede226a822066ce1d53476a4..41e7f2fa18474f843f39ed89fcd6c1f0b0f6c9fc 100644 --- a/mrstlnos/CMAME_tests/plate_MC_GS_case_2.py +++ b/mrstlnos/CMAME_tests/plate_MC_GS_case_2.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos.CMAME_tests.model as model import mrstlnos as m @@ -56,13 +57,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") args=parseargs() diff --git a/mrstlnos/CMAME_tests/plate_MC_GS_case_3.py b/mrstlnos/CMAME_tests/plate_MC_GS_case_3.py index 03166d3e71a89ede28de0585618242a116161600..07c650a43aff399cde7f6f1a148f6efb5a4e9788 100644 --- a/mrstlnos/CMAME_tests/plate_MC_GS_case_3.py +++ b/mrstlnos/CMAME_tests/plate_MC_GS_case_3.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos.CMAME_tests.model as model import mrstlnos as m @@ -59,13 +60,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") args=parseargs() diff --git a/mrstlnos/CMAME_tests/plate_MC_GS_case_4.py b/mrstlnos/CMAME_tests/plate_MC_GS_case_4.py index 78fd6d9e0489e8e5fd0a85f840fcadd218f29234..4b6efa97fe37de5968308f4ebb8be99cd98bfffd 100644 --- a/mrstlnos/CMAME_tests/plate_MC_GS_case_4.py +++ b/mrstlnos/CMAME_tests/plate_MC_GS_case_4.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos.CMAME_tests.model as model import mrstlnos as m @@ -60,13 +61,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") args=parseargs() diff --git a/mrstlnos/CMAME_tests/plate_MC_NO_EP_case_1.py b/mrstlnos/CMAME_tests/plate_MC_NO_EP_case_1.py index df719a886c7e1ef584a9a66b16714afb257b1be1..278332b1f132b279c41a99893358cf5df0513ade 100644 --- a/mrstlnos/CMAME_tests/plate_MC_NO_EP_case_1.py +++ b/mrstlnos/CMAME_tests/plate_MC_NO_EP_case_1.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos.CMAME_tests.model as model import mrstlnos as m @@ -61,13 +62,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") args=parseargs() diff --git a/mrstlnos/CMAME_tests/plate_MC_NO_EP_case_2.py b/mrstlnos/CMAME_tests/plate_MC_NO_EP_case_2.py index 03e005cdb81c0c874ce7170fa40f661769a1295f..2759e1153aaab5ffdad2d79a49d449f4a1b919ee 100644 --- a/mrstlnos/CMAME_tests/plate_MC_NO_EP_case_2.py +++ b/mrstlnos/CMAME_tests/plate_MC_NO_EP_case_2.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos.CMAME_tests.model as model import mrstlnos as m @@ -63,13 +64,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") args=parseargs() diff --git a/mrstlnos/CMAME_tests/plate_MC_NO_EP_case_3.py b/mrstlnos/CMAME_tests/plate_MC_NO_EP_case_3.py index 5c331230e83a5a0a7c442ab626096e6d4fd56629..6c9ce25fbf9eaaeae295484e606dee08a9078d04 100644 --- a/mrstlnos/CMAME_tests/plate_MC_NO_EP_case_3.py +++ b/mrstlnos/CMAME_tests/plate_MC_NO_EP_case_3.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos.CMAME_tests.model as model import mrstlnos as m @@ -66,13 +67,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") args=parseargs() diff --git a/mrstlnos/CMAME_tests/plate_MC_NO_EP_case_4.py b/mrstlnos/CMAME_tests/plate_MC_NO_EP_case_4.py index a2bea98bf6bf4caa5f4b7d2516858c7808cc1282..1fd6ef9caa82617767fc0f91a6dc4b1a1624ce8d 100644 --- a/mrstlnos/CMAME_tests/plate_MC_NO_EP_case_4.py +++ b/mrstlnos/CMAME_tests/plate_MC_NO_EP_case_4.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos.CMAME_tests.model as model import mrstlnos as m @@ -67,13 +68,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") args=parseargs() diff --git a/mrstlnos/CMAME_tests/plate_MC_direct_case_1.py b/mrstlnos/CMAME_tests/plate_MC_direct_case_1.py index b6c46275feb8f9eddb67f2606423704366d2c9c8..27751fcc633c4e718d0c0b35682a0c3f50392ac5 100644 --- a/mrstlnos/CMAME_tests/plate_MC_direct_case_1.py +++ b/mrstlnos/CMAME_tests/plate_MC_direct_case_1.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos.CMAME_tests.model as model import mrstlnos as m @@ -58,13 +59,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") args=parseargs() diff --git a/mrstlnos/CMAME_tests/plate_MC_direct_case_2.py b/mrstlnos/CMAME_tests/plate_MC_direct_case_2.py index 6a35f2a993b2e5df08e27366d23a404cfd9eb49a..76fe023f1ca69512887683387f30b8ccc1437d60 100644 --- a/mrstlnos/CMAME_tests/plate_MC_direct_case_2.py +++ b/mrstlnos/CMAME_tests/plate_MC_direct_case_2.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos.CMAME_tests.model as model import mrstlnos as m @@ -60,13 +61,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") args=parseargs() diff --git a/mrstlnos/CMAME_tests/plate_MC_direct_case_3.py b/mrstlnos/CMAME_tests/plate_MC_direct_case_3.py index 6bd418f7a5010a88144f38d35ced4ba7c446d6f2..a026af7d1ec91a10d63b2275fd77f3edfe59b34f 100644 --- a/mrstlnos/CMAME_tests/plate_MC_direct_case_3.py +++ b/mrstlnos/CMAME_tests/plate_MC_direct_case_3.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos.CMAME_tests.model as model import mrstlnos as m @@ -63,13 +64,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") args=parseargs() diff --git a/mrstlnos/CMAME_tests/plate_MC_direct_case_4.py b/mrstlnos/CMAME_tests/plate_MC_direct_case_4.py index 319e57531d0fce7d3420f841efb2932e012e782b..40374c76347bb10e6ee0ecf23619b299eb84489e 100644 --- a/mrstlnos/CMAME_tests/plate_MC_direct_case_4.py +++ b/mrstlnos/CMAME_tests/plate_MC_direct_case_4.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos.CMAME_tests.model as model import mrstlnos as m @@ -64,13 +65,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") args=parseargs() diff --git a/mrstlnos/CMAME_tests/plate_convergence_direct.py b/mrstlnos/CMAME_tests/plate_convergence_direct.py index f12207dccbefd89b4ced11807f680511d1522cff..4f8b8e2239c3c10214043eea8406ccb1feb62260 100644 --- a/mrstlnos/CMAME_tests/plate_convergence_direct.py +++ b/mrstlnos/CMAME_tests/plate_convergence_direct.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function from mrstlnos.eigenvalues import * from mrstlnos.convergence import * import os @@ -58,17 +59,17 @@ def main(): deltas.imag = tmp[:,1] timers['Read files'].stop() - print timers + print(timers) timers['Compute the convergence'].start() convergence = compute_convergence(k_max,n_omegas,omegas,deltas,A,b,x0,verbose=True) timers['Compute the basconvergenceis'].stop() - print timers + print(timers) np.savetxt(work_dir+'/convergence_'+ str(i) +'.txt',convergence) f = open('timers_'+ str(i) +'.txt', 'w') - print >>f, timers + print(timers, file=f) f.closed if __name__ == "__main__": diff --git a/mrstlnos/CMAME_tests/plate_deltas_omegas_GS.py b/mrstlnos/CMAME_tests/plate_deltas_omegas_GS.py index c75e8fbd7328cc46732dd3188d377afe76d17f26..2a4a011365ab6e9fd7721ebb1bccf80bdf0431ee 100644 --- a/mrstlnos/CMAME_tests/plate_deltas_omegas_GS.py +++ b/mrstlnos/CMAME_tests/plate_deltas_omegas_GS.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function from mrstlnos.eigenvalues import * import os import fwk @@ -46,7 +47,7 @@ def main(): i_min = int(i_min) i_max = int(i_max) - print 'Rank ' + str(rank) + ' from sample ' + str(i_min) + ':' + str(i_max) + print('Rank ' + str(rank) + ' from sample ' + str(i_min) + ':' + str(i_max)) for i in range(i_min,i_max): timers = fwk.Timers() @@ -71,19 +72,19 @@ def main(): invR = Gauss_Seidel(R,n=n_sweeps_R,damping=damp_R) timers['Compute invR'].stop() - print timers + print(timers) timers['Compute the inverse of Q'].start() invQ = Gauss_Seidel(Q,n=n_sweeps_Q,damping=damp_Q) timers['Compute the inverse of Q'].stop() - print timers + print(timers) timers['Compute the preconditioned matrix'].start() AinvP = SIMPLE_preconditioned_matrix(Q,invQ,G,GT,R,invR,omega=omega) timers['Compute the preconditioned matrix'].stop() - print timers + print(timers) timers['Compute the basis'].start() @@ -96,13 +97,13 @@ def main(): V,W = compute_VW(AinvP,b,m=m_max,N=N) timers['Compute the basis'].stop() - print timers + print(timers) timers['Compute the eigenvalues'].start() deltas, omegas = compute_deltas_omegas(V,W,b) timers['Compute the eigenvalues'].stop() - print timers + print(timers) timers['Write the eigenvalues'].start() write_eigenvalues(deltas,work_dir+'/deltas_GS_GS_'+ str(i) +'.txt') @@ -110,7 +111,7 @@ def main(): timers['Write the eigenvalues'].stop() f = open('timers_'+ str(i) +'.txt', 'w') - print >>f, timers + print(timers, file=f) f.closed if __name__ == "__main__": diff --git a/mrstlnos/CMAME_tests/plate_deltas_omegas_direct.py b/mrstlnos/CMAME_tests/plate_deltas_omegas_direct.py index de4c73e1902c6e5655f76ccd4f3b3e51a95a7122..96ac65cb02a10fca6e3d7d177e743db7dea1fade 100644 --- a/mrstlnos/CMAME_tests/plate_deltas_omegas_direct.py +++ b/mrstlnos/CMAME_tests/plate_deltas_omegas_direct.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function from mrstlnos.eigenvalues import * import os import fwk @@ -61,19 +62,19 @@ def main(): invR = compute_inv(R) timers['Compute invR'].stop() - print timers + print(timers) timers['Compute the inverse of Q'].start() invQG = compute_inv_on_image(Q,G) timers['Compute the inverse of Q'].stop() - print timers + print(timers) timers['Compute the preconditioned matrix'].start() AinvP = SIMPLE_prec(Q,invQG,G,GT,R,invR,True) timers['Compute the preconditioned matrix'].stop() - print timers + print(timers) timers['Compute the basis'].start() @@ -87,13 +88,13 @@ def main(): timers['Compute the basis'].stop() - print timers + print(timers) timers['Compute the eigenvalues'].start() deltas, omegas = compute_deltas_omegas(V,W,b) timers['Compute the eigenvalues'].stop() - print timers + print(timers) timers['Write the eigenvalues'].start() write_eigenvalues(deltas,work_dir+'/deltas_direct_direct_'+ str(i) +'.txt') @@ -101,7 +102,7 @@ def main(): timers['Write the eigenvalues'].stop() f = open('timers_'+ str(i) +'.txt', 'w') - print >>f, timers + print(timers, file=f) f.closed if __name__ == "__main__": diff --git a/mrstlnos/CMAME_tests/plate_eigenvalues.py b/mrstlnos/CMAME_tests/plate_eigenvalues.py index 10217e4aa96e17ff584b63815f62dd2f15374a86..3a503668cedd20e7cab8271a2f6691960af0bd34 100644 --- a/mrstlnos/CMAME_tests/plate_eigenvalues.py +++ b/mrstlnos/CMAME_tests/plate_eigenvalues.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function from mrstlnos.eigenvalues import * import os import fwk @@ -32,26 +33,26 @@ def main(): R = approx_Schur_complement(Q,G,GT) timers['Compute R'].stop() - print timers + print(timers) timers['Compute the inverse of Q'].start() invQG = compute_inv_on_image(Q,G) timers['Compute the inverse of Q'].stop() - print timers + print(timers) timers['Compute the eigenvalues'].start() v = eigenvalues_SR(invQG,G,GT,R,True) timers['Compute the eigenvalues'].stop() - print timers + print(timers) timers['Write the eigenvalues'].start() write_eigenvalues(v,work_dir+'/eigenvalues_direct_direct_'+ str(i) +'.txt') timers['Write the eigenvalues'].stop() f = open('timers_'+ str(i) +'.txt', 'w') - print >>f, timers + print(timers, file=f) f.closed if __name__ == "__main__": diff --git a/mrstlnos/CMAME_tests/plate_eigenvalues_gamma.py b/mrstlnos/CMAME_tests/plate_eigenvalues_gamma.py index e03a3256668db633d568c80374e5cd20e3a817b5..7ee95fda402f0cf340c104d2ea9353ae7bdf28c2 100644 --- a/mrstlnos/CMAME_tests/plate_eigenvalues_gamma.py +++ b/mrstlnos/CMAME_tests/plate_eigenvalues_gamma.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function from mrstlnos.eigenvalues import * import os import fwk @@ -35,26 +36,26 @@ def main(): R = approx_Schur_complement(Q,G,GT) timers['Compute R'].stop() - print timers + print(timers) timers['Compute the inverse of Q'].start() invQG = compute_inv_on_image(Q,G) timers['Compute the inverse of Q'].stop() - print timers + print(timers) timers['Compute the eigenvalues'].start() v = eigenvalues_SR(invQG,G,GT,R,True) timers['Compute the eigenvalues'].stop() - print timers + print(timers) timers['Write the eigenvalues'].start() write_eigenvalues(v,work_dir+'/eigenvalues_direct_direct_'+ str(i) +'.txt') timers['Write the eigenvalues'].stop() f = open('timers_'+ str(i) +'.txt', 'w') - print >>f, timers + print(timers, file=f) f.closed if __name__ == "__main__": main() diff --git a/mrstlnos/CMAME_tests/plate_extended.py b/mrstlnos/CMAME_tests/plate_extended.py index c2222343c698358825cef5526f4f307338d3b237..0790d9e011c4dcf2faec813959423b64b905aee7 100644 --- a/mrstlnos/CMAME_tests/plate_extended.py +++ b/mrstlnos/CMAME_tests/plate_extended.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos.CMAME_tests.model as model import mrstlnos as m @@ -25,13 +26,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") args=parseargs() diff --git a/mrstlnos/CMAME_tests/plate_mean_gamma.py b/mrstlnos/CMAME_tests/plate_mean_gamma.py index 60a2f946994dc123fd450955df04cdc7d2964731..f5db661bd6e41bd7d7dd60ea3fb7c955131104ab 100644 --- a/mrstlnos/CMAME_tests/plate_mean_gamma.py +++ b/mrstlnos/CMAME_tests/plate_mean_gamma.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos.CMAME_tests.model as model import mrstlnos as m @@ -55,13 +56,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") args=parseargs() diff --git a/mrstlnos/CMAME_tests/plate_mean_prec.py b/mrstlnos/CMAME_tests/plate_mean_prec.py index b01f9aef1a3da2d0ac975f816f32b26015af8479..fa1a72bb977daca38cc878e988a52a62c973b0db 100644 --- a/mrstlnos/CMAME_tests/plate_mean_prec.py +++ b/mrstlnos/CMAME_tests/plate_mean_prec.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos.CMAME_tests.model as model import mrstlnos as m @@ -63,13 +64,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") args=parseargs() diff --git a/mrstlnos/CMAME_tests/plate_mean_prec_GS_direct.py b/mrstlnos/CMAME_tests/plate_mean_prec_GS_direct.py index c6a4a24a07a7bbcd436251c3902b58f8076712eb..92f3bddff0a3c0616ea29d3a770d2631137ff6ca 100644 --- a/mrstlnos/CMAME_tests/plate_mean_prec_GS_direct.py +++ b/mrstlnos/CMAME_tests/plate_mean_prec_GS_direct.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos.CMAME_tests.model as model import mrstlnos as m @@ -64,13 +65,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") args=parseargs() diff --git a/mrstlnos/CMAME_tests/post_process/grouping.py b/mrstlnos/CMAME_tests/post_process/grouping.py index c6045025cfa25b71fa5fa460930c6936a39da336..94ab34e8980fa6d4d45cf4e5c4802ef413df0fbf 100644 --- a/mrstlnos/CMAME_tests/post_process/grouping.py +++ b/mrstlnos/CMAME_tests/post_process/grouping.py @@ -1,3 +1,4 @@ +from __future__ import print_function # require a git clone https://github.com/kliegeois/Same-Size-K-Means.git from clustering.equal_groups import EqualGroupsKMeans @@ -25,7 +26,7 @@ def compute_the_groups(N,ensemble_size,num_random_variables): for i in range(0,n_clusters): l_s = len(np.argwhere(Z==i)) if l_s != ensemble_size: - print 'Ensemble ' + str(i) + ' has ' + str(l_s) + ' samples instead of ' + str(ensemble_size) + print('Ensemble ' + str(i) + ' has ' + str(l_s) + ' samples instead of ' + str(ensemble_size)) np.savetxt('Groupe_id_s_'+str(ensemble_size)+'_'+str(N)+'.txt',Z, fmt='%i') diff --git a/mrstlnos/CMAME_tests/post_process/plate_MC_convergence.py b/mrstlnos/CMAME_tests/post_process/plate_MC_convergence.py index ece9660ec8764b65009aab931cf4ccaa44a00d63..cbc8837d0db354e3e202a8b0362b34d2ba37fa28 100644 --- a/mrstlnos/CMAME_tests/post_process/plate_MC_convergence.py +++ b/mrstlnos/CMAME_tests/post_process/plate_MC_convergence.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function from mrstlnos.readers import * def read_iter_all_ensemble_sizes(n_samples,ensemble_sizes,file_MC_base_dir,reduction=False): @@ -39,7 +40,7 @@ def main(): plt.savefig('GS_case_'+str(case_id)+'_ER.png', dpi=400) np.savetxt('GS_case_'+str(case_id)+'_ER.txt', iter, delimiter=' ') except: - print file_MC_base_dir + ' has not all the files' + print(file_MC_base_dir + ' has not all the files') file_MC_base_dir = '/Volumes/HD_SONY/CMAME/Plate/mrstlnos_CMAME_tests_plate_MC_direct_case_'+str(case_id)+'_ER' try: iter = read_iter_all_ensemble_sizes(n_samples,ensemble_sizes,file_MC_base_dir,True) @@ -47,7 +48,7 @@ def main(): plt.savefig('direct_case_'+str(case_id)+'_ER.png', dpi=400) np.savetxt('direct_case_'+str(case_id)+'_ER.txt', iter, delimiter=' ') except: - print file_MC_base_dir + ' has not all the files' + print(file_MC_base_dir + ' has not all the files') file_MC_base_dir = '/Volumes/HD_SONY/CMAME/Plate/mrstlnos_CMAME_tests_plate_MC_GS_case_'+str(case_id)+'_NER' try: iter = read_iter_all_ensemble_sizes(n_samples,ensemble_sizes,file_MC_base_dir) @@ -55,7 +56,7 @@ def main(): plt.savefig('GS_case_'+str(case_id)+'_NER.png', dpi=400) np.savetxt('GS_case_'+str(case_id)+'_NER.txt', iter, delimiter=' ') except: - print file_MC_base_dir + ' has not all the files' + print(file_MC_base_dir + ' has not all the files') file_MC_base_dir = '/Volumes/HD_SONY/CMAME/Plate/mrstlnos_CMAME_tests_plate_MC_direct_case_'+str(case_id)+'_NER' try: iter = read_iter_all_ensemble_sizes(n_samples,ensemble_sizes,file_MC_base_dir) @@ -63,7 +64,7 @@ def main(): plt.savefig('direct_case_'+str(case_id)+'_NER.png', dpi=400) np.savetxt('direct_case_'+str(case_id)+'_NER.txt', iter, delimiter=' ') except: - print file_MC_base_dir + ' has not all the files' + print(file_MC_base_dir + ' has not all the files') if __name__ == "__main__": main() diff --git a/mrstlnos/CMAME_tests/post_process/plate_MC_speedup.py b/mrstlnos/CMAME_tests/post_process/plate_MC_speedup.py index 7efb15bbae6a73068bc66532ead05dc786477f71..9617099bbae872cd69bf18dcfef8d8a60bffca2f 100644 --- a/mrstlnos/CMAME_tests/post_process/plate_MC_speedup.py +++ b/mrstlnos/CMAME_tests/post_process/plate_MC_speedup.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function from mrstlnos.speedup import * def speedup_of_one_case(case_id,GS,ensemble_reduction,n_samples,ensemble_sizes,quantiles,querylines,use_waves_timers,use_teuchos_timers,per_iteration): @@ -27,7 +28,7 @@ def speedup_of_one_case(case_id,GS,ensemble_reduction,n_samples,ensemble_sizes,q R = compute_R(n_samples,ensemble_sizes,file_MC_base_dir,quantiles,ensemble_reduction) save_R(R,'R_'+prec+'case_'+ case_id) except: - print '/Volumes/HD_SONY/CMAME/Plate/mrstlnos_CMAME_tests_plate_MC_'+prec+'case_'+ case_id + ' has not all the files' + print('/Volumes/HD_SONY/CMAME/Plate/mrstlnos_CMAME_tests_plate_MC_'+prec+'case_'+ case_id + ' has not all the files') def main(): import matplotlib.pyplot as plt diff --git a/mrstlnos/CMAME_tests/post_process/plate_mean.py b/mrstlnos/CMAME_tests/post_process/plate_mean.py index e71b8da145cbeb8bec69ec0081eea82ef55772e1..8a6b439b757ed83f13ded9cbd0f3348f662e9b89 100644 --- a/mrstlnos/CMAME_tests/post_process/plate_mean.py +++ b/mrstlnos/CMAME_tests/post_process/plate_mean.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function from mrstlnos.eigenvalues import * from mrstlnos.readers import * import os @@ -86,7 +87,7 @@ def plot_2D_cut_values_at_node(x,y,tri,value,v_min,v_max,n_levels=16): import matplotlib.pyplot as plt value = value.reshape((len(x),)) levels = np.linspace(v_min, v_max, n_levels) - print levels + print(levels) fig = plt.figure(figsize=(8, 8)) plt.set_cmap('coolwarm') @@ -107,7 +108,7 @@ def plot_2D_cut_values_at_elem(x,y,tri_1,value,v_min,v_max,n_levels=16,shading=F value = value.reshape((tri_1.shape[0],)) levels = np.linspace(v_min, v_max, n_levels) - print levels + print(levels) fig = plt.figure(figsize=(8, 8)) plt.set_cmap('coolwarm') if shading: @@ -126,7 +127,7 @@ def plot_2D_mesh(pts, quad): import matplotlib.pyplot as plt fig = plt.figure(figsize=(8, 8)) f = open('mesh_2.tex', 'w') - print >>f, '\begin{tikzpicture}' + print('\begin{tikzpicture}', file=f) for i in range(0,quad.shape[0]): x = np.zeros((quad.shape[1]+1,)) y = np.zeros((quad.shape[1]+1,)) @@ -143,12 +144,12 @@ def plot_2D_mesh(pts, quad): else: string_1 = string_1 + '--' - print >>f, string_1 + print(string_1, file=f) plt.plot(x,y,'black') plt.gca().set_aspect('equal') - print >>f, '\end{tikzpicture}' + print('\end{tikzpicture}', file=f) f.closed def main(): @@ -173,9 +174,9 @@ def main(): norm_Q = sparse_matrix_2_norm(Q) norm_GT = sparse_matrix_2_norm(GT) - print norm_Q - print norm_GT - print norm_Q/norm_GT + print(norm_Q) + print(norm_GT) + print(norm_Q/norm_GT) pts, tri, vals = cut_plate(mshName) pts_2, quad = extract_quad_msh(mshName) @@ -202,7 +203,7 @@ def main(): plot_Belos(iter_indices, residuals) - print timers + print(timers) plt.show() diff --git a/mrstlnos/CMAME_tests/post_process/plate_mean_GS_omega.py b/mrstlnos/CMAME_tests/post_process/plate_mean_GS_omega.py index f749576cb832b9bd4a279f53f96219e3cbe7d1a5..ad05370c1e6a8acccfe49ec878e80ae9b0279afb 100644 --- a/mrstlnos/CMAME_tests/post_process/plate_mean_GS_omega.py +++ b/mrstlnos/CMAME_tests/post_process/plate_mean_GS_omega.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function from mrstlnos.eigenvalues import * from mrstlnos.readers import * import os @@ -29,24 +30,24 @@ def main(): R = approx_Schur_complement(Q,G,GT) if diagonal_dominance(R): - print 'R is diagonally dominant' + print('R is diagonally dominant') else: - print 'R is not diagonally dominant' + print('R is not diagonally dominant') if diagonal_dominance(Q): - print 'Q is diagonally dominant' + print('Q is diagonally dominant') else: - print 'Q is not diagonally dominant' + print('Q is not diagonally dominant') if is_SPD(R): - print 'R is SPD' + print('R is SPD') else: - print 'R is not SPD' + print('R is not SPD') if is_SPD(Q): - print 'Q is SPD' + print('Q is SPD') else: - print 'Q is not SPD' + print('Q is not SPD') #Qjac = jacobi_iteration_matrix(Q) #Rjac = jacobi_iteration_matrix(R) diff --git a/mrstlnos/CMAME_tests/post_process/plate_mean_convergence.py b/mrstlnos/CMAME_tests/post_process/plate_mean_convergence.py index 86b4b22f7954724828a4fb49dba0daaf46e6a9fd..fc3d8f4756f0750305c49197b7740512418e4023 100644 --- a/mrstlnos/CMAME_tests/post_process/plate_mean_convergence.py +++ b/mrstlnos/CMAME_tests/post_process/plate_mean_convergence.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function from mrstlnos.eigenvalues import * import os import fwk @@ -96,7 +97,7 @@ def plot_2D_cut_values_at_node(x,y,tri,value,v_min,v_max,n_levels=16): import matplotlib.pyplot as plt value = value.reshape((len(x),)) levels = np.linspace(v_min, v_max, n_levels) - print levels + print(levels) fig = plt.figure(figsize=(8, 8)) plt.set_cmap('coolwarm') @@ -117,7 +118,7 @@ def plot_2D_cut_values_at_elem(x,y,tri_1,value,v_min,v_max,n_levels=16,shading=F value = value.reshape((tri_1.shape[0],)) levels = np.linspace(v_min, v_max, n_levels) - print levels + print(levels) fig = plt.figure(figsize=(8, 8)) plt.set_cmap('coolwarm') if shading: @@ -136,7 +137,7 @@ def plot_2D_mesh(pts, quad): import matplotlib.pyplot as plt fig = plt.figure(figsize=(8, 8)) f = open('mesh_2.tex', 'w') - print >>f, '\begin{tikzpicture}' + print('\begin{tikzpicture}', file=f) for i in range(0,quad.shape[0]): x = np.zeros((quad.shape[1]+1,)) y = np.zeros((quad.shape[1]+1,)) @@ -153,12 +154,12 @@ def plot_2D_mesh(pts, quad): else: string_1 = string_1 + '--' - print >>f, string_1 + print(string_1, file=f) plt.plot(x,y,'black') plt.gca().set_aspect('equal') - print >>f, '\end{tikzpicture}' + print('\end{tikzpicture}', file=f) f.closed def plot_1D_data_per_elem(pts,elems,vals): diff --git a/mrstlnos/Juelich/broken/M1.py b/mrstlnos/Juelich/broken/M1.py index 6756e93f0d21002a72ad537927d691ccfbaa7edd..55d5a6c93e4721ffd09082b837f08f7734252d6c 100644 --- a/mrstlnos/Juelich/broken/M1.py +++ b/mrstlnos/Juelich/broken/M1.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -13,13 +14,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") @@ -102,7 +103,7 @@ def main(): if rank == 0: command_line = 'gmsh -3 ' + file_dir + '/mesh/' + geo_name + ' -o ' + work_dir + '/' + mesh_name +' -part ' + str(siz) - print command_line + print(command_line) tmp = shlex.split(command_line) fileout = open('gmsh.log','w') p = subprocess.Popen(tmp, stdin=subprocess.PIPE, stdout=fileout, stderr=fileout, env=os.environ, shell=False,close_fds=True) diff --git a/mrstlnos/Juelich/broken/M1_assembly.py b/mrstlnos/Juelich/broken/M1_assembly.py index 39e09d5642cd0aa5358211e59d432baf7fcdd7f9..492afa891948c8b0bbde21e0da46c9c6b7b3a9a8 100644 --- a/mrstlnos/Juelich/broken/M1_assembly.py +++ b/mrstlnos/Juelich/broken/M1_assembly.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -13,13 +14,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") @@ -102,7 +103,7 @@ def main(): if rank == 0: command_line = 'gmsh -3 ' + file_dir + '/mesh/' + geo_name + ' -o ' + work_dir + '/' + mesh_name +' -part ' + str(siz) - print command_line + print(command_line) tmp = shlex.split(command_line) fileout = open('gmsh.log','w') p = subprocess.Popen(tmp, stdin=subprocess.PIPE, stdout=fileout, stderr=fileout, env=os.environ, shell=False,close_fds=True) diff --git a/mrstlnos/Juelich/broken/M1_assembly_fused_all.py b/mrstlnos/Juelich/broken/M1_assembly_fused_all.py index f3472a8186a3f3235bc681ffd81ab0d4cbaf3695..720fe961b9d36ffc843cf189b8fdab77e16d8d77 100644 --- a/mrstlnos/Juelich/broken/M1_assembly_fused_all.py +++ b/mrstlnos/Juelich/broken/M1_assembly_fused_all.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -13,13 +14,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") @@ -94,7 +95,7 @@ def main(): if rank == 0: command_line = 'gmsh -3 ' + file_dir + '/mesh/' + geo_name + ' -o ' + work_dir + '/' + mesh_name +' -part ' + str(siz) - print command_line + print(command_line) tmp = shlex.split(command_line) fileout = open('gmsh.log','w') p = subprocess.Popen(tmp, stdin=subprocess.PIPE, stdout=fileout, stderr=fileout, env=os.environ, shell=False,close_fds=True) diff --git a/mrstlnos/Juelich/broken/M1_assembly_fused_mm.py b/mrstlnos/Juelich/broken/M1_assembly_fused_mm.py index 0b8df7a319a426679b5c4cb377d18dee86627ad3..ca884b94e7401eb49b8b0c61c4647832746456a8 100644 --- a/mrstlnos/Juelich/broken/M1_assembly_fused_mm.py +++ b/mrstlnos/Juelich/broken/M1_assembly_fused_mm.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -13,13 +14,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") @@ -94,7 +95,7 @@ def main(): if rank == 0: command_line = 'gmsh -3 ' + file_dir + '/mesh/' + geo_name + ' -o ' + work_dir + '/' + mesh_name +' -part ' + str(siz) - print command_line + print(command_line) tmp = shlex.split(command_line) fileout = open('gmsh.log','w') p = subprocess.Popen(tmp, stdin=subprocess.PIPE, stdout=fileout, stderr=fileout, env=os.environ, shell=False,close_fds=True) diff --git a/mrstlnos/Juelich/broken/M1_assembly_mm.py b/mrstlnos/Juelich/broken/M1_assembly_mm.py index 38f17c1c06fd614ec993e6b8104bf2c86d49a458..a095a8018ad9a972b97b14cee9b05419c9a93f65 100644 --- a/mrstlnos/Juelich/broken/M1_assembly_mm.py +++ b/mrstlnos/Juelich/broken/M1_assembly_mm.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -13,13 +14,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") @@ -96,7 +97,7 @@ def main(): if rank == 0: command_line = 'gmsh -3 ' + file_dir + '/mesh/' + geo_name + ' -o ' + work_dir + '/' + mesh_name +' -part ' + str(siz) - print command_line + print(command_line) tmp = shlex.split(command_line) fileout = open('gmsh.log','w') p = subprocess.Popen(tmp, stdin=subprocess.PIPE, stdout=fileout, stderr=fileout, env=os.environ, shell=False,close_fds=True) diff --git a/mrstlnos/Juelich/broken/M1_mirror_optic.py b/mrstlnos/Juelich/broken/M1_mirror_optic.py index 63a31066f6a8be54af8ed9a57017da8c56ff3622..677d989965fb07b77667a7bbf83769c02f388ffa 100644 --- a/mrstlnos/Juelich/broken/M1_mirror_optic.py +++ b/mrstlnos/Juelich/broken/M1_mirror_optic.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos.utilities as u import numpy as np import os @@ -77,10 +78,10 @@ def main(): optical_coefficients_2B, dz_residual_2B = u.compute_RBM_Curvature_Irreg(x_2B,y_2B,z_2B,tri_2B,dz_2B,"m",np.array([0.0365,0.017])) - print optical_coefficients_1A - print optical_coefficients_1B - print optical_coefficients_2A - print optical_coefficients_2B + print(optical_coefficients_1A) + print(optical_coefficients_1B) + print(optical_coefficients_2A) + print(optical_coefficients_2B) if __name__ == "__main__": main() diff --git a/mrstlnos/Juelich/post_process/vtk_post_process.py b/mrstlnos/Juelich/post_process/vtk_post_process.py index e1b0fdd60064415d33bd4f7e1650492969bff0b8..6945a048d5da2ef1018424fe7bab8ce0cbeaa452 100644 --- a/mrstlnos/Juelich/post_process/vtk_post_process.py +++ b/mrstlnos/Juelich/post_process/vtk_post_process.py @@ -1,3 +1,4 @@ +from __future__ import print_function import vtk import numpy as np from numpy import zeros @@ -19,7 +20,7 @@ def SaveFigureAsImage(fileName,fig=None,**kwargs): fig_size = fig.get_size_inches() w,h = fig_size[0], fig_size[1] fig.patch.set_alpha(0) - if kwargs.has_key('orig_size'): # Aspect ratio scaling if required + if 'orig_size' in kwargs: # Aspect ratio scaling if required w,h = kwargs['orig_size'] w2,h2 = fig_size[0],fig_size[1] fig.set_size_inches([(w2/w)*w,(w2/w)*h]) @@ -234,8 +235,8 @@ def post_process(): fig = plt.figure(figsize=(8, 8)) plt.set_cmap('coolwarm') axtri = plt.tripcolor(x, y, tri, sigma_zz, levels) - print "sigma_zz_unsmooth.pdf" - print levels + print("sigma_zz_unsmooth.pdf") + print(levels) plt.gca().set_aspect('equal') plt.gca().set_axis_off() plt.subplots_adjust(top = 1, bottom = 0, right = 1, left = 0, @@ -251,8 +252,8 @@ def post_process(): fig = plt.figure(figsize=(8, 8)) plt.set_cmap('coolwarm') axtri = plt.tricontourf(x, y, tri, sigma_vector_node,levels) - print "sigma_zz_smooth.pdf" - print levels + print("sigma_zz_smooth.pdf") + print(levels) plt.gca().set_aspect('equal') plt.gca().set_axis_off() plt.subplots_adjust(top = 1, bottom = 0, right = 1, left = 0, @@ -269,8 +270,8 @@ def post_process(): F_zz_2 = compute_integrated_F(10,8,0.0529999991413206, 0.0440000002272427, -0.0413666241463175,0,0,1,reader) F_zz_3 = compute_integrated_F(11,8,0.0529999991413206, 0.0440000002272427, -0.0413666241463175,0,0,1,reader) - print F_zz_1 - print F_zz_2 - print F_zz_3 + print(F_zz_1) + print(F_zz_2) + print(F_zz_3) #plt.show() diff --git a/mrstlnos/Juelich/post_process/vtk_post_process_2.py b/mrstlnos/Juelich/post_process/vtk_post_process_2.py index 7ae20b179744ef8788a967bb0dd661fa693f1183..a875c6f6c2d2d335da74b8ff443b2517ab8bca77 100644 --- a/mrstlnos/Juelich/post_process/vtk_post_process_2.py +++ b/mrstlnos/Juelich/post_process/vtk_post_process_2.py @@ -1,3 +1,4 @@ +from __future__ import print_function import vtk import numpy as np from numpy import zeros @@ -19,7 +20,7 @@ def SaveFigureAsImage(fileName,fig=None,**kwargs): fig_size = fig.get_size_inches() w,h = fig_size[0], fig_size[1] fig.patch.set_alpha(0) - if kwargs.has_key('orig_size'): # Aspect ratio scaling if required + if 'orig_size' in kwargs: # Aspect ratio scaling if required w,h = kwargs['orig_size'] w2,h2 = fig_size[0],fig_size[1] fig.set_size_inches([(w2/w)*w,(w2/w)*h]) @@ -270,8 +271,8 @@ def post_process(): plt.tricontour(y, -z, tri, T_vec, level, linestyles='-', colors='black', linewidths=0.5) axtri = plt.tricontourf(y, -z, tri, T_vec, level) - print "T" - print level+22. + print("T") + print(level+22.) plt.gca().set_aspect('equal') plt.gca().set_axis_off() plt.subplots_adjust(top = 1, bottom = 0, right = 1, left = 0, @@ -289,8 +290,8 @@ def post_process(): plt.tricontour(y, -z, tri, dx, level, linestyles='-', colors='black', linewidths=0.5) axtri = plt.tricontourf(y, -z, tri, dx, level) - print "dx" - print level + print("dx") + print(level) plt.gca().set_aspect('equal') plt.gca().set_axis_off() plt.subplots_adjust(top = 1, bottom = 0, right = 1, left = 0, @@ -307,8 +308,8 @@ def post_process(): plt.tricontour(y, -z, tri, dy, level, linestyles='-', colors='black', linewidths=0.5) axtri = plt.tricontourf(y, -z, tri, dy, level) - print "dy" - print level + print("dy") + print(level) plt.gca().set_aspect('equal') plt.gca().set_axis_off() plt.subplots_adjust(top = 1, bottom = 0, right = 1, left = 0, @@ -325,8 +326,8 @@ def post_process(): plt.tricontour(y, -z, tri, dz, level, linestyles='-', colors='black', linewidths=0.5) axtri = plt.tricontourf(y, -z, tri, dz, level) - print "dz" - print level + print("dz") + print(level) plt.gca().set_aspect('equal') plt.gca().set_axis_off() plt.subplots_adjust(top = 1, bottom = 0, right = 1, left = 0, @@ -356,8 +357,8 @@ def post_process(): fig = plt.figure(figsize=(8, 8)) plt.set_cmap('coolwarm') axtri = plt.tripcolor(y, -z, tri, volume_id_vec_2) - print "volume_id.png" - print level + print("volume_id.png") + print(level) plt.gca().set_aspect('equal') plt.gca().set_axis_off() plt.subplots_adjust(top = 1, bottom = 0, right = 1, left = 0, @@ -422,8 +423,8 @@ def post_process(): plt.plot([0.0591792, 0.0591792], [0.0474981, 0.0542711], 'r-', lw=linewidth) plt.plot([0.0708312, 0.0708312], [0.0474981, 0.0542711], 'r-', lw=linewidth) - print "volume_id_with_contact.png" - print level + print("volume_id_with_contact.png") + print(level) plt.gca().set_aspect('equal') plt.gca().set_axis_off() plt.subplots_adjust(top = 1, bottom = 0, right = 1, left = 0,hspace = 0, wspace = 0) @@ -438,8 +439,8 @@ def post_process(): fig = plt.figure(figsize=(8, 8)) plt.set_cmap('coolwarm') axtri = plt.tripcolor(y+100*dy, -z-100*dz, tri, volume_id_vec_2) - print "volume_id_def.png" - print level + print("volume_id_def.png") + print(level) plt.gca().set_aspect('equal') plt.gca().set_axis_off() plt.subplots_adjust(top = 1, bottom = 0, right = 1, left = 0, @@ -454,8 +455,8 @@ def post_process(): fig = plt.figure(figsize=(8, 8)) plt.set_cmap('coolwarm') axtri = plt.tripcolor(y, -z, tri, sigma_zz, level) - print "sigma_zz_unsmooth_2" - print level + print("sigma_zz_unsmooth_2") + print(level) plt.gca().set_aspect('equal') plt.gca().set_axis_off() plt.subplots_adjust(top = 1, bottom = 0, right = 1, left = 0, @@ -469,8 +470,8 @@ def post_process(): fig = plt.figure(figsize=(8, 8)) plt.set_cmap('coolwarm') axtri = plt.tripcolor(y, -z, tri, sigma_zz_filtered, level) - print "sigma_zz_filtered.pdf" - print level + print("sigma_zz_filtered.pdf") + print(level) plt.gca().set_aspect('equal') plt.gca().set_axis_off() plt.subplots_adjust(top = 1, bottom = 0, right = 1, left = 0, @@ -487,8 +488,8 @@ def post_process(): fig = plt.figure(figsize=(8, 8)) plt.set_cmap('coolwarm') axtri = plt.tricontourf(y, -z, tri, sigma_vector_node,level) - print "sigma_zz_smooth_2" - print level + print("sigma_zz_smooth_2") + print(level) plt.gca().set_aspect('equal') plt.gca().set_axis_off() plt.subplots_adjust(top = 1, bottom = 0, right = 1, left = 0, @@ -503,8 +504,8 @@ def post_process(): fig = plt.figure(figsize=(8, 8)) plt.set_cmap('coolwarm') axtri = plt.tricontourf(y, -z, tri, sigma_vector_node_filtered,level) - print "sigma_vector_node_filtered" - print level + print("sigma_vector_node_filtered") + print(level) plt.gca().set_aspect('equal') plt.gca().set_axis_off() plt.subplots_adjust(top = 1, bottom = 0, right = 1, left = 0, @@ -541,8 +542,8 @@ def post_process_mirror(): plt.tricontour(x, y, tri, dx, level, linestyles='-', colors='black', linewidths=0.5) axtri = plt.tricontourf(x, y, tri, dx, level) - print "dx" - print level*1000 + print("dx") + print(level*1000) plt.gca().set_aspect('equal') plt.gca().set_axis_off() plt.subplots_adjust(top = 1, bottom = 0, right = 1, left = 0, @@ -559,8 +560,8 @@ def post_process_mirror(): plt.tricontour(x, y, tri, dy, level, linestyles='-', colors='black', linewidths=0.5) axtri = plt.tricontourf(x, y, tri, dy, level) - print "dy" - print level*1000 + print("dy") + print(level*1000) plt.gca().set_aspect('equal') plt.gca().set_axis_off() plt.subplots_adjust(top = 1, bottom = 0, right = 1, left = 0, @@ -577,8 +578,8 @@ def post_process_mirror(): plt.tricontour(x, y, tri, dz, level, linestyles='-', colors='black', linewidths=0.5) axtri = plt.tricontourf(x, y, tri, dz, level) - print "dz" - print level*1000 + print("dz") + print(level*1000) plt.gca().set_aspect('equal') plt.gca().set_axis_off() plt.subplots_adjust(top = 1, bottom = 0, right = 1, left = 0, @@ -596,8 +597,8 @@ def post_process_mirror(): plt.tricontour(x, y, tri, dz, level, linestyles='-', colors='black', linewidths=0.5) axtri = plt.tricontourf(x, y, tri, dz, level) - print "dz" - print level*1000 + print("dz") + print(level*1000) plt.gca().set_aspect('equal') plt.gca().set_axis_off() plt.subplots_adjust(top = 1, bottom = 0, right = 1, left = 0, diff --git a/mrstlnos/Juelich/tests/M1_assembly_fused.py b/mrstlnos/Juelich/tests/M1_assembly_fused.py index 860474cce4cbeddf1ca4186351807534623bd871..7e934725808b6efc6391dd23e44fddc435800f3b 100644 --- a/mrstlnos/Juelich/tests/M1_assembly_fused.py +++ b/mrstlnos/Juelich/tests/M1_assembly_fused.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -13,13 +14,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") @@ -62,7 +63,7 @@ def main(): # We have to distribute the work among MPI process if rank == 0: command_line = 'gmsh -3 ' + geo_dir + '/' + geo_name + ' -o ' + work_dir + '/' + mesh_name +' -part ' + str(siz) - print command_line + print(command_line) tmp = shlex.split(command_line) fileout = open('gmsh.log','w') p = subprocess.Popen(tmp, stdin=subprocess.PIPE, stdout=fileout, stderr=fileout, env=os.environ, shell=False,close_fds=True) @@ -182,9 +183,9 @@ def main(): post_process() from mrstlnos.Juelich.post_process.vtk_post_process_2 import post_process_mirror post_process_mirror() - print "Post processing has been performed" + print("Post processing has been performed") except: - print "No post processing has been performed" + print("No post processing has been performed") if __name__ == "__main__": main() diff --git a/mrstlnos/Juelich/tests/M1_assembly_fused_2.py b/mrstlnos/Juelich/tests/M1_assembly_fused_2.py index 852d97e702bbb7ea062deafbef6296bb64b6c0a5..4c147788b6cc15b490990e2b754f26aafc91b8f1 100644 --- a/mrstlnos/Juelich/tests/M1_assembly_fused_2.py +++ b/mrstlnos/Juelich/tests/M1_assembly_fused_2.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -13,13 +14,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") from fwk.wutils import parseargs args=parseargs() @@ -60,7 +61,7 @@ def main(): # We have to distribute the work among MPI process if rank == 0: command_line = 'gmsh -3 ' + geo_dir + '/' + geo_name + ' -o ' + work_dir + '/' + mesh_name +' -part ' + str(siz) - print command_line + print(command_line) tmp = shlex.split(command_line) fileout = open('gmsh.log','w') p = subprocess.Popen(tmp, stdin=subprocess.PIPE, stdout=fileout, stderr=fileout, env=os.environ, shell=False,close_fds=True) @@ -178,9 +179,9 @@ def main(): post_process() from mrstlnos.Juelich.post_process.vtk_post_process_2 import post_process_mirror post_process_mirror() - print "Post processing has been performed" + print("Post processing has been performed") except: - print "No post processing has been performed" + print("No post processing has been performed") if __name__ == "__main__": main() diff --git a/mrstlnos/Juelich/tests/M1_assembly_fused_CuCrZr_holder.py b/mrstlnos/Juelich/tests/M1_assembly_fused_CuCrZr_holder.py index f07bedbf29dec7c1d9cc2488ecb88c42960ac623..d183fb4874b57f0ae60fa87b1f767bfc1a5d0255 100644 --- a/mrstlnos/Juelich/tests/M1_assembly_fused_CuCrZr_holder.py +++ b/mrstlnos/Juelich/tests/M1_assembly_fused_CuCrZr_holder.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -13,13 +14,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") @@ -62,7 +63,7 @@ def main(): # We have to distribute the work among MPI process if rank == 0: command_line = 'gmsh -3 ' + geo_dir + '/' + geo_name + ' -o ' + work_dir + '/' + mesh_name +' -part ' + str(siz) - print command_line + print(command_line) tmp = shlex.split(command_line) fileout = open('gmsh.log','w') p = subprocess.Popen(tmp, stdin=subprocess.PIPE, stdout=fileout, stderr=fileout, env=os.environ, shell=False,close_fds=True) @@ -180,9 +181,9 @@ def main(): post_process() from mrstlnos.Juelich.post_process.vtk_post_process_2 import post_process_mirror post_process_mirror() - print "Post processing has been performed" + print("Post processing has been performed") except: - print "No post processing has been performed" + print("No post processing has been performed") if __name__ == "__main__": main() diff --git a/mrstlnos/Juelich/tests/M1_assembly_fused_CuCrZr_holder_2.py b/mrstlnos/Juelich/tests/M1_assembly_fused_CuCrZr_holder_2.py index 58d5b77750372ed491c49ea32cca84d4a3a32fe1..35268d46410b7b77e47d7421df0956189983df8e 100644 --- a/mrstlnos/Juelich/tests/M1_assembly_fused_CuCrZr_holder_2.py +++ b/mrstlnos/Juelich/tests/M1_assembly_fused_CuCrZr_holder_2.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -13,13 +14,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") @@ -64,7 +65,7 @@ def main(): # We have to distribute the work among MPI process if rank == 0: command_line = 'gmsh -3 ' + geo_dir + '/' + geo_name + ' -o ' + work_dir + '/' + mesh_name +' -part ' + str(siz) - print command_line + print(command_line) tmp = shlex.split(command_line) fileout = open('gmsh.log','w') p = subprocess.Popen(tmp, stdin=subprocess.PIPE, stdout=fileout, stderr=fileout, env=os.environ, shell=False,close_fds=True) @@ -183,9 +184,9 @@ def main(): post_process() from mrstlnos.Juelich.post_process.vtk_post_process_2 import post_process_mirror post_process_mirror() - print "Post processing has been performed" + print("Post processing has been performed") except: - print "No post processing has been performed" + print("No post processing has been performed") if __name__ == "__main__": main() diff --git a/mrstlnos/__init__.py b/mrstlnos/__init__.py index f78094a6f84200a1a3eb768707283c10b260b8cb..299b79a146b59fffcbf65078eda048e22bbbe496 100644 --- a/mrstlnos/__init__.py +++ b/mrstlnos/__init__.py @@ -1,9 +1,10 @@ # -*- coding: latin-1; -*- # mrstlnos MODULE initialization file +from __future__ import print_function import fwk import tbox try: from mrstlnosw import * except: - print 'mrstlnosw is not imported, this build is only enough for python post processing' + print('mrstlnosw is not imported, this build is only enough for python post processing') diff --git a/mrstlnos/broken/2_cubes.py b/mrstlnos/broken/2_cubes.py index 3a10ecddb48d6acda97529b3e81aec19b0bfefbb..a1663d32f32daeb3182c748c98a7b327a6b5d81d 100644 --- a/mrstlnos/broken/2_cubes.py +++ b/mrstlnos/broken/2_cubes.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -14,13 +15,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") @@ -45,7 +46,7 @@ def main(): if rank == 0: command_line = 'gmsh -3 ' + work_dir + '/' + mesh_name + ' -o ' + work_dir + '/' + partitioned_mesh_name +' -part ' + str(siz) - print command_line + print(command_line) tmp = shlex.split(command_line) fileout = open('gmsh.log','w') p = subprocess.Popen(tmp, stdin=subprocess.PIPE, stdout=fileout, stderr=fileout, env=os.environ, shell=False,close_fds=True) diff --git a/mrstlnos/broken/2_cubes_heat.py b/mrstlnos/broken/2_cubes_heat.py index 0831abda16a4b3390328f702cc1937adef00cfb7..4759685a0cb36f1aa4abaf3bae10a0de6469715c 100644 --- a/mrstlnos/broken/2_cubes_heat.py +++ b/mrstlnos/broken/2_cubes_heat.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -14,13 +15,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") @@ -45,7 +46,7 @@ def main(): if rank == 0: command_line = 'gmsh -3 ' + work_dir + '/' + mesh_name + ' -o ' + work_dir + '/' + partitioned_mesh_name +' -part ' + str(siz) - print command_line + print(command_line) tmp = shlex.split(command_line) fileout = open('gmsh.log','w') p = subprocess.Popen(tmp, stdin=subprocess.PIPE, stdout=fileout, stderr=fileout, env=os.environ, shell=False,close_fds=True) diff --git a/mrstlnos/broken/2_cubes_no_contact.py b/mrstlnos/broken/2_cubes_no_contact.py index 24000f052f53e58c35cba62bdbc20b268176af9f..5cd0c9e2fa785bb3df3f5ed9213d77346e6232bc 100644 --- a/mrstlnos/broken/2_cubes_no_contact.py +++ b/mrstlnos/broken/2_cubes_no_contact.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -14,13 +15,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") @@ -45,7 +46,7 @@ def main(): if rank == 0: command_line = 'gmsh -3 ' + work_dir + '/' + mesh_name + ' -o ' + work_dir + '/' + partitioned_mesh_name +' -part ' + str(siz) - print command_line + print(command_line) tmp = shlex.split(command_line) fileout = open('gmsh.log','w') p = subprocess.Popen(tmp, stdin=subprocess.PIPE, stdout=fileout, stderr=fileout, env=os.environ, shell=False,close_fds=True) diff --git a/mrstlnos/broken/2_cubes_patch_SIMPLE_k.py b/mrstlnos/broken/2_cubes_patch_SIMPLE_k.py index ee068ca1c1cb0de81681206f1267f37fa7e7681d..bad79e2632b53468713b8e76ff620e624bbfb9ed 100644 --- a/mrstlnos/broken/2_cubes_patch_SIMPLE_k.py +++ b/mrstlnos/broken/2_cubes_patch_SIMPLE_k.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -14,13 +15,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") @@ -45,7 +46,7 @@ def main(): if rank == 0: command_line = 'gmsh -3 ' + work_dir + '/' + mesh_name + ' -o ' + work_dir + '/' + partitioned_mesh_name +' -part ' + str(siz) - print command_line + print(command_line) tmp = shlex.split(command_line) fileout = open('gmsh.log','w') p = subprocess.Popen(tmp, stdin=subprocess.PIPE, stdout=fileout, stderr=fileout, env=os.environ, shell=False,close_fds=True) diff --git a/mrstlnos/broken/2_cubes_sticking.py b/mrstlnos/broken/2_cubes_sticking.py index 2daca8e6c37d83acc9c21d5a535e5e16777cdd06..ba196364613528a132d4df39e06457d525566963 100644 --- a/mrstlnos/broken/2_cubes_sticking.py +++ b/mrstlnos/broken/2_cubes_sticking.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -14,13 +15,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") @@ -45,7 +46,7 @@ def main(): if rank == 0: command_line = 'gmsh -3 ' + work_dir + '/' + mesh_name + ' -o ' + work_dir + '/' + partitioned_mesh_name +' -part ' + str(siz) - print command_line + print(command_line) tmp = shlex.split(command_line) fileout = open('gmsh.log','w') p = subprocess.Popen(tmp, stdin=subprocess.PIPE, stdout=fileout, stderr=fileout, env=os.environ, shell=False,close_fds=True) diff --git a/mrstlnos/broken/3_bodies.py b/mrstlnos/broken/3_bodies.py index 3ebb258c15ac74e29747c212d30e29fef5174320..5b1c6f1b3c648db3c8f562d8db5eaa7190a192d7 100644 --- a/mrstlnos/broken/3_bodies.py +++ b/mrstlnos/broken/3_bodies.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -13,13 +14,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") from fwk.wutils import parseargs @@ -82,7 +83,7 @@ def main(): if rank == 0: command_line = 'gmsh -3 ' + file_dir + '/' + geo_name + ' -o ' + work_dir + '/' + mesh_name +' -part ' + str(siz) - print command_line + print(command_line) tmp = shlex.split(command_line) fileout = open('gmsh.log','w') p = subprocess.Popen(tmp, stdin=subprocess.PIPE, stdout=fileout, stderr=fileout, env=os.environ, shell=False,close_fds=True) diff --git a/mrstlnos/broken/3_cubes_partial_sticking.py b/mrstlnos/broken/3_cubes_partial_sticking.py index 43477e1ad8d710d21869dcdc6ad38f459182ef38..cf0290fc43b8a44d54c5b7dc53ec9a1ddf92797f 100644 --- a/mrstlnos/broken/3_cubes_partial_sticking.py +++ b/mrstlnos/broken/3_cubes_partial_sticking.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -14,13 +15,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") @@ -45,7 +46,7 @@ def main(): if rank == 0: command_line = 'gmsh -3 ' + work_dir + '/' + mesh_name + ' -o ' + work_dir + '/' + partitioned_mesh_name +' -part ' + str(siz) - print command_line + print(command_line) tmp = shlex.split(command_line) fileout = open('gmsh.log','w') p = subprocess.Popen(tmp, stdin=subprocess.PIPE, stdout=fileout, stderr=fileout, env=os.environ, shell=False,close_fds=True) diff --git a/mrstlnos/broken/L_shape_curv.py b/mrstlnos/broken/L_shape_curv.py index 996a13a190244f42a6a19b108f54a625ca7ede43..1de618994fa3fb7017697f9dcdeb1d31a0c1f6da 100644 --- a/mrstlnos/broken/L_shape_curv.py +++ b/mrstlnos/broken/L_shape_curv.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -19,16 +20,16 @@ def read_msh(index_nodes,index_elements,index_tags,filename,filename_output): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") if rank == 0: command_line = 'gmsh -3 ' + file_dir + '/' + filename + ' -o ' + work_dir + '/' + filename_output - print command_line + print(command_line) tmp = shlex.split(command_line) fileout = open('gmsh.log','w') p = subprocess.Popen(tmp, stdin=subprocess.PIPE, stdout=fileout, stderr=fileout, env=os.environ, shell=False,close_fds=True) @@ -75,16 +76,16 @@ def fuse_meshes(filename1,filename12,filename2,filename22,filename_output): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") if rank == 0: command_line = 'gmsh -3 ' + work_dir + '/' + filename12 + ' ' + work_dir + '/' + filename22 + ' -o ' + work_dir + '/' + filename_output - print command_line + print(command_line) tmp = shlex.split(command_line) fileout = open('gmsh.log','w') p = subprocess.Popen(tmp, stdin=subprocess.PIPE, stdout=fileout, stderr=fileout, env=os.environ, shell=False,close_fds=True) @@ -106,13 +107,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") from fwk.wutils import parseargs args=parseargs() diff --git a/mrstlnos/broken/L_shape_curv_rf.py b/mrstlnos/broken/L_shape_curv_rf.py index 049420dfba95045aec257fa615181ce76da942f4..c6edad5c09f3208f22eb787042cfd76a58886106 100644 --- a/mrstlnos/broken/L_shape_curv_rf.py +++ b/mrstlnos/broken/L_shape_curv_rf.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -19,16 +20,16 @@ def read_msh(index_nodes,index_elements,index_tags,filename,filename_output): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") if rank == 0: command_line = 'gmsh -3 ' + file_dir + '/' + filename + ' -o ' + work_dir + '/' + filename_output - print command_line + print(command_line) tmp = shlex.split(command_line) fileout = open('gmsh.log','w') p = subprocess.Popen(tmp, stdin=subprocess.PIPE, stdout=fileout, stderr=fileout, env=os.environ, shell=False,close_fds=True) @@ -75,16 +76,16 @@ def fuse_meshes(filename1,filename12,filename2,filename22,filename_output): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") if rank == 0: command_line = 'gmsh -3 ' + work_dir + '/' + filename12 + ' ' + work_dir + '/' + filename22 + ' -o ' + work_dir + '/' + filename_output - print command_line + print(command_line) tmp = shlex.split(command_line) fileout = open('gmsh.log','w') p = subprocess.Popen(tmp, stdin=subprocess.PIPE, stdout=fileout, stderr=fileout, env=os.environ, shell=False,close_fds=True) @@ -106,13 +107,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") from fwk.wutils import parseargs args=parseargs() diff --git a/mrstlnos/broken/M1.py b/mrstlnos/broken/M1.py index 6756e93f0d21002a72ad537927d691ccfbaa7edd..55d5a6c93e4721ffd09082b837f08f7734252d6c 100644 --- a/mrstlnos/broken/M1.py +++ b/mrstlnos/broken/M1.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -13,13 +14,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") @@ -102,7 +103,7 @@ def main(): if rank == 0: command_line = 'gmsh -3 ' + file_dir + '/mesh/' + geo_name + ' -o ' + work_dir + '/' + mesh_name +' -part ' + str(siz) - print command_line + print(command_line) tmp = shlex.split(command_line) fileout = open('gmsh.log','w') p = subprocess.Popen(tmp, stdin=subprocess.PIPE, stdout=fileout, stderr=fileout, env=os.environ, shell=False,close_fds=True) diff --git a/mrstlnos/broken/M1_assembly.py b/mrstlnos/broken/M1_assembly.py index 39e09d5642cd0aa5358211e59d432baf7fcdd7f9..492afa891948c8b0bbde21e0da46c9c6b7b3a9a8 100644 --- a/mrstlnos/broken/M1_assembly.py +++ b/mrstlnos/broken/M1_assembly.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -13,13 +14,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") @@ -102,7 +103,7 @@ def main(): if rank == 0: command_line = 'gmsh -3 ' + file_dir + '/mesh/' + geo_name + ' -o ' + work_dir + '/' + mesh_name +' -part ' + str(siz) - print command_line + print(command_line) tmp = shlex.split(command_line) fileout = open('gmsh.log','w') p = subprocess.Popen(tmp, stdin=subprocess.PIPE, stdout=fileout, stderr=fileout, env=os.environ, shell=False,close_fds=True) diff --git a/mrstlnos/broken/M1_assembly_fused.py b/mrstlnos/broken/M1_assembly_fused.py index 37761f5f5e92f485b56411e318da2005ee744d3d..b8e4ebe9d8f6b75b01ece1959e6de015936a388b 100644 --- a/mrstlnos/broken/M1_assembly_fused.py +++ b/mrstlnos/broken/M1_assembly_fused.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -13,13 +14,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") @@ -234,15 +235,15 @@ def main(): plt_linewidth = 4.0 - print max(z) - print min(z) + print(max(z)) + print(min(z)) - print max(sol[:,2]) - print min(sol[:,2]) + print(max(sol[:,2])) + print(min(sol[:,2])) - print Zernike_coeff + print(Zernike_coeff) - print u.check_optical_tolerance(Zernike_coeff, Zernike_functions, sol[:,2],"m") + print(u.check_optical_tolerance(Zernike_coeff, Zernike_functions, sol[:,2],"m")) levels = np.linspace(min(dz_irreg), max(dz_irreg), 15) # Velocity x-component @@ -292,27 +293,27 @@ def main(): figurewidth = '\\figurewidth' ) - print "ux" - print max(sol[:,which_dof]) - print min(sol[:,which_dof]) + print("ux") + print(max(sol[:,which_dof])) + print(min(sol[:,which_dof])) elif which_dof == 1: #cb.set_label('displacement along y [m]', rotation=0) plt.savefig("uy.pdf", transparent=True, bbox_inches='tight', pad_inches=0.05) - print "uy" - print max(sol[:,which_dof]) - print min(sol[:,which_dof]) + print("uy") + print(max(sol[:,which_dof])) + print(min(sol[:,which_dof])) elif which_dof == 2: #cb.set_label('displacement along z [m]', rotation=0) plt.savefig("uz.pdf", transparent=True, bbox_inches='tight', pad_inches=0.05) - print "uz" - print max(sol[:,which_dof]) - print min(sol[:,which_dof]) + print("uz") + print(max(sol[:,which_dof])) + print(min(sol[:,which_dof])) elif which_dof == 3: #cb.set_label('Temperature [C]', rotation=0) plt.savefig("T.pdf", transparent=True, bbox_inches='tight', pad_inches=0.05) - print "T" - print max(sol[:,which_dof]) - print min(sol[:,which_dof]) + print("T") + print(max(sol[:,which_dof])) + print(min(sol[:,which_dof])) #plt.minorticks_on() #plt.gca().set_xticklabels([]) diff --git a/mrstlnos/broken/M1_assembly_fused_CuCrZr_holder.py b/mrstlnos/broken/M1_assembly_fused_CuCrZr_holder.py index bbbcbe8886619ae9cfd16e17bbd9f5cc0bf6629b..f3bd163e30b8948b05b9354cc5a18045fe6c6971 100644 --- a/mrstlnos/broken/M1_assembly_fused_CuCrZr_holder.py +++ b/mrstlnos/broken/M1_assembly_fused_CuCrZr_holder.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -13,13 +14,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") @@ -239,15 +240,15 @@ def main(): plt_linewidth = 4.0 - print max(z) - print min(z) + print(max(z)) + print(min(z)) - print max(sol[:,2]) - print min(sol[:,2]) + print(max(sol[:,2])) + print(min(sol[:,2])) - print Zernike_coeff + print(Zernike_coeff) - print u.check_optical_tolerance(Zernike_coeff, Zernike_functions, sol[:,2],"m") + print(u.check_optical_tolerance(Zernike_coeff, Zernike_functions, sol[:,2],"m")) for which_dof in range(0,DOFperNode): @@ -283,27 +284,27 @@ def main(): figurewidth = '\\figurewidth' ) - print "ux" - print max(sol[:,which_dof]) - print min(sol[:,which_dof]) + print("ux") + print(max(sol[:,which_dof])) + print(min(sol[:,which_dof])) elif which_dof == 1: #cb.set_label('displacement along y [m]', rotation=0) plt.savefig("uy.pdf", transparent=True, bbox_inches='tight', pad_inches=0.05) - print "uy" - print max(sol[:,which_dof]) - print min(sol[:,which_dof]) + print("uy") + print(max(sol[:,which_dof])) + print(min(sol[:,which_dof])) elif which_dof == 2: #cb.set_label('displacement along z [m]', rotation=0) plt.savefig("uz.pdf", transparent=True, bbox_inches='tight', pad_inches=0.05) - print "uz" - print max(sol[:,which_dof]) - print min(sol[:,which_dof]) + print("uz") + print(max(sol[:,which_dof])) + print(min(sol[:,which_dof])) elif which_dof == 3: #cb.set_label('Temperature [C]', rotation=0) plt.savefig("T.pdf", transparent=True, bbox_inches='tight', pad_inches=0.05) - print "T" - print max(sol[:,which_dof]) - print min(sol[:,which_dof]) + print("T") + print(max(sol[:,which_dof])) + print(min(sol[:,which_dof])) #plt.minorticks_on() #plt.gca().set_xticklabels([]) diff --git a/mrstlnos/broken/M1_assembly_fused_all.py b/mrstlnos/broken/M1_assembly_fused_all.py index f3472a8186a3f3235bc681ffd81ab0d4cbaf3695..720fe961b9d36ffc843cf189b8fdab77e16d8d77 100644 --- a/mrstlnos/broken/M1_assembly_fused_all.py +++ b/mrstlnos/broken/M1_assembly_fused_all.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -13,13 +14,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") @@ -94,7 +95,7 @@ def main(): if rank == 0: command_line = 'gmsh -3 ' + file_dir + '/mesh/' + geo_name + ' -o ' + work_dir + '/' + mesh_name +' -part ' + str(siz) - print command_line + print(command_line) tmp = shlex.split(command_line) fileout = open('gmsh.log','w') p = subprocess.Popen(tmp, stdin=subprocess.PIPE, stdout=fileout, stderr=fileout, env=os.environ, shell=False,close_fds=True) diff --git a/mrstlnos/broken/M1_assembly_fused_mm.py b/mrstlnos/broken/M1_assembly_fused_mm.py index 0b8df7a319a426679b5c4cb377d18dee86627ad3..ca884b94e7401eb49b8b0c61c4647832746456a8 100644 --- a/mrstlnos/broken/M1_assembly_fused_mm.py +++ b/mrstlnos/broken/M1_assembly_fused_mm.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -13,13 +14,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") @@ -94,7 +95,7 @@ def main(): if rank == 0: command_line = 'gmsh -3 ' + file_dir + '/mesh/' + geo_name + ' -o ' + work_dir + '/' + mesh_name +' -part ' + str(siz) - print command_line + print(command_line) tmp = shlex.split(command_line) fileout = open('gmsh.log','w') p = subprocess.Popen(tmp, stdin=subprocess.PIPE, stdout=fileout, stderr=fileout, env=os.environ, shell=False,close_fds=True) diff --git a/mrstlnos/broken/M1_assembly_mm.py b/mrstlnos/broken/M1_assembly_mm.py index 38f17c1c06fd614ec993e6b8104bf2c86d49a458..a095a8018ad9a972b97b14cee9b05419c9a93f65 100644 --- a/mrstlnos/broken/M1_assembly_mm.py +++ b/mrstlnos/broken/M1_assembly_mm.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -13,13 +14,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") @@ -96,7 +97,7 @@ def main(): if rank == 0: command_line = 'gmsh -3 ' + file_dir + '/mesh/' + geo_name + ' -o ' + work_dir + '/' + mesh_name +' -part ' + str(siz) - print command_line + print(command_line) tmp = shlex.split(command_line) fileout = open('gmsh.log','w') p = subprocess.Popen(tmp, stdin=subprocess.PIPE, stdout=fileout, stderr=fileout, env=os.environ, shell=False,close_fds=True) diff --git a/mrstlnos/broken/beam.py b/mrstlnos/broken/beam.py index 843375e0547ea835b0c3f87c900e35616cbc2fcb..05fdfee5970cfad22ee9c147e59fac115f1c646e 100644 --- a/mrstlnos/broken/beam.py +++ b/mrstlnos/broken/beam.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -45,13 +46,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") from fwk.wutils import parseargs @@ -96,7 +97,7 @@ def main(): if rank == 0: command_line = 'gmsh -3 ' + work_dir + '/' + mesh_name + ' -o ' + work_dir + '/' + partitioned_mesh_name +' -part ' + str(siz) - print command_line + print(command_line) tmp = shlex.split(command_line) fileout = open('gmsh.log','w') p = subprocess.Popen(tmp, stdin=subprocess.PIPE, stdout=fileout, stderr=fileout, env=os.environ, shell=False,close_fds=True) diff --git a/mrstlnos/broken/beam_2.py b/mrstlnos/broken/beam_2.py index 0bcca03fd84ba7456cef77acacbfbec68b1aaf44..3248c09ddce51ff88fc4477f37b6ad2190fbd697 100644 --- a/mrstlnos/broken/beam_2.py +++ b/mrstlnos/broken/beam_2.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -15,15 +16,15 @@ def analytical(E,nu,L,W,H,d,p,x): q_2 = 72*EI*d/L**4 a = (72*EI*d/q)**(0.25) - print a + print(a) - print E - print nu - print L - print W - print H - print d - print p + print(E) + print(nu) + print(L) + print(W) + print(H) + print(d) + print(p) if q < q_1: case_id = 1 @@ -38,10 +39,10 @@ def analytical(E,nu,L,W,H,d,p,x): if x[i] >= a: sol[i] = -d - print "q" - print q - print q_1 - print q_2 + print("q") + print(q) + print(q_1) + print(q_2) return case_id, sol @@ -65,13 +66,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") from fwk.wutils import parseargs @@ -116,7 +117,7 @@ def main(): if rank == 0: command_line = 'gmsh -3 ' + work_dir + '/' + mesh_name + ' -o ' + work_dir + '/' + partitioned_mesh_name +' -part ' + str(siz) - print command_line + print(command_line) tmp = shlex.split(command_line) fileout = open('gmsh.log','w') p = subprocess.Popen(tmp, stdin=subprocess.PIPE, stdout=fileout, stderr=fileout, env=os.environ, shell=False,close_fds=True) diff --git a/mrstlnos/broken/beam_UQ_1.py b/mrstlnos/broken/beam_UQ_1.py index d86faddbf6dffe3d0d69695330ce0da3fdc94d6d..ede031012cb5e074f5ae2dc8e2fee05520845987 100644 --- a/mrstlnos/broken/beam_UQ_1.py +++ b/mrstlnos/broken/beam_UQ_1.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -14,15 +15,15 @@ def analytical(E,nu,L,W,H,d,p,x): q_2 = 72*EI*d/L**4 a = (72*EI*d/q)**(0.25) - print a + print(a) - print E - print nu - print L - print W - print H - print d - print p + print(E) + print(nu) + print(L) + print(W) + print(H) + print(d) + print(p) if q < q_1: case_id = 1 @@ -37,10 +38,10 @@ def analytical(E,nu,L,W,H,d,p,x): if x[i] >= a: sol[i] = -d - print "q" - print q - print q_1 - print q_2 + print("q") + print(q) + print(q_1) + print(q_2) return case_id, sol @@ -64,13 +65,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") from fwk.wutils import parseargs @@ -130,7 +131,7 @@ def main(): if rank == 0: command_line = 'gmsh -3 ' + work_dir + '/' + mesh_name + ' -o ' + work_dir + '/' + partitioned_mesh_name +' -part ' + str(siz) - print command_line + print(command_line) tmp = shlex.split(command_line) fileout = open('gmsh.log','w') p = subprocess.Popen(tmp, stdin=subprocess.PIPE, stdout=fileout, stderr=fileout, env=os.environ, shell=False,close_fds=True) @@ -149,12 +150,7 @@ def main(): n1.row = n1.no-1 - -<<<<<<< HEAD - for i in range(0,len(x)): -======= for i in range(5,len(x)): ->>>>>>> 3b3777b71c71f67fe62bff65bea2213817e3eaf8 for j in range(0,len(x)): pbl = m.Problem(msh,comm) @@ -202,12 +198,8 @@ def main(): solverList['Output Style'] = 1 solverList['Output Frequency'] = 1 -<<<<<<< HEAD #solverList["MueLu xml file name"] = file_dir + '/nested_multigrid_2_lvls.xml' solverList["MueLu xml file name"] = file_dir + '/nested_multigrid_2_lvls_chebyshev.xml' -======= - solverList["MueLu xml file name"] = file_dir + '/nested_multigrid_2_lvls.xml' ->>>>>>> 3b3777b71c71f67fe62bff65bea2213817e3eaf8 solverList["convert MueLu xml file"] = True solverList['Use preconditioner'] = True @@ -236,15 +228,11 @@ def main(): m.Medium(pbl, "Rigid body", "Mat 1",E,nu,k,d) slv = m.IterativeSolver(pbl,args.k,solverList,DOFperNode, False, 1) - -<<<<<<< HEAD + slv.start() -======= - #slv.start() ->>>>>>> 3b3777b71c71f67fe62bff65bea2213817e3eaf8 f = open('timers.txt', 'w') - print >>f, slv.tms + print(slv.tms, file=f) f.closed diff --git a/mrstlnos/broken/beam_UQ_QMC_1.py b/mrstlnos/broken/beam_UQ_QMC_1.py index 90140200fb93d172cf01764d00d00f5fdce8c910..822cf348f7ea45bc63af4ac3de3805513aa1e7e7 100644 --- a/mrstlnos/broken/beam_UQ_QMC_1.py +++ b/mrstlnos/broken/beam_UQ_QMC_1.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -14,13 +15,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") from fwk.wutils import parseargs @@ -87,7 +88,7 @@ def main(): if rank == 0: command_line = 'gmsh -3 ' + work_dir + '/' + mesh_name + ' -o ' + work_dir + '/' + partitioned_mesh_name +' -part ' + str(siz) - print command_line + print(command_line) tmp = shlex.split(command_line) fileout = open('gmsh.log','w') p = subprocess.Popen(tmp, stdin=subprocess.PIPE, stdout=fileout, stderr=fileout, env=os.environ, shell=False,close_fds=True) @@ -187,12 +188,12 @@ def main(): slv.start() f = open('timers.txt', 'w') - print >>f, slv.tms + print(slv.tms, file=f) f.closed f = open('parameters_values.txt', 'w') - print >>f, E - print >>f, p + print(E, file=f) + print(p, file=f) f.closed os.rename('x_mm.txt', 'x_mm_'+str(i)+'.txt') diff --git a/mrstlnos/broken/beam_UQ_QMC_16.py b/mrstlnos/broken/beam_UQ_QMC_16.py index 1767aac30654a3756a94a8a33bb07f5dc25d455b..a33fa5284beb39d66f0b62a7894c578347684c5a 100644 --- a/mrstlnos/broken/beam_UQ_QMC_16.py +++ b/mrstlnos/broken/beam_UQ_QMC_16.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -14,13 +15,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") from fwk.wutils import parseargs @@ -87,7 +88,7 @@ def main(): if rank == 0: command_line = 'gmsh -3 ' + work_dir + '/' + mesh_name + ' -o ' + work_dir + '/' + partitioned_mesh_name +' -part ' + str(siz) - print command_line + print(command_line) tmp = shlex.split(command_line) fileout = open('gmsh.log','w') p = subprocess.Popen(tmp, stdin=subprocess.PIPE, stdout=fileout, stderr=fileout, env=os.environ, shell=False,close_fds=True) @@ -192,12 +193,12 @@ def main(): slv.start() f = open('timers.txt', 'w') - print >>f, slv.tms + print(slv.tms, file=f) f.closed f = open('parameters_values.txt', 'w') - print >>f, E - print >>f, p + print(E, file=f) + print(p, file=f) f.closed os.rename('x_mm.txt', 'x_mm_'+str(i)+'.txt') diff --git a/mrstlnos/broken/beam_UQ_QMC_32.py b/mrstlnos/broken/beam_UQ_QMC_32.py index 0d8af8820a0a7d73541a191998e61ffc7c5896aa..593be6f325f1c09fc6da9067f5e873ceb74cd963 100644 --- a/mrstlnos/broken/beam_UQ_QMC_32.py +++ b/mrstlnos/broken/beam_UQ_QMC_32.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -14,13 +15,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") from fwk.wutils import parseargs @@ -87,7 +88,7 @@ def main(): if rank == 0: command_line = 'gmsh -3 ' + work_dir + '/' + mesh_name + ' -o ' + work_dir + '/' + partitioned_mesh_name +' -part ' + str(siz) - print command_line + print(command_line) tmp = shlex.split(command_line) fileout = open('gmsh.log','w') p = subprocess.Popen(tmp, stdin=subprocess.PIPE, stdout=fileout, stderr=fileout, env=os.environ, shell=False,close_fds=True) @@ -192,12 +193,12 @@ def main(): slv.start() f = open('timers.txt', 'w') - print >>f, slv.tms + print(slv.tms, file=f) f.closed f = open('parameters_values.txt', 'w') - print >>f, E - print >>f, p + print(E, file=f) + print(p, file=f) f.closed os.rename('x_mm.txt', 'x_mm_'+str(i)+'.txt') diff --git a/mrstlnos/broken/beam_UQ_QMC_8.py b/mrstlnos/broken/beam_UQ_QMC_8.py index cd4707eb5b05fe545e550d2019ef6e306a3f82c8..444eeb5716f9ca2e4645a3e532c80b6023127740 100644 --- a/mrstlnos/broken/beam_UQ_QMC_8.py +++ b/mrstlnos/broken/beam_UQ_QMC_8.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -14,13 +15,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") from fwk.wutils import parseargs @@ -87,7 +88,7 @@ def main(): if rank == 0: command_line = 'gmsh -3 ' + work_dir + '/' + mesh_name + ' -o ' + work_dir + '/' + partitioned_mesh_name +' -part ' + str(siz) - print command_line + print(command_line) tmp = shlex.split(command_line) fileout = open('gmsh.log','w') p = subprocess.Popen(tmp, stdin=subprocess.PIPE, stdout=fileout, stderr=fileout, env=os.environ, shell=False,close_fds=True) @@ -192,12 +193,12 @@ def main(): slv.start() f = open('timers.txt', 'w') - print >>f, slv.tms + print(slv.tms, file=f) f.closed f = open('parameters_values.txt', 'w') - print >>f, E - print >>f, p + print(E, file=f) + print(p, file=f) f.closed os.rename('x_mm.txt', 'x_mm_'+str(i)+'.txt') diff --git a/mrstlnos/broken/beam_gmres_measures.py b/mrstlnos/broken/beam_gmres_measures.py index 21e3753a9d77f06e2a076e768acd202df2046404..61edb5a8f1fcb95fcd16556cb89a6f64e6035901 100644 --- a/mrstlnos/broken/beam_gmres_measures.py +++ b/mrstlnos/broken/beam_gmres_measures.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -13,13 +14,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") from fwk.wutils import parseargs @@ -64,7 +65,7 @@ def main(): if rank == 0: command_line = 'gmsh -3 ' + work_dir + '/' + mesh_name + ' -o ' + work_dir + '/' + partitioned_mesh_name +' -part ' + str(siz) - print command_line + print(command_line) tmp = shlex.split(command_line) fileout = open('gmsh.log','w') p = subprocess.Popen(tmp, stdin=subprocess.PIPE, stdout=fileout, stderr=fileout, env=os.environ, shell=False,close_fds=True) @@ -241,49 +242,49 @@ def main(): update_time[e] = slv.tms["update"].read().getReal().sec() if rank == 0: - print "Ensemble sizes:" - print ensemble_sizes - print "-------------------" - print "Total:" - print total - print "-------------------" - - print "Convert to discrete problem:" - print discrete_problem_times - print "Map:" - print map_times - print "Graph:" - print graph_times - print "Matrix assembly:" - print computeMatrices_times - print "BCs:" - print computeLoads_times - - print "Total preprocessing:" - print discrete_problem_times+map_times+graph_times+computeMatrices_times+computeLoads_times - - print "-------------------" - print "Solver: active set and gmres combine (= Belos + update cost + writting results)" - print solver_time - print "Update:" - print update_time - print "Writing time" - print writing_time - print "-------------------" - print "Belos total time:" - print belos_times - print "Belos apply matrix:" - print belos_matrix_times - print "Belos apply prec:" - print belos_apply_times - print "Belos orthogonalization:" - print ortho_times - print "Belos orthogonalization: inner product" - print ortho_times_inner - print "Belos orthogonalization: norm" - print ortho_times_norm - print "Belos orthogonalization: update" - print ortho_times_update + print("Ensemble sizes:") + print(ensemble_sizes) + print("-------------------") + print("Total:") + print(total) + print("-------------------") + + print("Convert to discrete problem:") + print(discrete_problem_times) + print("Map:") + print(map_times) + print("Graph:") + print(graph_times) + print("Matrix assembly:") + print(computeMatrices_times) + print("BCs:") + print(computeLoads_times) + + print("Total preprocessing:") + print(discrete_problem_times+map_times+graph_times+computeMatrices_times+computeLoads_times) + + print("-------------------") + print("Solver: active set and gmres combine (= Belos + update cost + writting results)") + print(solver_time) + print("Update:") + print(update_time) + print("Writing time") + print(writing_time) + print("-------------------") + print("Belos total time:") + print(belos_times) + print("Belos apply matrix:") + print(belos_matrix_times) + print("Belos apply prec:") + print(belos_apply_times) + print("Belos orthogonalization:") + print(ortho_times) + print("Belos orthogonalization: inner product") + print(ortho_times_inner) + print("Belos orthogonalization: norm") + print(ortho_times_norm) + print("Belos orthogonalization: update") + print(ortho_times_update) if __name__ == "__main__": main() diff --git a/mrstlnos/broken/bolt.py b/mrstlnos/broken/bolt.py index 996ca0a01043f12db35a409e0a57d4be14c5952c..ef8a5db8e677114b64eb0e30ce5666d02cb4bc2b 100644 --- a/mrstlnos/broken/bolt.py +++ b/mrstlnos/broken/bolt.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -13,13 +14,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") from fwk.wutils import parseargs @@ -88,7 +89,7 @@ def main(): if rank == 0: command_line = 'gmsh -3 ' + file_dir + '/' + geo_name + ' -o ' + work_dir + '/' + mesh_name +' -part ' + str(siz) - print command_line + print(command_line) tmp = shlex.split(command_line) fileout = open('gmsh.log','w') p = subprocess.Popen(tmp, stdin=subprocess.PIPE, stdout=fileout, stderr=fileout, env=os.environ, shell=False,close_fds=True) diff --git a/mrstlnos/broken/bolt_2.py b/mrstlnos/broken/bolt_2.py index a614d470f4a38d5075647fdd4acbfe706602c4af..ca86a2d878c337d30e834a26ba27ca2a711085fc 100644 --- a/mrstlnos/broken/bolt_2.py +++ b/mrstlnos/broken/bolt_2.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -13,13 +14,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") from fwk.wutils import parseargs @@ -46,7 +47,7 @@ def main(): if rank == 0: command_line = 'gmsh -3 ' + file_dir + '/' + geo_name + ' -o ' + work_dir + '/' + mesh_name +' -part ' + str(siz) + ' -clscale ' + str(clscale) - print command_line + print(command_line) tmp = shlex.split(command_line) fileout = open('gmsh.log','w') p = subprocess.Popen(tmp, stdin=subprocess.PIPE, stdout=fileout, stderr=fileout, env=os.environ, shell=False,close_fds=True) diff --git a/mrstlnos/broken/bolt_iterative.py b/mrstlnos/broken/bolt_iterative.py index 9efc19250780cdd353479e94d075ae92b2b82563..b6772e28f68adb7c03e042eacfeae2282b0796be 100644 --- a/mrstlnos/broken/bolt_iterative.py +++ b/mrstlnos/broken/bolt_iterative.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -13,13 +14,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") @@ -41,7 +42,7 @@ def main(): if rank == 0: command_line = 'gmsh -3 ' + file_dir + '/' + geo_name + ' -o ' + work_dir + '/' + mesh_name +' -part ' + str(siz) - print command_line + print(command_line) tmp = shlex.split(command_line) fileout = open('gmsh.log','w') p = subprocess.Popen(tmp, stdin=subprocess.PIPE, stdout=fileout, stderr=fileout, env=os.environ, shell=False,close_fds=True) @@ -177,18 +178,18 @@ def main(): timers = slv.tms; if rank == 0: - print 'Map real CPU cost' - print timers['map'].read().getReal() - print 'Graph real CPU cost' - print timers['graph'].read().getReal() - print 'Matrix computation on each mpi process real CPU cost' - print timers['computeMatrices'].read().getReal() - print 'MPI sharing CPU cost' - print timers['assembly-MPI'].read().getReal() - print 'prec' - print timers['prec'].read().getReal() - print 'belos' - print timers['belos'].read().getReal() + print('Map real CPU cost') + print(timers['map'].read().getReal()) + print('Graph real CPU cost') + print(timers['graph'].read().getReal()) + print('Matrix computation on each mpi process real CPU cost') + print(timers['computeMatrices'].read().getReal()) + print('MPI sharing CPU cost') + print(timers['assembly-MPI'].read().getReal()) + print('prec') + print(timers['prec'].read().getReal()) + print('belos') + print(timers['belos'].read().getReal()) if __name__ == "__main__": main() diff --git a/mrstlnos/broken/cube.py b/mrstlnos/broken/cube.py index a8028fc9b65c1590eeb7d692458b341139915d90..9f7d5c6c2b35f8855d014805917e9c16273ad1a4 100644 --- a/mrstlnos/broken/cube.py +++ b/mrstlnos/broken/cube.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -13,13 +14,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") @@ -87,7 +88,7 @@ def main(): if rank == 0: command_line = 'gmsh -3 ' + file_dir + '/' + geo_name + ' -o ' + work_dir + '/' + mesh_name +' -part ' + str(siz) - print command_line + print(command_line) tmp = shlex.split(command_line) fileout = open('gmsh.log','w') p = subprocess.Popen(tmp, stdin=subprocess.PIPE, stdout=fileout, stderr=fileout, env=os.environ, shell=False,close_fds=True) @@ -111,8 +112,8 @@ def main(): m.uDirichlet(pbl, "Surf 2", "Clamped",0,0.,1,1.5,0,0.) slv = m.Solver(pbl,args.k,solverList,3) - print "Number of threads per process" - print args.k + print("Number of threads per process") + print(args.k) if not args.nogui: if rank == 0: diff --git a/mrstlnos/broken/cube_1.py b/mrstlnos/broken/cube_1.py index 4d273c673ae13c5261fcc764e568e6a8d35500ce..5e43514146dd9ed2b3fe04f60f91dc4a07c776eb 100644 --- a/mrstlnos/broken/cube_1.py +++ b/mrstlnos/broken/cube_1.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -14,13 +15,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") @@ -42,7 +43,7 @@ def main(): if rank == 0: command_line = 'gmsh -3 ' + file_dir + '/' + geo_name + ' -o ' + work_dir + '/' + mesh_name +' -part ' + str(siz) - print command_line + print(command_line) tmp = shlex.split(command_line) fileout = open('gmsh.log','w') p = subprocess.Popen(tmp, stdin=subprocess.PIPE, stdout=fileout, stderr=fileout, env=os.environ, shell=False,close_fds=True) diff --git a/mrstlnos/broken/cube_16.py b/mrstlnos/broken/cube_16.py index ab304d10afac45a3460c43da06a765e051de0a0f..c4b6bb449d3261e9d60d96ff484439eb22298bde 100644 --- a/mrstlnos/broken/cube_16.py +++ b/mrstlnos/broken/cube_16.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -14,13 +15,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") @@ -42,7 +43,7 @@ def main(): if rank == 0: command_line = 'gmsh -3 ' + file_dir + '/' + geo_name + ' -o ' + work_dir + '/' + mesh_name +' -part ' + str(siz) - print command_line + print(command_line) tmp = shlex.split(command_line) fileout = open('gmsh.log','w') p = subprocess.Popen(tmp, stdin=subprocess.PIPE, stdout=fileout, stderr=fileout, env=os.environ, shell=False,close_fds=True) diff --git a/mrstlnos/broken/cube_16_k_scalability.py b/mrstlnos/broken/cube_16_k_scalability.py index 64e001f8c91e47fdec7c5c169b3ff152673a7f7e..6b9877ba1c961a444e4d500249e7d4cc15f4f204 100644 --- a/mrstlnos/broken/cube_16_k_scalability.py +++ b/mrstlnos/broken/cube_16_k_scalability.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -14,13 +15,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") @@ -48,7 +49,7 @@ def main(): if rank == 0: command_line = 'gmsh -3 ' + work_dir + '/' + mesh_name + ' -o ' + work_dir + '/' + partitioned_mesh_name +' -part ' + str(siz) - print command_line + print(command_line) tmp = shlex.split(command_line) fileout = open('gmsh.log','w') p = subprocess.Popen(tmp, stdin=subprocess.PIPE, stdout=fileout, stderr=fileout, env=os.environ, shell=False,close_fds=True) @@ -91,9 +92,9 @@ def main(): msh = gmsh.MeshLoader(partitioned_mesh_name,work_dir).myrank_execute(rank) k = ks[e] - print msh.name + print(msh.name) msh.name = msh.name + "_k_" + str(k) - print msh.name + print(msh.name) ensemble_size = 16 @@ -213,49 +214,49 @@ def main(): update_time[e] = slv.tms["update"].read().getReal().sec() if rank == 0: - print "k:" - print ks - print "-------------------" - print "Total:" - print total - print "-------------------" - - print "Convert to discrete problem:" - print discrete_problem_times - print "Map:" - print map_times - print "Graph:" - print graph_times - print "Matrix assembly:" - print computeMatrices_times - print "BCs:" - print computeLoads_times - - print "Total preprocessing:" - print discrete_problem_times+computeMatrices_times+computeLoads_times - - print "-------------------" - print "Solver: active set and gmres combine (= Belos + update cost + writting results)" - print solver_time - print "Update:" - print update_time - print "Writing time" - print writing_time - print "-------------------" - print "Belos total time:" - print belos_times - print "Belos apply matrix:" - print belos_matrix_times - print "Belos apply prec:" - print belos_apply_times - print "Belos orthogonalization:" - print ortho_times - print "Belos orthogonalization: inner product" - print ortho_times_inner - print "Belos orthogonalization: norm" - print ortho_times_norm - print "Belos orthogonalization: update" - print ortho_times_update + print("k:") + print(ks) + print("-------------------") + print("Total:") + print(total) + print("-------------------") + + print("Convert to discrete problem:") + print(discrete_problem_times) + print("Map:") + print(map_times) + print("Graph:") + print(graph_times) + print("Matrix assembly:") + print(computeMatrices_times) + print("BCs:") + print(computeLoads_times) + + print("Total preprocessing:") + print(discrete_problem_times+computeMatrices_times+computeLoads_times) + + print("-------------------") + print("Solver: active set and gmres combine (= Belos + update cost + writting results)") + print(solver_time) + print("Update:") + print(update_time) + print("Writing time") + print(writing_time) + print("-------------------") + print("Belos total time:") + print(belos_times) + print("Belos apply matrix:") + print(belos_matrix_times) + print("Belos apply prec:") + print(belos_apply_times) + print("Belos orthogonalization:") + print(ortho_times) + print("Belos orthogonalization: inner product") + print(ortho_times_inner) + print("Belos orthogonalization: norm") + print(ortho_times_norm) + print("Belos orthogonalization: update") + print(ortho_times_update) if __name__ == "__main__": main() diff --git a/mrstlnos/broken/cube_1_heat.py b/mrstlnos/broken/cube_1_heat.py index 58cef9925ae0842b0e0e6853ffccb6c7e72575ec..b48d617e704d13156cbe51b44468e9222bbf4707 100644 --- a/mrstlnos/broken/cube_1_heat.py +++ b/mrstlnos/broken/cube_1_heat.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -14,13 +15,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") @@ -42,7 +43,7 @@ def main(): if rank == 0: command_line = 'gmsh -3 ' + file_dir + '/' + geo_name + ' -o ' + work_dir + '/' + mesh_name +' -part ' + str(siz) - print command_line + print(command_line) tmp = shlex.split(command_line) fileout = open('gmsh.log','w') p = subprocess.Popen(tmp, stdin=subprocess.PIPE, stdout=fileout, stderr=fileout, env=os.environ, shell=False,close_fds=True) diff --git a/mrstlnos/broken/cube_1_k_scalability.py b/mrstlnos/broken/cube_1_k_scalability.py index 8665064f406993126cba1c3d89d78027a2d20be4..d8dc3d6dbfb36128234263e166e172febd7b5500 100644 --- a/mrstlnos/broken/cube_1_k_scalability.py +++ b/mrstlnos/broken/cube_1_k_scalability.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -14,13 +15,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") @@ -48,7 +49,7 @@ def main(): if rank == 0: command_line = 'gmsh -3 ' + work_dir + '/' + mesh_name + ' -o ' + work_dir + '/' + partitioned_mesh_name +' -part ' + str(siz) - print command_line + print(command_line) tmp = shlex.split(command_line) fileout = open('gmsh.log','w') p = subprocess.Popen(tmp, stdin=subprocess.PIPE, stdout=fileout, stderr=fileout, env=os.environ, shell=False,close_fds=True) @@ -92,9 +93,9 @@ def main(): msh = gmsh.MeshLoader(partitioned_mesh_name,work_dir).myrank_execute(rank) k = ks[e] - print msh.name + print(msh.name) msh.name = msh.name + "_k_" + str(k) - print msh.name + print(msh.name) ensemble_size = 1 @@ -214,49 +215,49 @@ def main(): update_time[e] = slv.tms["update"].read().getReal().sec() if rank == 0: - print "k:" - print ks - print "-------------------" - print "Total:" - print total - print "-------------------" - - print "Convert to discrete problem:" - print discrete_problem_times - print "Map:" - print map_times - print "Graph:" - print graph_times - print "Matrix assembly:" - print computeMatrices_times - print "BCs:" - print computeLoads_times - - print "Total preprocessing:" - print discrete_problem_times+computeMatrices_times+computeLoads_times - - print "-------------------" - print "Solver: active set and gmres combine (= Belos + update cost + writting results)" - print solver_time - print "Update:" - print update_time - print "Writing time" - print writing_time - print "-------------------" - print "Belos total time:" - print belos_times - print "Belos apply matrix:" - print belos_matrix_times - print "Belos apply prec:" - print belos_apply_times - print "Belos orthogonalization:" - print ortho_times - print "Belos orthogonalization: inner product" - print ortho_times_inner - print "Belos orthogonalization: norm" - print ortho_times_norm - print "Belos orthogonalization: update" - print ortho_times_update + print("k:") + print(ks) + print("-------------------") + print("Total:") + print(total) + print("-------------------") + + print("Convert to discrete problem:") + print(discrete_problem_times) + print("Map:") + print(map_times) + print("Graph:") + print(graph_times) + print("Matrix assembly:") + print(computeMatrices_times) + print("BCs:") + print(computeLoads_times) + + print("Total preprocessing:") + print(discrete_problem_times+computeMatrices_times+computeLoads_times) + + print("-------------------") + print("Solver: active set and gmres combine (= Belos + update cost + writting results)") + print(solver_time) + print("Update:") + print(update_time) + print("Writing time") + print(writing_time) + print("-------------------") + print("Belos total time:") + print(belos_times) + print("Belos apply matrix:") + print(belos_matrix_times) + print("Belos apply prec:") + print(belos_apply_times) + print("Belos orthogonalization:") + print(ortho_times) + print("Belos orthogonalization: inner product") + print(ortho_times_inner) + print("Belos orthogonalization: norm") + print(ortho_times_norm) + print("Belos orthogonalization: update") + print(ortho_times_update) if __name__ == "__main__": main() diff --git a/mrstlnos/broken/cube_1_k_scalability1.py b/mrstlnos/broken/cube_1_k_scalability1.py index b186e9f37b2e8ef4f3a69e1862de69174c841ead..c71d38376c36bc5dcead9b9ca06a1c9d9b15eb97 100644 --- a/mrstlnos/broken/cube_1_k_scalability1.py +++ b/mrstlnos/broken/cube_1_k_scalability1.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -14,13 +15,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") @@ -48,7 +49,7 @@ def main(): if rank == 0: command_line = 'gmsh -3 ' + work_dir + '/' + mesh_name + ' -o ' + work_dir + '/' + partitioned_mesh_name +' -part ' + str(siz) - print command_line + print(command_line) tmp = shlex.split(command_line) fileout = open('gmsh.log','w') p = subprocess.Popen(tmp, stdin=subprocess.PIPE, stdout=fileout, stderr=fileout, env=os.environ, shell=False,close_fds=True) @@ -92,9 +93,9 @@ def main(): msh = gmsh.MeshLoader(partitioned_mesh_name,work_dir).myrank_execute(rank) k = ks[e] - print msh.name + print(msh.name) msh.name = msh.name + "_k_" + str(k) - print msh.name + print(msh.name) ensemble_size = 1 @@ -214,49 +215,49 @@ def main(): update_time[e] = slv.tms["update"].read().getReal().sec() if rank == 0: - print "k:" - print ks - print "-------------------" - print "Total:" - print total - print "-------------------" - - print "Convert to discrete problem:" - print discrete_problem_times - print "Map:" - print map_times - print "Graph:" - print graph_times - print "Matrix assembly:" - print computeMatrices_times - print "BCs:" - print computeLoads_times - - print "Total preprocessing:" - print discrete_problem_times+computeMatrices_times+computeLoads_times - - print "-------------------" - print "Solver: active set and gmres combine (= Belos + update cost + writting results)" - print solver_time - print "Update:" - print update_time - print "Writing time" - print writing_time - print "-------------------" - print "Belos total time:" - print belos_times - print "Belos apply matrix:" - print belos_matrix_times - print "Belos apply prec:" - print belos_apply_times - print "Belos orthogonalization:" - print ortho_times - print "Belos orthogonalization: inner product" - print ortho_times_inner - print "Belos orthogonalization: norm" - print ortho_times_norm - print "Belos orthogonalization: update" - print ortho_times_update + print("k:") + print(ks) + print("-------------------") + print("Total:") + print(total) + print("-------------------") + + print("Convert to discrete problem:") + print(discrete_problem_times) + print("Map:") + print(map_times) + print("Graph:") + print(graph_times) + print("Matrix assembly:") + print(computeMatrices_times) + print("BCs:") + print(computeLoads_times) + + print("Total preprocessing:") + print(discrete_problem_times+computeMatrices_times+computeLoads_times) + + print("-------------------") + print("Solver: active set and gmres combine (= Belos + update cost + writting results)") + print(solver_time) + print("Update:") + print(update_time) + print("Writing time") + print(writing_time) + print("-------------------") + print("Belos total time:") + print(belos_times) + print("Belos apply matrix:") + print(belos_matrix_times) + print("Belos apply prec:") + print(belos_apply_times) + print("Belos orthogonalization:") + print(ortho_times) + print("Belos orthogonalization: inner product") + print(ortho_times_inner) + print("Belos orthogonalization: norm") + print(ortho_times_norm) + print("Belos orthogonalization: update") + print(ortho_times_update) if __name__ == "__main__": main() diff --git a/mrstlnos/broken/cube_1_k_scalability2.py b/mrstlnos/broken/cube_1_k_scalability2.py index 8dc5799e755a8e11b026dfd113747575d0a199d2..3bf52bf389ceac3468a7802645dc92ba48d051f3 100644 --- a/mrstlnos/broken/cube_1_k_scalability2.py +++ b/mrstlnos/broken/cube_1_k_scalability2.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -14,13 +15,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") @@ -48,7 +49,7 @@ def main(): if rank == 0: command_line = 'gmsh -3 ' + work_dir + '/' + mesh_name + ' -o ' + work_dir + '/' + partitioned_mesh_name +' -part ' + str(siz) - print command_line + print(command_line) tmp = shlex.split(command_line) fileout = open('gmsh.log','w') p = subprocess.Popen(tmp, stdin=subprocess.PIPE, stdout=fileout, stderr=fileout, env=os.environ, shell=False,close_fds=True) @@ -92,9 +93,9 @@ def main(): msh = gmsh.MeshLoader(partitioned_mesh_name,work_dir).myrank_execute(rank) k = ks[e] - print msh.name + print(msh.name) msh.name = msh.name + "_k_" + str(k) - print msh.name + print(msh.name) ensemble_size = 1 @@ -214,49 +215,49 @@ def main(): update_time[e] = slv.tms["update"].read().getReal().sec() if rank == 0: - print "k:" - print ks - print "-------------------" - print "Total:" - print total - print "-------------------" - - print "Convert to discrete problem:" - print discrete_problem_times - print "Map:" - print map_times - print "Graph:" - print graph_times - print "Matrix assembly:" - print computeMatrices_times - print "BCs:" - print computeLoads_times - - print "Total preprocessing:" - print discrete_problem_times+computeMatrices_times+computeLoads_times - - print "-------------------" - print "Solver: active set and gmres combine (= Belos + update cost + writting results)" - print solver_time - print "Update:" - print update_time - print "Writing time" - print writing_time - print "-------------------" - print "Belos total time:" - print belos_times - print "Belos apply matrix:" - print belos_matrix_times - print "Belos apply prec:" - print belos_apply_times - print "Belos orthogonalization:" - print ortho_times - print "Belos orthogonalization: inner product" - print ortho_times_inner - print "Belos orthogonalization: norm" - print ortho_times_norm - print "Belos orthogonalization: update" - print ortho_times_update + print("k:") + print(ks) + print("-------------------") + print("Total:") + print(total) + print("-------------------") + + print("Convert to discrete problem:") + print(discrete_problem_times) + print("Map:") + print(map_times) + print("Graph:") + print(graph_times) + print("Matrix assembly:") + print(computeMatrices_times) + print("BCs:") + print(computeLoads_times) + + print("Total preprocessing:") + print(discrete_problem_times+computeMatrices_times+computeLoads_times) + + print("-------------------") + print("Solver: active set and gmres combine (= Belos + update cost + writting results)") + print(solver_time) + print("Update:") + print(update_time) + print("Writing time") + print(writing_time) + print("-------------------") + print("Belos total time:") + print(belos_times) + print("Belos apply matrix:") + print(belos_matrix_times) + print("Belos apply prec:") + print(belos_apply_times) + print("Belos orthogonalization:") + print(ortho_times) + print("Belos orthogonalization: inner product") + print(ortho_times_inner) + print("Belos orthogonalization: norm") + print(ortho_times_norm) + print("Belos orthogonalization: update") + print(ortho_times_update) if __name__ == "__main__": main() diff --git a/mrstlnos/broken/cube_1_k_scalability3.py b/mrstlnos/broken/cube_1_k_scalability3.py index 5be4ce9cf1b5aa1d1e7c585608051506f081258d..3a9bc4c6f0bfcac3f911b24c5a86830e88a11daf 100644 --- a/mrstlnos/broken/cube_1_k_scalability3.py +++ b/mrstlnos/broken/cube_1_k_scalability3.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -14,13 +15,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") @@ -48,7 +49,7 @@ def main(): if rank == 0: command_line = 'gmsh -3 ' + work_dir + '/' + mesh_name + ' -o ' + work_dir + '/' + partitioned_mesh_name +' -part ' + str(siz) - print command_line + print(command_line) tmp = shlex.split(command_line) fileout = open('gmsh.log','w') p = subprocess.Popen(tmp, stdin=subprocess.PIPE, stdout=fileout, stderr=fileout, env=os.environ, shell=False,close_fds=True) @@ -92,9 +93,9 @@ def main(): msh = gmsh.MeshLoader(partitioned_mesh_name,work_dir).myrank_execute(rank) k = ks[e] - print msh.name + print(msh.name) msh.name = msh.name + "_k_" + str(k) - print msh.name + print(msh.name) ensemble_size = 1 @@ -214,49 +215,49 @@ def main(): update_time[e] = slv.tms["update"].read().getReal().sec() if rank == 0: - print "k:" - print ks - print "-------------------" - print "Total:" - print total - print "-------------------" - - print "Convert to discrete problem:" - print discrete_problem_times - print "Map:" - print map_times - print "Graph:" - print graph_times - print "Matrix assembly:" - print computeMatrices_times - print "BCs:" - print computeLoads_times - - print "Total preprocessing:" - print discrete_problem_times+computeMatrices_times+computeLoads_times - - print "-------------------" - print "Solver: active set and gmres combine (= Belos + update cost + writting results)" - print solver_time - print "Update:" - print update_time - print "Writing time" - print writing_time - print "-------------------" - print "Belos total time:" - print belos_times - print "Belos apply matrix:" - print belos_matrix_times - print "Belos apply prec:" - print belos_apply_times - print "Belos orthogonalization:" - print ortho_times - print "Belos orthogonalization: inner product" - print ortho_times_inner - print "Belos orthogonalization: norm" - print ortho_times_norm - print "Belos orthogonalization: update" - print ortho_times_update + print("k:") + print(ks) + print("-------------------") + print("Total:") + print(total) + print("-------------------") + + print("Convert to discrete problem:") + print(discrete_problem_times) + print("Map:") + print(map_times) + print("Graph:") + print(graph_times) + print("Matrix assembly:") + print(computeMatrices_times) + print("BCs:") + print(computeLoads_times) + + print("Total preprocessing:") + print(discrete_problem_times+computeMatrices_times+computeLoads_times) + + print("-------------------") + print("Solver: active set and gmres combine (= Belos + update cost + writting results)") + print(solver_time) + print("Update:") + print(update_time) + print("Writing time") + print(writing_time) + print("-------------------") + print("Belos total time:") + print(belos_times) + print("Belos apply matrix:") + print(belos_matrix_times) + print("Belos apply prec:") + print(belos_apply_times) + print("Belos orthogonalization:") + print(ortho_times) + print("Belos orthogonalization: inner product") + print(ortho_times_inner) + print("Belos orthogonalization: norm") + print(ortho_times_norm) + print("Belos orthogonalization: update") + print(ortho_times_update) if __name__ == "__main__": main() diff --git a/mrstlnos/broken/cube_1_k_scalability4.py b/mrstlnos/broken/cube_1_k_scalability4.py index d4874fbb73ba22f2f2b9cdbf9c13ee04d00fc3cc..da1524950889af30227aab73492880ac820ceb64 100644 --- a/mrstlnos/broken/cube_1_k_scalability4.py +++ b/mrstlnos/broken/cube_1_k_scalability4.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -14,13 +15,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") @@ -48,7 +49,7 @@ def main(): if rank == 0: command_line = 'gmsh -3 ' + work_dir + '/' + mesh_name + ' -o ' + work_dir + '/' + partitioned_mesh_name +' -part ' + str(siz) - print command_line + print(command_line) tmp = shlex.split(command_line) fileout = open('gmsh.log','w') p = subprocess.Popen(tmp, stdin=subprocess.PIPE, stdout=fileout, stderr=fileout, env=os.environ, shell=False,close_fds=True) @@ -92,9 +93,9 @@ def main(): msh = gmsh.MeshLoader(partitioned_mesh_name,work_dir).myrank_execute(rank) k = ks[e] - print msh.name + print(msh.name) msh.name = msh.name + "_k_" + str(k) - print msh.name + print(msh.name) ensemble_size = 1 @@ -214,49 +215,49 @@ def main(): update_time[e] = slv.tms["update"].read().getReal().sec() if rank == 0: - print "k:" - print ks - print "-------------------" - print "Total:" - print total - print "-------------------" - - print "Convert to discrete problem:" - print discrete_problem_times - print "Map:" - print map_times - print "Graph:" - print graph_times - print "Matrix assembly:" - print computeMatrices_times - print "BCs:" - print computeLoads_times - - print "Total preprocessing:" - print discrete_problem_times+computeMatrices_times+computeLoads_times - - print "-------------------" - print "Solver: active set and gmres combine (= Belos + update cost + writting results)" - print solver_time - print "Update:" - print update_time - print "Writing time" - print writing_time - print "-------------------" - print "Belos total time:" - print belos_times - print "Belos apply matrix:" - print belos_matrix_times - print "Belos apply prec:" - print belos_apply_times - print "Belos orthogonalization:" - print ortho_times - print "Belos orthogonalization: inner product" - print ortho_times_inner - print "Belos orthogonalization: norm" - print ortho_times_norm - print "Belos orthogonalization: update" - print ortho_times_update + print("k:") + print(ks) + print("-------------------") + print("Total:") + print(total) + print("-------------------") + + print("Convert to discrete problem:") + print(discrete_problem_times) + print("Map:") + print(map_times) + print("Graph:") + print(graph_times) + print("Matrix assembly:") + print(computeMatrices_times) + print("BCs:") + print(computeLoads_times) + + print("Total preprocessing:") + print(discrete_problem_times+computeMatrices_times+computeLoads_times) + + print("-------------------") + print("Solver: active set and gmres combine (= Belos + update cost + writting results)") + print(solver_time) + print("Update:") + print(update_time) + print("Writing time") + print(writing_time) + print("-------------------") + print("Belos total time:") + print(belos_times) + print("Belos apply matrix:") + print(belos_matrix_times) + print("Belos apply prec:") + print(belos_apply_times) + print("Belos orthogonalization:") + print(ortho_times) + print("Belos orthogonalization: inner product") + print(ortho_times_inner) + print("Belos orthogonalization: norm") + print(ortho_times_norm) + print("Belos orthogonalization: update") + print(ortho_times_update) if __name__ == "__main__": main() diff --git a/mrstlnos/broken/cube_1_k_scalability_2.py b/mrstlnos/broken/cube_1_k_scalability_2.py index 980c1cd9295e30087d7f8d710c5dbba45734f7c3..969f7444a0ca9be9c8d1b505d2c3599bece86508 100644 --- a/mrstlnos/broken/cube_1_k_scalability_2.py +++ b/mrstlnos/broken/cube_1_k_scalability_2.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -14,13 +15,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") @@ -48,7 +49,7 @@ def main(): if rank == 0: command_line = 'gmsh -3 ' + work_dir + '/' + mesh_name + ' -o ' + work_dir + '/' + partitioned_mesh_name +' -part ' + str(siz) - print command_line + print(command_line) tmp = shlex.split(command_line) fileout = open('gmsh.log','w') p = subprocess.Popen(tmp, stdin=subprocess.PIPE, stdout=fileout, stderr=fileout, env=os.environ, shell=False,close_fds=True) @@ -92,9 +93,9 @@ def main(): msh = gmsh.MeshLoader(partitioned_mesh_name,work_dir).myrank_execute(rank) k = ks[e] - print msh.name + print(msh.name) msh.name = msh.name + "_k_" + str(k) - print msh.name + print(msh.name) ensemble_size = 1 @@ -216,49 +217,49 @@ def main(): update_time[e] = slv.tms["update"].read().getReal().sec() if rank == 0: - print "k:" - print ks - print "-------------------" - print "Total:" - print total - print "-------------------" - - print "Convert to discrete problem:" - print discrete_problem_times - print "Map:" - print map_times - print "Graph:" - print graph_times - print "Matrix assembly:" - print computeMatrices_times - print "BCs:" - print computeLoads_times - - print "Total preprocessing:" - print discrete_problem_times+computeMatrices_times+computeLoads_times - - print "-------------------" - print "Solver: active set and gmres combine (= Belos + update cost + writting results)" - print solver_time - print "Update:" - print update_time - print "Writing time" - print writing_time - print "-------------------" - print "Belos total time:" - print belos_times - print "Belos apply matrix:" - print belos_matrix_times - print "Belos apply prec:" - print belos_apply_times - print "Belos orthogonalization:" - print ortho_times - print "Belos orthogonalization: inner product" - print ortho_times_inner - print "Belos orthogonalization: norm" - print ortho_times_norm - print "Belos orthogonalization: update" - print ortho_times_update + print("k:") + print(ks) + print("-------------------") + print("Total:") + print(total) + print("-------------------") + + print("Convert to discrete problem:") + print(discrete_problem_times) + print("Map:") + print(map_times) + print("Graph:") + print(graph_times) + print("Matrix assembly:") + print(computeMatrices_times) + print("BCs:") + print(computeLoads_times) + + print("Total preprocessing:") + print(discrete_problem_times+computeMatrices_times+computeLoads_times) + + print("-------------------") + print("Solver: active set and gmres combine (= Belos + update cost + writting results)") + print(solver_time) + print("Update:") + print(update_time) + print("Writing time") + print(writing_time) + print("-------------------") + print("Belos total time:") + print(belos_times) + print("Belos apply matrix:") + print(belos_matrix_times) + print("Belos apply prec:") + print(belos_apply_times) + print("Belos orthogonalization:") + print(ortho_times) + print("Belos orthogonalization: inner product") + print(ortho_times_inner) + print("Belos orthogonalization: norm") + print(ortho_times_norm) + print("Belos orthogonalization: update") + print(ortho_times_update) if __name__ == "__main__": main() diff --git a/mrstlnos/broken/cube_1_k_scalability_3.py b/mrstlnos/broken/cube_1_k_scalability_3.py index 7d838aa990925d25a83413237a21f84cca9ba220..f249f38aaa330893c6584387433e5f81713685fd 100644 --- a/mrstlnos/broken/cube_1_k_scalability_3.py +++ b/mrstlnos/broken/cube_1_k_scalability_3.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -14,13 +15,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") @@ -48,7 +49,7 @@ def main(): if rank == 0: command_line = 'gmsh -3 ' + work_dir + '/' + mesh_name + ' -o ' + work_dir + '/' + partitioned_mesh_name +' -part ' + str(siz) - print command_line + print(command_line) tmp = shlex.split(command_line) fileout = open('gmsh.log','w') p = subprocess.Popen(tmp, stdin=subprocess.PIPE, stdout=fileout, stderr=fileout, env=os.environ, shell=False,close_fds=True) @@ -92,9 +93,9 @@ def main(): msh = gmsh.MeshLoader(partitioned_mesh_name,work_dir).myrank_execute(rank) k = ks[e] - print msh.name + print(msh.name) msh.name = msh.name + "_k_" + str(k) - print msh.name + print(msh.name) ensemble_size = 1 @@ -197,49 +198,49 @@ def main(): update_time[e] = slv.tms["update"].read().getReal().sec() if rank == 0: - print "k:" - print ks - print "-------------------" - print "Total:" - print total - print "-------------------" - - print "Convert to discrete problem:" - print discrete_problem_times - print "Map:" - print map_times - print "Graph:" - print graph_times - print "Matrix assembly:" - print computeMatrices_times - print "BCs:" - print computeLoads_times - - print "Total preprocessing:" - print discrete_problem_times+computeMatrices_times+computeLoads_times - - print "-------------------" - print "Solver: active set and gmres combine (= Belos + update cost + writting results)" - print solver_time - print "Update:" - print update_time - print "Writing time" - print writing_time - print "-------------------" - print "Belos total time:" - print belos_times - print "Belos apply matrix:" - print belos_matrix_times - print "Belos apply prec:" - print belos_apply_times - print "Belos orthogonalization:" - print ortho_times - print "Belos orthogonalization: inner product" - print ortho_times_inner - print "Belos orthogonalization: norm" - print ortho_times_norm - print "Belos orthogonalization: update" - print ortho_times_update + print("k:") + print(ks) + print("-------------------") + print("Total:") + print(total) + print("-------------------") + + print("Convert to discrete problem:") + print(discrete_problem_times) + print("Map:") + print(map_times) + print("Graph:") + print(graph_times) + print("Matrix assembly:") + print(computeMatrices_times) + print("BCs:") + print(computeLoads_times) + + print("Total preprocessing:") + print(discrete_problem_times+computeMatrices_times+computeLoads_times) + + print("-------------------") + print("Solver: active set and gmres combine (= Belos + update cost + writting results)") + print(solver_time) + print("Update:") + print(update_time) + print("Writing time") + print(writing_time) + print("-------------------") + print("Belos total time:") + print(belos_times) + print("Belos apply matrix:") + print(belos_matrix_times) + print("Belos apply prec:") + print(belos_apply_times) + print("Belos orthogonalization:") + print(ortho_times) + print("Belos orthogonalization: inner product") + print(ortho_times_inner) + print("Belos orthogonalization: norm") + print(ortho_times_norm) + print("Belos orthogonalization: update") + print(ortho_times_update) if __name__ == "__main__": main() diff --git a/mrstlnos/broken/cube_32.py b/mrstlnos/broken/cube_32.py index dfc566a52466e36d7847dac693f0329ff295b0b3..f93efbd88221de2a1298d35ff50879952ef3e820 100644 --- a/mrstlnos/broken/cube_32.py +++ b/mrstlnos/broken/cube_32.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -14,13 +15,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") @@ -42,7 +43,7 @@ def main(): if rank == 0: command_line = 'gmsh -3 ' + file_dir + '/' + geo_name + ' -o ' + work_dir + '/' + mesh_name +' -part ' + str(siz) - print command_line + print(command_line) tmp = shlex.split(command_line) fileout = open('gmsh.log','w') p = subprocess.Popen(tmp, stdin=subprocess.PIPE, stdout=fileout, stderr=fileout, env=os.environ, shell=False,close_fds=True) diff --git a/mrstlnos/broken/cube_8.py b/mrstlnos/broken/cube_8.py index 4802a706ade6e984dfdbec81315b9b8ffcacdf26..7ac86bb612a9b792286f01b37536490f76fbff2f 100644 --- a/mrstlnos/broken/cube_8.py +++ b/mrstlnos/broken/cube_8.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -14,13 +15,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") @@ -42,7 +43,7 @@ def main(): if rank == 0: command_line = 'gmsh -3 ' + file_dir + '/' + geo_name + ' -o ' + work_dir + '/' + mesh_name +' -part ' + str(siz) - print command_line + print(command_line) tmp = shlex.split(command_line) fileout = open('gmsh.log','w') p = subprocess.Popen(tmp, stdin=subprocess.PIPE, stdout=fileout, stderr=fileout, env=os.environ, shell=False,close_fds=True) diff --git a/mrstlnos/broken/cube_8_k_scalability.py b/mrstlnos/broken/cube_8_k_scalability.py index 3af7dbe3b160d063e2938bae41b02a663a32d7c9..f66a6bb8b6fae6e264d937193d15705b53b72240 100644 --- a/mrstlnos/broken/cube_8_k_scalability.py +++ b/mrstlnos/broken/cube_8_k_scalability.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -14,13 +15,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") @@ -48,7 +49,7 @@ def main(): if rank == 0: command_line = 'gmsh -3 ' + work_dir + '/' + mesh_name + ' -o ' + work_dir + '/' + partitioned_mesh_name +' -part ' + str(siz) - print command_line + print(command_line) tmp = shlex.split(command_line) fileout = open('gmsh.log','w') p = subprocess.Popen(tmp, stdin=subprocess.PIPE, stdout=fileout, stderr=fileout, env=os.environ, shell=False,close_fds=True) @@ -91,9 +92,9 @@ def main(): msh = gmsh.MeshLoader(partitioned_mesh_name,work_dir).myrank_execute(rank) k = ks[e] - print msh.name + print(msh.name) msh.name = msh.name + "_k_" + str(k) - print msh.name + print(msh.name) ensemble_size = 8 @@ -213,49 +214,49 @@ def main(): update_time[e] = slv.tms["update"].read().getReal().sec() if rank == 0: - print "k:" - print ks - print "-------------------" - print "Total:" - print total - print "-------------------" - - print "Convert to discrete problem:" - print discrete_problem_times - print "Map:" - print map_times - print "Graph:" - print graph_times - print "Matrix assembly:" - print computeMatrices_times - print "BCs:" - print computeLoads_times - - print "Total preprocessing:" - print discrete_problem_times+computeMatrices_times+computeLoads_times - - print "-------------------" - print "Solver: active set and gmres combine (= Belos + update cost + writting results)" - print solver_time - print "Update:" - print update_time - print "Writing time" - print writing_time - print "-------------------" - print "Belos total time:" - print belos_times - print "Belos apply matrix:" - print belos_matrix_times - print "Belos apply prec:" - print belos_apply_times - print "Belos orthogonalization:" - print ortho_times - print "Belos orthogonalization: inner product" - print ortho_times_inner - print "Belos orthogonalization: norm" - print ortho_times_norm - print "Belos orthogonalization: update" - print ortho_times_update + print("k:") + print(ks) + print("-------------------") + print("Total:") + print(total) + print("-------------------") + + print("Convert to discrete problem:") + print(discrete_problem_times) + print("Map:") + print(map_times) + print("Graph:") + print(graph_times) + print("Matrix assembly:") + print(computeMatrices_times) + print("BCs:") + print(computeLoads_times) + + print("Total preprocessing:") + print(discrete_problem_times+computeMatrices_times+computeLoads_times) + + print("-------------------") + print("Solver: active set and gmres combine (= Belos + update cost + writting results)") + print(solver_time) + print("Update:") + print(update_time) + print("Writing time") + print(writing_time) + print("-------------------") + print("Belos total time:") + print(belos_times) + print("Belos apply matrix:") + print(belos_matrix_times) + print("Belos apply prec:") + print(belos_apply_times) + print("Belos orthogonalization:") + print(ortho_times) + print("Belos orthogonalization: inner product") + print(ortho_times_inner) + print("Belos orthogonalization: norm") + print(ortho_times_norm) + print("Belos orthogonalization: update") + print(ortho_times_update) if __name__ == "__main__": main() diff --git a/mrstlnos/broken/cube_LU_analysis.py b/mrstlnos/broken/cube_LU_analysis.py index 1f0ba11e7fd0cce47b02c2fbc8dbb2f8d2f435e8..5c77f16b9933c844b008472f941baf4ee39221e4 100644 --- a/mrstlnos/broken/cube_LU_analysis.py +++ b/mrstlnos/broken/cube_LU_analysis.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -13,13 +14,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") @@ -51,7 +52,7 @@ def main(): if rank == 0: command_line = 'gmsh -3 ' + file_dir + '/' + geo_current + ' -o ' + work_dir + '/' + mesh_name +' -part ' + str(siz) - print command_line + print(command_line) tmp = shlex.split(command_line) fileout = open('gmsh.log','w') p = subprocess.Popen(tmp, stdin=subprocess.PIPE, stdout=fileout, stderr=fileout, env=os.environ, shell=False,close_fds=True) @@ -90,10 +91,10 @@ def main(): slv.start() if rank == 0: - print 'finished' - print nC - print N - print amesos + print('finished') + print(nC) + print(N) + print(amesos) def replaceData(previousName,newName,previousData,newData): f = open(previousName,'r') diff --git a/mrstlnos/broken/cube_UQ_1.py b/mrstlnos/broken/cube_UQ_1.py index aff4fe8224307a897054c8466ab95cf0c771d010..22f0204f2a4becad8d4fb1db178d9ae7ffe38c4c 100644 --- a/mrstlnos/broken/cube_UQ_1.py +++ b/mrstlnos/broken/cube_UQ_1.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -13,13 +14,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") n_1D_gauss = 16 @@ -64,7 +65,7 @@ def main(): if rank == 0: command_line = 'gmsh -3 ' + work_dir + '/' + mesh_name + ' -o ' + work_dir + '/' + partitioned_mesh_name +' -part ' + str(siz) - print command_line + print(command_line) tmp = shlex.split(command_line) fileout = open('gmsh.log','w') p = subprocess.Popen(tmp, stdin=subprocess.PIPE, stdout=fileout, stderr=fileout, env=os.environ, shell=False,close_fds=True) @@ -178,12 +179,12 @@ def main(): slv.start() f = open('timers.txt', 'w') - print >>f, slv.tms + print(slv.tms, file=f) f.closed f = open('parameters_values.txt', 'w') - print >>f, E - print >>f, p + print(E, file=f) + print(p, file=f) f.closed diff --git a/mrstlnos/broken/cube_UQ_16_scenario_1.py b/mrstlnos/broken/cube_UQ_16_scenario_1.py index 1300f47b59a736fc080564a314e2eb6239fc48c0..e619e2f161423ba26309add08d7c36d3113ce40c 100644 --- a/mrstlnos/broken/cube_UQ_16_scenario_1.py +++ b/mrstlnos/broken/cube_UQ_16_scenario_1.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -13,13 +14,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") n_1D_gauss = 16 @@ -64,7 +65,7 @@ def main(): if rank == 0: command_line = 'gmsh -3 ' + work_dir + '/' + mesh_name + ' -o ' + work_dir + '/' + partitioned_mesh_name +' -part ' + str(siz) - print command_line + print(command_line) tmp = shlex.split(command_line) fileout = open('gmsh.log','w') p = subprocess.Popen(tmp, stdin=subprocess.PIPE, stdout=fileout, stderr=fileout, env=os.environ, shell=False,close_fds=True) @@ -105,13 +106,13 @@ def main(): p = p_gauss[i] * np.ones(ensemble_size) - print p - print p_gauss - print i - print j + print(p) + print(p_gauss) + print(i) + print(j) for ii in range(0,d_i): for jj in range(0,d_j): - print i+ii + print(i+ii) p[ii*d_j+jj] = p_gauss[i+ii] zero = np.zeros(ensemble_size) @@ -194,12 +195,12 @@ def main(): slv.start() f = open('timers.txt', 'w') - print >>f, slv.tms + print(slv.tms, file=f) f.closed f = open('parameters_values.txt', 'w') - print >>f, E - print >>f, p + print(E, file=f) + print(p, file=f) f.closed diff --git a/mrstlnos/broken/cube_UQ_16_scenario_2.py b/mrstlnos/broken/cube_UQ_16_scenario_2.py index eaf3459fc950d4038f1bd5896eff9076012f925d..048fadee073eaa31c0f4ca290a5b20b19b56a72d 100644 --- a/mrstlnos/broken/cube_UQ_16_scenario_2.py +++ b/mrstlnos/broken/cube_UQ_16_scenario_2.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -13,13 +14,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") n_1D_gauss = 16 @@ -64,7 +65,7 @@ def main(): if rank == 0: command_line = 'gmsh -3 ' + work_dir + '/' + mesh_name + ' -o ' + work_dir + '/' + partitioned_mesh_name +' -part ' + str(siz) - print command_line + print(command_line) tmp = shlex.split(command_line) fileout = open('gmsh.log','w') p = subprocess.Popen(tmp, stdin=subprocess.PIPE, stdout=fileout, stderr=fileout, env=os.environ, shell=False,close_fds=True) @@ -105,13 +106,13 @@ def main(): p = p_gauss[i] * np.ones(ensemble_size) - print p - print p_gauss - print i - print j + print(p) + print(p_gauss) + print(i) + print(j) for ii in range(0,d_i): for jj in range(0,d_j): - print i+ii + print(i+ii) p[ii*d_j+jj] = p_gauss[i+ii] zero = np.zeros(ensemble_size) @@ -194,12 +195,12 @@ def main(): slv.start() f = open('timers.txt', 'w') - print >>f, slv.tms + print(slv.tms, file=f) f.closed f = open('parameters_values.txt', 'w') - print >>f, E - print >>f, p + print(E, file=f) + print(p, file=f) f.closed diff --git a/mrstlnos/broken/cube_UQ_16_scenario_3.py b/mrstlnos/broken/cube_UQ_16_scenario_3.py index b7bf5e4ac9682790db4ce8a733ccca41f6e0bdfe..e5aaeccaaf617c92c22713f5e93649d348a609bb 100644 --- a/mrstlnos/broken/cube_UQ_16_scenario_3.py +++ b/mrstlnos/broken/cube_UQ_16_scenario_3.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -13,13 +14,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") n_1D_gauss = 16 @@ -64,7 +65,7 @@ def main(): if rank == 0: command_line = 'gmsh -3 ' + work_dir + '/' + mesh_name + ' -o ' + work_dir + '/' + partitioned_mesh_name +' -part ' + str(siz) - print command_line + print(command_line) tmp = shlex.split(command_line) fileout = open('gmsh.log','w') p = subprocess.Popen(tmp, stdin=subprocess.PIPE, stdout=fileout, stderr=fileout, env=os.environ, shell=False,close_fds=True) @@ -105,13 +106,13 @@ def main(): p = p_gauss[i] * np.ones(ensemble_size) - print p - print p_gauss - print i - print j + print(p) + print(p_gauss) + print(i) + print(j) for ii in range(0,d_i): for jj in range(0,d_j): - print i+ii + print(i+ii) p[ii*d_j+jj] = p_gauss[i+ii] zero = np.zeros(ensemble_size) @@ -194,12 +195,12 @@ def main(): slv.start() f = open('timers.txt', 'w') - print >>f, slv.tms + print(slv.tms, file=f) f.closed f = open('parameters_values.txt', 'w') - print >>f, E - print >>f, p + print(E, file=f) + print(p, file=f) f.closed diff --git a/mrstlnos/broken/cube_UQ_16_senario_1.py b/mrstlnos/broken/cube_UQ_16_senario_1.py index 1300f47b59a736fc080564a314e2eb6239fc48c0..e619e2f161423ba26309add08d7c36d3113ce40c 100644 --- a/mrstlnos/broken/cube_UQ_16_senario_1.py +++ b/mrstlnos/broken/cube_UQ_16_senario_1.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -13,13 +14,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") n_1D_gauss = 16 @@ -64,7 +65,7 @@ def main(): if rank == 0: command_line = 'gmsh -3 ' + work_dir + '/' + mesh_name + ' -o ' + work_dir + '/' + partitioned_mesh_name +' -part ' + str(siz) - print command_line + print(command_line) tmp = shlex.split(command_line) fileout = open('gmsh.log','w') p = subprocess.Popen(tmp, stdin=subprocess.PIPE, stdout=fileout, stderr=fileout, env=os.environ, shell=False,close_fds=True) @@ -105,13 +106,13 @@ def main(): p = p_gauss[i] * np.ones(ensemble_size) - print p - print p_gauss - print i - print j + print(p) + print(p_gauss) + print(i) + print(j) for ii in range(0,d_i): for jj in range(0,d_j): - print i+ii + print(i+ii) p[ii*d_j+jj] = p_gauss[i+ii] zero = np.zeros(ensemble_size) @@ -194,12 +195,12 @@ def main(): slv.start() f = open('timers.txt', 'w') - print >>f, slv.tms + print(slv.tms, file=f) f.closed f = open('parameters_values.txt', 'w') - print >>f, E - print >>f, p + print(E, file=f) + print(p, file=f) f.closed diff --git a/mrstlnos/broken/cube_UQ_16_senario_2.py b/mrstlnos/broken/cube_UQ_16_senario_2.py index eaf3459fc950d4038f1bd5896eff9076012f925d..048fadee073eaa31c0f4ca290a5b20b19b56a72d 100644 --- a/mrstlnos/broken/cube_UQ_16_senario_2.py +++ b/mrstlnos/broken/cube_UQ_16_senario_2.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -13,13 +14,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") n_1D_gauss = 16 @@ -64,7 +65,7 @@ def main(): if rank == 0: command_line = 'gmsh -3 ' + work_dir + '/' + mesh_name + ' -o ' + work_dir + '/' + partitioned_mesh_name +' -part ' + str(siz) - print command_line + print(command_line) tmp = shlex.split(command_line) fileout = open('gmsh.log','w') p = subprocess.Popen(tmp, stdin=subprocess.PIPE, stdout=fileout, stderr=fileout, env=os.environ, shell=False,close_fds=True) @@ -105,13 +106,13 @@ def main(): p = p_gauss[i] * np.ones(ensemble_size) - print p - print p_gauss - print i - print j + print(p) + print(p_gauss) + print(i) + print(j) for ii in range(0,d_i): for jj in range(0,d_j): - print i+ii + print(i+ii) p[ii*d_j+jj] = p_gauss[i+ii] zero = np.zeros(ensemble_size) @@ -194,12 +195,12 @@ def main(): slv.start() f = open('timers.txt', 'w') - print >>f, slv.tms + print(slv.tms, file=f) f.closed f = open('parameters_values.txt', 'w') - print >>f, E - print >>f, p + print(E, file=f) + print(p, file=f) f.closed diff --git a/mrstlnos/broken/cube_UQ_16_senario_3.py b/mrstlnos/broken/cube_UQ_16_senario_3.py index b7bf5e4ac9682790db4ce8a733ccca41f6e0bdfe..e5aaeccaaf617c92c22713f5e93649d348a609bb 100644 --- a/mrstlnos/broken/cube_UQ_16_senario_3.py +++ b/mrstlnos/broken/cube_UQ_16_senario_3.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -13,13 +14,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") n_1D_gauss = 16 @@ -64,7 +65,7 @@ def main(): if rank == 0: command_line = 'gmsh -3 ' + work_dir + '/' + mesh_name + ' -o ' + work_dir + '/' + partitioned_mesh_name +' -part ' + str(siz) - print command_line + print(command_line) tmp = shlex.split(command_line) fileout = open('gmsh.log','w') p = subprocess.Popen(tmp, stdin=subprocess.PIPE, stdout=fileout, stderr=fileout, env=os.environ, shell=False,close_fds=True) @@ -105,13 +106,13 @@ def main(): p = p_gauss[i] * np.ones(ensemble_size) - print p - print p_gauss - print i - print j + print(p) + print(p_gauss) + print(i) + print(j) for ii in range(0,d_i): for jj in range(0,d_j): - print i+ii + print(i+ii) p[ii*d_j+jj] = p_gauss[i+ii] zero = np.zeros(ensemble_size) @@ -194,12 +195,12 @@ def main(): slv.start() f = open('timers.txt', 'w') - print >>f, slv.tms + print(slv.tms, file=f) f.closed f = open('parameters_values.txt', 'w') - print >>f, E - print >>f, p + print(E, file=f) + print(p, file=f) f.closed diff --git a/mrstlnos/broken/cube_UQ_32_scenario_1.py b/mrstlnos/broken/cube_UQ_32_scenario_1.py index 3a2fedbd0a940cada3a6e43c131930d75851a459..a5f0bdc1558197730971ac2255354ff66e2bf4c3 100644 --- a/mrstlnos/broken/cube_UQ_32_scenario_1.py +++ b/mrstlnos/broken/cube_UQ_32_scenario_1.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -13,13 +14,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") n_1D_gauss = 16 @@ -64,7 +65,7 @@ def main(): if rank == 0: command_line = 'gmsh -3 ' + work_dir + '/' + mesh_name + ' -o ' + work_dir + '/' + partitioned_mesh_name +' -part ' + str(siz) - print command_line + print(command_line) tmp = shlex.split(command_line) fileout = open('gmsh.log','w') p = subprocess.Popen(tmp, stdin=subprocess.PIPE, stdout=fileout, stderr=fileout, env=os.environ, shell=False,close_fds=True) @@ -105,13 +106,13 @@ def main(): p = p_gauss[i] * np.ones(ensemble_size) - print p - print p_gauss - print i - print j + print(p) + print(p_gauss) + print(i) + print(j) for ii in range(0,d_i): for jj in range(0,d_j): - print i+ii + print(i+ii) p[ii*d_j+jj] = p_gauss[i+ii] zero = np.zeros(ensemble_size) @@ -194,12 +195,12 @@ def main(): slv.start() f = open('timers.txt', 'w') - print >>f, slv.tms + print(slv.tms, file=f) f.closed f = open('parameters_values.txt', 'w') - print >>f, E - print >>f, p + print(E, file=f) + print(p, file=f) f.closed diff --git a/mrstlnos/broken/cube_UQ_32_scenario_2.py b/mrstlnos/broken/cube_UQ_32_scenario_2.py index 54b32393954e85ed967d3e6e900496b1777d2ae6..f4324ef63ee526b260591873a619974d854cd5a4 100644 --- a/mrstlnos/broken/cube_UQ_32_scenario_2.py +++ b/mrstlnos/broken/cube_UQ_32_scenario_2.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -13,13 +14,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") n_1D_gauss = 16 @@ -64,7 +65,7 @@ def main(): if rank == 0: command_line = 'gmsh -3 ' + work_dir + '/' + mesh_name + ' -o ' + work_dir + '/' + partitioned_mesh_name +' -part ' + str(siz) - print command_line + print(command_line) tmp = shlex.split(command_line) fileout = open('gmsh.log','w') p = subprocess.Popen(tmp, stdin=subprocess.PIPE, stdout=fileout, stderr=fileout, env=os.environ, shell=False,close_fds=True) @@ -105,13 +106,13 @@ def main(): p = p_gauss[i] * np.ones(ensemble_size) - print p - print p_gauss - print i - print j + print(p) + print(p_gauss) + print(i) + print(j) for ii in range(0,d_i): for jj in range(0,d_j): - print i+ii + print(i+ii) p[ii*d_j+jj] = p_gauss[i+ii] zero = np.zeros(ensemble_size) @@ -194,12 +195,12 @@ def main(): slv.start() f = open('timers.txt', 'w') - print >>f, slv.tms + print(slv.tms, file=f) f.closed f = open('parameters_values.txt', 'w') - print >>f, E - print >>f, p + print(E, file=f) + print(p, file=f) f.closed diff --git a/mrstlnos/broken/cube_UQ_32_scenario_3.py b/mrstlnos/broken/cube_UQ_32_scenario_3.py index 66990530eda01377486f9546fba121ee706df189..4e4b36ae53c705aba6c032fcdc18dcf0234b2663 100644 --- a/mrstlnos/broken/cube_UQ_32_scenario_3.py +++ b/mrstlnos/broken/cube_UQ_32_scenario_3.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -13,13 +14,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") n_1D_gauss = 16 @@ -64,7 +65,7 @@ def main(): if rank == 0: command_line = 'gmsh -3 ' + work_dir + '/' + mesh_name + ' -o ' + work_dir + '/' + partitioned_mesh_name +' -part ' + str(siz) - print command_line + print(command_line) tmp = shlex.split(command_line) fileout = open('gmsh.log','w') p = subprocess.Popen(tmp, stdin=subprocess.PIPE, stdout=fileout, stderr=fileout, env=os.environ, shell=False,close_fds=True) @@ -105,13 +106,13 @@ def main(): p = p_gauss[i] * np.ones(ensemble_size) - print p - print p_gauss - print i - print j + print(p) + print(p_gauss) + print(i) + print(j) for ii in range(0,d_i): for jj in range(0,d_j): - print i+ii + print(i+ii) p[ii*d_j+jj] = p_gauss[i+ii] zero = np.zeros(ensemble_size) @@ -194,12 +195,12 @@ def main(): slv.start() f = open('timers.txt', 'w') - print >>f, slv.tms + print(slv.tms, file=f) f.closed f = open('parameters_values.txt', 'w') - print >>f, E - print >>f, p + print(E, file=f) + print(p, file=f) f.closed diff --git a/mrstlnos/broken/cube_UQ_32_senario_1.py b/mrstlnos/broken/cube_UQ_32_senario_1.py index 3a2fedbd0a940cada3a6e43c131930d75851a459..a5f0bdc1558197730971ac2255354ff66e2bf4c3 100644 --- a/mrstlnos/broken/cube_UQ_32_senario_1.py +++ b/mrstlnos/broken/cube_UQ_32_senario_1.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -13,13 +14,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") n_1D_gauss = 16 @@ -64,7 +65,7 @@ def main(): if rank == 0: command_line = 'gmsh -3 ' + work_dir + '/' + mesh_name + ' -o ' + work_dir + '/' + partitioned_mesh_name +' -part ' + str(siz) - print command_line + print(command_line) tmp = shlex.split(command_line) fileout = open('gmsh.log','w') p = subprocess.Popen(tmp, stdin=subprocess.PIPE, stdout=fileout, stderr=fileout, env=os.environ, shell=False,close_fds=True) @@ -105,13 +106,13 @@ def main(): p = p_gauss[i] * np.ones(ensemble_size) - print p - print p_gauss - print i - print j + print(p) + print(p_gauss) + print(i) + print(j) for ii in range(0,d_i): for jj in range(0,d_j): - print i+ii + print(i+ii) p[ii*d_j+jj] = p_gauss[i+ii] zero = np.zeros(ensemble_size) @@ -194,12 +195,12 @@ def main(): slv.start() f = open('timers.txt', 'w') - print >>f, slv.tms + print(slv.tms, file=f) f.closed f = open('parameters_values.txt', 'w') - print >>f, E - print >>f, p + print(E, file=f) + print(p, file=f) f.closed diff --git a/mrstlnos/broken/cube_UQ_32_senario_2.py b/mrstlnos/broken/cube_UQ_32_senario_2.py index 54b32393954e85ed967d3e6e900496b1777d2ae6..f4324ef63ee526b260591873a619974d854cd5a4 100644 --- a/mrstlnos/broken/cube_UQ_32_senario_2.py +++ b/mrstlnos/broken/cube_UQ_32_senario_2.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -13,13 +14,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") n_1D_gauss = 16 @@ -64,7 +65,7 @@ def main(): if rank == 0: command_line = 'gmsh -3 ' + work_dir + '/' + mesh_name + ' -o ' + work_dir + '/' + partitioned_mesh_name +' -part ' + str(siz) - print command_line + print(command_line) tmp = shlex.split(command_line) fileout = open('gmsh.log','w') p = subprocess.Popen(tmp, stdin=subprocess.PIPE, stdout=fileout, stderr=fileout, env=os.environ, shell=False,close_fds=True) @@ -105,13 +106,13 @@ def main(): p = p_gauss[i] * np.ones(ensemble_size) - print p - print p_gauss - print i - print j + print(p) + print(p_gauss) + print(i) + print(j) for ii in range(0,d_i): for jj in range(0,d_j): - print i+ii + print(i+ii) p[ii*d_j+jj] = p_gauss[i+ii] zero = np.zeros(ensemble_size) @@ -194,12 +195,12 @@ def main(): slv.start() f = open('timers.txt', 'w') - print >>f, slv.tms + print(slv.tms, file=f) f.closed f = open('parameters_values.txt', 'w') - print >>f, E - print >>f, p + print(E, file=f) + print(p, file=f) f.closed diff --git a/mrstlnos/broken/cube_UQ_32_senario_3.py b/mrstlnos/broken/cube_UQ_32_senario_3.py index 66990530eda01377486f9546fba121ee706df189..4e4b36ae53c705aba6c032fcdc18dcf0234b2663 100644 --- a/mrstlnos/broken/cube_UQ_32_senario_3.py +++ b/mrstlnos/broken/cube_UQ_32_senario_3.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -13,13 +14,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") n_1D_gauss = 16 @@ -64,7 +65,7 @@ def main(): if rank == 0: command_line = 'gmsh -3 ' + work_dir + '/' + mesh_name + ' -o ' + work_dir + '/' + partitioned_mesh_name +' -part ' + str(siz) - print command_line + print(command_line) tmp = shlex.split(command_line) fileout = open('gmsh.log','w') p = subprocess.Popen(tmp, stdin=subprocess.PIPE, stdout=fileout, stderr=fileout, env=os.environ, shell=False,close_fds=True) @@ -105,13 +106,13 @@ def main(): p = p_gauss[i] * np.ones(ensemble_size) - print p - print p_gauss - print i - print j + print(p) + print(p_gauss) + print(i) + print(j) for ii in range(0,d_i): for jj in range(0,d_j): - print i+ii + print(i+ii) p[ii*d_j+jj] = p_gauss[i+ii] zero = np.zeros(ensemble_size) @@ -194,12 +195,12 @@ def main(): slv.start() f = open('timers.txt', 'w') - print >>f, slv.tms + print(slv.tms, file=f) f.closed f = open('parameters_values.txt', 'w') - print >>f, E - print >>f, p + print(E, file=f) + print(p, file=f) f.closed diff --git a/mrstlnos/broken/cube_UQ_8_scenario_1.py b/mrstlnos/broken/cube_UQ_8_scenario_1.py index 6367b3fb3ffec9179e0c28b977ea47ba46d73d9c..c64606baa891f36a1cf216116103a86ffb082526 100644 --- a/mrstlnos/broken/cube_UQ_8_scenario_1.py +++ b/mrstlnos/broken/cube_UQ_8_scenario_1.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -13,13 +14,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") n_1D_gauss = 16 @@ -64,7 +65,7 @@ def main(): if rank == 0: command_line = 'gmsh -3 ' + work_dir + '/' + mesh_name + ' -o ' + work_dir + '/' + partitioned_mesh_name +' -part ' + str(siz) - print command_line + print(command_line) tmp = shlex.split(command_line) fileout = open('gmsh.log','w') p = subprocess.Popen(tmp, stdin=subprocess.PIPE, stdout=fileout, stderr=fileout, env=os.environ, shell=False,close_fds=True) @@ -105,13 +106,13 @@ def main(): p = p_gauss[i] * np.ones(ensemble_size) - print p - print p_gauss - print i - print j + print(p) + print(p_gauss) + print(i) + print(j) for ii in range(0,d_i): for jj in range(0,d_j): - print i+ii + print(i+ii) p[ii*d_j+jj] = p_gauss[i+ii] zero = np.zeros(ensemble_size) @@ -194,12 +195,12 @@ def main(): slv.start() f = open('timers.txt', 'w') - print >>f, slv.tms + print(slv.tms, file=f) f.closed f = open('parameters_values.txt', 'w') - print >>f, E - print >>f, p + print(E, file=f) + print(p, file=f) f.closed diff --git a/mrstlnos/broken/cube_UQ_8_scenario_2.py b/mrstlnos/broken/cube_UQ_8_scenario_2.py index 175e6f4155b4159fbb27cbba55b6141f429a812f..65b79239e74d7991479a1d0dc9cf8d0db0b7ee3f 100644 --- a/mrstlnos/broken/cube_UQ_8_scenario_2.py +++ b/mrstlnos/broken/cube_UQ_8_scenario_2.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -13,13 +14,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") n_1D_gauss = 16 @@ -64,7 +65,7 @@ def main(): if rank == 0: command_line = 'gmsh -3 ' + work_dir + '/' + mesh_name + ' -o ' + work_dir + '/' + partitioned_mesh_name +' -part ' + str(siz) - print command_line + print(command_line) tmp = shlex.split(command_line) fileout = open('gmsh.log','w') p = subprocess.Popen(tmp, stdin=subprocess.PIPE, stdout=fileout, stderr=fileout, env=os.environ, shell=False,close_fds=True) @@ -105,13 +106,13 @@ def main(): p = p_gauss[i] * np.ones(ensemble_size) - print p - print p_gauss - print i - print j + print(p) + print(p_gauss) + print(i) + print(j) for ii in range(0,d_i): for jj in range(0,d_j): - print i+ii + print(i+ii) p[ii*d_j+jj] = p_gauss[i+ii] zero = np.zeros(ensemble_size) @@ -194,12 +195,12 @@ def main(): slv.start() f = open('timers.txt', 'w') - print >>f, slv.tms + print(slv.tms, file=f) f.closed f = open('parameters_values.txt', 'w') - print >>f, E - print >>f, p + print(E, file=f) + print(p, file=f) f.closed diff --git a/mrstlnos/broken/cube_UQ_8_scenario_3.py b/mrstlnos/broken/cube_UQ_8_scenario_3.py index 074fca7e6792b21d9bd9eca05c256ac71c675596..15e1ea5a943cce16e3b78338bbd4d107a8aa73e2 100644 --- a/mrstlnos/broken/cube_UQ_8_scenario_3.py +++ b/mrstlnos/broken/cube_UQ_8_scenario_3.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -13,13 +14,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") n_1D_gauss = 16 @@ -64,7 +65,7 @@ def main(): if rank == 0: command_line = 'gmsh -3 ' + work_dir + '/' + mesh_name + ' -o ' + work_dir + '/' + partitioned_mesh_name +' -part ' + str(siz) - print command_line + print(command_line) tmp = shlex.split(command_line) fileout = open('gmsh.log','w') p = subprocess.Popen(tmp, stdin=subprocess.PIPE, stdout=fileout, stderr=fileout, env=os.environ, shell=False,close_fds=True) @@ -105,13 +106,13 @@ def main(): p = p_gauss[i] * np.ones(ensemble_size) - print p - print p_gauss - print i - print j + print(p) + print(p_gauss) + print(i) + print(j) for ii in range(0,d_i): for jj in range(0,d_j): - print i+ii + print(i+ii) p[ii*d_j+jj] = p_gauss[i+ii] zero = np.zeros(ensemble_size) @@ -194,12 +195,12 @@ def main(): slv.start() f = open('timers.txt', 'w') - print >>f, slv.tms + print(slv.tms, file=f) f.closed f = open('parameters_values.txt', 'w') - print >>f, E - print >>f, p + print(E, file=f) + print(p, file=f) f.closed diff --git a/mrstlnos/broken/cube_UQ_8_senario_1.py b/mrstlnos/broken/cube_UQ_8_senario_1.py index 6367b3fb3ffec9179e0c28b977ea47ba46d73d9c..c64606baa891f36a1cf216116103a86ffb082526 100644 --- a/mrstlnos/broken/cube_UQ_8_senario_1.py +++ b/mrstlnos/broken/cube_UQ_8_senario_1.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -13,13 +14,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") n_1D_gauss = 16 @@ -64,7 +65,7 @@ def main(): if rank == 0: command_line = 'gmsh -3 ' + work_dir + '/' + mesh_name + ' -o ' + work_dir + '/' + partitioned_mesh_name +' -part ' + str(siz) - print command_line + print(command_line) tmp = shlex.split(command_line) fileout = open('gmsh.log','w') p = subprocess.Popen(tmp, stdin=subprocess.PIPE, stdout=fileout, stderr=fileout, env=os.environ, shell=False,close_fds=True) @@ -105,13 +106,13 @@ def main(): p = p_gauss[i] * np.ones(ensemble_size) - print p - print p_gauss - print i - print j + print(p) + print(p_gauss) + print(i) + print(j) for ii in range(0,d_i): for jj in range(0,d_j): - print i+ii + print(i+ii) p[ii*d_j+jj] = p_gauss[i+ii] zero = np.zeros(ensemble_size) @@ -194,12 +195,12 @@ def main(): slv.start() f = open('timers.txt', 'w') - print >>f, slv.tms + print(slv.tms, file=f) f.closed f = open('parameters_values.txt', 'w') - print >>f, E - print >>f, p + print(E, file=f) + print(p, file=f) f.closed diff --git a/mrstlnos/broken/cube_UQ_8_senario_2.py b/mrstlnos/broken/cube_UQ_8_senario_2.py index 175e6f4155b4159fbb27cbba55b6141f429a812f..65b79239e74d7991479a1d0dc9cf8d0db0b7ee3f 100644 --- a/mrstlnos/broken/cube_UQ_8_senario_2.py +++ b/mrstlnos/broken/cube_UQ_8_senario_2.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -13,13 +14,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") n_1D_gauss = 16 @@ -64,7 +65,7 @@ def main(): if rank == 0: command_line = 'gmsh -3 ' + work_dir + '/' + mesh_name + ' -o ' + work_dir + '/' + partitioned_mesh_name +' -part ' + str(siz) - print command_line + print(command_line) tmp = shlex.split(command_line) fileout = open('gmsh.log','w') p = subprocess.Popen(tmp, stdin=subprocess.PIPE, stdout=fileout, stderr=fileout, env=os.environ, shell=False,close_fds=True) @@ -105,13 +106,13 @@ def main(): p = p_gauss[i] * np.ones(ensemble_size) - print p - print p_gauss - print i - print j + print(p) + print(p_gauss) + print(i) + print(j) for ii in range(0,d_i): for jj in range(0,d_j): - print i+ii + print(i+ii) p[ii*d_j+jj] = p_gauss[i+ii] zero = np.zeros(ensemble_size) @@ -194,12 +195,12 @@ def main(): slv.start() f = open('timers.txt', 'w') - print >>f, slv.tms + print(slv.tms, file=f) f.closed f = open('parameters_values.txt', 'w') - print >>f, E - print >>f, p + print(E, file=f) + print(p, file=f) f.closed diff --git a/mrstlnos/broken/cube_UQ_8_senario_3.py b/mrstlnos/broken/cube_UQ_8_senario_3.py index 074fca7e6792b21d9bd9eca05c256ac71c675596..15e1ea5a943cce16e3b78338bbd4d107a8aa73e2 100644 --- a/mrstlnos/broken/cube_UQ_8_senario_3.py +++ b/mrstlnos/broken/cube_UQ_8_senario_3.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -13,13 +14,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") n_1D_gauss = 16 @@ -64,7 +65,7 @@ def main(): if rank == 0: command_line = 'gmsh -3 ' + work_dir + '/' + mesh_name + ' -o ' + work_dir + '/' + partitioned_mesh_name +' -part ' + str(siz) - print command_line + print(command_line) tmp = shlex.split(command_line) fileout = open('gmsh.log','w') p = subprocess.Popen(tmp, stdin=subprocess.PIPE, stdout=fileout, stderr=fileout, env=os.environ, shell=False,close_fds=True) @@ -105,13 +106,13 @@ def main(): p = p_gauss[i] * np.ones(ensemble_size) - print p - print p_gauss - print i - print j + print(p) + print(p_gauss) + print(i) + print(j) for ii in range(0,d_i): for jj in range(0,d_j): - print i+ii + print(i+ii) p[ii*d_j+jj] = p_gauss[i+ii] zero = np.zeros(ensemble_size) @@ -194,12 +195,12 @@ def main(): slv.start() f = open('timers.txt', 'w') - print >>f, slv.tms + print(slv.tms, file=f) f.closed f = open('parameters_values.txt', 'w') - print >>f, E - print >>f, p + print(E, file=f) + print(p, file=f) f.closed diff --git a/mrstlnos/broken/cube_gmres_analysis.py b/mrstlnos/broken/cube_gmres_analysis.py index 7614ac65c13c8ec97d5ebb87b2eb7032c892bcb4..ed30bf8c51685a4d9bb7ed85c900f1e78c6b7265 100644 --- a/mrstlnos/broken/cube_gmres_analysis.py +++ b/mrstlnos/broken/cube_gmres_analysis.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -13,13 +14,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") @@ -52,7 +53,7 @@ def main(): if rank == 0: command_line = 'gmsh -3 ' + file_dir + '/' + geo_current + ' -o ' + work_dir + '/' + mesh_name +' -part ' + str(siz) - print command_line + print(command_line) tmp = shlex.split(command_line) fileout = open('gmsh.log','w') p = subprocess.Popen(tmp, stdin=subprocess.PIPE, stdout=fileout, stderr=fileout, env=os.environ, shell=False,close_fds=True) @@ -141,11 +142,11 @@ def main(): belos[j] = float(slv.tms['belos'].read().getReal().sec()) if rank == 0: - print 'finished' - print nC - print N - print prec - print belos + print('finished') + print(nC) + print(N) + print(prec) + print(belos) def replaceData(previousName,newName,previousData,newData): f = open(previousName,'r') diff --git a/mrstlnos/broken/cube_gmres_measures.py b/mrstlnos/broken/cube_gmres_measures.py index c54ac7cf22390ecc561648b0351c99c009a221ec..a7e0fc2963aa0a63b2909c8b7f2f8175bedd5767 100644 --- a/mrstlnos/broken/cube_gmres_measures.py +++ b/mrstlnos/broken/cube_gmres_measures.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -14,13 +15,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") @@ -42,7 +43,7 @@ def main(): if rank == 0: command_line = 'gmsh -3 ' + file_dir + '/' + geo_name + ' -o ' + work_dir + '/' + mesh_name +' -part ' + str(siz) - print command_line + print(command_line) tmp = shlex.split(command_line) fileout = open('gmsh.log','w') p = subprocess.Popen(tmp, stdin=subprocess.PIPE, stdout=fileout, stderr=fileout, env=os.environ, shell=False,close_fds=True) @@ -201,49 +202,49 @@ def main(): update_time[e] = slv.tms["update"].read().getReal().sec() if rank == 0: - print "Ensemble sizes:" - print ensemble_sizes - print "-------------------" - print "Total:" - print total - print "-------------------" - - print "Convert to discrete problem:" - print discrete_problem_times - print "Map:" - print map_times - print "Graph:" - print graph_times - print "Matrix assembly:" - print computeMatrices_times - print "BCs:" - print computeLoads_times - - print "Total preprocessing:" - print discrete_problem_times+map_times+graph_times+computeMatrices_times+computeLoads_times - - print "-------------------" - print "Solver: active set and gmres combine (= Belos + update cost + writting results)" - print solver_time - print "Update:" - print update_time - print "Writing time" - print writing_time - print "-------------------" - print "Belos total time:" - print belos_times - print "Belos apply matrix:" - print belos_matrix_times - print "Belos apply prec:" - print belos_apply_times - print "Belos orthogonalization:" - print ortho_times - print "Belos orthogonalization: inner product" - print ortho_times_inner - print "Belos orthogonalization: norm" - print ortho_times_norm - print "Belos orthogonalization: update" - print ortho_times_update + print("Ensemble sizes:") + print(ensemble_sizes) + print("-------------------") + print("Total:") + print(total) + print("-------------------") + + print("Convert to discrete problem:") + print(discrete_problem_times) + print("Map:") + print(map_times) + print("Graph:") + print(graph_times) + print("Matrix assembly:") + print(computeMatrices_times) + print("BCs:") + print(computeLoads_times) + + print("Total preprocessing:") + print(discrete_problem_times+map_times+graph_times+computeMatrices_times+computeLoads_times) + + print("-------------------") + print("Solver: active set and gmres combine (= Belos + update cost + writting results)") + print(solver_time) + print("Update:") + print(update_time) + print("Writing time") + print(writing_time) + print("-------------------") + print("Belos total time:") + print(belos_times) + print("Belos apply matrix:") + print(belos_matrix_times) + print("Belos apply prec:") + print(belos_apply_times) + print("Belos orthogonalization:") + print(ortho_times) + print("Belos orthogonalization: inner product") + print(ortho_times_inner) + print("Belos orthogonalization: norm") + print(ortho_times_norm) + print("Belos orthogonalization: update") + print(ortho_times_update) if __name__ == "__main__": main() diff --git a/mrstlnos/broken/cube_heat.py b/mrstlnos/broken/cube_heat.py index e9efd0b073f4b2cb3f92e41a1294f2628beb0ca4..417859dc29ac4c6f31c5b51d0ba45de824cbe517 100644 --- a/mrstlnos/broken/cube_heat.py +++ b/mrstlnos/broken/cube_heat.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -14,13 +15,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") @@ -48,7 +49,7 @@ def main(): if rank == 0: command_line = 'gmsh -3 ' + work_dir + '/' + mesh_name + ' -o ' + work_dir + '/' + partitioned_mesh_name +' -part ' + str(siz) - print command_line + print(command_line) tmp = shlex.split(command_line) fileout = open('gmsh.log','w') p = subprocess.Popen(tmp, stdin=subprocess.PIPE, stdout=fileout, stderr=fileout, env=os.environ, shell=False,close_fds=True) diff --git a/mrstlnos/broken/cube_new.py b/mrstlnos/broken/cube_new.py index b07847e4bb706f25c095ef22ed4689bc584437ee..0c7f56ab99dd86e77b06417fdae9ae502eb19674 100644 --- a/mrstlnos/broken/cube_new.py +++ b/mrstlnos/broken/cube_new.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -13,13 +14,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") @@ -41,7 +42,7 @@ def main(): if rank == 0: command_line = 'gmsh -3 ' + file_dir + '/' + geo_name + ' -o ' + work_dir + '/' + mesh_name +' -part ' + str(siz) - print command_line + print(command_line) tmp = shlex.split(command_line) fileout = open('gmsh.log','w') p = subprocess.Popen(tmp, stdin=subprocess.PIPE, stdout=fileout, stderr=fileout, env=os.environ, shell=False,close_fds=True) @@ -92,16 +93,16 @@ def main(): timers = slv.tms; if rank == 0: - print 'Map real CPU cost' - print timers['map'].read().getReal() - print 'Graph real CPU cost' - print timers['graph'].read().getReal() - print 'Matrix computation on each mpi process real CPU cost' - print timers['computeMatrices'].read().getReal() - print 'MPI sharing CPU cost' - print timers['assembly-MPI'].read().getReal() - print 'Amesos2' - print timers['Amesos2'].read().getReal() + print('Map real CPU cost') + print(timers['map'].read().getReal()) + print('Graph real CPU cost') + print(timers['graph'].read().getReal()) + print('Matrix computation on each mpi process real CPU cost') + print(timers['computeMatrices'].read().getReal()) + print('MPI sharing CPU cost') + print(timers['assembly-MPI'].read().getReal()) + print('Amesos2') + print(timers['Amesos2'].read().getReal()) if __name__ == "__main__": main() diff --git a/mrstlnos/broken/cube_new/cube_new_0.py b/mrstlnos/broken/cube_new/cube_new_0.py index de22527021f15a0ae1385cb5a487d9fec6d1a497..83e7e24b5a9784108871d76b0bc88ad2520f787b 100644 --- a/mrstlnos/broken/cube_new/cube_new_0.py +++ b/mrstlnos/broken/cube_new/cube_new_0.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -13,13 +14,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") @@ -41,7 +42,7 @@ def main(): if rank == 0: command_line = 'gmsh -3 ' + file_dir + '/' + geo_name + ' -o ' + work_dir + '/' + mesh_name +' -part ' + str(siz) - print command_line + print(command_line) tmp = shlex.split(command_line) fileout = open('gmsh.log','w') p = subprocess.Popen(tmp, stdin=subprocess.PIPE, stdout=fileout, stderr=fileout, env=os.environ, shell=False,close_fds=True) @@ -92,14 +93,14 @@ def main(): timers = slv.tms; if rank == 0: - print 'Map real CPU cost' - print timers['map'].read().getReal() - print 'Graph real CPU cost' - print timers['graph'].read().getReal() - print 'Matrix computation on each mpi process real CPU cost' - print timers['computeMatrices'].read().getReal() - print 'MPI sharing CPU cost' - print timers['assembly-MPI'].read().getReal() + print('Map real CPU cost') + print(timers['map'].read().getReal()) + print('Graph real CPU cost') + print(timers['graph'].read().getReal()) + print('Matrix computation on each mpi process real CPU cost') + print(timers['computeMatrices'].read().getReal()) + print('MPI sharing CPU cost') + print(timers['assembly-MPI'].read().getReal()) if __name__ == "__main__": main() diff --git a/mrstlnos/broken/cube_new_iterative.py b/mrstlnos/broken/cube_new_iterative.py index 3a2678fbcf6fbc78c3ef08643ae8a89fad37ec65..1f1fefbe48966c9f6b3c007d99eec8a55ec2f59c 100644 --- a/mrstlnos/broken/cube_new_iterative.py +++ b/mrstlnos/broken/cube_new_iterative.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -13,13 +14,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") @@ -41,7 +42,7 @@ def main(): if rank == 0: command_line = 'gmsh -3 ' + file_dir + '/' + geo_name + ' -o ' + work_dir + '/' + mesh_name +' -part ' + str(siz) - print command_line + print(command_line) tmp = shlex.split(command_line) fileout = open('gmsh.log','w') p = subprocess.Popen(tmp, stdin=subprocess.PIPE, stdout=fileout, stderr=fileout, env=os.environ, shell=False,close_fds=True) @@ -154,18 +155,18 @@ def main(): timers = slv.tms; if rank == 0: - print 'Map real CPU cost' - print timers['map'].read().getReal() - print 'Graph real CPU cost' - print timers['graph'].read().getReal() - print 'Matrix computation on each mpi process real CPU cost' - print timers['computeMatrices'].read().getReal() - print 'MPI sharing CPU cost' - print timers['assembly-MPI'].read().getReal() - print 'prec' - print timers['prec'].read().getReal() - print 'belos' - print timers['belos'].read().getReal() + print('Map real CPU cost') + print(timers['map'].read().getReal()) + print('Graph real CPU cost') + print(timers['graph'].read().getReal()) + print('Matrix computation on each mpi process real CPU cost') + print(timers['computeMatrices'].read().getReal()) + print('MPI sharing CPU cost') + print(timers['assembly-MPI'].read().getReal()) + print('prec') + print(timers['prec'].read().getReal()) + print('belos') + print(timers['belos'].read().getReal()) if __name__ == "__main__": main() diff --git a/mrstlnos/broken/cube_new_iterative_maxNorm.py b/mrstlnos/broken/cube_new_iterative_maxNorm.py index af2c50611fb9c3b99b67cde8be6c04afbc844b15..cd8ea87ec03e263f862fb8e25b655e616e2248f4 100644 --- a/mrstlnos/broken/cube_new_iterative_maxNorm.py +++ b/mrstlnos/broken/cube_new_iterative_maxNorm.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -40,13 +41,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") @@ -68,7 +69,7 @@ def main(): if rank == 0: command_line = 'gmsh -3 ' + file_dir + '/' + geo_name + ' -o ' + work_dir + '/' + mesh_name +' -part ' + str(siz) - print command_line + print(command_line) tmp = shlex.split(command_line) fileout = open('gmsh.log','w') p = subprocess.Popen(tmp, stdin=subprocess.PIPE, stdout=fileout, stderr=fileout, env=os.environ, shell=False,close_fds=True) @@ -184,9 +185,9 @@ def main(): sum_res[i] = sum(res) if rank == 0: - print expo - print max_it - print sum_res + print(expo) + print(max_it) + print(sum_res) if __name__ == "__main__": main() diff --git a/mrstlnos/broken/cube_new_submit.py b/mrstlnos/broken/cube_new_submit.py index 932a150a4b10d1d479ac12497c0ee9012f16717f..5c66aa1a86fac680069e85c576a95f2df0397d01 100644 --- a/mrstlnos/broken/cube_new_submit.py +++ b/mrstlnos/broken/cube_new_submit.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import shlex, subprocess import os import numpy as np @@ -29,10 +30,10 @@ def main(): if memPerCpu[i] < 2000: memPerCpu[i] = 2000 - print ntasks - print mm - print memPerCpu - print cpuPerTasks + print(ntasks) + print(mm) + print(memPerCpu) + print(cpuPerTasks) for i in range(0,d): @@ -45,10 +46,10 @@ def main(): python_current_file = file_dir+'/'+python_current_name - print current_file - print python_current_file + print(current_file) + print(python_current_file) - print os.getcwd() + print(os.getcwd()) # Cpu time replaceData(template_file,current_file,'*HH*','00') @@ -70,7 +71,7 @@ def main(): copyData(python_template_file,python_current_file) command_line = 'sbatch ' + current_name - print command_line + print(command_line) tmp = shlex.split(command_line) fileout = open(current_name+'.log','w') p = subprocess.Popen(tmp, stdin=subprocess.PIPE, stdout=fileout, stderr=fileout, env=os.environ, shell=False,close_fds=True) diff --git a/mrstlnos/broken/cylinder.py b/mrstlnos/broken/cylinder.py index ea41f2b796e895f69d4cd5dc684882094060b1a3..ed720aa727923b0e50aa1e9a2e63aaf8d5852359 100644 --- a/mrstlnos/broken/cylinder.py +++ b/mrstlnos/broken/cylinder.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -15,13 +16,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") from fwk.wutils import parseargs @@ -58,7 +59,7 @@ def main(): if rank == 0: command_line = 'gmsh -3 ' + file_dir + '/' + mesh_name + ' -o ' + work_dir + '/' + partitioned_mesh_name +' -part ' + str(siz) + ' -clscale ' + str(scale) - print command_line + print(command_line) tmp = shlex.split(command_line) fileout = open('gmsh.log','w') p = subprocess.Popen(tmp, stdin=subprocess.PIPE, stdout=fileout, stderr=fileout, env=os.environ, shell=False,close_fds=True) diff --git a/mrstlnos/broken/cylinder_2.py b/mrstlnos/broken/cylinder_2.py index af6672fb03779cd53fda10cca60007c41db43f71..a96e311f61be68c0d8dd5e456b6e83bdc52fff89 100644 --- a/mrstlnos/broken/cylinder_2.py +++ b/mrstlnos/broken/cylinder_2.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -13,13 +14,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") from fwk.wutils import parseargs @@ -56,7 +57,7 @@ def main(): if rank == 0: command_line = 'gmsh -3 ' + file_dir + '/' + mesh_name + ' -o ' + work_dir + '/' + partitioned_mesh_name +' -part ' + str(siz) + ' -clscale ' + str(scale) - print command_line + print(command_line) tmp = shlex.split(command_line) fileout = open('gmsh.log','w') p = subprocess.Popen(tmp, stdin=subprocess.PIPE, stdout=fileout, stderr=fileout, env=os.environ, shell=False,close_fds=True) diff --git a/mrstlnos/broken/cylinder_ensemble_size.py b/mrstlnos/broken/cylinder_ensemble_size.py index 6c7b3787b7132105967f326da2498c8a0e926667..3cd5a843d850d5a561c38a05729a67f0c6c30a24 100644 --- a/mrstlnos/broken/cylinder_ensemble_size.py +++ b/mrstlnos/broken/cylinder_ensemble_size.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -15,13 +16,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") from fwk.wutils import parseargs @@ -54,7 +55,7 @@ def main(): if rank == 0: command_line = 'gmsh -3 ' + file_dir + '/' + mesh_name + ' -o ' + work_dir + '/' + partitioned_mesh_name +' -part ' + str(siz) + ' -clscale ' + str(scale) - print command_line + print(command_line) tmp = shlex.split(command_line) fileout = open('gmsh.log','w') p = subprocess.Popen(tmp, stdin=subprocess.PIPE, stdout=fileout, stderr=fileout, env=os.environ, shell=False,close_fds=True) @@ -175,17 +176,17 @@ def main(): total_times[e] = slv.tms["total"].read().getReal().sec() if rank == 0: - print ensemble_sizes - print belos_times - print prec_times - print graph_times - print computeMatrices_times - print computeLoads_times - - print belos_matrix_times - print belos_prec_times - print belos_apply_times - print ortho_times + print(ensemble_sizes) + print(belos_times) + print(prec_times) + print(graph_times) + print(computeMatrices_times) + print(computeLoads_times) + + print(belos_matrix_times) + print(belos_prec_times) + print(belos_apply_times) + print(ortho_times) if __name__ == "__main__": main() diff --git a/mrstlnos/broken/discrete_problem.py b/mrstlnos/broken/discrete_problem.py index ed35fe4cc1d6fb0d64af6bfecc0abe0fb212139f..f5882e9fba57a9d45f84171e9ffbe4a94357b549 100644 --- a/mrstlnos/broken/discrete_problem.py +++ b/mrstlnos/broken/discrete_problem.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -13,13 +14,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") @@ -41,7 +42,7 @@ def main(): if rank == 0: command_line = 'gmsh -3 ' + file_dir + '/' + geo_name + ' -o ' + work_dir + '/' + mesh_name +' -part ' + str(siz) - print command_line + print(command_line) tmp = shlex.split(command_line) fileout = open('gmsh.log','w') p = subprocess.Popen(tmp, stdin=subprocess.PIPE, stdout=fileout, stderr=fileout, env=os.environ, shell=False,close_fds=True) @@ -92,14 +93,14 @@ def main(): timers = slv.tms; if rank == 0: - print 'Map real CPU cost' - print timers['map'].read().getReal() - print 'Graph real CPU cost' - print timers['graph'].read().getReal() - print 'Matrix computation on each mpi process real CPU cost' - print timers['computeMatrices'].read().getReal() - print 'MPI sharing CPU cost' - print timers['assembly-MPI'].read().getReal() + print('Map real CPU cost') + print(timers['map'].read().getReal()) + print('Graph real CPU cost') + print(timers['graph'].read().getReal()) + print('Matrix computation on each mpi process real CPU cost') + print(timers['computeMatrices'].read().getReal()) + print('MPI sharing CPU cost') + print(timers['assembly-MPI'].read().getReal()) if __name__ == "__main__": main() diff --git a/mrstlnos/broken/example2.py b/mrstlnos/broken/example2.py index b928ab369b0e15daaa8f4fd3c6de4b449303aeb8..a740e855241937732f198ebb5cae7a6b5439abb8 100644 --- a/mrstlnos/broken/example2.py +++ b/mrstlnos/broken/example2.py @@ -3,6 +3,7 @@ # runs the basic demo of Trilinos # trilinos-12.6.1-Source/demos/buildAgainstTrilinos +from __future__ import print_function import fwk.wutils as wu import mrstlnos @@ -14,13 +15,13 @@ def main(**d): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") import numpy as np from PyTrilinos import Teuchos diff --git a/mrstlnos/broken/hertz.py b/mrstlnos/broken/hertz.py index 6ab6ddaac6cb5c0965cf95d22fbe91fefd1e99f3..2f4c3211a8c2b58211f41a3f55ccae59775e3005 100644 --- a/mrstlnos/broken/hertz.py +++ b/mrstlnos/broken/hertz.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -13,13 +14,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") from fwk.wutils import parseargs @@ -56,7 +57,7 @@ def main(): if rank == 0: command_line = 'gmsh -3 ' + file_dir + '/' + mesh_name + ' -o ' + work_dir + '/' + partitioned_mesh_name +' -part ' + str(siz) + ' -clscale ' + str(scale) - print command_line + print(command_line) tmp = shlex.split(command_line) fileout = open('gmsh.log','w') p = subprocess.Popen(tmp, stdin=subprocess.PIPE, stdout=fileout, stderr=fileout, env=os.environ, shell=False,close_fds=True) diff --git a/mrstlnos/broken/mirror.py b/mrstlnos/broken/mirror.py index c3c47cdf28208966155be967114c64a00bc796dc..e6b7cb492d82b04ddd8091925f3daa7246c7ccd6 100644 --- a/mrstlnos/broken/mirror.py +++ b/mrstlnos/broken/mirror.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -13,13 +14,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") @@ -94,7 +95,7 @@ def main(): if rank == 0: command_line = 'gmsh -3 ' + file_dir + '/' + geo_name + ' -o ' + work_dir + '/' + mesh_name +' -part ' + str(siz) - print command_line + print(command_line) tmp = shlex.split(command_line) fileout = open('gmsh.log','w') p = subprocess.Popen(tmp, stdin=subprocess.PIPE, stdout=fileout, stderr=fileout, env=os.environ, shell=False,close_fds=True) diff --git a/mrstlnos/broken/model_problem.py b/mrstlnos/broken/model_problem.py index e2470c279388521d3ca980699ddf9fbd53e53486..61858bc47d0b13d8881caf876114c3b72bad5212 100644 --- a/mrstlnos/broken/model_problem.py +++ b/mrstlnos/broken/model_problem.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -13,13 +14,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") from fwk.wutils import parseargs @@ -53,7 +54,7 @@ def main(): if rank == 0: command_line = 'gmsh -3 ' + file_dir + '/' + geo_name + ' -o ' + work_dir + '/' + mesh_name +' -part ' + str(siz) - print command_line + print(command_line) tmp = shlex.split(command_line) fileout = open('gmsh.log','w') p = subprocess.Popen(tmp, stdin=subprocess.PIPE, stdout=fileout, stderr=fileout, env=os.environ, shell=False,close_fds=True) diff --git a/mrstlnos/broken/test_memory.py b/mrstlnos/broken/test_memory.py index e8a7f13cf1093660a89a26eae0f5176b79832b46..df4a0d06a1ccd92941697df24efef6188d18e84f 100644 --- a/mrstlnos/broken/test_memory.py +++ b/mrstlnos/broken/test_memory.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -14,13 +15,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") @@ -42,7 +43,7 @@ def main(): if rank == 0: command_line = 'gmsh -3 ' + file_dir + '/' + geo_name + ' -o ' + work_dir + '/' + mesh_name +' -part ' + str(siz) - print command_line + print(command_line) tmp = shlex.split(command_line) fileout = open('gmsh.log','w') p = subprocess.Popen(tmp, stdin=subprocess.PIPE, stdout=fileout, stderr=fileout, env=os.environ, shell=False,close_fds=True) diff --git a/mrstlnos/broken/test_memory_2.py b/mrstlnos/broken/test_memory_2.py index cf91b374b7440f5ad0c9f66ae91c1de73be21d22..558897c64ad55c81447820e109cd6aa955a9b85f 100644 --- a/mrstlnos/broken/test_memory_2.py +++ b/mrstlnos/broken/test_memory_2.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -13,13 +14,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") from fwk.wutils import parseargs @@ -64,7 +65,7 @@ def main(): if rank == 0: command_line = 'gmsh -3 ' + work_dir + '/' + mesh_name + ' -o ' + work_dir + '/' + partitioned_mesh_name +' -part ' + str(siz) - print command_line + print(command_line) tmp = shlex.split(command_line) fileout = open('gmsh.log','w') p = subprocess.Popen(tmp, stdin=subprocess.PIPE, stdout=fileout, stderr=fileout, env=os.environ, shell=False,close_fds=True) diff --git a/mrstlnos/broken/thermal_stress_1.py b/mrstlnos/broken/thermal_stress_1.py index 97f0a1aee7c6cdf02b9b1244b86e5bdb2d75e0b2..c9f75e3e1080dbbe5fe22624fead470f6b90aacb 100644 --- a/mrstlnos/broken/thermal_stress_1.py +++ b/mrstlnos/broken/thermal_stress_1.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -14,13 +15,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") @@ -45,7 +46,7 @@ def main(): if rank == 0: command_line = 'gmsh -3 ' + work_dir + '/' + mesh_name + ' -o ' + work_dir + '/' + partitioned_mesh_name +' -part ' + str(siz) - print command_line + print(command_line) tmp = shlex.split(command_line) fileout = open('gmsh.log','w') p = subprocess.Popen(tmp, stdin=subprocess.PIPE, stdout=fileout, stderr=fileout, env=os.environ, shell=False,close_fds=True) diff --git a/mrstlnos/broken/thermal_stress_2.py b/mrstlnos/broken/thermal_stress_2.py index b038bec3be8cf23ee4f83da48609366d289875b3..38bbe7fbdbe45073820a01d712140ce04a4733dc 100644 --- a/mrstlnos/broken/thermal_stress_2.py +++ b/mrstlnos/broken/thermal_stress_2.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -14,13 +15,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") @@ -45,7 +46,7 @@ def main(): if rank == 0: command_line = 'gmsh -3 ' + work_dir + '/' + mesh_name + ' -o ' + work_dir + '/' + partitioned_mesh_name +' -part ' + str(siz) - print command_line + print(command_line) tmp = shlex.split(command_line) fileout = open('gmsh.log','w') p = subprocess.Popen(tmp, stdin=subprocess.PIPE, stdout=fileout, stderr=fileout, env=os.environ, shell=False,close_fds=True) diff --git a/mrstlnos/convergence.py b/mrstlnos/convergence.py index 53fb09d1eb5899ab6d31e26a039ac2a1563b78ce..ae2dc421f22487306624aea5d7e827b934bacbdc 100644 --- a/mrstlnos/convergence.py +++ b/mrstlnos/convergence.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import numpy as np verb = False # set to True for (a lot of) debug info @@ -100,7 +101,7 @@ def compute_sum_of_product_times_product(k,n,omegas,deltas): results_product_1 = 1. results_product_2 = 1. index = i1.get_i() - print index + print(index) results_product_1 = results_product_1 * np.prod(omegas[index]) i2 = Index_no_repetition_2(index) while True: @@ -121,7 +122,7 @@ def compute_convergence_serial(k_max,n,omegas,deltas,A,b,x0,verbose): new_sum = compute_sum_of_product_times_product(k+1,n,omegas,deltas) convergence[k] = new_sum/old_sum if verbose: - print convergence + print(convergence) old_sum = new_sum return convergence @@ -144,7 +145,7 @@ def compute_convergence_mpi(k_max,n,omegas,deltas,A,b,x0,verbose): convergence[k] = new_sum/old_sum old_sum = new_sum if verbose: - print convergence + print(convergence) else: worker = Worker(rank) worker.start() @@ -191,12 +192,12 @@ class Master: global rank if rank!=0: raise Exception("this routine should be called with MPI rank=0") - if verb: print "[%d] starting master" % rank + if verb: print("[%d] starting master" % rank) ##----------------------------------------- for s in self.slaves: - if verb: print "[%d] sending wake-up signal to worker %d" % (rank,s) + if verb: print("[%d] sending wake-up signal to worker %d" % (rank,s)) comm.send(None, dest=s, tag=tags.WAKEUP) ################################################# @@ -215,14 +216,14 @@ class Master: source = status.Get_source() tag = status.Get_tag() if tag == tags.READY: - if verb: print "[0] worker %d is ready" % source + if verb: print("[0] worker %d is ready" % source) ################################################# if i1.get_is_valid(): job = Job(omegas,deltas,i1.get_i()) - if verb: print "[0] sending job to %d" % source + if verb: print("[0] sending job to %d" % source) comm.send(job, dest=source, tag=tags.START) # ------------------- @@ -232,11 +233,11 @@ class Master: ################################################# - if verb: print "[%d] exit %d" % (rank,source) + if verb: print("[%d] exit %d" % (rank,source)) comm.send(None, dest=source, tag=tags.EXIT) elif tag==tags.DONE: - if verb: print "[0] worker %d gives me its results" % source + if verb: print("[0] worker %d gives me its results" % source) ################################################# results_sum = results_sum + data.partial_sum @@ -244,7 +245,7 @@ class Master: elif tag==tags.EXIT: closed_workers+=1 - if verb: print "[0] worker %d exited (%d worker(s) still running)" % (source, num_workers-closed_workers) + if verb: print("[0] worker %d exited (%d worker(s) still running)" % (source, num_workers-closed_workers)) ##----------------------------------------- @@ -255,7 +256,7 @@ class Master: def killslaves(self): global rank for s in self.slaves: - if verb: print "[%d] sending suicide job to %d" % (rank,s) + if verb: print("[%d] sending suicide job to %d" % (rank,s)) comm.send(None, dest=s, tag=tags.SUICIDE) @@ -273,25 +274,25 @@ class Worker: if self.rank==0: raise Exception("this routine should be called with MPI rank!=0") - if verb: print "[%d] starting worker" % self.rank + if verb: print("[%d] starting worker" % self.rank) while True: comm.recv(source=0, tag=mpi.ANY_TAG, status=status) tag = status.Get_tag() if tag==tags.WAKEUP: - if verb: print "[%d] waking up" % self.rank + if verb: print("[%d] waking up" % self.rank) while True: comm.send(None, dest=0, tag=tags.READY) job = comm.recv(source=0, tag=mpi.ANY_TAG, status=status) tag = status.Get_tag() if tag==tags.START: - if verb: print "[%d] starting job" % self.rank + if verb: print("[%d] starting job" % self.rank) job.execute() - if verb: print "[%d] sending job results" % self.rank + if verb: print("[%d] sending job results" % self.rank) comm.send(job, dest=0, tag=tags.DONE) elif tag==tags.EXIT: - if verb: print "[%d] sending exit confirmation" % self.rank + if verb: print("[%d] sending exit confirmation" % self.rank) comm.send(None, dest=0, tag=tags.EXIT) break elif tag==tags.SUICIDE: - if verb: print "[%d] I'm dying..." % self.rank + if verb: print("[%d] I'm dying..." % self.rank) break diff --git a/mrstlnos/eigenvalues.py b/mrstlnos/eigenvalues.py index a1643d4afadbd91a9d347b805729ebac869bd974..da7f730a8fce5182093afa449d97b81bff49b998 100644 --- a/mrstlnos/eigenvalues.py +++ b/mrstlnos/eigenvalues.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import numpy as np from scipy.linalg import eig @@ -141,8 +142,8 @@ def SIMPLE_prec(Q,invQ,G,GT,R,invR,use_invQG=False,omega=1.): n1 = Q.shape[0] n2 = R.shape[0] if use_invQG: - print 'Warning: use_invQG is OK in SIMPLE only if we use a direct solver for each block for now' - print 'Warning: this returned the preconditioned matrix and not the preconditioner matrix' + print('Warning: use_invQG is OK in SIMPLE only if we use a direct solver for each block for now') + print('Warning: this returned the preconditioned matrix and not the preconditioner matrix') GTinvQ = invQ.T invP = create_block(eye(n1)-(eye(n1)-Q*invD)*G*invR*GTinvQ,(eye(n1)-Q*invD)*G*invR,None,eye(n2)) else: @@ -437,7 +438,7 @@ def diagonal_dominance(A): sum_row = np.sum(np.absolute(A[i,:])) sum_row = sum_row - diag if diag <= sum_row: - print str(diag) + ' <= ' + str(sum_row) + ' at row ' + str(i) + print(str(diag) + ' <= ' + str(sum_row) + ' at row ' + str(i)) is_diagonal_dominance = False break return is_diagonal_dominance diff --git a/mrstlnos/old_tests/3bodies.py b/mrstlnos/old_tests/3bodies.py index 8348354557c7808bac34c26b4b25ce1099ace6ac..8c6d22bf255d841c9ff5709b76b445f10c60e0be 100644 --- a/mrstlnos/old_tests/3bodies.py +++ b/mrstlnos/old_tests/3bodies.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -13,13 +14,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") from fwk.wutils import parseargs @@ -106,7 +107,7 @@ def main(): slv = m.Solver(pbl,args.k,solverList,4) - print slv + print(slv) import mrstlnos.viewer as v gui = v.MeshViewer(pbl,slv,msh) diff --git a/mrstlnos/old_tests/3bodies2.py b/mrstlnos/old_tests/3bodies2.py index 9a1c9e247381cccb6cdfa9fc96babce0cf57c73b..1373ec561bbea53e457c0fca4d397a41d5ad596f 100644 --- a/mrstlnos/old_tests/3bodies2.py +++ b/mrstlnos/old_tests/3bodies2.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -13,13 +14,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") from fwk.wutils import parseargs @@ -95,7 +96,7 @@ def main(): slv = m.Solver(pbl,args.k,solverList,4) - print slv + print(slv) import mrstlnos.viewer as v gui = v.MeshViewer(pbl,slv,msh) diff --git a/mrstlnos/old_tests/bolt.py b/mrstlnos/old_tests/bolt.py index e37e017478276c00e1588937b3e7b3e0af48cd44..6a7b588429083fd60bef309e0935c50e52d94e28 100644 --- a/mrstlnos/old_tests/bolt.py +++ b/mrstlnos/old_tests/bolt.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -13,13 +14,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") from fwk.wutils import parseargs @@ -83,7 +84,7 @@ def main(): slv = m.Solver(pbl,args.k,solverList,4) - print slv + print(slv) if not args.nogui: import mrstlnos.viewer as v @@ -94,7 +95,7 @@ def main(): else: slv.start() - print slv.belos_iter + print(slv.belos_iter) if __name__ == "__main__": main() diff --git a/mrstlnos/old_tests/bolt2.py b/mrstlnos/old_tests/bolt2.py index 3ff2ea7cfd7a7a8fe27b576ae8e808a600bbbd83..857399ce0d5bbf99f5f3d259dbf5deb28a211027 100644 --- a/mrstlnos/old_tests/bolt2.py +++ b/mrstlnos/old_tests/bolt2.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -13,13 +14,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") from fwk.wutils import parseargs @@ -83,7 +84,7 @@ def main(): slv = m.Solver(pbl,args.k,solverList,4) - print slv + print(slv) if not args.nogui: import mrstlnos.viewer as v @@ -94,7 +95,7 @@ def main(): else: slv.start() - print slv.belos_iter + print(slv.belos_iter) if __name__ == "__main__": main() diff --git a/mrstlnos/old_tests/bolt3.py b/mrstlnos/old_tests/bolt3.py index cd936ced1c7a183777d89b8ff92f5255d44d5a73..a082904c1be817f310cf525460c4ed8a3b684f02 100644 --- a/mrstlnos/old_tests/bolt3.py +++ b/mrstlnos/old_tests/bolt3.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -13,13 +14,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") from fwk.wutils import parseargs @@ -110,7 +111,7 @@ def main(): slv = m.Solver(pbl,args.k,solverList,4) - print slv + print(slv) if not args.nogui: import mrstlnos.viewer as v @@ -121,7 +122,7 @@ def main(): else: slv.start() - print slv.belos_iter + print(slv.belos_iter) if __name__ == "__main__": main() diff --git a/mrstlnos/old_tests/bolt_muelu.py b/mrstlnos/old_tests/bolt_muelu.py index 03ea78795e380dbb94fb5c2339868298c8dee5bf..eb9a2861e296a9bf43de6e8b04c03cf600e628f3 100644 --- a/mrstlnos/old_tests/bolt_muelu.py +++ b/mrstlnos/old_tests/bolt_muelu.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -13,13 +14,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") from fwk.wutils import parseargs diff --git a/mrstlnos/old_tests/bolt_muelu2.py b/mrstlnos/old_tests/bolt_muelu2.py index 159d0cd66df1cf8a904c7c0bb4403295539d33d5..3b7374e965586a3f6a7231a1a6a16e526b7bad3c 100644 --- a/mrstlnos/old_tests/bolt_muelu2.py +++ b/mrstlnos/old_tests/bolt_muelu2.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -13,13 +14,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") from fwk.wutils import parseargs diff --git a/mrstlnos/old_tests/bolt_p4.py b/mrstlnos/old_tests/bolt_p4.py index 50cf93736d380ea3f377ccf5e41caf2a64804636..c299593739b898a658facd74ecd51a1a4840666f 100644 --- a/mrstlnos/old_tests/bolt_p4.py +++ b/mrstlnos/old_tests/bolt_p4.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -13,13 +14,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") from fwk.wutils import parseargs @@ -120,9 +121,9 @@ def main(): else: slv.start() - print slv.belos_time - print slv.prec_time - print slv.belos_iter + print(slv.belos_time) + print(slv.prec_time) + print(slv.belos_iter) if __name__ == "__main__": main() diff --git a/mrstlnos/old_tests/bolt_p4_2.py b/mrstlnos/old_tests/bolt_p4_2.py index 80799fa4d17130ea93a2114b4cc1d8c8623a9da6..ec4581fb47a1be0766571fcdaf80390fcd11ea10 100644 --- a/mrstlnos/old_tests/bolt_p4_2.py +++ b/mrstlnos/old_tests/bolt_p4_2.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -13,13 +14,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") from fwk.wutils import parseargs @@ -120,9 +121,9 @@ def main(): else: slv.start() - print slv.belos_time - print slv.prec_time - print slv.belos_iter + print(slv.belos_time) + print(slv.prec_time) + print(slv.belos_iter) if __name__ == "__main__": main() diff --git a/mrstlnos/old_tests/bolt_p4_muelu.py b/mrstlnos/old_tests/bolt_p4_muelu.py index 07791ba1da8462983b0c1711c552e17e659887e5..16a0786139d0fcefe809dfc4ab81acee14d92a10 100644 --- a/mrstlnos/old_tests/bolt_p4_muelu.py +++ b/mrstlnos/old_tests/bolt_p4_muelu.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -13,13 +14,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") from fwk.wutils import parseargs @@ -120,9 +121,9 @@ def main(): else: slv.start() - print slv.belos_time - print slv.prec_time - print slv.belos_iter + print(slv.belos_time) + print(slv.prec_time) + print(slv.belos_iter) if __name__ == "__main__": main() diff --git a/mrstlnos/old_tests/mirrors.py b/mrstlnos/old_tests/mirrors.py index 2cbc85a4ffa20ca18b4b056838eb617727a1925b..21dcaef891ff6adc044f66b67b47ff490ab328aa 100755 --- a/mrstlnos/old_tests/mirrors.py +++ b/mrstlnos/old_tests/mirrors.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -13,13 +14,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") from fwk.wutils import parseargs @@ -69,7 +70,7 @@ def main(): slv = m.Solver(pbl,args.k,solverList,4) - print slv + print(slv) import mrstlnos.viewer as v gui = v.MeshViewer(pbl,slv,msh) diff --git a/mrstlnos/old_tests/mirrors01.py b/mrstlnos/old_tests/mirrors01.py index 10bdcc66f5d8904b165014078e9dbe15c7b8e01a..995a161eee3ee5ad786c97ba221ea4a8ce887066 100644 --- a/mrstlnos/old_tests/mirrors01.py +++ b/mrstlnos/old_tests/mirrors01.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -13,13 +14,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") diff --git a/mrstlnos/old_tests/mirrors01_all.py b/mrstlnos/old_tests/mirrors01_all.py index 5caa2e10c992591572370b34a5cc93cafd0802c1..d88304ccf584471353c42547eba19166b720d9d8 100644 --- a/mrstlnos/old_tests/mirrors01_all.py +++ b/mrstlnos/old_tests/mirrors01_all.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -13,13 +14,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") diff --git a/mrstlnos/old_tests/mirrors01_all2.py b/mrstlnos/old_tests/mirrors01_all2.py index 44261416bb9749ba4ee2717a0afca773c3e0cecc..829b8c0c4c757e0c392a1a59e75852c9a3f9dfbb 100644 --- a/mrstlnos/old_tests/mirrors01_all2.py +++ b/mrstlnos/old_tests/mirrors01_all2.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -13,13 +14,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") diff --git a/mrstlnos/old_tests/mirrors02.py b/mrstlnos/old_tests/mirrors02.py index 7c0062116d6f6cf5ccb19b5bf8dba03313c9ab81..947f037bcf335fa58db901f55dc4aa51a7035493 100755 --- a/mrstlnos/old_tests/mirrors02.py +++ b/mrstlnos/old_tests/mirrors02.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -27,7 +28,7 @@ def main(): slv = m.Solver(pbl) - print slv + print(slv) import mrstlnos.viewer as v gui = v.MeshViewer(pbl,slv) diff --git a/mrstlnos/old_tests/mirrors03.py b/mrstlnos/old_tests/mirrors03.py index 434d61bb294f0cd96a49380972a29160894f0053..066ea2f4949262deb09313764a63028b5610f575 100755 --- a/mrstlnos/old_tests/mirrors03.py +++ b/mrstlnos/old_tests/mirrors03.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -14,13 +15,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") from fwk.wutils import parseargs args=parseargs() @@ -29,7 +30,7 @@ def main(): msh = gmsh.MeshLoader("M1_all.msh",__file__).execute() - print msh + print(msh) pbl = m.Problem(msh,comm) m.Medium(pbl, 302, "TZM",330000,0.36) clamped = tbox.Pt(1,1,1) diff --git a/mrstlnos/old_tests/mirrors05.py b/mrstlnos/old_tests/mirrors05.py index 48ef776aff2170e1ec357d5118e7aa88e46617a8..64dfa714f9e6f03cd7e59dcc9b6ca49ad66cc3c8 100755 --- a/mrstlnos/old_tests/mirrors05.py +++ b/mrstlnos/old_tests/mirrors05.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -13,13 +14,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") msh = gmsh.MeshLoader("mirrors01_ansys_partition_8.msh",__file__).myrank_execute(rank) pbl = m.Problem(msh,comm) diff --git a/mrstlnos/old_tests/mirrors06.py b/mrstlnos/old_tests/mirrors06.py index 1a948b5ea7f13c4b6234b74b7d2b71931a9a9371..741ccc791bfee04f9d99482bf8496cefa2aa9ccc 100755 --- a/mrstlnos/old_tests/mirrors06.py +++ b/mrstlnos/old_tests/mirrors06.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -13,13 +14,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") msh = gmsh.MeshLoader("mirrors01_ansys_partition_4_refined.msh",__file__).myrank_execute(rank) pbl = m.Problem(msh,comm) diff --git a/mrstlnos/old_tests/mirrors2.py b/mrstlnos/old_tests/mirrors2.py index 969e75934fef26e22927e3d0d9281e04159516ff..a58994f7ace8dda0a5ff1fc7f3cbe426802ca1a9 100644 --- a/mrstlnos/old_tests/mirrors2.py +++ b/mrstlnos/old_tests/mirrors2.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -13,13 +14,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") from fwk.wutils import parseargs @@ -67,7 +68,7 @@ def main(): slv = m.Solver(pbl,args.k,solverList,4) - print slv + print(slv) if not args.nogui: import mrstlnos.viewer as v diff --git a/mrstlnos/old_tests/mirrors2_p3.py b/mrstlnos/old_tests/mirrors2_p3.py index 0130762c3ef6e63d5b4fd6e36826f7c4d66e2229..98a9bc8486c164c564ed0701b08fc2cb7e490147 100644 --- a/mrstlnos/old_tests/mirrors2_p3.py +++ b/mrstlnos/old_tests/mirrors2_p3.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -13,13 +14,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") from fwk.wutils import parseargs diff --git a/mrstlnos/old_tests/mirrors2_p3s.py b/mrstlnos/old_tests/mirrors2_p3s.py index 06dca34e8566e6d9a5a869afde5fea94387af31e..c5bca79a5f9e3d569bb79c497dcd62fd02d38820 100644 --- a/mrstlnos/old_tests/mirrors2_p3s.py +++ b/mrstlnos/old_tests/mirrors2_p3s.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -13,13 +14,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") from fwk.wutils import parseargs diff --git a/mrstlnos/old_tests/mirrors3.py b/mrstlnos/old_tests/mirrors3.py index e2d7aef46e737c046504f093cb4fb8739dbc30a0..a989035ab2dd6e8aac72926f2cfdd1d3120a7bb7 100644 --- a/mrstlnos/old_tests/mirrors3.py +++ b/mrstlnos/old_tests/mirrors3.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -13,13 +14,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") from fwk.wutils import parseargs @@ -69,7 +70,7 @@ def main(): slv = m.Solver(pbl,args.k,solverList,True) - print slv + print(slv) if not args.nogui: import mrstlnos.viewer as v diff --git a/mrstlnos/old_tests/mirrors4.py b/mrstlnos/old_tests/mirrors4.py index aaed28a74839a36642232049580b52eb072af09a..e775597cf8cdb82882ab9fb1341f7df645e7cfb9 100644 --- a/mrstlnos/old_tests/mirrors4.py +++ b/mrstlnos/old_tests/mirrors4.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -13,13 +14,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") from fwk.wutils import parseargs @@ -63,7 +64,7 @@ def main(): slv = m.Solver(pbl,args.k,solverList,4) - print slv + print(slv) if not args.nogui: import mrstlnos.viewer as v diff --git a/mrstlnos/old_tests/mirrors5.py b/mrstlnos/old_tests/mirrors5.py index 6f140e9196c1da13a5af00eaa1a2a3e4c82ee0cd..6c330495c124e93df1a895022520478a02b04411 100644 --- a/mrstlnos/old_tests/mirrors5.py +++ b/mrstlnos/old_tests/mirrors5.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -13,13 +14,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") from fwk.wutils import parseargs @@ -88,7 +89,7 @@ def main(): slv = m.Solver(pbl,args.k,solverList,4) - print slv + print(slv) if not args.nogui: import mrstlnos.viewer as v diff --git a/mrstlnos/old_tests/mirrors6.py b/mrstlnos/old_tests/mirrors6.py index d918c9676aee58910dfa14deae8260b11c5b3466..b3f57869b3887d1a8f2632874acdeacff07eeb67 100644 --- a/mrstlnos/old_tests/mirrors6.py +++ b/mrstlnos/old_tests/mirrors6.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -13,13 +14,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") from fwk.wutils import parseargs @@ -68,7 +69,7 @@ def main(): slv = m.Solver(pbl,args.k,solverList,4) - print slv + print(slv) if not args.nogui: import mrstlnos.viewer as v diff --git a/mrstlnos/speedup.py b/mrstlnos/speedup.py index ce0494ff77b2acf367f0c5f4c2b751a6b4770d08..0138bce946f38eb1b9edd635e93f44c520334511 100644 --- a/mrstlnos/speedup.py +++ b/mrstlnos/speedup.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import numpy as np from mrstlnos.readers import * @@ -61,7 +62,7 @@ def compute_speedup(n_samples,ensemble_sizes,file_base_dir,querylines,per_iterat sum_iter = sum_iter + iter[i_no_ep][j*ensemble_sizes[i]+k] cum_timers[0][j][l] = cum_timers[0][j][l] / sum_iter if cum_timers[0][j][l] == 0: - print 'Warning! The cumulated cpu cost of ' + querylines[l] + ' is zero and is replaced by ' + str(0.01 / sum_iter) + ', the precision of the timers has to be increased or the test is too small.' + print('Warning! The cumulated cpu cost of ' + querylines[l] + ' is zero and is replaced by ' + str(0.01 / sum_iter) + ', the precision of the timers has to be increased or the test is too small.') cum_timers[0][j][l] = 0.01 / sum_iter if per_iteration[l]: cum_timers[1][j][l] = timers[i][j*ensemble_sizes[i]][l] / (iter[i][j*ensemble_sizes[i]]*ensemble_sizes[i]) diff --git a/mrstlnos/tests/1_cube.py b/mrstlnos/tests/1_cube.py index ee3fd6ae03e87035bfd6ffb9bb84bf93cedd6b39..792be0601792ed0e56e0609a52c417edd5368a51 100644 --- a/mrstlnos/tests/1_cube.py +++ b/mrstlnos/tests/1_cube.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -15,13 +16,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") from fwk.wutils import parseargs args=parseargs() @@ -44,7 +45,7 @@ def main(): if rank == 0: command_line = 'gmsh -3 ' + work_dir + '/' + mesh_name + ' -o ' + work_dir + '/' + partitioned_mesh_name +' -part ' + str(siz) - print command_line + print(command_line) tmp = shlex.split(command_line) fileout = open('gmsh.log','w') p = subprocess.Popen(tmp, stdin=subprocess.PIPE, stdout=fileout, stderr=fileout, env=os.environ, shell=False,close_fds=True) diff --git a/mrstlnos/tests/1_cube_k.py b/mrstlnos/tests/1_cube_k.py index 4fdf936ec95373eccc8a4838cadd462a24495b0a..f0adf1e951781794dc984cb45e6f5d222d1b84c1 100644 --- a/mrstlnos/tests/1_cube_k.py +++ b/mrstlnos/tests/1_cube_k.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -15,13 +16,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") from fwk.wutils import parseargs args=parseargs() @@ -44,7 +45,7 @@ def main(): if rank == 0: command_line = 'gmsh -3 ' + work_dir + '/' + mesh_name + ' -o ' + work_dir + '/' + partitioned_mesh_name +' -part ' + str(siz) - print command_line + print(command_line) tmp = shlex.split(command_line) fileout = open('gmsh.log','w') p = subprocess.Popen(tmp, stdin=subprocess.PIPE, stdout=fileout, stderr=fileout, env=os.environ, shell=False,close_fds=True) diff --git a/mrstlnos/tests/1_cube_rf.py b/mrstlnos/tests/1_cube_rf.py index 343098f4411bf036820d22190748b87b47da87e0..24a4ceb0026668c27bb5107846974c4133764b99 100644 --- a/mrstlnos/tests/1_cube_rf.py +++ b/mrstlnos/tests/1_cube_rf.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -15,13 +16,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") from fwk.wutils import parseargs args=parseargs() @@ -44,7 +45,7 @@ def main(): if rank == 0: command_line = 'gmsh -3 ' + work_dir + '/' + mesh_name + ' -o ' + work_dir + '/' + partitioned_mesh_name +' -part ' + str(siz) - print command_line + print(command_line) tmp = shlex.split(command_line) fileout = open('gmsh.log','w') p = subprocess.Popen(tmp, stdin=subprocess.PIPE, stdout=fileout, stderr=fileout, env=os.environ, shell=False,close_fds=True) diff --git a/mrstlnos/tests/1_cube_tet.py b/mrstlnos/tests/1_cube_tet.py index 3d8d97029ee1a73c065de8a176ca316ffa89708a..137056440d296644fcb7d64e1808f8e9c1ad69c6 100644 --- a/mrstlnos/tests/1_cube_tet.py +++ b/mrstlnos/tests/1_cube_tet.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -15,13 +16,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") from fwk.wutils import parseargs args=parseargs() @@ -44,7 +45,7 @@ def main(): if rank == 0: command_line = 'gmsh -3 ' + work_dir + '/' + mesh_name + ' -o ' + work_dir + '/' + partitioned_mesh_name +' -part ' + str(siz) - print command_line + print(command_line) tmp = shlex.split(command_line) fileout = open('gmsh.log','w') p = subprocess.Popen(tmp, stdin=subprocess.PIPE, stdout=fileout, stderr=fileout, env=os.environ, shell=False,close_fds=True) diff --git a/mrstlnos/tests/2_cubes.py b/mrstlnos/tests/2_cubes.py index 65d4b306976e5fb3346da0c7ba36eb1d7cdcd2dc..24830ff171bc5557168df06d269fe9808771db6b 100644 --- a/mrstlnos/tests/2_cubes.py +++ b/mrstlnos/tests/2_cubes.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -14,13 +15,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") @@ -45,7 +46,7 @@ def main(): if rank == 0: command_line = 'gmsh -3 ' + work_dir + '/' + mesh_name + ' -o ' + work_dir + '/' + partitioned_mesh_name +' -part ' + str(siz) - print command_line + print(command_line) tmp = shlex.split(command_line) fileout = open('gmsh.log','w') p = subprocess.Popen(tmp, stdin=subprocess.PIPE, stdout=fileout, stderr=fileout, env=os.environ, shell=False,close_fds=True) diff --git a/mrstlnos/tests/2_cubes_heat.py b/mrstlnos/tests/2_cubes_heat.py index baf243a162564dd32aede23895df7743a44df67c..4410dc6c05cd31be7f36b42f5ec3ee091a1352b8 100644 --- a/mrstlnos/tests/2_cubes_heat.py +++ b/mrstlnos/tests/2_cubes_heat.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -14,13 +15,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") @@ -45,7 +46,7 @@ def main(): if rank == 0: command_line = 'gmsh -3 ' + work_dir + '/' + mesh_name + ' -o ' + work_dir + '/' + partitioned_mesh_name +' -part ' + str(siz) - print command_line + print(command_line) tmp = shlex.split(command_line) fileout = open('gmsh.log','w') p = subprocess.Popen(tmp, stdin=subprocess.PIPE, stdout=fileout, stderr=fileout, env=os.environ, shell=False,close_fds=True) diff --git a/mrstlnos/tests/2_cubes_no_contact.py b/mrstlnos/tests/2_cubes_no_contact.py index 53aff47435930a17e722f3f2af470258b3b057a8..62558c738c3896b66a0206cec0f5601b58cf840f 100644 --- a/mrstlnos/tests/2_cubes_no_contact.py +++ b/mrstlnos/tests/2_cubes_no_contact.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -13,13 +14,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") from fwk.wutils import parseargs args=parseargs() @@ -42,7 +43,7 @@ def main(): if rank == 0: command_line = 'gmsh -3 ' + work_dir + '/' + mesh_name + ' -o ' + work_dir + '/' + partitioned_mesh_name +' -part ' + str(siz) - print command_line + print(command_line) tmp = shlex.split(command_line) fileout = open('gmsh.log','w') p = subprocess.Popen(tmp, stdin=subprocess.PIPE, stdout=fileout, stderr=fileout, env=os.environ, shell=False,close_fds=True) diff --git a/mrstlnos/tests/2_cubes_patch.py b/mrstlnos/tests/2_cubes_patch.py index 08c25394b6bc7a5e9afd5dbc3ded61b97d6cffe4..7e20fb5b411f97ff3bd3de56e8ef7ee6f54a930a 100644 --- a/mrstlnos/tests/2_cubes_patch.py +++ b/mrstlnos/tests/2_cubes_patch.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -17,13 +18,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") from fwk.wutils import parseargs args=parseargs() @@ -46,7 +47,7 @@ def main(): if rank == 0: command_line = 'gmsh -3 ' + work_dir + '/' + mesh_name + ' -o ' + work_dir + '/' + partitioned_mesh_name +' -part ' + str(siz) - print command_line + print(command_line) tmp = shlex.split(command_line) fileout = open('gmsh.log','w') p = subprocess.Popen(tmp, stdin=subprocess.PIPE, stdout=fileout, stderr=fileout, env=os.environ, shell=False,close_fds=True) diff --git a/mrstlnos/tests/2_cubes_patch_2_lvls.py b/mrstlnos/tests/2_cubes_patch_2_lvls.py index 8a2511554ce76feeeb426e2496003ee9b8201c9b..1378918bf051e403e5bb4267eb0cfa50b9406f31 100644 --- a/mrstlnos/tests/2_cubes_patch_2_lvls.py +++ b/mrstlnos/tests/2_cubes_patch_2_lvls.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -14,13 +15,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") @@ -45,7 +46,7 @@ def main(): if rank == 0: command_line = 'gmsh -3 ' + work_dir + '/' + mesh_name + ' -o ' + work_dir + '/' + partitioned_mesh_name +' -part ' + str(siz) - print command_line + print(command_line) tmp = shlex.split(command_line) fileout = open('gmsh.log','w') p = subprocess.Popen(tmp, stdin=subprocess.PIPE, stdout=fileout, stderr=fileout, env=os.environ, shell=False,close_fds=True) diff --git a/mrstlnos/tests/2_cubes_patch_BraessSarazin.py b/mrstlnos/tests/2_cubes_patch_BraessSarazin.py index 48362b3f34d403756ca20232de6445be1ecf54b5..6610acdfe8bbb6731cf95a8b8ddd455822b25ceb 100644 --- a/mrstlnos/tests/2_cubes_patch_BraessSarazin.py +++ b/mrstlnos/tests/2_cubes_patch_BraessSarazin.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -14,13 +15,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") @@ -45,7 +46,7 @@ def main(): if rank == 0: command_line = 'gmsh -3 ' + work_dir + '/' + mesh_name + ' -o ' + work_dir + '/' + partitioned_mesh_name +' -part ' + str(siz) - print command_line + print(command_line) tmp = shlex.split(command_line) fileout = open('gmsh.log','w') p = subprocess.Popen(tmp, stdin=subprocess.PIPE, stdout=fileout, stderr=fileout, env=os.environ, shell=False,close_fds=True) diff --git a/mrstlnos/tests/2_cubes_patch_IndefBlockDiagonal.py b/mrstlnos/tests/2_cubes_patch_IndefBlockDiagonal.py index c788ac556b7dd5da4f03d15b28f226dab3025f01..dc0bfd36647b1fe76fbc2cc6f0467a11190d1112 100644 --- a/mrstlnos/tests/2_cubes_patch_IndefBlockDiagonal.py +++ b/mrstlnos/tests/2_cubes_patch_IndefBlockDiagonal.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -14,13 +15,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") @@ -45,7 +46,7 @@ def main(): if rank == 0: command_line = 'gmsh -3 ' + work_dir + '/' + mesh_name + ' -o ' + work_dir + '/' + partitioned_mesh_name +' -part ' + str(siz) - print command_line + print(command_line) tmp = shlex.split(command_line) fileout = open('gmsh.log','w') p = subprocess.Popen(tmp, stdin=subprocess.PIPE, stdout=fileout, stderr=fileout, env=os.environ, shell=False,close_fds=True) diff --git a/mrstlnos/tests/2_cubes_patch_SIMPLE.py b/mrstlnos/tests/2_cubes_patch_SIMPLE.py index 53ea27b661b7403dd10b9ee23dc6d85d2e6e3ae6..651d91c07ae981b22f8d64599945e04433dcb307 100644 --- a/mrstlnos/tests/2_cubes_patch_SIMPLE.py +++ b/mrstlnos/tests/2_cubes_patch_SIMPLE.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -14,13 +15,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") @@ -45,7 +46,7 @@ def main(): if rank == 0: command_line = 'gmsh -3 ' + work_dir + '/' + mesh_name + ' -o ' + work_dir + '/' + partitioned_mesh_name +' -part ' + str(siz) - print command_line + print(command_line) tmp = shlex.split(command_line) fileout = open('gmsh.log','w') p = subprocess.Popen(tmp, stdin=subprocess.PIPE, stdout=fileout, stderr=fileout, env=os.environ, shell=False,close_fds=True) diff --git a/mrstlnos/tests/2_cubes_patch_SIMPLEC.py b/mrstlnos/tests/2_cubes_patch_SIMPLEC.py index e666c5306379f72cc17f7b6690e4b047b6ce4897..bc438e20aa4b8900cdc84f31543f0f78107b4c0a 100644 --- a/mrstlnos/tests/2_cubes_patch_SIMPLEC.py +++ b/mrstlnos/tests/2_cubes_patch_SIMPLEC.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -14,13 +15,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") @@ -45,7 +46,7 @@ def main(): if rank == 0: command_line = 'gmsh -3 ' + work_dir + '/' + mesh_name + ' -o ' + work_dir + '/' + partitioned_mesh_name +' -part ' + str(siz) - print command_line + print(command_line) tmp = shlex.split(command_line) fileout = open('gmsh.log','w') p = subprocess.Popen(tmp, stdin=subprocess.PIPE, stdout=fileout, stderr=fileout, env=os.environ, shell=False,close_fds=True) diff --git a/mrstlnos/tests/2_cubes_patch_Uzawa.py b/mrstlnos/tests/2_cubes_patch_Uzawa.py index 71b483cc76931f2030372e7c17e4e98e931f6581..75e6421846c5cb464ba2faaf4ae8dc655ac38d1b 100644 --- a/mrstlnos/tests/2_cubes_patch_Uzawa.py +++ b/mrstlnos/tests/2_cubes_patch_Uzawa.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -14,13 +15,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") @@ -45,7 +46,7 @@ def main(): if rank == 0: command_line = 'gmsh -3 ' + work_dir + '/' + mesh_name + ' -o ' + work_dir + '/' + partitioned_mesh_name +' -part ' + str(siz) - print command_line + print(command_line) tmp = shlex.split(command_line) fileout = open('gmsh.log','w') p = subprocess.Popen(tmp, stdin=subprocess.PIPE, stdout=fileout, stderr=fileout, env=os.environ, shell=False,close_fds=True) diff --git a/mrstlnos/tests/2_cubes_sticking.py b/mrstlnos/tests/2_cubes_sticking.py index eedf9fe82a20856e84e796206d55332659ec3ec2..a2a1e23e4079daa8bd456b93819e56dbaac5723d 100644 --- a/mrstlnos/tests/2_cubes_sticking.py +++ b/mrstlnos/tests/2_cubes_sticking.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -14,13 +15,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") from fwk.wutils import parseargs args=parseargs() @@ -42,7 +43,7 @@ def main(): if rank == 0: command_line = 'gmsh -3 ' + work_dir + '/' + mesh_name + ' -o ' + work_dir + '/' + partitioned_mesh_name +' -part ' + str(siz) - print command_line + print(command_line) tmp = shlex.split(command_line) fileout = open('gmsh.log','w') p = subprocess.Popen(tmp, stdin=subprocess.PIPE, stdout=fileout, stderr=fileout, env=os.environ, shell=False,close_fds=True) diff --git a/mrstlnos/tests/2_cubes_tet.py b/mrstlnos/tests/2_cubes_tet.py index 06c47057f4e372d73e5c166e105d8783b82acfce..a21c025f55af12254772de1890460eaf83a723f2 100644 --- a/mrstlnos/tests/2_cubes_tet.py +++ b/mrstlnos/tests/2_cubes_tet.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -14,13 +15,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") @@ -45,7 +46,7 @@ def main(): if rank == 0: command_line = 'gmsh -3 ' + work_dir + '/' + mesh_name + ' -o ' + work_dir + '/' + partitioned_mesh_name +' -part ' + str(siz) - print command_line + print(command_line) tmp = shlex.split(command_line) fileout = open('gmsh.log','w') p = subprocess.Popen(tmp, stdin=subprocess.PIPE, stdout=fileout, stderr=fileout, env=os.environ, shell=False,close_fds=True) diff --git a/mrstlnos/tests/3_cubes_partial_sticking.py b/mrstlnos/tests/3_cubes_partial_sticking.py index daea57fee91aab169e7b6d68fcfcce6c52c71964..80500927fb0449c29343626fa3f5cf69d8fda634 100644 --- a/mrstlnos/tests/3_cubes_partial_sticking.py +++ b/mrstlnos/tests/3_cubes_partial_sticking.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -14,13 +15,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") @@ -45,7 +46,7 @@ def main(): if rank == 0: command_line = 'gmsh -3 ' + work_dir + '/' + mesh_name + ' -o ' + work_dir + '/' + partitioned_mesh_name +' -part ' + str(siz) - print command_line + print(command_line) tmp = shlex.split(command_line) fileout = open('gmsh.log','w') p = subprocess.Popen(tmp, stdin=subprocess.PIPE, stdout=fileout, stderr=fileout, env=os.environ, shell=False,close_fds=True) diff --git a/mrstlnos/tests/L_shape.py b/mrstlnos/tests/L_shape.py index 5fb81d780255b89636ad5e279322d54af6ca4028..d57ea4fafd59eb52ad3eec0d25886054ae130bc9 100644 --- a/mrstlnos/tests/L_shape.py +++ b/mrstlnos/tests/L_shape.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -16,13 +17,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") from fwk.wutils import parseargs args=parseargs() diff --git a/mrstlnos/tests/beam.py b/mrstlnos/tests/beam.py index 5494033bb332ac38009eedac7e67fc8880cc66cd..68e82e8a8653655276349ec032278418da80fc20 100644 --- a/mrstlnos/tests/beam.py +++ b/mrstlnos/tests/beam.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -15,15 +16,15 @@ def analytical(E,nu,L,W,H,d,p,x): q_2 = 72*EI*d/L**4 a = (72*EI*d/q)**(0.25) - print a + print(a) - print E - print nu - print L - print W - print H - print d - print p + print(E) + print(nu) + print(L) + print(W) + print(H) + print(d) + print(p) if q < q_1: case_id = 1 @@ -38,10 +39,10 @@ def analytical(E,nu,L,W,H,d,p,x): if x[i] >= a: sol[i] = -d - print "q" - print q - print q_1 - print q_2 + print("q") + print(q) + print(q_1) + print(q_2) return case_id, sol @@ -65,13 +66,13 @@ def main(): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") from fwk.wutils import parseargs @@ -116,7 +117,7 @@ def main(): if rank == 0: command_line = 'gmsh -3 ' + work_dir + '/' + mesh_name + ' -o ' + work_dir + '/' + partitioned_mesh_name +' -part ' + str(siz) - print command_line + print(command_line) tmp = shlex.split(command_line) fileout = open('gmsh.log','w') p = subprocess.Popen(tmp, stdin=subprocess.PIPE, stdout=fileout, stderr=fileout, env=os.environ, shell=False,close_fds=True) diff --git a/mrstlnos/utilities.py b/mrstlnos/utilities.py index b8006c3476326898a81b68100284a47b2b4deda5..637ac0bb808a4a5f85e017e8dff01cdedad6ed7f 100644 --- a/mrstlnos/utilities.py +++ b/mrstlnos/utilities.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: latin-1; -*- +from __future__ import print_function import mrstlnos as m import tbox import tbox.gmsh as gmsh @@ -95,14 +96,14 @@ def replace_strings(file_in,file_out,old_strings,new_strings): def print_nodes(msh, tag_names, rank): for tag_name in tag_names: - print 'Rank '+ str(rank) + ' Name tag: ' + tag_name + ' Elements: ' + str(len(msh.ntags[tag_name].elems)) + print('Rank '+ str(rank) + ' Name tag: ' + tag_name + ' Elements: ' + str(len(msh.ntags[tag_name].elems))) for el in msh.ntags[tag_name].elems: - print el - print 'Nodes: ' - print '{0:2s} {1:3s}'.format( 'no', 'row') + print(el) + print('Nodes: ') + print('{0:2s} {1:3s}'.format( 'no', 'row')) for el in msh.ntags[tag_name].elems: for n1 in el.nodes: - print '{0:2d} {1:3d}'.format( n1.no, n1.row) + print('{0:2d} {1:3d}'.format( n1.no, n1.row)) def extract(msh, tag_name, DOFperNode, which_pos, which_dof, ensemble_size, name_sol): try: @@ -185,13 +186,13 @@ def extract_2D(msh, tag_name, DOFperNode, which_dof, ensemble_size, name_sol): siz = comm.size name = mpi.Get_processor_name() status = mpi.Status() - print "info: MPI found" + print("info: MPI found") except: comm = None rank = 0 siz = 1 name = "noname" - print "info: MPI not found => MPI disabled" + print("info: MPI not found => MPI disabled") from PyTrilinos import Teuchos @@ -542,8 +543,8 @@ def compute_RBM_Curvature_Irreg_Sequential(x,y,z,tri,dz,unit,center_pos): W = np.zeros((n_nodes,n_nodes)) - print "mean dz" - print np.mean(dz) + print("mean dz") + print(np.mean(dz)) for i in range(0,n_tri): cross = np.cross(np.array([x[tri[i, 1]] - x[tri[i, 0]], y[tri[i, 1]] - y[tri[i, 0]], z[tri[i, 1]] - z[tri[i, 0]] ]), np.array([x[tri[i, 2]] - x[tri[i, 0]], y[tri[i, 2]] - y[tri[i, 0]], z[tri[i, 2]] - z[tri[i, 0]] ])) @@ -568,8 +569,8 @@ def compute_RBM_Curvature_Irreg_Sequential(x,y,z,tri,dz,unit,center_pos): optical_coefficients[3] = RBM_Curvature_Irreg_coeff[3]*np.amax(RBM_Curvature_Irreg_functions[:,3]) optical_coefficients[4] = np.amax(dz) - np.amin(dz) - print "optical_coefficients" - print optical_coefficients + print("optical_coefficients") + print(optical_coefficients) return RBM_Curvature_Irreg_coeff, RBM_Curvature_Irreg_functions, dz @@ -584,23 +585,23 @@ def check_optical_tolerance(optical_tolerance, unit): max_translation = 0.002 if np.absolute(optical_tolerance[0]) >= max_translation: - print "translation" + print("translation") passed = 0 if np.absolute(optical_tolerance[1]) >= max_angle: - print "rotation x" + print("rotation x") passed = 0 if np.absolute(optical_tolerance[2]) >= max_angle: - print "rotation y" + print("rotation y") passed = 0 if optical_tolerance[3] >= max_fringe: - print "curvature" + print("curvature") passed = 0 if optical_tolerance[4] >= max_fringe: - print "irregularity" + print("irregularity") passed = 0 return passed @@ -617,29 +618,29 @@ def check_optical_tolerance_Zernike(Zernike_coeff, Zernike_functions, dz,unit): max_translation = 0.002 if np.absolute(Zernike_coeff[0]) >= max_translation: - print "translation" + print("translation") passed = 0 if np.absolute(Zernike_coeff[1]) >= max_angle: - print "rotation x" + print("rotation x") passed = 0 if np.absolute(Zernike_coeff[2]) >= max_angle: - print "rotation y" + print("rotation y") passed = 0 tmp = np.dot(Zernike_coeff[3],Zernike_functions[:,3]) if np.absolute(max(tmp)-min(tmp)) >= max_fringe: - print "curvature" + print("curvature") passed = 0 tmp = dz - np.dot(Zernike_coeff[0],Zernike_functions[:,0]) - np.dot(Zernike_coeff[1],Zernike_functions[:,1]) - np.dot(Zernike_coeff[2],Zernike_functions[:,2]) - np.dot(Zernike_coeff[3],Zernike_functions[:,3]) if np.absolute(max(tmp)-min(tmp)) >= max_fringe: - print max(tmp) - print min(tmp) - print "irregularity" + print(max(tmp)) + print(min(tmp)) + print("irregularity") passed = 0 return passed diff --git a/mrstlnos/viewer.py b/mrstlnos/viewer.py index 4b01bc01cd37f162922adaa381e40ae31d7f4a63..824945f2b852256406535cb7f5847b9e6b9343b7 100644 --- a/mrstlnos/viewer.py +++ b/mrstlnos/viewer.py @@ -1,5 +1,6 @@ # -*- coding: latin-1; -*- +from __future__ import print_function import sys import mrstlnos as m import tbox as tb @@ -35,8 +36,8 @@ class MeshViewer(QtGui.QWidget, m.DisplayHook): self.elev = elev self.azim = azim - print " " - print "starting MeshViewer init..." + print(" ") + print("starting MeshViewer init...") self.__setupGUI() self.__setupVTK() @@ -44,12 +45,12 @@ class MeshViewer(QtGui.QWidget, m.DisplayHook): self.app.connect(self.app, QtCore.SIGNAL("lastWindowClosed()"), self.app, QtCore.SLOT("quit()")) self.show() self.vtkwidget.Initialize() # [Linux] faire ca le plus tard possible (apres self.show!!) - print "MeshViewer ready." + print("MeshViewer ready.") def closeEvent(self, event): #self.scheme.stopit=True self.running='running' # sort de "while self.running=='pause'" - print "GUI killed!" + print("GUI killed!") QtGui.QWidget.closeEvent(self,event) @@ -144,7 +145,7 @@ class MeshViewer(QtGui.QWidget, m.DisplayHook): def verboseSlot(self, state): self.scheme.verbose = state if not state: - print "<verbose=OFF>" + print("<verbose=OFF>") def startSlot(self): if self.running=='init': @@ -210,7 +211,7 @@ class MeshViewer(QtGui.QWidget, m.DisplayHook): def display(self, nt, t, u): """ C++ => python callback """ - print "[GUI] nt=", nt, "t=", t + print("[GUI] nt=", nt, "t=", t) # update data at points for i in range(self.msh.nodes.size()): @@ -241,7 +242,7 @@ class MeshViewer(QtGui.QWidget, m.DisplayHook): def display_sample(self, nt, t): if None == self.polydata.GetPointData().GetArray("Values "+str(nt)): - print "Please, before selecting solution to display, run the simulation." + print("Please, before selecting solution to display, run the simulation.") else: pos_x = self.polydata.GetPointData().GetArray("Positions x "+str(nt)) pos_y = self.polydata.GetPointData().GetArray("Positions y "+str(nt)) @@ -379,7 +380,7 @@ class MeshViewer(QtGui.QWidget, m.DisplayHook): self.render() def ragequit(self): - print "rage quit!" + print("rage quit!") self.scheme.stopit=True self.app.quit() @@ -395,7 +396,7 @@ class MeshViewer(QtGui.QWidget, m.DisplayHook): self.app.processEvents() def __createUgrid(self): - print 'creating vtkUnstructuredGrid...' + print('creating vtkUnstructuredGrid...') self.ugrid = vtk.vtkUnstructuredGrid() self.points = vtk.vtkPoints() self.ugrid.SetPoints(self.points) @@ -432,7 +433,7 @@ class MeshViewer(QtGui.QWidget, m.DisplayHook): for j in range(4): ids.SetId( j, n[j].no-1 ) self.ugrid.InsertNextCell(tetra.GetCellType(), ids) - print self.ugrid.GetNumberOfPoints(), 'points and', self.ugrid.GetNumberOfCells(), 'cells converted' + print(self.ugrid.GetNumberOfPoints(), 'points and', self.ugrid.GetNumberOfCells(), 'cells converted') def writeXML(self, name='mesh.vtu'): writer = vtk.vtkXMLUnstructuredGridWriter() @@ -490,8 +491,8 @@ class MeshViewer(QtGui.QWidget, m.DisplayHook): self.vmax = current_max current_max = self.scalars.GetRange() - print self.vmin - print self.vmax + print(self.vmin) + print(self.vmax) self.mesh.updateTcoords(self.vmin, self.vmax) diff --git a/params/CVT/python/test.py b/params/CVT/python/test.py index a33f0ff5ed46668c81c7dce134518e52b4ce370f..2a3a0d1a76ea64907a450ba27eb3089988c50ef2 100644 --- a/params/CVT/python/test.py +++ b/params/CVT/python/test.py @@ -16,6 +16,7 @@ # limitations under the License. +from __future__ import print_function import numpy as np def compute_energy(z,a,b,k,pdf): @@ -47,8 +48,8 @@ def MacQueen(a,b,k,pdf,it_max): Energy = np.zeros((it_max,)) - print z - print j + print(z) + print(j) for it in range(0,it_max): y = rejection_method(a,b,1,pdf) @@ -63,7 +64,7 @@ def MacQueen(a,b,k,pdf,it_max): j[istar] = j[istar] + 1. Energy[it] = compute_energy(z,a,b,k,pdf) - print z + print(z) import matplotlib.pyplot as plt plt.plot(Energy) @@ -80,8 +81,8 @@ def new_method(a,b,k,q,alpha,beta,pdf,it_max): Energy = np.zeros((it_max,)) - print z - print j + print(z) + print(j) for it in range(0,it_max): # 1. @@ -123,8 +124,8 @@ def new_method(a,b,k,q,alpha,beta,pdf,it_max): #print z Energy[it] = compute_energy(z,a,b,k,pdf) - print it - print z + print(it) + print(z) import matplotlib.pyplot as plt plt.plot(Energy) diff --git a/params/CVT/python/test2D.py b/params/CVT/python/test2D.py index 85e3696edb81f07a78e323ff91f1d9aff4452846..de8aff8efb544715594b5aa44a03e66bb25ee148 100644 --- a/params/CVT/python/test2D.py +++ b/params/CVT/python/test2D.py @@ -16,6 +16,7 @@ # limitations under the License. +from __future__ import print_function import numpy as np import matplotlib.pyplot as plt from scipy.spatial import Voronoi @@ -171,8 +172,8 @@ def new_method(a,b,c,d,k,q,alpha,beta,pdf,it_max): #Energy = np.zeros((it_max,)) - print z - print j + print(z) + print(j) for it in range(0,it_max): # 1. @@ -215,8 +216,8 @@ def new_method(a,b,c,d,k,q,alpha,beta,pdf,it_max): #print z #Energy[it] = compute_energy(z,a,b,k,pdf) - print it - print z + print(it) + print(z) ''' plt.scatter(z[:,0],z[:,1]) @@ -236,10 +237,10 @@ def new_method(a,b,c,d,k,q,alpha,beta,pdf,it_max): # plot regions, vertices = voronoi_finite_polygons_2d(vor) - print "--" - print regions - print "--" - print vertices + print("--") + print(regions) + print("--") + print(vertices) # colorize for region in regions: diff --git a/params/CVT/python/test2D2.py b/params/CVT/python/test2D2.py index de21274d790365f0b4f8a9266a58dd8ecc93cdc7..d3e3d4ad70636690a1a7e42dcc49959308ac0c77 100644 --- a/params/CVT/python/test2D2.py +++ b/params/CVT/python/test2D2.py @@ -16,6 +16,7 @@ # limitations under the License. +from __future__ import print_function import numpy as np import matplotlib.pyplot as plt from scipy.spatial import Voronoi @@ -113,10 +114,10 @@ vor = Voronoi(points) # plot regions, vertices = voronoi_finite_polygons_2d(vor) -print "--" -print regions -print "--" -print vertices +print("--") +print(regions) +print("--") +print(vertices) # colorize for region in regions: diff --git a/params/CVT/python/test3.py b/params/CVT/python/test3.py index afb034a11ab893d9a1067d6aa027d5a641c5d223..e9251db7f373793fd8d1668d3ecad90725bb41ce 100644 --- a/params/CVT/python/test3.py +++ b/params/CVT/python/test3.py @@ -16,6 +16,7 @@ # limitations under the License. +from __future__ import print_function import numpy as np import matplotlib.pyplot as plt from scipy.spatial import Voronoi @@ -112,10 +113,10 @@ vor = Voronoi(points) # plot regions, vertices = voronoi_finite_polygons_2d(vor) -print "--" -print regions -print "--" -print vertices +print("--") +print(regions) +print("--") +print(vertices) # colorize for region in regions: diff --git a/params/CVT/test/test.py b/params/CVT/test/test.py index df2c462e9aed8e67fa2e3e47cd31ad036e734006..9bc12b130fc24aad85ba60e242ace396853961cd 100644 --- a/params/CVT/test/test.py +++ b/params/CVT/test/test.py @@ -16,11 +16,12 @@ # limitations under the License. +from __future__ import print_function import paramsCVT def main(): - print "hi" + print("hi") if __name__ == "__main__": main() diff --git a/params/arnst_ponthot/tests/test7.py b/params/arnst_ponthot/tests/test7.py index 595e9279a76d0f71f0ca697b32b6fcf0f978bd87..162a510df072a435d3839034bc267465ee3cf4b7 100644 --- a/params/arnst_ponthot/tests/test7.py +++ b/params/arnst_ponthot/tests/test7.py @@ -16,6 +16,7 @@ # limitations under the License. +from __future__ import print_function import numpy as np def main(): @@ -39,7 +40,7 @@ def main(): x = gamma.sigma(0.5,0.5,rho) - print x + print(x) if __name__ == "__main__": main() diff --git a/params/dev_tests/LSP.py b/params/dev_tests/LSP.py index 7e3e0a5a90026ca4568e7949259600eef47015cc..2a50bc8f292c1358a5d7bcad772af517f00cb6df 100755 --- a/params/dev_tests/LSP.py +++ b/params/dev_tests/LSP.py @@ -16,6 +16,7 @@ # limitations under the License. +from __future__ import print_function import numpy as np import matplotlib.pyplot as plt @@ -40,8 +41,8 @@ def main(): plt.xlabel('i') plt.ylabel('sigma_i') - print V.shape - print Z.shape + print(V.shape) + print(Z.shape) plt.subplot(1,3,3) ZV = np.dot(Z,np.transpose(V)) diff --git a/params/dev_tests/LSP_2.py b/params/dev_tests/LSP_2.py index 3eff9c29d94e809e5ad0a9f73b66bb3c17ba14eb..8d5eb3f996caaba0abf1761d30d2ab21fdce97b4 100755 --- a/params/dev_tests/LSP_2.py +++ b/params/dev_tests/LSP_2.py @@ -16,6 +16,7 @@ # limitations under the License. +from __future__ import print_function import numpy as np import matplotlib.pyplot as plt @@ -46,8 +47,8 @@ def main(): plt.xlabel('i') plt.ylabel('sigma_i') - print V.shape - print Z.shape + print(V.shape) + print(Z.shape) plt.subplot(1,3,3) ZV = np.dot(Z,np.transpose(V)) diff --git a/params/dev_tests/LegPol.py b/params/dev_tests/LegPol.py index dc660668d923ee9bbd3c164e8e2782e4914e4caa..5ac045420edbf45c29c4f3d0721e749c2e5b9b6e 100755 --- a/params/dev_tests/LegPol.py +++ b/params/dev_tests/LegPol.py @@ -16,6 +16,7 @@ # limitations under the License. +from __future__ import print_function import matplotlib as mpl from mpl_toolkits.mplot3d import Axes3D from matplotlib import cm @@ -32,7 +33,7 @@ def main(): for i in range(0,n): p = Legendre.basis(i).convert(kind=Polynomial) - print p.coef + print(p.coef) x = np.linspace(x_min,x_max,m) diff --git a/params/dev_tests/numpy_matplotlib01.py b/params/dev_tests/numpy_matplotlib01.py index 4837e4e386ccb41e89625fc1720da27fc276066a..fdb010cd2657b483ae804bcf27fd9a049c625a58 100755 --- a/params/dev_tests/numpy_matplotlib01.py +++ b/params/dev_tests/numpy_matplotlib01.py @@ -16,19 +16,20 @@ # limitations under the License. +from __future__ import print_function import numpy as np import matplotlib.pyplot as plt def main(): a = np.random.randn(3,3) - print a + print(a) U, s, V = np.linalg.svd(a, full_matrices=True) - print U.shape, V.shape, s.shape + print(U.shape, V.shape, s.shape) S = np.zeros((3,3)) S[:3,:3] = np.diag(s) - print np.allclose(a, np.dot(U, np.dot(S,V))) - print a - np.dot(U, np.dot(S,V)) - print s + print(np.allclose(a, np.dot(U, np.dot(S,V)))) + print(a - np.dot(U, np.dot(S,V))) + print(s) plt.plot([1,2,3,4]) plt.ylabel('some numbers') diff --git a/params/src/indices.py b/params/src/indices.py index 2e57cf1006dd9ce4bafb8d092d27e80cc65efed4..5a740744e3148c4b0818046d739fae36a8442ede 100755 --- a/params/src/indices.py +++ b/params/src/indices.py @@ -18,7 +18,7 @@ import numpy as np -def next(p,i,M,d): +def my_next(p,i,M,d): i_zero = np.zeros((d,), dtype =np.int) i_one = np.ones((d,), dtype =np.int) diff --git a/params/src/legendre.py b/params/src/legendre.py index 5cb782bff795db72f878331163413465d721906f..850960fec21a0e16b2d55e045974a076329c4709 100755 --- a/params/src/legendre.py +++ b/params/src/legendre.py @@ -33,5 +33,5 @@ def phi(xi,N,n_max,d): for j in range(0,d): phi[n_i] = phi[n_i]*Legendre.basis(i[j])(xi[j]) n_i = n_i + 1 - p,i = indices.next(p,i,N,d) + p,i = indices.my_next(p,i,N,d) return phi diff --git a/params/src/legendre_norm.py b/params/src/legendre_norm.py index 69b1b01f7372632c72fff5e246975f04e144c85c..3a8871cac30f1ff826cefd6406851cf1273c9d8e 100755 --- a/params/src/legendre_norm.py +++ b/params/src/legendre_norm.py @@ -41,5 +41,5 @@ def phi(xi,N,n_max,d): for j in range(0,d): phi[n_i] = phi[n_i]*L[j,i[j]] / np.sqrt(2./(2*i[j]+1)) n_i = n_i + 1 - p,i = indices.next(p,i,N,d) + p,i = indices.my_next(p,i,N,d) return phi diff --git a/params/src/monomials.py b/params/src/monomials.py index 4c52b4acf1ac0cbd9474a127a9d2d259aa44ba4b..47f064f37cd67b538f245b5fdc92323dd8e6afbc 100755 --- a/params/src/monomials.py +++ b/params/src/monomials.py @@ -32,7 +32,7 @@ def phi(xi,N,n_max,d): for j in range(0,d): phi[n_i] = phi[n_i]*xi[j]**i[j] n_i = n_i + 1 - p,i = indices.next(p,i,N,d) + p,i = indices.my_next(p,i,N,d) return phi def compute_n_max(N,d): diff --git a/params/src/monomials_1norm.py b/params/src/monomials_1norm.py index dea5c1e8112419c6518082de3b79f5f0f69d0bb5..330845f3121223f79c4834f319619314476cfcad 100755 --- a/params/src/monomials_1norm.py +++ b/params/src/monomials_1norm.py @@ -38,7 +38,7 @@ def phi_old(xi,N,n_max,d): for j in range(0,d): phi[n_i] = phi[n_i]*xi[j]**i[j] n_i = n_i + 1 - p,i = indices.next(p,i,N,d) + p,i = indices.my_next(p,i,N,d) return phi @@ -78,7 +78,7 @@ def phi(xi,N,n_max,d): for j in range(0,d): phi[n_i] = phi[n_i]*xi[j]**i[j] n_i = n_i + 1 - p,i = indices.next(p,i,N,d) + p,i = indices.my_next(p,i,N,d) n_c = n_c + 1 return phi @@ -99,6 +99,6 @@ def compute_n_max(N,d): tmp = tmp+i[j] if tmp < n: n_max = n_max + 1 - p,i = indices.next(p,i,N,d) + p,i = indices.my_next(p,i,N,d) return n_max diff --git a/params/test/leg_lim.py b/params/test/leg_lim.py index 86fdb1011ed40babd664a47416d57c24ae28f96c..77d8528f92a44658dabae0e02650beb7d9f9f4ef 100755 --- a/params/test/leg_lim.py +++ b/params/test/leg_lim.py @@ -16,6 +16,7 @@ # limitations under the License. +from __future__ import print_function import numpy as np import os import shutil @@ -76,7 +77,7 @@ def main(): for j in range(0,d): W[m_i,m_i] = W[m_i,m_i]*w[i[j],j] - p,i = indices.next(p,i,M,d) + p,i = indices.my_next(p,i,M,d) m_i = m_i + 1 text = str(m_i)+' / '+str(m_max) sys.stdout.write("\r"+text) @@ -87,7 +88,7 @@ def main(): tmp = np.abs(ZWZ-np.diag(np.diag(ZWZ))) - print np.amax(np.abs(tmp)) + print(np.amax(np.abs(tmp))) from fwk.wutils import parseargs args = parseargs() diff --git a/run.py b/run.py index c4d78659c10046a3d6f97000eb7e7f6c33b12855..323fcefd04faa41d612b1ae9af3cb13d942b5f59 100755 --- a/run.py +++ b/run.py @@ -23,6 +23,7 @@ # - creates a workspace folder +from __future__ import print_function class DupStream(object): def __init__(self, stream1, stream2): self.stream1 = stream1 @@ -71,7 +72,7 @@ def main(thisfile): args = wu.parseargs() if args.fpe: fwk.enableFpe() # enables floating point exceptions at runtime - print ccolors.ANSI_YELLOW + 'Floating point exceptions will cause numpy to overflow!' + ccolors.ANSI_RESET + print(ccolors.ANSI_YELLOW + 'Floating point exceptions will cause numpy to overflow!' + ccolors.ANSI_RESET) # run all tests sequentially for testname in args.file: @@ -83,17 +84,17 @@ def main(thisfile): __file__ = testname __name__ = "__main__" - print "[run.py] __file__", __file__ + print("[run.py] __file__", __file__) # split streams tee = Tee('stdout.txt') # start test import time, socket - print '-' * 80 - print ccolors.ANSI_BLUE + 'PyStarting...' + ccolors.ANSI_RESET - print "starting test", testname - print "time:", time.strftime("%c") - print "hostname:", socket.gethostname() + print('-' * 80) + print(ccolors.ANSI_BLUE + 'PyStarting...' + ccolors.ANSI_RESET) + print("starting test", testname) + print("time:", time.strftime("%c")) + print("hostname:", socket.gethostname()) execfile(testname, globals(), globals()) # exec at global level!! if __name__ == "__main__": diff --git a/scripts/chkencoding.py b/scripts/chkencoding.py index 573c7308dcacf980112fa18bc30e1c377c4b29f7..9d8d6e39c55892c2618e4b36662ec288300bc2b0 100755 --- a/scripts/chkencoding.py +++ b/scripts/chkencoding.py @@ -2,6 +2,7 @@ # -*- coding: utf8 -*- # test encoding: à -é-è-ô-ï-€ +from __future__ import print_function import sys, os import fnmatch, re import subprocess @@ -79,9 +80,9 @@ def getnonascii(fichier, enc): def main(): - print "sys.stdout.encoding:", sys.stdout.encoding # cp850 sous windows 10 / UTF-8 sous linux - print "sys.getfilesystemencoding():", sys.getfilesystemencoding( - ) # mbcs sous windows 10 / UTF-8 sous linux + print("sys.stdout.encoding:", sys.stdout.encoding) # cp850 sous windows 10 / UTF-8 sous linux + print("sys.getfilesystemencoding():", sys.getfilesystemencoding( + )) # mbcs sous windows 10 / UTF-8 sous linux if 1: # loop over all files and try to guess encoding... @@ -89,7 +90,7 @@ def main(): for f in all_files(os.getcwd(), patterns='*.py;*.h;*.cpp;*.inl;*.i;*.hpp'): enc = getencoding_file(f) #enc = getencoding_chardet(f) # marche moins bien - if not encs.has_key(enc): + if enc not in encs: encs[enc] = [] encs[enc].append(f) @@ -97,15 +98,15 @@ def main(): for enc in encs: if enc in ['binary', 'us-ascii', None, 'ascii']: continue - print enc, 'encoding:' + print(enc, 'encoding:') for f in encs[enc]: - print '\t', f, + print('\t', f, end=' ') # display non-ASCII chars noascii = getnonascii(f, enc) - print ' non ASCII=(', + print(' non ASCII=(', end=' ') for c in noascii: - print c, - print ')' + print(c, end=' ') + print(')') if __name__ == "__main__": diff --git a/scripts/cppcheck.py b/scripts/cppcheck.py index 9befb7a20138f8814ace4abd1096a97bbdcc4e24..0810d890d1153f53caa3aa2d11c3c43bdded608b 100755 --- a/scripts/cppcheck.py +++ b/scripts/cppcheck.py @@ -1 +1 @@ -cppcheck -v --enable=all --xml . 2> cppcheck-report.xml +#cppcheck -v --enable=all --xml . 2> cppcheck-report.xml diff --git a/sph/broken/cpp/waterdrop.py b/sph/broken/cpp/waterdrop.py index 9591d9c1c75cc1dca2d32713dac0be29cad77884..bc1dbfa0c2512d90abeff4e63281f5452b970554 100644 --- a/sph/broken/cpp/waterdrop.py +++ b/sph/broken/cpp/waterdrop.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- +from __future__ import print_function from sph.helpers import * if __name__=="__main__": @@ -38,7 +39,7 @@ if __name__=="__main__": model.addFixed(plane.generate()) # run SPH model - print model + print(model) model.run() # convert to VTK diff --git a/sph/louis/build.py b/sph/louis/build.py index 4a10889c5be3ac98467cdac2ddc82fc9af0fd947..973113b61823a8cd5f6672d49cd2ba72401b1bca 100755 --- a/sph/louis/build.py +++ b/sph/louis/build.py @@ -16,6 +16,7 @@ # limitations under the License. +from __future__ import print_function import os, sys, subprocess, platform try: @@ -32,5 +33,5 @@ try: subprocess.call('cmake --build . --config Release', shell=True) os.chdir('../louis') except Exception as e: - print e - print "<press ENTER to quit>"; raw_input() + print(e) + print("<press ENTER to quit>"); raw_input() diff --git a/sph/louis/run.py b/sph/louis/run.py index 998cf616e1495c94647505c330b8f09dfdeb4ee0..1f5e879679b66d895f191c81f17d5e01b04eaf7e 100755 --- a/sph/louis/run.py +++ b/sph/louis/run.py @@ -21,6 +21,7 @@ # - creates a workspace folder +from __future__ import print_function class DupStream(object): def __init__(self, stream1, stream2): self.stream1 = stream1 @@ -72,10 +73,10 @@ if __name__=="__main__": # start test import time, platform - print '-'*80 - print "starting test", testname - print "time:", time.strftime("%c") - print "hostname:", platform.node() - print '-'*80 + print('-'*80) + print("starting test", testname) + print("time:", time.strftime("%c")) + print("hostname:", platform.node()) + print('-'*80) execfile(testname) diff --git a/sph/louis/sph/gui.py b/sph/louis/sph/gui.py index b7a1cb300831fa8af236755c2a79176b7b3845b1..71479d6374fefbd124bf6915f135f3ef70318cc0 100644 --- a/sph/louis/sph/gui.py +++ b/sph/louis/sph/gui.py @@ -18,6 +18,7 @@ # converts .res files to Paraview (VTK) +from __future__ import print_function import vtk version=vtk.vtkVersion().GetVTKMajorVersion() import glob @@ -27,14 +28,14 @@ class ToParaview(object): self.verb = verb def convertall(self, pattern='*MP*.res'): - print "converting grid to VTK" + print("converting grid to VTK") self.convertGrid() - print "converting %s to VTK" % pattern + print("converting %s to VTK" % pattern) for f in glob.glob(pattern): self.convertParts(f) def convertGrid(self, fname='grid.out'): - if self.verb: print 'converting', fname + if self.verb: print('converting', fname) # read file file = open(fname) @@ -70,7 +71,7 @@ class ToParaview(object): def convertParts(self, fname): #if self.verb: - print 'converting', fname + print('converting', fname) file = open(fname) ugrid = vtk.vtkUnstructuredGrid() @@ -100,7 +101,7 @@ class ToParaview(object): try: x,y,z, vx,vy,vz, rho, p, m, c, h, mu, nv = map(float, line.strip().split()) except: - print "**ERROR while reading file %s!\n\tline=\"%s\"" % (fname,line) + print("**ERROR while reading file %s!\n\tline=\"%s\"" % (fname,line)) break points.InsertPoint(i, x,y,z) results['v'].InsertNextTuple3(vx,vy,vz) @@ -115,7 +116,7 @@ class ToParaview(object): file.close() ntot=i - if self.verb: print "\t%d lines read. Converting grid to VTK..." % ntot + if self.verb: print("\t%d lines read. Converting grid to VTK..." % ntot) for i in range(ntot): vertex = vtk.vtkVertex() @@ -124,8 +125,8 @@ class ToParaview(object): ugrid.InsertNextCell(vertex.GetCellType(), ids) if self.verb: - print "\t...", ugrid.GetNumberOfPoints(), 'points and', \ - ugrid.GetNumberOfCells(), 'cells converted' + print("\t...", ugrid.GetNumberOfPoints(), 'points and', \ + ugrid.GetNumberOfCells(), 'cells converted') writer = vtk.vtkXMLUnstructuredGridWriter() compressor = vtk.vtkZLibDataCompressor() diff --git a/sph/louis/sph/helpers.py b/sph/louis/sph/helpers.py index 9d82de8c923060ce2af92cef34d3e7e33fbf2caa..e1c87a547b8fc9b1f69cf6a3fa6523d1812e8ccc 100644 --- a/sph/louis/sph/helpers.py +++ b/sph/louis/sph/helpers.py @@ -18,6 +18,7 @@ # Python helper classes for Louis' code +from __future__ import print_function import math, subprocess, os, platform, sys, glob import sph.wutils as wu @@ -102,7 +103,7 @@ class Model(object): def clean(self): for p in ['res*.*', 'input.*', 'grid.*']: for f in glob.glob(p): - print 'rm %s' % f + print('rm %s' % f) os.remove(f) def run(self): @@ -138,7 +139,7 @@ class Model(object): # run program exename = self.getexe() - print "running %s using %s threads" % (exename, os.environ['OMP_NUM_THREADS']) + print("running %s using %s threads" % (exename, os.environ['OMP_NUM_THREADS'])) #iop = subprocess.call(self.getexe(), shell=True, stdout=sys.stdout, stderr=sys.stderr) #print 'louis returned iop=%d', iop @@ -151,12 +152,12 @@ class Model(object): with proc.stdout: for line in iter(proc.stdout.readline, b''): line = line.rstrip('\n').rstrip('\r') - print '[F]%s' % line + print('[F]%s' % line) #sys.stdout.write(line) #file.write("line=\"%s\"\n" % line) proc.wait() except KeyboardInterrupt: - print 'Ignoring CTRL-C' + print('Ignoring CTRL-C') pass #file.close() diff --git a/sph/louis/sph/wutils.py b/sph/louis/sph/wutils.py index be27c4ce8da90552fa0b464e2820b7441fca6d0b..72260c6ac6b1854956c9579b3e1a3699c89b56da 100644 --- a/sph/louis/sph/wutils.py +++ b/sph/louis/sph/wutils.py @@ -18,6 +18,7 @@ # Python utilities +from __future__ import print_function def setupwdir(testname): """ creates a working folder for each test @@ -25,8 +26,8 @@ def setupwdir(testname): import os, os.path #print "__file__=",__file__ dir1=os.path.abspath(os.path.dirname(__file__)+os.sep+"..")+os.sep - print "dir1=",dir1 - print "testname=",testname + print("dir1=",dir1) + print("testname=",testname) common = os.path.commonprefix( (testname, dir1) ) #print "common=", common resdir = testname[len(common):].replace(os.sep,"_") @@ -34,7 +35,7 @@ def setupwdir(testname): #print "resdir=", resdir wdir=os.path.join('workspace', resdir) if not os.path.isdir(wdir): - print "creating", wdir + print("creating", wdir) os.makedirs(wdir) os.chdir(wdir) diff --git a/sph/louis/tests/waterdrop.py b/sph/louis/tests/waterdrop.py index 57e866a056f16b6e915fe48d7fbf2c469a46e4d7..ce7db063acd9aa4b43657cea656e0868b2d62f9b 100644 --- a/sph/louis/tests/waterdrop.py +++ b/sph/louis/tests/waterdrop.py @@ -16,6 +16,7 @@ # limitations under the License. +from __future__ import print_function from sph.helpers import * if __name__=="__main__": @@ -53,7 +54,7 @@ if __name__=="__main__": model.addFixed(plane.generate()) # run SPH model - print model + print(model) model.run() # convert to VTK diff --git a/sph/louis/tests/waterdrop2.py b/sph/louis/tests/waterdrop2.py index 678b2c696302a5bedbd36fcdfa66b071a448d438..6a36778593c01f2628886d94a3c2fc05bf5487db 100644 --- a/sph/louis/tests/waterdrop2.py +++ b/sph/louis/tests/waterdrop2.py @@ -16,6 +16,7 @@ # limitations under the License. +from __future__ import print_function from sph.helpers import * if __name__=="__main__": @@ -67,7 +68,7 @@ if __name__=="__main__": model.addFixed(plane.generate()) # run SPH model - print model + print(model) model.run() # convert to VTK diff --git a/sph/louis/tests/waterdrop3.py b/sph/louis/tests/waterdrop3.py index f605f5ddca32a5b6f92e7b2a747d42748e53e3e9..34666cd315dd6f6972014b2226de67b2a6d89037 100644 --- a/sph/louis/tests/waterdrop3.py +++ b/sph/louis/tests/waterdrop3.py @@ -16,6 +16,7 @@ # limitations under the License. +from __future__ import print_function from sph.helpers import * if __name__=="__main__": @@ -67,7 +68,7 @@ if __name__=="__main__": model.addFixed(plane.generate()) # run SPH model - print model + print(model) model.run() # convert to VTK diff --git a/sph/louis/tests/waterdrop4.py b/sph/louis/tests/waterdrop4.py index 16ac8d6a13bd01579ba9d9069f4e230b1c53e80c..09ff51b3363b259be3e6c1e4a0912a18cff49e50 100644 --- a/sph/louis/tests/waterdrop4.py +++ b/sph/louis/tests/waterdrop4.py @@ -16,6 +16,7 @@ # limitations under the License. +from __future__ import print_function from sph.helpers import * if __name__=="__main__": @@ -67,7 +68,7 @@ if __name__=="__main__": model.addFixed(plane.generate()) # run SPH model - print model + print(model) model.run() # convert to VTK diff --git a/sph/louis/tests/waterdrop_post.py b/sph/louis/tests/waterdrop_post.py index 0e373bb69315e36478eb68aea1e996c6d04b71d9..0caa68a2e46b8676c37020d47a0546374cfc83fc 100644 --- a/sph/louis/tests/waterdrop_post.py +++ b/sph/louis/tests/waterdrop_post.py @@ -1,3 +1,4 @@ +from __future__ import print_function # Copyright 2020 University of Liège # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -19,7 +20,7 @@ import glob, os.path #### disable automatic camera reset on 'Show' paraview.simple._DisableFirstRenderCameraReset() -print "cwd=", os.getcwd() +print("cwd=", os.getcwd()) dirname = '/home/boman/dev/Projet_MP/waves/sph/louis/workspace/tests_waterdrop' # create a new 'XML Structured Grid Reader' diff --git a/sph/tests/neighbours.py b/sph/tests/neighbours.py index 59c615d6e3e55ab25457dd990cc11f618f382f58..a0e4b26f712c0ca08b25d460bd71f4a7c206a436 100644 --- a/sph/tests/neighbours.py +++ b/sph/tests/neighbours.py @@ -16,13 +16,14 @@ # limitations under the License. +from __future__ import print_function import sph from sph import Vector3d from fwk import Timer def saveNeighbours(pbl, fname): - print 'saving results to %s...' % fname + print('saving results to %s...' % fname) f = open(fname,'w') for p in pbl.prts: nos=[] @@ -41,7 +42,7 @@ def printLouisGrid(sorter): for k in range(sorter.size()): prts = sorter.getParticles(i,j,k) if len(prts)!=0: - print "(i,l,k)=(%d,%d,%d) nbprts=%d" % (i,j,k,len(prts)) + print("(i,l,k)=(%d,%d,%d) nbprts=%d" % (i,j,k,len(prts))) # @@ -65,28 +66,28 @@ for p in cube.generate(): no+=1 pbl.addMobileP(no, sph.Dofs(Vector3d(p[0], p[1], p[2]), Vector3d(0.0, 0.0, 0.0), rho)) -print pbl +print(pbl) # kernel kernel = sph.CubicSplineKernel() -print kernel +print(kernel) # sorter timer = Timer(); timer.start() sorter = sph.LouisSorter(boxL, h0, kernel) -print sorter +print(sorter) sorter.execute(pbl.prts) -timer.stop(); print timer +timer.stop(); print(timer) #saveNeighbours(pbl, 'louissorter.txt') timer = Timer(); timer.start() sorter = sph.BruteForceSorter(h0, kernel) sorter.method = 2 sorter.nthreads = 6 -print sorter +print(sorter) sorter.execute(pbl.prts) -timer.stop(); print timer +timer.stop(); print(timer) #saveNeighbours(pbl, 'bruteforcesorter.txt') diff --git a/sph/tests/sandbox.py b/sph/tests/sandbox.py index 7369045566960c999dd607a8878e5079e276e267..de4ee544fc7a944c2db457c7dd131f6ae4426cc0 100644 --- a/sph/tests/sandbox.py +++ b/sph/tests/sandbox.py @@ -16,6 +16,7 @@ # limitations under the License. +from __future__ import print_function import sph from sph import Vector3d from fwk import Timer @@ -24,8 +25,8 @@ from fwk import Timer # test dofs -- d1 = sph.Dofs(Vector3d(0,0,0), Vector3d(0,0,0), 0.0) d2 = sph.Dofs(Vector3d(1,1,1), Vector3d(0,0,0), 0.0) -print "dof1:", d1 -print "dof2:", d2 +print("dof1:", d1) +print("dof2:", d2) # @@ -39,7 +40,7 @@ h0 = 1.2*sep pbl = sph.Problem(h0) -print pbl +print(pbl) # generate a set of particles @@ -65,12 +66,12 @@ for p in plane.generate(): no+=1 pbl.addMobileP(no, sph.Dofs(Vector3d(p[0], p[1], p[2]), Vector3d(0.0, 0.0, 0.0), rho)) -print pbl +print(pbl) # kernel kernel = sph.CubicSplineKernel() -print kernel +print(kernel) # sorter @@ -78,9 +79,9 @@ print kernel timer = Timer(); timer.start() sorter = sph.LouisSorter(boxL, h0, kernel) sorter.execute(pbl.prts) -timer.stop(); print timer +timer.stop(); print(timer) -print sorter +print(sorter) if 0: for i in range(sorter.size()): @@ -88,7 +89,7 @@ if 0: for k in range(sorter.size()): prts = sorter.getParticles(i,j,k) if len(prts)!=0: - print "(i,l,k)=(%d,%d,%d) nbprts=%d" % (i,j,k,len(prts)) + print("(i,l,k)=(%d,%d,%d) nbprts=%d" % (i,j,k,len(prts))) def saveNeighbours(pbl, fname): f = open(fname,'w') @@ -101,16 +102,16 @@ def saveNeighbours(pbl, fname): f.write( '%d,' % no) f.write('\n') f.close() - print '%s saved to disk' % fname + print('%s saved to disk' % fname) saveNeighbours(pbl, 'louissorter.txt') timer = Timer(); timer.start() sorter = sph.BruteForceSorter(h0, kernel) sorter.execute(pbl.prts) -timer.stop(); print timer +timer.stop(); print(timer) -print sorter +print(sorter) saveNeighbours(pbl, 'bruteforcesorter.txt') diff --git a/tbox/gmsh.py b/tbox/gmsh.py index e51c655b90c611ec1e031841bbf228cdf1468a2e..3eeae17bbe04c0410df2d793f020d75acce1aded 100644 --- a/tbox/gmsh.py +++ b/tbox/gmsh.py @@ -16,6 +16,7 @@ # limitations under the License. +from __future__ import print_function import os, os.path, sys import fwk.wutils as wu @@ -35,7 +36,7 @@ class MeshLoader: mshConv.ansys_gmsh(oldfilename, self.filename) def execute(self, myrank=-1, **pars): - print " [%s] processing %s" % (self.__class__, self.filename) + print(" [%s] processing %s" % (self.__class__, self.filename)) ext = os.path.splitext(self.filename)[1] if ext == '.msh': return self.__loadMSH(self.filename, myrank) @@ -58,37 +59,37 @@ class MeshLoader: mshfile=os.path.basename(geofile.replace('.geo','.msh')) parnew=str(pars) - if self.verb: print " [%s] new set of pars=%s" % (self.__class__, parnew) + if self.verb: print(" [%s] new set of pars=%s" % (self.__class__, parnew)) # force rebuild if pars have changed although .msh exists parfile=os.path.basename(geofile.replace('.geo','.par')) rebuild=True if os.path.isfile(mshfile): - if self.verb: print " [%s] an older version of .msh has been found" %self.__class__ + if self.verb: print(" [%s] an older version of .msh has been found" %self.__class__) if os.path.getmtime(mshfile) < os.path.getmtime(geofile): - if self.verb: print " [%s] .geo has been modified => gmsh should be rerun" %self.__class__ + if self.verb: print(" [%s] .geo has been modified => gmsh should be rerun" %self.__class__) else: - if self.verb: print " [%s] .geo and .msh match" %self.__class__ + if self.verb: print(" [%s] .geo and .msh match" %self.__class__) if os.path.isfile(parfile): # a parfile exists f = open(parfile,'r') parold = f.readline() f.close() - if self.verb: print " [%s] old set of pars=%s" % (self.__class__, parold) + if self.verb: print(" [%s] old set of pars=%s" % (self.__class__, parold)) if parold==parnew: rebuild=False - if self.verb: print " [%s] pars are the same => gmsh run avoided" %self.__class__ + if self.verb: print(" [%s] pars are the same => gmsh run avoided" %self.__class__) else: - if self.verb: print " [%s] pars are different => gmsh should be rerun" %self.__class__ + if self.verb: print(" [%s] pars are different => gmsh should be rerun" %self.__class__) else: - if self.verb: print " [%s] %s not found" % (self.__class__, parfile) + if self.verb: print(" [%s] %s not found" % (self.__class__, parfile)) if rebuild: - print ' [%s] running gmsh on "%s"...' % (self.__class__, geofile) + print(' [%s] running gmsh on "%s"...' % (self.__class__, geofile)) parcmd = self.__buildParList(pars) # TEMPORARY FIX: force gmsh to produce meshes in v2 format [RB] cmd = 'gmsh -3 -format msh2 %s -o "%s" "%s"'% (parcmd, mshfile, geofile) - if self.verb: print " [%s] cmd= %s" % (self.__class__, cmd) + if self.verb: print(" [%s] cmd= %s" % (self.__class__, cmd)) import shlex args=shlex.split(cmd) @@ -98,29 +99,29 @@ class MeshLoader: try: sproc = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=os.environ) out, err = sproc.communicate() - except Exception, e: - print "Error:", e - print "\n** Check that gmsh in your PATH!!\n" + except Exception as e: + print("Error:", e) + print("\n** Check that gmsh in your PATH!!\n") raise e # redirige la sortie de gmsh vers le stdout (eventuellement GUI) via un PIPE # (evite d'imprimer hors de la fenetre) for l in out.splitlines(): - print " [gmsh-out] ", l + print(" [gmsh-out] ", l) for l in err.splitlines(): - print " [gmsh-err] ", l + print(" [gmsh-err] ", l) if not os.path.isfile(mshfile): raise Exception("Problem during gmsh run") # write pars - if self.verb: print " [%s] writing parameters to %s" % (self.__class__, parfile) + if self.verb: print(" [%s] writing parameters to %s" % (self.__class__, parfile)) f = open(parfile,'w') f.write(parnew) f.close() else: - print ' [%s] "%s" up-to-date' % (self.__class__, mshfile) + print(' [%s] "%s" up-to-date' % (self.__class__, mshfile)) self.mshfile = mshfile def __loadMSH(self, mshfile, myrank): diff --git a/tbox/tests/basicops.py b/tbox/tests/basicops.py index 26d6dfb6a423fec9e2479c7cc5a9b6be75beab7d..7cb6e85b837986ae078e4fc7c69e2e4ab3122c9f 100644 --- a/tbox/tests/basicops.py +++ b/tbox/tests/basicops.py @@ -16,19 +16,20 @@ # limitations under the License. +from __future__ import print_function import tbox def main(): - print "creating a Point" + print("creating a Point") p1 = tbox.Pt(0., 0., 0.) - print p1 - print "creating a Node" + print(p1) + print("creating a Node") n1 = tbox.Node(1, p1) - print n1 - print "accessing Node position" + print(n1) + print("accessing Node position") pos = n1.pos - print pos + print(pos) if __name__ == "__main__": main() diff --git a/tbox/tests/fem/elem1s.py b/tbox/tests/fem/elem1s.py index d88eb21e3a638cd179befd3dce4c5e19848da1ef..68cdde0d51f5f85426bc0c74e55e4fa6bce68df0 100644 --- a/tbox/tests/fem/elem1s.py +++ b/tbox/tests/fem/elem1s.py @@ -2,40 +2,41 @@ # -*- coding: utf-8 -*- # basic tests on single finite elements +from __future__ import print_function import tbox import tbox.gmsh as gmsh def main(**d): # 1 triangle - print '='*80+'\nTesting Tri\n'+'='*80 + print('='*80+'\nTesting Tri\n'+'='*80) msh = gmsh.MeshLoader('tri1.geo',__file__).execute() el = msh.ntags['S1'].elems[0] - print el + print(el) #el.buildM() el.buildK() el.buildS() el.builds() # 1 hex - print '='*80+'\nTesting Hex\n'+'='*80 + print('='*80+'\nTesting Hex\n'+'='*80) msh = gmsh.MeshLoader('hex1.geo',__file__).execute() el = msh.ntags['Volume'].elems[0] - print el + print(el) el.buildM() el.buildK() #el.buildS() #el.builds() # 1 quad - print '='*80+'\nTesting Quad\n'+'='*80 + print('='*80+'\nTesting Quad\n'+'='*80) msh = gmsh.MeshLoader('quad1.geo',__file__).execute() el = msh.ntags['S1'].elems[0] - print el + print(el) #el.buildM() #el.buildK() el.buildS() diff --git a/tbox/tests/gmshio_test.py b/tbox/tests/gmshio_test.py index cb544aac8d3619438ddb5b77485dfab552fc6e4d..f6a1d3984924f53d825c4eec784e8f0e728334a3 100755 --- a/tbox/tests/gmshio_test.py +++ b/tbox/tests/gmshio_test.py @@ -16,6 +16,7 @@ # limitations under the License. +from __future__ import print_function import tbox import tbox.gmsh as gmsh @@ -24,19 +25,19 @@ def main(): printtags(msh) gmshWriter = tbox.GmshExport(msh) - print gmshWriter + print(gmshWriter) gmshWriter.save(msh.name) def printtags(mshdata): - print "\n-ptags:" + print("\n-ptags:") for t in mshdata.ptags.items(): - print t[1] - print "\n-etags:" + print(t[1]) + print("\n-etags:") for t in mshdata.etags.items(): - print t[1] - print "\n-partitions:" + print(t[1]) + print("\n-partitions:") for t in mshdata.parts.items(): - print t[1] + print(t[1]) if __name__ == "__main__": main() diff --git a/tbox/tests/meshDeformation.py b/tbox/tests/meshDeformation.py index 141db2609937a15934aa6a909fdf5845c9c7ce10..97e073c88873b83dd856f39ff229d8a3ce2d47f2 100644 --- a/tbox/tests/meshDeformation.py +++ b/tbox/tests/meshDeformation.py @@ -18,6 +18,7 @@ # Test mesh deformation +from __future__ import print_function import numpy as np import tbox import tbox.gmsh as gmsh @@ -62,11 +63,11 @@ def main(): # display timers tms["total"].stop() - print "CPU statistics" - print tms + print("CPU statistics") + print(tms) # eof - print '' + print('') if __name__ == "__main__": main() diff --git a/tbox/tests/meshDeformation3.py b/tbox/tests/meshDeformation3.py index 84a2b134d7df5f86b0e6551c27630cde57a143ee..ab91c2bdde2dc913e3068dadfd3337af2865610e 100644 --- a/tbox/tests/meshDeformation3.py +++ b/tbox/tests/meshDeformation3.py @@ -18,6 +18,7 @@ # Test mesh deformation +from __future__ import print_function import numpy as np import tbox import tbox.gmsh as gmsh @@ -61,11 +62,11 @@ def main(): # display timers tms["total"].stop() - print "CPU statistics" - print tms + print("CPU statistics") + print(tms) # eof - print '' + print('') if __name__ == "__main__": main() diff --git a/tbox/utils.py b/tbox/utils.py index f8adcd114379e4e0ee6ff93ee99cad276f3f7f5a..c3e5a80b32711805ad25705d78870ac658d774e4 100644 --- a/tbox/utils.py +++ b/tbox/utils.py @@ -20,6 +20,7 @@ Utilities for tbox Adrien Crovato """ +from __future__ import print_function def myrange(start, stop, step): """Extended range with custom step @@ -91,5 +92,5 @@ def write(data, name, frmt, dlm, hdr, cmts): Adrien Crovato """ import numpy as np - print 'writing data file ' + name + '.' + print('writing data file ' + name + '.') np.savetxt(name, data, fmt=frmt, delimiter=dlm, header=hdr, comments=cmts) diff --git a/tboxVtk/qt5vtk6/QVTKRenderWindowInteractor.py b/tboxVtk/qt5vtk6/QVTKRenderWindowInteractor.py index fd0565975b5ecac80a174c18827d222cae554f65..9e830585f851f53b43e9593b59e724a61e8f85fa 100644 --- a/tboxVtk/qt5vtk6/QVTKRenderWindowInteractor.py +++ b/tboxVtk/qt5vtk6/QVTKRenderWindowInteractor.py @@ -53,6 +53,7 @@ Changes by Alex Tsui, Apr. 2015 Changes by Fabian Wenzel, Jan. 2016 Support for Python3 """ +from __future__ import print_function import vtk # added by RoBo PyQtImpl = None # added by RoBo diff --git a/tboxVtk/reader.py b/tboxVtk/reader.py index 98c40f500f8df65caa3e64a73033126e866bb9d9..959d51cb14b6fb4f1f4f4052505ce9eb138750a3 100644 --- a/tboxVtk/reader.py +++ b/tboxVtk/reader.py @@ -19,6 +19,7 @@ # @brief VTK Reader # @authors Adrien Crovato +from __future__ import print_function try: import vtk except: @@ -41,5 +42,5 @@ class Reader: self.reader.Update() def close(self): - print 'No need to do that apparently...\n' + print('No need to do that apparently...\n') #self.reader.CloseFile() diff --git a/tboxVtk/tests/vtkio.py b/tboxVtk/tests/vtkio.py index 630c16f30059fc0e7b22c3ed7fc630518f4debc8..f3dae14b79d28a6b23fd0c64a21eb7fa6f7937f9 100755 --- a/tboxVtk/tests/vtkio.py +++ b/tboxVtk/tests/vtkio.py @@ -16,6 +16,7 @@ # limitations under the License. +from __future__ import print_function import tboxVtk import tbox.gmsh as gmsh @@ -24,20 +25,20 @@ def main(): printtags(msh) vtkWriter = tboxVtk.VtkExport(msh) - print vtkWriter + print(vtkWriter) vtkWriter.binary = False vtkWriter.save(msh.name) def printtags(mshdata): - print "\n-ptags:" + print("\n-ptags:") for t in mshdata.ptags.items(): - print t[1] - print "\n-etags:" + print(t[1]) + print("\n-etags:") for t in mshdata.etags.items(): - print t[1] - print "\n-partitions:" + print(t[1]) + print("\n-partitions:") for t in mshdata.parts.items(): - print t[1] + print(t[1]) if __name__ == "__main__": main() diff --git a/tlnos/tests/example1.py b/tlnos/tests/example1.py index c65921651a7a5bf1b3b6b28af14274a636121e5c..95e2c9aac6aac3ae89969a7736e56520a8ef3103 100755 --- a/tlnos/tests/example1.py +++ b/tlnos/tests/example1.py @@ -3,11 +3,12 @@ # runs the basic demo of Trilinos # trilinos-12.6.1-Source/demos/buildAgainstTrilinos +from __future__ import print_function import fwk.wutils as wu import tlnos def main(**d): - print "main!" + print("main!") expl = tlnos.Example1() expl.execute(wu.pth("input.xml",__file__)) diff --git a/waves/attic/export_xml.py b/waves/attic/export_xml.py index 33bbd4582efd9cb8f3e65c570d83ad725e9a7c62..afbf596d7cc76869346e40f6f959cb9b98f2fb7a 100644 --- a/waves/attic/export_xml.py +++ b/waves/attic/export_xml.py @@ -1,6 +1,6 @@ - # display - if 0: - import viewer - ugrid = viewer.toUgrid(mshdata) - viewer.writeXML(ugrid, name='mesh.vtu') - viewer.viewUgrid(ugrid) +# display +if 0: + import viewer + ugrid = viewer.toUgrid(mshdata) + viewer.writeXML(ugrid, name='mesh.vtu') + viewer.viewUgrid(ugrid) \ No newline at end of file diff --git a/waves/broken/cas1.py b/waves/broken/cas1.py index 54d864ce39517fdcef97e5cea1bf42c3ff817820..cc070328af39bc0c74afde84f2e88222de3adc17 100755 --- a/waves/broken/cas1.py +++ b/waves/broken/cas1.py @@ -3,6 +3,7 @@ # # TODO: il manque une source... +from __future__ import print_function import waves as w import tbox.gmsh as gmsh import waves.wtools as wt @@ -25,12 +26,12 @@ def main(): scheme.savefreq=5 scheme.nthreads=8 - print "dt=", dt - print "nsteps=", int(scheme.ttot/dt) + print("dt=", dt) + print("nsteps=", int(scheme.ttot/dt)) w.Medium(pbl, "Volume", c) - print pbl + print(pbl) usegui=1 if not usegui: diff --git a/waves/broken/geuz/geophysique.py b/waves/broken/geuz/geophysique.py index cd328d478b231dad58190736e2cf3e9902628b6b..93db74273c5020155cc9a58b21a7ebeafdbf2a0e 100755 --- a/waves/broken/geuz/geophysique.py +++ b/waves/broken/geuz/geophysique.py @@ -3,12 +3,13 @@ # # TODO: marche pas/plus +from __future__ import print_function import waves as w import tbox.gmsh as gmsh def main(): msh = gmsh.MeshLoader("geophysique.geo", __file__).execute() - print msh + print(msh) pbl = w.Problem(msh) pbl.c = 1500.0 diff --git a/waves/broken/waves01_onelab.py b/waves/broken/waves01_onelab.py index 4c055683d4788ac67e6bad4f6afa2e5f544d538c..260bef92cd764efbe9d044addb8df98d194ff574 100755 --- a/waves/broken/waves01_onelab.py +++ b/waves/broken/waves01_onelab.py @@ -2,6 +2,7 @@ # -*- coding: utf-8 -*- # Simple 2D wave propagation test +from __future__ import print_function import sys #sys.path.append("/usr/local/bin") #sys.path.append("C:\local\gmsh-2.9.0-Windows") @@ -93,10 +94,10 @@ class OneLabCallback(w.DisplayHook): def main(): global olab msh = wutils.MeshLoader("waves01.geo").execute() - print msh + print(msh) pbl = w.Problem(msh) - print pbl + print(pbl) Nx=50 c = wspeed diff --git a/waves/srcs.py b/waves/srcs.py index 43416c5f42fd0e80b61d250805fc782ae6be25f2..ba3cd8ff57ee78ad5c6cc403d05ca819f5069489 100644 --- a/waves/srcs.py +++ b/waves/srcs.py @@ -17,6 +17,7 @@ # custom sources coded with python +from __future__ import print_function import waves as w import tbox import math @@ -63,13 +64,13 @@ class MultiSource(w.Source): v.x[2] = 0 d = v.length() if abs(d - dist) < 1.0e-6: - print "node source selected at ", n - print "dist", dist - print "nod=", n + print("node source selected at ", n) + print("dist", dist) + print("nod=", n) self.srcs.append(Src(n, freq)) def __del__(self): - print "[MultiSource] I'm dying..." + print("[MultiSource] I'm dying...") class PulseSource(w.Source): diff --git a/waves/utils.py b/waves/utils.py index 2876872fdfa244f123736aa544cbf81587266ed4..c039715ee585dee222f479f5e2cee41b5ddf753a 100644 --- a/waves/utils.py +++ b/waves/utils.py @@ -17,6 +17,7 @@ # limitations under the License. +from __future__ import print_function import tbox import waves as w @@ -26,7 +27,7 @@ def integrate(scheme, writer, vmin=-0.1, vmax=0.1): args = parseargs() scheme.nthreads = args.k - print scheme + print(scheme) if args.nogui: scheme.start(writer) diff --git a/waves/viewer.py b/waves/viewer.py index 80b60dcac9179ce67314ec22a5a9393448e9d432..748ee6021570748829c237c0332a46a19c3f0fbe 100644 --- a/waves/viewer.py +++ b/waves/viewer.py @@ -17,6 +17,7 @@ # limitations under the License. +from __future__ import print_function import sys import waves as w import tbox as tb @@ -27,16 +28,16 @@ import tbox as tb from PyQt5.QtCore import * from PyQt5.QtGui import * from PyQt5.QtWidgets import * -print "PyQt5 (Qt %s) loaded!" % QT_VERSION_STR +print("PyQt5 (Qt %s) loaded!" % QT_VERSION_STR) # vtk import vtk try: from vtk.qt.QVTKRenderWindowInteractor import QVTKRenderWindowInteractor - print "using vtk.qt.QVTKRenderWindowInteractor" + print("using vtk.qt.QVTKRenderWindowInteractor") except: from tboxVtk.qt5vtk6.QVTKRenderWindowInteractor import QVTKRenderWindowInteractor - print "using pki.qt5vtk6.QVTKRenderWindowInteractor" + print("using pki.qt5vtk6.QVTKRenderWindowInteractor") # ----------------------------------------------------------------------------------------- @@ -63,7 +64,7 @@ class MeshViewer(QWidget, w.DisplayHook): self.vmin = -0.1 self.vmax = 0.1 - print "starting MeshViewer init..." + print("starting MeshViewer init...") self.__setupGUI() self.__setupVTK() @@ -72,12 +73,12 @@ class MeshViewer(QWidget, w.DisplayHook): self.show() self.vtkwidget.Initialize( ) # [Linux] faire ca le plus tard possible (apres self.show!!) - print "MeshViewer ready." + print("MeshViewer ready.") def closeEvent(self, event): self.scheme.stopit = True self.running = 'running' # sort de "while self.running=='pause'" - print "GUI killed!" + print("GUI killed!") QWidget.closeEvent(self, event) def start(self): @@ -159,7 +160,7 @@ class MeshViewer(QWidget, w.DisplayHook): def verboseSlot(self, state): self.scheme.verbose = (state != 0) if not state: - print "<verbose=OFF>" + print("<verbose=OFF>") def startSlot(self): if self.running == 'init': @@ -247,7 +248,7 @@ class MeshViewer(QWidget, w.DisplayHook): self.render() def ragequit(self): - print "rage quit!" + print("rage quit!") self.scheme.stopit = True self.app.quit() @@ -263,7 +264,7 @@ class MeshViewer(QWidget, w.DisplayHook): self.app.processEvents() def __createUgrid(self): - print 'creating vtkUnstructuredGrid...' + print('creating vtkUnstructuredGrid...') self.ugrid = vtk.vtkUnstructuredGrid() self.points = vtk.vtkPoints() self.ugrid.SetPoints(self.points) @@ -290,8 +291,8 @@ class MeshViewer(QWidget, w.DisplayHook): for j in range(8): ids.SetId(j, n[j].no - 1) self.ugrid.InsertNextCell(hexa.GetCellType(), ids) - print self.ugrid.GetNumberOfPoints( - ), 'points and', self.ugrid.GetNumberOfCells(), 'cells converted' + print(self.ugrid.GetNumberOfPoints( + ), 'points and', self.ugrid.GetNumberOfCells(), 'cells converted') def writeXML(self, name='mesh.vtu'): writer = vtk.vtkXMLUnstructuredGridWriter()