Skip to content

Commit e8e3ea8

Browse files
author
Francesco Rizzi
committed
wip before adding license
1 parent d0db686 commit e8e3ea8

28 files changed

+275
-127
lines changed

docs/source/endtoend/swe_galerkin_default.rst

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ build directory, so you don't need to do anything:
3535
.. literalinclude:: ../../../end-to-end-roms/2d_swe_galerkin_default/wf.yaml
3636
:language: yaml
3737
:lines: 1-35
38-
:linenos:
3938

4039

4140
Step 1: execute FOMs
@@ -50,8 +49,7 @@ When we run the FOM driver, the following C++ code is being executed:
5049

5150
.. literalinclude:: ../../../end-to-end-roms/cpp/run_fom_explicit.hpp
5251
:language: cpp
53-
:lines: 9-31
54-
:linenos:
52+
:lines: 15-35
5553

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

@@ -103,9 +101,7 @@ The following C++ code is being executed:
103101

104102
.. literalinclude:: ../../../end-to-end-roms/cpp/run_default_galerkin.hpp
105103
:language: cpp
106-
:lines: 10-43
107-
:linenos:
108-
104+
:lines: 26-58, 18-18, 60-62
109105

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

docs/source/endtoend/swe_galerkin_hypred_1.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +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: 40-77
108-
:linenos:
107+
:lines: 26-94, 18-18, 96-97
109108

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

docs/source/endtoend/swe_lspg_default.rst

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ build directory, so you don't need to do anything:
3535
.. literalinclude:: ../../../end-to-end-roms/2d_swe_lspg_default/wf.yaml
3636
:language: yaml
3737
:lines: 1-35
38-
:linenos:
3938

4039

4140
Step 1: execute FOMs
@@ -54,8 +53,7 @@ When we run the FOM driver, the following C++ code is being executed:
5453

5554
.. literalinclude:: ../../../end-to-end-roms/cpp/run_fom_implicit.hpp
5655
:language: cpp
57-
:lines: 9-45
58-
:linenos:
56+
:lines: 15-49
5957

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

@@ -93,7 +91,7 @@ and creates all data into an "offline_rom" subdirectory:
9391
9492
9593
Step 3: lspg rom
96-
--------------------
94+
----------------
9795

9896
.. code-block:: bash
9997
@@ -104,13 +102,11 @@ The following C++ code is being executed:
104102

105103
.. literalinclude:: ../../../end-to-end-roms/cpp/run_default_lspg.hpp
106104
:language: cpp
107-
:lines: 10-37
108-
:linenos:
105+
:lines: 22-46
109106

110107
.. literalinclude:: ../../../end-to-end-roms/cpp/lspg_pick_solver_and_run.hpp
111108
:language: cpp
112-
:lines: 23-37
113-
:linenos:
109+
:lines: 21-35, 36-51, 18-18, 62-65, 18-18, 79-80
114110

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

docs/source/endtoend/templateyaml.rst

Lines changed: 0 additions & 6 deletions
This file was deleted.

docs/source/using_eigen/ode3.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ ode: tutorial 3
33

44
.. literalinclude:: ../../../ode-using-eigen-types/tutorial3/main.cc
55
:language: cpp
6-
:lines: 1-158
7-
6+
:lines: 1-157
87

98
Process results
109
---------------
File renamed without changes.

end-to-end-roms/all.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def assert_valid_and_supported_problem(wfDic, ptutRepoEndToEndFullPath):
2626
assert('problem' in wfDic)
2727

2828
problemName = find_problem_name_from_wf_dic(wfDic)
29-
moduleName = 'customizations_'+problemName
29+
moduleName = problemName+'_customizations'
3030
modulePath = os.path.realpath(ptutRepoEndToEndFullPath+'/'+moduleName)
3131
if not os.path.exists(modulePath):
3232
print("\n")
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
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+
*/

end-to-end-roms/cpp/lspg_pick_solver_and_run.hpp

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,39 @@
22
#ifndef RUN_LSPG_PICK_SOLVER_AND_RUN_HPP_
33
#define RUN_LSPG_PICK_SOLVER_AND_RUN_HPP_
44

5-
template<
6-
class LspgStepperType,
7-
class ParserType,
8-
class RomStateType
9-
>
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+
21+
template<class LspgStepperType, class ParserType, class RomStateType>
1022
void lspg_pick_solver_and_run(const ParserType & parser,
1123
LspgStepperType & lspgStepper,
1224
RomStateType & reducedState)
1325
{
14-
using scalar_t = typename pressio::Traits<RomStateType>::scalar_type;
15-
namespace pode = pressio::ode;
26+
namespace pode = pressio::ode;
1627
namespace pnlins = pressio::nonlinearsolvers;
1728

18-
StateObserver observer(parser.stateSamplingFreq());
19-
20-
const pressio::ode::StepCount numSteps(parser.numSteps());
29+
using scalar_type = typename pressio::Traits<RomStateType>::scalar_type;
2130
const auto startTime = static_cast<typename LspgStepperType::independent_variable_type>(0);
31+
const pressio::ode::StepCount numSteps(parser.numSteps());
32+
StateObserver observer(parser.stateSamplingFreq());
2233

2334
if (parser.nonlinearSolver() == "GaussNewton")
2435
{
25-
using hessian_t = Eigen::Matrix<scalar_t, -1, -1>;
26-
using solver_tag = pressio::linearsolvers::direct::HouseholderQR;
36+
using hessian_t = Eigen::Matrix<scalar_type, -1, -1>;
37+
using solver_tag = pressio::linearsolvers::direct::HouseholderQR;
2738
using linear_solver_t = pressio::linearsolvers::Solver<solver_tag, hessian_t>;
2839
linear_solver_t linearSolver;
2940

@@ -38,7 +49,6 @@ void lspg_pick_solver_and_run(const ParserType & parser,
3849

3950
else if (parser.nonlinearSolver() == "GaussNewtonQR")
4051
{
41-
4252
using mat_t = typename LspgStepperType::jacobian_type;
4353
using qr_solver_t = pressio::qr::QRSolver<mat_t, pressio::qr::Householder>;
4454
qr_solver_t qrSolver;
@@ -53,8 +63,8 @@ void lspg_pick_solver_and_run(const ParserType & parser,
5363

5464
else if (parser.nonlinearSolver() == "LevenbergMarquardt")
5565
{
56-
using hessian_t = Eigen::Matrix<scalar_t, -1, -1>;
57-
using solver_tag = pressio::linearsolvers::direct::HouseholderQR;
66+
using hessian_t = Eigen::Matrix<scalar_type, -1, -1>;
67+
using solver_tag = pressio::linearsolvers::direct::HouseholderQR;
5868
using linear_solver_t = pressio::linearsolvers::Solver<solver_tag, hessian_t>;
5969
linear_solver_t linearSolver;
6070

@@ -68,5 +78,4 @@ void lspg_pick_solver_and_run(const ParserType & parser,
6878
observer, solver);
6979
}
7080
}
71-
7281
#endif

end-to-end-roms/cpp/main.cc

Lines changed: 1 addition & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ int main(int argc, char *argv[])
7575
const auto problemNode = node["problem"];
7676
if (!problemNode){ throw std::runtime_error("Missing problem in yaml input!"); }
7777
const auto problemName = problemNode.as<std::string>();
78-
std::cout << problemName << std::endl;
78+
std::cout << "Running: " << problemName << std::endl;
7979

8080
// start timer
8181
auto t1 = std::chrono::high_resolution_clock::now();
@@ -86,7 +86,6 @@ int main(int argc, char *argv[])
8686
using scalar_t = double;
8787
ParserTwoDimShallowWater<scalar_t> parser(node);
8888
const auto meshObj = pda::load_cellcentered_uniform_mesh_eigen<scalar_t>(parser.meshDir());
89-
const auto probId = pda::Swe2d::SlipWall;
9089
const auto invScheme = string_to_inviscid_flux_scheme(parser.inviscidFluxReconstruction());
9190
const auto gravity = parser.gravity();
9291
const auto coriolis = parser.coriolis();
@@ -104,36 +103,3 @@ int main(int argc, char *argv[])
104103
pressio::log::finalize();
105104
return 0;
106105
}
107-
108-
// if (problem == "2d_rd")
109-
// {
110-
// namespace pda = pressiodemoapps;
111-
// ParserTwoDimReacDiff<scalar_t> parser(node);
112-
// const auto meshObj = pda::load_cellcentered_uniform_mesh_eigen<scalar_t>(parser.meshDir());
113-
// const auto diffusion = parser.diffusion();
114-
// const auto reaction = parser.reaction();
115-
// const auto scheme = pda::ViscousFluxReconstruction::FirstOrder;
116-
// const auto probId = pda::DiffusionReaction2d::ProblemA;
117-
// auto fomSystem = pda::create_problem_eigen(meshObj, probId, scheme,
118-
// mySource, diffusion, reaction);
119-
// dispatch(fomSystem, parser);
120-
// }
121-
122-
123-
// if (problem == "2d_gs")
124-
// {
125-
// namespace pda = pressiodemoapps;
126-
// ParserTwoDimGrayScott<scalar_t> parser(node);
127-
// const auto meshObj = pda::load_cellcentered_uniform_mesh_eigen<scalar_t>(parser.meshDir());
128-
// const auto probId = pda::DiffusionReaction2d::GrayScott;
129-
// const auto scheme = pda::ViscousFluxReconstruction::FirstOrder;
130-
131-
// const auto diffusionA = parser.diffusionA();
132-
// const auto diffusionB = parser.diffusionB();
133-
// const auto feedRate = parser.feedRate();
134-
// const auto killRate = parser.killRate();
135-
// auto fomSystem = pda::create_problem_eigen(meshObj, probId, scheme,
136-
// diffusionA, diffusionB,
137-
// feedRate, killRate);
138-
// dispatch(fomSystem, parser);
139-
// }

0 commit comments

Comments
 (0)