Skip to content

Commit 4ecf3ea

Browse files
author
Nicola-Fonzi
committed
Fixes as suggested by reviewers
1 parent 0cf08d4 commit 4ecf3ea

2 files changed

Lines changed: 75 additions & 73 deletions

File tree

SU2_PY/FSI_tools/FSIInterface.py

Lines changed: 62 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -2129,72 +2129,72 @@ def SteadyFSI(self, FSI_config,FluidSolver, SolidSolver):
21292129
self.MPIPrint(' ')
21302130

21312131
def MapModes(self, FSI_config, FluidSolver, SolidSolver):
2132-
"""
2133-
Runs nothing, just extract the structural modes mapped on the fluid mesh
2134-
"""
2135-
2136-
if self.have_MPI:
2137-
myid = self.comm.Get_rank()
2138-
numberPart = self.comm.Get_size()
2139-
else:
2140-
myid = 0
2141-
numberPart = 1
2142-
2143-
nodeNormals = {}
2144-
for iVertex in range(self.nLocalFluidInterfaceNodes):
2145-
nx, ny, nz = FluidSolver.GetVertexNormal(self.fluidInterfaceIdentifier, iVertex, False)
2146-
GlobalIndex = FluidSolver.GetVertexGlobalIndex(self.fluidInterfaceIdentifier, iVertex)
2147-
nodeNormals[GlobalIndex] = [nx, ny, nz]
2148-
2149-
nodeNormals = self.comm.gather(nodeNormals, root=self.rootProcess)
2150-
if myid == self.rootProcess:
2151-
normalsToPrint = {}
2152-
for iDictionary in range(numberPart):
2153-
for key, value in nodeNormals[iDictionary].items():
2154-
normalsToPrint[key] = value
2155-
normalsToPrint = dict(sorted(normalsToPrint.items()))
2156-
with open('Normals.csv', 'w') as f:
2157-
writer = csv.writer(f)
2158-
for key, value in normalsToPrint.items():
2159-
writer.writerow([key, value])
2160-
2161-
2162-
SurfaceFileName = FluidSolver.GetSurfaceFileName()
2132+
"""
2133+
Runs nothing, just extract the structural modes mapped on the fluid mesh
2134+
"""
21632135

2164-
self.MPIPrint('\n********************************')
2165-
self.MPIPrint('* Begin mapping the modes *')
2166-
self.MPIPrint('********************************\n')
2167-
self.MPIPrint("\n")
2136+
if self.have_MPI:
2137+
myid = self.comm.Get_rank()
2138+
numberPart = self.comm.Get_size()
2139+
else:
2140+
myid = 0
2141+
numberPart = 1
21682142

2169-
if myid == self.rootProcess: # The root process contains the solid solver for sure
2170-
modesNumber = np.array(int(SolidSolver.getNumberOfModes()))
2171-
else:
2172-
modesNumber = np.empty(1, dtype=np.int)
2143+
nodeNormals = {}
2144+
for iVertex in range(self.nLocalFluidInterfaceNodes):
2145+
nx, ny, nz = FluidSolver.GetVertexNormal(self.fluidInterfaceIdentifier, iVertex, False)
2146+
GlobalIndex = FluidSolver.GetVertexGlobalIndex(self.fluidInterfaceIdentifier, iVertex)
2147+
nodeNormals[GlobalIndex] = [nx, ny, nz]
21732148

2174-
self.comm.Bcast(modesNumber, root=self.rootProcess)
2149+
nodeNormals = self.comm.gather(nodeNormals, root=self.rootProcess)
2150+
if myid == self.rootProcess:
2151+
normalsToPrint = {}
2152+
for iDictionary in range(numberPart):
2153+
for key, value in nodeNormals[iDictionary].items():
2154+
normalsToPrint[key] = value
2155+
normalsToPrint = dict(sorted(normalsToPrint.items()))
2156+
with open('Normals.csv', 'w') as f:
2157+
writer = csv.writer(f)
2158+
for key, value in normalsToPrint.items():
2159+
writer.writerow([key, value])
2160+
2161+
2162+
SurfaceFileName = FluidSolver.GetSurfaceFileName()
2163+
2164+
self.MPIPrint('\n********************************')
2165+
self.MPIPrint('* Begin mapping the modes *')
2166+
self.MPIPrint('********************************\n')
2167+
self.MPIPrint("\n")
2168+
2169+
if myid == self.rootProcess: # The root process contains the solid solver for sure
2170+
modesNumber = np.array(int(SolidSolver.getNumberOfModes()))
2171+
else:
2172+
modesNumber = np.empty(1, dtype=np.int)
21752173

2176-
for mode in range(np.asscalar(modesNumber)):
2177-
self.MPIPrint("Setting mode {} active".format(mode))
2178-
if myid in self.solidSolverProcessors:
2179-
SolidSolver.activateMode(mode)
2180-
self.MPIBarrier()
2181-
self.getSolidInterfaceDisplacement(SolidSolver)
2182-
self.interpolateSolidPositionOnFluidMesh(FSI_config)
2183-
self.setFluidInterfaceVarCoord(FluidSolver)
2174+
self.comm.Bcast(modesNumber, root=self.rootProcess)
21842175

2185-
self.MPIPrint('\nPerforming mesh deformation...\n')
2186-
FluidSolver.DynamicMeshUpdate(0)
2187-
FluidSolver.Output(0)
2188-
self.MPIBarrier()
2176+
for mode in range(np.asscalar(modesNumber)):
2177+
self.MPIPrint("Setting mode {} active".format(mode))
2178+
if myid in self.solidSolverProcessors:
2179+
SolidSolver.activateMode(mode)
2180+
self.MPIBarrier()
2181+
self.getSolidInterfaceDisplacement(SolidSolver)
2182+
self.interpolateSolidPositionOnFluidMesh(FSI_config)
2183+
self.setFluidInterfaceVarCoord(FluidSolver)
21892184

2190-
if myid == self.rootProcess:
2191-
AllFiles = os.listdir()
2192-
for FileNumber,FileName in enumerate(AllFiles):
2193-
if SurfaceFileName in FileName:
2194-
file = FileName.split(".")[0]
2195-
extension = FileName.split(".")[1]
2196-
os.rename(file+"."+extension,"Mode{}.".format(mode)+extension)
2185+
self.MPIPrint('\nPerforming mesh deformation...\n')
2186+
FluidSolver.DynamicMeshUpdate(0)
2187+
FluidSolver.Output(0)
2188+
self.MPIBarrier()
21972189

2198-
self.MPIPrint('\n*************************')
2199-
self.MPIPrint('* Mapping completed *')
2200-
self.MPIPrint('*************************\n')
2190+
if myid == self.rootProcess:
2191+
AllFiles = os.listdir()
2192+
for FileNumber,FileName in enumerate(AllFiles):
2193+
if SurfaceFileName in FileName:
2194+
file = FileName.split(".")[0]
2195+
extension = FileName.split(".")[1]
2196+
os.rename(file+"."+extension,"Mode{}.".format(mode)+extension)
2197+
2198+
self.MPIPrint('\n*************************')
2199+
self.MPIPrint('* Mapping completed *')
2200+
self.MPIPrint('*************************\n')

SU2_PY/SU2_Nastran/pysu2_nastran.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,7 @@ def __checkBlankField(self, string):
509509
This method considers that Nastran apply 0 when the reference system is not specified
510510
"""
511511

512-
if string == ' ':
512+
if string == ' '*8:
513513
return int(0)
514514
return int(string)
515515

@@ -932,12 +932,13 @@ def run(self,time):
932932
self.__computeInterfacePosVel(False)
933933

934934
def activateMode(self, iMode):
935-
""" This method is used to artificially set only one mode activated, thus
936-
with non zero amplitude.
937-
"""
938-
self.__reset(self.q)
939-
self.q[iMode] = 1.0
940-
self.__computeInterfacePosVel(True)
935+
"""
936+
This method is used to artificially set only one mode activated, thus
937+
with non zero amplitude.
938+
"""
939+
self.__reset(self.q)
940+
self.q[iMode] = 1.0
941+
self.__computeInterfacePosVel(True)
941942

942943
def setInitialDisplacements(self):
943944
"""
@@ -987,10 +988,11 @@ def applyload(self, iVertex, fx, fy, fz):
987988
self.node[iPoint].SetForce((fx,fy,fz))
988989

989990
def getNumberOfModes(self):
990-
""" This method provides the number of degrees of freedom used in
991-
the structural solver.
992-
"""
993-
return self.nDof
991+
"""
992+
This method provides the number of degrees of freedom used in
993+
the structural solver.
994+
"""
995+
return self.nDof
994996

995997
def getFSIMarkerID(self):
996998
"""

0 commit comments

Comments
 (0)