> For the complete documentation index, see [llms.txt](https://wiki.solids.group/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://wiki.solids.group/alamo/paraview-with-alamo-and-hdf5.md).

# Paraview with Alamo and HDF5

With the HDF5 capability of Alamo, we can now visualize results using Paraview rather than VisIt (although we can still use VisIt if that is your preference).  However, there are some nuances:

* When opening .h5 files via the GUI, files that should be grouped in a "time series" are opened individually, thus each time step has its own pipeline for filters, etc.
* Vector variables are not automatically defined based on `x/y/z` suffixes, so each directional variable is only accessible as scalar quantities.

In order to assist with these limitations, below is a python script that will force the grouped .h5 files to load in a single time series and will automatically search for variables with `x/y/z` suffixes and build corresponding vector variables for them.

The script can used by either passing it as an argument if opening Paraview from the command line or as a macro within the GUI itself.

## Command line option

To run the script from the command line, **first enter the directory containing the Alamo output** file you wish to visualize.

`cd /path/to/celloutput.visit`

Then, assuming Paraview is accessible in `PATH` , simply open with the `--script` flag followed by the path to the Python script.

`paraview --script /path/to/paraview_load_alamo.py`&#x20;

## Macro option

To run the script as a macro, first open Paraview **from the directory containing the Alamo output** file you wish to visualize.

```
cd /path/to/celloutput.visit
paraview
```

and from the top menu select **Macros->Import new macro...**

Locate the Python script and select **Ok.**

Then once again from the top menu, select **Macros->paraview\_load\_alamo**

## paraview\_load\_alamo.py

{% code expandable="true" %}

```python
from paraview.simple import *
import re
import sys

# ------------------------------------------------------------
# Read Chombo file list from celloutput.visit
# ------------------------------------------------------------

output = "celloutput.visit"

files = []

with open(output, "r") as f:
    for line in f:
        line = line.strip()
        if line and not line.startswith("!"):
            files.append(line)


# ------------------------------------------------------------
# Create Chombo reader
# ------------------------------------------------------------

reader = VisItChomboReader(FileName=files)

reader.UpdatePipelineInformation()


# ------------------------------------------------------------
# Enable all available cell variables
# ------------------------------------------------------------

all_cell_arrays = []

try:
    cell_array_info = reader.GetProperty("CellArrayInfo")

    if cell_array_info is not None:
        all_cell_arrays = [
            cell_array_info.GetElement(i)
            for i in range(cell_array_info.GetNumberOfElements())
        ]

except Exception as e:
    print("CellArrayInfo unavailable:")
    print(e)


# Fallback
if len(all_cell_arrays) == 0:

    print("Using CellArrayStatus fallback")

    status = reader.GetProperty("CellArrayStatus")

    all_cell_arrays = [
        status.GetElement(i)
        for i in range(status.GetNumberOfElements())
    ]


if len(all_cell_arrays) == 0:
    raise RuntimeError("No cell arrays found")

reader.CellArrayStatus = all_cell_arrays

reader.UpdatePipelineInformation()


# ------------------------------------------------------------
# Detect vector components
#
# Supports:
#   velocityx velocityy velocityz
#   solid.momentumx solid.momentumy solid.momentumz
#
# Also supports:
#   velocity.x velocity.y velocity.z
#   solid.momentum.x ...
# ------------------------------------------------------------

vectors = {}

for name in all_cell_arrays:

    # Case 1: suffix x/y/z
    m = re.match(r"^(.*)(x|y|z)$", name)

    if m:
        base, component = m.groups()
        vectors.setdefault(base, {})[component] = name
        continue

    # Case 2: suffix .x/.y/.z
    m = re.match(r"^(.*)\.(x|y|z)$", name)

    if m:
        base, component = m.groups()
        vectors.setdefault(base, {})[component] = name


vector_defs = {}

for base, comps in vectors.items():

    if "x" in comps and "y" in comps:
        vector_defs[base] = comps


# ------------------------------------------------------------
# Chain Calculator filters
# ------------------------------------------------------------

current_input = reader

for vec_name, comps in vector_defs.items():

    calc = Calculator(
        Input=current_input,
        AttributeType="Cell Data",
        ResultArrayName=vec_name
    )

    if "z" in comps:

        calc.Function = (
            f'iHat*"{comps['x']}" + '
            f'jHat*"{comps['y']}" + '
            f'kHat*"{comps['z']}"'
        )

    else:

        calc.Function = (
            f'iHat*"{comps['x']}" + '
            f'jHat*"{comps['y']}"'
        )

    current_input = calc


# ------------------------------------------------------------
# Enable animation
# ------------------------------------------------------------

animation = GetAnimationScene()
animation.UpdateAnimationUsingDataTimeSteps()

timekeeper = GetTimeKeeper()


# ------------------------------------------------------------
# Convert cell data to point data
# ------------------------------------------------------------

current_input = CellDatatoPointData(Input=current_input)
current_input.UpdatePipeline()

display = Show(current_input)
display.Representation = "Surface"

SetActiveSource(current_input)
Render()

```

{% endcode %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://wiki.solids.group/alamo/paraview-with-alamo-and-hdf5.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
