Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
fnrizzi committed Jun 14, 2023
2 parents 14e4a50 + 2972c27 commit 86aedf3
Show file tree
Hide file tree
Showing 2,213 changed files with 1,030,838 additions and 256 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/test-all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ jobs:
BUILD_DIR: /home/runner/work/build/pressio-tutorials

steps:
- uses: actions/checkout@v2 # check out the repository with submodules
with: { submodules: recursive }
- uses: actions/checkout@v2

- name: Install packages
run: |
Expand Down
6 changes: 0 additions & 6 deletions .gitmodules

This file was deleted.

47 changes: 41 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,55 @@
cmake_minimum_required(VERSION 3.18.0)
project(pressio-tutorials CXX)

function(get_version_number PATH_TO_FILE OUT)
file(READ ${PATH_TO_FILE} tmpver)

string(FIND ${OUT} MAJOR wantMajor)
string(FIND ${OUT} MINOR wantMinor)
string(FIND ${OUT} PATCH wantPatch)
if (wantMajor GREATER -1)
string(REGEX MATCH "VERSION_MAJOR ([0-9]*)" _ ${tmpver})
endif()
if (wantMinor GREATER -1)
string(REGEX MATCH "VERSION_MINOR ([0-9]*)" _ ${tmpver})
endif()
if (wantPatch GREATER -1)
string(REGEX MATCH "VERSION_PATCH ([0-9]*)" _ ${tmpver})
endif()
set(${OUT} ${CMAKE_MATCH_1} PARENT_SCOPE)
endfunction()


#===================================================
# versioning info
#===================================================

get_version_number("version.txt" PressioTutorials_VERSION_MAJOR)
get_version_number("version.txt" PressioTutorials_VERSION_MINOR)
get_version_number("version.txt" PressioTutorials_VERSION_PATCH)
set(PressioTutorials_VERSION "${PressioTutorials_VERSION_MAJOR}.${PressioTutorials_VERSION_MINOR}.${PressioTutorials_VERSION_PATCH}")
message("pressio-tutorials version = ${PressioTutorials_VERSION}")

set(pressio_version ${CMAKE_CURRENT_SOURCE_DIR}/tpls/pressio/version.txt)
get_version_number(${pressio_version} MyPressio_VERSION_MAJOR)
get_version_number(${pressio_version} MyPressio_VERSION_MINOR)
get_version_number(${pressio_version} MyPressio_VERSION_PATCH)
message("pressio version = ${MyPressio_VERSION_MAJOR}.${MyPressio_VERSION_MINOR}.${MyPressio_VERSION_PATCH}")

#===================================================
# c++ standard
#===================================================
# commands to test if compiler supports standard
include(CheckCXXCompilerFlag)
check_cxx_compiler_flag("-std=c++14" COMPILER_SUPPORT_CPP14)
if(NOT COMPILER_SUPPORT_CPP14)
message(FATAL_ERROR "Compiler does not support -std=c++14. This is required.")
check_cxx_compiler_flag("-std=c++17" COMPILER_SUPPORT_CPP17)
if(NOT COMPILER_SUPPORT_CPP17)
message(FATAL_ERROR "Compiler does not support -std=c++17. This is required.")
endif()
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

enable_testing()
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/end-to-end-roms)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/ode-using-eigen-types)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/nonlinearsolvers-using-eigen-types)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/ode-using-eigen-types)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/end-to-end-roms)
29 changes: 14 additions & 15 deletions docs/source/build.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,41 +9,40 @@ What you need

- **CMake > 3.18.0**

- **C++14 compiler**: `our CI <https://github.com/Pressio/pressio-tutorials/blob/develop/.github/workflows/test-all.yml>`__ is currently testing both GCC and Clang
- **C++17 compiler**: GCC or Clang are tested in our CI

- Python 3.x with specific packages listed `here <../../py_requirements.txt>`__
- Python 3.x

Steps
-----

.. code-block:: bash
git clone --recursive [email protected]:Pressio/pressio-tutorials.git
git clone [email protected]:Pressio/pressio-tutorials.git
export CXX=<fullpath-to-your-CXX-compiler>
export BUILDDIR=$HOME/tutorialBuild
mkdir $BUILDDIR
cmake -DCMAKE_BUILD_TYPE=Release -S <path-to-your-cloned-repo> -B $BUILDDIR
cmake -DPRESSIOTUTORIALS_ENABLE_TESTS=ON \
-DCMAKE_BUILD_TYPE=Release -S <path-to-your-cloned-repo> -B $BUILDDIR
cd $BUILDDIR && make -j4
# if needed, the Python packages can be installed as
# ensure you have all required Python packages installed
pip3 install <path-to-your-cloned-repo>/py_requirements.txt
Then what?
----------

Individual executables and the end-to-end demos can be found inside the build directory.
Verify the build
----------------

.. tip::
.. code-block:: cpp
If you want to verify the build, you can enable tests via ``-DPRESSIOTUTORIALS_ENABLE_TESTS=ON``,
and then do:
cd $BUIlDDIR
ctest
.. code-block:: cpp
Then what?
----------

cd $BUIlDDIR
ctest
Individual executables and the end-to-end demos can be found inside the build directory.


More details on dependencies
Expand Down
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
project = "pressio-tutorials"
copyright = u"2021, National Technology & Engineering Solutions of Sandia, LLC (NTESS)"

version = "0.13.0"
version = "0.14.0"

# The full version, including alpha/beta/rc tags.
release = version
Expand Down
20 changes: 5 additions & 15 deletions docs/source/endtoend/readthisfirst.rst
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
Start reading here
==================

This section offers a suite of end-to-end tutorials/demos covering
some of the key ROM methods implemented in pressio.

Why doing this?
---------------

Describing how to use pressio for ROMs cannot be simply
boiled down to presenting the API, because setting up, running
and processing a ROM involves several steps.
Expand All @@ -20,17 +14,13 @@ automating (to some extent) the execution.
Key features
------------

- each demo is fully documented in a step by step manner (see `here for example <swe_galerkin_default.html>`__) to show how to run each step

- each demo has an associated yaml workflow file,
organized into several section each with a specific scope
- each demo is documented in a step-by-step manner (see `example <swe_galerkin_default.html>`__)

- all `driver scripts <https://github.com/Pressio/pressio-tutorials/tree/develop/end-to-end-roms>`__
are written in Python and are designed to be easy to run
- each demo is defined via a yaml workflow file (`example <swe_galerkin_default.html#workflow-file>`__),
which is used by the `driver scripts <https://github.com/Pressio/pressio-tutorials/tree/develop/end-to-end-roms>`__ we provide to execute that demo

- one can easily extend the framework by adding new ROM methods
in pressio or account for variations
in how each step is run
- one can easily extend the framework by adding new ROM methods in pressio or account
for variations in how each step is run

- pressio-demoapps: for the end-to-end demos we rely on pressio-demoapps,
which have built-in support for the sample mesh.
Expand Down
42 changes: 25 additions & 17 deletions docs/source/endtoend/swe_galerkin_default.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,29 @@
2D SWE: default Galerkin
========================

- ROM technique: default Galerkin
- ROM technique: default Galerkin

- problem: `2D shallow water equations (SWE) <https://pressio.github.io/pressio-demoapps/swe_2d.html>`_
- problem: `2D shallow water equations (SWE) <https://pressio.github.io/pressio-demoapps/swe_2d.html>`_


Prerequisites
-------------

- A valid build of the tutorials, see `here <../build.html>`__, and the following env variables set:
- A valid build of the tutorials, see `here <../build.html>`__

- The following env variables MUST be set:

.. code-block:: bash
export REPOSRC=<full-path-to-the-pressio-tutorials-source-repo>/end-to-end-roms
export BUILDDIR=<full-path-to-where-you-built-the-tutorials>
- To run all scripts below, you MUST be in the correct end-to-end directory:
.. admonition:: To run the demo scripts below, you MUST be inside the correct directory:
:class: important

.. code-block:: bash
.. code-block:: bash
cd $BUILDDIR/end-to-end-roms/2d_swe_galerkin_default
cd $BUILDDIR/end-to-end-roms/2d_swe_galerkin_default
Workflow File
Expand All @@ -35,7 +38,7 @@ copied to the build directory, so you don't need to do anything:
.. literalinclude:: ../../../end-to-end-roms/2d_swe_galerkin_default/wf.yaml
:language: yaml
:lines: 1-35

:linenos:

Step 1: execute FOMs
--------------------
Expand All @@ -48,12 +51,15 @@ Step 1: execute FOMs
This driver script automates this first stage by creating input files,
generating run directories and running the C++ executable
to generate all the FOM train and test data at the points specified
in the yaml file. For exposition purposes, we show below the actual
C++ code executed during this stage to run a single FOM:
in the yaml file.

.. literalinclude:: ../../../end-to-end-roms/cpp/run_fom_explicit.hpp
:language: cpp
:lines: 56-76
..
For exposition purposes, we show below the actual
C++ code executed during this stage to run a single FOM:
.. literalinclude:: ../../../end-to-end-roms/cpp/run_fom_explicit.hpp
:language: cpp
:lines: 56-76

At the end, doing ``tree -L 1 .`` should produce:

Expand Down Expand Up @@ -107,12 +113,14 @@ Step 3: galerkin rom
This driver script automates all the Galerkin runs.
Specifically, it creates all the run directories, writes all input files,
prepares initial conditions and runs the actual Galerkin run at every test point.
For exposition purposes, we show below the actual
C++ code executed during this stage to run a single Galerkin run:

.. literalinclude:: ../../../end-to-end-roms/cpp/run_default_galerkin.hpp
:language: cpp
:lines: 57-79, 82-87, 92
..
For exposition purposes, we show below the actual
C++ code executed during this stage to run a single Galerkin run:
.. literalinclude:: ../../../end-to-end-roms/cpp/run_default_galerkin.hpp
:language: cpp
:lines: 57-79, 82-87, 92

More specifically, what happens here is the following:

Expand Down
24 changes: 14 additions & 10 deletions docs/source/endtoend/swe_galerkin_hypred_1.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,29 @@
2D SWE: hyper-reduced Galerkin (example 1)
==========================================

- ROM technique: Hyper-reduced Galerkin with gappy POD
- ROM technique: Hyper-reduced Galerkin with gappy POD

- problem: `2D shallow water equations (SWE) <https://pressio.github.io/pressio-demoapps/swe_2d.html>`_
- problem: `2D shallow water equations (SWE) <https://pressio.github.io/pressio-demoapps/swe_2d.html>`_


Prerequisites
-------------

- A valid build of the tutorials, see `here <../build.html>`__, and the following env variables set:
- A valid build of the tutorials, see `here <../build.html>`__

- The following env variables MUST be set:

.. code-block:: bash
export REPOSRC=<full-path-to-the-pressio-tutorials-source-repo>/end-to-end-roms
export BUILDDIR=<full-path-to-where-you-built-the-tutorials>
- To run all scripts below, you MUST be in the correct end-to-end directory:
.. admonition:: To run the demo scripts below, you MUST be inside the correct directory:
:class: important

.. code-block:: bash
.. code-block:: bash
cd $BUILDDIR/end-to-end-roms/2d_swe_galerkin_hypred_1
cd $BUILDDIR/end-to-end-roms/2d_swe_galerkin_hypred_1
Workflow File
Expand Down Expand Up @@ -100,11 +103,12 @@ Step 3: galerkin rom
python3 $REPOSRC/wf_galerkin.py --wf wf.yaml
Running the Galerkin driver means the following C++ code is being executed:
..
Running the Galerkin driver means the following C++ code is being executed:
.. literalinclude:: ../../../end-to-end-roms/cpp/run_hyperreduced_galerkin.hpp
:language: cpp
:lines: 57-109, 112-121, 126
.. literalinclude:: ../../../end-to-end-roms/cpp/run_hyperreduced_galerkin.hpp
:language: cpp
:lines: 57-109, 112-121, 126

At the end, you should have the following directory structure:

Expand Down
Loading

0 comments on commit 86aedf3

Please sign in to comment.