def frames(): """Render frames""" camera = vtk.vtkCamera() camera.SetViewUp(0.0000000000, 1.0000000000, 0.0000000000) camera.SetPosition(0.1520000000, 0.0128500000, 0.1627768061) camera.SetFocalPoint(0.1520000000, 0.0128500000, 0.0000000000) reader = chigger.exodus.ExodusReader(EXODUS) temperature = chigger.exodus.ExodusResult(reader, camera=camera, variable='temperature', viewport=[0,0.5,1,1], range=[300, 350], cmap='viridis') pressure = chigger.exodus.ExodusResult(reader, camera=camera, variable='pressure', viewport=[0, 0, 1, 0.5], range=[0, 4000], cmap='viridis') cbar = chigger.exodus.ExodusColorBar(temperature, pressure, viewport=[0,0,1,1], length=0.6, colorbar_origin=[0.2, 0.5], location='top') time = chigger.annotations.TextAnnotation(position=[0.5,0.05], font_size=48, text_color=[0,0,0], justification='center') cbar.setOptions('primary', title='Temperature (K)', font_size=48, font_color=[0,0,0]) cbar.setOptions('secondary', title='Pressure (Pa)', font_size=48, font_color=[0,0,0]) window = chigger.RenderWindow(temperature, pressure, cbar, time, size=[1920, 1080], background=[1,1,1]) for i, t in enumerate(reader.getTimes()): reader.setOptions(timestep=i) time.setOptions(text='Time = {:.0f} sec.'.format(t)) filename = 'output/{}_{:05d}.png'.format(PREFIX, i) window.write(filename) window.start()
def frames(): camera = vtk.vtkCamera() camera.SetViewUp(0.0000000000, 1.0000000000, 0.0000000000) camera.SetPosition(0.1520000000, 0.0128500000, 0.3276535154) camera.SetFocalPoint(0.1520000000, 0.0128500000, 0.0000000000) reader = chigger.exodus.ExodusReader('step7d_adapt_blocks_out.e') temp = chigger.exodus.ExodusResult(reader, camera=camera, variable='temperature', range=[300, 350], edges=True, edge_color=EDGE_COLOR, cmap='plasma') cbar = chigger.exodus.ExodusColorBar(temp, length=0.6, viewport=[0,0,1,1], colorbar_origin=[0.2, 0.7], location='top') cbar.setOptions('primary', title='Temperature (K)', font_size=48, font_color=[0,0,0]) time = chigger.annotations.TextAnnotation(position=[0.5,0.2], font_size=48, text_color=[0,0,0], justification='center') window = chigger.RenderWindow(temp, cbar, time, size=[1920, 1080], motion_factor=0.1, background=[1,1,1]) for i, t in enumerate(reader.getTimes()): reader.setOptions(timestep=i) reader.setOptions(timestep=i) reader.setOptions(timestep=i) time.setOptions(text='Time = {:.1f} sec.'.format(t)) filename = 'output/step07d_{:05d}.png'.format(i) window.write(filename) window.start()
def __init__(self, size=None, **kwargs): super(VTKWindowPlugin, self).__init__(**kwargs) # Setup widget self.setSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding, QtWidgets.QSizePolicy.MinimumExpanding) # Create the QVTK interactor if (vtk.vtkVersion.GetVTKMajorVersion() < 8): self.__qvtkinteractor = RetinaQVTKRenderWindowInteractor(self) else: self.__qvtkinteractor = QVTKRenderWindowInteractor(self) # Member variables self._highlight = None self._initialized = False self._run_start_time = -1 self._reader = None self._result = None self._window = chigger.RenderWindow( vtkwindow=self.__qvtkinteractor.GetRenderWindow(), vtkinteractor=self.__qvtkinteractor.GetRenderWindow( ).GetInteractor(), size=size) self._reader_options = self.getDefaultReaderOptions() self._result_options = self.getDefaultResultOptions() self._window_options = self.getDefaultWindowOptions() # If size is provided, restrict the window if size != None: self.setFixedSize(QtCore.QSize(*size)) else: self.setMinimumSize(QtCore.QSize(600, 600)) # Define timers for initialization and updating data self._timers = dict() for name in ['update', 'initialize']: self._timers[name] = QtCore.QTimer() self._timers[name].setInterval(1000) self._timers['update'].timeout.connect(self.onWindowRequiresUpdate) self._timers['initialize'].timeout.connect(self.onWindowRequiresUpdate) # Create a "tight" layout and add the QVTK widget self._layout = QtWidgets.QHBoxLayout() self._layout.setContentsMargins(0, 0, 0, 0) self._layout.addWidget(self.__qvtkinteractor) self.setLayout(self._layout) # Camera cache self._cameras = dict() # Display items for when no file exists self._peacock_logo = chigger.annotations.ImageAnnotation( filename='peacock.png', opacity=0.33) self._peacock_text = chigger.annotations.TextAnnotation( justification='center', font_size=18) self.setMainLayoutName('RightLayout') self.setup()
def setUp(self): """ Create a window to export. """ file_name = '../input/mug_blocks_out.e' self._reader = chigger.exodus.ExodusReader(file_name, adaptive=False) self._result = chigger.exodus.ExodusResult(self._reader, cmap='viridis') self._window = chigger.RenderWindow(self._result, size=[300,300], style='test')
def build_frames(camera=None): """ Function for building level set demonstration images/movies. Args: camera[vtkCamera]: The camera to utilize for the rendered window. """ parser = argparse.ArgumentParser(description="Process results for initial/final condition and/or area conservation.") parser.add_argument('exodus', help="The ExodusII file to process.") parser.add_argument('--variable', '-v', default='phi', type=str, help="The variable to display.") parser.add_argument('--interval', default=5, type=int, help="The image output interval.") parser.add_argument('--output', '-o', type=str, help="The prefix for the outputted PNG files.") parser.add_argument('--size', default=[400, 400], type=list, help="The image size, in pixels.") parser.add_argument('--gif', action='store_true', help="Enable the creation of an animated gif via ImageMagick, using the --output prefix for the filename.") parser.add_argument('--delay', default=20, type=int, help="Delay between frames in animate gif.") parser.add_argument('--clean', action='store_true', help="Delete existing PNG files matching the output name.") options = parser.parse_args() # Initial Condition initial_reader = chigger.exodus.ExodusReader(options.exodus, timestep=0) initial_contour = chigger.filters.ContourFilter(levels=[0.5]) initial_result = chigger.exodus.ExodusResult(initial_reader, variable=options.variable, camera=camera, color=[0,0,0], filters=[initial_contour], edge_width=2, layer=2) # The background "phi" colormap reader = chigger.exodus.ExodusReader(options.exodus) reader.update() result = chigger.exodus.ExodusResult(reader, variable=options.variable, camera=camera, layer=1, opacity=0.8, cmap='viridis', edges=True, edge_color=[0.5,0.5,0.5]) # The current contour result_contour = chigger.filters.ContourFilter(levels=[0.5]) result2 = chigger.exodus.ExodusResult(reader, variable=options.variable, camera=camera, color=[0,1,0], layer=2, edge_width=2, filters=[result_contour]) # Write image frames window = chigger.RenderWindow(initial_result, result, result2, background=[1,1,1], size=[400,400], style='interactive2D') # Determine output if not options.output: options.output, _ = os.path.splitext(options.exodus) # Clean existing PNGs if options.clean: for filename in glob.glob('{}*.png'.format(options.output)): os.remove(filename) # Write the frames n = len(reader.getTimes()) rng = range(0, n, options.interval) + [n-1] for i in rng: reader.setOptions(timestep=i) window.write('{}_{:04d}.png'.format(options.output, i)) window.update() # Create animated _gif if options.gif: chigger.utils.animate('{}_*.png'.format(options.output), '{}.gif'.format(options.output), delay=options.delay)
def __init__(self, size=None, **kwargs): super(VTKWindowPlugin, self).__init__(**kwargs) # Setup widget self.setSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding, QtWidgets.QSizePolicy.MinimumExpanding) self.setMainLayoutName('WindowLayout') # Create the QVTK interactor if self.devicePixelRatio() > 1: self.__qvtkinteractor = RetinaQVTKRenderWindowInteractor(self) else: self.__qvtkinteractor = QVTKRenderWindowInteractor(self) # Member variables self._highlight = None self._reader = None self._result = None self._filename = str() self._initialized = False self._run_start_time = None self._window = chigger.RenderWindow( vtkwindow=self.__qvtkinteractor.GetRenderWindow(), vtkinteractor=self.__qvtkinteractor.GetRenderWindow( ).GetInteractor(), size=size) # Set to True when the window needs to be reset (e.g., when the input file was changed) self._reset_required = False # If size is provided, restrict the window if size != None: self.setFixedSize(QtCore.QSize(*size)) # Define timers for initialization and updating data self._timers = dict() for name in ['update', 'initialize']: self._timers[name] = QtCore.QTimer() self._timers[name].setInterval(1000) self._timers['update'].timeout.connect(self.onWindowRequiresUpdate) self._timers['initialize'].timeout.connect(self.onReloadWindow) # Create a "tight" layout and add the QVTK widget self._layout = QtWidgets.QHBoxLayout() self._layout.setContentsMargins(0, 0, 0, 0) self._layout.addWidget(self.__qvtkinteractor) self.setLayout(self._layout) # Display items for when no file exists self._peacock_logo = chigger.annotations.ImageAnnotation( filename='peacock.png', opacity=0.33) self._peacock_text = chigger.annotations.TextAnnotation( text='No file selected.', justification='center', font_size=18) self.setup()
def frames(): """Render frames""" camera = vtk.vtkCamera() camera.SetViewUp(0.0000000000, 1.0000000000, 0.0000000000) camera.SetPosition(0.1590705559, -0.0218861161, 0.1683082924) camera.SetFocalPoint(0.1590705559, -0.0218861161, 0.0000000000) reader = chigger.exodus.ExodusReader(EXODUS, displacement_magnitude=DISP) temp_rot = chigger.filters.TransformFilter(rotate=[0,0,270]) temp = chigger.exodus.ExodusResult(reader, camera=camera, variable='temperature', viewport=[0,0.5,1,1], range=[300, 350], filters=[temp_rot], cmap='plasma') disp_rot = chigger.filters.TransformFilter(rotate=[0,0,270]) disp = chigger.exodus.ExodusResult(reader, camera=camera, variable='vonmises_stress', #component=1, viewport=[0, 0, 1, 0.5], filters=[disp_rot], range=[0, 1.8e8], cmap='plasma') cbar = chigger.exodus.ExodusColorBar(temp, disp, viewport=[0,0,1,1], length=0.6, colorbar_origin=[0.2, 0.5], location='top') time = chigger.annotations.TextAnnotation(position=[0.5,0.9], font_size=48, text_color=[0,0,0], justification='center') tdisp = chigger.annotations.TextAnnotation(position=[0.5,0.05], font_size=48, text_color=[0,0,0], text='{}x Displacement'.format(DISP), justification='center') cbar.setOptions('primary', title='Temperature (K)', font_size=48, font_color=[0,0,0], num_ticks=6) cbar.setOptions('secondary', title='VonMises Stress (MPa)', font_size=48, font_color=[0,0,0], axis_scale=1e-6, num_ticks=5) window = chigger.RenderWindow(temp, disp, cbar, time, tdisp, size=[1920, 1080], background=[1,1,1], motion_factor=0.2) for i, t in enumerate(reader.getTimes()): reader.setOptions(timestep=i) time.setOptions(text='Time = {:.2f} sec.'.format(t)) filename = 'output/{}_{:05d}.png'.format(PREFIX, i) window.write(filename) #break window.start()
def __init__(self, size=None): super(VTKWindowPlugin, self).__init__() # Setup widget self.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding) self.setMainLayoutName('WindowLayout') # Create the QVTK interactor if self.devicePixelRatio() > 1: self.__qvtkinteractor = RetinaQVTKRenderWindowInteractor(self) else: self.__qvtkinteractor = QVTKRenderWindowInteractor(self) self.__qvtkinteractor.hide() # Member variables self._highlight = None self._reader = None self._result = None self._filename = None self._initialized = False self._run_start_time = None self._window = chigger.RenderWindow(vtkwindow=self.__qvtkinteractor.GetRenderWindow(), vtkinteractor=self.__qvtkinteractor.GetRenderWindow().GetInteractor(), size=size) # Set to True when the window needs to be reset (e.g., when the input file was changed) self._reset_required = False # If size is provided, restrict the window if size != None: self.setFixedSize(QtCore.QSize(*size)) # Define timers for initialization and updating data self._timers = dict() for name in ['update', 'initialize']: self._timers[name] = QtCore.QTimer() self._timers[name].setInterval(1000) self._timers['update'].timeout.connect(self.onWindowRequiresUpdate) self._timers['initialize'].timeout.connect(self.onReloadWindow) # Create a "tight" layout and add the QVTK widget self._layout = QtWidgets.QHBoxLayout() self._layout.setContentsMargins(0, 0, 0, 0) self._layout.addWidget(self.__qvtkinteractor) self.setLayout(self._layout) self.setup()
def frames(): camera = vtk.vtkCamera() camera.SetViewUp(0.0000000000, 1.0000000000, 0.0000000000) camera.SetPosition(0.0502350449, 0.0585791400, 0.2368438986) camera.SetFocalPoint(0.0502350449, 0.0585791400, 0.0000000000) reader = chigger.exodus.ExodusReader('step10_micro_out.e') phase = chigger.exodus.ExodusResult(reader, camera=camera, variable='phi', range=[0, 1], viewport=[0,0,0.5,1], edges=True, edge_color=[0.5]*3, cmap='Blues', cmap_reverse=True) cbar = chigger.exodus.ExodusColorBar(phase, length=0.8, colorbar_origin=[0.1, 0.85], location='top') cbar.setOptions('primary', title='Phase (0=water; 1=steel)', num_ticks=3, font_size=FONTSIZE, font_color=[0,0,0]) poro = chigger.graphs.Line(color=[0.1,0.1,1], width=4, tracer=True) keff = chigger.graphs.Line(color=[1,0.2,0.2], width=4, tracer=True, corner='right-bottom') graph = chigger.graphs.Graph(poro, keff, viewport=[0.5,0,1,1]) graph.setOptions('legend', visible=False) graph.setOptions('xaxis', title='Time (s)', lim=[0, 700], font_color=[0,0,0], font_size=FONTSIZE, num_ticks=8) graph.setOptions('yaxis', title='Porosity ', lim=[0, 1], font_color=[0.1,0.1,1], font_size=FONTSIZE, num_ticks=5) graph.setOptions('y2axis', title='Thermal Cond. (W/mK)', lim=[0.5,12.5], font_color=[1,0.2,0.2], font_size=FONTSIZE, num_ticks=5) window = chigger.RenderWindow(phase, cbar, graph, size=[1920, 1080], motion_factor=0.1, background=[1,1,1]) for i, t in enumerate(reader.getTimes()): reader.setOptions(timestep=i) poro.setOptions(x=[t], y=[reader.getGlobalData('por_var')]) keff.setOptions(x=[t], y=[reader.getGlobalData('k_eff')]) filename = 'output/step10_micro_{:05d}.png'.format(i) window.write(filename) window.start()
import vtk import chigger camera = vtk.vtkCamera() camera.SetViewUp(-0.2488, 0.8185, -0.5178) camera.SetPosition(1.8403, 2.7164, 3.4098) camera.SetFocalPoint(0.0000, 0.0000, 0.0000) cube0 = chigger.geometric.CubeSource(position=[0, 0, 0], lengths=[1, 1, 1], rotation=[45, 0, 0], color=[0.5, 0, 0], edges=False) cube1 = chigger.geometric.CubeSource(position=[0, 0, 0], lengths=[1, 1, 1], rotation=[0, 45, 0], color=[0, 0.5, 0], edges=False) cube2 = chigger.geometric.CubeSource(position=[0, 0, 0], lengths=[1, 1, 1], rotation=[0, 0, 45], color=[0, 0, 0.5], edges=False) cubes = chigger.base.ChiggerResult(cube0, cube1, cube2, camera=camera) window = chigger.RenderWindow(cubes, size=[300, 300], test=True) window.write('rotation.png') window.start()
def frames(): """Render frames""" camera = vtk.vtkCamera() camera.SetViewUp(0.0000000000, 0.9999999979, 0.0000646418) camera.SetPosition(0.1801966629, -0.0310247580, 0.1288860739) camera.SetFocalPoint(0.1801966629, -0.0310164265, 0.0000000000) master_reader = chigger.exodus.ExodusReader('step10_out.e', displacement_magnitude=500) temp_rot = chigger.filters.TransformFilter(rotate=[0, 0, 270]) temp = chigger.exodus.ExodusResult(master_reader, camera=camera, variable='temperature', viewport=[0, 2 / 3., 1, 1], range=[300, 350], filters=[temp_rot], cmap='plasma') sub_camera = vtk.vtkCamera() sub_camera.SetViewUp(0.0000000000, 1.0000000000, 0.0000000000) sub_camera.SetPosition(0.0500000000, 0.0500000000, 0.2165474516) sub_camera.SetFocalPoint(0.0500000000, 0.0500000000, 0.0000000000) sub0_reader = chigger.exodus.ExodusReader('step10_out_micro0.e', timestep=0) sub0_result = chigger.exodus.ExodusResult( sub0_reader, variable='phi', cmap='plasma', camera=sub_camera, viewport=[0, 1 / 3., 1 / 6., 2 / 3.]) sub1_reader = chigger.exodus.ExodusReader('step10_out_micro1.e', timestep=0) sub1_result = chigger.exodus.ExodusResult( sub1_reader, variable='phi', cmap='plasma', camera=sub_camera, viewport=[1 / 6., 1 / 3., 2 / 6., 2 / 3.]) sub2_reader = chigger.exodus.ExodusReader('step10_out_micro2.e', timestep=0) sub2_result = chigger.exodus.ExodusResult( sub2_reader, variable='phi', cmap='plasma', camera=sub_camera, viewport=[2 / 6., 1 / 3., 3 / 6., 2 / 3.]) sub3_reader = chigger.exodus.ExodusReader('step10_out_micro3.e', timestep=0) sub3_result = chigger.exodus.ExodusResult( sub3_reader, variable='phi', cmap='plasma', camera=sub_camera, viewport=[3 / 6., 1 / 3., 4 / 6., 2 / 3.]) sub4_reader = chigger.exodus.ExodusReader('step10_out_micro4.e', timestep=0) sub4_result = chigger.exodus.ExodusResult( sub4_reader, variable='phi', cmap='plasma', camera=sub_camera, viewport=[4 / 6., 1 / 3., 5 / 6., 2 / 3.]) sub5_reader = chigger.exodus.ExodusReader('step10_out_micro5.e', timestep=0) sub5_result = chigger.exodus.ExodusResult( sub5_reader, variable='phi', cmap='plasma', camera=sub_camera, viewport=[5 / 6., 1 / 3., 6 / 6., 2 / 3.]) subs = [ sub0_result, sub1_result, sub2_result, sub3_result, sub4_result, sub5_result ] cbar = chigger.exodus.ExodusColorBar(temp, sub0_result, viewport=[0, 0, 1, 1], width=0.05, length=0.6, colorbar_origin=[0.2, 0.725], location='top') cbar.setOptions('primary', title='Temperature (K)', font_size=FONTSIZE, font_color=[0, 0, 0], num_ticks=6) cbar.setOptions('secondary', title='Phase (0=water; 1=steel)', font_size=FONTSIZE, font_color=[0, 0, 0], num_ticks=3) time = chigger.annotations.TextAnnotation(position=[0.1, 0.725], font_size=FONTSIZE, text_color=[0, 0, 0], justification='center', vertical_alignment='middle') tdisp = chigger.annotations.TextAnnotation(position=[0.92, 0.825], font_size=FONTSIZE * .75, text_color=[0, 0, 0], text='500x Displacement', justification='center', vertical_alignment='middle') line0 = chigger.graphs.Line(width=3, label='Sub0') line1 = chigger.graphs.Line(width=3, label='Sub1') line2 = chigger.graphs.Line(width=3, label='Sub2') line3 = chigger.graphs.Line(width=3, label='Sub3') line4 = chigger.graphs.Line(width=3, label='Sub4') line5 = chigger.graphs.Line(width=3, label='Sub5') # VTK messes up the order, that is why the strange input graph = chigger.graphs.Graph(line3, line0, line2, line4, line5, line1, color_scheme='BREWER_QUALITATIVE_DARK2', viewport=[0, 0, 1, 1 / 3.]) graph.setOptions('xaxis', title='Time (s)', lim=[0, 80], font_color=[0, 0, 0], font_size=FONTSIZE, num_ticks=9) graph.setOptions('yaxis', title='k (W/mK)', lim=[0.5, 12.5], font_color=[0, 0, 0], font_size=FONTSIZE, num_ticks=5) graph.setOptions('legend', label_color=[0, 0, 0], label_font_size=0.75 * FONTSIZE, opacity=1, background=[1, 1, 1], border=True, border_width=1, border_color=[0, 0, 0]) laby = 1 / 3. - 1 / 64. lab0 = chigger.annotations.TextAnnotation(text='Sub0: x=0', position=[1 / 12., laby], font_size=FONTSIZE, text_color=[0.5] * 3, justification='center', vertical_alignment='top') lab1 = chigger.annotations.TextAnnotation( text='Sub1: x=0.0608', position=[1 / 6. + 1 / 12., laby], font_size=FONTSIZE, text_color=[0.5] * 3, justification='center', vertical_alignment='top') lab2 = chigger.annotations.TextAnnotation( text='Sub2: x=0.1216', position=[2 / 6. + 1 / 12., laby], font_size=FONTSIZE, text_color=[0.5] * 3, justification='center', vertical_alignment='top') lab3 = chigger.annotations.TextAnnotation( text='Sub3: x=0.1824', position=[3 / 6. + 1 / 12., laby], font_size=FONTSIZE, text_color=[0.5] * 3, justification='center', vertical_alignment='top') lab4 = chigger.annotations.TextAnnotation( text='Sub4: x=0.2432', position=[4 / 6. + 1 / 12., laby], font_size=FONTSIZE, text_color=[0.5] * 3, justification='center', vertical_alignment='top') lab5 = chigger.annotations.TextAnnotation( text='Sub5: x=0.304', position=[5 / 6. + 1 / 12., laby], font_size=FONTSIZE, text_color=[0.5] * 3, justification='center', vertical_alignment='top') subs += [lab0, lab1, lab2, lab3, lab4, lab5] window = chigger.RenderWindow(temp, cbar, time, tdisp, graph, *subs, size=[1920, 1080], background=[1, 1, 1], motion_factor=0.2) for i, t in enumerate(master_reader.getTimes()): master_reader.setOptions(timestep=i) if i > 11: sub0_reader.setOptions(timestep=i - 11) sub1_reader.setOptions(timestep=i - 11) sub2_reader.setOptions(timestep=i - 11) sub3_reader.setOptions(timestep=i - 11) sub4_reader.setOptions(timestep=i - 11) sub5_reader.setOptions(timestep=i - 11) line0.setOptions(y=[sub0_reader.getGlobalData('k_eff')], x=[t]) line1.setOptions(y=[sub1_reader.getGlobalData('k_eff')], x=[t]) line2.setOptions(y=[sub2_reader.getGlobalData('k_eff')], x=[t]) line3.setOptions(y=[sub3_reader.getGlobalData('k_eff')], x=[t]) line4.setOptions(y=[sub4_reader.getGlobalData('k_eff')], x=[t]) line5.setOptions(y=[sub5_reader.getGlobalData('k_eff')], x=[t]) time.setOptions(text='Time = {:.2f} sec.'.format(t)) filename = 'output/{}_{:05d}.png'.format(PREFIX, i) window.write(filename) window.start()
#* This file is part of the MOOSE framework #* https://www.mooseframework.org #* #* All rights reserved, see COPYRIGHT for full restrictions #* https://github.com/idaholab/moose/blob/master/COPYRIGHT #* #* Licensed under LGPL 2.1, please see LICENSE for details #* https://www.gnu.org/licenses/lgpl-2.1.html import chigger n = 3 line0 = chigger.graphs.Line(marker='circle', color=[0, 0, 1]) line1 = chigger.graphs.Line(marker='plus', color=[0, 1, 0], corner='right-top') graph = chigger.graphs.Graph(line0, line1) graph.setOptions('xaxis', lim=[0, n]) graph.setOptions('yaxis', lim=[0, n]) graph.setOptions('x2axis', lim=[0, n]) graph.setOptions('y2axis', lim=[0, n]) graph.setOptions('legend', visible=False) window = chigger.RenderWindow(graph, size=[300, 300], test=True) window.write('secondary_initial.png') for i in range(n + 1): line0.setOptions(x=[i], y=[i], append=True) line1.setOptions(x=[i], y=[n - i], append=True) window.write('secondary_' + str(i) + '.png') window.start()
#!/usr/bin/env python #pylint: disable=missing-docstring #* This file is part of the MOOSE framework #* https://www.mooseframework.org #* #* All rights reserved, see COPYRIGHT for full restrictions #* https://github.com/idaholab/moose/blob/master/COPYRIGHT #* #* Licensed under LGPL 2.1, please see LICENSE for details #* https://www.gnu.org/licenses/lgpl-2.1.html import chigger reader = chigger.exodus.ExodusReader('../input/mug_blocks_out.e') mug = chigger.exodus.ExodusResult(reader, variable='convected', cmap='viridis') cbar = chigger.exodus.ExodusColorBar(mug, location='bottom', notation='standard', precision=2) window = chigger.RenderWindow(mug, cbar, size=[600, 400], test=True) window.start()
#!/usr/bin/env python #pylint: disable=missing-docstring ################################################################# # DO NOT MODIFY THIS HEADER # # MOOSE - Multiphysics Object Oriented Simulation Environment # # # # (c) 2010 Battelle Energy Alliance, LLC # # ALL RIGHTS RESERVED # # # # Prepared by Battelle Energy Alliance, LLC # # Under Contract No. DE-AC07-05ID14517 # # With the U. S. Department of Energy # # # # See COPYRIGHT for full restrictions # ################################################################# import chigger moose = chigger.annotations.ImageAnnotation(filename='../../../chigger/logos/moose.png', opacity=0.5, scale=0.5, position=[0.5, 0.75]) window = chigger.RenderWindow(moose, size=[400,400], test=True) window.write('image_annotation.png') window.start()
#!/usr/bin/env python3 #pylint: disable=missing-docstring #* This file is part of the MOOSE framework #* https://www.mooseframework.org #* #* All rights reserved, see COPYRIGHT for full restrictions #* https://github.com/idaholab/moose/blob/master/COPYRIGHT #* #* Licensed under LGPL 2.1, please see LICENSE for details #* https://www.gnu.org/licenses/lgpl-2.1.html import chigger colorbar = chigger.misc.ColorBar(cmap='viridis') colorbar.setOptions('primary', lim=[5, 10]) colorbar.setOptions('secondary', lim=[100, 500], visible=True) window = chigger.RenderWindow(colorbar, size=[600, 400], test=True) window.write('colorbar.png') window.start()
result = chigger.exodus.ExodusResult(reader, variable='aux', viewport=[0, 0, 0.5, 1], opacity=0.1, range=[-1, 1]) cbar = chigger.exodus.ExodusColorBar(result) result.update() sample = chigger.exodus.ExodusResultLineSampler(result, point1=[0, 0, 0.5], resolution=100) sample.update() x = sample[0].getDistance() y = sample[0].getSample('aux') line = chigger.graphs.Line(x, y, width=4, label='probe') graph = chigger.graphs.Graph(line, viewport=[0.5, 0, 1, 1]) graph.setOptions('xaxis', lim=[0, 1.4]) graph.setOptions('yaxis', lim=[0, 1.]) window = chigger.RenderWindow(result, cbar, sample, graph, size=[800, 400], test=True) window.write('line_sample_elem.png') window.start()
#!/usr/bin/env python #pylint: disable=missing-docstring #* This file is part of the MOOSE framework #* https://www.mooseframework.org #* #* All rights reserved, see COPYRIGHT for full restrictions #* https://github.com/idaholab/moose/blob/master/COPYRIGHT #* #* Licensed under LGPL 2.1, please see LICENSE for details #* https://www.gnu.org/licenses/lgpl-2.1.html import chigger reader = chigger.exodus.ExodusReader('../input/vector_out.e') mug = chigger.exodus.ExodusResult(reader, variable='vel_', component=0) window = chigger.RenderWindow(mug, size=[300, 300], test=True) window.write('vector_x.png') window.start()
#!/usr/bin/env python3 #pylint: disable=missing-docstring #* This file is part of the MOOSE framework #* https://www.mooseframework.org #* #* All rights reserved, see COPYRIGHT for full restrictions #* https://github.com/idaholab/moose/blob/master/COPYRIGHT #* #* Licensed under LGPL 2.1, please see LICENSE for details #* https://www.gnu.org/licenses/lgpl-2.1.html import chigger reader = chigger.exodus.ExodusReader('../input/mug_blocks_out.e') mug0 = chigger.exodus.ExodusResult(reader, variable='convected', viewport=[0, 0, 0.5, 1], cmap='shock') mug1 = chigger.exodus.ExodusResult(reader, variable='diffused', viewport=[0.5, 0, 1, 1], cmap='coolwarm') window = chigger.RenderWindow(mug1, mug0, size=[600, 300], test=True) window.write('viewports.png') window.start()
#!/usr/bin/env python2 #pylint: disable=missing-docstring #* This file is part of the MOOSE framework #* https://www.mooseframework.org #* #* All rights reserved, see COPYRIGHT for full restrictions #* https://github.com/idaholab/moose/blob/master/COPYRIGHT #* #* Licensed under LGPL 2.1, please see LICENSE for details #* https://www.gnu.org/licenses/lgpl-2.1.html import chigger reader = chigger.exodus.ExodusReader('../input/mug_blocks_out.e') mug = chigger.exodus.ExodusResult(reader, variable='diffused', cmap='viridis') cbar = chigger.exodus.ExodusColorBar(mug, primary={'num_ticks':6}) window = chigger.RenderWindow(mug, cbar, size=[300,300], offscreen=True) window.write('offscreen.png')
def frames(): camera = vtk.vtkCamera() camera.SetViewUp(-0.0000000012, 0.9999999979, -0.0000646418) camera.SetPosition(0.1520029313, 0.0128604224, 0.1612327470) camera.SetFocalPoint(0.1520000000, 0.0128500000, 0.0000000000) reader = chigger.exodus.ExodusReader('step8_out.e') temp = chigger.exodus.ExodusResult(reader, camera=camera, variable='temperature', range=[300, 350], viewport=[0, 0.5, 1, 1], cmap='plasma') cbar = chigger.exodus.ExodusColorBar(temp, length=0.6, viewport=[0, 0, 1, 1], colorbar_origin=[0.1, 0.85], location='top') cbar.setOptions('primary', title='Temperature (K)', num_ticks=6, font_size=48, font_color=[0, 0, 0]) time = chigger.annotations.TextAnnotation(position=[0.85, 0.85], font_size=48, text_color=[0, 0, 0], justification='center') pp_data = mooseutils.PostprocessorReader('step8_out.csv') x = pp_data['time'] y0 = pp_data['average_temperature'] y1 = pp_data['outlet_heat_flux'] avg_temp = chigger.graphs.Line(color=[0.1, 0.1, 1], width=4, tracer=True) out_flux = chigger.graphs.Line(color=[1, 0.2, 0.2], width=4, tracer=True, corner='right-bottom') graph = chigger.graphs.Graph(avg_temp, out_flux, viewport=[0, 0, 0.5, 0.65]) graph.setOptions('legend', visible=False) graph.setOptions('xaxis', title='Time (s)', lim=[0, 100], font_color=[0, 0, 0], font_size=28) graph.setOptions('yaxis', title='Temperature (K)', lim=[300, 350], font_color=[0.1, 0.1, 1], font_size=28, num_ticks=6) graph.setOptions('y2axis', title='Heat Flux (W/m^2)', lim=[0, 2.5], font_color=[1, 0.2, 0.2], font_size=28, num_ticks=6) vpp_data = mooseutils.VectorPostprocessorReader( 'step8_out_temperature_sample_*.csv') line_temp = chigger.graphs.Line(color=[0.1, 0.1, 1], width=4, append=False) graph2 = chigger.graphs.Graph(line_temp, viewport=[0.5, 0, 1, 0.65]) graph2.setOptions('legend', visible=False) graph2.setOptions('yaxis', title='y (cm)', lim=[0, 0.026], font_color=[0, 0, 0], font_size=28, axis_scale=100, num_ticks=5) graph2.setOptions('xaxis', title='Temperature (K)', lim=[300, 350], font_color=[0, 0, 0], font_size=28, num_ticks=6) window = chigger.RenderWindow(temp, cbar, time, graph, graph2, size=[1920, 1080], motion_factor=0.1, background=[1, 1, 1]) for i, t in enumerate(reader.getTimes()): reader.setOptions(timestep=i) reader.setOptions(timestep=i) reader.setOptions(timestep=i) avg_temp.setOptions(x=[x[i]], y=[y0[i]]) out_flux.setOptions(x=[x[i]], y=[y1[i]]) vpp = vpp_data(['y', 'temperature'], time=i) line_temp.setOptions(x=vpp['temperature'].tolist(), y=vpp['y'].multiply(100).tolist()) time.setOptions(text='Time = {:.2f} sec.'.format(t)) filename = 'output/step08_{:05d}.png'.format(i) window.write(filename) window.start()
#!/usr/bin/env python2 #pylint: disable=missing-docstring #* This file is part of the MOOSE framework #* https://www.mooseframework.org #* #* All rights reserved, see COPYRIGHT for full restrictions #* https://github.com/idaholab/moose/blob/master/COPYRIGHT #* #* Licensed under LGPL 2.1, please see LICENSE for details #* https://www.gnu.org/licenses/lgpl-2.1.html import vtk import chigger camera = vtk.vtkCamera() camera.SetViewUp(-0.0124, 0.7882, 0.6153) camera.SetPosition(0.0783, -0.1549, 0.3130) camera.SetFocalPoint(0.0500, 0.0500, 0.0500) reader = chigger.exodus.ExodusReader('../input/step10_micro_out.e') rotate = chigger.filters.TransformFilter(rotate=[90,0,0]) # move to x-z plane extrude = chigger.filters.RotationalExtrusionFilter(angle=90) # rotate along z result = chigger.exodus.ExodusResult(reader, filters=[rotate, extrude], camera=camera) window = chigger.RenderWindow(result, size=[300,300], antialiasing=10, test=True) window.write('rotational_extrusion.png') window.start()
#!/usr/bin/env python #* This file is part of the MOOSE framework #* https://www.mooseframework.org #* #* All rights reserved, see COPYRIGHT for full restrictions #* https://github.com/idaholab/moose/blob/master/COPYRIGHT #* #* Licensed under LGPL 2.1, please see LICENSE for details #* https://www.gnu.org/licenses/lgpl-2.1.html import os import chigger names = ['default', 'coolwarm', 'grayscale', 'rainbow', 'jet', 'shock', 'viridis', 'inferno', 'magma', 'plasma', 'Blues', 'Greens', 'Reds'] for name in names: fname = os.path.realpath(os.path.join('..', 'icons', 'colormaps', name + ".png")) colorbar = chigger.misc.ColorBar(cmap=name, location='top', width=1.02, length=1.01, colorbar_origin=[0,0]) window = chigger.RenderWindow(colorbar, size=[400, 200]) window.write(fname)
viewport=[0, 0, 1, 0.5], camera=camera, variable='permeability', range=[8.5e-10, 1.5e-9], cmap='viridis') cbar = chigger.exodus.ExodusColorBar(pressure, permeability, length=0.6, viewport=[0, 0, 1, 1], colorbar_origin=[0.2, 0.5], location='top') cbar.setOptions('primary', title='Pressure (Pa)', font_size=48, font_color=[0, 0, 0]) cbar.setOptions('secondary', title='Permeability (1e-9)', font_size=48, axis_scale=1e9, font_color=[0, 0, 0]) window = chigger.RenderWindow(pressure, permeability, cbar, size=[1920, 1080], motion_factor=0.1, background=[1, 1, 1]) window.write('step03b_result.png') window.start()
#!/usr/bin/env python3 #pylint: disable=missing-docstring #* This file is part of the MOOSE framework #* https://www.mooseframework.org #* #* All rights reserved, see COPYRIGHT for full restrictions #* https://github.com/idaholab/moose/blob/master/COPYRIGHT #* #* Licensed under LGPL 2.1, please see LICENSE for details #* https://www.gnu.org/licenses/lgpl-2.1.html import chigger transform = chigger.filters.TransformFilter(scale=[3, 1, 1]) reader = chigger.exodus.ExodusReader('../input/step10_micro_out.e') mug = chigger.exodus.ExodusResult(reader, variable='phi', cmap='viridis', filters=[transform]) window = chigger.RenderWindow(mug, size=[300, 300], style='interactive2D', test=True) window.write('scale_2d.png') window.start()
#!/usr/bin/env python #pylint: disable=missing-docstring ################################################################# # DO NOT MODIFY THIS HEADER # # MOOSE - Multiphysics Object Oriented Simulation Environment # # # # (c) 2010 Battelle Energy Alliance, LLC # # ALL RIGHTS RESERVED # # # # Prepared by Battelle Energy Alliance, LLC # # Under Contract No. DE-AC07-05ID14517 # # With the U. S. Department of Energy # # # # See COPYRIGHT for full restrictions # ################################################################# import chigger reader = chigger.exodus.ExodusReader('../input/mug_blocks_out.e') mug = chigger.exodus.ExodusResult(reader) window = chigger.RenderWindow(size=[300, 300], gradient_background=True, background=[0.5, 0.5, 0], background2=[0.05, 0.05, 0], test=True) window.write('gradient.png') window.start()
#!/usr/bin/env python2 #pylint: disable=missing-docstring #* This file is part of the MOOSE framework #* https://www.mooseframework.org #* #* All rights reserved, see COPYRIGHT for full restrictions #* https://github.com/idaholab/moose/blob/master/COPYRIGHT #* #* Licensed under LGPL 2.1, please see LICENSE for details #* https://www.gnu.org/licenses/lgpl-2.1.html import chigger reader = chigger.exodus.ExodusReader('../input/mug_blocks_out.e') mug = chigger.exodus.ExodusResult(reader) window = chigger.RenderWindow(size=[300, 300], background=[0.5, 0.5, 0], test=True) window.write('background.png') window.start()
#* https://github.com/idaholab/moose/blob/master/COPYRIGHT #* #* Licensed under LGPL 2.1, please see LICENSE for details #* https://www.gnu.org/licenses/lgpl-2.1.html import chigger # Create a graph graph = chigger.graphs.Graph(xaxis={'lim':[0,10], 'num_ticks':3, 'title':'x'}, yaxis={'lim':[0,30], 'num_ticks':5, 'title':'y'}, color_scheme='citrus', legend={'visible':False}) # Generate data x = range(0,10) y0 = range(0,10) y1 = range(0,20,2) y2 = range(0,30,3) # Create line objects line0 = chigger.graphs.Line(x, y0, label='y0') line1 = chigger.graphs.Line(x, y1, label='y1') line2 = chigger.graphs.Line(x, y2, label='y2') # Add lines to graph graph.setOptions(lines=[line0, line1, line2]) # Window window = chigger.RenderWindow(graph, size=[500, 250], test=True) window.write('color.png') window.start()
import vtk import chigger name = 'cube.e' name = 'tiled_mesh_test_in.e' if name == 'cube.e': out = 'tiled_mesh_input.png' else: out = 'tiled_mesh_output.png' camera = vtk.vtkCamera() camera.SetViewUp(-0.2136, 0.8540, -0.4745) camera.SetPosition(23.7499, 21.0876, 27.5908) camera.SetFocalPoint(4.9242, 4.2034, 5.6789) reader = chigger.exodus.ExodusReader(name) result = chigger.exodus.ExodusResult(reader, camera=camera, color=[0,0.85,0.85], edges=True, edge_color=[0,0,0]) extents = chigger.misc.VolumeAxes(result) extents.setOptions('xaxis', color=[0, 0, 0], minor_ticks=True) extents.setOptions('yaxis', color=[0, 0, 0], minor_ticks=True) extents.setOptions('zaxis', color=[0, 0, 0], minor_ticks=True) window = chigger.RenderWindow(result, extents, antialiasing=5) window.setOptions(size=[600,600], background=[0.7058823529411765, 0.7058823529411765, 0.7058823529411765], background2=[0.43529411764705883, 0.43529411764705883, 0.43529411764705883], gradient_background=True) window.update() window.resetCamera() window.write(out) #window.start() #print '\n'.join(chigger.utils.print_camera(result.getVTKRenderer().GetActiveCamera()))
#!/usr/bin/env python #pylint: disable=missing-docstring #* This file is part of the MOOSE framework #* https://www.mooseframework.org #* #* All rights reserved, see COPYRIGHT for full restrictions #* https://github.com/idaholab/moose/blob/master/COPYRIGHT #* #* Licensed under LGPL 2.1, please see LICENSE for details #* https://www.gnu.org/licenses/lgpl-2.1.html import chigger line0 = chigger.geometric.LineSource(color=[0.5,0.5,0.5]) line1 = chigger.geometric.LineSource(point1=[1,0,0], point2=[0,1,0], color=[1,0.5,0.5]) result = chigger.base.ChiggerResult(line0, line1) window = chigger.RenderWindow(result, size=[300,300], test=True) window.write('line_source.png') window.start()
#!/usr/bin/env python #pylint: disable=missing-docstring ################################################################# # DO NOT MODIFY THIS HEADER # # MOOSE - Multiphysics Object Oriented Simulation Environment # # # # (c) 2010 Battelle Energy Alliance, LLC # # ALL RIGHTS RESERVED # # # # Prepared by Battelle Energy Alliance, LLC # # Under Contract No. DE-AC07-05ID14517 # # With the U. S. Department of Energy # # # # See COPYRIGHT for full restrictions # ################################################################# import chigger reader = chigger.exodus.ExodusReader('../input/displace.e', displacement_magnitude=2) exodus = chigger.exodus.ExodusResult(reader, color=[0, 0, 1]) exodus.setOptions('colorbar', visible=False) window = chigger.RenderWindow(exodus, size=[300, 300], test=True) reader.update() times = reader.getTimes() for i in range(4): reader.setOptions(timestep=None, time=times[i]) window.write('displacement_mag_' + str(i) + '.png') window.start()