Line data Source code
1 : // Class BConds
2 : // This is the container class for the field BCs.
3 : // It calls the findBCNeighbors and apply in the
4 : // respective BC classes to apply field BCs
5 : //
6 : #ifndef IPPL_FIELD_BC_H
7 : #define IPPL_FIELD_BC_H
8 :
9 : #include <array>
10 : #include <iostream>
11 : #include <memory>
12 :
13 : #include "Field/BcTypes.h"
14 :
15 : namespace ippl {
16 : /*!
17 : * A container for boundary conditions
18 : * @tparam Field the type of the field to which the boundary conditions will be applied
19 : * @tparam Dim the rank of the field (redundant parameter required to avoid a circular
20 : * dependency loop between Field and BConds)
21 : */
22 : template <typename Field, unsigned Dim>
23 : class BConds {
24 : public:
25 : using bc_type = detail::BCondBase<Field>;
26 : using container = std::array<std::shared_ptr<bc_type>, 2 * Dim>;
27 : using iterator = typename container::iterator;
28 : using const_iterator = typename container::const_iterator;
29 :
30 612 : BConds() = default;
31 742 : ~BConds() = default;
32 :
33 : void findBCNeighbors(Field& field);
34 : void apply(Field& field);
35 : void assignGhostToPhysical(Field& field);
36 :
37 : bool changesPhysicalCells() const;
38 : virtual void write(std::ostream&) const;
39 :
40 : const std::shared_ptr<bc_type>& operator[](const int& i) const noexcept { return bc_m[i]; }
41 :
42 4380 : std::shared_ptr<bc_type>& operator[](const int& i) noexcept { return bc_m[i]; }
43 :
44 : private:
45 : container bc_m;
46 : };
47 :
48 : template <typename Field, unsigned Dim>
49 : inline std::ostream& operator<<(std::ostream& os, const BConds<Field, Dim>& bc) {
50 : bc.write(os);
51 : return os;
52 : }
53 : } // namespace ippl
54 :
55 : #include "Field/BConds.hpp"
56 :
57 : #endif
|