hemocell
Loading...
Searching...
No Matches
hemocell.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 HEMOCELL_H
25#define HEMOCELL_H
26
27//Load Constants
28#include "constant_defaults.h"
29#include "config.h"
30
31/* CORE libs */
32#include "hemoCellFields.h"
33
34/* IO */
35#include "loadBalancer.h"
36#include "profiler.h"
37
38/* MECHANICS */
39#include "cellMechanics.h"
40#include "constantConversion.h"
41
42/* Helpers */
43#include "preInlet.h"
44// #include "leesEdwardsBC.h"
45
46/* Always used palabos functions in case files*/
47#ifndef COMPILING_HEMOCELL_LIBRARY
48#include "voxelizeDomain.h"
49#include "palabos3D.h"
50#include "palabos3D.hh"
51using namespace hemo;
52using namespace plb;
53#endif
54
55namespace hemo {
56
68class HemoCell {
69 public:
77
86 HemoCell(char * configFileName, int argc, char* argv[]) : HemoCell{ configFileName, argc, argv, HemoCell::MPIHandle::Internal } {};
87
92 HemoCell(char * configFileName, int argc, char* argv[], HemoCell::MPIHandle mpi_handle);
93
94 /*
95 * Clean up hemocell
96 */
97 ~HemoCell();
98
106
110 void initializeCellfield();
111
122 template<class Mechanics>
123 void addCellType(string name, int constructType) {
124 HemoCellField * cellfield = cellfields->addCellType(name,constructType);
125 Mechanics * mechanics = new Mechanics(*cellfield->materialCfg, *cellfield);
126 cellfield->mechanics = mechanics;
127 cellfield->statistics();
128 }
129
138 void setOutputs(string name, vector<int> outputs);
139
140 //Sets the repulsion constant and cutoff distance, also enables repulsion
141 bool repulsionEnabled = false;
143 void setRepulsion(T repulsionConstant, T repulsionCutoff);
144
145 // Lees-Edwards boundary condition
146 bool leesEdwardsBC = false;
148
149 //Set the timescale separation of the particles of a particle type
150 void setMaterialTimeScaleSeparation(string name, unsigned int separation);
151
152 //Enable solidify mechanics of a celltype
153 void enableSolidifyMechanics(string name) {
154 hlog << "(HemoCell) Enabling Solidify Mechanics for " << name << " mechanical model" << endl;
155 (*cellfields)[name]->doSolidifyMechanics = true;
156 }
157
158 //Set the separation of when velocity is interpolated to the particle
159 void setParticleVelocityUpdateTimeScaleSeparation(unsigned int separation);
160
161 //Set the timescale separation of the repulsion force for all particles
162 void setRepulsionTimeScaleSeperation(unsigned int separation);
163
164 void setSolidifyTimeScaleSeperation(unsigned int separation);
165
166 //Set the timescale separation of the interior viscosity, in between update and raytracing (expensive) update
167 void setInteriorViscosityTimeScaleSeperation(unsigned int separation, unsigned int separation_entire_grid);
168
169 //Enable Boundary particles and set the boundary particle constants
170 void enableBoundaryParticles(T boundaryRepulsionConstant, T boundaryRepulsionCutoff, unsigned int timestep = 1);
171
172 //Set the minimum distance of the particles of a type to the solid, must be called BEFORE loadparticles
173 void setInitialMinimumDistanceFromSolid(string name, T distance);
174
175 //Set the output of the fluid field
176 void setFluidOutputs(vector<int> outputs);
177
178 //Set the output of the CEPAC field
179 void setCEPACOutputs(vector<int> outputs);
180
181 //Explicitly set the periodicity of the domain along the different axes
182 void setSystemPeriodicity(unsigned int axis, bool bePeriodic);
183
184 //Set the number or times a particle should be able to wrap around in a certain direction (both negative and positive (default: 100)
185 void setSystemPeriodicityLimit(unsigned int axis, int limit);
186
187 //Load the particles
188private:
190public:
192 void loadParticles();
193
195 void loadCheckPoint();
196
198 void saveCheckPoint();
199
201 bool outputInSiUnits = true;
202
204 void writeOutput();
205
208 void iterate();
209
211 void checkExitSignals();
212
213 //Load balancing library functions
216
219
221 void doRestructure(bool checkpoint_avail = true);
222
224 void initializeLattice(MultiBlockManagement3D const & management);
225
227
228 bool partOfpreInlet = false;
229
230 map<plint,plint> BlockToMpi;
231
234 MultiBlockLattice3D<T, DESCRIPTOR> * lattice = 0, *preinlet_lattice = 0, * domain_lattice = 0;
235
236 MultiBlockManagement3D * preinlet_lattice_management = 0, * domain_lattice_management = 0;
237
238 Config * cfg = 0;
241 unsigned int iter = 0;
242
243 XMLreader * documentXML = 0; //Needed for legacy checkpoint reading TODO fix
244 private:
246 unsigned int lastOutputAt = 0;
247 std::chrono::high_resolution_clock::duration lastOutput = std::chrono::high_resolution_clock::duration::zero();
248
250 void sanityCheck();
252 bool sanityCheckDone = false;
253};
254}
255#endif // HEMOCELL_H
Definition config.h:58
Definition hemoCellField.h:42
Config * materialCfg
Definition hemoCellField.h:56
CellMechanics * mechanics
Definition hemoCellField.h:74
void statistics()
Definition hemoCellField.cpp:173
Definition hemoCellFields.h:53
HemoCellField * addCellType(std::string name_, int constructType)
Add an celltype with a certain mesh, the name also specifies <name_>.xml and <name_>....
Definition hemoCellFields.cpp:141
Definition hemocell.h:68
T calculateFractionalLoadImbalance()
Calculate and return the fractional load imbalance.
Definition hemoCell.cpp:378
void setOutputs(string name, vector< int > outputs)
Definition hemoCell.cpp:149
void sanityCheck()
To be run right before the first iteration, all checking should move here.
Definition hemoCell.cpp:585
void loadCheckPoint()
Load a checkpoint.
Definition hemoCell.cpp:199
void setParticleVelocityUpdateTimeScaleSeparation(unsigned int separation)
Definition hemoCell.cpp:388
MultiBlockLattice3D< T, DESCRIPTOR > * preinlet_lattice
Definition hemocell.h:234
bool repulsionEnabled
Definition hemocell.h:141
void setInitialMinimumDistanceFromSolid(string name, T distance)
Definition hemoCell.cpp:412
bool sanityCheckDone
Checked in iteration, do sanity check when not yet done.
Definition hemocell.h:252
void initializeLattice(MultiBlockManagement3D const &management)
Initialize the fluid field with the given management, should be done after specifing the pre inlets a...
Definition hemoCell.cpp:438
void doRestructure(bool checkpoint_avail=true)
Restructure the grid, has an optional argument to specify whether a checkpoint from this iteration is...
Definition hemoCell.cpp:580
void setRepulsionTimeScaleSeperation(unsigned int separation)
Definition hemoCell.cpp:394
void setInteriorViscosityTimeScaleSeperation(unsigned int separation, unsigned int separation_entire_grid)
Definition hemoCell.cpp:404
void initializeCellfield()
Definition hemoCell.cpp:135
map< plint, plint > BlockToMpi
Definition hemocell.h:230
void loadParticles()
Load the particles from their .pos files.
Definition hemoCell.cpp:191
void setCEPACOutputs(vector< int > outputs)
Definition hemoCell.cpp:161
bool boundaryRepulsionEnabled
Definition hemocell.h:142
PreInlet * preInlet
Definition hemocell.h:226
void setSystemPeriodicityLimit(unsigned int axis, int limit)
Definition hemoCell.cpp:182
void addCellType(string name, int constructType)
Definition hemocell.h:123
double * LEcurrentDisplacement
Definition hemocell.h:147
HemoCellFields * cellfields
The cellfields contains the particle field and all celltypes.
Definition hemocell.h:240
XMLreader * documentXML
Definition hemocell.h:243
void enableBoundaryParticles(T boundaryRepulsionConstant, T boundaryRepulsionCutoff, unsigned int timestep=1)
Definition hemoCell.cpp:428
void saveCheckPoint()
Save a checkpoint.
Definition hemoCell.cpp:210
LoadBalancer * loadBalancer
Definition hemocell.h:232
void checkExitSignals()
Check if any exis signal was caught.
Definition hemoCell.cpp:289
unsigned int iter
Definition hemocell.h:241
bool outputInSiUnits
Specify whether the output is in SI or LBM units.
Definition hemocell.h:201
void setSolidifyTimeScaleSeperation(unsigned int separation)
Definition hemoCell.cpp:399
void doLoadBalance()
Load balance the domain (only necessary with nAtomic blocks > nMpi processors, also checkpoints.
unsigned int lastOutputAt
Store the last time (iteration) output occured.
Definition hemocell.h:246
MultiBlockLattice3D< T, DESCRIPTOR > * lattice
The fluid lattice.
Definition hemocell.h:234
void setFluidOutputs(vector< int > outputs)
Definition hemoCell.cpp:155
MPIHandle
Switch to indicate if the MPI instance is managed externally. The MPI instance is typically invoked w...
Definition hemocell.h:76
MultiBlockLattice3D< T, DESCRIPTOR > * domain_lattice
Definition hemocell.h:234
void setRepulsion(T repulsionConstant, T repulsionCutoff)
Definition hemoCell.cpp:420
Config * cfg
Definition hemocell.h:238
void setMaterialTimeScaleSeparation(string name, unsigned int separation)
Definition hemoCell.cpp:383
void writeOutput()
Write the specified output to hdf5 files.
Definition hemoCell.cpp:221
void enableSolidifyMechanics(string name)
Definition hemocell.h:153
void iterate()
Definition hemoCell.cpp:299
~HemoCell()
Definition hemoCell.cpp:97
void latticeEquilibrium(T rho, hemo::Array< T, 3 > vel)
Definition hemoCell.cpp:129
MultiBlockManagement3D * domain_lattice_management
Definition hemocell.h:236
HemoCell(char *configFileName, int argc, char *argv[])
Definition hemocell.h:86
MultiBlockManagement3D * preinlet_lattice_management
Definition hemocell.h:236
bool leesEdwardsBC
Definition hemocell.h:146
bool partOfpreInlet
Definition hemocell.h:228
std::chrono::high_resolution_clock::duration lastOutput
Definition hemocell.h:247
void setSystemPeriodicity(unsigned int axis, bool bePeriodic)
Definition hemoCell.cpp:168
bool loadParticlesIsCalled
Definition hemocell.h:189
Definition loadBalancer.h:31
Definition preInlet.h:57
double T
Definition constant_defaults.h:118
int argc
Definition main.cpp:22
char ** argv
Definition main.cpp:23
Definition config.cpp:34
Logfile hlog
Definition logfile.cpp:26
Definition meshGeneratingFunctions.cpp:28
Definition array.h:39