Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ParaView Catalyst in-situ visualization capability #222

Open
wants to merge 63 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
5ca50df
Add WIP CatalystAdaptor class
mirenradia Nov 19, 2021
8bf6560
Add Make.insitu
mirenradia Nov 23, 2021
2bbabed
Remove code that strips spaces in isystem flag
mirenradia Nov 25, 2021
276c3d9
Add script to cache output from paraview-config
mirenradia Nov 30, 2021
1ab1957
Add CatalystAdaptor to GRAMR
mirenradia Nov 30, 2021
2955d39
Add Catalyst parameters
mirenradia Dec 1, 2021
cd576ce
Add CatalystAdaptor::build_vtk_grid function
mirenradia Dec 1, 2021
8707946
Add CatalystAdaptor::add_vars
mirenradia Dec 1, 2021
ae6cddc
Implement CatalystAdaptor::coprocess and call it
mirenradia Dec 7, 2021
cf8069c
Modify construction of vtkOverlappingAMR
mirenradia Dec 15, 2021
8c82572
Add example Catalyst script and params file
mirenradia Dec 15, 2021
06ea334
Add Catalyst volume rendering script
mirenradia Dec 20, 2021
a95360e
Add another Catalyst volume rendering script
mirenradia Dec 21, 2021
43dd07b
Attempt to fix building of VTK grid
mirenradia Dec 22, 2021
1574003
Refactor calling of Catalyst CoProcess
mirenradia Dec 23, 2021
f88ce83
Modify Catalyst Scripts
mirenradia Dec 23, 2021
fee88cd
Update ParaView Catalyst scripts
mirenradia Jan 4, 2022
5df0a4e
Create insitu makefile target
mirenradia Jan 21, 2022
d666910
Implement catalyst_vars parameter
mirenradia Jan 25, 2022
f828470
Add support for multiple Catalyst scripts
mirenradia Feb 3, 2022
f3d9c37
Make VTK/Catalyst log to a pout file
mirenradia Feb 4, 2022
502c025
Use vtkLogger function to cast int to verbosity
mirenradia Feb 7, 2022
9e9ec91
Add Catalyst Insitu readme
mirenradia Feb 7, 2022
ce6528d
Add more instructions to Catalyst readme
mirenradia Feb 7, 2022
4f6d9fb
Add minor changes to Insitu readme
mirenradia Feb 8, 2022
76603c8
Add parameter to abort on catalyst error
mirenradia Feb 9, 2022
2df36c9
Fix Make.insitu when PARAVIEW_DIR is not set
mirenradia Feb 11, 2022
63b4a70
Fix incorrect casting from IntVect to RealVect
mirenradia Feb 14, 2022
774340d
Add user to include extra VTK/ParaVIew components
mirenradia Feb 16, 2022
951b69e
Add Catalyst Insitu test
mirenradia Feb 16, 2022
d36b883
Fix CatalystAdaptor bug with no diagnostic vars
mirenradia Feb 16, 2022
6b0344d
Fix various problems with CatalystInsituTest
mirenradia Feb 16, 2022
9bc6a0e
Make ParaView version checking more portable
mirenradia Feb 16, 2022
59dd99a
Make Catalyst aware of the output_path parameter
mirenradia Feb 18, 2022
1b9c294
Add catalyst_remove_ghosts parameter
mirenradia Mar 11, 2022
518c653
Fix dimensions of vtkAMRBox
mirenradia Mar 14, 2022
02d5a3c
Add support for ParaView v5.8
mirenradia Mar 17, 2022
468e59e
Fix issues with Catalyst v2.0 scripts
mirenradia Mar 21, 2022
352ee3c
Make VTK use the same number of threads as GRChombo
mirenradia Mar 21, 2022
6395ba8
Make preCatalystCoProcess fill ghosts by default
mirenradia Apr 6, 2022
27b8951
Add GitHub action to run Catalyst Insitu test
mirenradia Apr 25, 2022
1b35751
Fix potential segfault with BinaryBH example
mirenradia May 18, 2022
8b6ee34
Pass ghost cell info to Catalyst
mirenradia May 18, 2022
59a5022
Add ability to write VTK XML files from Catalyst
mirenradia May 19, 2022
5cedc26
Initialize `vtkUniformGrid`s from `vtkAMRBox`s
mirenradia May 19, 2022
a2bc9fa
Refactor Catalyst parameter code
mirenradia May 25, 2022
362ff95
Add VTK XML file parameters
mirenradia May 25, 2022
068c213
Make CatalystInsituTest check PNG is modified
mirenradia May 25, 2022
69c3755
Fix incorrect comparison on file modification time
mirenradia May 26, 2022
49628de
Delete generated PNG at start of CatalystInsituTest
mirenradia May 27, 2022
7d81232
Fix slice visualization artifacts
mirenradia Sep 20, 2022
64cf4ad
Fix parameter name typo
mirenradia Sep 20, 2022
5698b55
Fix segfault due to vtkOverlappingAMR reallocation
mirenradia Oct 27, 2022
3a3eed0
Make make exit earlier if there are Catalyst problems
mirenradia Dec 7, 2022
800deed
Fix in-situ building with old Make versions
mirenradia Dec 8, 2022
5b6d28f
Make GitHub action use latest ParaView version
mirenradia Dec 9, 2022
15851dd
Update Catalyst README
mirenradia Jan 16, 2023
e78dee1
Add passing of GRChombo parameters to Catalyst
mirenradia Jan 17, 2023
7ada53b
Remove old Catalyst scripts
mirenradia Feb 3, 2023
8974a0c
Clean up example Catalyst scripts
mirenradia Feb 3, 2023
d84a86a
Update Catalyst insitu action and clang-format
mirenradia Feb 7, 2023
cee3031
Fix compilation with old VTK versions
mirenradia Feb 14, 2023
d084a76
Fix buffer overflow warning
mirenradia Feb 15, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 94 additions & 0 deletions .github/workflows/run-catalyst-insitu-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
name: Run Catalyst Insitu test

on: [push]

jobs:
build-and-test:
runs-on: ubuntu-22.04
env:
CHOMBO_HOME: ${{ github.workspace }}/Chombo/lib
PARAVIEW_SUPERBUILD_DIR: ${{ github.workspace }}/build
PARAVIEW_DIR: ${{ github.workspace }}/build/install
OMP_NUM_THREADS: 1

steps:
- name: Checkout Chombo
uses: actions/checkout@v3
with:
repository: GRChombo/Chombo
path: Chombo

- name: Checkout GRChombo
uses: actions/checkout@v3
with:
path: GRChombo

- name: Install Chombo dependencies
run: |
# First update package repository mirrors
sudo gem install apt-spy2
sudo apt-spy2 check
sudo apt-spy2 fix --commit
sudo apt-get update
sudo apt-get -y --no-install-recommends install csh libhdf5-dev libhdf5-openmpi-dev openmpi-bin libblas-dev liblapack-dev libgetopt-complete-perl

- name: Set Compilers
run: |
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-12 120
sudo update-alternatives --install /usr/bin/gfortran gfortran /usr/bin/gfortran-12 120
sudo update-alternatives --install /usr/bin/cpp cpp /usr/bin/cpp-12 120

- name: Build Chombo
run: |
cp $GITHUB_WORKSPACE/GRChombo/InstallNotes/MakeDefsLocalExamples/ubuntu-gcc.Make.defs.local $CHOMBO_HOME/mk/Make.defs.local
make -j 4 AMRTimeDependent AMRTools BaseTools BoxTools
working-directory: ${{ env.CHOMBO_HOME }}

- name: Install ParaView dependencies
run: |
sudo apt-get update
sudo apt-get -y install build-essential libgl1-mesa-dev \
libxt-dev python3-dev python3-numpy libopenmpi-dev libtbb-dev \
ninja-build libosmesa6 libosmesa6-dev llvm-14-dev
sudo update-alternatives --install /usr/bin/llvm-config llvm-config /usr/bin/llvm-config-14 14

# There is a problem with the paraview-config script with CMake v3.23
# (see https://gitlab.kitware.com/paraview/paraview/-/issues/21361)
- name: Downgrade CMake
env:
CMAKE_VERSION: 3.22.6
run: |
wget https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/cmake-${CMAKE_VERSION}-linux-x86_64.sh
chmod +x cmake-${CMAKE_VERSION}-linux-x86_64.sh
sudo ./cmake-${CMAKE_VERSION}-linux-x86_64.sh --prefix=/usr/local --exclude-subdir

- name: Download pre-built ParaView
uses: dsaltares/fetch-gh-release-asset@master
with:
repo: "GRChombo/paraview-build"
version: latest
regex: true
file: "paraview-v.*.tar.gz"

- name: Untar ParaView
run: |
mkdir -p $PARAVIEW_DIR
cd $PARAVIEW_DIR
ls $GITHUB_WORKSPACE
tar -xzvf $GITHUB_WORKSPACE/paraview-v*.tar.gz

- name: Build Catalyst Insitu test
run: make test -j 4
working-directory: ${{ github.workspace }}/GRChombo/Tests/CatalystInsituTest

- name: Run Catalyst Insitu test
run: make run
working-directory: ${{ github.workspace }}/GRChombo/Tests/CatalystInsituTest

- name: Upload output files if test failed
if: failure()
uses: actions/upload-artifact@v3
with:
name: CatalystInsituTest-pouts
path: ${{ github.workspace }}/GRChombo/Tests/CatalystInsituTest/pout.*
if-no-files-found: warn
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,9 @@ time.table.*
ipo_out.optrpt

Doxygen/html

# ParaView Catalyst
catalyst_pout.*
*.png
*.jpg
datasets/*
15 changes: 13 additions & 2 deletions Examples/BinaryBH/BinaryBHLevel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,21 @@ void BinaryBHLevel::specificPostTimeStep()
// called during setup at t=0 from Main
// bool first_step = (m_time == m_dt); // if not called in Main

if (m_p.activate_extraction == 1)
if (m_p.activate_extraction
#ifdef USE_CATALYST
|| m_p.catalyst_activate
#endif
)
{
int min_level = m_p.extraction_params.min_extraction_level();
int min_level = (m_p.activate_extraction)
? m_p.extraction_params.min_extraction_level()
: -1;
bool calculate_weyl = at_level_timestep_multiple(min_level);
#ifdef USE_CATALYST
calculate_weyl |=
(m_p.catalyst_activate &&
at_level_timestep_multiple(m_p.catalyst_coprocess_level));
#endif
if (calculate_weyl)
{
// Populate the Weyl Scalar values on the grid
Expand Down
4 changes: 4 additions & 0 deletions Examples/BinaryBH/GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,8 @@ ifeq ($(USE_TWOPUNCTURES),TRUE)
src_dirs += $(TWOPUNCTURES_SOURCE)
endif

# ParaView Catalyst insitu visualisation
# Set PARAVIEW_DIR environment variable to use
include $(GRCHOMBO_SOURCE)/Insitu/Make.insitu

include $(CHOMBO_HOME)/mk/Make.test
8 changes: 7 additions & 1 deletion Examples/BinaryBH/Main_BinaryBH.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,17 @@ int runGRChombo(int argc, char *argv[])

std::chrono::time_point<Clock> start_time = Clock::now();

// Add a scheduler to call specificPostTimeStep on every AMRLevel at t=0
// Add a scheduler to call specificPostTimeStep and catalystCoProcess
// on every AMRLevel at t=0
auto task = [](GRAMRLevel *level)
{
if (level->time() == 0.)
{
level->specificPostTimeStep();
#ifdef USE_CATALYST
level->catalystCoProcess();
#endif
}
};
// call 'now' really now
MultiLevelTaskPtr<> call_task(task);
Expand Down
141 changes: 141 additions & 0 deletions Examples/BinaryBH/catalyst_scripts/slice_center_z_amr_blocks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
# script-version: 2.0
# Catalyst state generated using paraview version 5.11.0

# This script takes a slice through the center of the domain of constant z,
# renders an outline of the blocks in the domain and saves the result to a PNG

# Import this to get environment variables
import os

#### import the simple module from the paraview
from paraview.simple import *
#### disable automatic camera reset on 'Show'
paraview.simple._DisableFirstRenderCameraReset()

# Get center from environment
grchombo_center_str = os.getenv('GRCHOMBO_PARAM_CENTER')
grchombo_center = [float(dim) for dim in grchombo_center_str.split(' ')]

# ----------------------------------------------------------------
# setup views used in the visualization
# ----------------------------------------------------------------

# get the material library
materialLibrary1 = GetMaterialLibrary()

# Create a new 'Render View'
renderView1 = CreateView('RenderView')
renderView1.ViewSize = [928, 789]
renderView1.AxesGrid = 'GridAxes3DActor'
renderView1.CenterOfRotation = grchombo_center
renderView1.StereoType = 'Crystal Eyes'
renderView1.CameraPosition = [grchombo_center[0], grchombo_center[1], 500.0]
renderView1.CameraFocalPoint = grchombo_center
renderView1.CameraFocalDisk = 1.0
renderView1.CameraParallelScale = 49.50757517794625
renderView1.BackEnd = 'OSPRay raycaster'
renderView1.OSPRayMaterialLibrary = materialLibrary1

# init the 'GridAxes3DActor' selected for 'AxesGrid'
renderView1.AxesGrid.Visibility = 1

SetActiveView(None)

# ----------------------------------------------------------------
# setup view layouts
# ----------------------------------------------------------------

# create new layout object 'Layout #1'
layout1 = CreateLayout(name='Layout #1')
layout1.AssignView(0, renderView1)
layout1.SetSize(928, 789)

# ----------------------------------------------------------------
# restore active view
SetActiveView(renderView1)
# ----------------------------------------------------------------

# ----------------------------------------------------------------
# setup the data processing pipelines
# ----------------------------------------------------------------

# create source
input = AMRGaussianPulseSource(registrationName='input')
input.MeshStatus = ['Mesh']
input.CellArrayStatus = []

# create a new 'Slice'
slice1 = Slice(registrationName='Slice1', Input=input)
slice1.SliceType = 'Plane'
slice1.HyperTreeGridSlicer = 'Plane'
slice1.SliceOffsetValues = [0.0]

# init the 'Plane' selected for 'SliceType'
slice1.SliceType.Origin = grchombo_center
slice1.SliceType.Normal = [0.0, 0.0, 1.0]

# init the 'Plane' selected for 'HyperTreeGridSlicer'
slice1.HyperTreeGridSlicer.Origin = grchombo_center

# ----------------------------------------------------------------
# setup the visualization in view 'renderView1'
# ----------------------------------------------------------------

# show data from slice1
slice1Display = Show(slice1, renderView1, 'GeometryRepresentation')

# trace defaults for the display properties.
slice1Display.Representation = 'Outline'
slice1Display.ColorArrayName = [None, '']
slice1Display.SelectTCoordArray = 'None'
slice1Display.SelectNormalArray = 'None'
slice1Display.SelectTangentArray = 'None'
slice1Display.OSPRayScaleFunction = 'PiecewiseFunction'
slice1Display.SelectOrientationVectors = 'None'
slice1Display.ScaleFactor = 7.0
slice1Display.SelectScaleArray = 'None'
slice1Display.GlyphType = 'Arrow'
slice1Display.GlyphTableIndexArray = 'None'
slice1Display.GaussianRadius = 0.35000000000000003
slice1Display.SetScaleArray = [None, '']
slice1Display.ScaleTransferFunction = 'PiecewiseFunction'
slice1Display.OpacityArray = [None, '']
slice1Display.OpacityTransferFunction = 'PiecewiseFunction'
slice1Display.DataAxesGrid = 'GridAxesRepresentation'
slice1Display.PolarAxes = 'PolarAxesRepresentation'
slice1Display.SelectInputVectors = [None, '']
slice1Display.WriteLog = ''

# ----------------------------------------------------------------
# setup extractors
# ----------------------------------------------------------------

# create extractor
pNG1 = CreateExtractor('PNG', renderView1, registrationName='PNG1')
# trace defaults for the extractor.
pNG1.Trigger = 'TimeStep'

# init the 'PNG' selected for 'Writer'
pNG1.Writer.FileName = 'SliceAMRBlocks_{timestep:06d}{camera}.png'
pNG1.Writer.ImageResolution = [2048, 1536]
pNG1.Writer.Format = 'PNG'
pNG1.Writer.ResetDisplay = 1

# ----------------------------------------------------------------
# restore active source
SetActiveSource(pNG1)
# ----------------------------------------------------------------

# ------------------------------------------------------------------------------
# Catalyst options
from paraview import catalyst
options = catalyst.Options()
options.GlobalTrigger = 'TimeStep'
options.CatalystLiveTrigger = 'TimeStep'

# ------------------------------------------------------------------------------
if __name__ == '__main__':
from paraview.simple import SaveExtractsUsingCatalystOptions
# Code for non in-situ environments; if executing in post-processing
# i.e. non-Catalyst mode, let's generate extracts using Catalyst options
SaveExtractsUsingCatalystOptions(options)
Loading