@@ -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 ('\n Performing 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 ('\n Performing 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 ' )
0 commit comments