Skip to content

Commit 08515c1

Browse files
author
Francesco Rizzi
committed
add license and cleanup
1 parent e8e3ea8 commit 08515c1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+910
-2083
lines changed

docs/source/endtoend/swe_galerkin_default.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ Workflow File
2929
-------------
3030

3131
The `workflow file <../../../end-to-end-roms/2d_swe_galerkin_default/wf.yaml>`_
32-
is shown below for exposition purposes, but it is automatically copied to the
33-
build directory, so you don't need to do anything:
32+
for this demo is shown below for exposition purposes, but it is automatically
33+
copied to the build directory, so you don't need to do anything:
3434

3535
.. literalinclude:: ../../../end-to-end-roms/2d_swe_galerkin_default/wf.yaml
3636
:language: yaml
@@ -49,7 +49,7 @@ When we run the FOM driver, the following C++ code is being executed:
4949

5050
.. literalinclude:: ../../../end-to-end-roms/cpp/run_fom_explicit.hpp
5151
:language: cpp
52-
:lines: 15-35
52+
:lines: 56-76
5353

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

@@ -101,7 +101,7 @@ The following C++ code is being executed:
101101

102102
.. literalinclude:: ../../../end-to-end-roms/cpp/run_default_galerkin.hpp
103103
:language: cpp
104-
:lines: 26-58, 18-18, 60-62
104+
:lines: 57-79, 82-87, 92
105105

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

docs/source/endtoend/swe_galerkin_hypred_1.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ Workflow File
2929
-------------
3030

3131
The `workflow file <../../../end-to-end-roms/2d_swe_galerkin_hypred_1/wf.yaml>`_
32-
is shown below for exposition purposes, but it is automatically copied to the
33-
build directory, so you don't need to do anything:
32+
for this demo is shown below for exposition purposes, but it is automatically
33+
copied to the build directory, so you don't need to do anything:
3434

3535
.. literalinclude:: ../../../end-to-end-roms/2d_swe_galerkin_hypred_1/wf.yaml
3636
:language: yaml
@@ -104,7 +104,7 @@ Running the Galerkin driver means the following C++ code is being executed:
104104

105105
.. literalinclude:: ../../../end-to-end-roms/cpp/run_hyperreduced_galerkin.hpp
106106
:language: cpp
107-
:lines: 26-94, 18-18, 96-97
107+
:lines: 57-109, 112-121, 126
108108

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

docs/source/endtoend/swe_lspg_default.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ Workflow File
2929
-------------
3030

3131
The `workflow file <../../../end-to-end-roms/2d_swe_lspg_default/wf.yaml>`_
32-
is shown below for exposition purposes, but it is automatically copied to the
33-
build directory, so you don't need to do anything:
32+
for this demo is shown below for exposition purposes, but it is automatically
33+
copied to the build directory, so you don't need to do anything:
3434

3535
.. literalinclude:: ../../../end-to-end-roms/2d_swe_lspg_default/wf.yaml
3636
:language: yaml
@@ -53,7 +53,7 @@ When we run the FOM driver, the following C++ code is being executed:
5353

5454
.. literalinclude:: ../../../end-to-end-roms/cpp/run_fom_implicit.hpp
5555
:language: cpp
56-
:lines: 15-49
56+
:lines: 56-90
5757

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

@@ -102,11 +102,11 @@ The following C++ code is being executed:
102102

103103
.. literalinclude:: ../../../end-to-end-roms/cpp/run_default_lspg.hpp
104104
:language: cpp
105-
:lines: 22-46
105+
:lines: 58-82
106106

107107
.. literalinclude:: ../../../end-to-end-roms/cpp/lspg_pick_solver_and_run.hpp
108108
:language: cpp
109-
:lines: 21-35, 36-51, 18-18, 62-65, 18-18, 79-80
109+
:lines: 52-64, 67-78, 111
110110

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

docs/source/endtoend/swe_lspg_hypred_1.rst

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ Workflow File
2727
-------------
2828

2929
The `workflow file <../../../end-to-end-roms/2d_swe_lspg_hypred_1/wf.yaml>`_
30-
is shown below for exposition purposes, but it is automatically copied to the
31-
build directory, so you don't need to do anything:
30+
for this demo is shown below for exposition purposes, but it is automatically
31+
copied to the build directory, so you don't need to do anything:
3232

3333
.. literalinclude:: ../../../end-to-end-roms/2d_swe_lspg_hypred_1/wf.yaml
3434
:language: yaml
@@ -106,13 +106,11 @@ The following C++ code is being executed:
106106

107107
.. literalinclude:: ../../../end-to-end-roms/cpp/run_hyperreduced_lspg.hpp
108108
:language: cpp
109-
:lines: 82-111
110-
:linenos:
109+
:lines: 58-155
111110

112111
.. literalinclude:: ../../../end-to-end-roms/cpp/lspg_pick_solver_and_run.hpp
113112
:language: cpp
114-
:lines: 23-37
115-
:linenos:
113+
:lines: 52-64, 67-78, 111
116114

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
nonlinear solvers: tutorial 1
22
=============================
33

4+
This tutorial shows how to solve via Gauss-Newton one variant of the Rosenbrock problem.
5+
46
.. literalinclude:: ../../../nonlinearsolvers-using-eigen-types/main1.cc
57
:language: cpp
6-
:lines: 1-99
7-
:linenos:
8+
:lines: 48-145

docs/source/using_eigen/ode1.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ ode: tutorial 1
33

44
.. literalinclude:: ../../../ode-using-eigen-types/main1.cc
55
:language: cpp
6-
:lines: 1-85
6+
:lines: 48-132

docs/source/using_eigen/ode2.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
ode: tutorial 2
22
===============
33

4+
This tutorial shows how to integrate the `original Lorenz system <https://en.wikipedia.org/wiki/Lorenz_system>`__ using explicit time integration.
5+
46
.. literalinclude:: ../../../ode-using-eigen-types/tutorial2/main.cc
57
:language: cpp
6-
:lines: 1-96
8+
:lines: 48-143
79

810

911
Process results

docs/source/using_eigen/ode3.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
ode: tutorial 3
22
===============
33

4+
This tutorial shows how to integrate the `original Lorenz system <https://en.wikipedia.org/wiki/Lorenz_system>`__ using implicit time integration.
5+
46
.. literalinclude:: ../../../ode-using-eigen-types/tutorial3/main.cc
57
:language: cpp
6-
:lines: 1-157
8+
:lines: 48-187
79

810
Process results
911
---------------
Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11

2-
/* NOTE: the formatting and line order below matters because
3-
the rst docs use literalinclude to pick up snippets of code,
4-
so if you change something below
5-
it is likely you impact the documentation, so be careful
6-
*/
2+
- the formatting and line order in all files **matters**
3+
because the rst docs use literalinclude to pick up snippets of code,
4+
so if you change something in a file, t is likely you impact the documentation,
5+
so be careful
6+
7+
- indentation is in some places **intentionally* not set for the a
8+
similar reason as above
Lines changed: 77 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,54 @@
1+
/*
2+
//@HEADER
3+
// ************************************************************************
4+
//
5+
// lspg_pick_solver_and_run.hpp
6+
// Pressio
7+
// Copyright 2019
8+
// National Technology & Engineering Solutions of Sandia, LLC (NTESS)
9+
//
10+
// Under the terms of Contract DE-NA0003525 with NTESS, the
11+
// U.S. Government retains certain rights in this software.
12+
//
13+
// Pressio is licensed under BSD-3-Clause terms of use:
14+
//
15+
// Redistribution and use in source and binary forms, with or without
16+
// modification, are permitted provided that the following conditions
17+
// are met:
18+
//
19+
// 1. Redistributions of source code must retain the above copyright
20+
// notice, this list of conditions and the following disclaimer.
21+
//
22+
// 2. Redistributions in binary form must reproduce the above copyright
23+
// notice, this list of conditions and the following disclaimer in the
24+
// documentation and/or other materials provided with the distribution.
25+
//
26+
// 3. Neither the name of the copyright holder nor the names of its
27+
// contributors may be used to endorse or promote products derived
28+
// from this software without specific prior written permission.
29+
//
30+
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
31+
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
32+
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
33+
// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
34+
// COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
35+
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
36+
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
37+
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38+
// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39+
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40+
// IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41+
// POSSIBILITY OF SUCH DAMAGE.
42+
//
43+
// Questions? Contact Francesco Rizzi ([email protected])
44+
//
45+
// ************************************************************************
46+
//@HEADER
47+
*/
148

249
#ifndef RUN_LSPG_PICK_SOLVER_AND_RUN_HPP_
350
#define RUN_LSPG_PICK_SOLVER_AND_RUN_HPP_
451

5-
/* NOTE:
6-
1. the formatting here matters because the rst docs
7-
use literalincludes so if you change somehting below
8-
it is likely you impact the documentation
9-
10-
2. the comments below are used by the rst documentaion
11-
in non contiguous literalinclude statetements so that
12-
we can make the documentation more clear
13-
14-
3. do NOT erase these comments, and do NOT move them
15-
or you impact the rst docs
16-
17-
// branch taken in this demo
18-
// branch not used in this demo
19-
*/
20-
2152
template<class LspgStepperType, class ParserType, class RomStateType>
2253
void lspg_pick_solver_and_run(const ParserType & parser,
2354
LspgStepperType & lspgStepper,
@@ -33,49 +64,49 @@ void lspg_pick_solver_and_run(const ParserType & parser,
3364

3465
if (parser.nonlinearSolver() == "GaussNewton")
3566
{
36-
using hessian_t = Eigen::Matrix<scalar_type, -1, -1>;
37-
using solver_tag = pressio::linearsolvers::direct::HouseholderQR;
38-
using linear_solver_t = pressio::linearsolvers::Solver<solver_tag, hessian_t>;
39-
linear_solver_t linearSolver;
67+
using hessian_t = Eigen::Matrix<scalar_type, -1, -1>;
68+
using solver_tag = pressio::linearsolvers::direct::HouseholderQR;
69+
using linear_solver_t = pressio::linearsolvers::Solver<solver_tag, hessian_t>;
70+
linear_solver_t linearSolver;
4071

41-
auto solver = pnlins::create_gauss_newton(lspgStepper, linearSolver);
42-
solver.setStoppingCriterion(pnlins::Stop::WhenGradientAbsoluteNormBelowTolerance);
43-
solver.setTolerance(parser.nonlinearSolverTolerance());
72+
auto solver = pnlins::create_gauss_newton(lspgStepper, linearSolver);
73+
solver.setStoppingCriterion(pnlins::Stop::WhenGradientAbsoluteNormBelowTolerance);
74+
solver.setTolerance(parser.nonlinearSolverTolerance());
4475

45-
pode::advance_n_steps(lspgStepper, reducedState, startTime,
46-
parser.timeStepSize(), numSteps,
47-
observer, solver);
76+
pode::advance_n_steps(lspgStepper, reducedState, startTime,
77+
parser.timeStepSize(), numSteps,
78+
observer, solver);
4879
}
4980

5081
else if (parser.nonlinearSolver() == "GaussNewtonQR")
5182
{
52-
using mat_t = typename LspgStepperType::jacobian_type;
53-
using qr_solver_t = pressio::qr::QRSolver<mat_t, pressio::qr::Householder>;
54-
qr_solver_t qrSolver;
55-
auto solver = pnlins::create_gauss_newtonQR(lspgStepper, qrSolver);
56-
solver.setStoppingCriterion(pnlins::Stop::WhenGradientAbsoluteNormBelowTolerance);
57-
solver.setTolerance(parser.nonlinearSolverTolerance());
83+
using mat_t = typename LspgStepperType::jacobian_type;
84+
using qr_solver_t = pressio::qr::QRSolver<mat_t, pressio::qr::Householder>;
85+
qr_solver_t qrSolver;
86+
auto solver = pnlins::create_gauss_newtonQR(lspgStepper, qrSolver);
87+
solver.setStoppingCriterion(pnlins::Stop::WhenGradientAbsoluteNormBelowTolerance);
88+
solver.setTolerance(parser.nonlinearSolverTolerance());
5889

59-
pode::advance_n_steps(lspgStepper, reducedState, startTime,
60-
parser.timeStepSize(), numSteps,
61-
observer, solver);
90+
pode::advance_n_steps(lspgStepper, reducedState, startTime,
91+
parser.timeStepSize(), numSteps,
92+
observer, solver);
6293
}
6394

6495
else if (parser.nonlinearSolver() == "LevenbergMarquardt")
6596
{
66-
using hessian_t = Eigen::Matrix<scalar_type, -1, -1>;
67-
using solver_tag = pressio::linearsolvers::direct::HouseholderQR;
68-
using linear_solver_t = pressio::linearsolvers::Solver<solver_tag, hessian_t>;
69-
linear_solver_t linearSolver;
97+
using hessian_t = Eigen::Matrix<scalar_type, -1, -1>;
98+
using solver_tag = pressio::linearsolvers::direct::HouseholderQR;
99+
using linear_solver_t = pressio::linearsolvers::Solver<solver_tag, hessian_t>;
100+
linear_solver_t linearSolver;
70101

71-
auto solver = pnlins::create_levenberg_marquardt(lspgStepper, linearSolver);
72-
solver.setUpdatingCriterion(pnlins::Update::LMSchedule2);
73-
solver.setStoppingCriterion(pnlins::Stop::WhenGradientAbsoluteNormBelowTolerance);
74-
solver.setTolerance(parser.nonlinearSolverTolerance());
102+
auto solver = pnlins::create_levenberg_marquardt(lspgStepper, linearSolver);
103+
solver.setUpdatingCriterion(pnlins::Update::LMSchedule2);
104+
solver.setStoppingCriterion(pnlins::Stop::WhenGradientAbsoluteNormBelowTolerance);
105+
solver.setTolerance(parser.nonlinearSolverTolerance());
75106

76-
pode::advance_n_steps(lspgStepper, reducedState, startTime,
77-
parser.timeStepSize(), numSteps,
78-
observer, solver);
107+
pode::advance_n_steps(lspgStepper, reducedState, startTime,
108+
parser.timeStepSize(), numSteps,
109+
observer, solver);
79110
}
80111
}
81112
#endif

0 commit comments

Comments
 (0)