Skip to content
Snippets Groups Projects
Verified Commit 4016f192 authored by Paul Dechamps's avatar Paul Dechamps :speech_balloon:
Browse files

(feat) Automatically detect mesh file for su2

parent 1c93bf71
No related branches found
No related tags found
No related merge requests found
Pipeline #52848 failed
......@@ -27,6 +27,7 @@ import pysu2
class SU2Interface(SolversInterface):
def __init__(self, su2config, vconfig, task='analysis'):
self.filename = su2config.get('filename')
self._modify_meshpath(self.filename, su2config.get('meshfile'))
self.verbose = su2config.get('Verb', 0)
self.have_mpi, self.comm, self.status, self.myid = self.__setup_mpi()
self.solver = pysu2.CSinglezoneDriver(self.filename, 1, self.comm)
......@@ -344,3 +345,17 @@ class SU2Interface(SolversInterface):
self.iBnd[ibody][0].elemsCoord = elemsCoord
self.iBnd[ibody][0].setConnectList(np.array(nodesCoord[:,-1],dtype=int),
np.array(elemsCoord[:,-1],dtype=int))
def _modify_meshpath(self, config, mesh):
# Open config file and look for line MESH_FILENAME
# replace this line with MESH_FILENAME = mesh
with open(config, 'r') as f:
lines = f.readlines()
for i, line in enumerate(lines):
if line.startswith('MESH_FILENAME'):
lines[i] = f'MESH_FILENAME = {mesh}\n'
with open(config, 'w') as f:
f.writelines(lines)
break
else:
raise RuntimeError('su2Interface::MESH_FILENAME not found in config file.')
source diff could not be displayed: it is too large. Options to address this: view the blob.
source diff could not be displayed: it is too large. Options to address this: view the blob.
......@@ -28,6 +28,7 @@ def cfgSu2(verb):
import os
return {
'filename' : os.path.abspath(os.path.join(os.path.split(os.path.abspath(__file__))[0], "config.cfg")),
'meshfile': os.path.abspath(os.path.join(os.path.split(os.path.abspath(__file__))[0], "../../models/su2/n0012_su2.su2")),
'wingTags' : ['airfoil', 'airfoil_'],
'Verb': verb, # Verbosity level
}
......@@ -36,7 +37,7 @@ def cfgBlast():
return {
'Re' : 1e7, # Freestream Reynolds number
'CFL0' : 2, # Inital CFL number of the calculation
'couplIter': 10, # Maximum number of iterations
'couplIter': 2, # Maximum number of iterations
'sections': {'airfoil': [0.0]},
'spans': {'airfoil': 1.0},
'couplTol' : 1e-4, # Tolerance of the VII methodology
......
......@@ -184,7 +184,7 @@ SCREEN_WRT_FREQ_INNER= 50
VOLUME_OUTPUT = SOLUTION, PRIMITIVE, RMS_DENSITY
% Mesh input file
MESH_FILENAME= /Users/pauldechamps/lab/softwares/blasterdev/blast/models/su2/n0012_su2_2.su2
MESH_FILENAME = path/to/mesh.su2
%
% Mesh input file format (SU2, CGNS, NETCDF_ASCII)
MESH_FORMAT= SU2
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment