@@ -28,28 +28,59 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
28
28
29
29
namespace hemo {
30
30
InteriorViscosityHelper::InteriorViscosityHelper (HemoCellFields & cellFields_) : cellFields(cellFields_) {
31
- // Create bindingfield with same properties as fluid field underlying the particleField.
32
- multiInteriorViscosityField = new plb::MultiScalarField3D<T>(
31
+ // Create viscosity field with same properties as fluid field underlying the particleField.
32
+ if (cellFields.hemocell .preInlet ){
33
+ preinlet_multiInteriorViscosityField = new plb::MultiScalarField3D<T>(
33
34
MultiBlockManagement3D (
34
- *cellFields.hemocell .lattice ->getSparseBlockStructure ().clone (),
35
- cellFields.hemocell .lattice ->getMultiBlockManagement ().getThreadAttribution ().clone (),
36
- cellFields.hemocell .lattice ->getMultiBlockManagement ().getEnvelopeWidth (),
37
- cellFields.hemocell .lattice ->getMultiBlockManagement ().getRefinementLevel ()),
35
+ *cellFields.hemocell .preinlet_lattice ->getSparseBlockStructure ().clone (),
36
+ cellFields.hemocell .preinlet_lattice ->getMultiBlockManagement ().getThreadAttribution ().clone (),
37
+ cellFields.hemocell .preinlet_lattice ->getMultiBlockManagement ().getEnvelopeWidth (),
38
+ cellFields.hemocell .preinlet_lattice ->getMultiBlockManagement ().getRefinementLevel ()),
38
39
defaultMultiBlockPolicy3D ().getBlockCommunicator (),
39
40
defaultMultiBlockPolicy3D ().getCombinedStatistics (),
40
41
defaultMultiBlockPolicy3D ().getMultiScalarAccess <T>(),
41
42
0 );
42
- multiInteriorViscosityField ->periodicity ().toggle (0 ,cellFields.hemocell .lattice ->periodicity ().get (0 ));
43
- multiInteriorViscosityField ->periodicity ().toggle (1 ,cellFields.hemocell .lattice ->periodicity ().get (1 ));
44
- multiInteriorViscosityField ->periodicity ().toggle (2 ,cellFields.hemocell .lattice ->periodicity ().get (2 ));
43
+ preinlet_multiInteriorViscosityField ->periodicity ().toggle (0 ,cellFields.hemocell .preinlet_lattice ->periodicity ().get (0 ));
44
+ preinlet_multiInteriorViscosityField ->periodicity ().toggle (1 ,cellFields.hemocell .preinlet_lattice ->periodicity ().get (1 ));
45
+ preinlet_multiInteriorViscosityField ->periodicity ().toggle (2 ,cellFields.hemocell .preinlet_lattice ->periodicity ().get (2 ));
45
46
46
- multiInteriorViscosityField->initialize ();
47
+ preinlet_multiInteriorViscosityField->initialize ();
48
+
49
+ // Make sure each particleField has access to its local scalarField
50
+ for (const plint & bId : preinlet_multiInteriorViscosityField->getLocalInfo ().getBlocks ()) {
51
+ HemoCellParticleField & pf = cellFields.preinlet_immersedParticles ->getComponent (bId);
52
+ pf.interiorViscosityField = &preinlet_multiInteriorViscosityField->getComponent (bId);
53
+ }
54
+ }
55
+ domain_multiInteriorViscosityField = new plb::MultiScalarField3D<T>(
56
+ MultiBlockManagement3D (
57
+ *cellFields.hemocell .domain_lattice ->getSparseBlockStructure ().clone (),
58
+ cellFields.hemocell .domain_lattice ->getMultiBlockManagement ().getThreadAttribution ().clone (),
59
+ cellFields.hemocell .domain_lattice ->getMultiBlockManagement ().getEnvelopeWidth (),
60
+ cellFields.hemocell .domain_lattice ->getMultiBlockManagement ().getRefinementLevel ()),
61
+ defaultMultiBlockPolicy3D ().getBlockCommunicator (),
62
+ defaultMultiBlockPolicy3D ().getCombinedStatistics (),
63
+ defaultMultiBlockPolicy3D ().getMultiScalarAccess <T>(),
64
+ 0 );
65
+ domain_multiInteriorViscosityField->periodicity ().toggle (0 ,cellFields.hemocell .domain_lattice ->periodicity ().get (0 ));
66
+ domain_multiInteriorViscosityField->periodicity ().toggle (1 ,cellFields.hemocell .domain_lattice ->periodicity ().get (1 ));
67
+ domain_multiInteriorViscosityField->periodicity ().toggle (2 ,cellFields.hemocell .domain_lattice ->periodicity ().get (2 ));
68
+
69
+ domain_multiInteriorViscosityField->initialize ();
47
70
48
71
// Make sure each particleField has access to its local scalarField
49
- for (const plint & bId : multiInteriorViscosityField->getLocalInfo ().getBlocks ()) {
50
- HemoCellParticleField & pf = cellFields.immersedParticles ->getComponent (bId);
51
- pf.interiorViscosityField = &multiInteriorViscosityField->getComponent (bId);
72
+ for (const plint & bId : domain_multiInteriorViscosityField->getLocalInfo ().getBlocks ()) {
73
+ HemoCellParticleField & pf = cellFields.domain_immersedParticles ->getComponent (bId);
74
+ pf.interiorViscosityField = &domain_multiInteriorViscosityField->getComponent (bId);
75
+ }
76
+
77
+ if (cellFields.hemocell .partOfpreInlet ){
78
+ multiInteriorViscosityField = preinlet_multiInteriorViscosityField;
79
+ }
80
+ else {
81
+ multiInteriorViscosityField = domain_multiInteriorViscosityField;
52
82
}
83
+
53
84
}
54
85
55
86
InteriorViscosityHelper::~InteriorViscosityHelper () {
@@ -67,9 +98,15 @@ namespace hemo {
67
98
if (global::mpi ().isMainProcessor ()) {
68
99
renameFileToDotOld (outDir + " internalViscosity.dat" );
69
100
renameFileToDotOld (outDir + " internalViscosity.plb" );
101
+ if (cellFields.hemocell .preInlet ){
102
+ renameFileToDotOld (outDir + " PRE_internalViscosity.dat" );
103
+ renameFileToDotOld (outDir + " PRE_internalViscosity.plb" );
104
+ }
70
105
}
71
-
72
- plb::parallelIO::save (*multiInteriorViscosityField, outDir + " internalViscosity" , true );
106
+ if (cellFields.hemocell .preInlet ){
107
+ plb::parallelIO::save (*preinlet_multiInteriorViscosityField, outDir + " PRE_internalViscosity" , true );
108
+ }
109
+ plb::parallelIO::save (*domain_multiInteriorViscosityField, outDir + " internalViscosity" , true );
73
110
}
74
111
75
112
void InteriorViscosityHelper::restore (HemoCellFields & cellFields) {
@@ -84,8 +121,18 @@ namespace hemo {
84
121
pcout << " (internalViscosityField) Error restoring internalViscosity fields from checkpoint, they do not seem to exist" << endl;
85
122
exit (1 );
86
123
}
87
-
88
- plb::parallelIO::load (outDir + " internalViscosity" ,*get (cellFields).multiInteriorViscosityField ,true );
124
+ if (cellFields.hemocell .preInlet ){
125
+ std::string file_dat = outDir + " PRE_internalViscosity.dat" ;
126
+ std::string file_plb = outDir + " PRE_internalViscosity.plb" ;
127
+ if (!(file_exists (file_dat) && file_exists (file_plb))) {
128
+ pcout << " (PRE_internalViscosityField) Error restoring PRE_internalViscosity fields from checkpoint, they do not seem to exist" << endl;
129
+ exit (1 );
130
+ }
131
+ }
132
+ plb::parallelIO::load (outDir + " internalViscosity" ,*get (cellFields).domain_multiInteriorViscosityField ,true );
133
+ if (cellFields.hemocell .preInlet ){
134
+ plb::parallelIO::load (outDir + " PRE_internalViscosity" ,*get (cellFields).preinlet_multiInteriorViscosityField ,true );
135
+ }
89
136
get (cellFields).refillBindingSites ();
90
137
}
91
138
@@ -119,8 +166,29 @@ namespace hemo {
119
166
}
120
167
121
168
void InteriorViscosityHelper::refillBindingSites () {
122
- for (const plint & bId : cellFields.immersedParticles ->getLocalInfo ().getBlocks ()) {
123
- HemoCellParticleField & pf = cellFields.immersedParticles ->getComponent (bId);
169
+ if (cellFields.hemocell .preInlet ){
170
+ for (const plint & bId : cellFields.preinlet_immersedParticles ->getLocalInfo ().getBlocks ()) {
171
+ HemoCellParticleField & pf = cellFields.preinlet_immersedParticles ->getComponent (bId);
172
+ ScalarField3D<T> & bf = *pf.interiorViscosityField ;
173
+ Box3D domain = bf.getBoundingBox ();
174
+ for (int x = domain.x0 ; x <= domain.x1 ; x++) {
175
+ for (int y = domain.y0 ; y <= domain.y1 ; y++) {
176
+ for (int z = domain.z0 ; z <= domain.z1 ; z++) {
177
+ if (bf.get (x,y,z)) {
178
+ pf.internalPoints .insert ({x,y,z});
179
+
180
+ // WARNING this _can_ memory leak, so you should be ok if this is only called one time (from checkpointing)
181
+ plb::Dynamics<T,DESCRIPTOR>* dynamic = cellFields.hemocell .preinlet_lattice ->getBackgroundDynamics ().clone ();
182
+ dynamic->setOmega (1.0 /bf.get (x,y,z));
183
+ pf.atomicLattice ->get (x,y,z).attributeDynamics (dynamic);
184
+ }
185
+ }
186
+ }
187
+ }
188
+ }
189
+ }
190
+ for (const plint & bId : cellFields.domain_immersedParticles ->getLocalInfo ().getBlocks ()) {
191
+ HemoCellParticleField & pf = cellFields.domain_immersedParticles ->getComponent (bId);
124
192
ScalarField3D<T> & bf = *pf.interiorViscosityField ;
125
193
Box3D domain = bf.getBoundingBox ();
126
194
for (int x = domain.x0 ; x <= domain.x1 ; x++) {
@@ -130,7 +198,7 @@ namespace hemo {
130
198
pf.internalPoints .insert ({x,y,z});
131
199
132
200
// WARNING this _can_ memory leak, so you should be ok if this is only called one time (from checkpointing)
133
- plb::Dynamics<T,DESCRIPTOR>* dynamic = cellFields.lattice ->getBackgroundDynamics ().clone ();
201
+ plb::Dynamics<T,DESCRIPTOR>* dynamic = cellFields.hemocell . domain_lattice ->getBackgroundDynamics ().clone ();
134
202
dynamic->setOmega (1.0 /bf.get (x,y,z));
135
203
pf.atomicLattice ->get (x,y,z).attributeDynamics (dynamic);
136
204
}
@@ -139,4 +207,4 @@ namespace hemo {
139
207
}
140
208
}
141
209
}
142
- }
210
+ }
0 commit comments