Exemple #1
0
 def touch(self, file_path):
     if not os.path.isabs(file_path):
         file_path = os.path.join(self.current_folder.path, file_path)
     if os.path.exists(file_path):
         print("Already exists")
     else:
         file = FSI.File(file_path)
         file.create()
     print()
Exemple #2
0
 def cd(self, dir):
     if not os.path.isabs(dir):
         dir = os.path.join(self.current_folder.path, dir)
     if dir == '.':
         return
     if os.path.exists(dir) and os.path.isdir(dir):
         self.current_folder = FSI.Directory(dir)
     else:
         print("There is no such directory")
     print()
Exemple #3
0
 def __init__(self):
     self.current_folder = FSI.Directory('.')
     os.system('cls')
     print("What is your name?")
     s = input()
     while len(s.split()) > 1:
         print("Must be one word")
         s = input()
     os.system('cls')
     print("This is Bioinformatics shell. \nType \"exit\" to quit")
     self.user = s
     self.prefix = ''
     self.stop = False
     self.current_command = None
     print()
Exemple #4
0
def main():

  # --- Get the FSI conig file name form the command line options --- #
  parser=OptionParser()
  parser.add_option("-f", "--file",       dest="filename",
                      help="read config from FILE", metavar="FILE")
  parser.add_option("--parallel", action="store_true",
                      help="Specify if we need to initialize MPI", dest="with_MPI", default=False)

  (options, args)=parser.parse_args()

  if options.with_MPI == True:
    from mpi4py import MPI  # MPI is initialized from now by python and can be continued in C++ !
    comm = MPI.COMM_WORLD
    myid = comm.Get_rank()
    numberPart = comm.Get_size()
    have_MPI = True
  else:
    comm = 0
    myid = 0
    numberPart = 1
    have_MPI = False

  rootProcess = 0

  # --- Set the working directory --- #
  if myid == rootProcess:
      if os.getcwd() not in sys.path:
          sys.path.append(os.getcwd())
	  print("Setting working directory : {}".format(os.getcwd()))
      else: 
	  print ("Working directory is set to {}".format(os.getcwd()))

  # starts timer
  start = timer.time()

  confFile = str(options.filename)

  FSI_config = FSI.io.FSIConfig(confFile) 		# FSI configuration file
  CFD_ConFile = FSI_config['CFD_CONFIG_FILE_NAME']	# CFD configuration file
  CSD_ConFile = FSI_config['CSD_CONFIG_FILE_NAME']	# CSD configuration file

  CSD_Solver = FSI_config['CSD_SOLVER']			# CSD solver

  if have_MPI == True:
    comm.barrier()

  # --- Initialize the fluid solver --- #
  if myid == rootProcess:
    print('\n***************************** Initializing fluid solver *****************************')
  try:
    FluidSolver = pysu2.CFluidDriver(CFD_ConFile, 1, FSI_config['NDIM'], comm)
  except TypeError as exception:
    print('A TypeError occured in pysu2.CSingleZoneDriver : ',exception)
    if have_MPI == True:
      print('ERROR : You are trying to initialize MPI with a serial build of the wrapper. Please, remove the --parallel option that is incompatible with a serial build.')
    else:
      print('ERROR : You are trying to launch a computation without initializing MPI but the wrapper has been built in parallel. Please add the --parallel option in order to initialize MPI for the wrapper.')
    return

  if have_MPI == True:
    comm.barrier()
  
  # --- Initialize the solid solver --- # (!! for now we are using only serial solid solvers)
  if myid == rootProcess:
    print('\n***************************** Initializing solid solver *****************************')
    if CSD_Solver == 'METAFOR':
      from MetaforSolver import MtfSolver
      SolidSolver = MtfSolver(CSD_ConFile)
    elif CSD_Solver == 'NATIVE':
      import NativeSolid
      SolidSolver = NativeSolid.NativeSolidSolver(CSD_ConFile, True)
    elif CSD_Solver == 'GETDP':
      import GetDPSolver
      SolidSolver = GetDPSolver.GetDPSolver(CSD_ConFile, True)
    elif CSD_Solver == 'TESTER':
      SolidSolver = FSI.PitchPlungeAirfoilStructuralTester.Solver(CSD_ConFile)
  else:
    SolidSolver = None

  if have_MPI == True:
    comm.barrier()

  # --- Initialize and set the FSI interface (coupling environement) --- #
  if myid == rootProcess:
    print('\n***************************** Initializing FSI interface *****************************')
  if have_MPI == True:
    comm.barrier()
  FSIInterface = FSI.Interface(FSI_config, FluidSolver, SolidSolver, have_MPI)
  
  if myid == rootProcess:
    print('\n***************************** Connect fluid and solid solvers *****************************')
  if have_MPI == True:
    comm.barrier()
  FSIInterface.connect(FSI_config, FluidSolver, SolidSolver)

  if myid == rootProcess:
    print('\n***************************** Mapping fluid-solid interfaces *****************************')
  if have_MPI == True:
    comm.barrier()
  FSIInterface.interfaceMapping(FluidSolver, SolidSolver, FSI_config)
 
  if have_MPI == True: 
    comm.barrier()

  # --- Launch a steady or unsteady FSI computation --- #
  if FSI_config['UNSTEADY_SIMULATION'] == "YES":
    try:
      FSIInterface.UnsteadyFSI(FSI_config, FluidSolver, SolidSolver)
    except NameError as exception:
      if myid == rootProcess:
        print('An NameError occured in FSIInterface.UnsteadyFSI : ',exception)
    except TypeError as exception:
      if myid == rootProcess:
        print('A TypeError occured in FSIInterface.UnsteadyFSI : ',exception)
    except KeyboardInterrupt as exception :
      if myid == rootProcess:
        print('A KeyboardInterrupt occured in FSIInterface.UnsteadyFSI : ',exception)
  else:
    try:
      NbExtIter = FSI_config['NB_EXT_ITER']
      FSIInterface.SteadyFSI(FSI_config, FluidSolver, SolidSolver)
    except NameError as exception:
      if myid == rootProcess:
        print('An NameError occured in FSIInterface.SteadyFSI : ',exception)
    except TypeError as exception:
      if myid == rootProcess:
        print('A TypeError occured in FSIInterface.SteadyFSI : ',exception)
    except KeyboardInterrupt as exception :
      if myid == rootProcess:
        print('A KeyboardInterrupt occured in FSIInterface.SteadyFSI : ',exception)
  
  if have_MPI == True:
    comm.barrier()

  # --- Exit cleanly the fluid and solid solvers --- #
  FluidSolver.Postprocessing()
  if myid == rootProcess:
      SolidSolver.exit()

  if have_MPI == True:
    comm.barrier()

  # stops timer
  stop = timer.time()
  elapsedTime = stop-start
  
  if myid == rootProcess:
    print("\n Computation successfully performed in {} seconds.".format(elapsedTime))

  return