From 2d6d1821cca926236ecb89b6d8a35abab342c2ee Mon Sep 17 00:00:00 2001 From: astrobearrrrr <895208821@qq.com> Date: Fri, 4 Aug 2023 13:35:38 +0800 Subject: [PATCH] fix/disspation --- VortexWake.cpp | 333 +++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 296 insertions(+), 37 deletions(-) diff --git a/VortexWake.cpp b/VortexWake.cpp index a76d8d9..f96ba17 100644 --- a/VortexWake.cpp +++ b/VortexWake.cpp @@ -8,18 +8,29 @@ #include #include #include +//attention!!! only window have , the existence of in unix/Linux needs to be verified +#include using namespace std; -double Integration(const std::vector &dx, const std::vector &dy, const std::vector &data); +double average(const std::vector > &x, const std::vector > &y, const double averangex[], const double averangey[], const double &Nx, const double &Ny, const std::vector > &data); +double DisplaThick_LineIntegration(const std::vector > &y, const std::vector &dy, const double &Ny, const double &u_inf, const std::vector &data, const double &beam_y_end); +double MomentumThick_LineIntegration(const std::vector > &y, const std::vector &dy, const double &Ny, const double &u_inf, const std::vector &data, const double &beam_y_end); +double EnergyThick_LineIntegration(const std::vector > &y, const std::vector &dy, const double &Ny, const double &u_inf, const std::vector &data, const double &beam_y_end); +double LineIntegration(const std::vector > &x, const std::vector > &y, const std::vector &dx, const std::vector &dy, const double integrangex[], const double integrangey[], const double &Nx, const double &Ny, const std::vector > &data); +double SurfaceIntegration(const std::vector > &x, const std::vector > &y, const std::vector &dx, const std::vector &dy, const double integrangex[], const double integrangey[], const double &Nx, const double &Ny, const std::vector > &data); int ExtractDxDy(const std::vector & zones, std::vector &dx, std::vector &dy); +int Extractxypuvw(const std::vector & zones, std::vector > &x, std::vector > &y, std::vector > &p, std::vector > &u, std::vector > &v,std::vector > &W_z); -double ProcessWakeData(const std::vector & zones, std::string message) { +double ProcessWakeData(const std::vector & zones, std::string message, const double &u_inf, const double &beam_y_end, const double &volumforce) { int Np = zones[0].data[0].size(); - int Idx = 0, Idy = 1, Idu = 3, Idv = 4, Idvor = 5; - double xmin = -5, xmax = 25., ymin = -5., ymax = 5.; - double x0 = zones[1].data[0][0]; - double y0 = zones[1].data[1][0]; - std::vector dx, dy; - ExtractDxDy(zones, dx, dy); + std::vector N = zones[0].N; + int Nx = N[0]; + int Ny = N[1]; + + // modify as needed !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + // calculate zone [-20,20]*[0,20], modify as needed + double xmin = -20., xmax = 20., ymin = 0., ymax = 20.; + double x0 = 0; + double y0 = 0; xmin += x0; xmax += x0; ymin += y0; @@ -28,23 +39,156 @@ double ProcessWakeData(const std::vector & zones, std::string message) ymin = max(ymin, zones[0].data[1][0]); xmax = min(xmax, zones[0].data[0][Np-1]); ymax = min(ymax, zones[0].data[1][Np-1]); - double Area = (ymax - ymin) * (xmax - xmin); - std::vector enstrophy(Np, 0.); - std::vector kinetic(Np, 0.); - for(int i=0; i > x(Ny,vector(Nx,0)); + std::vector > y(Ny,vector(Nx,0)); + std::vector > p(Ny,vector(Nx,0)); + std::vector > u(Ny,vector(Nx,0)); + std::vector > v(Ny,vector(Nx,0)); + std::vector > W_z(Ny,vector(Nx,0)); + std::vector dx, dy; + ExtractDxDy(zones, dx, dy); + std::vector > enstrophy(Ny,vector(Nx,0)); + std::vector > kinetic(Ny,vector(Nx,0)); + std::vector > velocity_u(Ny,vector(Nx,0)); + std::vector > velocity_v(Ny,vector(Nx,0)); + std::vector > vorticity(Ny,vector(Nx,0)); + std::vector > boundaryvortexflux(Ny,vector(Nx,0)); + std::vector > velocity_ugradient(Ny,vector(Nx,0)); + double totalenstrophy = 0., totalkinetic = 0., avervelocity_u = 0., avervelocity_v = 0., avervorticity = 0., averboundaryvortexflux = 0., avervelocity_ugradient = 0.; + Extractxypuvw(zones, x, y, p, u, v, W_z); + + fstream BasicInfor; + BasicInfor.open("BasicInfor.txt", ios::app); + if (!BasicInfor.is_open()) + { + cout << "打开文件失败" << endl; + return -1; + } + for(int j=0; j aver_u(Ny,0); + double displathick = 0.,momenthick = 0., energythick = 0.; + fstream BounLayThick; + BounLayThick.open("BounLayThick.txt", ios::app); + for(int j=0; j > disspation(Ny,vector(Nx,0)); + std::vector > presspower(Ny,vector(Nx,0)); + std::vector > kineticpower(Ny,vector(Nx,0)); + std::vector > volumforcepower(Ny,vector(Nx,0)); + double totaldisspation = 0., totalpresspower = 0., totalkineticpower = 0., totalvolumforcepower = 0.; + fstream Power; + Power.open("Power.txt", ios::app); + for(int j=0; j & zones, std::vector > &x, std::vector > &y, std::vector > &p, std::vector > &u, std::vector > &v,std::vector > &W_z) { + int Np = zones[0].data[0].size(); + std::vector N = zones[0].N; + int Nx = N[0]; + int i,j; + int Idx = 0, Idy = 1, Idp = 2, Idu = 3, Idv = 4, Idvor = 5; + for(int n=0; n & zones, std::vector &dx, st return 0; } -double Integration(const std::vector &dx, const std::vector &dy, const std::vector &data) { +double average(const std::vector > &x, const std::vector > &y, const double averangex[], const double averangey[], const double &Nx, const double &Ny, const std::vector > &data) { double sum = 0.; int offset = 0; - for(size_t j=0; j > &y, const std::vector &dy, const double &Ny, const double &u_inf, const std::vector &data, const double &beam_y_end) { + double sum = 0.; + for(int j=0; j > &y, const std::vector &dy, const double &Ny, const double &u_inf, const std::vector &data, const double &beam_y_end) { + double sum = 0.; + for(int j=0; j > &y, const std::vector &dy, const double &Ny, const double &u_inf, const std::vector &data, const double &beam_y_end) { + double sum = 0.; + for(int j=0; j > &x, const std::vector > &y, const std::vector &dx, const std::vector &dy, const double integrangex[], const double integrangey[], const double &Nx, const double &Ny, const std::vector > &data) { + double sum = 0.; + for(int j=0; j > &x, const std::vector > &y, const std::vector &dx, const std::vector &dy, const double integrangex[], const double integrangey[], const double &Nx, const double &Ny, const std::vector > &data) { + double sum = 0.; + for(int j=0; j& files) { + intptr_t hFile = 0; + //file information + struct _finddata_t fileinfo; + string p; + if ((hFile = _findfirst(p.assign(path).append("\\*.plt").c_str(), &fileinfo)) != -1) + { + do + { + if(strcmp(fileinfo.name , "Flow0000.00000.plt" ) !=0 )//search each file except "Flow0000.00000.plt" + { + files.push_back(fileinfo.name); + } + } while (_findnext(hFile, &fileinfo) == 0); + _findclose(hFile); + } +} + int main(int argc, char* argv[]) { string filename("0.plt"); string message; @@ -111,18 +342,46 @@ int main(int argc, char* argv[]) { message = argv[2]; } std::vector variables = {"x", "y", "p", "u", "v", "W_z"}; - std::vector zones(3); - zones[0].N = {985, 1, 4497}; - zones[1].N = {101, 1, 1}; - zones[2].N = {101, 1, 1}; - std::vector> dataBody; + std::vector zones(1); +// zones[0].N = {997, 1, 1997}; +// zones[1].N = {51, 1, 1}; + std::vector > dataBody; std::map vm; - InputTec360_FSILBM2D(filename, zones); - ShiftIndex(zones[0].N, zones[0].data, 1); + vector fileNames; + string path("ptspostprocessing\\build");//choose directory + getFileNames(path, fileNames); + +// Set the far-field velocity and calculation range of boundary layer loss thickness at different times +// If you don't take into account the loss of the boundary layer thickness you can ignore this + double t = -0.78125; +// Y-axis coordinates at the end of beam. Be used to determine the calculation range of boundary layer loss thickness + double beam_y_end[66] ={0.44381, 0.43872, 0.43552, 0.43372, 0.43354, 0.43491, 0.43829, 0.44374, 0.45132, 0.4609, 0.47298, 0.48792, 0.50713, 0.53125, 0.56191, 0.60025, 0.64965, 0.7134, 0.79821, 0.90358, 0.99839, 0.98758, 0.86612, 0.73716, 0.63271, 0.56496, 0.52729, 0.50351, 0.48613, 0.47182, 0.46031, 0.45124, 0.44422, 0.43889, 0.43531, 0.43334, 0.43337, 0.43517, 0.43875, 0.44405, 0.45123, 0.4605, 0.4727, 0.48803, 0.50752, 0.53163, 0.56196, 0.6, 0.6494, 0.71332, 0.79823, 0.90349, 0.99825, 0.98761, 0.86604, 0.73737, 0.63322, 0.56535, 0.52733, 0.50329, 0.48593, 0.47185, 0.4606, 0.45157, 0.44431, 0.4387}; + int BeamInstantY = 0.; - message = processMessage(message); - ProcessWakeData(zones, message); + for (const auto &ph : fileNames) { + filename = ph; + std::cout << filename << endl; + zones[0].N = {997, 1, 1997}; + InputTec360_FSILBM2D(filename, zones); + ShiftIndex(zones[0].N, zones[0].data, 1); + message = processMessage(message); + + // If you don't take into account the loss of the boundary layer thickness you can ignore this + double u_inf = cos(2 * 3.141592653589793 * 0.02 * t); + double volumforce = -0.2513274122871834624 * sin(2 * 3.141592653589793 * 0.02 * t); + // -0.2513274122871834624=-4.908738521234052e-4/0.0019531250, 0.0019531250 is Fref, 0.02 = (1/0.00125)/Tref + if(u_inf == 0) { + u_inf = 0.000001; + } + + ProcessWakeData(zones, message, u_inf, beam_y_end[BeamInstantY], volumforce); + + // If you don't take into account the loss of the boundary layer thickness you can ignore this + BeamInstantY += 1; + t += 0.78125; + + } return 0; } \ No newline at end of file