ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
Loading...
Searching...
No Matches
lb_tracers.cpp
Go to the documentation of this file.
1
/*
2
* Copyright (C) 2010-2022 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 VIRTUAL_SITES_INERTIALESS_TRACERS
22
23
#include "
BoxGeometry.hpp
"
24
#include "
LocalBox.hpp
"
25
#include "
cell_system/CellStructure.hpp
"
26
#include "
errorhandling.hpp
"
27
#include "
forces.hpp
"
28
#include "
lb/Solver.hpp
"
29
#include "
lb/particle_coupling.hpp
"
30
31
static
bool
lb_sanity_checks
(
LB::Solver
const
&lb) {
32
if
(not lb.
is_solver_set
()) {
33
runtimeErrorMsg
() <<
"LB needs to be active for inertialess tracers."
;
34
return
true
;
35
}
36
return
false
;
37
}
38
39
void
lb_tracers_add_particle_force_to_fluid
(
CellStructure
&cell_structure,
40
BoxGeometry
const
&box_geo,
41
LocalBox
const
&local_box,
42
LB::Solver
&lb) {
43
if
(
lb_sanity_checks
(lb)) {
44
return
;
45
}
46
auto
const
agrid = lb.
get_agrid
();
47
48
// Distribute summed-up forces from physical particles to ghosts
49
init_forces_ghosts
(cell_structure.
ghost_particles
());
50
cell_structure.
update_ghosts_and_resort_particle
(
Cells::DATA_PART_FORCE
);
51
52
// Keep track of ghost particles (ids) that have already been coupled
53
LB::CouplingBookkeeping
bookkeeping{cell_structure};
54
// Apply particle forces to the LB fluid at particle positions.
55
// For physical particles, also set particle velocity = fluid velocity.
56
for
(
auto
const
&particle_range :
57
{cell_structure.
local_particles
(), cell_structure.
ghost_particles
()}) {
58
for
(
auto
const
&p : particle_range) {
59
if
(!
LB::is_tracer
(p))
60
continue
;
61
if
(bookkeeping.should_be_coupled(p)) {
62
for
(
auto
const
&pos :
63
positions_in_halo
(p.pos(), box_geo, local_box, agrid)) {
64
lb.
add_force_density
(pos, p.force());
65
}
66
}
67
}
68
}
69
70
// Clear ghost forces to avoid double counting later
71
init_forces_ghosts
(cell_structure.
ghost_particles
());
72
}
73
74
void
lb_tracers_propagate
(
CellStructure
&cell_structure,
LB::Solver
const
&lb,
75
double
time_step) {
76
if
(
lb_sanity_checks
(lb)) {
77
return
;
78
}
79
auto
const
verlet_skin = cell_structure.
get_verlet_skin
();
80
auto
const
verlet_skin_sq = verlet_skin * verlet_skin;
81
82
// Advect particles
83
for
(
auto
&p : cell_structure.
local_particles
()) {
84
if
(!
LB::is_tracer
(p))
85
continue
;
86
p.v() = lb.
get_coupling_interpolated_velocity
(p.pos());
87
for
(
auto
i = 0u; i < 3u; i++) {
88
if
(!p.is_fixed_along(i)) {
89
p.pos()[i] += p.v()[i] * time_step;
90
}
91
}
92
// Verlet list update check
93
if
((p.pos() - p.pos_at_last_verlet_update()).norm2() > verlet_skin_sq) {
94
cell_structure.
set_resort_particles
(
Cells::RESORT_LOCAL
);
95
}
96
}
97
}
98
#endif
// VIRTUAL_SITES_INERTIALESS_TRACERS
BoxGeometry.hpp
CellStructure.hpp
LocalBox.hpp
BoxGeometry
Definition
BoxGeometry.hpp:98
LB::CouplingBookkeeping
Keep track of ghost particles that have already been coupled once.
Definition
particle_coupling.hpp:102
LocalBox
Definition
LocalBox.hpp:27
config.hpp
This file contains the defaults for ESPResSo.
errorhandling.hpp
This file contains the errorhandling code for severe errors, like a broken bond or illegal parameter ...
runtimeErrorMsg
#define runtimeErrorMsg()
Definition
errorhandling.hpp:95
init_forces_ghosts
void init_forces_ghosts(ParticleRange const &particles)
Set forces of all ghosts to zero.
Definition
forces.cpp:103
forces.hpp
Force calculation.
Solver.hpp
lb_tracers_propagate
void lb_tracers_propagate(CellStructure &cell_structure, LB::Solver const &lb, double time_step)
Definition
lb_tracers.cpp:74
lb_tracers_add_particle_force_to_fluid
void lb_tracers_add_particle_force_to_fluid(CellStructure &cell_structure, BoxGeometry const &box_geo, LocalBox const &local_box, LB::Solver &lb)
Definition
lb_tracers.cpp:39
lb_sanity_checks
static bool lb_sanity_checks(LB::Solver const &lb)
Definition
lb_tracers.cpp:31
Cells::DATA_PART_FORCE
@ DATA_PART_FORCE
Particle::f.
Definition
CellStructure.hpp:71
Cells::RESORT_LOCAL
@ RESORT_LOCAL
Definition
CellStructure.hpp:59
LB::is_tracer
bool is_tracer(Particle const &p)
Definition
particle_coupling.hpp:144
positions_in_halo
std::vector< Utils::Vector3d > positions_in_halo(Utils::Vector3d const &pos, BoxGeometry const &box_geo, LocalBox const &local_box, double agrid)
Return a vector of positions shifted by +,- box length in each coordinate.
Definition
particle_coupling.cpp:163
particle_coupling.hpp
CellStructure
Describes a cell structure / cell system.
Definition
CellStructure.hpp:134
CellStructure::ghost_particles
ParticleRange ghost_particles() const
Definition
CellStructure.hpp:274
CellStructure::update_ghosts_and_resort_particle
void update_ghosts_and_resort_particle(unsigned data_parts)
Update ghost particles, with particle resort if needed.
Definition
CellStructure.cpp:299
CellStructure::set_resort_particles
void set_resort_particles(Cells::Resort level)
Increase the local resort level at least to level.
Definition
CellStructure.hpp:370
CellStructure::get_verlet_skin
auto get_verlet_skin() const
Get the Verlet skin.
Definition
CellStructure.hpp:454
CellStructure::local_particles
ParticleRange local_particles() const
Definition
CellStructure.hpp:270
LB::Solver
Definition
lb/Solver.hpp:35
LB::Solver::add_force_density
void add_force_density(Utils::Vector3d const &pos, Utils::Vector3d const &force_density)
Add a force density to the fluid at the given position.
Definition
lb/Solver.cpp:269
LB::Solver::get_coupling_interpolated_velocity
Utils::Vector3d get_coupling_interpolated_velocity(Utils::Vector3d const &pos) const
Calculate the interpolated fluid velocity in MD units.
Definition
lb/Solver.cpp:222
LB::Solver::is_solver_set
bool is_solver_set() const
Return true if a LB solver is active.
Definition
lb/Solver.cpp:64
LB::Solver::get_agrid
double get_agrid() const
Get the LB grid spacing.
Definition
lb/Solver.cpp:175
src
core
virtual_sites
lb_tracers.cpp
Generated on Thu Dec 19 2024 02:13:16 for ESPResSo by
1.9.8