ExaDG
Loading...
Searching...
No Matches
push_back_vectors.h
1/* ______________________________________________________________________
2 *
3 * ExaDG - High-Order Discontinuous Galerkin for the Exa-Scale
4 *
5 * Copyright (C) 2021 by the ExaDG authors
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 * ______________________________________________________________________
20 */
21
22#ifndef INCLUDE_EXADG_TIME_INTEGRATION_PUSH_BACK_VECTORS_H_
23#define INCLUDE_EXADG_TIME_INTEGRATION_PUSH_BACK_VECTORS_H_
24
25// C/C++
26#include <vector>
27
28namespace ExaDG
29{
30/*
31 * This function implements a push-back operation that is needed in multistep time integration
32 * schemes like BDF schemes in order to update the solution vectors from one time step to the
33 * next. The prerequisite to call this function is that the type VectorType implements a
34 * swap-function!
35 */
36template<typename VectorType>
37void
38push_back(std::vector<VectorType> & vector)
39{
40 /*
41 * time t
42 * --------> t_{n-3} t_{n-2} t_{n-1} t_{n}
43 * _______________|_________|________|_________|___________\
44 * | | | | /
45 *
46 * vector: vec[3] vec[2] vec[1] vec[0]
47 *
48 * <- vec[3] <- vec[2] <- vec[1] <- vec[0] <- vec[3] <--
49 * |___________________________________________________|
50 *
51 */
52
53 // solution at t_{n-i} <-- solution at t_{n-i+1}
54 for(int i = vector.size() - 1; i > 0; --i)
55 {
56 vector[i].swap(vector[i - 1]);
57 }
58}
59
60} // namespace ExaDG
61
62#endif /* INCLUDE_EXADG_TIME_INTEGRATION_PUSH_BACK_VECTORS_H_ */
Definition driver.cpp:33