def main(args): """The main loop""" # this globbling logic is copied from `filedriver.py`. It may be worth # cleaning this up to ensure it handles typical use-cases we encounter. files = glob.glob(args.glob) # 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)) # initialize Catalyst from paraview.catalyst import bridge from paraview import print_info, print_warning bridge.initialize() # add analysis script for script in args.script: bridge.add_pipeline(script, args.script_version) # Some MPI related stuff to figure out if we're running with MPI # and if so, on how many ranks. try: from mpi4py import MPI comm = MPI.COMM_WORLD rank = comm.Get_rank() num_ranks = comm.Get_size() except ImportError: print_warning("missing mpi4py, running in serial (non-distributed) mode") rank = 0 num_ranks = 1 reader = create_reader(files) timesteps = reader.TimestepValues[:] step = 0 numsteps = len(timesteps) for time in timesteps: if args.delay > 0: import time time.sleep(args.delay) if rank == 0: print_info("timestep: {0} of {1}".format((step+1), numsteps)) dataset, wholeExtent = read_dataset(reader, time, rank, num_ranks) # "perform" coprocessing. results are outputted only if # the passed in script says we should at time/step bridge.coprocess(time, step, dataset, name=args.channel, wholeExtent=wholeExtent) del dataset del wholeExtent step += 1 # finalize Catalyst bridge.finalize()
def main(args): """The main loop""" # initialize Catalyst from paraview.catalyst import bridge from paraview import print_info, print_warning bridge.initialize() # add analysis script for script in args.script: bridge.add_pipeline(script, args.script_version) # Some MPI related stuff to figure out if we're running with MPI # and if so, on how many ranks. try: from mpi4py import MPI comm = MPI.COMM_WORLD rank = comm.Get_rank() num_ranks = comm.Get_size() except ImportError: print_warning( "missing mpi4py, running in serial (non-distributed) mode") rank = 0 num_ranks = 1 numsteps = args.timesteps for step in range(numsteps): if args.delay > 0: import time time.sleep(args.delay) if rank == 0: print_info("timestep: {0}/{1}".format(step + 1, numsteps)) # assume simulation time starts at 0 time = step / float(numsteps) dataset, wholeExtent = create_dataset(step, args, rank, num_ranks) # "perform" coprocessing. results are outputted only if # the passed in script says we should at time/step bridge.coprocess(time, step, dataset, name=args.channel, wholeExtent=wholeExtent) del dataset del wholeExtent # finalize Catalyst bridge.finalize()
def addscript(filename): bridge.add_pipeline(filename)
default=0.0) parser.add_argument("-c", "--channel", type=str, help="Catalyst channel name (default: input)", default="input") args = parser.parse_args() #---------------------------------------------------------------- # initialize Catalyst from paraview.catalyst import bridge bridge.initialize() # add analysis script for script in args.script: bridge.add_pipeline(script, args.script_version) #---------------------------------------------------------------- # Here's our simulation main loop try: from mpi4py import MPI comm = MPI.COMM_WORLD rank = comm.Get_rank() num_ranks = comm.Get_size() except ImportError: print("missing mpi4py, running in serial (non-distributed) mode") rank = 0 num_ranks = 1 # We'll use vtkRTAnalyticSource to generate our dataset