-
Notifications
You must be signed in to change notification settings - Fork 1
/
eulerforward.h
43 lines (35 loc) · 1.03 KB
/
eulerforward.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#ifndef EULERFORWARD_H
#define EULERFORWARD_H
#include <algorithm>
#include <cstddef>
#include <execution>
#include <ranges>
#include "arithmeticwith.h"
template<ArithmeticWith<numeric_val> T, typename... Args>
void EulerForward(
std::ranges::common_range auto& U,
std::ranges::common_range auto& dflux,
T t, T dt, T dx,
const std::ranges::common_range auto& max_eigenvalues,
std::size_t n_ghost_points,
auto&& calcdSpace,
auto&& updateGhostPoints,
Args... opts_args) {
const std::size_t n_size = std::ranges::size(U)
- 2 * n_ghost_points;
dflux = calcdSpace(U, t, dx, max_eigenvalues,
n_size, opts_args...); // L1 = L[u^n]
// std::valarray<Vector4<T>> res(Vector4<T>::ZERO, U.size());
// L[u] = (-) dF[u]/dx
// Y2 = U + Vector4<T>(dt) * dflux;
std::transform(
std::execution::par_unseq,
std::ranges::begin(U), std::ranges::end(U),
std::ranges::begin(dflux),
std::ranges::begin(U),
[dt](const auto u, const auto df) {
return u + dt * df;
});
updateGhostPoints(U);
}
#endif // EULERFORWARD_H