Free Surface Processor 6: Mass Excess.
352 {
354
355
356
357
359 return;
360 }
361
362 T mass_excess = T(0);
363
365
366 const T mass = cell.template getField<FreeSurface::MASS>();
367 mass_excess = mass;
368 cell.template setField<FreeSurface::MASS>(T(0));
369 }
370
372
373 const T rho = cell.computeRho();
374 const T mass = cell.template getField<FreeSurface::MASS>();
375 mass_excess = mass - rho;
376 cell.template setField<FreeSurface::MASS>(rho);
377 }
378 else { return; }
379
380
381
382
383
384 std::uint8_t oldIntefaceNbrs = std::uint8_t(0);
385 std::uint8_t newIntefaceNbrs = std::uint8_t(0);
386 for (int iPop = 1; iPop < DESCRIPTOR::q; ++iPop) {
388
389
390
392 ++oldIntefaceNbrs;
393 }
394
396 ++newIntefaceNbrs;
397 }
398 }
399
400
401 const std::uint8_t intefaceNbrs = newIntefaceNbrs + oldIntefaceNbrs;
402 if (intefaceNbrs == std::uint8_t(0)) { return; }
403
404
405 bool enableAllInterfaces = true;
406 constexpr bool weightedDistribution = true;
408 T weightsSum = T(0);
409
410
411 if constexpr (weightedDistribution) {
412
415
416
417 for (const auto& weight : weights) { weightsSum += weight; }
418
419 if (
util::fabs(weightsSum) < zeroThreshold<T>()) {
420
421
422 if (!enableAllInterfaces) {
423 enableAllInterfaces = true;
424 weightsSum = T(0);
426 for (const auto& weight : weights) { weightsSum += weight; }
427
428
429
430 if (
util::fabs(weightsSum) < zeroThreshold<T>()) {
431 for (auto& weight : weights) { weight = T(1); }
432 weightsSum = T(intefaceNbrs);
433 }
434 }
435
436
437 else {
438 for (auto& weight : weights) { weight = T(1); }
439 weightsSum = T(intefaceNbrs);
440 }
441 }
442 }
443
444 else {
445
446 if (!enableAllInterfaces && oldIntefaceNbrs > std::uint8_t(0)) {
447 for (auto& weight : weights) { weight = T(1); }
448 weightsSum = T(oldIntefaceNbrs);
449 }
450
451 else {
452 enableAllInterfaces = true;
453 for (auto& weight : weights) { weight = T(1); }
454 weightsSum = T(intefaceNbrs);
455 }
456 }
457
459 for (int iPop = 1; iPop < DESCRIPTOR::q; ++iPop) {
461
463 mass_exchange[iPop] = mass_excess * weights[iPop] / weightsSum;
464 }
466 mass_exchange[iPop] = mass_excess * weights[iPop] / weightsSum;
467 }
468 else {
469 mass_exchange[iPop] = T(0);
470 }
471 }
472
473 cell.template setField<FreeSurface::TEMP_MASS_EXCHANGE>(mass_exchange);
474}
void computeMassExcessWeights(CELL &cell, const Vector< V, CELL::descriptor_t::d > &normal, const bool &enableAllInterfaces, Vector< V, CELL::descriptor_t::q > &weights)
Vector< V, CELL::descriptor_t::d > computeInterfaceNormal(CELL &cell)
bool isCellType(CELL &cell, const FreeSurface::Type &type)
bool hasCellFlags(CELL &cell, const FreeSurface::Flags &flags)
constexpr int c(unsigned iPop, unsigned iDim) any_platform
Distribution< T > normal(T mean, T stddev)