hemocell
Loading...
Searching...
No Matches
hemoCellParticleField.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 HEMOCELLPARTICLEFIELD_H
25#define HEMOCELLPARTICLEFIELD_H
26
27namespace hemo {
28class HemoCellParticleField;
29}
30
31#include "hemoCellFields.h"
33#include "hemoCellParticle.h"
34#include "particleGrid.h"
35
36#include "atomicBlock/blockLattice3D.hh"
37
38namespace hemo {
39class HemoCellParticleField : public plb::AtomicBlock3D {
40public:
42 virtual ~HemoCellParticleField();
50 virtual void applyConstitutiveModel(bool forced = false);
51 virtual void addParticle(HemoCellParticle * particle);
54
55 virtual void removeParticles(plb::Box3D domain);
56 virtual void removeParticles_inverse(plb::Box3D domain);
57 virtual void removeParticles(plb::Box3D domain, plint tag);
58 virtual void removeParticles(plint tag);
59 virtual void findParticles(plb::Box3D domain, std::vector<HemoCellParticle *> & found);
60 virtual void findParticles(plb::Box3D domain, std::vector<const HemoCellParticle *> & found) const;
61 void findParticles(plb::Box3D domain, std::vector<HemoCellParticle *> & found, pluint type);
62 virtual void advanceParticles();
63 void applyRepulsionForce(bool forced = false);
66 void capRepulsionForce(T limit);
67 virtual void interpolateFluidVelocity(plb::Box3D domain);
68 virtual void spreadParticleForce(plb::Box3D domain);
70 void unifyForceVectors();
71 void updateResidenceTime(unsigned int rtime);
72
73 virtual void findInternalParticleGridPoints(plb::Box3D domain);
74 virtual void internalGridPointsMembrane(plb::Box3D domain);
75
77 int deleteIncompleteCells(pluint ctype, bool verbose = true);
79 int deleteIncompleteCells(bool verbose = true);
93 int deleteBrokenCells(plint envelope, bool verbose);
96 void snapshotParticles();
98 void restoreParticles();
100 void applyBoundaryRepulsionForce(bool resetFirst = false);
101 void populateBindingSites(plb::Box3D & domain);
102
103 T eigenValueFromCell(plb::Cell<T, DESCRIPTOR> & cell);
104
105 void solidifyCells();
107
108 void setlocalDomain(plb::Box3D & localDomain_);
109
110 void computeGridPosition(hemo::Array<T, 3> const & position, plint & iX, plint & iY, plint & iZ) const;
111 inline void computeGridPosition(hemo::Array<T, 3> const & position, plint * iX, plint * iY, plint * iZ) const;
112
113 inline bool isContainedABS(const hemo::Array<T, 3> & pos, const plb::Box3D & box) const {
114 plb::Dot3D const & location = this->getLocation();
115 T x = pos[0] - location.x;
116 T y = pos[1] - location.y;
117 T z = pos[2] - location.z;
118
119 return (x > box.x0 - 0.5) && (x <= box.x1 + 0.5) && (y > box.y0 - 0.5) && (y <= box.y1 + 0.5) &&
120 (z > box.z0 - 0.5) && (z <= box.z1 + 0.5);
121 }
122 plb::Box3D & getBoundingBox() { return boundingBox; }
123 // Keep AtomicBlock3D's const version visible (same box), e.g. for the
124 // PLB_ASSERTs in const member functions.
125 using plb::AtomicBlock3D::getBoundingBox;
138 void getOutputCells(pluint ctype, std::vector<plint> & cellIds);
139 //Ugly output functions:
140 void outputPositions(plb::Box3D, std::vector<std::vector<T>> &, pluint, std::string &);
141 void outputVelocities(plb::Box3D, std::vector<std::vector<T>> &, pluint, std::string &);
142 void outputForces(plb::Box3D, std::vector<std::vector<T>> &, pluint, std::string &);
143 void outputForceVolume(plb::Box3D, std::vector<std::vector<T>> &, pluint, std::string &);
144 void outputForceArea(plb::Box3D, std::vector<std::vector<T>> &, pluint, std::string &);
145 void outputForceBending(plb::Box3D, std::vector<std::vector<T>> &, pluint, std::string &);
146 void outputForceLink(plb::Box3D, std::vector<std::vector<T>> &, pluint, std::string &);
147 void outputForceVisc(plb::Box3D, std::vector<std::vector<T>> &, pluint, std::string &);
148 void outputForceRepulsion(plb::Box3D, std::vector<std::vector<T>> &, pluint, std::string &);
149
150 void outputTriangles(plb::Box3D, std::vector<std::vector<plint>> &, pluint, std::string &);
151 void outputInnerLinks(plb::Box3D, std::vector<std::vector<plint>> &, pluint, std::string &);
152
153 void outputVertexId(plb::Box3D, std::vector<std::vector<T>> &, pluint, std::string &);
156 void outputCellIds(std::vector<std::vector<plint>> & output, pluint ctype, std::string & name);
157 void outputForceInnerLink(plb::Box3D, std::vector<std::vector<T>> &, pluint, std::string &);
158 void outputResTime(plb::Box3D, std::vector<std::vector<T>> &, pluint, std::string &);
159
160
161 void AddOutputMap();
162 std::map<int, void (HemoCellParticleField::*)(plb::Box3D, std::vector<std::vector<T>> &, pluint, std::string &)>
164 void passthroughpass(int, plb::Box3D, std::vector<std::vector<T>> &, pluint, std::string &);
165
166public:
168 virtual HemoCellParticleDataTransfer const & getDataTransfer() const;
169 static std::string getBlockName();
172 plb::BlockLattice3D<T, DESCRIPTOR> * atomicLattice = 0;
173 plb::BlockLattice3D<T, CEPAC_DESCRIPTOR> * CEPAClattice = 0;
174
175 std::vector<plint> neighbours;
176 std::vector<plb::Dot3D> boundaryParticles;
178 pluint getsize() { return particles.size(); }
179 plint nearestCell(T const) const;
180 static std::string basicType() { return std::string(plb::NativeType<T>::getName()); }
181 static std::string descriptorType() { return std::string(DESCRIPTOR<T>::name); }
182 std::vector<HemoCellParticle> particles;
183 plb::Box3D boundingBox;
184 int nFluidCells = 0;
185
186private:
187 bool lpc_up_to_date = false;
188 bool ppt_up_to_date = false;
189 bool ppc_up_to_date = false;
191 bool pg_up_to_date = false;
192
193public:
194 void invalidate_lpc() { lpc_up_to_date = false; };
195 void invalidate_ppt() { ppt_up_to_date = false; };
196 void invalidate_ppc() { ppc_up_to_date = false; };
198 void invalidate_pg() { pg_up_to_date = false; };
199
200private:
201 std::vector<std::vector<unsigned int>> _particles_per_type;
202 std::map<plint, std::vector<int>> _particles_per_cell;
203 std::map<plint, std::vector<int>> _preinlet_particles_per_cell;
204 std::map<plint, bool> _lpc;
205 void update_lpc();
206 void update_ppc();
208 void update_ppt();
209 void update_pg();
213 int deleteIncompleteCellsImpl(bool onlyType, pluint ctype, const plb::Box3D * near, bool verbose);
215 std::vector<HemoCellParticle> particlesSnapshot;
218 void dropNonFiniteParticle(HemoCellParticle & particle, plint & count);
219
223
224 std::vector<hemo::Array<T, 3> *> allocated_for_output;
225
226public:
227 const std::vector<std::vector<unsigned int>> & get_particles_per_type();
228 const std::map<plint, std::vector<int>> & get_particles_per_cell();
229 const std::map<plint, std::vector<int>> & get_preinlet_particles_per_cell();
230 const std::map<plint, bool> & get_lpc();
231
232 std::set<plb::Dot3D> internalPoints; // Store found interior points
233 plb::ScalarField3D<T> * interiorViscosityField = 0;
234
235
236 //vector<vector<vector<vector<HemoCellParticle*>>>> particle_grid; //maybe better to make custom data structure, But that would be slower
237 void insert_ppc(HemoCellParticle * particle, unsigned int index);
238 void insert_preinlet_ppc(HemoCellParticle * particle, unsigned int index);
239
241
242public:
244 plb::Box3D localDomain;
245
246 //These should be edited through the helper/solidifyField.h functions
247 std::set<plb::Dot3D> bindingSites;
248 plb::ScalarField3D<bool> * bindingField = 0;
249};
250
251}
252#endif
Definition hemoCellFields.h:54
Definition hemoCellParticleDataTransfer.h:37
Definition hemoCellParticleField.h:39
void outputInnerLinks(plb::Box3D, std::vector< std::vector< plint > > &, pluint, std::string &)
Definition hemoCellParticleFieldOutputFunctions.cpp:186
HemoCellParticleField * clone() const
Definition hemoCellParticleField.cpp:90
void outputForceRepulsion(plb::Box3D, std::vector< std::vector< T > > &, pluint, std::string &)
Definition hemoCellParticleFieldOutputFunctions.cpp:157
plb::Box3D & getBoundingBox()
Definition hemoCellParticleField.h:122
void outputForceBending(plb::Box3D, std::vector< std::vector< T > > &, pluint, std::string &)
Definition hemoCellParticleFieldOutputFunctions.cpp:115
plb::ScalarField3D< bool > * bindingField
Definition hemoCellParticleField.h:248
static HemoCellFields * cellFields
Definition hemoCellParticleField.h:170
void addParticlePreinlet(const HemoCellParticle::serializeValues_t &sv)
Definition hemoCellParticleField.cpp:187
void computeGridPosition(hemo::Array< T, 3 > const &position, plint &iX, plint &iY, plint &iZ) const
Definition hemoCellParticleField.cpp:364
void outputForces(plb::Box3D, std::vector< std::vector< T > > &, pluint, std::string &)
Definition hemoCellParticleFieldOutputFunctions.cpp:164
void snapshotParticles()
Definition hemoCellParticleField.cpp:395
void update_lpc()
Definition hemoCellParticleField.cpp:107
void insert_preinlet_ppc(HemoCellParticle *particle, unsigned int index)
Definition hemoCellParticleField.cpp:225
void prepareSolidification()
Definition hemoCellParticleField.cpp:916
pluint getsize()
Definition hemoCellParticleField.h:178
void applyRepulsionForce(bool forced=false)
Definition hemoCellParticleField.cpp:594
HemoCellParticleField & operator=(HemoCellParticleField const &rhs)
Definition hemoCellParticleField.cpp:78
virtual void advanceParticles()
Definition hemoCellParticleField.cpp:485
void AddOutputMap()
Definition hemoCellParticleFieldOutputFunctions.cpp:34
void update_ppt()
Definition hemoCellParticleField.cpp:114
std::map< int, void(HemoCellParticleField::*)(plb::Box3D, std::vector< std::vector< T > > &, pluint, std::string &)> outputFunctionMap
Definition hemoCellParticleField.h:163
virtual void removeParticles_inverse(plb::Box3D domain)
Definition hemoCellParticleField.cpp:300
virtual void internalGridPointsMembrane(plb::Box3D domain)
Definition hemoCellParticleField.cpp:679
void restoreParticles()
Discard the current particles and put back those kept by snapshotParticles().
Definition hemoCellParticleField.cpp:407
void separateForceVectors()
Definition hemoCellParticleField.cpp:511
void outputResTime(plb::Box3D, std::vector< std::vector< T > > &, pluint, std::string &)
Definition hemoCellParticleFieldOutputFunctions.cpp:217
std::vector< std::vector< unsigned int > > _particles_per_type
Definition hemoCellParticleField.h:201
bool ppt_up_to_date
Definition hemoCellParticleField.h:188
T eigenValueFromCell(plb::Cell< T, DESCRIPTOR > &cell)
Definition hemoCellParticleField.cpp:870
void update_ppc()
Definition hemoCellParticleField.cpp:121
std::vector< hemo::Array< T, 3 > * > allocated_for_output
Definition hemoCellParticleField.h:224
void setlocalDomain(plb::Box3D &localDomain_)
Definition hemoCellParticleField.cpp:474
void outputForceVolume(plb::Box3D, std::vector< std::vector< T > > &, pluint, std::string &)
Definition hemoCellParticleFieldOutputFunctions.cpp:143
bool ppc_up_to_date
Definition hemoCellParticleField.h:189
const std::map< plint, std::vector< int > > & get_particles_per_cell()
Definition hemoCellParticleField.cpp:98
void populateBindingSites(plb::Box3D &domain)
Definition hemoCellParticleField.cpp:840
std::vector< plint > neighbours
Definition hemoCellParticleField.h:175
void outputForceLink(plb::Box3D, std::vector< std::vector< T > > &, pluint, std::string &)
Definition hemoCellParticleFieldOutputFunctions.cpp:129
const std::map< plint, bool > & get_lpc()
Definition hemoCellParticleField.cpp:103
int deleteBrokenCells(plint envelope, bool verbose)
Delete the particles of cells that lost vertices.
Definition hemoCellParticleField.cpp:390
void capRepulsionForce(T limit)
Definition hemoCellParticleField.cpp:602
std::vector< HemoCellParticle > particles
Definition hemoCellParticleField.h:182
void invalidate_ppc()
Definition hemoCellParticleField.h:196
HemoCellParticleDataTransfer & particleDataTransfer
Definition hemoCellParticleField.h:240
int deleteIncompleteCellsImpl(bool onlyType, pluint ctype, const plb::Box3D *near, bool verbose)
Definition hemoCellParticleField.cpp:417
int nFluidCells
Definition hemoCellParticleField.h:184
bool isContainedABS(const hemo::Array< T, 3 > &pos, const plb::Box3D &box) const
Definition hemoCellParticleField.h:113
virtual void spreadParticleForce(plb::Box3D domain)
Definition hemoCellParticleField.cpp:707
plb::BlockLattice3D< T, CEPAC_DESCRIPTOR > * CEPAClattice
Definition hemoCellParticleField.h:173
void outputPositions(plb::Box3D, std::vector< std::vector< T > > &, pluint, std::string &)
Definition hemoCellParticleFieldOutputFunctions.cpp:97
pluint envelopeSize
Definition hemoCellParticleField.h:177
void invalidate_ppt()
Definition hemoCellParticleField.h:195
pluint atomicBlockId
Definition hemoCellParticleField.h:171
int deleteIncompleteCells(pluint ctype, bool verbose=true)
Delete the particles of cells of type ctype that are not complete in this block.
Definition hemoCellParticleField.cpp:382
void outputForceArea(plb::Box3D, std::vector< std::vector< T > > &, pluint, std::string &)
Definition hemoCellParticleFieldOutputFunctions.cpp:122
std::vector< HemoCellParticle > particlesSnapshot
The particles kept aside by snapshotParticles().
Definition hemoCellParticleField.h:215
void outputForceInnerLink(plb::Box3D, std::vector< std::vector< T > > &, pluint, std::string &)
Definition hemoCellParticleFieldOutputFunctions.cpp:136
plint nearestCell(T const) const
Definition hemoCellParticleField.cpp:352
void dropNonFiniteParticle(HemoCellParticle &particle, plint &count)
Definition hemoCellParticleField.cpp:770
virtual void applyConstitutiveModel(bool forced=false)
Definition hemoCellParticleField.cpp:549
bool lpc_up_to_date
Definition hemoCellParticleField.h:187
void populateBoundaryParticles()
Definition hemoCellParticleField.cpp:784
void insert_ppc(HemoCellParticle *particle, unsigned int index)
Definition hemoCellParticleField.cpp:219
std::map< plint, std::vector< int > > _particles_per_cell
Definition hemoCellParticleField.h:202
void outputVelocities(plb::Box3D, std::vector< std::vector< T > > &, pluint, std::string &)
Definition hemoCellParticleFieldOutputFunctions.cpp:104
void passthroughpass(int, plb::Box3D, std::vector< std::vector< T > > &, pluint, std::string &)
Definition hemoCellParticleFieldOutputFunctions.cpp:49
bool pg_up_to_date
Definition hemoCellParticleField.h:191
static std::string getBlockName()
Definition hemoCellParticleField.cpp:994
static std::string descriptorType()
Definition hemoCellParticleField.h:181
void unifyForceVectors()
Definition hemoCellParticleField.cpp:543
plint addParticleCount
Definition hemoCellParticleField.h:243
void invalidate_preinlet_ppc()
Definition hemoCellParticleField.h:197
void solidifyCells()
Definition hemoCellParticleField.cpp:931
static std::string basicType()
Definition hemoCellParticleField.h:180
plb::Box3D boundingBox
Definition hemoCellParticleField.h:183
void update_pg()
Definition hemoCellParticleField.cpp:128
virtual void removeParticles(plb::Box3D domain)
Definition hemoCellParticleField.cpp:276
virtual HemoCellParticleDataTransfer & getDataTransfer()
Definition hemoCellParticleField.cpp:987
virtual void findInternalParticleGridPoints(plb::Box3D domain)
Definition hemoCellParticleField.cpp:676
plb::BlockLattice3D< T, DESCRIPTOR > * atomicLattice
Definition hemoCellParticleField.h:172
void updateResidenceTime(unsigned int rtime)
Definition hemoCellParticleField.cpp:538
void outputCellIds(std::vector< std::vector< plint > > &output, pluint ctype, std::string &name)
Definition hemoCellParticleFieldOutputFunctions.cpp:208
void outputForceVisc(plb::Box3D, std::vector< std::vector< T > > &, pluint, std::string &)
Definition hemoCellParticleFieldOutputFunctions.cpp:150
void invalidate_pg()
Definition hemoCellParticleField.h:198
virtual void findParticles(plb::Box3D domain, std::vector< HemoCellParticle * > &found)
Definition hemoCellParticleField.cpp:323
void invalidate_lpc()
Definition hemoCellParticleField.h:194
void applyBoundaryRepulsionForce(bool resetFirst=false)
Definition hemoCellParticleField.cpp:809
void getOutputCells(pluint ctype, std::vector< plint > &cellIds)
The cells of type ctype that this block writes to the cell output.
Definition hemoCellParticleFieldOutputFunctions.cpp:57
bool preinlet_ppc_up_to_date
Definition hemoCellParticleField.h:190
void outputTriangles(plb::Box3D, std::vector< std::vector< plint > > &, pluint, std::string &)
Definition hemoCellParticleFieldOutputFunctions.cpp:170
std::set< plb::Dot3D > internalPoints
Definition hemoCellParticleField.h:232
std::map< plint, bool > _lpc
Definition hemoCellParticleField.h:204
std::set< plb::Dot3D > bindingSites
Definition hemoCellParticleField.h:247
std::map< plint, std::vector< int > > _preinlet_particles_per_cell
Definition hemoCellParticleField.h:203
plb::ScalarField3D< T > * interiorViscosityField
Definition hemoCellParticleField.h:233
const std::vector< std::vector< unsigned int > > & get_particles_per_type()
Definition hemoCellParticleField.cpp:94
virtual void interpolateFluidVelocity(plb::Box3D domain)
Definition hemoCellParticleField.cpp:684
void issueWarning(HemoCellParticle &p)
Definition hemoCellParticleField.cpp:372
void outputVertexId(plb::Box3D, std::vector< std::vector< T > > &, pluint, std::string &)
Definition hemoCellParticleFieldOutputFunctions.cpp:203
std::vector< plb::Dot3D > boundaryParticles
Definition hemoCellParticleField.h:176
plb::Box3D localDomain
Definition hemoCellParticleField.h:244
virtual ~HemoCellParticleField()
Definition hemoCellParticleField.cpp:66
ParticleGrid particleGrid
Definition hemoCellParticleField.h:222
const std::map< plint, std::vector< int > > & get_preinlet_particles_per_cell()
virtual void addParticle(HemoCellParticle *particle)
Definition hemoCellParticleField.cpp:135
Definition hemoCellParticle.h:44
Cell list that bins the particles of one atomic block onto its lattice nodes.
Definition particleGrid.h:67
double T
Definition constant_defaults.h:137
long int plint
Definition constant_defaults.h:149
long unsigned int pluint
Definition constant_defaults.h:152
Definition cell.py:1
Definition config.cpp:37
Definition meshGeneratingFunctions.cpp:28
Definition array.h:40
Definition hemoCellParticle.h:48