ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
Loading...
Searching...
No Matches
LBWalberla.cpp
Go to the documentation of this file.
1/*
2 * Copyright (C) 2019-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#include "config/config.hpp"
20
21#ifdef WALBERLA
22
23#include "LBWalberla.hpp"
24
25#include "BoxGeometry.hpp"
26#include "LocalBox.hpp"
27#include "communication.hpp"
28#include "errorhandling.hpp"
29#include "integrate.hpp"
30#include "system/System.hpp"
31#include "thermostat.hpp"
32
34
35#include <utils/Vector.hpp>
37
38#include <optional>
39
40namespace LB {
41
42bool LBWalberla::is_gpu() const { return lb_fluid->is_gpu(); }
43
44double LBWalberla::get_kT() const { return lb_fluid->get_kT(); }
45
47 return lb_fluid->get_pressure_tensor();
48}
49
50void LBWalberla::propagate() { lb_fluid->integrate(); }
51
52void LBWalberla::lebc_sanity_checks(unsigned int shear_direction,
53 unsigned int shear_plane_normal) const {
54 lb_fluid->check_lebc(shear_direction, shear_plane_normal);
55}
56
57std::optional<Utils::Vector3d>
59 bool consider_points_in_halo) const {
60 return lb_fluid->get_velocity_at_pos(pos, consider_points_in_halo);
61}
62
63std::optional<double>
65 bool consider_points_in_halo) const {
66 return lb_fluid->get_density_at_pos(pos, consider_points_in_halo);
67}
68
70 return lb_fluid->get_momentum();
71}
72
74 Utils::Vector3d const &force) {
75 return lb_fluid->add_force_at_pos(pos, force);
76}
77
78void LBWalberla::add_forces_at_pos(std::vector<Utils::Vector3d> const &pos,
79 std::vector<Utils::Vector3d> const &forces) {
80 lb_fluid->add_forces_at_pos(pos, forces);
81}
82
83std::vector<Utils::Vector3d>
84LBWalberla::get_velocities_at_pos(std::vector<Utils::Vector3d> const &pos) {
85 return lb_fluid->get_velocities_at_pos(pos);
86}
87
88void LBWalberla::veto_time_step(double time_step) const {
89 walberla_tau_sanity_checks("LB", lb_params->get_tau(), time_step);
90}
91
92void LBWalberla::veto_kT(double kT) const {
93 auto const energy_conversion =
94 Utils::int_pow<2>(lb_params->get_agrid() / lb_params->get_tau());
95 auto const lb_kT = lb_fluid->get_kT() * energy_conversion;
96 if (not ::Thermostat::are_kT_equal(lb_kT, kT)) {
97 throw std::runtime_error("Temperature change not supported by LB");
98 }
99}
100
101void LBWalberla::sanity_checks(System::System const &system) const {
102 auto const agrid = lb_params->get_agrid();
103 auto [lb_left, lb_right] = lb_fluid->get_lattice().get_local_domain();
104 lb_left *= agrid;
105 lb_right *= agrid;
106 auto const &md_left = system.local_geo->my_left();
107 auto const &md_right = system.local_geo->my_right();
108 walberla_agrid_sanity_checks("LB", md_left, md_right, lb_left, lb_right,
109 agrid);
110 // LB time step and MD time step must agree
111 walberla_tau_sanity_checks("LB", lb_params->get_tau(),
112 system.get_time_step());
113}
114
115} // namespace LB
116
117#endif // WALBERLA
LBWalberlaBase provides the public interface of the LB waLBerla bridge.
Vector implementation and trait types for boost qvm interoperability.
__global__ float * force
__shared__ int pos[MAXDEPTH *THREADS5/WARPSIZE]
Main system class.
auto get_time_step() const
Get time_step.
std::shared_ptr< LocalBox > local_geo
This file contains the defaults for ESPResSo.
This file contains the errorhandling code for severe errors, like a broken bond or illegal parameter ...
void walberla_agrid_sanity_checks(std::string method, Utils::Vector3d const &geo_left, Utils::Vector3d const &geo_right, Utils::Vector3d const &lattice_left, Utils::Vector3d const &lattice_right, double agrid)
void walberla_tau_sanity_checks(std::string method, double tau, double time_step)
Molecular dynamics integrator.
bool is_gpu() const
Utils::Vector3d get_momentum() const
std::shared_ptr< LBWalberlaBase > lb_fluid
Utils::VectorXd< 9 > get_pressure_tensor() 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
double get_kT() const
std::shared_ptr< LBWalberlaParams > lb_params
std::vector< Utils::Vector3d > get_velocities_at_pos(std::vector< Utils::Vector3d > const &pos)
void sanity_checks(System::System const &system) 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)