|
@@ -3,10 +3,10 @@
|
|
|
#include <windows.h>
|
|
|
#include <QDebug>
|
|
|
#include "IRdataSingleton.h"
|
|
|
-#include <iostream>
|
|
|
-#include <fstream>
|
|
|
#include <cmath>
|
|
|
#include "ModuleBase/ProgressWidget.h"
|
|
|
+#include "InterpolationTask.h"
|
|
|
+#define M_PI 3.1415926
|
|
|
|
|
|
namespace IR
|
|
|
{
|
|
@@ -18,15 +18,29 @@ namespace IR
|
|
|
{
|
|
|
ui->setupUi(this);
|
|
|
_data = IRData::getInstance();
|
|
|
- ui->bodySourceGrid->setText(_data->_cfdBodyPath);
|
|
|
+ _cfdData = _data->cfdBodyFile.data();
|
|
|
+
|
|
|
+ //初始化进度组件
|
|
|
_progressWidget = new ModuleBase::ProgressWidget;
|
|
|
ui->progressLayout->addWidget(_progressWidget);
|
|
|
+ //初始化插值类
|
|
|
+ _task = new InterpolationBodyTask;
|
|
|
+ connect(_task,&InterpolationBodyTask::threadInfo,_progressWidget,&ModuleBase::ProgressWidget::setInfo);
|
|
|
+ connect(ui->collateBnt,&QPushButton::clicked,this,&IRbodyGridCollation::doCollation);
|
|
|
+
|
|
|
+ //初始化变量选择
|
|
|
+ std::vector<std::string> varList = _data->cfdBodyFile.data().varList();
|
|
|
|
|
|
- std::vector<std::string> varList = _data->_cfdBodyFile.data().varList();
|
|
|
- for(auto it : varList)
|
|
|
+ for(int i = 3; i < varList.size() ; i++)
|
|
|
{
|
|
|
- ui->varList ->addItem(QString::fromStdString(it));
|
|
|
+ ui->varList->addItem(QString::fromStdString(varList.at(i)));
|
|
|
}
|
|
|
+ ui->varList->setSelectionMode(QAbstractItemView::MultiSelection);
|
|
|
+ connect(ui->varList,&QListWidget::itemChanged,this,[=](QListWidgetItem *item){
|
|
|
+ item->setSelected(!item->isSelected());
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
|
|
|
IRbodyGridCollation::~IRbodyGridCollation()
|
|
@@ -40,85 +54,83 @@ namespace IR
|
|
|
para->flowAxisSegment = ui->I->value();
|
|
|
para->flowCircumferenceSegment = ui->J->value();
|
|
|
para->flowRadiusSegment = ui->K->value();
|
|
|
+ IRData::getInstance()->setIRComputationPara(para);
|
|
|
|
|
|
|
|
|
- IRData::getInstance()->setIRComputationPara(para);
|
|
|
QDialog::accept();
|
|
|
}
|
|
|
|
|
|
- void IFIRFlowPointFDLLL(double YEJC1_ToFortran, double YEJC2_ToFortran, double REJC_ToFortran,
|
|
|
- int MI01_ToFortran, int MJ01_ToFortran, int MK01_ToFortran, const char* OutPutDataFilePath)
|
|
|
+ void IRbodyGridCollation::doCollation()
|
|
|
{
|
|
|
- // 流场节点的生成
|
|
|
+ QVector<int> vars;
|
|
|
+ for(int i = 0; i < ui->varList->count(); ++i)
|
|
|
+ {
|
|
|
+ if(ui->varList->item(i)->isSelected())
|
|
|
+ {
|
|
|
+ vars.push_back(i+3);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ _task->setVarIndex(vars);
|
|
|
+ _task->setIJK(ui->I->value(),ui->J->value(),ui->K->value());
|
|
|
+ _task->setKnnToSearch(3);
|
|
|
+ Tecplot::TecplotData cfd = _data->cfdBodyFile.data();
|
|
|
+ double YEJC1 = ui->startPos->value();
|
|
|
+ double YEJC2 = ui->endPos->value();
|
|
|
+ double REJC = ui->radius->value();
|
|
|
+ int I = ui->I->value();
|
|
|
+ int J = ui->J->value();
|
|
|
+ int K = ui->K->value();
|
|
|
+ QVector<QVector<double>> irPoint = IFIRFlowPointFDLLL(YEJC1,YEJC2,REJC,I,J,K);
|
|
|
+ _task->setCfdData(cfd);
|
|
|
+ _task->setIrBodyPoint(irPoint);
|
|
|
+
|
|
|
+ _task->start();
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ QVector<QVector<double>> IFIRFlowPointFDLLL(double YEJC1_ToFortran, double YEJC2_ToFortran, double REJC_ToFortran,
|
|
|
+ int MI01_ToFortran, int MJ01_ToFortran, int MK01_ToFortran) {
|
|
|
+ // Calculate grid spacing
|
|
|
double y_start = YEJC1_ToFortran;
|
|
|
double y_end = YEJC2_ToFortran;
|
|
|
double radius = REJC_ToFortran;
|
|
|
+ int sym_param = 1; // assume symmetry parameter is 1
|
|
|
|
|
|
- int mi01 = MI01_ToFortran;
|
|
|
- int mj01 = MJ01_ToFortran;
|
|
|
- int mk01 = MK01_ToFortran;
|
|
|
- int sym_param = 1; // assume sym_param is 1, adjust as needed
|
|
|
-
|
|
|
- double pi = 3.1415926;
|
|
|
double length = y_end - y_start;
|
|
|
- double dl = length / (mi01 - 1);
|
|
|
- double dr = radius / (mk01 - 1);
|
|
|
- double dj = 2.0 * pi / sym_param / (mj01 - 1);
|
|
|
-
|
|
|
- // allocate memory for xf, yf, zf
|
|
|
- double*** xf = new double**[mi01];
|
|
|
- double*** yf = new double**[mi01];
|
|
|
- double*** zf = new double**[mi01];
|
|
|
- for (int i = 0; i < mi01; i++) {
|
|
|
- xf[i] = new double*[mj01];
|
|
|
- yf[i] = new double*[mj01];
|
|
|
- zf[i] = new double*[mj01];
|
|
|
- for (int j = 0; j < mj01; j++) {
|
|
|
- xf[i][j] = new double[mk01];
|
|
|
- yf[i][j] = new double[mk01];
|
|
|
- zf[i][j] = new double[mk01];
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // calculate xf, yf, zf
|
|
|
- for (int k = 0; k < mk01; k++) {
|
|
|
- for (int j = 0; j < mj01; j++) {
|
|
|
- for (int i = 0; i < mi01; i++) {
|
|
|
- yf[i][j][k] = y_start + dl * (i - 1);
|
|
|
+ double dl = length / (MI01_ToFortran - 1);
|
|
|
+ double dr = radius / (MK01_ToFortran - 1);
|
|
|
+ double dj = 2.0 * M_PI / sym_param / (MJ01_ToFortran - 1);
|
|
|
+
|
|
|
+ // Allocate memory for 3D arrays
|
|
|
+ vector<vector<vector<double>>> xf(MI01_ToFortran, vector<vector<double>>(MJ01_ToFortran, vector<double>(MK01_ToFortran)));
|
|
|
+ vector<vector<vector<double>>> yf(MI01_ToFortran, vector<vector<double>>(MJ01_ToFortran, vector<double>(MK01_ToFortran)));
|
|
|
+ vector<vector<vector<double>>> zf(MI01_ToFortran, vector<vector<double>>(MJ01_ToFortran, vector<double>(MK01_ToFortran)));
|
|
|
+
|
|
|
+ // Calculate grid points
|
|
|
+ for (int k = 0; k < MK01_ToFortran; k++) {
|
|
|
+ for (int j = 0; j < MJ01_ToFortran; j++) {
|
|
|
+ for (int i = 0; i < MI01_ToFortran; i++) {
|
|
|
+ yf[i][j][k] = y_start + dl * i;
|
|
|
xf[i][j][k] = dr * sin((j - 1) * dj) * (k - 1);
|
|
|
zf[i][j][k] = dr * cos((j - 1) * dj) * (k - 1);
|
|
|
|
|
|
- // sym_param == 1 case
|
|
|
+ // Apply symmetry conditions
|
|
|
if (sym_param == 1) {
|
|
|
- if (j == 1) {
|
|
|
+ if (j == 0) {
|
|
|
xf[i][j][k] = 1E-4;
|
|
|
zf[i][j][k] = dr * (k - 1);
|
|
|
- }
|
|
|
- if (j == mj01) {
|
|
|
+ } else if (j == MJ01_ToFortran - 1) {
|
|
|
xf[i][j][k] = 0.0;
|
|
|
zf[i][j][k] = dr * (k - 1);
|
|
|
}
|
|
|
- }
|
|
|
-
|
|
|
- // sym_param >= 2 case
|
|
|
- if (sym_param >= 2) {
|
|
|
- if (j == 1 && k > 1) {
|
|
|
+ } else if (sym_param >= 2) {
|
|
|
+ if (j == 0 && k > 0) {
|
|
|
xf[i][j][k] = dr * sin((j - 1 + 0.1) * dj) * (k - 1);
|
|
|
zf[i][j][k] = dr * cos((j - 1 + 0.1) * dj) * (k - 1);
|
|
|
- }
|
|
|
- if (j == mj01 && k > 1) {
|
|
|
+ } else if (j == MJ01_ToFortran - 1 && k > 0) {
|
|
|
xf[i][j][k] = dr * sin((j - 1 - 0.1) * dj) * (k - 1);
|
|
|
zf[i][j][k] = dr * cos((j - 1 - 0.1) * dj) * (k - 1);
|
|
|
- }
|
|
|
- if (j == 1 && k == 1) {
|
|
|
- xf[i][j][k] = dr * sin((j - 1 + 0.1) * dj) * (k - 1 + 0.1);
|
|
|
- zf[i][j][k] = dr * cos((j - 1 + 0.1) * dj) * (k - 1 + 0.1);
|
|
|
- }
|
|
|
- if (j == mj01 && k == 1) {
|
|
|
- xf[i][j][k] = dr * sin((j - 1 - 0.1) * dj) * (k - 1 + 0.1);
|
|
|
- zf[i][j][k] = dr * cos((j - 1 - 0.1) * dj) * (k - 1 + 0.1);
|
|
|
- }
|
|
|
- if (j > 1 && j < mj01 && k == 1) {
|
|
|
+ } else if (j > 0 && j < MJ01_ToFortran - 1 && k == 0) {
|
|
|
xf[i][j][k] = dr * sin((j - 1) * dj) * (k - 1 + 0.1);
|
|
|
zf[i][j][k] = dr * cos((j - 1) * dj) * (k - 1 + 0.1);
|
|
|
}
|
|
@@ -127,49 +139,18 @@ namespace IR
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- // write to file
|
|
|
- std::ofstream file(OutPutDataFilePath);
|
|
|
- file << "1\n";
|
|
|
- file << mi01 << " " << mj01 << " " << mk01 << "\n";
|
|
|
- for (int k = 0; k < mk01; k++) {
|
|
|
- for (int j = 0; j < mj01; j++) {
|
|
|
- for (int i = 0; i < mi01; i++) {
|
|
|
- file << xf[i][j][k] << " ";
|
|
|
- }
|
|
|
- file << "\n";
|
|
|
- }
|
|
|
- }
|
|
|
- for (int k = 0; k < mk01; k++) {
|
|
|
- for (int j = 0; j < mj01; j++) {
|
|
|
- for (int i = 0; i < mi01; i++) {
|
|
|
- file << yf[i][j][k] << " ";
|
|
|
- }
|
|
|
- file << "\n";
|
|
|
- }
|
|
|
- }
|
|
|
- for (int k = 0; k < mk01; k++) {
|
|
|
- for (int j = 0; j < mj01; j++) {
|
|
|
- for (int i = 0; i < mi01; i++) {
|
|
|
- file << zf[i][j][k] << " ";
|
|
|
+ // Store XYZ in QVector<QVector<double>>
|
|
|
+ QVector<QVector<double>> xyz;
|
|
|
+ for (int k = 0; k < MK01_ToFortran; k++) {
|
|
|
+ for (int j = 0; j < MJ01_ToFortran; j++) {
|
|
|
+ QVector<double> row;
|
|
|
+ for (int i = 0; i < MI01_ToFortran; i++) {
|
|
|
+ row << xf[i][j][k] << yf[i][j][k] << zf[i][j][k];
|
|
|
}
|
|
|
- file << "\n";
|
|
|
- }
|
|
|
- }
|
|
|
- file.close();
|
|
|
-
|
|
|
- // deallocate memory
|
|
|
- for (int i = 0; i < mi01; i++) {
|
|
|
- for (int j = 0; j < mj01; j++) {
|
|
|
- delete[] xf[i][j];
|
|
|
- delete[] yf[i][j];
|
|
|
- delete[] zf[i][j];
|
|
|
+ xyz << row;
|
|
|
}
|
|
|
- delete[] xf[i];
|
|
|
- delete[] yf[i];
|
|
|
- delete[] zf[i];
|
|
|
}
|
|
|
- delete[] xf;
|
|
|
- delete[] yf;
|
|
|
- delete[] zf;
|
|
|
+ return xyz;
|
|
|
}
|
|
|
+
|
|
|
}
|