1#ifndef OPALX_SRC_PARTBUNCH_BCHANDLER_HPP
2#define OPALX_SRC_PARTBUNCH_BCHANDLER_HPP
25template <
unsigned Dim>
57 }
else if (str ==
"PERIODIC") {
61 "Unknown boundary condition type: " + str);
81 template <
typename... Bcs>
84 if (
sizeof...(bcs) !=
Dim) {
86 "Number of passed BCs does not match dimensionality!");
97 for (
unsigned int d = 0; d <
Dim; ++d) {
98 if (bcs_m[d] != bc_type)
return false;
113 bool base_case = bcs_m[0];
114 for (
unsigned int d = 1; d <
Dim; ++d) {
115 if (bcs_m[d] != base_case)
return false;
127 os <<
"* BCHandler<" <<
Dim <<
">: [";
128 for (
unsigned int d = 0; d <
Dim; ++d) {
129 switch (h.
bcs_m[d]) {
130 case OPEN: os <<
"OPEN";
break;
131 case PERIODIC: os <<
"PERIODIC";
break;
132 default: os <<
"UNKNOWN";
break;
134 if (d + 1 <
Dim) os <<
", ";
Handler for boundary conditions per spatial dimension.
bool isAllEqual() const
Check whether all stored BCs are equal (all the same value).
friend std::ostream & operator<<(std::ostream &os, const BCHandler &h)
Stream output helper for debugging and logging.
static BCType strToBCType(const std::string &str)
Convert a textual boundary-condition name to BCType enum.
BCHandler(const BCHandler &other)=default
Defaulted copy constructor.
BCHandler(Bcs... bcs)
Variadic constructor accepting exactly Dim BC values.
std::array< BCType, Dim > bcs_m
Internal storage of boundary conditions, one per dimension.
bool isAll(BCType bc_type) const
Return true if every stored BC equals bc_type.
BCType
Supported boundary condition types.
The base class for all OPAL exceptions.