Skip to content

Commit d0db686

Browse files
author
Francesco Rizzi
committed
improve tutorials and ci and docs
1 parent 919b83a commit d0db686

File tree

24 files changed

+406
-100
lines changed

24 files changed

+406
-100
lines changed

.github/workflows/test-all.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,3 +103,10 @@ jobs:
103103
run: |
104104
cd $BUILD_DIR
105105
ctest
106+
107+
- name: Run demos
108+
run: |
109+
cd $BUILD_DIR/ode-using-eigen-types
110+
bash runall_for_ci.sh
111+
cd ../nonlinearsolvers-using-eigen-types
112+
bash runall_for_ci.sh

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@ set(CMAKE_CXX_EXTENSIONS OFF)
1717

1818
enable_testing()
1919
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/end-to-end-roms)
20-
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/ode-eigen)
21-
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/solvers-eigen)
20+
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/ode-using-eigen-types)
21+
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/nonlinearsolvers-using-eigen-types)

docs/source/build.rst

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,19 @@
22
Build instructions
33
##################
44

5-
The pressio tutorials are designed to be easy and quick to build.
6-
Thefore, all C++ dependencies **are already snapshotted inside the repo**,
7-
and to build the code you ONLY need **CMake > 3.18.0** and a **C++14 compliant compiler**.
5+
These tutorials should be easy and quick to build, follow below.
6+
7+
What you need
8+
-------------
9+
10+
- **CMake > 3.18.0**
11+
12+
- **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
13+
14+
- Python 3.x with specific packages listed `here <../../py_requirements.txt>`__
15+
16+
Steps
17+
-----
818

919
.. code-block:: bash
1020
@@ -16,29 +26,32 @@ and to build the code you ONLY need **CMake > 3.18.0** and a **C++14 compliant c
1626
cmake -DCMAKE_BUILD_TYPE=Release -S <path-to-your-cloned-repo> -B $BUILDDIR
1727
cd $BUILDDIR && make -j4
1828
19-
Executables for all tutorials and the end-to-end demos
20-
can be found inside the build directory.
29+
# if needed, the Python packages can be installed as
30+
pip3 install <path-to-your-cloned-repo>/py_requirements.txt
31+
32+
33+
Then what?
34+
----------
35+
36+
Individual executables and the end-to-end demos can be found inside the build directory.
2137

2238
.. tip::
2339

24-
To verify the build, you can enable the tests using ``-DPRESSIOTUTORIALS_ENABLE_TESTS=ON``,
40+
If you want to verify the build, you can enable tests via ``-DPRESSIOTUTORIALS_ENABLE_TESTS=ON``,
2541
and then do:
2642

2743
.. code-block:: cpp
2844
2945
cd $BUIlDDIR
3046
ctest
3147
32-
The Python requirements can be found `here <../../end-to-end-roms/requirements.txt>`__
33-
and can be installed via ``pip3 install end-to-end-roms/requirements.txt``
34-
3548
36-
Dependencies
37-
------------
49+
More details on dependencies
50+
----------------------------
3851

3952
The tutorials have the following dependencies:
4053

41-
- pressio: contains the C++ code that this tutorials repo convers
54+
- pressio C++ library: contains the C++ code that this tutorials repo convers
4255
- pressio-demoapps: provides a suite of physics problems that are used in the tutorials to demonstrate the functionalities of pressio
43-
- Eigen: is the data structure library that pressio-demoapps rely on
56+
- Eigen: is the library used by pressio-demoapps
4457
- Python: is used in pressio-demoapps to implement all the ROM workflow drivers

docs/source/index.rst

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@ reduced-order models (ROMs), which is a strongly multidisciplinary topic.
1515
Working on a production-level ROM capability inevitably means touching
1616
multiple fields, ranging from, e.g., linear algebra, nonlinear solvers
1717
and optimization, to distributed computing, HPC and time integration.
18-
This is clearly reflected in the `structure of pressio <https://pressio.github.io/pressio/html/index.html>`__,
19-
where several components (all usable independently) offer different capabilities,
20-
but as a whole constitute the stack foundation of the ``pressio/rom`` component.
18+
This is clearly reflected in the `structure of pressio <https://pressio.github.io/pressio/html/index.html>`__
19+
which display a "stacked" design: each component handles a specific capability and depends
20+
on the ones below it such that you can use it directly, but, as a whole, the stack constitutes
21+
the foundation of the top-level ``pressio/rom`` component.
2122

2223
Describing how to use pressio for ROMs cannot be simply reduced to presenting the API.
2324
Several steps are involved, and the best way to understand them is via examples.
@@ -102,6 +103,8 @@ Find us on `Slack <https://pressioteam.slack.com>`_.
102103
:caption: 2. self-contained tutorials using Eigen data types
103104

104105
./using_eigen/ode1
106+
./using_eigen/ode2
107+
./using_eigen/ode3
105108
./using_eigen/nonlinsolvers1
106109

107110
.. toctree::
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
nonlinear solvers tutorial 1
2-
============================
1+
nonlinear solvers: tutorial 1
2+
=============================
33

4-
.. literalinclude:: ../../../solvers-eigen/main1.cc
4+
.. literalinclude:: ../../../nonlinearsolvers-using-eigen-types/main1.cc
55
:language: cpp
6-
:lines: 1-100
6+
:lines: 1-99
77
:linenos:

docs/source/using_eigen/ode1.rst

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
ode tutorial 1
2-
==============
1+
ode: tutorial 1
2+
===============
33

4-
.. literalinclude:: ../../../ode-eigen/main1.cc
4+
.. literalinclude:: ../../../ode-using-eigen-types/main1.cc
55
:language: cpp
6-
:lines: 1-86
7-
:linenos:
6+
:lines: 1-85

docs/source/using_eigen/ode2.rst

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
ode: tutorial 2
2+
===============
3+
4+
.. literalinclude:: ../../../ode-using-eigen-types/tutorial2/main.cc
5+
:language: cpp
6+
:lines: 1-96
7+
8+
9+
Process results
10+
---------------
11+
12+
.. code-block:: bash
13+
14+
# from within $BUILDDIR/ode-using-eigen-types/tutorial2
15+
python3 plot.py
16+
17+
.. image:: ../../../ode-using-eigen-types/tutorial2/plot.png
18+
:width: 50 %
19+
:align: center
20+
:alt: Lorenz

docs/source/using_eigen/ode3.rst

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
ode: tutorial 3
2+
===============
3+
4+
.. literalinclude:: ../../../ode-using-eigen-types/tutorial3/main.cc
5+
:language: cpp
6+
:lines: 1-158
7+
8+
9+
Process results
10+
---------------
11+
12+
.. code-block:: bash
13+
14+
# from within $BUILDDIR/ode-using-eigen-types/tutorial3
15+
python3 plot.py
16+
17+
.. image:: ../../../ode-using-eigen-types/tutorial3/plot.png
18+
:width: 50 %
19+
:align: center
20+
:alt: Lorenz

solvers-eigen/CMakeLists.txt renamed to nonlinearsolvers-using-eigen-types/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@ include_directories(
44
${CMAKE_CURRENT_SOURCE_DIR}/../tpls
55
${CMAKE_CURRENT_SOURCE_DIR}/../tpls/pressio/include)
66

7-
set(EXENAMEROOT solvers_eigen)
7+
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/runall_for_ci.sh runall_for_ci.sh COPYONLY)
8+
set(EXENAMEROOT nonlinear_solvers_eigen)
89
add_executable(${EXENAMEROOT}_exe1 main1.cc)

solvers-eigen/main1.cc renamed to nonlinearsolvers-using-eigen-types/main1.cc

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -78,18 +78,18 @@ int main()
7878
auto gnSolver = pnonls::create_gauss_newton(problem, linearSolver);
7979
gnSolver.setTolerance(1e-5);
8080

81-
auto state = problem.createState();
82-
state(0) = -0.05; state(1) = 1.1; state(2) = 1.2; state(3) = 1.5;
83-
gnSolver.solve(problem, state);
81+
auto x = problem.createState();
82+
x(0) = -0.05; x(1) = 1.1; x(2) = 1.2; x(3) = 1.5;
83+
gnSolver.solve(problem, x);
8484

8585
// check solution
8686
std::cout << "Computed solution: \n "
8787
<< "["
8888
<< std::setprecision(14)
89-
<< state(0) << " "
90-
<< state(1) << " "
91-
<< state(2) << " "
92-
<< state(3) << " " << "] \n"
89+
<< x(0) << " "
90+
<< x(1) << " "
91+
<< x(2) << " "
92+
<< x(3) << " " << "] \n"
9393
<< "Expected solution: \n "
9494
<< "[1.0000000156741, 0.99999999912477, 0.99999999651993, 0.99999998889888]"
9595
<< std::endl;

0 commit comments

Comments
 (0)