def main(_p, nogui): # NB, the argument 'nogui' is specific to PFEM only!
    
    p = getParameters(_p)

    # --- Workspace set up --- #
    withMPI = False
    comm = None
    myid = 0
    numberPart = 0
    rootProcess = 0
    
    cupyutil.load(fileName, withMPI, comm, myid, numberPart)
    
    # --- Input parameters --- #
    cfd_file = 'waterColoumnFallWithFlexibleObstacle_water_Pfem_NotMatching'
    csd_file = 'waterColoumnFallWithFlexibleObstacle_obstacle_Mtf_E_1_0e6_NotMatching'
    
    # --- Initialize the fluid solver --- #
    import cupydoInterfaces.PfemInterface
    fluidSolver = cupydoInterfaces.PfemInterface.PfemSolver(cfd_file, 17, p['dt'])
    
    # --- This part is specific to PFEM ---
    fluidSolver.pfem.scheme.nthreads = p['nthreads']
    fluidSolver.pfem.scheme.savefreq = p['saveFreqPFEM']
    if nogui:
        fluidSolver.pfem.gui = None
    # ---
    
    cupyutil.mpiBarrier(comm)
    
    # --- Initialize the solid solver --- #
    solidSolver = None
    if myid == rootProcess:
        import cupydoInterfaces.MtfInterface
        solidSolver = cupydoInterfaces.MtfInterface.MtfSolver(csd_file, p['computationType'])
        
        # --- This part is specific to Metafor ---
        solidSolver.saveAllFacs = p['mtfSaveAllFacs']
        
    cupyutil.mpiBarrier(comm)
        
    # --- Initialize the FSI manager --- #
    manager = cupyman.Manager(fluidSolver, solidSolver, p['nDim'], p['computationType'], comm)
    cupyutil.mpiBarrier()

    # --- Initialize the interpolator --- #
    #interpolator = cupyinterp.MatchingMeshesInterpolator(manager, fluidSolver, solidSolver, comm)
    interpolator = cupyinterp.RBFInterpolator(manager, fluidSolver, solidSolver, p['rbfRadius'], comm)
    #interpolator = cupyinterp.TPSInterpolator(manager, fluidSolver, solidSolver, comm)
    
    # --- Initialize the FSI criterion --- #
    criterion = cupycrit.DispNormCriterion(p['tollFSI'])
    cupyutil.mpiBarrier()
    
    # --- Initialize the FSI algorithm --- #
    algorithm = cupyalgo.AlgorithmBGSAitkenRelax(manager, fluidSolver, solidSolver, interpolator, criterion, p['nFSIIterMax'], p['dt'], p['tTot'], p['timeIterTreshold'], p['omegaMax'], comm)
    
    # --- Launch the FSI computation --- #
    algorithm.run()
Пример #2
0
    def __init__(self, p):
        # --- Set up MPI --- #
        withMPI, comm, myId, numberPart = cupyutil.getMpi()
        rootProcess = 0

        # --- Initialize the fluid and solid solvers --- #
        fluidSolver = self.__initFluid(p, withMPI, comm)
        cupyutil.mpiBarrier(comm)
        solidSolver = self.__initSolid(p, myId)
        cupyutil.mpiBarrier(comm)

        # --- Initialize the FSI manager --- #
        manager = cupyman.Manager(fluidSolver, solidSolver, p['nDim'], p['compType'], comm)
        cupyutil.mpiBarrier()

        # --- Initialize the interpolator --- #
        if p['interpolator'] == 'Matching':
            interpolator = cupyinterp.MatchingMeshesInterpolator(manager, fluidSolver, solidSolver, comm)
        elif p['interpolator'] == 'RBF':
            interpolator = cupyinterp.RBFInterpolator(manager, fluidSolver, solidSolver, p['rbfRadius'], comm)
        elif p['interpolator'] == 'TPS':
            interpolator = cupyinterp.TPSInterpolator(manager, fluidSolver, solidSolver, comm)
        else:
            raise RuntimeError(p['interpolator'], 'not available! (avail: "Matching", "RBF" or "TPS").\n')
        # if petsc is used, then some options can be set
        if withMPI and 'interpOpts' in p:
            for linSolver in interpolator.getLinearSolvers():
                linSolver.setMaxNumberIterations(p['interpOpts'][0])
                linSolver.setPreconditioner(p['interpOpts'][1])

        # --- Initialize the FSI criterion --- #
        if p['algorithm'] == 'Explicit':
            print 'Explicit simulations requested, criterion redefined to None.'
        if p['criterion'] == 'Displacements':
            criterion = cupycrit.DispNormCriterion(p['tol'])
        else:
            raise RuntimeError(p['criterion'], 'not available! (avail: "Displacements").\n')
        cupyutil.mpiBarrier()

        # --- Initialize the FSI algorithm --- #
        if p['algorithm'] == 'Explicit':
            self.algorithm = cupyalgo.AlgorithmExplicit(manager, fluidSolver, solidSolver, interpolator,
                p['dt'], p['tTot'], p['timeItTresh'], comm)
        elif p['algorithm'] == 'StaticBGS':
            self.algorithm = cupyalgo.AlgorithmBGSStaticRelax(manager, fluidSolver, solidSolver, interpolator, criterion,
                p['maxIt'], p['dt'], p['tTot'], p['timeItTresh'], p['omega'], comm)
        elif p['algorithm'] == 'AitkenBGS':
            self.algorithm = cupyalgo.AlgorithmBGSAitkenRelax(manager, fluidSolver, solidSolver, interpolator, criterion,
                p['maxIt'], p['dt'], p['tTot'], p['timeItTresh'], p['omega'], comm)
        elif p ['algorithm'] == 'IQN_ILS':
            self.algorithm = cupyalgo.AlgorithmIQN_ILS(manager, fluidSolver, solidSolver, interpolator, criterion,
                p['maxIt'], p['dt'], p['tTot'], p['timeItTresh'], p['omega'], p['nSteps'], p['firstItTgtMat'], comm)
        else:
            raise RuntimeError(p['algorithm'], 'not available! (avail: "Explicit", "StaticBGS", "AitkenBGS" or "IQN_ILS").\n')
        cupyutil.mpiBarrier()
Пример #3
0
def main(_p, nogui):
    # --- Get FSI parameters ---#
    p = getParameters(_p)

    raise Exception(
        'Test should work but is NOT validated (no reference data). Remove this exception when ready.\n'
    )

    # --- Set up MPI --- #
    withMPI, comm, myid, numberPart = cupyutil.getMpi()
    rootProcess = 0

    # --- Input parameters --- #
    cfd_file = os.path.join(filePath, 'agard_dynamic_fluid.cfg')
    csd_file = 'agard_solid'

    # --- Initialize the fluid solver --- #
    import cupydo.interfaces.SU2 as fItf
    if comm != None:
        fluidSolver = fItf.SU2(cfd_file, p['nZones_SU2'], p['nDim'],
                               p['computationType'], p['nodalLoadsType'],
                               withMPI, comm)
    else:
        fluidSolver = fItf.SU2(cfd_file, p['nZones_SU2'], p['nDim'],
                               p['computationType'], p['nodalLoadsType'],
                               withMPI, 0)
    cupyutil.mpiBarrier(comm)

    # --- Initialize modal interpreter --- #
    solidSolver = None
    if myid == rootProcess:
        import cupydo.interfaces.Modal as sItf
        solidSolver = sItf.ModalInterface(csd_file, p['computationType'])
    cupyutil.mpiBarrier(comm)

    # --- Initialize the FSI manager --- #
    manager = cupyman.Manager(fluidSolver, solidSolver, p['nDim'],
                              p['computationType'], comm)
    cupyutil.mpiBarrier()

    # --- Initialize the interpolator --- #
    interpolator = cupyinterp.RBFInterpolator(manager, fluidSolver,
                                              solidSolver, p['rbfRadius'],
                                              comm)

    # --- Initialize the FSI criterion --- #
    criterion = cupycrit.DispNormCriterion(p['tollFSI'])
    cupyutil.mpiBarrier()

    # --- Initialize the FSI algorithm --- #
    #algorithm = cupyalgo.AlgorithmBGSStaticRelax(manager, fluidSolver, solidSolver, interpolator, criterion, p['nFSIIterMax'], p['dt'], p['tTot'], p['timeIterTreshold'], p['omegaMax'], comm)
    algorithm = cupyalgo.AlgorithmExplicit(manager, fluidSolver, solidSolver,
                                           interpolator, p['dt'], p['tTot'],
                                           p['timeIterTreshold'], comm)

    # --- Launch the FSI computation --- #
    algorithm.run()

    # --- Check the results --- #
    test(algorithm.errValue, p['tollFSI'])

    # --- Exit computation --- #
    del manager
    del criterion
    del fluidSolver
    del solidSolver
    del interpolator
    del algorithm
    cupyutil.mpiBarrier(comm)

    # eof
    print ''
Пример #4
0
def main(_p, nogui):

    p = getParameters(_p)

    comm = None
    myid = 0
    numberPart = 0
    rootProcess = 0

    cupyutil.load(fileName, p['withMPI'], comm, myid, numberPart)

    if p['withMPI']:
        from mpi4py import MPI
        comm = MPI.COMM_WORLD
        myid = comm.Get_rank()
        numberPart = comm.Get_size()
    else:
        comm = None
        myid = 0
        numberPart = 1

    # --- Input parameters --- #
    CFD_file = '../../../tests/SU2_Metafor/AGARD445_Static_SU2Conf.cfg'
    CSD_file = 'AGARD445_Static_MetaforConf'

    # --- Initialize the fluid solver --- #
    import cupydoInterfaces.SU2Interface
    if comm != None:
        FluidSolver = cupydoInterfaces.SU2Interface.SU2Solver(
            CFD_file, p['nZones_SU2'], p['nDim'], p['computationType'],
            p['nodalLoadsType'], p['withMPI'], comm)
    else:
        FluidSolver = cupydoInterfaces.SU2Interface.SU2Solver(
            CFD_file, p['nZones_SU2'], p['nDim'], p['computationType'],
            p['nodalLoadsType'], p['withMPI'], 0)
    cupyutil.mpiBarrier(comm)

    # --- Initialize the solid solver --- #
    SolidSolver = None
    if myid == rootProcess:
        import cupydoInterfaces.MtfInterface
        SolidSolver = cupydoInterfaces.MtfInterface.MtfSolver(
            CSD_file, p['computationType'])
        SolidSolver.saveAllFacs = p['mtfSaveAllFacs']
    cupyutil.mpiBarrier(comm)

    # --- Initialize the FSI manager --- #
    manager = cupyman.Manager(FluidSolver, SolidSolver, p['nDim'],
                              p['computationType'], comm)
    cupyutil.mpiBarrier()

    # --- Initialize the interpolator --- #
    interpolator = cupyinterp.RBFInterpolator(manager, FluidSolver,
                                              SolidSolver, p['rbfRadius'],
                                              comm)
    solverList = interpolator.getLinearSolvers()
    for ii in range(2):
        solverList[ii].setMaxNumberIterations(1000)
        solverList[ii].setPreconditioner("JACOBI")

    # --- Initialize the FSI criterion --- #
    criterion = cupycrit.DispNormCriterion(p['tollFSI'])
    cupyutil.mpiBarrier()

    # --- Initialize the FSI algorithm --- #
    algorithm = cupyalgo.AlgorithmBGSStaticRelax(manager, FluidSolver,
                                                 SolidSolver, interpolator,
                                                 criterion, p['nFSIIterMax'],
                                                 p['dt'], p['tTot'],
                                                 p['timeIterTreshold'],
                                                 p['omegaMax'], comm)

    # --- Launch the FSI computation --- #
    algorithm.run()

    # --- Exit computation --- #
    del manager
    del criterion
    del FluidSolver
    del SolidSolver
    del interpolator
    del algorithm
    cupyutil.mpiBarrier(comm)
    return 0