Execute post-processing step on a sublattice.
238{
239
240
241 BlockLattice<T,DESCRIPTOR> *partnerLattice1 = static_cast<BlockLattice<T,DESCRIPTOR> *>(partners[0]);
242 BlockLattice<T,DESCRIPTOR> *partnerLattice2 = 0;
243 if (partners.size() > 1) {
244 partnerLattice2 = static_cast<BlockLattice<T,DESCRIPTOR> *>(partners[1]);
245 }
246
247 int newX0, newX1, newY0, newY1, newZ0, newZ1;
249 x0_, x1_, y0_, y1_, z0_, z1_,
250 newX0, newX1, newY0, newY1, newZ0, newZ1 ) ) {
251
252 for (int iX=newX0; iX<=newX1; ++iX) {
253 for (int iY=newY0; iY<=newY1; ++iY) {
254 for (int iZ=newZ0; iZ<=newZ1; ++iZ) {
255 T phi = blockLattice.get(iX,iY,iZ).computeRho();
256 T rho = partnerLattice1->get(iX,iY,iZ).computeRho();
257
258 T gradMuPhiX = 1./12. * ( -blockLattice.get(iX-1,iY,iZ-1).template getField<descriptors::CHEM_POTENTIAL>()
259 - blockLattice.get(iX-1,iY,iZ+1).template getField<descriptors::CHEM_POTENTIAL>()
260 - blockLattice.get(iX-1,iY-1,iZ ).template getField<descriptors::CHEM_POTENTIAL>()
261 - 2.* blockLattice.get(iX-1,iY,iZ ).template getField<descriptors::CHEM_POTENTIAL>()
262 - blockLattice.get(iX-1,iY+1,iZ ).template getField<descriptors::CHEM_POTENTIAL>()
263 + blockLattice.get(iX+1,iY-1,iZ ).template getField<descriptors::CHEM_POTENTIAL>()
264 + 2.* blockLattice.get(iX+1,iY,iZ ).template getField<descriptors::CHEM_POTENTIAL>()
265 + blockLattice.get(iX+1,iY+1,iZ ).template getField<descriptors::CHEM_POTENTIAL>()
266 + blockLattice.get(iX+1,iY,iZ-1).template getField<descriptors::CHEM_POTENTIAL>()
267 + blockLattice.get(iX+1,iY,iZ+1).template getField<descriptors::CHEM_POTENTIAL>() );
268 T gradMuPhiY = 1./12. * ( -blockLattice.get(iX-1,iY-1,iZ ).template getField<descriptors::CHEM_POTENTIAL>()
269 - blockLattice.get(iX+1,iY-1,iZ ).template getField<descriptors::CHEM_POTENTIAL>()
270 - blockLattice.get(iX,iY-1,iZ-1).template getField<descriptors::CHEM_POTENTIAL>()
271 - 2.* blockLattice.get(iX,iY-1,iZ ).template getField<descriptors::CHEM_POTENTIAL>()
272 - blockLattice.get(iX,iY-1,iZ+1).template getField<descriptors::CHEM_POTENTIAL>()
273 + blockLattice.get(iX,iY+1,iZ-1).template getField<descriptors::CHEM_POTENTIAL>()
274 + 2.* blockLattice.get(iX,iY+1,iZ ).template getField<descriptors::CHEM_POTENTIAL>()
275 + blockLattice.get(iX,iY+1,iZ+1).template getField<descriptors::CHEM_POTENTIAL>()
276 + blockLattice.get(iX-1,iY+1,iZ ).template getField<descriptors::CHEM_POTENTIAL>()
277 + blockLattice.get(iX+1,iY+1,iZ ).template getField<descriptors::CHEM_POTENTIAL>() );
278 T gradMuPhiZ = 1./12. * ( -blockLattice.get(iX,iY-1,iZ-1).template getField<descriptors::CHEM_POTENTIAL>()
279 - blockLattice.get(iX,iY+1,iZ-1).template getField<descriptors::CHEM_POTENTIAL>()
280 - blockLattice.get(iX-1,iY,iZ-1).template getField<descriptors::CHEM_POTENTIAL>()
281 - 2.* blockLattice.get(iX,iY,iZ-1).template getField<descriptors::CHEM_POTENTIAL>()
282 - blockLattice.get(iX+1,iY,iZ-1).template getField<descriptors::CHEM_POTENTIAL>()
283 + blockLattice.get(iX-1,iY,iZ+1).template getField<descriptors::CHEM_POTENTIAL>()
284 + 2.* blockLattice.get(iX,iY,iZ+1).template getField<descriptors::CHEM_POTENTIAL>()
285 + blockLattice.get(iX+1,iY,iZ+1).template getField<descriptors::CHEM_POTENTIAL>()
286 + blockLattice.get(iX,iY-1,iZ+1).template getField<descriptors::CHEM_POTENTIAL>()
287 + blockLattice.get(iX,iY+1,iZ+1).template getField<descriptors::CHEM_POTENTIAL>() );
288
289 T gradMuRhoX = 1./12. * ( -partnerLattice1->get(iX-1,iY,iZ-1).template getField<descriptors::CHEM_POTENTIAL>()
290 - partnerLattice1->get(iX-1,iY,iZ+1).template getField<descriptors::CHEM_POTENTIAL>()
291 - partnerLattice1->get(iX-1,iY-1,iZ ).template getField<descriptors::CHEM_POTENTIAL>()
292 - 2.* partnerLattice1->get(iX-1,iY,iZ ).template getField<descriptors::CHEM_POTENTIAL>()
293 - partnerLattice1->get(iX-1,iY+1,iZ ).template getField<descriptors::CHEM_POTENTIAL>()
294 + partnerLattice1->get(iX+1,iY-1,iZ ).template getField<descriptors::CHEM_POTENTIAL>()
295 + 2.* partnerLattice1->get(iX+1,iY,iZ ).template getField<descriptors::CHEM_POTENTIAL>()
296 + partnerLattice1->get(iX+1,iY+1,iZ ).template getField<descriptors::CHEM_POTENTIAL>()
297 + partnerLattice1->get(iX+1,iY,iZ-1).template getField<descriptors::CHEM_POTENTIAL>()
298 + partnerLattice1->get(iX+1,iY,iZ+1).template getField<descriptors::CHEM_POTENTIAL>() );
299 T gradMuRhoY = 1./12. * ( -partnerLattice1->get(iX-1,iY-1,iZ ).template getField<descriptors::CHEM_POTENTIAL>()
300 - partnerLattice1->get(iX+1,iY-1,iZ ).template getField<descriptors::CHEM_POTENTIAL>()
301 - partnerLattice1->get(iX,iY-1,iZ-1).template getField<descriptors::CHEM_POTENTIAL>()
302 - 2.* partnerLattice1->get(iX,iY-1,iZ ).template getField<descriptors::CHEM_POTENTIAL>()
303 - partnerLattice1->get(iX,iY-1,iZ+1).template getField<descriptors::CHEM_POTENTIAL>()
304 + partnerLattice1->get(iX,iY+1,iZ-1).template getField<descriptors::CHEM_POTENTIAL>()
305 + 2.* partnerLattice1->get(iX,iY+1,iZ ).template getField<descriptors::CHEM_POTENTIAL>()
306 + partnerLattice1->get(iX,iY+1,iZ+1).template getField<descriptors::CHEM_POTENTIAL>()
307 + partnerLattice1->get(iX-1,iY+1,iZ ).template getField<descriptors::CHEM_POTENTIAL>()
308 + partnerLattice1->get(iX+1,iY+1,iZ ).template getField<descriptors::CHEM_POTENTIAL>() );
309 T gradMuRhoZ = 1./12. * ( -partnerLattice1->get(iX,iY-1,iZ-1).template getField<descriptors::CHEM_POTENTIAL>()
310 - partnerLattice1->get(iX,iY+1,iZ-1).template getField<descriptors::CHEM_POTENTIAL>()
311 - partnerLattice1->get(iX-1,iY,iZ-1).template getField<descriptors::CHEM_POTENTIAL>()
312 - 2.* partnerLattice1->get(iX,iY,iZ-1).template getField<descriptors::CHEM_POTENTIAL>()
313 - partnerLattice1->get(iX+1,iY,iZ-1).template getField<descriptors::CHEM_POTENTIAL>()
314 + partnerLattice1->get(iX-1,iY,iZ+1).template getField<descriptors::CHEM_POTENTIAL>()
315 + 2.* partnerLattice1->get(iX,iY,iZ+1).template getField<descriptors::CHEM_POTENTIAL>()
316 + partnerLattice1->get(iX+1,iY,iZ+1).template getField<descriptors::CHEM_POTENTIAL>()
317 + partnerLattice1->get(iX,iY-1,iZ+1).template getField<descriptors::CHEM_POTENTIAL>()
318 + partnerLattice1->get(iX,iY+1,iZ+1).template getField<descriptors::CHEM_POTENTIAL>() );
319
320 T psi = 0.;
321 T gradMuPsiX = 0.;
322 T gradMuPsiY = 0.;
323 T gradMuPsiZ = 0.;
324 if (partners.size() > 1) {
325 psi = partnerLattice2->get(iX,iY,iZ).computeRho();
326 gradMuPsiX = 1./12. * ( -partnerLattice2->get(iX-1,iY,iZ-1).template getField<descriptors::CHEM_POTENTIAL>()
327 - partnerLattice2->get(iX-1,iY,iZ+1).template getField<descriptors::CHEM_POTENTIAL>()
328 - partnerLattice2->get(iX-1,iY-1,iZ ).template getField<descriptors::CHEM_POTENTIAL>()
329 - 2.* partnerLattice2->get(iX-1,iY,iZ ).template getField<descriptors::CHEM_POTENTIAL>()
330 - partnerLattice2->get(iX-1,iY+1,iZ ).template getField<descriptors::CHEM_POTENTIAL>()
331 + partnerLattice2->get(iX+1,iY-1,iZ ).template getField<descriptors::CHEM_POTENTIAL>()
332 + 2.* partnerLattice2->get(iX+1,iY,iZ ).template getField<descriptors::CHEM_POTENTIAL>()
333 + partnerLattice2->get(iX+1,iY+1,iZ ).template getField<descriptors::CHEM_POTENTIAL>()
334 + partnerLattice2->get(iX+1,iY,iZ-1).template getField<descriptors::CHEM_POTENTIAL>()
335 + partnerLattice2->get(iX+1,iY,iZ+1).template getField<descriptors::CHEM_POTENTIAL>() );
336 gradMuPsiY = 1./12. * ( -partnerLattice2->get(iX-1,iY-1,iZ ).template getField<descriptors::CHEM_POTENTIAL>()
337 - partnerLattice2->get(iX+1,iY-1,iZ ).template getField<descriptors::CHEM_POTENTIAL>()
338 - partnerLattice2->get(iX,iY-1,iZ-1).template getField<descriptors::CHEM_POTENTIAL>()
339 - 2.* partnerLattice2->get(iX,iY-1,iZ ).template getField<descriptors::CHEM_POTENTIAL>()
340 - partnerLattice2->get(iX,iY-1,iZ+1).template getField<descriptors::CHEM_POTENTIAL>()
341 + partnerLattice2->get(iX,iY+1,iZ-1).template getField<descriptors::CHEM_POTENTIAL>()
342 + 2.* partnerLattice2->get(iX,iY+1,iZ ).template getField<descriptors::CHEM_POTENTIAL>()
343 + partnerLattice2->get(iX,iY+1,iZ+1).template getField<descriptors::CHEM_POTENTIAL>()
344 + partnerLattice2->get(iX-1,iY+1,iZ ).template getField<descriptors::CHEM_POTENTIAL>()
345 + partnerLattice2->get(iX+1,iY+1,iZ ).template getField<descriptors::CHEM_POTENTIAL>() );
346 gradMuPsiZ = 1./12. * ( -partnerLattice2->get(iX,iY-1,iZ-1).template getField<descriptors::CHEM_POTENTIAL>()
347 - partnerLattice2->get(iX,iY+1,iZ-1).template getField<descriptors::CHEM_POTENTIAL>()
348 - partnerLattice2->get(iX-1,iY,iZ-1).template getField<descriptors::CHEM_POTENTIAL>()
349 - 2.* partnerLattice2->get(iX,iY,iZ-1).template getField<descriptors::CHEM_POTENTIAL>()
350 - partnerLattice2->get(iX+1,iY,iZ-1).template getField<descriptors::CHEM_POTENTIAL>()
351 + partnerLattice2->get(iX-1,iY,iZ+1).template getField<descriptors::CHEM_POTENTIAL>()
352 + 2.* partnerLattice2->get(iX,iY,iZ+1).template getField<descriptors::CHEM_POTENTIAL>()
353 + partnerLattice2->get(iX+1,iY,iZ+1).template getField<descriptors::CHEM_POTENTIAL>()
354 + partnerLattice2->get(iX,iY-1,iZ+1).template getField<descriptors::CHEM_POTENTIAL>()
355 + partnerLattice2->get(iX,iY+1,iZ+1).template getField<descriptors::CHEM_POTENTIAL>() );
356 }
357
358 T forceX = -rho*gradMuRhoX - phi*gradMuPhiX - psi*gradMuPsiX;
359 T forceY = -rho*gradMuRhoY - phi*gradMuPhiY - psi*gradMuPsiY;
360 T forceZ = -rho*gradMuRhoZ - phi*gradMuPhiZ - psi*gradMuPsiZ;
361 partnerLattice1->get(iX,iY,iZ).template setField<descriptors::FORCE>({forceX, forceY, forceZ});
362 T u[3];
363 partnerLattice1->get(iX,iY,iZ).computeU(u);
364 blockLattice.get(iX,iY,iZ).template setField<descriptors::FORCE>(u);
365 if (partners.size() > 1) {
366 partnerLattice2->get(iX,iY,iZ).template setField<descriptors::FORCE>(u);
367 }
368 }
369 }
370 }
371 }
372}
bool intersect(int x0, int x1, int y0, int y1, int x0_, int x1_, int y0_, int y1_, int &newX0, int &newX1, int &newY0, int &newY1)