ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
Loading...
Searching...
No Matches
LBWalberla.hpp
Go to the documentation of this file.
1/*
2 * Copyright (C) 2023 The ESPResSo project
3 *
4 * This file is part of ESPResSo.
5 *
6 * ESPResSo is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * ESPResSo is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#pragma once
21
22#include <config/config.hpp>
23
24#ifdef ESPRESSO_WALBERLA
25
26#include "system/Leaf.hpp"
27
28#include <utils/Vector.hpp>
29
30#include <functional>
31#include <memory>
32#include <optional>
33#include <stdexcept>
34#include <utility>
35#include <vector>
36
37class LBWalberlaBase;
38namespace System {
39class System;
40}
41
42namespace LB {
43
45 LBWalberlaParams(double agrid, double tau) : m_agrid(agrid), m_tau(tau) {}
46 double get_agrid() const { return m_agrid; }
47 double get_tau() const { return m_tau; }
48
49private:
50 double m_agrid;
51 double m_tau;
52};
53
54struct LBWalberla : public System::Leaf<LBWalberla> {
55 std::shared_ptr<LBWalberlaBase> lb_fluid;
56 std::shared_ptr<LBWalberlaParams> lb_params;
57 LBWalberla(std::shared_ptr<LBWalberlaBase> lb_fluid_,
58 std::shared_ptr<LBWalberlaParams> lb_params_)
59 : lb_fluid{std::move(lb_fluid_)}, lb_params{std::move(lb_params_)} {}
60 double get_kT() const;
61 auto get_tau() const { return lb_params->get_tau(); }
62 auto get_agrid() const { return lb_params->get_agrid(); }
63 auto get_lattice_speed() const { return get_agrid() / get_tau(); }
65 bool is_gpu() const;
66 std::optional<Utils::Vector3d>
68 bool consider_points_in_halo) const;
69 std::optional<double> get_density_at_pos(Utils::Vector3d const &pos,
70 bool consider_points_in_halo) const;
72 std::function<bool(Utils::Vector3d const &)>
73 make_lattice_position_checker(bool consider_points_in_halo) const;
74 bool add_force_at_pos(Utils::Vector3d const &pos,
75 Utils::Vector3d const &force);
76 void add_forces_at_pos(std::vector<Utils::Vector3d> const &pos,
77 std::vector<Utils::Vector3d> const &forces);
78 std::vector<double>
79 get_densities_at_pos(std::vector<Utils::Vector3d> const &pos);
80 std::vector<Utils::Vector3d>
81 get_velocities_at_pos(std::vector<Utils::Vector3d> const &pos);
82 void propagate();
86 void veto_time_step(double time_step) const;
87 void veto_kT(double kT) const;
88 void sanity_checks(System::System const &system) const;
89 void lebc_sanity_checks(unsigned int shear_direction,
90 unsigned int shear_plane_normal) const;
91
93 void veto_boxl_change() const {
94 throw std::runtime_error("MD cell geometry change not supported by LB");
95 }
96 void on_boxl_change() const { veto_boxl_change(); }
97 void on_node_grid_change() const {
98 throw std::runtime_error("MPI topology change not supported by LB");
99 }
100 void on_timestep_change() const {}
101 void on_temperature_change() const {}
105 LBWalberlaParams &params, double kT,
106 unsigned int seed);
107};
108
109} // namespace LB
110
111#endif // ESPRESSO_WALBERLA
Vector implementation and trait types for boost qvm interoperability.
Interface of a lattice-based fluid model.
Abstract class that represents a component of the system.
Main system class.
STL namespace.
double get_agrid() const
double get_tau() const
LBWalberlaParams(double agrid, double tau)
void update_collision_model()
auto get_agrid() const
std::vector< double > get_densities_at_pos(std::vector< Utils::Vector3d > const &pos)
bool is_gpu() const
Utils::Vector3d get_momentum() const
auto get_lattice_speed() const
std::shared_ptr< LBWalberlaBase > lb_fluid
Utils::VectorXd< 9 > get_pressure_tensor() const
void ghost_communication_vel()
auto get_tau() const
std::optional< Utils::Vector3d > get_velocity_at_pos(Utils::Vector3d const &pos, bool consider_points_in_halo) const
void veto_time_step(double time_step) const
void add_forces_at_pos(std::vector< Utils::Vector3d > const &pos, std::vector< Utils::Vector3d > const &forces)
void veto_kT(double kT) const
std::optional< double > get_density_at_pos(Utils::Vector3d const &pos, bool consider_points_in_halo) const
LBWalberla(std::shared_ptr< LBWalberlaBase > lb_fluid_, std::shared_ptr< LBWalberlaParams > lb_params_)
void on_boxl_change() const
void on_cell_structure_change() const
double get_kT() const
std::shared_ptr< LBWalberlaParams > lb_params
void veto_boxl_change() const
std::vector< Utils::Vector3d > get_velocities_at_pos(std::vector< Utils::Vector3d > const &pos)
std::function< bool(Utils::Vector3d const &)> make_lattice_position_checker(bool consider_points_in_halo) const
void ghost_communication()
void on_temperature_change() const
void ghost_communication_pdf()
void on_node_grid_change() const
void sanity_checks(System::System const &system) const
void on_timestep_change() const
void lebc_sanity_checks(unsigned int shear_direction, unsigned int shear_plane_normal) const
bool add_force_at_pos(Utils::Vector3d const &pos, Utils::Vector3d const &force)
void on_lees_edwards_change()