diff --git a/002-Methods/003-Visualization/001-InSitu/001-Catalyst2JupyterLab-Tutorial/Catalyst_Example.ipynb b/002-Methods/003-Visualization/001-InSitu/001-Catalyst2JupyterLab-Tutorial/Catalyst_Example.ipynb index 772dc7f2fc4a045a8e0223e2770e684a234d1185..1eb84fdac0094baae300bd5a2b057a730d8964e4 100644 --- a/002-Methods/003-Visualization/001-InSitu/001-Catalyst2JupyterLab-Tutorial/Catalyst_Example.ipynb +++ b/002-Methods/003-Visualization/001-InSitu/001-Catalyst2JupyterLab-Tutorial/Catalyst_Example.ipynb @@ -24,6 +24,7 @@ "source": [ "## Table of contents\n", "\n", + "- Requirements \n", "- Start pvserver\n", "- Start Catalyst enabled simulation\n", "- Setup Render Window in Browser\n", @@ -33,6 +34,61 @@ "- Additional usefull functions for using Catalyst in Notebook" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Requirements\n", + "- The bash variable JUPYTER_LOG_DIR needs to be set to a folder, where logs can be written. It can be set, before starting jupyter by executing `export JUPYTER_LOG_DIR=\"/your/path\"` before running `jupyter-lab`. The two following lines allows to check the value that was set when starting jupyter:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "from os import environ\n", + "print(environ.get('JUPYTER_LOG_DIR'))" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Additional files are needed. They can be obtained by cloning the git repo, or copying the files in the folder `001-Catalyst2JupyterLab-Tutorial`. Afterwards the path to the folder needs to be written into the file `${JUPYTER_LAB_DIR}/catalystTutorialPath.txt`. This can be done with the following commands:\n", + "\n", + "```\n", + "git init repo j4j_notebooks\n", + "cd j4j_notebooks\n", + "git remote add origin https://gitlab.version.fz-juelich.de/jupyter4jsc/j4j_notebooks.git\n", + "git config core.sparseCheckout true\n", + "echo \"002-Methods/003-Visualization/001-InSitu/001-Catalyst2JupyterLab-Tutorial/*\" >> .git/info/sparse-checkout\n", + "git pull --depth=1 origin master\n", + "cd 002-Methods/003-Visualization/001-InSitu/001-Catalyst2JupyterLab-Tutorial/\n", + "pwd >${JUPYTER_LOG_DIR}/catalystTutorialPath.txt\n", + "```" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import glob\n", + "file = open(environ.get('JUPYTER_LOG_DIR') + \"/catalystTutorialPath.txt\",\"r\")\n", + "catalystTutorialPath = file.readline().rstrip()\n", + "file.close()\n", + "if len(catalystTutorialPath) < 30:\n", + " import sys\n", + " print(\"Path is short: '\" + catalystTutorialPath + \"' is it the right path?\", file=sys.stderr)\n", + " \n", + "if len(glob.glob(catalystTutorialPath+ \"/*\")) < 4:\n", + " import sys\n", + " print(\"Not enough files in '\" + catalystTutorialPath + \"' is it the right path?\", file=sys.stderr)" + ] + }, { "cell_type": "markdown", "metadata": {}, @@ -210,9 +266,7 @@ "simple.SetActiveSource(extract)\n", "extractDisplay = simple.Show(extract, view)\n", "\n", - "#ResetCamera(view, renderer)\n", - "view.ResetCamera()\n", - "view.CenterOfRotation = view.GetActiveCamera().GetFocalPoint()" + "ResetCamera(view, renderer)" ] }, { diff --git a/002-Methods/003-Visualization/001-InSitu/001-Catalyst2JupyterLab-Tutorial/Catalyst_Example_minimal.ipynb b/002-Methods/003-Visualization/001-InSitu/001-Catalyst2JupyterLab-Tutorial/Catalyst_Example_minimal.ipynb index 74eadb9d0e6e57201b66097931ef652c51de8cc5..6d76b151ce3fa187c656ab1575b87bbab5358526 100644 --- a/002-Methods/003-Visualization/001-InSitu/001-Catalyst2JupyterLab-Tutorial/Catalyst_Example_minimal.ipynb +++ b/002-Methods/003-Visualization/001-InSitu/001-Catalyst2JupyterLab-Tutorial/Catalyst_Example_minimal.ipynb @@ -24,12 +24,68 @@ "source": [ "## Table of contents\n", "\n", + "- Requirements \n", "- Start Catalyst enabled simulation\n", "- Setup Render Window in Browser\n", "- Establish Catalyst Connection\n", "- Setup render pipeline using ParaView Python Commands" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Requirements\n", + "- The bash variable JUPYTER_LOG_DIR needs to be set to a folder, where logs can be written. It can be set, before starting jupyter by executing `export JUPYTER_LOG_DIR=\"/your/path\"` before running `jupyter-lab`. The two following lines allows to check the value that was set when starting jupyter:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "from os import environ\n", + "print(environ.get('JUPYTER_LOG_DIR'))" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Additional files are needed. They can be obtained by cloning the git repo, or copying the files in the folder `001-Catalyst2JupyterLab-Tutorial`. Afterwards the path to the folder needs to be written into the file `${JUPYTER_LAB_DIR}/catalystTutorialPath.txt`. This can be done with the following commands:\n", + "\n", + "```\n", + "git init repo j4j_notebooks\n", + "cd j4j_notebooks\n", + "git remote add origin https://gitlab.version.fz-juelich.de/jupyter4jsc/j4j_notebooks.git\n", + "git config core.sparseCheckout true\n", + "echo \"002-Methods/003-Visualization/001-InSitu/001-Catalyst2JupyterLab-Tutorial/*\" >> .git/info/sparse-checkout\n", + "git pull --depth=1 origin master\n", + "cd 002-Methods/003-Visualization/001-InSitu/001-Catalyst2JupyterLab-Tutorial/\n", + "pwd >${JUPYTER_LOG_DIR}/catalystTutorialPath.txt\n", + "```" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import glob\n", + "file = open(environ.get('JUPYTER_LOG_DIR') + \"/catalystTutorialPath.txt\",\"r\")\n", + "catalystTutorialPath = file.readline().rstrip()\n", + "file.close()\n", + "if len(catalystTutorialPath) < 30:\n", + " import sys\n", + " print(\"Path is short: '\" + catalystTutorialPath + \"' is it the right path?\", file=sys.stderr)\n", + " \n", + "if len(glob.glob(catalystTutorialPath+ \"/*\")) < 4:\n", + " import sys\n", + " print(\"Not enough files in '\" + catalystTutorialPath + \"' is it the right path?\", file=sys.stderr)" + ] + }, { "cell_type": "markdown", "metadata": {}, @@ -45,6 +101,7 @@ "outputs": [], "source": [ "%%script bash --bg --proc catalyst_process\n", + "cd `cat ${JUPYTER_LOG_DIR}/catalystTutorialPath.txt`\n", "export OMP_NUM_THREADS=1\n", "pvpython CatalystEnabledSimulation/fedriver.py CatalystEnabledSimulation/cpscript.py > ${JUPYTER_LOG_DIR}/simulation.log 2>&1" ] @@ -145,9 +202,7 @@ "simple.SetActiveSource(extract)\n", "extractDisplay = simple.Show(extract, view)\n", "\n", - "#ResetCamera(view, renderer)\n", - "view.ResetCamera()\n", - "view.CenterOfRotation = view.GetActiveCamera().GetFocalPoint()" + "ResetCamera(view, renderer)" ] }, {