Skip to content

Commit 5e1d24f

Browse files
committed
Merge pull request #132 from memmett/memmett/state0
LGTM. Fix assumption that `state(0)` is the same as `start_state`.
2 parents dbb1e6a + 3bed49c commit 5e1d24f

File tree

6 files changed

+230
-254
lines changed

6 files changed

+230
-254
lines changed

examples/advection_diffusion/advection_diffusion_sweeper.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,6 @@ class AdvectionDiffusionSweeper
133133

134134
auto n = this->get_controller()->get_step();
135135
auto k = this->get_controller()->get_iteration();
136-
CLOG(INFO, "data_values") << n << k << qend;
137136
LOG(INFO) << "err:" << n << k << max << "(" << qend.size() << "," << predict << ")";
138137

139138
this->errors.insert(pair<pair<size_t, size_t>, double>(pair<size_t, size_t>(n, k), max));

examples/advection_diffusion/vanilla_sdc.cpp

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,13 @@ error_map run_vanilla_sdc(double abs_residual_tol)
2323

2424
const size_t nsteps = pfasst::config::get_value<size_t>("num_steps", 4);
2525
const double dt = pfasst::config::get_value<double>("delta_step", 0.01);
26-
const size_t nnodes = pfasst::config::get_value<size_t>("num_nodes", 5);
26+
const size_t nnodes = pfasst::config::get_value<size_t>("num_nodes", 3);
2727
const size_t ndofs = pfasst::config::get_value<size_t>("spatial_dofs", 64);
2828
const size_t niters = pfasst::config::get_value<size_t>("num_iter", 4);
2929
const pfasst::quadrature::QuadratureType quad_type = \
30-
pfasst::config::get_value<pfasst::quadrature::QuadratureType>("nodes_type", pfasst::quadrature::QuadratureType::GaussLobatto);
30+
pfasst::config::get_value<pfasst::quadrature::QuadratureType>("nodes_type", pfasst::quadrature::QuadratureType::GaussLegendre);
3131

32-
// auto quad = pfasst::quadrature::quadrature_factory(nnodes, pfasst::quadrature::QuadratureType::GaussLobatto);
33-
auto quad = pfasst::quadrature::quadrature_factory(nnodes-2, pfasst::quadrature::QuadratureType::GaussLegendre);
32+
auto quad = pfasst::quadrature::quadrature_factory(nnodes, quad_type);
3433
auto factory = make_shared<pfasst::encap::VectorFactory<double>>(ndofs);
3534
auto sweeper = make_shared<AdvectionDiffusionSweeper<>>(ndofs);
3635

@@ -56,12 +55,8 @@ error_map run_vanilla_sdc(double abs_residual_tol)
5655
#ifndef PFASST_UNIT_TESTING
5756
int main(int argc, char** argv)
5857
{
59-
pfasst::encap::enable_config_options();
60-
// First we want to enable command line options for the Advection-Diffusion Sweeper ...
6158
AdvectionDiffusionSweeper<>::enable_config_options();
62-
// ... then we initialize all options other default options and parse given parameters ...
6359
pfasst::init(argc, argv);
64-
pfasst::encap::set_logfile_from_options();
6560

6661
run_vanilla_sdc(0.0);
6762
}

examples/boris/boris_sweeper.hpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ namespace pfasst
380380

381381
// building rules for Q_E and Q_I:
382382
// Q_E is striclty lower diagonal matrix with delta nodes of column index
383-
// Q_I is lower diagonal matrix with first row and column all zero and delta nodes of
383+
// Q_I is lower diagonal matrix with first row and column all zero and delta nodes of
384384
// column index minus one
385385
Matrix<time> qe_mat = Matrix<time>(nnodes, nnodes);
386386
qe_mat.fill(time(0.0));
@@ -423,7 +423,7 @@ namespace pfasst
423423
this->energy_evals.front() = this->energy_evals.back();
424424
}
425425

426-
virtual void evaluate(size_t m) override
426+
void evaluate(size_t m)
427427
{
428428
// Vector3d<scalar> vel; vel.fill(scalar(0.0));
429429
// Vector3d<scalar> B; B.fill(scalar(0.0));
@@ -448,6 +448,13 @@ namespace pfasst
448448
this->f_evals++;
449449
}
450450

451+
virtual void reevaluate(bool initial) override
452+
{
453+
for (size_t m = 0; m < this->get_quadrature()->get_num_nodes(); m++) {
454+
this->evaluate(m);
455+
}
456+
}
457+
451458
virtual void predict(bool initial) override
452459
{
453460
UNUSED(initial);

include/pfasst/encap/encap_sweeper.hpp

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -108,19 +108,16 @@ namespace pfasst
108108
}
109109

110110
if (coarse) {
111-
size_t num_fas = this->quadrature->left_is_node() ? num_nodes -1 : num_nodes;
112-
for (size_t m = 0; m < num_fas; m++) {
111+
for (size_t m = 0; m < num_nodes; m++) {
113112
this->fas_corrections.push_back(this->get_factory()->create(pfasst::encap::solution));
114113
}
115114
}
116-
117115
}
118116

119117
//! @{
120118
virtual void spread() override
121119
{
122120
for (size_t m = 1; m < this->quadrature->get_num_nodes(); m++) {
123-
// this->get_state(m)->copy(this->start_state);
124121
this->state[m]->copy(this->state[0]);
125122
}
126123
}
@@ -190,18 +187,12 @@ namespace pfasst
190187
}
191188

192189
/**
193-
* evaluates the right hand side at given time node
194-
*
195-
* This evaluates the right hand side at the given time node with index `m` as returned by
196-
* pfasst::encap::EncapSweeper::get_nodes:
197-
*
198-
* @param[in] m index of the time node to evaluate at
190+
* Re-evaluate function values.
199191
*
200192
* @note This method must be implemented in derived sweepers.
201193
*/
202-
virtual void evaluate(size_t m)
194+
virtual void reevaluate(bool initial_only=false)
203195
{
204-
UNUSED(m);
205196
throw NotImplementedYet("sweeper");
206197
}
207198

@@ -282,8 +273,9 @@ namespace pfasst
282273
virtual void recv(ICommunicator* comm, int tag, bool blocking) override
283274
{
284275
this->start_state->recv(comm, tag, blocking);
285-
// XXX
286-
this->state.front()->copy(this->start_state);
276+
if (this->quadrature->left_is_node()) {
277+
this->state[0]->copy(this->start_state);
278+
}
287279
}
288280

289281
virtual void broadcast(ICommunicator* comm) override
@@ -292,8 +284,6 @@ namespace pfasst
292284
this->start_state->copy(this->end_state);
293285
}
294286
this->start_state->broadcast(comm);
295-
// XXX
296-
this->state.front()->copy(this->start_state);
297287
}
298288
//! @}
299289
};

0 commit comments

Comments
 (0)