33 using container_type = std::vector<std::shared_ptr<EKSpecies>>;
37 using iterator =
typename container_type::iterator;
42 std::shared_ptr<walberla::PoissonSolver> m_poisson_solver;
43 container_type m_ekcontainer;
51 void sanity_checks(std::shared_ptr<EKSpecies>
const &new_ek_species)
const {
52 if (not lattice_equal(new_ek_species->get_lattice(),
53 m_poisson_solver->get_lattice())) {
54 throw std::runtime_error(
"EKSpecies lattice incompatible with existing "
55 "Poisson solver lattice");
60 std::shared_ptr<walberla::PoissonSolver>
const &new_ek_solver)
const {
61 if (not m_ekcontainer.empty()) {
62 auto const &old_ek_species = m_ekcontainer.front();
63 if (not lattice_equal(new_ek_solver->get_lattice(),
64 old_ek_species->get_lattice())) {
65 throw std::runtime_error(
"Poisson solver lattice incompatible with "
66 "existing EKSpecies lattice");
72 EKContainer(
double tau, std::shared_ptr<walberla::PoissonSolver> solver)
73 : m_tau{tau}, m_poisson_solver{std::move(solver)}, m_ekcontainer{} {}
75 bool contains(std::shared_ptr<EKSpecies>
const &ek_species)
const noexcept {
76 return std::ranges::find(m_ekcontainer, ek_species) != m_ekcontainer.end();
79 void add(std::shared_ptr<EKSpecies>
const &ek_species) {
81 sanity_checks(ek_species);
82 m_ekcontainer.emplace_back(ek_species);
85 void remove(std::shared_ptr<EKSpecies>
const &ek_species) {
87 std::erase(m_ekcontainer, ek_species);
94 [[nodiscard]]
bool empty() const noexcept {
return m_ekcontainer.empty(); }
98 assert(solver !=
nullptr);
99 sanity_checks(solver);
100 m_poisson_solver = solver;
103 [[nodiscard]]
double get_tau() const noexcept {
return m_tau; }
105 void set_tau(
double tau)
noexcept { m_tau = tau; }
110 bool is_double_precision)
const {
111 m_poisson_solver->add_charge_to_field(
id, valency, is_double_precision);
117 return m_poisson_solver->get_potential_field_id();
121 return m_poisson_solver->get_lattice();