You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Documentation and examples for saving and loading state in Paraview (#4559)
## Summary
I have added two files to
`Docs/sphinx_documentation/source/Visualization/` which can be used as
example state files in Paraview. These were generated by Paraview. I
modified the saved file paths in these by hand, as Paraview exports them
by default with the absolute path from the host machine. I have also
added documentation to
`Docs/sphinx_documentation/source/Visualization.rst` to explain how to
save state files and load them in Paraview, using these two files as
examples.
## Additional background
Undertaken as directed by Jean Sexton. Please review the added
documentation for clarity and correctness and reply with any suggested
edits.
## Checklist
The proposed changes:
- [ ] fix a bug or incorrect behavior in AMReX
- [ ] add new capabilities to AMReX
- [ ] changes answers in the test suite to more than roundoff level
- [ ] are likely to significantly affect the results of downstream AMReX
users
- [x] include documentation in the code and/or rst files, if appropriate
---------
Co-authored-by: Spencer Lamoureux <[email protected]>
To save the state of this example, go to ``File > Save State...``, and select the format, location, and name
546
+
of the state file you want to save. In order to later reload the state you've saved, see below.
547
+
548
+
Note that the ``Save State`` option will write state files containing the absolute path to the data files you have loaded.
549
+
This can cause issues if you're using state files saved on another machine, have moved your data files, or
550
+
if Paraview doesn't know which directory to look in. When loading state from a ``pvsm`` file, there are menu
551
+
options available to navigate to the data source directory. When running a Python script to load data, this can
552
+
cause an error or crash. We outline the way to avoid this below.
553
+
554
+
For demonstration purposes, we have also included state files in both formats:
555
+
:download:`slice_state1.pvsm </Visualization/slice_state1.pvsm>` and :download:`slice_state1.py </Visualization/slice_state1.py>`
556
+
557
+
558
+
Loading from a Paraview state file (.pvsm)
559
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
560
+
561
+
#. Go to ``File > Load State``, navigate to ``slice_state1.pvsm`` in the file browser and click ``OK``. A new window labeled ``Load State Options`` appears with a drop-down menu.
562
+
563
+
#. Select ``Search files under specified directory``, and click the ``...`` button to the right of the ``Data Directory`` line.
564
+
565
+
#. Navigate to ``amrex-tutorials/ExampleCodes/Basic/HeatEquation_EX1_C/Exec`` and click ``OK``. This is where the plotfiles will have been saved by default if you've built and run the example code ``HeatEquation_EX1_C``.
566
+
567
+
What you see displayed should be a 2D slice of the solution to the 3D equation.
568
+
569
+
In general, you can use the load state menu options to navigate to whichever data files you wish to load using your saved ``pvsm`` state.
570
+
571
+
572
+
Loading from a Python state file (.py)
573
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
574
+
575
+
In order to load state from a ``.py`` file, you must execute the file as a script from the Python Shell within Paraview.
576
+
577
+
#. If the Python Shell is not displayed, click the checkbox in ``View > Python Shell``.
578
+
579
+
#. Click the ``Run Script`` button to the bottom right of the Python shell, navigate to the file ``amrex/Docs/sphinx_documentation/source/Visualization/slice_state1.py`` in the file navigator, and click ``OK``.
580
+
581
+
You should see a 2D slice of the solution to the 3D heat equation. If Paraview reports
582
+
an error or crashes, see below.
583
+
584
+
Aside: Working directory in the Paraview Python shell
When you load a state from a Python script in Paraview, it will look in the current working directory of the Python shell to
588
+
resolve the paths to the data files provided in the Python script.
589
+
590
+
By default, the current working directory of the Paraview Python shell will be the directory from which you launched Paraview.
591
+
592
+
.. warning:: If your Python script makes direct reference to a set of files that can't be found from your current working directory, then running that script will result in an error, and potentially cause Paraview to crash. This can be addressed by changing the cwd of your Python shell to the proper location.
593
+
594
+
595
+
To check the cwd of the Paraview Python shell, run
596
+
597
+
.. code-block:: python
598
+
599
+
>>>import os
600
+
>>> os.getcwd()
601
+
602
+
and make sure that your cwd contains the folder you want to search in so that Python can resolve the path. To change the cwd, run
0 commit comments