From 9256de54e2f820235074f21905c686e4e446a0b4 Mon Sep 17 00:00:00 2001 From: acrovato <a.crovato@uliege.be> Date: Mon, 16 May 2022 15:20:55 +0200 Subject: [PATCH] Adapt API to new MshCrack/Deform --- dart/api/core.py | 28 +++++++++++++++++----------- dart/default.py | 12 +++++++----- dart/tests/adjoint.py | 2 +- dart/tests/morpher.py | 2 +- dart/tests/rae_25.py | 2 +- dart/tests/rae_3.py | 2 +- dart/validation/agard.py | 2 +- dart/validation/onera.py | 2 +- ext/amfe | 2 +- 9 files changed, 31 insertions(+), 23 deletions(-) diff --git a/dart/api/core.py b/dart/api/core.py index af1922a..8359e35 100644 --- a/dart/api/core.py +++ b/dart/api/core.py @@ -122,17 +122,21 @@ def initDart(cfg, scenario='aerodynamic', task='analysis'): if _dim == 2: mshCrck = tbox.MshCrack(_msh, _dim) mshCrck.setCrack(cfg['Wake']) - mshCrck.addBoundaries([cfg['Fluid'], cfg['Farfield'][-1], cfg['Wing']]) + mshCrck.addBoundary(cfg['Fluid']) + mshCrck.addBoundary(cfg['Farfield'][-1]) + mshCrck.addBoundary(cfg['Wing']) mshCrck.run() else: for i in range(len(cfg['Wakes'])): mshCrck = tbox.MshCrack(_msh, _dim) mshCrck.setCrack(cfg['Wakes'][i]) - mshCrck.addBoundaries([cfg['Fluid'], cfg['Farfield'][-1], cfg['Wings'][i]]) + mshCrck.addBoundary(cfg['Fluid']) + mshCrck.addBoundary(cfg['Farfield'][-1]) + mshCrck.addBoundary(cfg['Wings'][i]) if 'Fuselage' in cfg: - mshCrck.addBoundaries([cfg['Fuselage']]) + mshCrck.addBoundary(cfg['Fuselage']) if 'Symmetry' in cfg: - mshCrck.addBoundaries([cfg['Symmetry']]) + mshCrck.addBoundary(cfg['Symmetry']) if 'WakeTips' in cfg: mshCrck.setExcluded(cfg['WakeTips'][i]) # 3D computations (not excluded for 2.5D) mshCrck.run() @@ -146,20 +150,22 @@ def initDart(cfg, scenario='aerodynamic', task='analysis'): if scenario == 'aerostructural' or task == 'optimization': _mrf = tbox.MshDeform(_msh, tbox.Gmres(1, 1e-6, 30, 1e-8), _dim, nthrds=nthrd, vrb=verb) _mrf.setField(cfg['Fluid']) - _mrf.addFixed(cfg['Farfield']) + for tag in cfg['Farfield']: + _mrf.addFixed(tag) if _dim == 2: - _mrf.addMoving([cfg['Wing']]) - _mrf.addInternal([cfg['Wake'], cfg['Wake']+'_']) + _mrf.addMoving(cfg['Wing']) + _mrf.addInternal(cfg['Wake'], cfg['Wake']+'_') else: if 'Fuselage' in cfg: _mrf.addFixed(cfg['Fuselage']) - _mrf.setSymmetry(cfg['Symmetry'], 1) + if 'Symmetry' in cfg: + _mrf.setSymmetry(cfg['Symmetry'], 1) for i in range(len(cfg['Wings'])): if i == 0: - _mrf.addMoving([cfg['Wings'][i]]) # TODO body of interest (FSI/OPT) is always first given body + _mrf.addMoving(cfg['Wings'][i]) # TODO body of interest (FSI/OPT) is always first given body else: - _mrf.addFixed([cfg['Wings'][i]]) - _mrf.addInternal([cfg['Wakes'][i], cfg['Wakes'][i]+'_']) + _mrf.addFixed(cfg['Wings'][i]) + _mrf.addInternal(cfg['Wakes'][i], cfg['Wakes'][i]+'_') _mrf.initialize() else: _mrf = None diff --git a/dart/default.py b/dart/default.py index ba0be48..2a05db4 100644 --- a/dart/default.py +++ b/dart/default.py @@ -23,7 +23,7 @@ from fwk.wutils import parseargs import dart import tbox -def mesh(dim, file, pars, bnd, wk = 'wake', wktp = None): +def mesh(dim, file, pars, bnds, wk = 'wake', wktp = None): """Initialize mesh and mesh writer Parameters @@ -34,7 +34,7 @@ def mesh(dim, file, pars, bnd, wk = 'wake', wktp = None): file contaning mesh (w/o extention) pars : dict parameters for mesh - bnd : array of str + bnds : array of str names of crack (wake) boundaries physical tag wk : str (optional) name of crack (wake) physical tag @@ -47,7 +47,8 @@ def mesh(dim, file, pars, bnd, wk = 'wake', wktp = None): # crack the mesh mshCrck = tbox.MshCrack(msh, dim) mshCrck.setCrack(wk) - mshCrck.addBoundaries(bnd) + for bnd in bnds: + mshCrck.addBoundary(bnd) if dim == 3 and wktp is not None: mshCrck.setExcluded(wktp) mshCrck.run() @@ -189,11 +190,12 @@ def morpher(msh, dim, mov, fxd = ['upstream', 'farfield', 'downstream'], fld = ' args = parseargs() mshDef = tbox.MshDeform(msh, tbox.Gmres(1, 1e-6, 30, 1e-8), dim, nthrds=args.k) mshDef.setField(fld) - mshDef.addFixed(fxd) + for tag in fxd: + mshDef.addFixed(tag) mshDef.addMoving(mov) if dim == 3: mshDef.setSymmetry(sym, 1) - mshDef.addInternal([wk, wk+'_']) + mshDef.addInternal(wk, wk+'_') mshDef.initialize() return mshDef diff --git a/dart/tests/adjoint.py b/dart/tests/adjoint.py index f2ed009..df03af2 100644 --- a/dart/tests/adjoint.py +++ b/dart/tests/adjoint.py @@ -50,7 +50,7 @@ def main(): pars = {'xLgt' : 5, 'yLgt' : 5, 'msF' : 1., 'msTe' : 0.0075, 'msLe' : 0.0075} msh, gmshWriter = floD.mesh(dim, 'models/n0012.geo', pars, ['field', 'airfoil', 'downstream']) # create mesh deformation handler - morpher = floD.morpher(msh, dim, ['airfoil']) + morpher = floD.morpher(msh, dim, 'airfoil') tms['msh'].stop() # set the problem and add fluid, initial/boundary conditions diff --git a/dart/tests/morpher.py b/dart/tests/morpher.py index 63c9b47..5bca5c1 100644 --- a/dart/tests/morpher.py +++ b/dart/tests/morpher.py @@ -55,7 +55,7 @@ def main(): pars = {'xLgt' : 5, 'yLgt' : 5, 'msF' : 1., 'msTe' : 0.01, 'msLe' : 0.01} msh, gmshWriter = floD.mesh(dim, 'models/n0012.geo', pars, ['field', 'airfoil', 'downstream']) # create mesh deformation handler - morpher = floD.morpher(msh, dim, ['airfoil']) + morpher = floD.morpher(msh, dim, 'airfoil') # mesh the reference geometry pars = {'xLgt' : 5, 'yLgt' : 5, 'msF' : 1., 'msTe' : 0.01, 'msLe' : 0.01, 'angle' : alfa, 'xRot' : xc} msh_ref, gmshWriter_ref = floD.mesh(dim, 'models/n0012.geo', pars, ['field', 'airfoil', 'downstream']) diff --git a/dart/tests/rae_25.py b/dart/tests/rae_25.py index 33a83b4..95ab324 100644 --- a/dart/tests/rae_25.py +++ b/dart/tests/rae_25.py @@ -56,7 +56,7 @@ def main(): tms["msh"].start() pars = {'spn' : spn, 'lgt' : lgt, 'wdt' : wdt, 'hgt' : hgt, 'msN' : nms, 'msF' : fms} msh, gmshWriter = floD.mesh(dim, 'models/rae_25.geo', pars, ['field', 'wing', 'symmetry', 'downstream']) - morpher = floD.morpher(msh, dim, ['wing']) + morpher = floD.morpher(msh, dim, 'wing') tms["msh"].stop() # set the problem and add fluid, initial/boundary conditions diff --git a/dart/tests/rae_3.py b/dart/tests/rae_3.py index 7bb85ba..72097ac 100644 --- a/dart/tests/rae_3.py +++ b/dart/tests/rae_3.py @@ -61,7 +61,7 @@ def main(): tms["msh"].start() pars = {'spn' : spn, 'lgt' : lgt, 'wdt' : wdt, 'hgt' : hgt, 'msN' : nms, 'msF' : fms} msh, gmshWriter = floD.mesh(dim, 'models/rae_3.geo', pars, ['field', 'wing', 'symmetry', 'downstream'], wktp = 'wakeTip') - morpher = floD.morpher(msh, dim, ['wing']) + morpher = floD.morpher(msh, dim, 'wing') tms["msh"].stop() # set the problem and add fluid, initial/boundary conditions diff --git a/dart/validation/agard.py b/dart/validation/agard.py index fb1fb03..dc18dcb 100644 --- a/dart/validation/agard.py +++ b/dart/validation/agard.py @@ -84,7 +84,7 @@ def main(): tms['post'].start() if canPost: floU.writeSlices(msh.name,[0.01, 0.37, 0.75],5) - data = tbxU.read('slice_1.dat') + data = tbxU.read('agard445_slice_1.dat') tbxU.plot(data[:,3], data[:,4], 'x', 'Cp', 'Pressure distribution at MAC', True) tms['post'].stop() diff --git a/dart/validation/onera.py b/dart/validation/onera.py index 8bb1fad..85f4e67 100644 --- a/dart/validation/onera.py +++ b/dart/validation/onera.py @@ -82,7 +82,7 @@ def main(): tms['post'].start() if canPost: floU.writeSlices(msh.name,[0.01, 0.239, 0.526, 0.777, 0.957, 1.076, 1.136, 1.184],5) - data = tbxU.read('slice_2.dat') + data = tbxU.read('oneraM6_slice_2.dat') tbxU.plot(data[:,3], data[:,4], 'x', 'Cp', 'Pressure distribution at MAC', True) tms['post'].stop() diff --git a/ext/amfe b/ext/amfe index 7dbafd3..7a60afc 160000 --- a/ext/amfe +++ b/ext/amfe @@ -1 +1 @@ -Subproject commit 7dbafd30acd41e369b54962af8a0994af1aa55e8 +Subproject commit 7a60afc9668ac6793c98f76ef79835158769c662 -- GitLab