hemocell
Loading...
Searching...
No Matches
preInlet.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 PREINLET_H
25#define PREINLET_H
26
27class PreInlet;
30
31#include "core/geometry3D.h"
32#include "atomicBlock/atomicBlock3D.h"
33#include "config.h"
34#include "hemocell.h"
35
36#ifndef HEMOCELL_H
37namespace hemo {
38class HemoCell;
39}
40#endif
41
42enum Direction : int { Xpos, Xneg, Ypos, Yneg, Zpos, Zneg };
43
44
45#define DSET_SLICE 1000
46
47namespace hemo {
48
49
50inline plint cellsInBoundingBox(plb::Box3D const & box) {
51 return abs((box.x1 - box.x0) * (box.y1 - box.y0) * (box.z1 - box.z0));
52}
53
54
55class PreInlet {
56public:
58 void processGenericBlocks(plb::Box3D, std::vector<plb::AtomicBlock3D *>);
61
62 public:
63 CreateDrivingForceFunctional(plint & count_) : count(count_) { count = 0; }
64 };
66 void processGenericBlocks(plb::Box3D, std::vector<plb::AtomicBlock3D *>);
68 plb::Box3D & boundingBox;
70
71 public:
72 CreatePreInletBoundingBox(plb::Box3D & b_, bool & fp_) : boundingBox(b_), foundPreInlet(fp_) {}
73 };
74
76 void processGenericBlocks(plb::Box3D, std::vector<plb::AtomicBlock3D *>);
77 FillFlagMatrix * clone() const;
78 };
79
80 PreInlet(hemo::HemoCell * hemocell_, plb::MultiScalarField3D<int> * flagMatrix_);
81 PreInlet(hemo::HemoCell * hemocell_, plb::MultiBlockManagement3D & management);
83 void createBoundary();
85 void setDrivingForce();
86 void setDrivingForceTimeDependent(double t);
88 double interpolate(std::vector<double> & xData, std::vector<double> & yData, double x, bool extrapolate);
89 double average(std::vector<double> values);
102
104 void preInletFromSlice(Direction direction_, plb::Box3D boundary);
105
107 plb::Box3D location;
108 plb::Box3D fluidInlet;
109 int nProcs = 0;
110 bool initialized = false;
111 double drivingForce = 0.0;
112 double average_vel = 0.0;
113 double pulseEndTime = 1.0;
114 double pFrequency = 1.0;
115 std::vector<double> normalizedVelocityTimes;
116 std::vector<double> normalizedVelocityValues;
117 std::map<plint, plint> BlockToMpi;
118 std::map<int, plint> particleSendMpi;
119 std::map<int, bool> particleReceiveMpi;
120 std::vector<plint> communicating_blocks;
121 std::map<int, plb::Box3D> domain_at_rank;
122 std::vector<int> my_send_blocks;
123 std::vector<int> my_recv_blocks;
125 bool partOfpreInlet = false;
129 std::vector<int> particle_receivers;
130 std::vector<int> particle_senders;
132 plb::MultiScalarField3D<int> * flagMatrix = 0;
133
134 ~PreInlet();
135
136private:
140 MPI_Comm comm = MPI_COMM_NULL;
141
143 struct BlockNode {
145 };
150 std::map<int, std::vector<BlockNode>> velocitySendNodes;
151 std::map<int, std::vector<BlockNode>> velocityRecvNodes;
152 std::vector<std::vector<T>> velocityBuffers;
154 std::vector<char> inletFluidMask;
155 inline pluint inletMaskIndex(plint x, plint y, plint z) const {
156 return ((x - fluidInlet.x0) * fluidInlet.getNy() + (y - fluidInlet.y0)) * fluidInlet.getNz() + (z - fluidInlet.z0);
157 }
158 std::vector<char> particleSendBuffer;
159 std::vector<char> particleRecvBuffer;
161};
162
163}
164#endif /* PREINLET_H */
Definition hemoCellFunctional.h:37
Definition hemocell.h:66
plint & count
Definition preInlet.h:60
CreateDrivingForceFunctional(plint &count_)
Definition preInlet.h:63
CreateDrivingForceFunctional * clone() const
Definition preInlet.cpp:971
void processGenericBlocks(plb::Box3D, std::vector< plb::AtomicBlock3D * >)
Definition preInlet.cpp:747
bool & foundPreInlet
Definition preInlet.h:69
CreatePreInletBoundingBox(plb::Box3D &b_, bool &fp_)
Definition preInlet.h:72
CreatePreInletBoundingBox * clone() const
Definition preInlet.cpp:968
plb::Box3D & boundingBox
Definition preInlet.h:68
void processGenericBlocks(plb::Box3D, std::vector< plb::AtomicBlock3D * >)
Definition preInlet.cpp:611
Definition preInlet.h:75
void processGenericBlocks(plb::Box3D, std::vector< plb::AtomicBlock3D * >)
Definition preInlet.cpp:759
FillFlagMatrix * clone() const
Definition preInlet.cpp:974
Definition preInlet.h:55
std::map< int, bool > particleReceiveMpi
Definition preInlet.h:119
bool initialized
Definition preInlet.h:110
std::vector< char > particleRecvBuffer
Definition preInlet.h:159
int sendingBlocks
Definition preInlet.h:124
void createBoundary()
Definition preInlet.cpp:920
bool partOfpreInlet
Definition preInlet.h:125
double average(std::vector< double > values)
Definition preInlet.cpp:805
Direction direction
Definition preInlet.h:106
bool readNormalizedVelocities()
Definition preInlet.cpp:814
plb::MultiScalarField3D< int > * flagMatrix
Definition preInlet.h:132
void autoPreinletFromBoundary(Direction)
Definition preInlet.cpp:641
std::vector< std::vector< T > > velocityBuffers
Definition preInlet.h:152
std::vector< int > particle_senders
Definition preInlet.h:130
double pFrequency
Definition preInlet.h:114
bool communications_mapped
Definition preInlet.h:128
std::map< int, std::vector< BlockNode > > velocityRecvNodes
Definition preInlet.h:151
bool velocityExchangeReady
Definition preInlet.h:149
void applyPreInlet()
Definition preInlet.h:92
void preInletFromSlice(Direction direction_, plb::Box3D boundary)
Definition preInlet.cpp:532
std::vector< char > inletFluidMask
Fluid flag of each node of fluidInlet (see initializePreInletVelocityBoundary()).
Definition preInlet.h:154
double drivingForce
Definition preInlet.h:111
std::vector< double > normalizedVelocityValues
Definition preInlet.h:116
void setDrivingForce()
Definition preInlet.cpp:906
double average_vel
Definition preInlet.h:112
~PreInlet()
Definition preInlet.cpp:249
void calculateDrivingForce()
Definition preInlet.cpp:771
void applyPreInletVelocityBoundary()
Definition preInlet.cpp:448
std::map< int, plb::Box3D > domain_at_rank
Definition preInlet.h:121
void initializePreInletVelocityBoundary()
Definition preInlet.cpp:495
std::vector< plint > communicating_blocks
Definition preInlet.h:120
int inflow_length
Definition preInlet.h:126
void setDrivingForceTimeDependent(double t)
Definition preInlet.cpp:880
HemoCell * hemocell
Definition preInlet.h:131
std::map< int, plint > particleSendMpi
Definition preInlet.h:118
std::vector< int > particle_receivers
Definition preInlet.h:129
std::vector< double > normalizedVelocityTimes
Definition preInlet.h:115
plb::Box3D fluidInlet
Definition preInlet.h:108
std::vector< int > my_send_blocks
Definition preInlet.h:122
void applyPreInletParticleBoundary()
Definition preInlet.cpp:255
void initializePreInletParticleBoundary()
Definition preInlet.cpp:68
int nProcs
Definition preInlet.h:109
MPI_Comm comm
Definition preInlet.h:140
double pulseEndTime
Definition preInlet.h:113
plint getNumberOfNodes()
Definition preInlet.h:82
void buildVelocityExchange()
Definition preInlet.cpp:373
std::map< int, std::vector< BlockNode > > velocitySendNodes
Definition preInlet.h:150
pluint inletMaskIndex(plint x, plint y, plint z) const
Definition preInlet.h:155
int preinlet_length
Definition preInlet.h:127
double interpolate(std::vector< double > &xData, std::vector< double > &yData, double x, bool extrapolate)
Definition preInlet.cpp:852
std::vector< char > particleSendBuffer
Definition preInlet.h:158
std::map< plint, plint > BlockToMpi
Definition preInlet.h:117
void initializePreInlet()
Definition preInlet.h:98
plb::Box3D location
Definition preInlet.h:107
std::vector< int > my_recv_blocks
Definition preInlet.h:123
long int plint
Definition constant_defaults.h:149
long unsigned int pluint
Definition constant_defaults.h:152
Definition config.cpp:37
plint cellsInBoundingBox(plb::Box3D const &box)
Definition preInlet.h:50
Direction
Definition preInlet.h:42
@ Xpos
Definition preInlet.h:42
@ Ypos
Definition preInlet.h:42
@ Zneg
Definition preInlet.h:42
@ Xneg
Definition preInlet.h:42
@ Zpos
Definition preInlet.h:42
@ Yneg
Definition preInlet.h:42
A lattice node of a local atomic block (block-local coordinates).
Definition preInlet.h:143
plint z
Definition preInlet.h:144
plint blockId
Definition preInlet.h:144
plint y
Definition preInlet.h:144
plint x
Definition preInlet.h:144