<commit_before>/* ==========================================================================
 * Generation of a .fld file for the Falkner-Skan boundary layer starting 
 * from a session file with some physical data for the definition of the 
 * BL and a .txt file with the similarity solution. 
 * ======================================================================== */

/* =====================================
 * Author: <NAME> 
 * Generation: dd/mm/aa = 08/03/12
===================================== */ 

//! Loading cc libraries
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <string.h>
#include <sstream>
#include <iomanip>

//! Loading Nektar++ libraries
#include <LibUtilities/Memory/NekMemoryManager.hpp>
#include <MultiRegions/ExpList.h>
#include <MultiRegions/ExpList0D.h>
#include <MultiRegions/ExpList1D.h>
#include <MultiRegions/ExpList2D.h>
#include <MultiRegions/ExpList3D.h>
#include <MultiRegions/ExpList2DHomogeneous1D.h>
#include <MultiRegions/ExpList3DHomogeneous1D.h>
#include <MultiRegions/ExpList1DHomogeneous2D.h>
#include <MultiRegions/ExpList3DHomogeneous2D.h>
#include <MultiRegions/ContField1D.h>
#include <MultiRegions/ContField2D.h>



//! Nektar++ namespace
using namespace Nektar;

//! Main
int main(int argc, char *argv[])
{
    //! Setting up the decimal precision to machine precision
    setprecision (16);
    
    //! Auxiliary counters for the x and y directions
    int  i, j, k, m, numModes;
    
    //! Auxiliary variables
    char    LocalString[1000];
    string  GlobalString[10000];
    bool    inspection = 1;

    
    // Usage check
	if((argc != 2) && (argc != 3))
    {
        fprintf(stderr,"Usage: ./FldAddFalknerSkanBL sessionFile [SysSolnType]\n");exit(1);
    }
    
    //! Check for the command line
    //if(argc != 3)
    //{
    //  fprintf(stderr,"Usage: FldAddFSBL  meshfile txt_file\n");
    //  exit(1);
    //}

    //! Reading the session file
    LibUtilities::SessionReaderSharedPtr vSession = LibUtilities::SessionReader::CreateInstance(argc, argv);
    
    //! Loading the parameters to define the BL
    NekDouble Re;
    NekDouble L;
    NekDouble U_inf;
    NekDouble x;
    NekDouble x_0;
    NekDouble nu;
    string    BL_type;
    string    txt_file;
    int       numLines; 

    
    BL_type   = vSession->GetSolverInfo("BL_type");
    txt_file  = vSession->GetSolverInfo("txt_file");


    vSession->LoadParameter("Re",               Re,             1.0);
    vSession->LoadParameter("L",                L,              1.0);
    vSession->LoadParameter("U_inf",            U_inf,          1.0);
    vSession->LoadParameter("x",                x,              1.0);
    vSession->LoadParameter("x_0",              x_0,            1.0);
    vSession->LoadParameter("NumberLines_txt",  numLines,       1.0);

    //! Check on the physical parameters
    if(x <= 0)
    {
        fprintf(stderr,"Error: x must be positive ===> CHECK the session file\n");
        exit(1);
    }
    
    if(x_0 < 0)
    {
        fprintf(stderr,"Error: x_0 must be positive or at least equal to 0 ===> CHECK the session file\n");
        exit(1);
    }
    std::cout<<"\n===================================================================\n";
    std::cout<<"Falkner-Skan Boundary Layer Generation (version of March 23th 2012)\n"; 
    std::cout<<"===================================================================\n";
    std::cout<<"*******************************************************************\n";
    std::cout<<"DATA FROM THE SESSION FILE:\n";
    std::cout << "Reynolds number                               = " << Re            << std::endl;
    std::cout << "Characteristic length [m]                     = " << L             << std::endl;
    std::cout << "U_infinity [m/s]                              = " << U_inf         << std::endl;
    std::cout << "Position x (parallel case only) [m]           = " << x             << std::endl;
    std::cout << "Position x_0 to start the BL [m]              = " << x_0           << std::endl;
    std::cout << "Number of lines of the .txt file              = " << numLines      << std::endl;
    std::cout << "BL type                                       = " << BL_type       << std::endl;
    std::cout << ".txt file read                                = " << txt_file      << std::endl;
    std::cout<<"*******************************************************************\n";
    std::cout<<"-------------------------------------------------------------------\n";
    std::cout<<"MESH and EXPANSION DATA:\n";
    
    //! Computation of the kinematic viscosity
    nu = U_inf * L / Re;

    //! Read in mesh from input file and create an object of class MeshGraph2D
    SpatialDomains::MeshGraphSharedPtr graphShPt; 
    graphShPt = MemoryManager<SpatialDomains::MeshGraph2D>::AllocateSharedPtr(vSession);
    
    //!  Feed our spatial discretisation object
    MultiRegions::ContField2DSharedPtr Domain;
    Domain = MemoryManager<MultiRegions::ContField2D>::AllocateSharedPtr(vSession,graphShPt,vSession->GetVariable(0));
    
    //! Get the total number of elements
    int nElements;
    nElements = Domain->GetExpSize();
    std::cout << "Number of elements                 = " << nElements << std::endl;
    
    //! Get the total number of quadrature points (depends on n. modes)
    int nQuadraturePts;
    nQuadraturePts = Domain->GetTotPoints();
    std::cout << "Number of quadrature points        = " << nQuadraturePts << std::endl;

    //! Coordinates of the quadrature points
    Array<OneD,NekDouble> x_QuadraturePts;
    Array<OneD,NekDouble> y_QuadraturePts;
    Array<OneD,NekDouble> z_QuadraturePts;
    x_QuadraturePts = Array<OneD,NekDouble>(nQuadraturePts);
    y_QuadraturePts = Array<OneD,NekDouble>(nQuadraturePts);
    z_QuadraturePts = Array<OneD,NekDouble>(nQuadraturePts);
    Domain->GetCoords(x_QuadraturePts,y_QuadraturePts,z_QuadraturePts);
    
    //! Reading the .txt file with eta, f(eta) and f'(eta) -----------------------------------------
    const char *txt_file_char;
    //string txt_file(argv[argc-1]);
    txt_file_char = txt_file.c_str();
        
    ifstream pFile(txt_file_char);
    numLines = numLines/3;
    NekDouble d;
    //NekDouble GlobalArray[numLines][3];
    std::vector<std::vector<NekDouble> > GlobalArray (numLines);

    for (i=0; i<=numLines-1; i++) 
    {
        GlobalArray[i].resize(3);
        for (j=0; j<=2; j++)
        {
            pFile >> d;
            GlobalArray[i][j] = d;
        }
    }
    //! --------------------------------------------------------------------------------------------

    
    //! Saving eta, f(eta) and f'(eta) into separate arrays ----------------------------------------
    Array<OneD,NekDouble> eta;
    Array<OneD,NekDouble> f;
    Array<OneD,NekDouble> df;
    
    eta = Array<OneD,NekDouble>(numLines);
    f   = Array<OneD,NekDouble>(numLines);
    df  = Array<OneD,NekDouble>(numLines);
    
    for (i=0; i<numLines; i++) 
    {
        eta[i] = GlobalArray[i][0];
        f[i]   = GlobalArray[i][1];
        df[i]  = GlobalArray[i][2];
    }
    //! --------------------------------------------------------------------------------------------

    
    //! Inizialisation of the arrays for computations on the Quadrature points --------------------- 
    Array<OneD,NekDouble> eta_QuadraturePts;
    eta_QuadraturePts = Array<OneD,NekDouble>(nQuadraturePts);

    Array<OneD,NekDouble> f_QuadraturePts;
    f_QuadraturePts   = Array<OneD,NekDouble>(nQuadraturePts);
    
    Array<OneD,NekDouble> df_QuadraturePts;
    df_QuadraturePts  = Array<OneD,NekDouble>(nQuadraturePts);
    
    Array<OneD,NekDouble> u_QuadraturePts;
    u_QuadraturePts   = Array<OneD,NekDouble>(nQuadraturePts);

    Array<OneD,NekDouble> v_QuadraturePts;
    v_QuadraturePts   = Array<OneD,NekDouble>(nQuadraturePts);
    
    Array<OneD,NekDouble> p_QuadraturePts;<commit_msg>Changed data reading ordering in  FldAddFalknerSkanBL<commit_after>/* ==========================================================================
 * Generation of a .fld file for the Falkner-Skan boundary layer starting 
 * from a session file with some physical data for the definition of the 
 * BL and a .txt file with the similarity solution. 
 * ======================================================================== */

/* =====================================
 * Author: <NAME> 
 * Generation: dd/mm/aa = 08/03/12
===================================== */ 

//! Loading cc libraries
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <string.h>
#include <sstream>
#include <iomanip>

//! Loading Nektar++ libraries
#include <LibUtilities/Memory/NekMemoryManager.hpp>
#include <MultiRegions/ExpList.h>
#include <MultiRegions/ExpList0D.h>
#include <MultiRegions/ExpList1D.h>
#include <MultiRegions/ExpList2D.h>
#include <MultiRegions/ExpList3D.h>
#include <MultiRegions/ExpList2DHomogeneous1D.h>
#include <MultiRegions/ExpList3DHomogeneous1D.h>
#include <MultiRegions/ExpList1DHomogeneous2D.h>
#include <MultiRegions/ExpList3DHomogeneous2D.h>
#include <MultiRegions/ContField1D.h>
#include <MultiRegions/ContField2D.h>



//! Nektar++ namespace
using namespace Nektar;

//! Main
int main(int argc, char *argv[])
{
    //! Setting up the decimal precision to machine precision
    setprecision (16);
    
    //! Auxiliary counters for the x and y directions
    int  i, j, k, m, numModes;
    
    //! Auxiliary variables
    char    LocalString[1000];
    string  GlobalString[10000];
    bool    inspection = 1;

    
    // Usage check
	if((argc != 2) && (argc != 3))
    {
        fprintf(stderr,"Usage: ./FldAddFalknerSkanBL sessionFile [SysSolnType]\n");exit(1);
    }
    
    //! Check for the command line
    //if(argc != 3)
    //{
    //  fprintf(stderr,"Usage: FldAddFSBL  meshfile txt_file\n");
    //  exit(1);
    //}

    //! Reading the session file
    LibUtilities::SessionReaderSharedPtr vSession = LibUtilities::SessionReader::CreateInstance(argc, argv);
    
    //! Loading the parameters to define the BL
    NekDouble Re;
    NekDouble L;
    NekDouble U_inf;
    NekDouble x;
    NekDouble x_0;
    NekDouble nu;
    string    BL_type;
    string    txt_file;
    int       numLines; 

    
    BL_type   = vSession->GetSolverInfo("BL_type");
    txt_file  = vSession->GetSolverInfo("txt_file");


    vSession->LoadParameter("Re",               Re,             1.0);
    vSession->LoadParameter("L",                L,              1.0);
    vSession->LoadParameter("U_inf",            U_inf,          1.0);
    vSession->LoadParameter("x",                x,              1.0);
    vSession->LoadParameter("x_0",              x_0,            1.0);
    vSession->LoadParameter("NumberLines_txt",  numLines,       1.0);

    //! Check on the physical parameters
    if(x <= 0)
    {
        fprintf(stderr,"Error: x must be positive ===> CHECK the session file\n");
        exit(1);
    }
    
    if(x_0 < 0)
    {
        fprintf(stderr,"Error: x_0 must be positive or at least equal to 0 ===> CHECK the session file\n");
        exit(1);
    }
    std::cout<<"\n===================================================================\n";
    std::cout<<"Falkner-Skan Boundary Layer Generation (version of March 23th 2012)\n"; 
    std::cout<<"===================================================================\n";
    std::cout<<"*******************************************************************\n";
    std::cout<<"DATA FROM THE SESSION FILE:\n";
    std::cout << "Reynolds number                               = " << Re            << std::endl;
    std::cout << "Characteristic length [m]                     = " << L             << std::endl;
    std::cout << "U_infinity [m/s]                              = " << U_inf         << std::endl;
    std::cout << "Position x (parallel case only) [m]           = " << x             << std::endl;
    std::cout << "Position x_0 to start the BL [m]              = " << x_0           << std::endl;
    std::cout << "Number of lines of the .txt file              = " << numLines      << std::endl;
    std::cout << "BL type                                       = " << BL_type       << std::endl;
    std::cout << ".txt file read                                = " << txt_file      << std::endl;
    std::cout<<"*******************************************************************\n";
    std::cout<<"-------------------------------------------------------------------\n";
    std::cout<<"MESH and EXPANSION DATA:\n";
    
    //! Computation of the kinematic viscosity
    nu = U_inf * L / Re;

    //! Read in mesh from input file and create an object of class MeshGraph2D
    SpatialDomains::MeshGraphSharedPtr graphShPt; 
    graphShPt = MemoryManager<SpatialDomains::MeshGraph2D>::AllocateSharedPtr(vSession);
    
    //!  Feed our spatial discretisation object
    MultiRegions::ContField2DSharedPtr Domain;
    Domain = MemoryManager<MultiRegions::ContField2D>::AllocateSharedPtr(vSession,graphShPt,vSession->GetVariable(0));
    
    //! Get the total number of elements
    int nElements;
    nElements = Domain->GetExpSize();
    std::cout << "Number of elements                 = " << nElements << std::endl;
    
    //! Get the total number of quadrature points (depends on n. modes)
    int nQuadraturePts;
    nQuadraturePts = Domain->GetTotPoints();
    std::cout << "Number of quadrature points        = " << nQuadraturePts << std::endl;

    //! Coordinates of the quadrature points
    Array<OneD,NekDouble> x_QuadraturePts;
    Array<OneD,NekDouble> y_QuadraturePts;
    Array<OneD,NekDouble> z_QuadraturePts;
    x_QuadraturePts = Array<OneD,NekDouble>(nQuadraturePts);
    y_QuadraturePts = Array<OneD,NekDouble>(nQuadraturePts);
    z_QuadraturePts = Array<OneD,NekDouble>(nQuadraturePts);
    Domain->GetCoords(x_QuadraturePts,y_QuadraturePts,z_QuadraturePts);

    //! Reading the .txt file with eta, f(eta) and f'(eta) -----------------------------------------
    const char *txt_file_char;
    //string txt_file(argv[argc-1]);
    txt_file_char = txt_file.c_str();

    ifstream pFile(txt_file_char);
    numLines = numLines/3;
    NekDouble d;
    //NekDouble GlobalArray[numLines][3];
    std::vector<std::vector<NekDouble> > GlobalArray (3);

    for (j=0; j<=2; j++)
    {
        GlobalArray[i].resize(numLines);
        for (i=0; i<=numLines-1; i++)
        {
            pFile >> d;
            GlobalArray[j][i] = d;
        }
    }
    //! --------------------------------------------------------------------------------------------


    //! Saving eta, f(eta) and f'(eta) into separate arrays ----------------------------------------
    Array<OneD,NekDouble> eta;
    Array<OneD,NekDouble> f;
    Array<OneD,NekDouble> df;

    eta = Array<OneD,NekDouble>(numLines);
    f   = Array<OneD,NekDouble>(numLines);
    df  = Array<OneD,NekDouble>(numLines);

    for (i=0; i<numLines; i++)
    {
        eta[i] = GlobalArray[0][i];
        f[i]   = GlobalArray[1][i];
        df[i]  = GlobalArray[2][i];
    }
    //! --------------------------------------------------------------------------------------------

    
    //! Inizialisation of the arrays for computations on the Quadrature points --------------------- 
    Array<OneD,NekDouble> eta_QuadraturePts;
    eta_QuadraturePts = Array<OneD,NekDouble>(nQuadraturePts);

    Array<OneD,NekDouble> f_QuadraturePts;
    f_QuadraturePts   = Array<OneD,NekDouble>(nQuadraturePts);
    
    Array<OneD,NekDouble> df_QuadraturePts;
    df_QuadraturePts  = Array<OneD,NekDouble>(nQuadraturePts);
    
    Array<OneD,NekDouble> u_QuadraturePts;
    u_QuadraturePts   = Array<OneD,NekDouble>(nQuadraturePts);

    Array<OneD,NekDouble> v_QuadraturePts;
    v_QuadraturePts   = Array<OneD,NekDouble>(nQuadraturePts);
    
    Array<OneD,NekDouble> p_QuadraturePts;
{'fraction_non_alphanumeric': 0.22342433010441565, 'fraction_numerical': 0.010567366964398037, 'mean_word_length': 2.4052259584493467, 'pattern_counts': {'":': 0, '<': 259, '<?xml version=': 0, '>': 129, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 16, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3394231', 'n_tokens_mistral': 5064, 'n_tokens_neox': 4855, 'n_words': 1026}