1#ifndef TATOOINE_BOUNDARY_SWITCH_H
2#define TATOOINE_BOUNDARY_SWITCH_H
5#include "grid_sampler.h"
7#include "sampled_field.h"
11template <
typename Real>
15 const size_t left = 0;
16 const size_t right = sampler.size(0) - 1;
17 const size_t bottom = 0;
18 const size_t top = sampler.size(1) - 1;
19 std::vector<vec<Real, 2>> boundary_switch_points;
22 for (
size_t i = 0; i < sampler.size(0) - 1; ++i) {
23 if ((sampler[i][bottom](1) <= 0 && sampler[i + 1][bottom](1) > 0) ||
24 (sampler[i][bottom](1) >= 0 && sampler[i + 1][bottom](1) < 0)) {
26 - sampler[i][bottom](1) / (sampler[i + 1][bottom](1) - sampler[i][bottom](1));
27 boundary_switch_points.emplace_back(
28 sampler.dimension(0)[i] * (1 - t) + sampler.dimension(0)[i + 1] * t,
29 sampler.dimension(1)[bottom]);
32 if ((sampler[i][top](1) <= 0 && sampler[i + 1][top](1) > 0) ||
33 (sampler[i][top](1) >= 0 && sampler[i + 1][top](1) < 0)) {
35 - sampler[i][top](1) / (sampler[i + 1][top](1) - sampler[i][top](1));
36 boundary_switch_points.emplace_back(
37 sampler.dimension(0)[i] * (1 - t) + sampler.dimension(0)[i + 1] * t,
38 sampler.dimension(1)[top]);
42 for (
size_t i = 0; i < sampler.size(1) - 1; ++i) {
43 if ((sampler[left][i](0) <= 0 && sampler[left][i + 1](0) > 0) ||
44 (sampler[left][i](0) >= 0 && sampler[left][i + 1](0) < 0)) {
46 - sampler[left][i](0) / (sampler[left][i + 1](0) - sampler[left][i](0));
47 boundary_switch_points.emplace_back(
48 sampler.dimension(0)[left],
49 sampler.dimension(1)[i] * (1 - t) + sampler.dimension(1)[i + 1] * t);
51 if ((sampler[right][i](0) <= 0 && sampler[right][i + 1](0) > 0) ||
52 (sampler[right][i](0) >= 0 && sampler[right][i + 1](0) < 0)) {
54 - sampler[right][i](0) / (sampler[right][i + 1](0) - sampler[right][i](0));
55 boundary_switch_points.emplace_back(
56 sampler.dimension(0)[right],
57 sampler.dimension(1)[i] * (1 - t) + sampler.dimension(1)[i + 1] * t);
60 return boundary_switch_points;
63template <
typename Real>
Definition: algorithm.h:6
auto find_boundary_switch_points(const grid_sampler< Real, 2, vec< Real, 2 >, interpolation::linear, interpolation::linear > &sampler)
Definition: boundary_switch.h:12
Definition: interpolation.h:16