Exemple #1
0
def initialize():
    global coProcessor

    import paraview
    import paraview.vtk as vtk
    import paraview.simple
    from paraview import servermanager
    from paraview.modules import vtkPVCatalyst as catalyst

    from mpi4py import MPI
    import os, sys

    paraview.options.batch = True
    paraview.options.symmetric = True

    if not servermanager.vtkProcessModule.GetProcessModule():
        pvoptions = None
        if paraview.options.batch:
            pvoptions = servermanager.vtkPVOptions()
            pvoptions.SetProcessType(servermanager.vtkPVOptions.PVBATCH)
            if paraview.options.symmetric:
                pvoptions.SetSymmetricMPIMode(True)
        servermanager.vtkInitializationHelper.Initialize(
            sys.executable, servermanager.vtkProcessModule.PROCESS_BATCH,
            pvoptions)

    coProcessor = catalyst.vtkCPProcessor()
    pm = paraview.servermanager.vtkProcessModule.GetProcessModule()
Exemple #2
0
def initialize():
    global coProcessor
    import paraview
    paraview.options.batch = True
    paraview.options.symmetric = True
    from paraview.modules import vtkPVCatalyst as catalyst
    coProcessor = catalyst.vtkCPProcessor()
Exemple #3
0
def initialize():
    global coProcessor
    import paraview
    import vtkParallelCorePython
    import vtk
    from mpi4py import MPI
    import os, sys

    paraview.options.batch = True
    paraview.options.symmetric = True
    import vtkPVClientServerCoreCorePython as CorePython
    try:
        import vtkPVServerManagerApplicationPython as ApplicationPython
    except:
        paraview.print_error(
            "Error: Cannot import vtkPVServerManagerApplicationPython")

    if not CorePython.vtkProcessModule.GetProcessModule():
        pvoptions = None
        if paraview.options.batch:
            pvoptions = CorePython.vtkPVOptions()
            pvoptions.SetProcessType(CorePython.vtkPVOptions.PVBATCH)
            if paraview.options.symmetric:
                pvoptions.SetSymmetricMPIMode(True)
        ApplicationPython.vtkInitializationHelper.Initialize(
            sys.executable, CorePython.vtkProcessModule.PROCESS_BATCH,
            pvoptions)

    import paraview.servermanager as pvsm
    # we need ParaView 4.2 since ParaView 4.1 doesn't properly wrap
    # vtkPVPythonCatalystPython
    if pvsm.vtkSMProxyManager.GetVersionMajor() < 4 or (
            pvsm.vtkSMProxyManager.GetVersionMajor() == 4
            and pvsm.vtkSMProxyManager.GetVersionMinor() < 2):
        print 'Must use ParaView v4.2 or greater'
        sys.exit(0)

    import numpy
    from paraview.modules import vtkPVCatalyst as catalyst
    import vtkPVPythonCatalystPython as pythoncatalyst
    import paraview.simple
    import paraview.vtk as vtk
    from paraview.vtk.util import numpy_support
    paraview.options.batch = True
    paraview.options.symmetric = True

    coProcessor = catalyst.vtkCPProcessor()
    pm = paraview.servermanager.vtkProcessModule.GetProcessModule()
    from mpi4py import MPI
Exemple #4
0
def initialize():
    global coProcessor
    import paraview
    import vtkParallelCorePython
    import vtk
    from mpi4py import MPI
    import os, sys

    paraview.options.batch = True
    paraview.options.symmetric = True
    import vtkPVClientServerCoreCorePython as CorePython
    try:
        import vtkPVServerManagerApplicationPython as ApplicationPython
    except:
        paraview.print_error("Error: Cannot import vtkPVServerManagerApplicationPython")

    if not CorePython.vtkProcessModule.GetProcessModule():
        pvoptions = None
        if paraview.options.batch:
            pvoptions = CorePython.vtkPVOptions();
            pvoptions.SetProcessType(CorePython.vtkPVOptions.PVBATCH)
            if paraview.options.symmetric:
                pvoptions.SetSymmetricMPIMode(True)
        ApplicationPython.vtkInitializationHelper.Initialize(sys.executable, CorePython.vtkProcessModule.PROCESS_BATCH, pvoptions)

    import paraview.servermanager as pvsm
    # we need ParaView 4.2 since ParaView 4.1 doesn't properly wrap
    # vtkPVPythonCatalystPython
    if pvsm.vtkSMProxyManager.GetVersionMajor() < 4 or (pvsm.vtkSMProxyManager.GetVersionMajor() == 4 and pvsm.vtkSMProxyManager.GetVersionMinor() < 2):
        print 'Must use ParaView v4.2 or greater'
        sys.exit(0)

    import numpy
    from paraview.modules import vtkPVCatalyst as catalyst
    import vtkPVPythonCatalystPython as pythoncatalyst
    import paraview.simple
    import paraview.vtk as vtk
    from paraview.vtk.util import numpy_support
    paraview.options.batch = True
    paraview.options.symmetric = True

    coProcessor = catalyst.vtkCPProcessor()
    pm = paraview.servermanager.vtkProcessModule.GetProcessModule()
    from mpi4py import MPI
def initialize():
    global coProcessor
    import paraview
    from vtk import vtkParallelCore
    import paraview.servermanager as pvsm
    import vtk
    from mpi4py import MPI
    import os, sys

    paraview.options.batch = True
    paraview.options.symmetric = True
    from paraview.modules import vtkRemotingServerManager as CorePython
    from paraview.modules.vtkRemotingApplication import vtkInitializationHelper

    if not pvsm.vtkProcessModule.GetProcessModule():
        pvoptions = None
        if paraview.options.batch:
            pvoptions = CorePython.vtkPVOptions();
            pvoptions.SetProcessType(CorePython.vtkPVOptions.PVBATCH)
            if paraview.options.symmetric:
                pvoptions.SetSymmetricMPIMode(True)
        vtkInitializationHelper.Initialize(sys.executable, pvsm.vtkProcessModule.PROCESS_BATCH, pvoptions)

    
    # we need ParaView 4.2 since ParaView 4.1 doesn't properly wrap
    # vtkPVPythonCatalyst
    if pvsm.vtkSMProxyManager.GetVersionMajor() < 4 or (pvsm.vtkSMProxyManager.GetVersionMajor() == 4 and pvsm.vtkSMProxyManager.GetVersionMinor() < 2):
        print('Must use ParaView v4.2 or greater')
        sys.exit(0)

    import numpy
    from paraview.modules import vtkPVCatalyst as catalyst
    from paraview.modules import vtkPVPythonCatalyst as pythoncatalyst
    import paraview.simple
    import paraview.vtk as vtk
    from paraview.vtk.util import numpy_support
    paraview.options.batch = True
    paraview.options.symmetric = True

    coProcessor = catalyst.vtkCPProcessor()
    pm = paraview.servermanager.vtkProcessModule.GetProcessModule()
    from mpi4py import MPI
Exemple #6
0
def initialize():
    # if ParaView is already initialized, some of the options we set here don't
    # get used, hence it's a good thing to warn about it. It's not an error,
    # but something that users (and developers) should realize.

    # Note, this happens when pvpython/pvbatch is used to execute the Python scripts.
    # Once we unity ParaView initialization in these executables and standard
    # Python interpreter, this will not be an issue.
    _sanity_check()

    # initialize ParaView's ServerManager. To do that, we set some
    # variables that control how the ParaView will get initialized
    # and then simply `import paraview.servermanager`
    paraview.options.batch = True
    paraview.options.symmetric = True

    global coprocessor
    coprocessor = vtkCPProcessor()
    if not coprocessor.Initialize():
        raise RuntimeError("Failed to initialize Catalyst")
Exemple #7
0
# alphabetically. This is a slight modification based on the question by Adrian and answer by
# Jochen Ritzel at:
# https://stackoverflow.com/questions/4659524/how-to-sort-by-length-of-string-followed-by-alphabetical-order
files.sort(key=lambda item: (len(item), item))
if rank == 0:
    print("Reading in ", files)
reader = pvsimple.OpenDataFile(files)

if pm.GetSymmetricMPIMode() == False and nranks > 1:
    if rank == 0:
        print(
            "ERROR: must run pvbatch with -sym when running with more than a single MPI process"
        )
    sys.exit(1)

catalyst = vtkPVCatalyst.vtkCPProcessor()
# We don't need to initialize Catalyst since we run from pvbatch
# with the -sym argument which acts exactly like we're running
# Catalyst from a simulation code.
#catalyst.Initialize()

for script in sys.argv[2:]:
    import os.path
    if rank == 0:
        print("Adding script ", script)
    if os.path.splitext(script)[1] == ".zip":
        pipeline = vtkPVPythonCatalyst.vtkCPPythonScriptV2Pipeline()
        pipeline.Initialize(script)
    elif os.path.isdir(script):
        pipeline = vtkPVPythonCatalyst.vtkCPPythonScriptV2Pipeline()
        pipeline.InitializeFromDirectory(script)
Exemple #8
0
# In case the filenames aren't padded we sort first by shorter length and then
# alphabetically. This is a slight modification based on the question by Adrian and answer by
# Jochen Ritzel at:
# https://stackoverflow.com/questions/4659524/how-to-sort-by-length-of-string-followed-by-alphabetical-order
files.sort(key=lambda item: (len(item), item))
if rank == 0:
    print("Reading in ", files)
reader = pvsimple.OpenDataFile(files)

if pm.GetSymmetricMPIMode() == False and nranks > 1:
    if rank == 0:
        print("ERROR: must run pvbatch with -sym when running with more than a single MPI process")
    sys.exit(1)

catalyst = vtkPVCatalyst.vtkCPProcessor()
# We don't need to initialize Catalyst since we run from pvbatch
# with the -sym argument which acts exactly like we're running
# Catalyst from a simulation code.
#catalyst.Initialize()

for script in sys.argv[2:]:
    pipeline = vtkPVPythonCatalystPython.vtkCPPythonScriptPipeline()
    if rank == 0:
        print("Adding script ", script)
    pipeline.Initialize(script)
    catalyst.AddPipeline(pipeline)


# we get the channel name here from the reader's dataset. if there
# isn't a channel name there we just assume that the channel name