Skip to content

Commit bcd963a

Browse files
committed
Merge branch 'development' into feature/boris-linearized-cloud
* development: docs: Update install instructions. config: Add abs/rel residual tolerances. examples: Update option initialization. config: Tidy and set defaults. config: Get rid of redundant `add_option`. config: Add two stage config/log init to `pfasst::init`. config: Revamp adding options. tests: Add RelativeAdaptiveErrorTest to test_advection_diffusion.cpp. mpi: Minor tidying. tests: Re-organise the adaptive MLSDC tests a bit. tests: Add AdaptiveErrorTest for AD example to MPI PFASST. encap: Compute relative residuals as well. status: Bug fix. status: Move to blocking send/recv. status: Break iterations in PFASST when converged. status: Begin adding converged status MPI communication. Conflicts: examples/advection_diffusion/vanilla_sdc.cpp examples/boris/boris_sdc.cpp examples/boris/boris_sweeper.hpp include/pfasst.hpp
2 parents f0ef3c3 + 9986b16 commit bcd963a

21 files changed

+479
-314
lines changed

doc/source/installing.md

Lines changed: 56 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,34 +2,63 @@
22

33
## Prerequesites
44

5-
* A recent C++ compiler that supports (most of) the C++11 standard.
6-
This either implies at least GCC 4.7 (we recommend 4.8 or later) or Clang 3.2 (we recommend 3.3 or later).
5+
If you use [CMake] to compile, most of the prerequesites are downloaded automatically if they aren't
6+
already found on your system.
77

8-
* The [Boost](https://boost.org/) libraries at least of version 1.53.0.
9-
Especially `boost::program_options` is required.
8+
### Required
109

11-
* The [CMake] build tool (at least version 2.8).
10+
* A recent C++ compiler that supports (most of) the C++11 standard. This implies either: GCC 4.7
11+
(we recommend 4.8 or later) or Clang 3.2 (we recommend 3.3 or later).
1212

13-
* The [Eigen3] library is required for everything using the \em PFASST++ library.
14-
It will be automatically downloaded if it is not found on the system.
13+
* The [Boost] `boost::program_options` library (at least version 1.53.0). The [Boost]
14+
multiprecision component may also be of interest to \em PFASST++ users.
1515

16-
* The [FFTW3] library is required for (some) of the examples.
17-
It will be automatically downloaded and built as well if it is not found on the system.
16+
* The [Eigen3] library.
1817

19-
* The [Google Testing] and [Mocking Framework] are required for the unit tests, and are automatically downloaded and
20-
built.
18+
### Optional
19+
20+
* The [CMake] build tool (at least version 2.8). This is especially useful for developers.
21+
22+
* The [FFTW3] library is required for some of the examples.
23+
24+
* The [Google Testing] and [Google Mocking] are required for the unit tests.
25+
26+
* An MPI implementation.
27+
28+
### Using [HashDist] to obtain prerequesites
29+
30+
The [HashDist] environment management system provides an easy, robust, and version controlled way
31+
for our developers (and users) to download and install all prerequesites *locally* (ie, you don't
32+
need special privileges on your system to use [HashDist], and it won't modify your system).
33+
34+
To use [HashDist]
35+
36+
1. Install [HashDist]
37+
38+
git clone [email protected]:hashdist/hashdist.git
39+
export PATH=$PWD/hashdist/bin:$PATH
40+
41+
2. Install prerequesites
42+
43+
cd PFASST
44+
hit build -v tools/hashdist/pfasst-stack.debian.yaml
45+
mv pfasst-stack.debian stack
46+
47+
This may take a while (ie, do this before going for lunch) the first time through. However, once
48+
complete, subsequent builds (using [CMake] or otherwise) will bypass prerequesite installation, even
49+
if you change [CMake] build options or start a fresh out-of-source build directory.
2150

2251

2352
## Obtaining the Sources
2453

25-
Either use _Git_ to clone the repository (https://github.com/Parallel-in-Time/PFASST.git) or download the latest
26-
release from [GitHub][github_releases].
54+
Use _Git_ to clone the repository (https://github.com/Parallel-in-Time/PFASST.git) or download the
55+
latest release from [GitHub][github_releases].
2756

2857

29-
## Building
58+
## Building with CMake
3059

31-
1. Create a directory for out-of-source builds (usually, people are creative and name it `build`) in the source tree
32-
(or elsewhere).
60+
1. Create a directory for out-of-source builds (usually, people are creative and name it `build`) in
61+
the source tree (or elsewhere).
3362

3463
2. Decide on what and how you want to build:
3564

@@ -58,7 +87,7 @@ release from [GitHub][github_releases].
5887

5988
* __Test Suite__
6089

61-
* Deactivate building of the test suite by passing `-Dpfasst_BUILD_TESTS=OFF` to the _CMake_ command line (not
90+
* Deactivate building of the test suite by passing `-Dpfasst_BUILD_TESTS=OFF` to the _CMake_ command line (not
6291
recommended).
6392

6493
* __Examples__
@@ -81,7 +110,7 @@ release from [GitHub][github_releases].
81110
* In case you also want to install the compiled example programs on your system, specify
82111
`-Dpfasst_INSTALL_EXAMPLES=ON`.
83112

84-
* For example, to build a release version with _Clang_ on a Linux system without the examples, the call to
113+
* For example, to build a release version with _Clang_ on a Linux system without the examples, the call to
85114
_CMake_ looks like:
86115

87116
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -Dpfasst_BUILD_EXAMPLES=OFF ..
@@ -99,18 +128,25 @@ release from [GitHub][github_releases].
99128

100129
make test
101130

102-
In case any of the tests do not pass, please [open an issue on GitHub][github_new_issue] and provide the full log of
131+
In case any of the tests do not pass, please [open an issue on GitHub][github_new_issue] and provide the full log of
103132
your _CMake_ and _make_ invocations.
104133

105134
5. (optional) Install \em PFASST++ headers (and compiled examples if specified so):
106135

107136
make install
108137

138+
## Building with vanilla make
139+
140+
A sample `Makefile` is included in the `advection_diffusion` example. This may be of particular
141+
interested to advanced users wishing to incorporate \rm PFASST++ into their existing code bases.
142+
109143

144+
[Boost]: https://boost.org/
110145
[CMake]: http://cmake.org/
111146
[Eigen3]: http://eigen.tuxfamily.org/
112147
[Google Testing]: https://code.google.com/p/googletest/
113-
[Mocking Framework]: https://code.google.com/p/googlemock/
148+
[Google Mocking]: https://code.google.com/p/googlemock/
114149
[FFTW3]: http://fftw.org/
115150
[github_releases]: https://github.com/Parallel-in-Time/PFASST/releases
116151
[github_new_issue]: https://github.com/Parallel-in-Time/PFASST/issues/new
152+
[HashDist]: http://hashdist.readthedocs.org/en/latest/

examples/advection_diffusion/advection_diffusion_sweeper.hpp

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -47,21 +47,15 @@ namespace pfasst
4747
class AdvectionDiffusionSweeper
4848
: public encap::IMEXSweeper<time>
4949
{
50-
private:
51-
static void init_config_options(po::options_description& opts)
50+
public:
51+
static void init_opts()
5252
{
53-
opts.add_options()
54-
("spatial_dofs", po::value<size_t>(), "number of spatial degrees of freedom")
55-
;
53+
pfasst::config::options::add_option<size_t>("Adv/Diff Sweeper", "spatial_dofs", "Number of spatial degrees of freedom");
5654
}
5755

58-
public:
59-
static void enable_config_options(size_t index = -1)
56+
static void init_logs()
6057
{
61-
config::Options::get_instance()
62-
.register_init_function("Advection-Diffusion Sweeper",
63-
std::function<void(po::options_description&)>(init_config_options),
64-
index);
58+
pfasst::log::add_custom_logger("Advec");
6559
}
6660

6761
private:
@@ -141,8 +135,8 @@ namespace pfasst
141135

142136
auto n = this->get_controller()->get_step();
143137
auto k = this->get_controller()->get_iteration();
144-
CLOG(INFO, "Advec") << "err: " << n << " " << k << " " << max << " (" << qend.size() << "," << predict << ")";
145138

139+
CLOG(INFO, "Advec") << "err: " << n << " " << k << " " << max << " (" << qend.size() << "," << predict << ")";
146140
this->errors.insert(vtype(ktype(n, k), max));
147141
}
148142

examples/advection_diffusion/mpi_pfasst.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,20 @@ using namespace std;
2121

2222
#include "advection_diffusion_sweeper.hpp"
2323
#include "spectral_transfer_1d.hpp"
24+
2425
using namespace pfasst::encap;
2526
using namespace pfasst::mpi;
2627

27-
2828
namespace pfasst
2929
{
3030
namespace examples
3131
{
3232
namespace advection_diffusion
3333
{
34-
error_map run_mpi_pfasst()
34+
error_map run_mpi_pfasst(double abs_residual_tol, size_t niters=4)
3535
{
3636
const size_t nsteps = 4;
3737
const double dt = 0.01;
38-
const size_t niters = 4;
3938

4039
vector<pair<size_t, quadrature::QuadratureType>> nodes = {
4140
{ 3, quadrature::QuadratureType::GaussLobatto },
@@ -67,6 +66,7 @@ namespace pfasst
6766
pf.set_comm(&comm);
6867
pf.set_duration(0.0, nsteps * dt, dt, niters);
6968
pf.set_nsweeps({2, 1});
69+
pf.get_finest<AdvectionDiffusionSweeper<>>()->set_residual_tolerances(abs_residual_tol, 0.0);
7070
pf.run();
7171

7272
auto fine = pf.get_finest<AdvectionDiffusionSweeper<>>();
@@ -81,7 +81,7 @@ namespace pfasst
8181
int main(int argc, char** argv)
8282
{
8383
MPI_Init(&argc, &argv);
84-
pfasst::examples::advection_diffusion::run_mpi_pfasst();
84+
pfasst::examples::advection_diffusion::run_mpi_pfasst(0.0);
8585
fftw_cleanup();
8686
MPI_Finalize();
8787
}

examples/advection_diffusion/serial_mlsdc.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,9 @@ namespace pfasst
101101
#ifndef PFASST_UNIT_TESTING
102102
int main(int argc, char** argv)
103103
{
104-
pfasst::examples::advection_diffusion::AdvectionDiffusionSweeper<>::enable_config_options();
105-
pfasst::init(argc, argv);
106-
pfasst::log::add_custom_logger("Advec");
107-
104+
pfasst::init(argc, argv,
105+
pfasst::examples::advection_diffusion::AdvectionDiffusionSweeper<>::init_opts,
106+
pfasst::examples::advection_diffusion::AdvectionDiffusionSweeper<>::init_logs);
108107
pfasst::examples::advection_diffusion::run_serial_mlsdc(3);
109108
}
110109
#endif

examples/advection_diffusion/serial_mlsdc_autobuild.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,9 @@ namespace pfasst
9797
#ifndef PFASST_UNIT_TESTING
9898
int main(int argc, char** argv)
9999
{
100-
pfasst::examples::advection_diffusion::AdvectionDiffusionSweeper<>::enable_config_options();
101-
pfasst::init(argc, argv);
102-
pfasst::log::add_custom_logger("Advec");
103-
100+
pfasst::init(argc, argv,
101+
pfasst::examples::advection_diffusion::AdvectionDiffusionSweeper<>::init_opts,
102+
pfasst::examples::advection_diffusion::AdvectionDiffusionSweeper<>::init_logs);
104103
pfasst::examples::advection_diffusion::run_serial_mlsdc_autobuild();
105104
}
106105
#endif

examples/advection_diffusion/vanilla_sdc.cpp

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,13 @@ namespace pfasst
2323
{
2424
namespace advection_diffusion
2525
{
26-
error_map run_vanilla_sdc(double abs_residual_tol)
26+
error_map run_vanilla_sdc(double abs_residual_tol, double rel_residual_tol=0.0)
2727
{
2828
SDC<> sdc;
2929

30-
const size_t nsteps = config::get_value<size_t>("num_steps", 4);
31-
const double dt = config::get_value<double>("delta_step", 0.01);
32-
const size_t nnodes = config::get_value<size_t>("num_nodes", 3);
33-
const size_t ndofs = config::get_value<size_t>("spatial_dofs", 64);
34-
const size_t niters = config::get_value<size_t>("num_iter", 4);
35-
const quadrature::QuadratureType quad_type = \
30+
auto const nnodes = config::get_value<size_t>("num_nodes", 3);
31+
auto const ndofs = config::get_value<size_t>("spatial_dofs", 64);
32+
auto const quad_type = \
3633
config::get_value<quadrature::QuadratureType>("nodes_type", quadrature::QuadratureType::GaussLegendre);
3734

3835
auto quad = quadrature::quadrature_factory(nnodes, quad_type);
@@ -41,10 +38,11 @@ namespace pfasst
4138

4239
sweeper->set_quadrature(quad);
4340
sweeper->set_factory(factory);
44-
sweeper->set_residual_tolerances(abs_residual_tol, pfasst::config::get_value<double>("rel_res_tol", 0.0));
41+
sweeper->set_residual_tolerances(abs_residual_tol, rel_residual_tol);
4542

4643
sdc.add_level(sweeper);
47-
sdc.set_duration(0.0, nsteps*dt, dt, niters);
44+
sdc.set_duration(0.0, 4*0.01, 0.01, 4);
45+
sdc.set_options();
4846
sdc.setup();
4947

5048
auto q0 = sweeper->get_start_state();
@@ -64,12 +62,9 @@ namespace pfasst
6462
#ifndef PFASST_UNIT_TESTING
6563
int main(int argc, char** argv)
6664
{
67-
pfasst::examples::advection_diffusion::AdvectionDiffusionSweeper<>::enable_config_options();
68-
pfasst::init(argc, argv);
69-
pfasst::log::add_custom_logger("Advec");
70-
71-
const double abs_res_tol = pfasst::config::get_value<double>("abs_res_tol", 0.0);
72-
73-
pfasst::examples::advection_diffusion::run_vanilla_sdc(abs_res_tol);
65+
pfasst::init(argc, argv,
66+
pfasst::examples::advection_diffusion::AdvectionDiffusionSweeper<>::init_opts,
67+
pfasst::examples::advection_diffusion::AdvectionDiffusionSweeper<>::init_logs);
68+
pfasst::examples::advection_diffusion::run_vanilla_sdc(0.0);
7469
}
7570
#endif

examples/boris/boris_mlsdc.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ namespace pfasst
8282
#ifndef PFASST_UNIT_TESTING
8383
int main(int argc, char** argv)
8484
{
85-
pfasst::examples::boris::enable_config_options<double>();
85+
pfasst::init(argc, argv, pfasst::examples::boris::init_opts<double>);
8686
pfasst::init(argc, argv);
8787
pfasst::log::add_custom_logger("Boris");
8888
pfasst::log::add_custom_logger("BorisTransfer");

examples/boris/boris_sdc.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,7 @@ namespace pfasst
6767
#ifndef PFASST_UNIT_TESTING
6868
int main(int argc, char** argv)
6969
{
70-
pfasst::examples::boris::enable_config_options<double>();
71-
pfasst::init(argc, argv);
70+
pfasst::init(argc, argv, pfasst::examples::boris::init_opts<double>);
7271
pfasst::log::add_custom_logger("Boris");
7372
pfasst::log::add_custom_logger("Solver");
7473

examples/boris/boris_sweeper.hpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,7 @@ namespace pfasst
7575

7676

7777
template<typename scalar>
78-
static void init_config_options(po::options_description& opts);
79-
80-
template<typename scalar>
81-
static void enable_config_options(size_t index = -1);
78+
static void init_opts();
8279

8380

8481
class LogIndent

examples/boris/boris_sweeper_impl.hpp

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -56,23 +56,12 @@ namespace pfasst
5656

5757

5858
template<typename scalar>
59-
static void init_config_options(po::options_description& opts)
59+
static void init_opts()
6060
{
61-
opts.add_options()
62-
("num_particles", po::value<size_t>(), "number of particles in the cloud")
63-
("epsilon", po::value<scalar>(), "Boris' epsilon")
64-
("omega_e", po::value<scalar>(), "E-field constant")
65-
("omega_b", po::value<scalar>(), "B-field constant")
66-
;
67-
}
68-
69-
template<typename scalar>
70-
static void enable_config_options(size_t index)
71-
{
72-
config::Options::get_instance()
73-
.register_init_function("Boris-SDC",
74-
std::function<void(po::options_description&)>(pfasst::examples::boris::init_config_options<scalar>),
75-
index);
61+
pfasst::config::options::add_option<size_t>("Boris-SDC", "num_particles", "number of particles in the cloud");
62+
pfasst::config::options::add_option<scalar>("Boris-SDC", "epsilon", "Boris' epsilon");
63+
pfasst::config::options::add_option<scalar>("Boris-SDC", "omega_e", "E-field constant");
64+
pfasst::config::options::add_option<scalar>("Boris-SDC", "omega_b", "B-field constant");
7665
}
7766

7867

0 commit comments

Comments
 (0)