# Catalyst 2 API C++: Documentation and architecture

**URL:** https://discourse.paraview.org/t/catalyst-2-api-c-documentation-and-architecture/8991
**Category:** In Situ Support
**Tags:** catalyst
**Created:** [February 16, 2022, 10:28pm UTC](https://discourse.paraview.org/t/catalyst-2-api-c-documentation-and-architecture/8991 "2022-02-16T22:28:10Z")
**Posts on this page:** 16
**Page:** 1

<div class="post-metadata">

### Author: ![lorak41](https://discourse.paraview.org/user_avatar/discourse.paraview.org/lorak41/32/1509_2.png) [@lorak41](https://discourse.paraview.org/u/lorak41)
#### Post date: [February 16, 2022, 10:28pm UTC](https://discourse.paraview.org/t/catalyst-2-api-c-documentation-and-architecture/8991/1 "2022-02-16T22:28:11Z")

</div>

Hello, I am new to visualization in-situ. I would like to implement it in my C++ simulation software.  
I have looked into the documentation [Catalyst — Catalyst documentation](https://catalyst-in-situ.readthedocs.io/en/latest/index.html)  
Is there a place with more detailed documentation?

Also, where can I find a process flow or system architecture on how Catalyst integrates with code and Paraview?

---

<div class="post-metadata">

### Author: ![nicolas.vuaille](https://discourse.paraview.org/user_avatar/discourse.paraview.org/nicolas.vuaille/32/5873_2.png) [@nicolas.vuaille](https://discourse.paraview.org/u/nicolas.vuaille)
#### Post date: [February 17, 2022, 8:42am UTC](https://discourse.paraview.org/t/catalyst-2-api-c-documentation-and-architecture/8991/2 "2022-02-17T08:42:16Z")

</div>

You can find some examples in [ParaView code source](https://gitlab.kitware.com/paraview/paraview/-/tree/v5.10.0/Examples/Catalyst2). They are good starting point.

---

<div class="post-metadata">

### Author: ![lorak41](https://discourse.paraview.org/user_avatar/discourse.paraview.org/lorak41/32/1509_2.png) [@lorak41](https://discourse.paraview.org/u/lorak41)
#### Post date: [February 17, 2022, 12:30pm UTC](https://discourse.paraview.org/t/catalyst-2-api-c-documentation-and-architecture/8991/3 "2022-02-17T12:30:56Z")

</div>

Examples do not say anything on how to actually run it?  
do I have to link libraries from my ParaView build? or just Catalyst2?

How do I connect with Paraview? default port 22222 will work?

---

<div class="post-metadata">

### Author: ![nicolas.vuaille](https://discourse.paraview.org/user_avatar/discourse.paraview.org/nicolas.vuaille/32/5873_2.png) [@nicolas.vuaille](https://discourse.paraview.org/u/nicolas.vuaille)
#### Post date: [February 17, 2022, 12:53pm UTC](https://discourse.paraview.org/t/catalyst-2-api-c-documentation-and-architecture/8991/4 "2022-02-17T12:53:50Z")

</div>

## Building

- no need for paraview
- MPI required
- installed version of catalyst2 required
- use CMake for configuration to find the packages

## Running

Run the generated executable with a catalyst pipeline script as parameter (can be generated from ParaView). The command is also added as a test (you can enable it in CMake and then use `ctest`).

The executable should find the correct catalyst lib to do effective computation. That’s where ParaView comes.

```auto
export CATALYST_IMPLEMENTATION_PATHS="/path/to/ParaView/lib/catalyst" 
export CATALYST_IMPLEMENTATION_NAME=paraview
./bin/CxxFullExample catalyst_pipeline.py

```

Be careful that MPI used to build the simu should be the same that MPI used by ParaView.

## Connecting

This is an option you can enable in your python script. See `Save as Catalyst script` in ParaView to enable it and optionally configure the port (but the default works).

Use `Catalyst / Connect` menu in ParaView so ParaView will hear for catalyst. Then run your simu as explained above. The configured pipeline will appears in your ParaView session.

_tip_: use `Catalyst / pause simu` menu before starting the simu, so it will be paused on the first timestep, letting you inspect what you want. Useful because the simu will close the connection when terminating. (and examples code go fast).

---

<div class="post-metadata">

### Author: ![lorak41](https://discourse.paraview.org/user_avatar/discourse.paraview.org/lorak41/32/1509_2.png) [@lorak41](https://discourse.paraview.org/u/lorak41)
#### Post date: [February 17, 2022, 1:11pm UTC](https://discourse.paraview.org/t/catalyst-2-api-c-documentation-and-architecture/8991/5 "2022-02-17T13:11:51Z")

</div>

Thank you so much for this thorough instruction!

I am not sure what do you mean about MPI. Do you mean, we should like this ?

```auto
/path/to/ParaView/bin/mpiexec

```

Currently when I execute the ./CxxFullExampleV2 I am getting this

> Loguru caught a signal: SIGSEGV  
> Stack trace:  
> 10 0x55f00158a27a ./bin/CxxFullExampleV2(+0x427a) [0x55f00158a27a]  
> 9 0x7fceb6d25bf7 \_\_libc\_start\_main + 231  
> 8 0x55f00158f942 ./bin/CxxFullExampleV2(+0x9942) [0x55f00158f942]  
> 7 0x55f00158de36 ./bin/CxxFullExampleV2(+0x7e36) [0x55f00158de36]  
> 6 0x7fceb7d5e69d catalyst\_initialize + 174  
> 5 0x7fceaf5eaec3 /home/karol/ParaView-5.10.0-MPI-Linux-Python3.9-x86\_64/lib/catalyst//libcatalyst-paraview.so(+0x9ec3) [0x7fceaf5eaec3]  
> 4 0x7fceaf3d5897 vtkInSituInitializationHelper::Initialize(unsigned long long) + 87  
> 3 0x7fceacb0cea9 vtkMPICommunicator::InitializeExternal(vtkMPICommunicatorOpaqueComm\*) + 121  
> 2 0x7fceacb0cc08 vtkMPICommunicator::InitializeNumberOfProcesses() + 40  
> 1 0x7fceb77262d7 PMPI\_Comm\_size + 55  
> 0 0x7fceb6d43040 /lib/x86\_64-linux-gnu/libc.so.6(+0x3f040) [0x7fceb6d43040]  
> ( 0.003s) [main thread] :0 FATL| Signal: SIGSEGV  
> Segmentation fault (core dumped)

---

<div class="post-metadata">

### Author: ![nicolas.vuaille](https://discourse.paraview.org/user_avatar/discourse.paraview.org/nicolas.vuaille/32/5873_2.png) [@nicolas.vuaille](https://discourse.paraview.org/u/nicolas.vuaille)
#### Post date: [February 17, 2022, 1:35pm UTC](https://discourse.paraview.org/t/catalyst-2-api-c-documentation-and-architecture/8991/6 "2022-02-17T13:35:46Z")

</div>

Problem is that distributed PV is build with a given MPI and when you build your example, it may be another, incompatible MPI.

The correct fix is to build ParaView by yourself using your version of MPI.

A workaround for testing purpose is to comment any lines related to MPI in `FEDataStructure.cxx` and in `CMakeLists.txt` (`startxPoint=0` and `endXPoint=numPoints[0]`)

---

<div class="post-metadata">

### Author: ![lorak41](https://discourse.paraview.org/user_avatar/discourse.paraview.org/lorak41/32/1509_2.png) [@lorak41](https://discourse.paraview.org/u/lorak41)
#### Post date: [February 17, 2022, 10:38pm UTC](https://discourse.paraview.org/t/catalyst-2-api-c-documentation-and-architecture/8991/7 "2022-02-17T22:38:00Z")

</div>

I followed your instructions.

catalyst\_initialize fails and returns only this

> Attempting to use an MPI routine before initializing MPICH

---

<div class="post-metadata">

### Author: ![nicolas.vuaille](https://discourse.paraview.org/user_avatar/discourse.paraview.org/nicolas.vuaille/32/5873_2.png) [@nicolas.vuaille](https://discourse.paraview.org/u/nicolas.vuaille)
#### Post date: [February 18, 2022, 9:48am UTC](https://discourse.paraview.org/t/catalyst-2-api-c-documentation-and-architecture/8991/8 "2022-02-18T09:48:50Z")

</div>

That is weird. I reproduced with the 5.10.0 release.  
But I do not have the problem with a nightly release, so something have been fixed since then.

---

<div class="post-metadata">

### Author: ![nicolas.vuaille](https://discourse.paraview.org/user_avatar/discourse.paraview.org/nicolas.vuaille/32/5873_2.png) [@nicolas.vuaille](https://discourse.paraview.org/u/nicolas.vuaille)
#### Post date: [February 18, 2022, 10:46am UTC](https://discourse.paraview.org/t/catalyst-2-api-c-documentation-and-architecture/8991/9 "2022-02-18T10:46:54Z")

</div>

Also, I just created this tip based on our discussion. Feel free to add some feedback from your experience!

> [@How to try out Catalyst2](https://discourse.paraview.org/t/how-to-try-out-catalyst2/9008):
>
> Catalyst is an in-situ framework created as a part of ParaView a few years ago. With time and use, we saw the different drawbacks of our approach and then it was decided to create a new architecture, [Catalyst2](https://catalyst-in-situ.readthedocs.io/en/latest/index.html) With this new implementation, it is: easier to implement in your simulation (less knowledges required) easier to update from a version to another (less dependencies, binary compatibility) possible to activate Steering mode, where ParaView can modify simulation parameters at runtime A…

---

<div class="post-metadata">

### Author: ![lorak41](https://discourse.paraview.org/user_avatar/discourse.paraview.org/lorak41/32/1509_2.png) [@lorak41](https://discourse.paraview.org/u/lorak41)
#### Post date: [February 18, 2022, 4:04pm UTC](https://discourse.paraview.org/t/catalyst-2-api-c-documentation-and-architecture/8991/10 "2022-02-18T16:04:32Z")

</div>

Thank you for creating these tips, it is a very good and clear start!  
The original catalyst script from the example seems to work now, but when I try to load yours `catalyst2_pipeline.py` I get this generic error:

```auto
( 1.827s) [pvbatch]vtkXOpenGLRenderWindow.:465 ERR| vtkXOpenGLRenderWindow (0x562e039aeb60): bad X server connection. DISPLAY=localhost:10.0. Aborting.
...

```

---

<div class="post-metadata">

### Author: ![nicolas.vuaille](https://discourse.paraview.org/user_avatar/discourse.paraview.org/nicolas.vuaille/32/5873_2.png) [@nicolas.vuaille](https://discourse.paraview.org/u/nicolas.vuaille)
#### Post date: [February 21, 2022, 8:48am UTC](https://discourse.paraview.org/t/catalyst-2-api-c-documentation-and-architecture/8991/11 "2022-02-21T08:48:11Z")

</div>

Can you detail your environment ? Specially which OS and is there any graphical capabilities installed on this system ?

---

<div class="post-metadata">

### Author: ![lorak41](https://discourse.paraview.org/user_avatar/discourse.paraview.org/lorak41/32/1509_2.png) [@lorak41](https://discourse.paraview.org/u/lorak41)
#### Post date: [February 21, 2022, 5:06pm UTC](https://discourse.paraview.org/t/catalyst-2-api-c-documentation-and-architecture/8991/12 "2022-02-21T17:06:18Z")

</div>

Ubuntu 18.04 and GPU GeForce RTX 2070.

---

<div class="post-metadata">

### Author: ![nicolas.vuaille](https://discourse.paraview.org/user_avatar/discourse.paraview.org/nicolas.vuaille/32/5873_2.png) [@nicolas.vuaille](https://discourse.paraview.org/u/nicolas.vuaille)
#### Post date: [February 22, 2022, 8:40am UTC](https://discourse.paraview.org/t/catalyst-2-api-c-documentation-and-architecture/8991/13 "2022-02-22T08:40:17Z")

</div>

Can you try the following please ?

- run it from command line: `./bin/pvbatch catalyst2_pipeline.py`
- load it from ParaView GUI: `File / Load State`

---

<div class="post-metadata">

### Author: ![lorak41](https://discourse.paraview.org/user_avatar/discourse.paraview.org/lorak41/32/1509_2.png) [@lorak41](https://discourse.paraview.org/u/lorak41)
#### Post date: [February 22, 2022, 10:30am UTC](https://discourse.paraview.org/t/catalyst-2-api-c-documentation-and-architecture/8991/14 "2022-02-22T10:30:52Z")

</div>

I use nightly build: ParaView-master-5.10.0-657-gbd25839943-MPI-Linux-Python3.9-x86\_64  
When I load the state in Paraview it looks all ok, a grid is loaded.  
The first command gives me segmentation fault:

```auto
Loguru caught a signal: SIGSEGV
Stack trace:
45 0x401dbf /home/karol/Downloads/ParaView-master-5.10.0-657-gbd25839943-MPI-Linux-Python3.9-x86_64/bin/pvpython-real() [0x401dbf]
44 0x7f45c85d8bf7 __libc_start_main + 231
43 0x4023aa /home/karol/Downloads/ParaView-master-5.10.0-657-gbd25839943-MPI-Linux-Python3.9-x86_64/bin/pvpython-real() [0x4023aa]
42 0x7f45c5e5d0a4 vtkPythonInterpreter::PyMain(int, char**) + 916
41 0x7f45c46d2bf0 Py_RunMain + 1936
40 0x7f45c46ae948 PyRun_SimpleFileExFlags + 376
39 0x7f45c46aca25 /home/karol/Downloads/ParaView-master-5.10.0-657-gbd25839943-MPI-Linux-Python3.9-x86_64/bin/../lib/libpython3.9.so.1.0(+0x207a25) [0x7f45c46aca25]
38 0x7f45c466831b PyEval_EvalCode + 27
37 0x7f45c46682ee PyEval_EvalCodeEx + 62
36 0x7f45c46682a2 _PyEval_EvalCodeWithName + 82
35 0x7f45c4667f09 /home/karol/Downloads/ParaView-master-5.10.0-657-gbd25839943-MPI-Linux-Python3.9-x86_64/bin/../lib/libpython3.9.so.1.0(+0x1c2f09) [0x7f45c4667f09]
34 0x7f45c4512dcb _PyEval_EvalFrameDefault + 22283
33 0x7f45c450c187 /home/karol/Downloads/ParaView-master-5.10.0-657-gbd25839943-MPI-Linux-Python3.9-x86_64/bin/../lib/libpython3.9.so.1.0(+0x67187) [0x7f45c450c187]
32 0x7f45c4512d2d _PyEval_EvalFrameDefault + 22125
31 0x7f45c45622d1 _PyFunction_Vectorcall + 177
30 0x7f45c4667f09 /home/karol/Downloads/ParaView-master-5.10.0-657-gbd25839943-MPI-Linux-Python3.9-x86_64/bin/../lib/libpython3.9.so.1.0(+0x1c2f09) [0x7f45c4667f09]
29 0x7f45c4513750 _PyEval_EvalFrameDefault + 24720
28 0x7f45c450d2a7 /home/karol/Downloads/ParaView-master-5.10.0-657-gbd25839943-MPI-Linux-Python3.9-x86_64/bin/../lib/libpython3.9.so.1.0(+0x682a7) [0x7f45c450d2a7]
27 0x7f45c4565be3 /home/karol/Downloads/ParaView-master-5.10.0-657-gbd25839943-MPI-Linux-Python3.9-x86_64/bin/../lib/libpython3.9.so.1.0(+0xc0be3) [0x7f45c4565be3]
26 0x7f45c45622d1 _PyFunction_Vectorcall + 177
25 0x7f45c4667f09 /home/karol/Downloads/ParaView-master-5.10.0-657-gbd25839943-MPI-Linux-Python3.9-x86_64/bin/../lib/libpython3.9.so.1.0(+0x1c2f09) [0x7f45c4667f09]
24 0x7f45c450f3e9 _PyEval_EvalFrameDefault + 7465
23 0x7f45c456211e _PyObject_Call + 94
22 0x7f45c45bd50b /home/karol/Downloads/ParaView-master-5.10.0-657-gbd25839943-MPI-Linux-Python3.9-x86_64/bin/../lib/libpython3.9.so.1.0(+0x11850b) [0x7f45c45bd50b]
21 0x7f458379632d /home/karol/Downloads/ParaView-master-5.10.0-657-gbd25839943-MPI-Linux-Python3.9-x86_64/lib/python3.9/site-packages/paraview/modules/vtkRemotingAnimation.so(+0x3332d) [0x7f458379632d]
20 0x7f45bd544983 vtkSMSaveAnimationExtractsProxy::SaveExtracts() + 1395
19 0x7f45bd543715 vtkSMAnimationSceneWriter::Save() + 53
18 0x7f45c2a0adcf vtkAnimationCue::Tick(double, double, double) + 511
17 0x7f45bd53ecbd vtkSMAnimationScene::TickInternal(double, double, double) + 1901
16 0x7f45bcfbc453 vtkSMViewProxy::StillRender() + 307
15 0x7f45c68e8fc5 vtkPVSessionBase::ExecuteStream(unsigned int, vtkClientServerStream const&, bool) + 53
14 0x7f45c68e9f9b vtkPVSessionCore::ExecuteStream(unsigned int, vtkClientServerStream const&, bool) + 59
13 0x7f45c68ea162 vtkPVSessionCore::ExecuteStreamInternal(vtkClientServerStream const&, bool) + 242
12 0x7f45c5c291dd vtkClientServerInterpreter::ProcessStream(vtkClientServerStream const&) + 29
11 0x7f45c5c28f3e vtkClientServerInterpreter::ProcessOneMessage(vtkClientServerStream const&, int) + 1294
10 0x7f45c5c2880d vtkClientServerInterpreter::ProcessCommandInvoke(vtkClientServerStream const&, int) + 1229
9 0x7f45c5c281a9 vtkClientServerInterpreter::CallCommandFunction(char const*, vtkObjectBase*, char const*, vtkClientServerStream const&, vtkClientServerStream&) + 345
8 0x7f45c72d8810 vtkPVRenderViewCommand(vtkClientServerInterpreter*, vtkObjectBase*, char const*, vtkClientServerStream const&, vtkClientServerStream&, void*) + 8496
7 0x7f45bcf188d1 vtkPVRenderView::StillRender() + 97
6 0x7f45bcf246ea vtkPVRenderView::Render(bool, bool) + 2106
5 0x7f45ac70bcb0 vtkXOpenGLRenderWindow::Render() + 32
4 0x7f45ac66d151 vtkOpenGLRenderWindow::Render() + 81
3 0x7f45a7c006c9 vtkRenderWindow::Render() + 169
2 0x7f45ac31a69c vtkXRenderWindowInteractor::Initialize() + 204
1 0x7f45ac01225b XSync + 27
0 0x7f45c85f6040 /lib/x86_64-linux-gnu/libc.so.6(+0x3f040) [0x7f45c85f6040]
( 1.841s) [paraview] :0 FATL| Signal: SIGSEGV

```

---

<div class="post-metadata">

### Author: ![nicolas.vuaille](https://discourse.paraview.org/user_avatar/discourse.paraview.org/nicolas.vuaille/32/5873_2.png) [@nicolas.vuaille](https://discourse.paraview.org/u/nicolas.vuaille)
#### Post date: [February 23, 2022, 8:30am UTC](https://discourse.paraview.org/t/catalyst-2-api-c-documentation-and-architecture/8991/15 "2022-02-23T08:30:18Z")

</div>

Well, no problem for me with the same binary (on archlinux), and no more idea …

As it seems unrelated to Catalyst, maybe open a new clean thread about this pvbatch issue to catch attention from other people than me …

---

<div class="post-metadata">

### Author: ![lorak41](https://discourse.paraview.org/user_avatar/discourse.paraview.org/lorak41/32/1509_2.png) [@lorak41](https://discourse.paraview.org/u/lorak41)
#### Post date: [February 23, 2022, 12:02pm UTC](https://discourse.paraview.org/t/catalyst-2-api-c-documentation-and-architecture/8991/16 "2022-02-23T12:02:17Z")

</div>

Yes, I do realize that the problem is most likely related to my machine only. I will try on another system and update you about the outcomes. Thank you so much again for all the help.
