File types.hpp
File List > include > multigrid > types.hpp
Go to the documentation of this file
#pragma once
#include <array>
#include <vector>
namespace mgrid {
using Level = int;
enum CycleType {
vCycle = 1,
wCycle = 2,
threeCycle = 3
};
struct Deriv {
double dx{}, dxu{}, dz{}, dzu{}, dxx{}, dxxu{}, dzz{}, dzzu{}, dxz{}, dxzu{};
};
enum class AxisKind {
bounded,
periodic
};
struct Axis {
int n = 0;
double h = 0.0;
bool periodic = false;
[[nodiscard]] int lo() const { return periodic ? 0 : (n > 0 ? 1 : 0); }
[[nodiscard]] int hi() const { return periodic ? n : (n > 0 ? n - 1 : 0); }
[[nodiscard]] bool edge_lo(int i) const { return !periodic && i == 0; }
[[nodiscard]] bool edge_hi(int i) const { return !periodic && i == n - 1; }
[[nodiscard]] int shift(int i, int d) const {
return (periodic && n > 0) ? ((i + d) % n + n) % n : i + d;
}
};
enum ConditionType {
dirichlet,
neumann,
periodic
};
struct BoundaryPoint {
ConditionType conditionType{dirichlet};
double value{0.0};
};
inline constexpr BoundaryPoint periodicCondition{.conditionType = periodic, .value = 0.0};
using Boundary = std::vector<BoundaryPoint>;
enum BoundaryFlag {
leftBoundary,
rightBoundary,
topBoundary,
bottomBoundary
};
inline constexpr std::array<BoundaryFlag, 4> allBoundaryFlags{leftBoundary, rightBoundary,
topBoundary, bottomBoundary};
} // namespace mgrid