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 {
28 class HemoCellParticleField;
29}
30
31#include "hemoCellFields.h"
33#include "hemoCellParticle.h"
34
35#include "atomicBlock/blockLattice3D.hh"
36
37namespace hemo {
38using namespace std;
39class HemoCellParticleField : public plb::AtomicBlock3D {
40public:
42 virtual ~HemoCellParticleField();
47 virtual void applyConstitutiveModel(bool forced = false);
48 virtual void addParticle(HemoCellParticle* particle);
51
52 virtual void removeParticles(plb::Box3D domain);
53 virtual void removeParticles_inverse(plb::Box3D domain);
54 virtual void removeParticles(plb::Box3D domain,plint tag);
55 virtual void removeParticles(plint tag);
56 virtual void findParticles(plb::Box3D domain,
57 std::vector<HemoCellParticle*>& found);
58 virtual void findParticles(plb::Box3D domain,
59 std::vector<const HemoCellParticle*>& found) const;
60 void findParticles(plb::Box3D domain,
61 std::vector<HemoCellParticle*>& found,
62 pluint type);
63 virtual void advanceParticles();
64 void applyRepulsionForce(bool forced = false);
65 virtual void interpolateFluidVelocity(plb::Box3D domain);
66 virtual void spreadParticleForce(plb::Box3D domain);
68 void unifyForceVectors();
69 void updateResidenceTime(unsigned int rtime);
70
71 virtual void findInternalParticleGridPoints(plb::Box3D domain);
72 virtual void internalGridPointsMembrane(plb::Box3D domain);
73
74 int deleteIncompleteCells(pluint ctype, bool verbose=true);
75 int deleteIncompleteCells(bool verbose=true);
76 void syncEnvelopes();
79 void populateBindingSites(plb::Box3D & domain);
80
81 T eigenValueFromCell(plb::Cell<T,DESCRIPTOR> & cell);
82
83 void solidifyCells();
85
86 void setlocalDomain(plb::Box3D & localDomain_);
87
88 void computeGridPosition ( hemo::Array<T,3> const& position,
89 plint& iX, plint& iY, plint& iZ ) const;
90 inline void computeGridPosition ( hemo::Array<T,3> const& position,
91 plint* iX, plint* iY, plint* iZ ) const;
92
93 inline bool isContainedABS(const hemo::Array<T,3> & pos, const plb::Box3D & box) const {
94 plb::Dot3D const& location = this->getLocation();
95 T x = pos[0]-location.x;
96 T y = pos[1]-location.y;
97 T z = pos[2]-location.z;
98
99 return (x > box.x0-0.5) && (x <= box.x1+0.5) &&
100 (y > box.y0-0.5) && (y <= box.y1+0.5) &&
101 (z > box.z0-0.5) && (z <= box.z1+0.5);
102
103 }
104 plb::Box3D & getBoundingBox() {
105 return boundingBox;
106 }
107 //Ugly output functions:
108 void outputPositions(plb::Box3D,vector<vector<T>>&, pluint, std::string&);
109 void outputVelocities(plb::Box3D,vector<vector<T>>&, pluint, std::string&);
110 void outputForces (plb::Box3D,vector<vector<T>>&, pluint, std::string&);
111 void outputForceVolume (plb::Box3D,vector<vector<T>>&, pluint, std::string&);
112 void outputForceArea (plb::Box3D,vector<vector<T>>&, pluint, std::string&);
113 void outputForceBending (plb::Box3D,vector<vector<T>>&, pluint, std::string&);
114 void outputForceLink (plb::Box3D,vector<vector<T>>&, pluint, std::string&);
115 void outputForceVisc (plb::Box3D,vector<vector<T>>&, pluint, std::string&);
116 void outputForceRepulsion (plb::Box3D,vector<vector<T>>&, pluint, std::string&);
117
118 void outputTriangles (plb::Box3D,vector<vector<plint>>&, pluint, std::string&);
119 void outputInnerLinks (plb::Box3D,vector<vector<plint>>&, pluint, std::string&);
120
121 void outputVertexId (plb::Box3D,vector<vector<T>>&, pluint, std::string&);
122 void outputCellId (plb::Box3D,vector<vector<T>>&, pluint, std::string&);
123 void outputForceInnerLink (plb::Box3D,vector<vector<T>>&, pluint, std::string&);
124 void outputResTime (plb::Box3D,vector<vector<T>>&, pluint, std::string&);
125
126
127 void AddOutputMap();
128 map<int,void (HemoCellParticleField::*)(plb::Box3D,vector<vector<T>>&,pluint,std::string&)> outputFunctionMap;
129 void passthroughpass(int,plb::Box3D,vector<vector<T>>&,pluint,std::string&);
130
131public:
133 virtual HemoCellParticleDataTransfer const& getDataTransfer() const;
134 static std::string getBlockName();
137 plb::BlockLattice3D<T, DESCRIPTOR> * atomicLattice = 0;
138 plb::BlockLattice3D<T, CEPAC_DESCRIPTOR> * CEPAClattice = 0;
139
140 vector<plint> neighbours;
141 vector<plb::Dot3D> boundaryParticles;
143 pluint getsize() { return particles.size();}
144 plint nearestCell(T const) const;
145 static std::string basicType() {return std::string(plb::NativeType<T>::getName());}
146 static std::string descriptorType() {
147 return std::string(DESCRIPTOR<T>::name);
148 }
149 vector<HemoCellParticle> particles;
150 plb::Box3D boundingBox;
151 int nFluidCells = 0;
152
153private:
154 bool lpc_up_to_date = false;
155 bool ppt_up_to_date = false;
156 bool ppc_up_to_date = false;
158 bool pg_up_to_date = false;
159public:
160 void invalidate_lpc() { lpc_up_to_date = false;};
161 void invalidate_ppt() { ppt_up_to_date = false;};
162 void invalidate_ppc() { ppc_up_to_date = false;};
164 void invalidate_pg() { pg_up_to_date = false;};
165private:
166 vector<vector<unsigned int>> _particles_per_type;
167 map<int,vector<int>> _particles_per_cell;
168 map<int,vector<int>> _preinlet_particles_per_cell;
169 map<int,bool> _lpc;
170 void update_lpc();
171 void update_ppc();
173 void update_ppt();
174 void update_pg();
176
178 unsigned int * particle_grid_size = 0;
179 unsigned int grid_index(int & nx,int & ny,int & nz) {
180 return nz+this->atomicLattice->getNz()*(ny+(this->atomicLattice->getNy()*nx));
181 }
182
183 vector<hemo::Array<T,3>*> allocated_for_output;
184
185public:
186 const vector<vector<unsigned int>> & get_particles_per_type();
187 const map<int,vector<int>> & get_particles_per_cell();
188 const map<int,vector<int>> & get_preinlet_particles_per_cell();
189 const map<int,bool> & get_lpc();
190
191 set<plb::Dot3D> internalPoints; // Store found interior points
192 plb::ScalarField3D<T> * interiorViscosityField = 0;
193
194
195 //vector<vector<vector<vector<HemoCellParticle*>>>> particle_grid; //maybe better to make custom data structure, But that would be slower
196 void insert_ppc(HemoCellParticle* particle,unsigned int index);
197 void insert_preinlet_ppc(HemoCellParticle* particle,unsigned int index);
198
200public:
202 plb::Box3D localDomain;
203
204 //These should be edited through the helper/solidifyField.h functions
205 std::set<plb::Dot3D> bindingSites;
206 plb::ScalarField3D<bool> * bindingField = 0;
207};
208
209}
210#endif
Definition hemoCellFields.h:53
Definition hemoCellParticleDataTransfer.h:38
Definition hemoCellParticleField.h:39
unsigned int * particle_grid_size
Definition hemoCellParticleField.h:178
HemoCellParticleField * clone() const
Definition hemoCellParticleField.cpp:92
void passthroughpass(int, plb::Box3D, vector< vector< T > > &, pluint, std::string &)
Definition hemoCellParticleFieldOutputFunctions.cpp:45
plb::Box3D & getBoundingBox()
Definition hemoCellParticleField.h:104
plb::ScalarField3D< bool > * bindingField
Definition hemoCellParticleField.h:206
static HemoCellFields * cellFields
Definition hemoCellParticleField.h:135
vector< hemo::Array< T, 3 > * > allocated_for_output
Definition hemoCellParticleField.h:183
void addParticlePreinlet(const HemoCellParticle::serializeValues_t &sv)
Definition hemoCellParticleField.cpp:237
void computeGridPosition(hemo::Array< T, 3 > const &position, plint &iX, plint &iY, plint &iZ) const
Definition hemoCellParticleField.cpp:453
void update_lpc()
Definition hemoCellParticleField.cpp:110
void insert_preinlet_ppc(HemoCellParticle *particle, unsigned int index)
Definition hemoCellParticleField.cpp:293
void prepareSolidification()
Definition hemoCellParticleField.cpp:1002
pluint getsize()
Definition hemoCellParticleField.h:143
void applyRepulsionForce(bool forced=false)
Definition hemoCellParticleField.cpp:696
HemoCellParticleField & operator=(HemoCellParticleField const &rhs)
Definition hemoCellParticleField.cpp:86
virtual void advanceParticles()
Definition hemoCellParticleField.cpp:566
void AddOutputMap()
Definition hemoCellParticleFieldOutputFunctions.cpp:28
vector< plint > neighbours
Definition hemoCellParticleField.h:140
void update_ppt()
Definition hemoCellParticleField.cpp:119
void outputForceVolume(plb::Box3D, vector< vector< T > > &, pluint, std::string &)
Definition hemoCellParticleFieldOutputFunctions.cpp:230
void outputInnerLinks(plb::Box3D, vector< vector< plint > > &, pluint, std::string &)
Definition hemoCellParticleFieldOutputFunctions.cpp:367
void syncEnvelopes()
Definition hemoCellParticleField.cpp:392
virtual void removeParticles_inverse(plb::Box3D domain)
Definition hemoCellParticleField.cpp:369
virtual void internalGridPointsMembrane(plb::Box3D domain)
Definition hemoCellParticleField.cpp:813
void separateForceVectors()
Definition hemoCellParticleField.cpp:590
bool ppt_up_to_date
Definition hemoCellParticleField.h:155
T eigenValueFromCell(plb::Cell< T, DESCRIPTOR > &cell)
Definition hemoCellParticleField.cpp:951
void update_ppc()
Definition hemoCellParticleField.cpp:128
map< int, vector< int > > _particles_per_cell
Definition hemoCellParticleField.h:167
void setlocalDomain(plb::Box3D &localDomain_)
Definition hemoCellParticleField.cpp:555
bool ppc_up_to_date
Definition hemoCellParticleField.h:156
void outputVelocities(plb::Box3D, vector< vector< T > > &, pluint, std::string &)
Definition hemoCellParticleFieldOutputFunctions.cpp:83
virtual void removeParticles(plb::Box3D domain)
const map< int, vector< int > > & get_preinlet_particles_per_cell()
void populateBindingSites(plb::Box3D &domain)
Definition hemoCellParticleField.cpp:920
map< int, bool > _lpc
Definition hemoCellParticleField.h:169
void outputForceVisc(plb::Box3D, vector< vector< T > > &, pluint, std::string &)
Definition hemoCellParticleFieldOutputFunctions.cpp:259
void outputVertexId(plb::Box3D, vector< vector< T > > &, pluint, std::string &)
Definition hemoCellParticleFieldOutputFunctions.cpp:387
void invalidate_ppc()
Definition hemoCellParticleField.h:162
void outputCellId(plb::Box3D, vector< vector< T > > &, pluint, std::string &)
Definition hemoCellParticleFieldOutputFunctions.cpp:406
HemoCellParticleDataTransfer & particleDataTransfer
Definition hemoCellParticleField.h:199
int nFluidCells
Definition hemoCellParticleField.h:151
bool isContainedABS(const hemo::Array< T, 3 > &pos, const plb::Box3D &box) const
Definition hemoCellParticleField.h:93
virtual void spreadParticleForce(plb::Box3D domain)
Definition hemoCellParticleField.cpp:841
plb::BlockLattice3D< T, CEPAC_DESCRIPTOR > * CEPAClattice
Definition hemoCellParticleField.h:138
void applyBoundaryRepulsionForce()
Definition hemoCellParticleField.cpp:891
pluint envelopeSize
Definition hemoCellParticleField.h:142
void invalidate_ppt()
Definition hemoCellParticleField.h:161
pluint atomicBlockId
Definition hemoCellParticleField.h:136
virtual void findParticles(plb::Box3D domain, std::vector< const HemoCellParticle * > &found) const
int deleteIncompleteCells(pluint ctype, bool verbose=true)
Definition hemoCellParticleField.cpp:469
set< plb::Dot3D > internalPoints
Definition hemoCellParticleField.h:191
void outputForceRepulsion(plb::Box3D, vector< vector< T > > &, pluint, std::string &)
Definition hemoCellParticleFieldOutputFunctions.cpp:288
plint nearestCell(T const) const
Definition hemoCellParticleField.cpp:439
const map< int, vector< int > > & get_particles_per_cell()
Definition hemoCellParticleField.cpp:101
void outputTriangles(plb::Box3D, vector< vector< plint > > &, pluint, std::string &)
Definition hemoCellParticleFieldOutputFunctions.cpp:346
virtual void applyConstitutiveModel(bool forced=false)
Definition hemoCellParticleField.cpp:633
bool lpc_up_to_date
Definition hemoCellParticleField.h:154
void populateBoundaryParticles()
Definition hemoCellParticleField.cpp:865
virtual void removeParticles(plb::Box3D domain, plint tag)
void insert_ppc(HemoCellParticle *particle, unsigned int index)
Definition hemoCellParticleField.cpp:286
vector< plb::Dot3D > boundaryParticles
Definition hemoCellParticleField.h:141
bool pg_up_to_date
Definition hemoCellParticleField.h:158
static std::string getBlockName()
Definition hemoCellParticleField.cpp:1080
static std::string descriptorType()
Definition hemoCellParticleField.h:146
vector< HemoCellParticle > particles
Definition hemoCellParticleField.h:149
void unifyForceVectors()
Definition hemoCellParticleField.cpp:623
hemo::Array< unsigned int, 10 > * particle_grid
Definition hemoCellParticleField.h:177
void outputForceLink(plb::Box3D, vector< vector< T > > &, pluint, std::string &)
Definition hemoCellParticleFieldOutputFunctions.cpp:172
plint addParticleCount
Definition hemoCellParticleField.h:201
void invalidate_preinlet_ppc()
Definition hemoCellParticleField.h:163
void outputResTime(plb::Box3D, vector< vector< T > > &, pluint, std::string &)
Definition hemoCellParticleFieldOutputFunctions.cpp:425
void solidifyCells()
Definition hemoCellParticleField.cpp:1018
static std::string basicType()
Definition hemoCellParticleField.h:145
plb::Box3D boundingBox
Definition hemoCellParticleField.h:150
void outputForceArea(plb::Box3D, vector< vector< T > > &, pluint, std::string &)
Definition hemoCellParticleFieldOutputFunctions.cpp:143
void outputForces(plb::Box3D, vector< vector< T > > &, pluint, std::string &)
Definition hemoCellParticleFieldOutputFunctions.cpp:317
vector< vector< unsigned int > > _particles_per_type
Definition hemoCellParticleField.h:166
void update_pg()
Definition hemoCellParticleField.cpp:137
virtual HemoCellParticleDataTransfer & getDataTransfer()
Definition hemoCellParticleField.cpp:1073
virtual void findInternalParticleGridPoints(plb::Box3D domain)
Definition hemoCellParticleField.cpp:809
map< int, void(HemoCellParticleField::*)(plb::Box3D, vector< vector< T > > &, pluint, std::string &)> outputFunctionMap
Definition hemoCellParticleField.h:128
plb::BlockLattice3D< T, DESCRIPTOR > * atomicLattice
Definition hemoCellParticleField.h:137
unsigned int grid_index(int &nx, int &ny, int &nz)
Definition hemoCellParticleField.h:179
void updateResidenceTime(unsigned int rtime)
Definition hemoCellParticleField.cpp:616
void invalidate_pg()
Definition hemoCellParticleField.h:164
void invalidate_lpc()
Definition hemoCellParticleField.h:160
bool preinlet_ppc_up_to_date
Definition hemoCellParticleField.h:157
std::set< plb::Dot3D > bindingSites
Definition hemoCellParticleField.h:205
void findParticles(plb::Box3D domain, std::vector< HemoCellParticle * > &found, pluint type)
void outputForceBending(plb::Box3D, vector< vector< T > > &, pluint, std::string &)
Definition hemoCellParticleFieldOutputFunctions.cpp:114
map< int, vector< int > > _preinlet_particles_per_cell
Definition hemoCellParticleField.h:168
void swap(HemoCellParticleField &rhs)
plb::ScalarField3D< T > * interiorViscosityField
Definition hemoCellParticleField.h:192
virtual void findParticles(plb::Box3D domain, std::vector< HemoCellParticle * > &found)
const vector< vector< unsigned int > > & get_particles_per_type()
Definition hemoCellParticleField.cpp:97
virtual void interpolateFluidVelocity(plb::Box3D domain)
Definition hemoCellParticleField.cpp:819
void outputForceInnerLink(plb::Box3D, vector< vector< T > > &, pluint, std::string &)
Definition hemoCellParticleFieldOutputFunctions.cpp:201
void outputPositions(plb::Box3D, vector< vector< T > > &, pluint, std::string &)
Definition hemoCellParticleFieldOutputFunctions.cpp:51
void issueWarning(HemoCellParticle &p)
Definition hemoCellParticleField.cpp:463
plb::Box3D localDomain
Definition hemoCellParticleField.h:202
virtual ~HemoCellParticleField()
Definition hemoCellParticleField.cpp:64
virtual void addParticle(HemoCellParticle *particle)
Definition hemoCellParticleField.cpp:170
const map< int, bool > & get_lpc()
Definition hemoCellParticleField.cpp:106
Definition hemoCellParticle.h:40
double T
Definition constant_defaults.h:118
long int plint
Definition constant_defaults.h:127
long unsigned int pluint
Definition constant_defaults.h:130
Definition cell.py:1
Definition config.cpp:34
Definition meshGeneratingFunctions.cpp:28
Definition array.h:39
Definition hemoCellParticle.h:45