From ca57dca62f2f4fbd818d6fb77f7de773f5593afb Mon Sep 17 00:00:00 2001 From: acrovato <a.crovato@uliege.be> Date: Wed, 11 Nov 2020 15:40:32 +0100 Subject: [PATCH] Change default save behavior. Uniformize python header and doc. --- flow/benchmark/onera.py | 6 +++--- flow/cases/coyote.py | 2 +- flow/cases/n0012.py | 4 ++-- flow/cases/n0012_3.py | 8 ++++---- flow/cases/n64A410.py | 4 ++-- flow/cases/rae2822.py | 4 ++-- flow/cases/wbht.py | 6 +++--- flow/cases/wht.py | 6 +++--- flow/default.py | 19 ++++++++++++------- flow/scripts/config.py | 4 ++-- flow/scripts/polar.py | 20 ++++++++++---------- flow/scripts/trim.py | 9 +++++---- flow/src/wAdjoint.cpp | 2 +- flow/src/wAdjoint.h | 2 +- flow/src/wSolver.cpp | 4 ++-- flow/src/wSolver.h | 2 +- flow/tests/adjoint.py | 9 +++++---- flow/tests/bli.py | 4 ++-- flow/tests/cylinder.py | 9 +++++---- flow/tests/cylinder2D5.py | 7 ++++--- flow/tests/cylinder3.py | 7 ++++--- flow/tests/lift.py | 7 ++++--- flow/tests/lift3.py | 7 ++++--- flow/tests/meshDef.py | 9 +++++---- flow/tests/meshDef3.py | 7 ++++--- flow/tests/nonlift.py | 7 ++++--- flow/utils.py | 38 +++++++++++++++++++------------------- flow/validation/agard.py | 6 +++--- flow/validation/onera.py | 6 +++--- flow/viscous/airfoil.py | 3 +-- flow/viscous/boundary.py | 1 - flow/viscous/coupler.py | 5 ++--- flow/viscous/newton.py | 1 - flow/viscous/solver.py | 3 +-- flow/viscous/wake.py | 3 +-- 35 files changed, 125 insertions(+), 116 deletions(-) diff --git a/flow/benchmark/onera.py b/flow/benchmark/onera.py index b65789de..962b830e 100644 --- a/flow/benchmark/onera.py +++ b/flow/benchmark/onera.py @@ -16,8 +16,8 @@ # limitations under the License. -# @brief Compute flow around the Onera M6 wing at 3 degrees AOA and Mach 0.84 for benchmark -# @authors Adrien Crovato +## Compute flow around the Onera M6 wing at 3 degrees AOA and Mach 0.84 for benchmark +# Adrien Crovato import numpy as np import flow.default as floD @@ -88,7 +88,7 @@ def main(): tms['solver'].start() solver = newton(pbl) solver.run() - solver.save(0, writer) + solver.save(writer) tms['solver'].stop() # display timers diff --git a/flow/cases/coyote.py b/flow/cases/coyote.py index dbda2d57..d5c0b564 100644 --- a/flow/cases/coyote.py +++ b/flow/cases/coyote.py @@ -16,7 +16,7 @@ # limitations under the License. -# Coyote - Advanced Pilot Training Aircraft +## Coyote - Advanced Pilot Training Aircraft # Plane designed for the AIAA 2017-2018 aircraft design competition # by Raphael Dubois, Thibault Laurent, Bao Long Le Van, Nayan Levaux, # Guillaume Noiset, Axel Piret, Arthur Scheffer, and Vincent Schmitz diff --git a/flow/cases/n0012.py b/flow/cases/n0012.py index 9979bdbf..be2da329 100644 --- a/flow/cases/n0012.py +++ b/flow/cases/n0012.py @@ -16,8 +16,8 @@ # limitations under the License. -# @brief NACA0012 airfoil configuration file for flow polar script -# @authors Adrien Crovato +## NACA 0012 airfoil configuration file for flow polar script +# Adrien Crovato def getParam(): p = {} diff --git a/flow/cases/n0012_3.py b/flow/cases/n0012_3.py index e5564d35..0505e436 100644 --- a/flow/cases/n0012_3.py +++ b/flow/cases/n0012_3.py @@ -16,8 +16,8 @@ # limitations under the License. -# @brief NACA0012 wing configuration file for flow polar script -# @authors Adrien Crovato +## NACA 0012 wing configuration file for flow polar script +# Adrien Crovato def getParam(): p = {} @@ -29,7 +29,7 @@ def getParam(): p['Dim'] = 3 # Problem dimension p['Format'] = 'vtk' # Save format (vtk or gmsh) p['Slice'] = [0.01, 0.25, 0.5, 0.75, 0.95] # array of (y) coordinates to perform slice along the span (empty if none) - p['TagId'] = 5 # tag number of physical group to be sliced + p['TagId'] = 4 # tag number of physical group to be sliced # Markers p['Fluid'] = 'field' # Name of physical group containing the fluid p['Farfield'] = ['upstream', 'farfield', 'downstream'] # LIST of name of physical groups containing the farfield boundaries (upstream/downstream should be first/last element) @@ -69,4 +69,4 @@ def main(): polar.disp() if __name__ == "__main__": - main() \ No newline at end of file + main() diff --git a/flow/cases/n64A410.py b/flow/cases/n64A410.py index b020ff43..219095dc 100644 --- a/flow/cases/n64A410.py +++ b/flow/cases/n64A410.py @@ -16,8 +16,8 @@ # limitations under the License. -# @brief NACA64A210 airfoil configuration file for flow trim script -# @authors Adrien Crovato +## NACA 64A210 airfoil configuration file for flow trim script +# Adrien Crovato def getParam(): p = {} diff --git a/flow/cases/rae2822.py b/flow/cases/rae2822.py index ec5061d1..e234637c 100644 --- a/flow/cases/rae2822.py +++ b/flow/cases/rae2822.py @@ -16,8 +16,8 @@ # limitations under the License. -# @brief RAE2822 airfoil configuration file for flow polar script -# @authors Adrien Crovato +## RAE 2822 airfoil configuration file for flow polar script +# Adrien Crovato def getParam(): p = {} diff --git a/flow/cases/wbht.py b/flow/cases/wbht.py index 1e25c020..39723b8c 100644 --- a/flow/cases/wbht.py +++ b/flow/cases/wbht.py @@ -16,8 +16,8 @@ # limitations under the License. -# @brief Wing-body-tail configuration file for flow trim script -# @authors Adrien Crovato +## Wing-body-tail configuration file for flow trim script +# Adrien Crovato # # CAUTION # Gmsh might not generate the wing/tail surfaces properly. Results might not be accurate @@ -94,4 +94,4 @@ def main(): trim.disp() if __name__ == "__main__": - main() \ No newline at end of file + main() diff --git a/flow/cases/wht.py b/flow/cases/wht.py index 19e6de7b..3b11cb26 100644 --- a/flow/cases/wht.py +++ b/flow/cases/wht.py @@ -16,8 +16,8 @@ # limitations under the License. -# @brief Wing-tail configuration file for flow trim script -# @authors Adrien Crovato +## Wing-tail configuration file for flow trim script +# Adrien Crovato def getParam(): p = {} @@ -85,4 +85,4 @@ def main(): trim.disp() if __name__ == "__main__": - main() \ No newline at end of file + main() diff --git a/flow/default.py b/flow/default.py index ebc7aeec..7b38f3c3 100644 --- a/flow/default.py +++ b/flow/default.py @@ -17,15 +17,15 @@ ## Default initialization for flow tests -# # Adrien Crovato from fwk.wutils import parseargs import flow as flo import tbox -## Initialize mesh and mesh writer def mesh(dim, file, pars, bnd, wk = 'wake', wktp = None): + '''Initialize mesh and mesh writer + ''' import tbox.gmsh as gmsh # load the mesh msh = gmsh.MeshLoader(file,__file__).execute(**pars) @@ -41,8 +41,9 @@ def mesh(dim, file, pars, bnd, wk = 'wake', wktp = None): gmshWriter.save(msh.name) return msh, gmshWriter -## Initialize problem def problem(msh, dim, alpha, beta, minf, mcrit, sref, lref, xref, yref, zref, sur, fld = 'field', upstr = 'upstream', ff = 'farfield', dnstr = 'downstream', wk = 'wake', te = None, tp = None, vsc = False): + '''Initialize problem + ''' pbl = flo.Problem(msh, dim, alpha, beta, minf, sref, lref, xref, yref, zref) if minf == 0: pbl.set(flo.Medium(msh, fld, flo.F0ElRhoL(), flo.F0ElMachL(), flo.F0ElCpL(), flo.F0PsPhiInf(dim, alpha, beta))) @@ -74,8 +75,9 @@ def problem(msh, dim, alpha, beta, minf, mcrit, sref, lref, xref, yref, zref, su blww = None return pbl, dirichlet, wake, bnd, [blw, blww] -## Initialize Picard solver def picard(pbl): + '''Initialize Picard solver + ''' args = parseargs() solver = flo.Picard(pbl, tbox.Gmres()) solver.nthreads = args.k @@ -86,8 +88,9 @@ def picard(pbl): solver.relax = 0.7 return solver -## Initialize Newton solver def newton(pbl): + '''Initialize Newton solver + ''' from tbox.solvers import LinearSolver args = parseargs() solver = flo.Newton(pbl, LinearSolver().pardiso()) @@ -101,8 +104,9 @@ def newton(pbl): solver.avThrsh = 1e-2 return solver -## Initialize mesh morpher def meshMorpher(msh, dim, mov, fxd = ['upstream', 'farfield', 'downstream'], fld = 'field', wk = 'wake', sym = 'symmetry'): + '''Initialize mesh morpher + ''' args = parseargs() mshDef = tbox.MshDeform(msh, dim) mshDef.nthreads = args.k @@ -115,8 +119,9 @@ def meshMorpher(msh, dim, mov, fxd = ['upstream', 'farfield', 'downstream'], fld mshDef.initialize() return mshDef -## Initialize viewer def initViewer(problem): + '''Initialize viewer + ''' args = parseargs() if not args.nogui: from tbox.viewer import GUI diff --git a/flow/scripts/config.py b/flow/scripts/config.py index 09ab1757..89306a13 100644 --- a/flow/scripts/config.py +++ b/flow/scripts/config.py @@ -16,8 +16,8 @@ # limitations under the License. -# @brief Base class for configuration -# @authors Adrien Crovato +## Base class for configuration +# Adrien Crovato import flow as f import tbox diff --git a/flow/scripts/polar.py b/flow/scripts/polar.py index 8adb98b5..3d1ade85 100644 --- a/flow/scripts/polar.py +++ b/flow/scripts/polar.py @@ -16,9 +16,10 @@ # limitations under the License. -# @brief Polar -# Compute lift and polar curves -# @authors Adrien Crovato +## Polar +# Adrien Crovato +# +# Compute lift and polar curves import math import flow.utils as fU @@ -66,15 +67,14 @@ class Polar(Config): self.tms["solver"].start() self.solver.run() self.tms["solver"].stop() - self.solver.save(ac, self.mshWriter) + self.solver.save(self.mshWriter, ac) print('\n') # extract Cp - if self.alphas[0] == self.alphas[-1]: - if self.dim == 2: - Cp = fU.extract(self.bnd.groups[0].tag.elems, self.solver.Cp) - tU.write(Cp, "Cp_airfoil.dat", "%1.5e", ", ", "x, y, z, Cp", "") - elif self.dim == 3 and self.format == 'vtk' and self.slice: - fU.writeSlices(self.msh.name, self.slice, self.tag) + if self.dim == 2: + Cp = fU.extract(self.bnd.groups[0].tag.elems, self.solver.Cp) + tU.write(Cp, 'Cp_airfoil_'+str(ac)+'.dat', '%1.5e', ', ', 'alpha = '+str(alpha*180/math.pi)+' deg\nx, y, z, Cp', '') + elif self.dim == 3 and self.format == 'vtk' and self.slice: + fU.writeSlices(self.msh.name, self.slice, self.tag, ac) # extract force coefficients self.Cls.append(self.solver.Cl) self.Cds.append(self.solver.Cd) diff --git a/flow/scripts/trim.py b/flow/scripts/trim.py index c9f1d954..71e38240 100644 --- a/flow/scripts/trim.py +++ b/flow/scripts/trim.py @@ -16,9 +16,10 @@ # limitations under the License. -# @brief Trim analysis -# Find the angle of attack to match a specified lift coefficient -# @authors Adrien Crovato +## Trim analysis +# Adrien Crovato +# +# Find the angle of attack to match a specified lift coefficient import math import flow.utils as fU @@ -79,7 +80,7 @@ class Trim(Config): it += 1 # save results - self.solver.save(0, self.mshWriter) + self.solver.save(self.mshWriter) print('\n') # extract Cp if self.dim == 2: diff --git a/flow/src/wAdjoint.cpp b/flow/src/wAdjoint.cpp index b02ef4ca..c7112241 100644 --- a/flow/src/wAdjoint.cpp +++ b/flow/src/wAdjoint.cpp @@ -413,7 +413,7 @@ void Adjoint::buildWake(WakeElement *&we, Eigen::MatrixXd &Kupup, Eigen::MatrixX * @brief Write the results * @authors Adrien Crovato */ -void Adjoint::save(int n, MshExport *mshWriter) +void Adjoint::save(MshExport *mshWriter, int n) { // Write files std::cout << "Saving files... " << std::endl; diff --git a/flow/src/wAdjoint.h b/flow/src/wAdjoint.h index 54cd7970..e0943ba6 100644 --- a/flow/src/wAdjoint.h +++ b/flow/src/wAdjoint.h @@ -49,7 +49,7 @@ public: virtual ~Adjoint() { std::cout << "~Adjoint()\n"; } void run(); - void save(int n, tbox::MshExport *mshWriter); + void save(tbox::MshExport *mshWriter, int n = 0); #ifndef SWIG virtual void write(std::ostream &out) const override; diff --git a/flow/src/wSolver.cpp b/flow/src/wSolver.cpp index 686ccad5..0fda55d6 100644 --- a/flow/src/wSolver.cpp +++ b/flow/src/wSolver.cpp @@ -57,7 +57,7 @@ Solver::Solver(std::shared_ptr<Problem> _pbl, std::shared_ptr<LinearSolver> _lin std::cout << "** | __| | | / \\ \\ \\_/ / **" << std::endl; std::cout << "** |_| |_| \\__/ \\/ \\/ **" << std::endl; std::cout << "*******************************************************************************" << std::endl; - std::cout << "** Hi! My name is Flow v1.6-2004 **" << std::endl; + std::cout << "** Hi! My name is Flow v1.7-2011 **" << std::endl; std::cout << "** Adrien Crovato & Romain Boman **" << std::endl; std::cout << "** ULiege 2018-2020 **" << std::endl; std::cout << "*******************************************************************************" << std::endl @@ -126,7 +126,7 @@ bool Solver::run() * @brief Write the results * @authors Adrien Crovato */ -void Solver::save(int n, MshExport *mshWriter) +void Solver::save(MshExport *mshWriter, int n) { // Write files std::cout << "Saving files... " << std::endl; diff --git a/flow/src/wSolver.h b/flow/src/wSolver.h index ba3cf3a7..0a176700 100644 --- a/flow/src/wSolver.h +++ b/flow/src/wSolver.h @@ -67,7 +67,7 @@ public: virtual ~Solver(); virtual bool run(); - void save(int n, tbox::MshExport *mshWriter); + void save(tbox::MshExport *mshWriter, int n = 0); protected: void computeFlow(); diff --git a/flow/tests/adjoint.py b/flow/tests/adjoint.py index 2241d156..58d0fe77 100644 --- a/flow/tests/adjoint.py +++ b/flow/tests/adjoint.py @@ -16,8 +16,9 @@ # limitations under the License. -# @brief Compute adjoint solution of lifting (linear or nonlinear) potential flow around a naca0012 -# @authors Adrien Crovato +## Compute adjoint solution of lifting (linear or nonlinear) potential flow around a NACA 0012 +# Adrien Crovato +# # Test the adjoint solver # # CAUTION @@ -63,14 +64,14 @@ def main(): tms['solver'].start() solver = floD.newton(pbl) solver.run() - solver.save(0, gmshWriter) + solver.save(gmshWriter) tms['solver'].stop() # solve adjoint problem tms['adjoint'].start() adjoint = flo.Adjoint(solver) adjoint.run() - adjoint.save(0, gmshWriter) + adjoint.save(gmshWriter) tms['adjoint'].stop() # extract Cp diff --git a/flow/tests/bli.py b/flow/tests/bli.py index c6e8cbc2..4c936f19 100644 --- a/flow/tests/bli.py +++ b/flow/tests/bli.py @@ -17,8 +17,8 @@ ## Compute lifting (linear or nonlinear) viscous flow around a NACA 0012 -# # Amaury Bilocq +# # Test the viscous-inviscid interaction scheme # Reference to the master's thesis: http://hdl.handle.net/2268/252195 # Reference test cases with Naca0012 (different from master's thesis): @@ -132,4 +132,4 @@ def main(): print('') if __name__ == "__main__": - main() \ No newline at end of file + main() diff --git a/flow/tests/cylinder.py b/flow/tests/cylinder.py index 44ddfd1d..c5d09d07 100644 --- a/flow/tests/cylinder.py +++ b/flow/tests/cylinder.py @@ -16,8 +16,9 @@ # limitations under the License. -# @brief Compute the (non)linear flow around cylinder, with various B.C. -# @authors Adrien Crovato +## Compute the (non)linear flow around cylinder, with various B.C. +# Adrien Crovato +# # Test solver convergence and boundary conditions # # CAUTION @@ -67,12 +68,12 @@ def main(): tms['picard'].start() solver0 = floD.picard(pbl) cnvrgd0 = solver0.run() - solver0.save(0, gmshWriter) + solver0.save(gmshWriter) tms['picard'].stop() tms['newton'].start() solver1 = floD.newton(pbl) cnvrgd1 = solver1.run() - solver1.save(0, gmshWriter) + solver1.save(gmshWriter) tms['newton'].stop() # compute mean error in Boundary, Neumann boundary condition (works only for Line2 elements) diff --git a/flow/tests/cylinder2D5.py b/flow/tests/cylinder2D5.py index 76ef1e20..087f5dfb 100644 --- a/flow/tests/cylinder2D5.py +++ b/flow/tests/cylinder2D5.py @@ -16,8 +16,9 @@ # limitations under the License. -# @brief Compute the (non)linear flow around extruded 2D cylinder, with various B.C. -# @authors Adrien Crovato +## Compute the (non)linear flow around extruded 2D cylinder, with various B.C. +# Adrien Crovato +# # Test solver convergence and boundary conditions # # CAUTION @@ -69,7 +70,7 @@ def main(): tms['solver'].start() solver = floD.newton(pbl) cnvrgd = solver.run() - solver.save(0, gmshWriter) + solver.save(gmshWriter) tms['solver'].stop() # compute mean error in Boundary, Neumann boundary condition (works only for Tri3 elements) diff --git a/flow/tests/cylinder3.py b/flow/tests/cylinder3.py index 38462d4e..e618daf7 100644 --- a/flow/tests/cylinder3.py +++ b/flow/tests/cylinder3.py @@ -16,8 +16,9 @@ # limitations under the License. -# @brief Compute the (non)linear flow around 3D cylinder, with various B.C. -# @authors Adrien Crovato +## Compute the (non)linear flow around 3D cylinder, with various B.C. +# Adrien Crovato +# # Test solver convergence and boundary conditions # # CAUTION @@ -72,7 +73,7 @@ def main(): tms['solver'].start() solver = floD.newton(pbl) cnvrgd = solver.run() - solver.save(0, gmshWriter) + solver.save(gmshWriter) tms['solver'].stop() # compute mean error in Boundary, Neumann boundary condition (works only for Tri3 elements) diff --git a/flow/tests/lift.py b/flow/tests/lift.py index ca223a02..0c4e5dc1 100644 --- a/flow/tests/lift.py +++ b/flow/tests/lift.py @@ -16,8 +16,9 @@ # limitations under the License. -# @brief Compute lifting (linear or nonlinear) potential flow around a naca0012 -# @authors Adrien Crovato +## Compute lifting (linear or nonlinear) potential flow around a NACA 0012 +# Adrien Crovato +# # Test the nonlinear shock-capturing capability and the Kutta condition # # CAUTION @@ -61,7 +62,7 @@ def main(): tms['solver'].start() solver = floD.newton(pbl) solver.run() - solver.save(0, gmshWriter) + solver.save(gmshWriter) tms['solver'].stop() # extract Cp diff --git a/flow/tests/lift3.py b/flow/tests/lift3.py index bbbc9c44..5d754533 100644 --- a/flow/tests/lift3.py +++ b/flow/tests/lift3.py @@ -16,8 +16,9 @@ # limitations under the License. -# @brief Compute lifting (linear or nonlinear) potential flow around a naca0012 rectangular wing -# @authors Adrien Crovato +## Compute lifting (linear or nonlinear) potential flow around a NACA 0012 rectangular wing +# Adrien Crovato +# # Test the nonlinear shock-capturing capability and the Kutta condition # # CAUTION @@ -69,7 +70,7 @@ def main(): tms['solver'].start() solver = floD.newton(pbl) solver.run() - solver.save(0, gmshWriter) + solver.save(gmshWriter) tms['solver'].stop() # display timers diff --git a/flow/tests/meshDef.py b/flow/tests/meshDef.py index c92090da..a5d37315 100644 --- a/flow/tests/meshDef.py +++ b/flow/tests/meshDef.py @@ -16,8 +16,9 @@ # limitations under the License. -# @brief Compute the flow on a deformed mesh -# @authors Adrien Crovato +## Compute the flow around a NACA 0012 on a deformed mesh +# Adrien Crovato +# # Test the mesh deformation process # # CAUTION @@ -99,7 +100,7 @@ def main(): print(ccolors.ANSI_BLUE + 'PySolving...' + ccolors.ANSI_RESET) tms['solver1'].start() solver.run() - solver.save(0, gmshWriter) + solver.save(gmshWriter) tms['solver1'].stop() # compute reference solution @@ -107,7 +108,7 @@ def main(): tms['solver_ref'].start() solver_ref = floD.newton(pbl_ref) solver_ref.run() - solver_ref.save(0, gmshWriter_ref) + solver_ref.save(gmshWriter_ref) tms['solver_ref'].stop() # extract Cp diff --git a/flow/tests/meshDef3.py b/flow/tests/meshDef3.py index 1997450e..cbfab276 100644 --- a/flow/tests/meshDef3.py +++ b/flow/tests/meshDef3.py @@ -16,8 +16,9 @@ # limitations under the License. -# @brief Compute the flow on a deformed mesh -# @authors Adrien Crovato +## Compute the flow around a NACA 0012 wing on a deformed mesh +# Adrien Crovato +# # Test the mesh deformation process # # CAUTION @@ -102,7 +103,7 @@ def main(): print(ccolors.ANSI_BLUE + 'PySolving...' + ccolors.ANSI_RESET) tms['solver1'].start() solver.run() - solver.save(0, gmshWriter) + solver.save(gmshWriter) tms['solver1'].stop() # display results diff --git a/flow/tests/nonlift.py b/flow/tests/nonlift.py index d9fd64eb..db228273 100644 --- a/flow/tests/nonlift.py +++ b/flow/tests/nonlift.py @@ -16,8 +16,9 @@ # limitations under the License. -# @brief Compute non-lifting (linear or nonlinear) potential flow around a naca0012 -# @authors Adrien Crovato +## Compute non-lifting (linear or nonlinear) potential flow around a NACA 0012 +# Adrien Crovato +# # Test the nonlinear shock-capturing capability # # CAUTION @@ -62,7 +63,7 @@ def main(): tms['solver'].start() solver = floD.newton(pbl) solver.run() - solver.save(0, gmshWriter) + solver.save(gmshWriter) tms['solver'].stop() # extract Cp diff --git a/flow/utils.py b/flow/utils.py index f0e0a099..359c7cc9 100644 --- a/flow/utils.py +++ b/flow/utils.py @@ -16,17 +16,14 @@ # limitations under the License. -"""@package docstring -Utilities for flow -Adrien Crovato -""" +## Utilities for flow +# Adrien Crovato def computeAeroCoef(_x, _y, _Cp, _alpha): - """Compute 2D aerodynamic coefficients + '''Compute 2D aerodynamic coefficients The coefficients are computed from Cp averaged at nodes, which might leads to innacurate results For accurate results, use coefficients from solver or boundary objects - Adrien Crovato - """ + ''' import math i = 0 Cy = 0 @@ -44,9 +41,8 @@ def computeAeroCoef(_x, _y, _Cp, _alpha): return (Cl, Cd, Cm) def convex_sort(vNodes, vData): - """Sort point cloud data forming a convex hull in counterclowise order, from TE - Adrien Crovato - """ + '''Sort point cloud data forming a convex hull in counterclowise order, from TE + ''' import numpy as np # store map in arrays data = np.zeros((vNodes.size(),4)) @@ -76,9 +72,8 @@ def convex_sort(vNodes, vData): return data def extract(vElems, vData): - """Extract data at first node of elements - Adrien Crovato - """ + '''Extract data at first node of elements + ''' import numpy as np data = np.zeros((vElems.size()+1,4)) i = 0 @@ -90,10 +85,9 @@ def extract(vElems, vData): i += 1 return data -def writeSlices(mshName, ys, wId): - """Write slice data for each ys coordinate along the span (only works with VTK) - Adrien Crovato - """ +def writeSlices(mshName, ys, wId, n = 0): + '''Write slice data for each ys coordinate along the span (only works with VTK) + ''' import numpy as np try: import vtk @@ -103,7 +97,10 @@ def writeSlices(mshName, ys, wId): import tboxVtk.reader as vtkR import tboxVtk.cutter as vtkC reader = vtkR.Reader() - reader.open(mshName) + if n == 0: + reader.open(mshName) + else: + reader.open(mshName+'_'+str(n)) cutter = vtkC.Cutter(reader.reader.GetOutputPort()) for i in range(0, len(ys)): pts, elems, vals = cutter.extract(cutter.cut(wId, [0., ys[i], 0.], [0., 1., 0.]), 2, ['Cp']) @@ -113,4 +110,7 @@ def writeSlices(mshName, ys, wId): data = np.hstack((data, vals['Cp'])) tU.sort(elems, data) data = np.vstack((data, data[0,:])) - tU.write(data, 'slice_'+str(i)+'.dat', "%1.5e", ", ", "x, y, z, x/c, Cp", "") + if n == 0: + tU.write(data, 'slice_'+str(i)+'.dat', '%1.5e', ', ', 'x, y, z, x/c, Cp', '') + else: + tU.write(data, 'slice_'+str(n)+'_'+str(i)+'.dat', '%1.5e', ', ', 'x, y, z, x/c, Cp', '') diff --git a/flow/validation/agard.py b/flow/validation/agard.py index 2a8d488a..6fd48c46 100644 --- a/flow/validation/agard.py +++ b/flow/validation/agard.py @@ -16,8 +16,8 @@ # limitations under the License. -# @brief Compute flow around the Agard445 wing at 1 degrees AOA and Mach 0.80 -# @authors Adrien Crovato +## Compute flow around the Agard 445 wing at 1 degrees AOA and Mach 0.80 +# Adrien Crovato import numpy as np import flow.utils as floU @@ -78,7 +78,7 @@ def main(): tms['solver'].start() solver = floD.newton(pbl) solver.run() - solver.save(0, writer) + solver.save(writer) tms['solver'].stop() # post process diff --git a/flow/validation/onera.py b/flow/validation/onera.py index e53482cb..afedc094 100644 --- a/flow/validation/onera.py +++ b/flow/validation/onera.py @@ -16,8 +16,8 @@ # limitations under the License. -# @brief Compute flow around the Onera M6 wing at 3 degrees AOA and Mach 0.84 -# @authors Adrien Crovato +## Compute flow around the Onera M6 wing at 3 degrees AOA and Mach 0.84 +# Adrien Crovato import numpy as np import flow.utils as floU @@ -76,7 +76,7 @@ def main(): tms['solver'].start() solver = floD.newton(pbl) solver.run() - solver.save(0, writer) + solver.save(writer) tms['solver'].stop() # post process diff --git a/flow/viscous/airfoil.py b/flow/viscous/airfoil.py index 15fc43c7..e76a6093 100644 --- a/flow/viscous/airfoil.py +++ b/flow/viscous/airfoil.py @@ -17,7 +17,6 @@ ## Airfoil around which the boundary layer is computed -# # Amaury Bilocq from flow.viscous.boundary import Boundary @@ -129,4 +128,4 @@ class Airfoil(Boundary): uData = data[0:np.argmax(data[:,0])+1] lData = data[np.argmax(data[:,0])+1:None] lData = np.insert(lData, 0, uData[0,:], axis = 0) #double the stagnation point - return connectListNodes, connectListElems,[uData, lData] \ No newline at end of file + return connectListNodes, connectListElems,[uData, lData] diff --git a/flow/viscous/boundary.py b/flow/viscous/boundary.py index 3a8e862b..773cf7f9 100644 --- a/flow/viscous/boundary.py +++ b/flow/viscous/boundary.py @@ -17,7 +17,6 @@ ## Base class representing a physical boundary -# # Amaury Bilocq import numpy as np diff --git a/flow/viscous/coupler.py b/flow/viscous/coupler.py index 4a672c20..605bc4be 100644 --- a/flow/viscous/coupler.py +++ b/flow/viscous/coupler.py @@ -17,7 +17,6 @@ ## Viscous-inviscid coupler (quasi-simultaneous coupling) -# # Amaury Bilocq import numpy as np @@ -80,6 +79,6 @@ class Coupler: it += 1 self.vsolver.it += 1 # save results - self.isolver.save(0, self.writer) + self.isolver.save(self.writer) self.vsolver.writeFile() - print('\n') \ No newline at end of file + print('\n') diff --git a/flow/viscous/newton.py b/flow/viscous/newton.py index bed39ec6..6c068686 100644 --- a/flow/viscous/newton.py +++ b/flow/viscous/newton.py @@ -17,7 +17,6 @@ ## Newton raphson method coupled with linear solver -# # Amaury Bilocq import numpy as np diff --git a/flow/viscous/solver.py b/flow/viscous/solver.py index 54f97a45..da3a9914 100644 --- a/flow/viscous/solver.py +++ b/flow/viscous/solver.py @@ -17,7 +17,6 @@ ## Integral boundary layer equations viscous solver -# # Amaury Bilocq # # TODO list @@ -475,4 +474,4 @@ class Solver: # Sort the following results in reference frame group.deltaStar = group.deltaStar[group.connectListNodes.argsort()] group.xx = group.xx[group.connectListNodes.argsort()] - group.u = blwVel[group.connectListElems.argsort()] \ No newline at end of file + group.u = blwVel[group.connectListElems.argsort()] diff --git a/flow/viscous/wake.py b/flow/viscous/wake.py index 0f3cd5e5..c925c2ea 100644 --- a/flow/viscous/wake.py +++ b/flow/viscous/wake.py @@ -17,7 +17,6 @@ ## Wake behind airfoil (around which the boundary layer is computed) -# # Amaury Bilocq from flow.viscous.boundary import Boundary @@ -76,4 +75,4 @@ class Wake(Boundary): data[:,9] = data[connectListNodes,9] # Separated upper and lower part data = np.delete(data,0,1) - return connectListNodes, connectListElems, data \ No newline at end of file + return connectListNodes, connectListElems, data -- GitLab