hemocell
Loading...
Searching...
No Matches
particleGrid.h
Go to the documentation of this file.
1/*
2This file is part of the HemoCell library
3
4HemoCell is developed and maintained by the Computational Science Lab
5in the University of Amsterdam. Any questions or remarks regarding this library
6can be sent to: info@hemocell.eu
7
8When using the HemoCell library in scientific work please cite the
9corresponding paper: https://doi.org/10.3389/fphys.2017.00563
10
11The HemoCell library is free software: you can redistribute it and/or
12modify it under the terms of the GNU Affero General Public License as
13published by the Free Software Foundation, either version 3 of the
14License, or (at your option) any later version.
15
16The library is distributed in the hope that it will be useful,
17but WITHOUT ANY WARRANTY; without even the implied warranty of
18MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19GNU Affero General Public License for more details.
20
21You should have received a copy of the GNU Affero General Public License
22along with this program. If not, see <http://www.gnu.org/licenses/>.
23*/
24#ifndef HEMO_PARTICLEGRID_H
25#define HEMO_PARTICLEGRID_H
26
27#include "hemoCellParticle.h"
28
29#include <cmath>
30#include <vector>
31
32namespace hemo {
33
41inline plint nearestNode(T x) {
42 return plint(std::floor(x + 0.5));
43}
44
68public:
77 void build(const std::vector<HemoCellParticle> & particles, const plb::Dot3D & location, plint nx, plint ny,
78 plint nz);
79
81 inline unsigned int index(plint x, plint y, plint z) const { return z + nz * (y + ny * x); }
83 inline const unsigned int * begin(unsigned int node) const { return particleIndices.data() + nodeStart[node]; }
85 inline const unsigned int * end(unsigned int node) const { return particleIndices.data() + nodeStart[node + 1]; }
87 inline unsigned int count(unsigned int node) const { return nodeStart[node + 1] - nodeStart[node]; }
88 inline plint getNx() const { return nx; }
89 inline plint getNy() const { return ny; }
90 inline plint getNz() const { return nz; }
91
92private:
93 plint nx = 0, ny = 0, nz = 0;
94 std::vector<unsigned int> nodeStart;
95 std::vector<unsigned int> particleIndices;
96 std::vector<unsigned int> nodeOfParticle;
97};
98
122void computePairRepulsion(std::vector<HemoCellParticle> & particles, const ParticleGrid & grid, T r_const, T r_cutoff);
123
124}
125#endif // HEMO_PARTICLEGRID_H
Cell list that bins the particles of one atomic block onto its lattice nodes.
Definition particleGrid.h:67
std::vector< unsigned int > particleIndices
particle indices, grouped per node
Definition particleGrid.h:95
std::vector< unsigned int > nodeStart
nx*ny*nz+1 offsets into particleIndices
Definition particleGrid.h:94
plint nx
Definition particleGrid.h:93
const unsigned int * begin(unsigned int node) const
First particle index of node node (see class description).
Definition particleGrid.h:83
plint nz
Definition particleGrid.h:93
unsigned int count(unsigned int node) const
Number of particles binned in node node.
Definition particleGrid.h:87
unsigned int index(plint x, plint y, plint z) const
Linear index of block-local node (x,y,z); the caller guarantees it is inside the grid.
Definition particleGrid.h:81
std::vector< unsigned int > nodeOfParticle
scratch: node of each particle (or sentinel)
Definition particleGrid.h:96
plint getNz() const
Definition particleGrid.h:90
plint ny
Definition particleGrid.h:93
void build(const std::vector< HemoCellParticle > &particles, const plb::Dot3D &location, plint nx, plint ny, plint nz)
(Re)build the grid.
Definition particleGrid.cpp:30
const unsigned int * end(unsigned int node) const
One past the last particle index of node node.
Definition particleGrid.h:85
plint getNx() const
Definition particleGrid.h:88
plint getNy() const
Definition particleGrid.h:89
double T
Definition constant_defaults.h:137
long int plint
Definition constant_defaults.h:149
Definition config.cpp:37
void computePairRepulsion(std::vector< HemoCellParticle > &particles, const ParticleGrid &grid, const T r_const, const T r_cutoff)
Accumulate the pairwise inter-cell repulsion force into sv.force_repulsion of all binned particles.
Definition particleGrid.cpp:116
plint nearestNode(T x)
The lattice node nearest to a coordinate [lattice units].
Definition particleGrid.h:41