Skip to content

Commit c271293

Browse files
authored
Merge branch 'develop' into cleanup_flow_solver_duplication
2 parents 93822d4 + 574c286 commit c271293

3 files changed

Lines changed: 42 additions & 34 deletions

File tree

SU2_PY/SU2/util/filter_adjoint.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,13 @@
2727

2828
from __future__ import division, print_function, absolute_import
2929

30-
import os, math
30+
import os
31+
import math
3132
from numpy import pi
3233
from optparse import OptionParser
3334
import numpy as np
34-
import libSU2, libSU2_mesh
35+
import libSU2
36+
import libSU2_mesh
3537

3638
# plotting with matplotlib
3739
try:
@@ -179,7 +181,7 @@ def process_surface_adjoint( config_filename ,
179181
Sens_smoother = smooth( S_clip, Sens_smooth, smth_len , 'blackman' )
180182
Sens_filter = Sens_smooth + (Sens_smooth - Sens_smoother) # sharpener
181183
else:
182-
raise Exception, 'unknown filter type'
184+
raise Exception('unknown filter type')
183185

184186
# --------------------------------------------
185187
# PLOTTING
@@ -282,8 +284,6 @@ def process_surface_adjoint( config_filename ,
282284
print('----------------- Exit Success (Process Surface Adjoint) ----------------')
283285
print('')
284286

285-
return
286-
287287
#: def process_surface_adjoint()
288288

289289

@@ -472,10 +472,10 @@ def window(t,x,window_delta,window='hanning'):
472472
"""
473473

474474
if x.ndim != 1:
475-
raise ValueError, "smooth only accepts 1 dimension arrays."
475+
raise ValueError("smooth only accepts 1 dimension arrays.")
476476

477-
if not window in ['flat', 'hanning', 'hamming', 'bartlett', 'blackman']:
478-
raise ValueError, "Window is not of 'flat', 'hanning', 'hamming', 'bartlett', 'blackman'"
477+
if window not in ['flat', 'hanning', 'hamming', 'bartlett', 'blackman']:
478+
raise ValueError("Window is not of 'flat', 'hanning', 'hamming', 'bartlett', 'blackman'")
479479

480480
# interpolate to constant time sample width
481481
min_dt = np.min( np.diff(t) )
@@ -514,6 +514,7 @@ def window(t,x,window_delta,window='hanning'):
514514
# Run Main from Command Line
515515
# -----------------------------------------------------------------
516516

517-
if __name__ == '__main__': main()
517+
if __name__ == '__main__':
518+
main()
518519

519520

SU2_PY/compute_uncertainty.py

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,11 @@
2727
# imports
2828
import numpy as np
2929
from optparse import OptionParser
30-
import os, sys, shutil, copy, os.path
30+
import os
31+
import sys
32+
import shutil
33+
import copy
34+
import os.path
3135
sys.path.append(os.environ['SU2_RUN'])
3236
import SU2
3337

@@ -66,13 +70,13 @@ def main():
6670

6771
# perform eigenvalue perturbations
6872
for comp in range(1,4):
69-
print "\n\n =================== Performing " + str(comp) + " Component Perturbation =================== \n\n"
73+
print('\n\n =================== Performing ' + str(comp) + ' Component Perturbation =================== \n\n')
7074

7175
# make copies
7276
konfig = copy.deepcopy(config)
7377
ztate = copy.deepcopy(state)
7478

75-
# set componentality
79+
# set componentality
7680
konfig.UQ_COMPONENT = comp
7781

7882
# send output to a folder
@@ -85,14 +89,14 @@ def main():
8589
# run su2
8690
info = SU2.run.CFD(konfig)
8791
ztate.update(info)
88-
89-
# Solution merging
90-
konfig.SOLUTION_FILENAME = konfig.RESTART_FILENAME
91-
info = SU2.run.merge(konfig)
92-
ztate.update(info)
92+
93+
# Solution merging
94+
konfig.SOLUTION_FILENAME = konfig.RESTART_FILENAME
95+
info = SU2.run.merge(konfig)
96+
ztate.update(info)
9397

9498

95-
print "\n\n =================== Performing p1c1 Component Perturbation =================== \n\n"
99+
print('\n\n =================== Performing p1c1 Component Perturbation =================== \n\n')
96100

97101
# make copies
98102
konfig = copy.deepcopy(config)
@@ -118,7 +122,7 @@ def main():
118122
info = SU2.run.merge(konfig)
119123
state.update(info)
120124

121-
print "\n\n =================== Performing p1c2 Component Perturbation =================== \n\n"
125+
print('\n\n =================== Performing p1c2 Component Perturbation =================== \n\n')
122126

123127
# make copies
124128
konfig = copy.deepcopy(config)

SU2_PY/fsi_computation.py

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@
2929
# Imports
3030
# ----------------------------------------------------------------------
3131

32-
import os, sys, shutil, copy
32+
import os
33+
import sys
34+
import shutil
35+
import copy
3336
import time as timer
3437
from math import * # use mathematical expressions
3538
from optparse import OptionParser # use a parser for configuration
@@ -56,7 +59,7 @@ def main():
5659

5760
(options, args)=parser.parse_args()
5861

59-
if options.with_MPI == True:
62+
if options.with_MPI:
6063
from mpi4py import MPI # MPI is initialized from now by python and can be continued in C++ !
6164
comm = MPI.COMM_WORLD
6265
myid = comm.Get_rank()
@@ -74,9 +77,9 @@ def main():
7477
if myid == rootProcess:
7578
if os.getcwd() not in sys.path:
7679
sys.path.append(os.getcwd())
77-
print("Setting working directory : {}".format(os.getcwd()))
78-
else:
79-
print("Working directory is set to {}".format(os.getcwd()))
80+
print("Setting working directory : {}".format(os.getcwd()))
81+
else:
82+
print("Working directory is set to {}".format(os.getcwd()))
8083

8184
# starts timer
8285
start = timer.time()
@@ -89,7 +92,7 @@ def main():
8992

9093
CSD_Solver = FSI_config['CSD_SOLVER'] # CSD solver
9194

92-
if have_MPI == True:
95+
if have_MPI:
9396
comm.barrier()
9497

9598
# --- Initialize the fluid solver --- #
@@ -99,13 +102,13 @@ def main():
99102
FluidSolver = pysu2.CFluidDriver(CFD_ConFile, 1, FSI_config['NDIM'], comm)
100103
except TypeError as exception:
101104
print('A TypeError occured in pysu2.CSingleZoneDriver : ',exception)
102-
if have_MPI == True:
105+
if have_MPI:
103106
print('ERROR : You are trying to initialize MPI with a serial build of the wrapper. Please, remove the --parallel option that is incompatible with a serial build.')
104107
else:
105108
print('ERROR : You are trying to launch a computation without initializing MPI but the wrapper has been built in parallel. Please add the --parallel option in order to initialize MPI for the wrapper.')
106109
return
107110

108-
if have_MPI == True:
111+
if have_MPI:
109112
comm.barrier()
110113

111114
# --- Initialize the solid solver --- # (!! for now we are using only serial solid solvers)
@@ -125,29 +128,29 @@ def main():
125128
else:
126129
SolidSolver = None
127130

128-
if have_MPI == True:
131+
if have_MPI:
129132
comm.barrier()
130133

131134
# --- Initialize and set the FSI interface (coupling environement) --- #
132135
if myid == rootProcess:
133136
print('\n***************************** Initializing FSI interface *****************************')
134-
if have_MPI == True:
137+
if have_MPI:
135138
comm.barrier()
136139
FSIInterface = FSI.Interface(FSI_config, FluidSolver, SolidSolver, have_MPI)
137140

138141
if myid == rootProcess:
139142
print('\n***************************** Connect fluid and solid solvers *****************************')
140-
if have_MPI == True:
143+
if have_MPI:
141144
comm.barrier()
142145
FSIInterface.connect(FSI_config, FluidSolver, SolidSolver)
143146

144147
if myid == rootProcess:
145148
print('\n***************************** Mapping fluid-solid interfaces *****************************')
146-
if have_MPI == True:
149+
if have_MPI:
147150
comm.barrier()
148151
FSIInterface.interfaceMapping(FluidSolver, SolidSolver, FSI_config)
149152

150-
if have_MPI == True:
153+
if have_MPI:
151154
comm.barrier()
152155

153156
# --- Launch a steady or unsteady FSI computation --- #
@@ -177,15 +180,15 @@ def main():
177180
if myid == rootProcess:
178181
print('A KeyboardInterrupt occured in FSIInterface.SteadyFSI : ',exception)
179182

180-
if have_MPI == True:
183+
if have_MPI:
181184
comm.barrier()
182185

183186
# --- Exit cleanly the fluid and solid solvers --- #
184187
FluidSolver.Postprocessing()
185188
if myid == rootProcess:
186189
SolidSolver.exit()
187190

188-
if have_MPI == True:
191+
if have_MPI:
189192
comm.barrier()
190193

191194
# stops timer

0 commit comments

Comments
 (0)