1#ifndef OPALX_SRC_PARTBUNCH_BCHANDLER_HPP
2#define OPALX_SRC_PARTBUNCH_BCHANDLER_HPP
28template <
unsigned Dim>
58 }
else if (str ==
"PERIODIC") {
60 }
else if (str ==
"DIRICHLET") {
64 "BCHandler::strToBCType",
"Unknown boundary condition type: " + str);
84 template <
typename... Bcs>
86 if (
sizeof...(bcs) !=
Dim) {
88 "BCHandler::BCHandler",
"Number of passed BCs does not match dimensionality!");
99 for (
unsigned int d = 0; d <
Dim; ++d) {
100 if (bcs_m[d] != bc_type)
return false;
115 int base_case = bcs_m[0];
116 for (
unsigned int d = 1; d <
Dim; ++d) {
117 if (bcs_m[d] != base_case)
return false;
129 os <<
"* BCHandler<" <<
Dim <<
">: [";
130 for (
unsigned int d = 0; d <
Dim; ++d) {
131 switch (h.
bcs_m[d]) {
145 if (d + 1 <
Dim) os <<
", ";
178 template <
typename Field>
180 typedef ippl::BConds<Field, Dim> bc_type;
181 bc_type bc_container;
183 for (
unsigned int face = 0; face < 2 *
Dim; ++face) {
184 unsigned int d = face / 2;
186 if (bcs_m[d] == PERIODIC) {
187 bc_container[face] = std::make_shared<ippl::PeriodicFace<Field>>(face);
188 }
else if (bcs_m[d] == DIRICHLET) {
189 bc_container[face] = std::make_shared<ippl::ZeroFace<Field>>(face);
190 }
else if (bcs_m[d] ==
OPEN) {
191 bc_container[face] = std::make_shared<ippl::NoBcFace<Field>>(face);
193 throw OpalException(
"BCHandler::toIPPLBConds",
"Unsupported BCType encountered.");
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.
ippl::BConds< Field, Dim > toIPPLBConds() const
BCType
Supported boundary condition types.