341 {
342 TRACE();
343
345
347
348
350
351
352
353
354
355
356
357
358
359 MFloat tuFreeStream = 0.05;
360
362 std::vector<std::pair<MFloat, MFloat>> tuFreeStreamData = {
363 std::make_pair(31171.1711712, 0.0451546391753), std::make_pair(34774.7747748, 0.0428865979381),
364 std::make_pair(38378.3783784, 0.0407216494845), std::make_pair(42702.7027027, 0.0385567010309),
365 std::make_pair(51711.7117117, 0.0349484536082), std::make_pair(58558.5585586, 0.0327835051546),
366 std::make_pair(66846.8468468, 0.0305154639175), std::make_pair(78738.7387387, 0.0278350515464),
367 std::make_pair(93513.5135135, 0.0250515463918), std::make_pair(111891.891892, 0.0223711340206),
368 std::make_pair(132432.432432, 0.0198969072165), std::make_pair(158738.738739, 0.0175257731959),
369 std::make_pair(186126.126126, 0.0154639175258), std::make_pair(215675.675676, 0.0137113402062),
370 std::make_pair(243783.783784, 0.0124742268041), std::make_pair(273693.693694, 0.0113402061856),
371 std::make_pair(301801.801802, 0.0105154639175)};
372
373
374 MInt length = (
MInt)tuFreeStreamData.size();
375 for(
MInt i = 0; i < length; i++) {
377 tuFreeStream = tuFreeStreamData[i - 1].second
378 + (tuFreeStreamData[i].second - tuFreeStreamData[i - 1].second)
379 / (tuFreeStreamData[i].first - tuFreeStreamData[i - 1].first)
381 break;
382 }
383 }
384
386 tuFreeStream = tuFreeStreamData[0].second
387 + (tuFreeStreamData[1].second - tuFreeStreamData[0].second)
388 / (tuFreeStreamData[1].first - tuFreeStreamData[0].first)
390 }
392 tuFreeStream = tuFreeStreamData[length - 2].second
393 + (tuFreeStreamData[length - 1].second - tuFreeStreamData[length - 2].second)
394 / (tuFreeStreamData[length - 1].first - tuFreeStreamData[length - 2].first)
396 }
397
398 tuFreeStream *= 0.95;
399
400 m_log <<
"interpolation of freestream turbulence intensity: " << tuFreeStream << endl;
401
402 } else {
404 }
405
408 vector<MInt>::iterator findLESId =
409 find(
LESSolver().m_LESAverageCells.begin(),
LESSolver().m_LESAverageCells.end(), cellId);
410 if(findLESId ==
LESSolver().m_LESAverageCells.end()) TERMM(1,
"Something went wrong " + to_string(cellId));
412
413
420 for(
MInt i = 0; i < nDim; i++) {
421 for(
MInt j = count_; j < nDim; j++) {
423 if(i == j) {
425 "Trying to access data [" + to_string(index1) + "][" + to_string(LESAvgId)
426 + "] in LESSolver().m_LESVarAverage with length "
427 + to_string(
LESSolver().m_LESVarAverage[index1].size()));
428
429 k += 0.5
431 - pow(
LESSolver().m_LESVarAverage[index2][LESAvgId], F2));
433 - pow(
LESSolver().m_LESVarAverage[index2][LESAvgId], F2));
434 index2++;
435 }
436 index_++;
437 }
438 count_++;
439 }
440
441 tuarg = max(tuarg,
epss);
442
444 MFloat tufac = tanh((tu - tuFreeStream) / tuFreeStream);
445 MFloat tulim = max(tu, tuFreeStream);
446 tulim = tu / tulim;
447
448 k = k * tufac * tulim;
449
450
451 MFloat du[3][3]{{F0, F0, F0}, {F0, F0, F0}, {F0, F0, F0}};
453
456
462
463 vector<MInt>::iterator findRecNghbrId =
464 find(
LESSolver().m_LESAverageCells.begin(),
LESSolver().m_LESAverageCells.end(), recNghbrId);
465
466 if(findRecNghbrId ==
LESSolver().m_LESAverageCells.end())
467 TERMM(1, "Something went wrong in nghbr " + to_string(recNghbrId));
468
470
471 for(
MInt dim = 0; dim < nDim; dim++) {
473 "Trying to access data [" + to_string(dim) + "][" + to_string(LESRecNghbrId)
474 + "] in LESSolver().m_LESVarAverage with length "
475 + to_string(
LESSolver().m_LESVarAverage[dim].size()));
476
478 if(abs(
LESSolver().m_LESVarAverage[dim][LESRecNghbrId]) >
epss
479 || abs(u[dim] /
LESSolver().m_LESVarAverage[dim][LESRecNghbrId]) > 100) {
480 du[dim][0] += recConst_x * delta_u;
481 du[dim][1] += recConst_y * delta_u;
482 du[dim][2] += recConst_z * delta_u;
483 }
484 }
485 }
486
488 for(
MInt d1 = 0; d1 < nDim; d1++) {
489 for(
MInt d2 = 0; d2 < nDim; d2++) {
490 MFloat sij = 0.5 * (du[d1][d2] + du[d2][d1]);
491 SijSij += sij * sij;
492 }
493 }
494
496 SijSij = max(SijSij, SijSijLim);
498 MFloat omega = 1 / sqrt(c_mu) * sqrt(2 * SijSij);
499 omega = max(omega,
epss);
500
501
504 if(std::isnan(omega) || tulim < 1) {
506 }
507
513 const MFloat nuLaminar = mue / rho;
514
515
516 MInt NewtonIter = 50;
523
524 while(abs(nu_new - nu_old) >
eps && icount < NewtonIter) {
525 nu_old = nu_new;
526
527 MFloat chi = nu_old / nuLaminar;
528 MFloat chi3 = pow(chi, 3.0);
530 MFloat fv1 = chi3 / (chi3 + cv13);
531
532
533 func_n = nu_old * fv1 - nut;
534
535 derv_n = fv1 + 3.0 * fv1 - 3.0 * fv1 * fv1;
536
537 nu_new = nu_old - func_n / derv_n;
538
539 icount++;
540 }
541
542 nuTilde = nu_new;
543 }
544
546 }
547 }
548}
MFloat m_sutherlandPlusOne
MFloat m_sutherlandConstant
MInt & a_reconstructionData(const MInt cellId)
Returns reconstruction data offset i of the cell cellId.
MInt & a_reconstructionNeighborId(const MInt cellId, const MInt nghbrNo)
Returns reconstruction neighbor n of the cell cellId.
std::vector< MFloat > m_reconstructionConstants
MInt & a_noReconstructionNeighbors(const MInt cellId)
Returns the noRcnstrctnNghbrIds of the cell cellId.
MFloat m_turbulentIntensity
MFloat m_tuLengthScaleCorrection
MFloat m_Re
the Reynolds number
constexpr std::underlying_type< FcCell >::type p(const FcCell property)
Converts property name to underlying integer value.
MFloat distance(const MFloat *a, const MFloat *b)
static constexpr MFloat cv1to3