15 template<
typename time>
18 , abs_residual_tol(0.0)
19 , rel_residual_tol(0.0)
22 template<
typename time>
25 return this->state[m];
28 template<
typename time>
31 return this->fas_corrections[m];
34 template<
typename time>
37 return this->saved_state[m];
52 template<
typename time>
55 this->abs_residual_tol = time(config::get_value<double>(
"abs_res_tol", this->abs_residual_tol));
56 this->rel_residual_tol = time(config::get_value<double>(
"rel_res_tol", this->rel_residual_tol));
67 template<
typename time>
70 auto const nodes = this->quadrature->get_nodes();
71 auto const num_nodes = this->quadrature->get_num_nodes();
76 for (
size_t m = 0; m < num_nodes; m++) {
84 for (
size_t m = 0; m < num_nodes; m++) {
94 template<
typename time>
97 for (
size_t m = 1; m < this->quadrature->get_num_nodes(); m++) {
98 this->state[m]->copy(this->state[0]);
102 template<
typename time>
107 this->saved_state[0]->copy(state[0]);
109 for (
size_t m = 0; m < this->saved_state.size(); m++) {
110 this->saved_state[m]->copy(state[m]);
115 template<
typename time>
118 this->quadrature = quadrature;
121 template<
typename time>
124 return this->quadrature;
127 template<
typename time>
130 return this->start_state;
133 template<
typename time>
136 return this->quadrature->get_nodes();
139 template<
typename time>
142 this->factory = factory;
145 template<
typename time>
151 template<
typename time>
154 return this->end_state;
160 template<
typename time>
169 template<
typename time>
179 template<
typename time>
186 template<
typename time>
190 this->abs_residual_tol = abs_residual_tol;
191 this->rel_residual_tol = rel_residual_tol;
192 this->residual_norm_order = order;
198 template<
typename time>
217 template<
typename time>
220 if (this->abs_residual_tol > 0.0 || this->rel_residual_tol > 0.0) {
221 if (this->residuals.size() == 0) {
222 for (
size_t m = 0; m < this->get_nodes().size(); m++) {
226 this->residual(this->get_controller()->get_step_size(), this->residuals);
227 vector<time> anorms, rnorms;
228 for (
size_t m = 0; m < this->get_nodes().size(); m++) {
229 anorms.push_back(this->residuals[m]->
norm0());
230 rnorms.push_back(anorms.back() / this->get_state(m)->norm0());
232 auto amax = *std::max_element(anorms.begin(), anorms.end());
233 auto rmax = *std::max_element(rnorms.begin(), rnorms.end());
234 if (amax < this->abs_residual_tol || rmax < this->rel_residual_tol) {
241 template<
typename time>
244 this->start_state->post(comm, tag);
247 template<
typename time>
250 this->end_state->send(comm, tag, blocking);
253 template<
typename time>
256 this->start_state->recv(comm, tag, blocking);
257 if (this->quadrature->left_is_node()) {
258 this->state[0]->copy(this->start_state);
262 template<
typename time>
265 if (comm->
rank() == comm->
size() - 1) {
266 this->start_state->copy(this->end_state);
268 this->start_state->broadcast(comm);
272 template<
typename time>
280 template<
typename time>
283 shared_ptr<const EncapSweeper<time>> y = dynamic_pointer_cast<
const EncapSweeper<time>>(x);
virtual bool converged() override
Return convergence status.
virtual void recv(ICommunicator *comm, int tag, bool blocking) override
virtual void send(ICommunicator *comm, int tag, bool blocking) override
virtual shared_ptr< Encapsulation< time > > get_end_state()
Host based encapsulated base sweeper.
Interface for quadrature handlers.
Not implemented yet exception.
virtual shared_ptr< Encapsulation< time > > get_state(size_t m) const
Retrieve solution values of current iteration at time node index m.
void set_residual_tolerances(time abs_residual_tol, time rel_residual_tol, int order=0)
Set residual tolerances for convergence checking.
virtual void integrate(time dt, vector< shared_ptr< Encapsulation< time >>> dst) const
Integrates values of right hand side at all time nodes \( t \in [0,M-1] \) simultaneously.
virtual shared_ptr< const IQuadrature< time > > get_quadrature() const
virtual void spread() override
Initialize solution values at all time nodes with meaningful values.
EncapSweeper< time > & as_encap_sweeper(shared_ptr< ISweeper< time >> x)
Abstract interface of factory for creating Encapsulation objects.
virtual void save(bool initial_only) override
Save states (and/or function values) at all nodes.
virtual void setup(bool coarse) override
Setup (allocate etc) the sweeper.
virtual void set_factory(shared_ptr< EncapFactory< time >> factory)
virtual void reevaluate(bool initial_only=false)
Re-evaluate function values.
virtual void residual(time dt, vector< shared_ptr< Encapsulation< time >>> dst) const
Compute residual at each SDC node (including FAS corrections).
virtual shared_ptr< Encapsulation< time > > get_saved_state(size_t m) const
Retrieve solution values of previous iteration at time node index m.
virtual void set_options() override
Set options from command line etc.
Data/solution encapsulation.
virtual void broadcast(ICommunicator *comm) override
#define UNUSED(expr)
Denoting unused function parameters for omitting compiler warnings.
virtual const vector< time > get_nodes() const
virtual void advance() override
Advance from one time step to the next.
Abstract interface for communicators.
virtual shared_ptr< Encapsulation< time > > get_start_state() const
virtual shared_ptr< Encapsulation< time > > get_tau(size_t m) const
Retrieve FAS correction of current iteration at time node index m.
virtual shared_ptr< EncapFactory< time > > get_factory() const
virtual void post(ICommunicator *comm, int tag) override
static precision norm0(const vector< precision > &data)
virtual void set_quadrature(shared_ptr< IQuadrature< time >> quadrature)