Nektar++
Functions | Variables
CompressibleBL.cpp File Reference
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <string>
#include <boost/core/ignore_unused.hpp>
#include <MultiRegions/AssemblyMap/AssemblyMapDG.h>
#include <MultiRegions/ContField.h>
#include <MultiRegions/DisContField.h>
#include <MultiRegions/ExpList.h>
#include <MultiRegions/ExpList2DHomogeneous1D.h>
#include <MultiRegions/ExpList3DHomogeneous1D.h>
#include <MultiRegions/ExpList3DHomogeneous2D.h>
#include <LocalRegions/Expansion.h>
#include <LocalRegions/Expansion2D.h>
#include <LocalRegions/Expansion3D.h>
#include <LocalRegions/MatrixKey.h>
#include <LibUtilities/BasicUtils/FieldIO.h>
#include <LibUtilities/BasicUtils/NekFactory.hpp>
#include <LibUtilities/BasicUtils/SessionReader.h>
#include <LibUtilities/BasicUtils/SharedArray.hpp>
#include <LibUtilities/Communication/Comm.h>
#include <LibUtilities/Memory/NekMemoryManager.hpp>
#include <SpatialDomains/MeshGraph.h>
#include <SolverUtils/SolverUtilsDeclspec.h>

Go to the source code of this file.

Functions

void COMPBL (Array< OneD, NekDouble > v, Array< OneD, NekDouble > dv)
 
void RK4 (Array< OneD, NekDouble > y, Array< OneD, NekDouble > dydx, int n, NekDouble x, NekDouble h, Array< OneD, NekDouble > yout)
 
void RKDUMB (Array< OneD, NekDouble > vstart, int nvar, NekDouble x1, NekDouble x2, int m_xpoints, Array< OneD, NekDouble > xx, Array< OneD, Array< OneD, NekDouble > > y)
 
void OUTPUT (int m_xpoints, Array< OneD, NekDouble > xx, Array< OneD, Array< OneD, NekDouble > > ff, int nQuadraturePts, Array< OneD, NekDouble > x_QuadraturePts, Array< OneD, NekDouble > y_QuadraturePts, Array< OneD, NekDouble > u_QuadraturePts, Array< OneD, NekDouble > v_QuadraturePts, Array< OneD, NekDouble > rho_QuadraturePts, Array< OneD, NekDouble > T_QuadraturePts)
 
int main (int argc, char *argv[])
 

Variables

NekDouble m_Re
 
NekDouble m_Mach
 
NekDouble L
 
NekDouble m_Tinf
 
NekDouble m_Suth
 
NekDouble m_Tw
 
NekDouble m_Twall
 
NekDouble m_Gamma
 
NekDouble m_Pr
 
NekDouble m_long
 
NekDouble m_uInf
 
NekDouble m_rhoInf
 
NekDouble m_R
 
NekDouble m_vInf
 
NekDouble m_mu
 
NekDouble m_To = 273.11
 
const int m_xpoints = 1000001
 
const NekDouble Nvisc = 1
 
const NekDouble Omega = 1
 
const NekDouble etamax = 10.0
 
const NekDouble errtol = 1e-5
 

Function Documentation

◆ COMPBL()

void COMPBL ( Array< OneD, NekDouble v,
Array< OneD, NekDouble dv 
)

Calculate the compressible boundary layer using the similarity solution

Definition at line 99 of file CompressibleBL.cpp.

100{
101 NekDouble c, dcdg, cp;
102
103 if (Nvisc == 1)
104 {
105 c = sqrt(v[3]) * (1.0 + m_Suth) / (v[3] + m_Suth);
106 dcdg = 1.0 / (2. * sqrt(v[3])) - sqrt(v[3]) / (v[3] + m_Suth);
107 dcdg = dcdg * (1.0 + m_Suth) / (v[3] + m_Suth);
108 cp = dcdg * v[4];
109 }
110 if (Nvisc == 2)
111 {
112 c = pow(v[3], (Omega - 1.0));
113 dcdg = (Omega - 1.0) * pow(v[3], (Omega - 2.0));
114 cp = dcdg * v[4];
115 }
116 if (Nvisc == 3)
117 {
118 c = sqrt(m_Twall) * (1.0 + m_Suth) / (m_Suth + m_Twall);
119 cp = 0.0;
120 }
121
122 dv[0] = v[1];
123 dv[1] = v[2];
124 dv[2] = -v[2] * (cp + v[0]) / c;
125 dv[3] = v[4];
126 dv[4] = -v[4] * (cp + m_Pr * v[0]) / c -
127 m_Pr * (m_Gamma - 1.0) * pow(m_Mach, 2.0) * pow(v[2], 2);
128}
NekDouble m_Suth
NekDouble m_Gamma
NekDouble m_Twall
const NekDouble Nvisc
NekDouble m_Mach
const NekDouble Omega
NekDouble m_Pr
double NekDouble
scalarT< T > sqrt(scalarT< T > in)
Definition: scalar.hpp:294

References m_Gamma, m_Mach, m_Pr, m_Suth, m_Twall, Nvisc, Omega, and tinysimd::sqrt().

Referenced by OUTPUT(), RK4(), and RKDUMB().

◆ main()

int main ( int  argc,
char *  argv[] 
)

Calculate the compressible boundary layer solution for a given 3D mesh and dump the solution into a .rst file.

Definition at line 337 of file CompressibleBL.cpp.

338{
339 // Variable initialisation
340 int nmax = 5;
341 int maxit = 10;
342
343 string opt;
344
345 int i, j, k, numModes;
346
349 Array<OneD, NekDouble> parameter(9, 0.0);
350
351 for (i = 0; i < nmax; i++)
352 {
354 }
355
356 Array<OneD, NekDouble> vstart(nmax, 0.0);
362
363 NekDouble al11, al21, al12, al22, det;
364
365 // Reading the session file
367 LibUtilities::SessionReader::CreateInstance(argc, argv);
368
369 // Read in mesh from input file and create an object of class MeshGraph
371 SpatialDomains::MeshGraph::Read(vSession);
372
373 int expdim = graphShPt->GetMeshDimension();
374
375 int nElements, nQuadraturePts = 0;
376 Array<OneD, NekDouble> x_QuadraturePts;
377 Array<OneD, NekDouble> y_QuadraturePts;
378 Array<OneD, NekDouble> z_QuadraturePts;
379
382 vSession, graphShPt, vSession->GetVariable(0));
383
384 // Get the total number of elements
385 nElements = Domain->GetExpSize();
386 std::cout << "Number of elements = " << nElements
387 << std::endl;
388
389 // Get the total number of quadrature points (depends on n. modes)
390 nQuadraturePts = Domain->GetTotPoints();
391 std::cout << "Number of quadrature points = " << nQuadraturePts
392 << std::endl;
393
394 // Coordinates of the quadrature points
395 x_QuadraturePts = Array<OneD, NekDouble>(nQuadraturePts);
396 y_QuadraturePts = Array<OneD, NekDouble>(nQuadraturePts);
397 z_QuadraturePts = Array<OneD, NekDouble>(nQuadraturePts);
398 Domain->GetCoords(x_QuadraturePts, y_QuadraturePts, z_QuadraturePts);
399
400 if (expdim == 1)
401 {
402 ASSERTL0(false, "Routine available for 2D and 3D problem only.")
403 }
404
405 // Loading parameters from session file
406 vSession->LoadParameter("Re", m_Re, 1.0);
407 vSession->LoadParameter("Mach", m_Mach, 1.0);
408 vSession->LoadParameter("TInf", m_Tinf, 1.0);
409 vSession->LoadParameter("Twall", m_Twall, 1.0);
410 vSession->LoadParameter("Gamma", m_Gamma, 1.0);
411 vSession->LoadParameter("Pr", m_Pr, 1.0);
412 vSession->LoadParameter("L", m_long, 1.0);
413 vSession->LoadParameter("rhoInf", m_rhoInf, 1.0);
414 vSession->LoadParameter("uInf", m_uInf, 1.0);
415 vSession->LoadParameter("GasConstant", m_R, 1.0);
416 vSession->LoadParameter("vInf", m_vInf, 1.0);
417 vSession->LoadParameter("mu", m_mu, 1.0);
418
419 // Rescaling factors
420 m_Suth = 110.4 / m_Tinf;
421 m_Tw = m_Twall / m_Tinf;
422 m_Re = m_Re / m_long;
423
424 cout << "Number of points"
425 << " " << m_xpoints << endl;
426
427 // Defining the solution arrays
428 Array<OneD, NekDouble> u_QuadraturePts(nQuadraturePts, 0.0);
429 Array<OneD, NekDouble> v_QuadraturePts(nQuadraturePts, 0.0);
430 Array<OneD, NekDouble> rho_QuadraturePts(nQuadraturePts, 0.0);
431 Array<OneD, NekDouble> T_QuadraturePts(nQuadraturePts, 0.0);
432
433 // Calculation of the similarity variables
434 if (m_Tw > 0)
435 {
436 vstart[3] = m_Tw;
437 }
438 if (m_Tw < 0.0)
439 {
440 v[1] = 1.0 + 0.5 * 0.84 * (m_Gamma - 1) * (m_Mach * m_Mach);
441 v[0] = 0.47 * pow(v[1], 0.21);
442 }
443 else
444 {
445 v[1] = 0.062 * pow(m_Mach, 2) -
446 0.1 * (m_Tw - 1.0) * (10 + m_Mach) / (0.2 + m_Mach);
447 v[0] = 0.45 - 0.01 * m_Mach + (m_Tw - 1.0) * 0.06;
448 m_Twall = m_Tw;
449 }
450
451 dv[0] = v[0] * 0.01;
452
453 if (m_Tw < 0.0)
454 {
455 dv[1] = v[1] * 0.01;
456 }
457 else
458 {
459 dv[1] = 0.1;
460 }
461
462 vstart[2] = v[0];
463
464 if (m_Tw < 0)
465 {
466 vstart[3] = v[1];
467 m_Twall = vstart[3];
468 }
469 else
470 {
471 vstart[4] = v[1];
472 }
473
474 RKDUMB(vstart, 5, 0.0, etamax, m_xpoints, xx, ff);
475
476 for (k = 0; k < maxit; k++)
477 {
478 vstart[2] = v[0];
479
480 if (m_Tw < 0)
481 {
482 vstart[3] = v[1];
483 m_Twall = vstart[3];
484 }
485 else
486 {
487 vstart[4] = v[1];
488 }
489
490 RKDUMB(vstart, 5, 0.0, etamax, m_xpoints, xx, ff);
491
492 NekDouble err = fabs(ff[1][m_xpoints] - 1) + fabs(ff[3][m_xpoints] - 1);
493
494 cout << "err" << scientific << setprecision(9) << " " << err << endl;
495
496 if (expdim == 2)
497 {
498 if (err < errtol)
499 {
500 cout << "Calculating" << endl;
501 OUTPUT(m_xpoints, xx, ff, nQuadraturePts, x_QuadraturePts,
502 y_QuadraturePts, u_QuadraturePts, v_QuadraturePts,
503 rho_QuadraturePts, T_QuadraturePts);
504 break;
505 }
506 else
507 {
508 f[0] = ff[1][m_xpoints] - 1;
509 f[1] = ff[3][m_xpoints] - 1;
510 vstart[2] = v[0] + dv[0];
511
512 if (m_Tw < 0)
513 {
514 vstart[3] = v[1];
515 m_Twall = vstart[3];
516 }
517 else
518 {
519 vstart[4] = v[1];
520 }
521
522 RKDUMB(vstart, 5, 0.0, etamax, m_xpoints, xx, ff);
523
524 f1[0] = ff[1][m_xpoints] - 1;
525 f1[1] = ff[3][m_xpoints] - 1;
526
527 vstart[2] = v[0];
528
529 if (m_Tw < 0)
530 {
531 vstart[3] = v[1] + dv[1];
532 m_Twall = vstart[3];
533 }
534 else
535 {
536 vstart[4] = v[1] + dv[1];
537 }
538
539 RKDUMB(vstart, 5, 0.0, etamax, m_xpoints, xx, ff);
540
541 f2[0] = ff[1][m_xpoints] - 1;
542 f2[1] = ff[3][m_xpoints] - 1;
543
544 al11 = (f1[0] - f[0]) / dv[0];
545 al21 = (f1[1] - f[1]) / dv[0];
546 al12 = (f2[0] - f[0]) / dv[1];
547 al22 = (f2[1] - f[1]) / dv[1];
548 det = al11 * al22 - al21 * al12;
549
550 dv[0] = (-al22 * f[0] + al12 * f[1]) / det;
551 dv[1] = (al21 * f[0] - al11 * f[1]) / det;
552 v[0] = v[0] + dv[0];
553 v[1] = v[1] + dv[1];
554 }
555 }
556 else if (expdim == 3)
557 {
558 {
559 if (err < errtol)
560 {
561 cout << "Calculating" << endl;
562 OUTPUT(m_xpoints, xx, ff, nQuadraturePts, x_QuadraturePts,
563 z_QuadraturePts, u_QuadraturePts, v_QuadraturePts,
564 rho_QuadraturePts, T_QuadraturePts);
565 break;
566 }
567 else
568 {
569 f[0] = ff[1][m_xpoints] - 1;
570 f[1] = ff[3][m_xpoints] - 1;
571 vstart[2] = v[0] + dv[0];
572
573 if (m_Tw < 0)
574 {
575 vstart[3] = v[1];
576 m_Twall = vstart[3];
577 }
578 else
579 {
580 vstart[4] = v[1];
581 }
582
583 RKDUMB(vstart, 5, 0.0, etamax, m_xpoints, xx, ff);
584
585 f1[0] = ff[1][m_xpoints] - 1;
586 f1[1] = ff[3][m_xpoints] - 1;
587
588 vstart[2] = v[0];
589
590 if (m_Tw < 0)
591 {
592 vstart[3] = v[1] + dv[1];
593 m_Twall = vstart[3];
594 }
595 else
596 {
597 vstart[4] = v[1] + dv[1];
598 }
599
600 RKDUMB(vstart, 5, 0.0, etamax, m_xpoints, xx, ff);
601
602 f2[0] = ff[1][m_xpoints] - 1;
603 f2[1] = ff[3][m_xpoints] - 1;
604
605 al11 = (f1[0] - f[0]) / dv[0];
606 al21 = (f1[1] - f[1]) / dv[0];
607 al12 = (f2[0] - f[0]) / dv[1];
608 al22 = (f2[1] - f[1]) / dv[1];
609 det = al11 * al22 - al21 * al12;
610
611 dv[0] = (-al22 * f[0] + al12 * f[1]) / det;
612 dv[1] = (al21 * f[0] - al11 * f[1]) / det;
613 v[0] = v[0] + dv[0];
614 v[1] = v[1] + dv[1];
615 }
616 }
617 }
618 }
619
620 // Verification of the compressible similarity solution
621 ofstream verif;
622 verif.open("similarity_solution.dat");
623 for (i = 0; i < nQuadraturePts; i++)
624 {
625 verif << scientific << setprecision(9) << x_QuadraturePts[i] << " \t "
626 << y_QuadraturePts[i] << " \t ";
627 verif << scientific << setprecision(9) << u_QuadraturePts[i] << " \t "
628 << v_QuadraturePts[i] << " \t ";
629 verif << scientific << setprecision(9) << rho_QuadraturePts[i]
630 << " \t " << T_QuadraturePts[i] << endl;
631 }
632 verif.close();
633
634 // Calculation of the physical variables
635 for (i = 0; i < nQuadraturePts; i++)
636 {
637 rho_QuadraturePts[i] = rho_QuadraturePts[i] * m_rhoInf;
638 u_QuadraturePts[i] = u_QuadraturePts[i] * m_uInf;
639 v_QuadraturePts[i] = v_QuadraturePts[i] * m_uInf;
640 T_QuadraturePts[i] = T_QuadraturePts[i] * m_Tinf;
641
642 T_QuadraturePts[i] = T_QuadraturePts[i] * rho_QuadraturePts[i] * m_R;
643 T_QuadraturePts[i] = T_QuadraturePts[i] / (m_Gamma - 1);
644 T_QuadraturePts[i] =
645 T_QuadraturePts[i] +
646 0.5 * rho_QuadraturePts[i] *
647 (pow(u_QuadraturePts[i], 2.0) + pow(v_QuadraturePts[i], 2.0));
648
649 u_QuadraturePts[i] = u_QuadraturePts[i] * rho_QuadraturePts[i];
650 v_QuadraturePts[i] = v_QuadraturePts[i] * rho_QuadraturePts[i];
651 }
652 string file_name;
653 if (expdim == 2)
654 {
657 vSession, graphShPt, vSession->GetVariable(0));
658
662 vSession, graphShPt);
663
666 vSession, graphShPt);
667
670 vSession, graphShPt);
671
674 vSession, graphShPt);
675
676 // Filling the 2D expansion using a recursive algorithm based on the
677 // mesh ordering
679 Basis = Domain->GetExp(0)->GetBasis(0);
680 numModes = Basis->GetNumModes();
681
682 std::cout << "Number of modes = " << numModes << std::endl;
683
684 // Copying the ukGlobal vector in m_phys (with the same pattern of
685 // m_phys)
686 Vmath::Vcopy(nQuadraturePts, u_QuadraturePts, 1, Exp2D_uk->UpdatePhys(),
687 1);
688 Vmath::Vcopy(nQuadraturePts, v_QuadraturePts, 1, Exp2D_vk->UpdatePhys(),
689 1);
690 Vmath::Vcopy(nQuadraturePts, rho_QuadraturePts, 1,
691 Exp2D_rhok->UpdatePhys(), 1);
692 Vmath::Vcopy(nQuadraturePts, T_QuadraturePts, 1, Exp2D_Tk->UpdatePhys(),
693 1);
694
695 // Initialisation of the ExpList Exp
696 Exp[0] = Exp2D_rhok;
697 Exp[1] = Exp2D_uk;
698 Exp[2] = Exp2D_vk;
699 Exp[3] = Exp2D_Tk;
700
701 // Expansion coefficient extraction (necessary to write the .fld file)
702 Exp[0]->FwdTrans(Exp2D_rhok->GetPhys(), Exp[0]->UpdateCoeffs());
703 Exp[1]->FwdTrans(Exp2D_uk->GetPhys(), Exp[1]->UpdateCoeffs());
704 Exp[2]->FwdTrans(Exp2D_vk->GetPhys(), Exp[2]->UpdateCoeffs());
705 Exp[3]->FwdTrans(Exp2D_Tk->GetPhys(), Exp[3]->UpdateCoeffs());
706
707 // Definition of the name of the .fld file
708 cout << argv[1] << endl;
709 string tmp = argv[1];
710 int len = tmp.size();
711 for (i = 0; i < len - 4; ++i)
712 {
713 file_name += argv[1][i];
714 }
715 file_name = file_name + ".rst";
716
717 // Definition of the Field
718 std::vector<LibUtilities::FieldDefinitionsSharedPtr> FieldDef =
719 Exp[0]->GetFieldDefinitions();
720 std::vector<std::vector<NekDouble>> FieldData(FieldDef.size());
721
722 for (j = 0; j < 4; j++)
723 {
724 for (i = 0; i < FieldDef.size(); i++)
725 {
726 if (j == 0)
727 {
728 FieldDef[i]->m_fields.push_back("rho");
729 }
730 else if (j == 1)
731 {
732 FieldDef[i]->m_fields.push_back("rhou");
733 }
734 else if (j == 2)
735 {
736 FieldDef[i]->m_fields.push_back("rhov");
737 }
738 else if (j == 3)
739 {
740 FieldDef[i]->m_fields.push_back("E");
741 }
742 Exp[j]->AppendFieldData(FieldDef[i], FieldData[i]);
743 }
744 }
745
746 LibUtilities::Write(file_name, FieldDef, FieldData);
747 }
748 else if (expdim == 3)
749 {
752 vSession, graphShPt, vSession->GetVariable(0));
753
754 Array<OneD, NekDouble> w_QuadraturePts;
755 w_QuadraturePts = Array<OneD, NekDouble>(nQuadraturePts, 0.0);
757
760 vSession, graphShPt);
761
764 vSession, graphShPt);
765
768 vSession, graphShPt);
769
772 vSession, graphShPt);
773
776 vSession, graphShPt);
777
778 // Filling the 3D expansion using a recursive algorithm based
779 // on the mesh ordering
781 Basis = Domain->GetExp(0)->GetBasis(0);
782 numModes = Basis->GetNumModes();
783
784 std::cout << "Number of modes = " << numModes << std::endl;
785
786 // Copying the ukGlobal vector in m_phys (with the same pattern
787 // of m_phys)
788 Vmath::Vcopy(nQuadraturePts, rho_QuadraturePts, 1,
789 Exp3D_rhok->UpdatePhys(), 1);
790 Vmath::Vcopy(nQuadraturePts, u_QuadraturePts, 1, Exp3D_uk->UpdatePhys(),
791 1);
792 Vmath::Vcopy(nQuadraturePts, w_QuadraturePts, 1, Exp3D_vk->UpdatePhys(),
793 1);
794 Vmath::Vcopy(nQuadraturePts, v_QuadraturePts, 1, Exp3D_wk->UpdatePhys(),
795 1);
796 Vmath::Vcopy(nQuadraturePts, T_QuadraturePts, 1, Exp3D_Tk->UpdatePhys(),
797 1);
798
799 // Initialisation of the ExpList Exp
800 Exp[0] = Exp3D_rhok;
801 Exp[1] = Exp3D_uk;
802 Exp[2] = Exp3D_vk;
803 Exp[3] = Exp3D_wk;
804 Exp[4] = Exp3D_Tk;
805
806 // Expansion coefficient extraction (necessary to write the .fld file)
807 Exp[0]->FwdTrans(Exp3D_rhok->GetPhys(), Exp[0]->UpdateCoeffs());
808 Exp[1]->FwdTrans(Exp3D_uk->GetPhys(), Exp[1]->UpdateCoeffs());
809 Exp[2]->FwdTrans(Exp3D_vk->GetPhys(), Exp[2]->UpdateCoeffs());
810 Exp[3]->FwdTrans(Exp3D_wk->GetPhys(), Exp[3]->UpdateCoeffs());
811 Exp[4]->FwdTrans(Exp3D_Tk->GetPhys(), Exp[4]->UpdateCoeffs());
812
813 // Definition of the name of the .fld file
814 cout << argv[1] << endl;
815 string tmp = argv[1];
816 int len = tmp.size();
817 for (i = 0; i < len - 4; ++i)
818 {
819 file_name += argv[1][i];
820 }
821 file_name = file_name + ".rst";
822
823 // Definition of the Field
824 std::vector<LibUtilities::FieldDefinitionsSharedPtr> FieldDef =
825 Exp[0]->GetFieldDefinitions();
826 std::vector<std::vector<NekDouble>> FieldData(FieldDef.size());
827
828 for (j = 0; j < 5; j++)
829 {
830 for (i = 0; i < FieldDef.size(); i++)
831 {
832 if (j == 0)
833 {
834 FieldDef[i]->m_fields.push_back("rho");
835 }
836 else if (j == 1)
837 {
838 FieldDef[i]->m_fields.push_back("rhou");
839 }
840 else if (j == 2)
841 {
842 FieldDef[i]->m_fields.push_back("rhov");
843 }
844 else if (j == 3)
845 {
846 FieldDef[i]->m_fields.push_back("rhow");
847 }
848 else if (j == 4)
849 {
850 FieldDef[i]->m_fields.push_back("E");
851 }
852 Exp[j]->AppendFieldData(FieldDef[i], FieldData[i]);
853 }
854 }
855
856 LibUtilities::Write(file_name, FieldDef, FieldData);
857 }
858
859 std::cout << "----------------------------------------------------\n";
860 std::cout << "\n=================================================\n";
861 std::cout << "Similarity solution \n";
862 std::cout << "===================================================\n";
863 std::cout << "***************************************************\n";
864 std::cout << "DATA FROM THE SESSION FILE:\n";
865 std::cout << "Reynolds number = " << m_Re << "\t[-]"
866 << std::endl;
867 std::cout << "Mach number = " << m_Mach << "\t[-]"
868 << std::endl;
869 std::cout << "Characteristic length = " << m_long << "\t[m]"
870 << std::endl;
871 std::cout << "U_infinity = " << m_uInf << "\t[m/s]"
872 << std::endl;
873 std::cout << "***************************************************\n";
874 std::cout << "---------------------------------------------------\n";
875 std::cout << "MESH and EXPANSION DATA:\n";
876 std::cout << "Done." << std::endl;
877
878 return 0;
879}
NekDouble m_mu
NekDouble m_Tinf
NekDouble m_R
void OUTPUT(int m_xpoints, Array< OneD, NekDouble > xx, Array< OneD, Array< OneD, NekDouble > > ff, int nQuadraturePts, Array< OneD, NekDouble > x_QuadraturePts, Array< OneD, NekDouble > y_QuadraturePts, Array< OneD, NekDouble > u_QuadraturePts, Array< OneD, NekDouble > v_QuadraturePts, Array< OneD, NekDouble > rho_QuadraturePts, Array< OneD, NekDouble > T_QuadraturePts)
const NekDouble etamax
NekDouble m_Tw
const NekDouble errtol
NekDouble m_rhoInf
void RKDUMB(Array< OneD, NekDouble > vstart, int nvar, NekDouble x1, NekDouble x2, int m_xpoints, Array< OneD, NekDouble > xx, Array< OneD, Array< OneD, NekDouble > > y)
NekDouble m_long
const int m_xpoints
NekDouble m_vInf
NekDouble m_uInf
NekDouble m_Re
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:215
Represents a basis of a given type.
Definition: Basis.h:200
int GetNumModes() const
Return order of basis from the basis specification.
Definition: Basis.h:209
General purpose memory allocation routines with the ability to allocate from thread specific memory p...
std::shared_ptr< Basis > BasisSharedPtr
std::shared_ptr< SessionReader > SessionReaderSharedPtr
void Write(const std::string &outFile, std::vector< FieldDefinitionsSharedPtr > &fielddefs, std::vector< std::vector< NekDouble > > &fielddata, const FieldMetaDataMap &fieldinfomap, const bool backup)
This function allows for data to be written to an FLD file when a session and/or communicator is not ...
Definition: FieldIO.cpp:247
std::shared_ptr< ExpList > ExpListSharedPtr
Shared pointer to an ExpList object.
std::shared_ptr< ContField > ContFieldSharedPtr
Definition: ContField.h:270
std::shared_ptr< MeshGraph > MeshGraphSharedPtr
Definition: MeshGraph.h:176
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
Definition: Vmath.cpp:1191

References ASSERTL0, errtol, etamax, Nektar::LibUtilities::Basis::GetNumModes(), m_Gamma, m_long, m_Mach, m_mu, m_Pr, m_R, m_Re, m_rhoInf, m_Suth, m_Tinf, m_Tw, m_Twall, m_uInf, m_vInf, m_xpoints, OUTPUT(), RKDUMB(), Vmath::Vcopy(), and Nektar::LibUtilities::Write().

◆ OUTPUT()

void OUTPUT ( int  m_xpoints,
Array< OneD, NekDouble xx,
Array< OneD, Array< OneD, NekDouble > >  ff,
int  nQuadraturePts,
Array< OneD, NekDouble x_QuadraturePts,
Array< OneD, NekDouble y_QuadraturePts,
Array< OneD, NekDouble u_QuadraturePts,
Array< OneD, NekDouble v_QuadraturePts,
Array< OneD, NekDouble rho_QuadraturePts,
Array< OneD, NekDouble T_QuadraturePts 
)

Create the output file

Definition at line 219 of file CompressibleBL.cpp.

227{
236 Array<OneD, NekDouble> velocity(m_xpoints, 0.0);
238
239 NekDouble dd, dm, scale;
240 NekDouble xcher, ycher;
241 int index = -1;
242
243 z[0] = 0.0;
244 NekDouble sumd = 0.0;
245
246 for (int i = 1; i < m_xpoints; i++)
247 {
248 z[i] = z[i - 1] + 0.5 * (xx[i] - xx[i - 1]) * (ff[3][i] + ff[3][i - 1]);
249 dm = ff[3][i - 1] - ff[1][i - 1];
250 dd = ff[3][i] - ff[1][i];
251 sumd = sumd + 0.5 * (xx[i] - xx[i - 1]) * (dd + dm);
252 }
253
254 scale = sumd;
255
256 ofstream file3;
257 file3.open("physical_data.dat");
258
259 NekDouble xin, rex, delsx, delta;
260
261 for (int i = 0; i < m_xpoints; i++)
262 {
263 for (int k = 0; k < 5; k++)
264 {
265 v[k] = ff[k][i];
266 }
267 COMPBL(v, dv);
268 u[i] = ff[1][i];
269 t[i] = ff[3][i];
270 rho[i] = (1.0 / ff[3][i]);
271 vv[i] = -ff[0][i] / sqrt(m_uInf);
272 mu[i] = pow(t[i], 1.5) * (1 + m_Suth) / (t[i] + m_Suth) / (m_Re);
273 velocity[i] = ff[0][i];
274 }
275
276 NekDouble scale2, coeff;
277
278 for (int i = 0; i < nQuadraturePts; i++)
279 {
280 if (i % 100000 == 0)
281 {
282 cout << "i"
283 << " " << i << "/" << nQuadraturePts << endl;
284 }
285
286 xcher = x_QuadraturePts[i];
287 ycher = y_QuadraturePts[i];
288
289 scale = sumd;
290 xin = xcher;
291 rex = 0.5 * pow(((m_Re) / scale), 2) + (m_Re)*xin;
292 delsx = sqrt(2.0 / rex) * scale * (xin)*m_Pr;
293 scale = scale / delsx;
294 delta = 4.91 * sqrt((xin * m_mu) / (m_rhoInf * m_uInf));
295 scale2 = ycher * (scale * delta) / sqrt(etamax);
296 coeff = 0.5 * sqrt(2 / (xcher * m_Re));
297
298 if (scale2 > z[m_xpoints - 3])
299 {
300 u_QuadraturePts[i] = 1;
301 rho_QuadraturePts[i] = 1;
302 T_QuadraturePts[i] = 1.0 / rho_QuadraturePts[i];
303 v_QuadraturePts[i] =
304 coeff * (z[m_xpoints - 3] - velocity[m_xpoints - 3]);
305
306 file3 << xcher << " " << ycher << " "
307 << velocity[m_xpoints - 3] << " " << z[m_xpoints - 3]
308 << " " << u[m_xpoints - 3] << endl;
309 }
310 else
311 {
312 for (int j = 0; j < m_xpoints - 1; j++)
313 {
314 if ((z[j] <= scale2) && (z[j + 1] > scale2))
315 {
316 index = j;
317 break;
318 }
319 }
320 if (index == -1)
321 {
322 ASSERTL0(false, "Could not determine index in CompressibleBL");
323 }
324
325 u_QuadraturePts[i] = u[index];
326 rho_QuadraturePts[i] = rho[index];
327 T_QuadraturePts[i] = 1.0 / rho_QuadraturePts[i];
328 v_QuadraturePts[i] = coeff * (u[index] * scale2 - velocity[index]);
329 }
330 }
331}
void COMPBL(Array< OneD, NekDouble > v, Array< OneD, NekDouble > dv)
std::vector< double > z(NPUPPER)

References ASSERTL0, COMPBL(), etamax, m_mu, m_Pr, m_Re, m_rhoInf, m_Suth, m_uInf, m_xpoints, tinysimd::sqrt(), Nektar::UnitTests::test(), and Nektar::UnitTests::z().

Referenced by main().

◆ RK4()

void RK4 ( Array< OneD, NekDouble y,
Array< OneD, NekDouble dydx,
int  n,
NekDouble  x,
NekDouble  h,
Array< OneD, NekDouble yout 
)

Perform the RK4 integration

Definition at line 133 of file CompressibleBL.cpp.

135{
136 boost::ignore_unused(x);
137
138 int nmax = 5;
139
140 Array<OneD, NekDouble> yt(nmax, 0.0);
141 Array<OneD, NekDouble> dyt(nmax, 0.0);
142 Array<OneD, NekDouble> dym(nmax, 0.0);
143 NekDouble hh = h * 0.5;
144 NekDouble h6 = h / 6;
145
146 for (int i = 0; i < n; i++)
147 {
148 yt[i] = y[i] + hh * dydx[i];
149 }
150
151 COMPBL(yt, dyt);
152
153 for (int i = 0; i < n; i++)
154 {
155 yt[i] = y[i] + hh * dyt[i];
156 }
157
158 COMPBL(yt, dym);
159
160 for (int i = 0; i < n; i++)
161 {
162 yt[i] = y[i] + h * dym[i];
163 dym[i] = dyt[i] + dym[i];
164 }
165
166 COMPBL(yt, dyt);
167
168 for (int i = 0; i < n; i++)
169 {
170 yout[i] = y[i] + h6 * (dydx[i] + dyt[i] + 2 * dym[i]);
171 }
172}

References COMPBL().

Referenced by RKDUMB().

◆ RKDUMB()

void RKDUMB ( Array< OneD, NekDouble vstart,
int  nvar,
NekDouble  x1,
NekDouble  x2,
int  m_xpoints,
Array< OneD, NekDouble xx,
Array< OneD, Array< OneD, NekDouble > >  y 
)

Calculate initial guess for RK4

Definition at line 177 of file CompressibleBL.cpp.

180{
181 int nmax = 5;
182 NekDouble x, h;
183 Array<OneD, NekDouble> v(nmax, 0.0);
184 Array<OneD, NekDouble> dv(nmax, 0.0);
185
186 for (int i = 0; i < nvar; i++)
187 {
188 v[i] = vstart[i];
189 y[i][0] = v[i];
190 }
191
192 xx[0] = x1;
193 x = x1;
194 h = (x2 - x1) / m_xpoints;
195
196 for (int k = 0; k < m_xpoints; k++)
197 {
198 COMPBL(v, dv);
199 RK4(v, dv, nvar, x, h, v);
200
201 if (x + h == x)
202 {
203 cout << "bug" << endl;
204 }
205
206 x = x + h;
207 xx[k + 1] = x;
208
209 for (int i = 0; i < nvar; i++)
210 {
211 y[i][k + 1] = v[i];
212 }
213 }
214}
void RK4(Array< OneD, NekDouble > y, Array< OneD, NekDouble > dydx, int n, NekDouble x, NekDouble h, Array< OneD, NekDouble > yout)

References COMPBL(), m_xpoints, and RK4().

Referenced by main().

Variable Documentation

◆ errtol

const NekDouble errtol = 1e-5

Definition at line 94 of file CompressibleBL.cpp.

Referenced by main().

◆ etamax

const NekDouble etamax = 10.0

Definition at line 93 of file CompressibleBL.cpp.

Referenced by main(), and OUTPUT().

◆ L

◆ m_Gamma

NekDouble m_Gamma

Definition at line 79 of file CompressibleBL.cpp.

Referenced by COMPBL(), and main().

◆ m_long

NekDouble m_long

Definition at line 81 of file CompressibleBL.cpp.

Referenced by main().

◆ m_Mach

NekDouble m_Mach

Definition at line 73 of file CompressibleBL.cpp.

Referenced by COMPBL(), and main().

◆ m_mu

NekDouble m_mu

◆ m_Pr

NekDouble m_Pr

Definition at line 80 of file CompressibleBL.cpp.

Referenced by COMPBL(), main(), and OUTPUT().

◆ m_R

NekDouble m_R

Definition at line 84 of file CompressibleBL.cpp.

Referenced by main().

◆ m_Re

NekDouble m_Re

Definition at line 72 of file CompressibleBL.cpp.

Referenced by main(), and OUTPUT().

◆ m_rhoInf

NekDouble m_rhoInf

Definition at line 83 of file CompressibleBL.cpp.

Referenced by Nektar::FieldUtils::ProcessWSS::GetViscosity(), main(), and OUTPUT().

◆ m_Suth

NekDouble m_Suth

Definition at line 76 of file CompressibleBL.cpp.

Referenced by COMPBL(), main(), and OUTPUT().

◆ m_Tinf

NekDouble m_Tinf

Definition at line 75 of file CompressibleBL.cpp.

Referenced by main().

◆ m_To

NekDouble m_To = 273.11

Definition at line 87 of file CompressibleBL.cpp.

◆ m_Tw

NekDouble m_Tw

Definition at line 77 of file CompressibleBL.cpp.

Referenced by main().

◆ m_Twall

NekDouble m_Twall

Definition at line 78 of file CompressibleBL.cpp.

Referenced by COMPBL(), and main().

◆ m_uInf

NekDouble m_uInf

Definition at line 82 of file CompressibleBL.cpp.

Referenced by main(), and OUTPUT().

◆ m_vInf

NekDouble m_vInf

Definition at line 85 of file CompressibleBL.cpp.

Referenced by main().

◆ m_xpoints

const int m_xpoints = 1000001

Definition at line 89 of file CompressibleBL.cpp.

Referenced by main(), OUTPUT(), and RKDUMB().

◆ Nvisc

const NekDouble Nvisc = 1

Definition at line 91 of file CompressibleBL.cpp.

Referenced by COMPBL().

◆ Omega

const NekDouble Omega = 1