Mallard 0.8.0
Unstructured, GPU accelerated, high-order finite volume CFD solver
Mallard website
Loading...
Searching...
No Matches
periodic.h
Go to the documentation of this file.
1
12#ifndef PERIODIC_H
13#define PERIODIC_H
14
15#include <array>
16#include <cstdint>
17#include <map>
18#include <string>
19#include <vector>
20
21#include "mesh.h"
22
29 std::vector<std::string> zones; // the zones joined by the pairs
30 std::vector<std::array<rtype, N_DIM>> translations;
31 std::vector<uint32_t> key;
32 std::vector<std::array<int8_t, 3>> lattice;
33};
34
41std::vector<size_t> periodic_directions(const std::vector<Mesh::PeriodicPair> & pairs, PeriodicNodes & result);
42
45
51 public:
52 using Point = std::array<rtype, N_DIM>;
53 using Cell = std::array<int64_t, N_DIM>;
54 static constexpr int N_NEIGHBORS = N_DIM == 2 ? 9 : 27;
55
56 explicit PeriodicGrid(rtype spacing) : h(spacing), tol(periodic_tolerance(spacing)) {}
57
58 Cell cell_of(const Point & x) const;
60 static Cell neighbor(const Cell & c, int m);
61 void insert(uint32_t id, const Point & x) { grid[cell_of(x)].push_back({id, x}); }
63 uint32_t find(const Point & y, uint32_t & match) const;
64
65 private:
66 rtype h, tol;
67 std::map<Cell, std::vector<std::pair<uint32_t, Point>>> grid;
68};
69
71std::string periodic_point_string(const std::array<rtype, N_DIM> & x);
72
81PeriodicNodes match_periodic_nodes(const std::vector<std::array<rtype, N_DIM>> & nodes,
82 const std::vector<Mesh::BoundaryFace> & boundary_faces,
83 const std::vector<Mesh::PeriodicPair> & pairs);
84
85#endif // PERIODIC_H
Points on a grid of spacing h. A point within the tolerance of a query lies in one of the 3^N_DIM gri...
Definition periodic.h:50
void insert(uint32_t id, const Point &x)
Definition periodic.h:61
static Cell neighbor(const Cell &c, int m)
Neighbor m of cell c, m in [0, N_NEIGHBORS) (c itself included).
Definition periodic.cpp:107
static constexpr int N_NEIGHBORS
Definition periodic.h:54
PeriodicGrid(rtype spacing)
Definition periodic.h:56
std::array< int64_t, N_DIM > Cell
Definition periodic.h:53
uint32_t find(const Point &y, uint32_t &match) const
Number of points within the tolerance of y; match is the last one's id.
Definition periodic.cpp:116
std::array< rtype, N_DIM > Point
Definition periodic.h:52
Cell cell_of(const Point &x) const
Definition periodic.cpp:101
KOKKOS_INLINE_FUNCTION rtype dot(const rtype *a, const rtype *b)
Compute the dot product of two arrays.
Definition common_math.h:32
float rtype
Definition common_typedef.h:39
#define N_DIM
Definition common_typedef.h:28
Mesh class declaration.
std::string periodic_point_string(const std::array< rtype, N_DIM > &x)
"(x, y[, z])", for error messages.
Definition periodic.cpp:134
std::vector< size_t > periodic_directions(const std::vector< Mesh::PeriodicPair > &pairs, PeriodicNodes &result)
Check the pairs (zones used once, nonzero translations, at most three distinct ones) and fill result....
Definition periodic.cpp:69
PeriodicNodes match_periodic_nodes(const std::vector< std::array< rtype, N_DIM > > &nodes, const std::vector< Mesh::BoundaryFace > &boundary_faces, const std::vector< Mesh::PeriodicPair > &pairs)
Match the nodes of zone_b of every pair to the nodes of zone_a translated by the pair's translation (...
Definition periodic.cpp:140
rtype periodic_tolerance(rtype h)
Matching tolerance of a pair whose zones' shortest edge is h.
Definition periodic.cpp:99
Periodic classes of the mesh nodes: the translation of each lattice direction, and per node its key (...
Definition periodic.h:28
std::vector< std::array< int8_t, 3 > > lattice
Definition periodic.h:32
std::vector< std::array< rtype, N_DIM > > translations
Definition periodic.h:30
std::vector< std::string > zones
Definition periodic.h:29
std::vector< uint32_t > key
Definition periodic.h:31
std::array< double, N_DIM > Point
Point in space.
Definition synthetic_inflow.h:34
CellSetup< ExecSpace > c
Definition teno_setup.cpp:1810