2727
2828import sys
2929import pysu2
30- from mpi4py import MPI
3130import numpy as np
3231
3332# with mpi:
@@ -77,9 +76,7 @@ def initC(coord):
7776def SetInitialSpecies (SU2Driver ):
7877 allCoords = SU2Driver .Coordinates ()
7978 iSPECIESSOLVER = SU2Driver .GetSolverIndices ()['SPECIES' ]
80- print ("index of species solver = " ,iSPECIESSOLVER )
8179 nVarsSpecies = SU2Driver .GetNumberSolverVars (iSPECIESSOLVER )
82- print ("number of species solver variables:" ,nVarsSpecies )
8380 for iPoint in range (SU2Driver .GetNumberNodes () - SU2Driver .GetNumberHaloNodes ()):
8481 coord = allCoords .Get (iPoint )
8582 C = initC (coord )
@@ -168,7 +165,6 @@ def main():
168165 sys .stdout .flush ()
169166
170167 nDim = driver .GetNumberDimensions ()
171- print ("Dimensions of the problem = " ,nDim )
172168
173169 # index to the flow solver
174170 # C.FLOW
@@ -179,69 +175,65 @@ def main():
179175 # SA
180176 # SST
181177 iFLOWSOLVER = driver .GetSolverIndices ()['INC.FLOW' ]
182- print ("index of flow solver = " ,iFLOWSOLVER )
183178 iSPECIESSOLVER = driver .GetSolverIndices ()['SPECIES' ]
184- print ("index of species solver = " ,iSPECIESSOLVER )
185179 iSSTSOLVER = driver .GetSolverIndices ()['SST' ]
186- print ("index of turbulence solver = " ,iSSTSOLVER )
187-
188180 # all the indices and the map to the names of the primitives
189181 primindex = driver .GetPrimitiveIndices ()
190- print ("indices of primitives=" ,primindex )
191- print ("number of primitives:" ,len (primindex ))
192-
193182 nElem = driver .GetNumberElements ()
194- print ("number of elements:" ,nElem )
195-
196183 nVars = driver .GetNumberSolverVars (iFLOWSOLVER )
197- print ("number of flow solver variables:" ,nVars )
198-
199184 nVarsSpecies = driver .GetNumberSolverVars (iSPECIESSOLVER )
200- print ("number of species solver variables:" ,nVarsSpecies )
201185 nVarsTurb = driver .GetNumberSolverVars (iSSTSOLVER )
202- print ("number of turbulence solver variables:" ,nVarsTurb )
186+
187+ if rank == 0 :
188+ print ("Dimensions of the problem = " ,nDim )
189+ print ("index of flow solver = " ,iFLOWSOLVER )
190+ print ("index of turbulence solver = " ,iSSTSOLVER )
191+ print ("indices of primitives=" ,primindex )
192+ print ("number of primitives:" ,len (primindex ))
193+ print ("number of elements:" ,nElem )
194+ print ("number of flow solver variables:" ,nVars )
195+ print ("number of species solver variables:" ,nVarsSpecies )
196+ print ("number of turbulence solver variables:" ,nVarsTurb )
197+ sys .stdout .flush ()
198+
199+
203200
204201 # ### Check if we do a restart or not. ###
205202 with open ('psi.cfg' ) as f :
206203 if 'RESTART_SOL= YES' in f .read ():
204+ if rank == 0 :
207205 print ("restarting from file" )
208206 else :
209207 # We can set an initial condition by calling this function:
210- print ("Start calling SetInitialSpecies" )
208+ if rank == 0 :
209+ print ("Using user defined initial condition." )
211210 SetInitialSpecies (driver )
212- print ("End calling SetInitialSpecies" )
213211
214212 # super important to actually push the commands.
215213 sys .stdout .flush ()
216214
217215 # run N iterations
218- for inner_iter in range (1000 ):
216+ for inner_iter in range (2 ):
219217 if (rank == 0 ):
220218 print ("python iteration " , inner_iter )
221219 driver .Preprocess (inner_iter )
222220 driver .Run ()
223221
224- # set the source term, per point,
222+ # set the source term, per point
225223 for i_node in range (driver .GetNumberNodes () - driver .GetNumberHaloNodes ()):
226224 # add source term:
227225 # default TFC of Zimont: rho*Sc = rho_u * U_t * grad(c)
228226 S = zimont (driver ,i_node )
229227 driver .UserDefinedSource (iSPECIESSOLVER ).Set (i_node ,0 ,S )
230228
231-
232- #S = [zimont(driver,i_node)]
233- #driver.SetPointCustomSource(iSPECIESSOLVER, i_node,S)
234-
235-
236-
237229 # for the update of temperature, we need to update also the halo nodes
238230 for i_node in range (driver .GetNumberNodes ()):
239231 # set the temperature to T = c*Tf + (1-c)*Tu
240232 update_temperature (driver , i_node )
241233
242234 driver .Postprocess ()
243235 driver .Update ()
244- # Monitor the solver and output solution to file if required
236+ # Monitor the solver and output solution to file if required.
245237 #driver.Monitor(inner_iter)
246238 # Output the solution to file
247239 driver .Output (inner_iter )
0 commit comments