Browse Source

opt:修改插值部分

wzj 4 months ago
parent
commit
855f8c140d

+ 1 - 1
CMakeLists.txt.user

@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE QtCreatorProject>
-<!-- Written by QtCreator 12.0.1, 2024-07-08T22:26:35. -->
+<!-- Written by QtCreator 12.0.1, 2024-07-10T18:32:44. -->
 <qtcreator>
  <data>
   <variable>EnvironmentId</variable>

+ 3 - 1
src/CFD/DialogCFDThread.cpp

@@ -60,7 +60,9 @@ namespace CFD
 		connect(ui->startBnt,&QPushButton::clicked,this,[=](){
 
 			QString cmd = "powershell.exe";
-			_process->start(cmd,QStringList()<< "-command" <<" mpiexec.exe -n 4 " << exeDit << " -w " << dir+"/CFD/Output/ " << casfile);
+			QString exe = Setting::BusAPI::instance()->getMsMpiPath()+ "/";
+
+			_process->start(cmd,QStringList()<< "-command" << " "<< exe << "mpiexec.exe -n 4 " << exeDit << " -w " << dir+"/CFD/Output/ " << casfile);
 			if(!_process->waitForStarted())
 				{
 				qDebug()<<"error";

+ 83 - 102
src/IR/IRbodyGridCollation.cpp

@@ -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;
 	}
+
 }

+ 11 - 3
src/IR/IRbodyGridCollation.h

@@ -3,7 +3,8 @@
 
 #include <QDialog>
 #include "IRAPI.h"
-#pragma comment(lib)
+#include "InterpolationTask.h"
+
 namespace Ui {
 	class IRbodyGridCollation;
 }
@@ -16,6 +17,7 @@ namespace ModuleBase
 namespace IR
 {
 	class IRData;
+	class InterpolationBodyTask;
 	class IRAPI IRbodyGridCollation : public QDialog {
 		Q_OBJECT
 
@@ -25,14 +27,20 @@ namespace IR
 
 	private:
 		void accept() override;
+
+	private slots:
+		void doCollation();
+
 	private:
 		Ui::IRbodyGridCollation* ui;
 		IRData* _data;
 		ModuleBase::ProgressWidget *_progressWidget;
+		InterpolationBodyTask* _task;
+		Tecplot::TecplotData _cfdData;
 	};
 
-	void IFIRFlowPointFDLLL(double YEJC1_ToFortran, double YEJC2_ToFortran, double REJC_ToFortran,
-							int MI01_ToFortran, int MJ01_ToFortran, int MK01_ToFortran, const char* OutPutDataFilePath);
+	QVector<QVector<double>> IRAPI IFIRFlowPointFDLLL(double YEJC1_ToFortran, double YEJC2_ToFortran, double REJC_ToFortran,
+							int MI01_ToFortran, int MJ01_ToFortran, int MK01_ToFortran);
 
 }
 

+ 21 - 24
src/IR/IRbodyGridCollation.ui

@@ -13,10 +13,20 @@
   <property name="windowTitle">
    <string>整理红外流体网格</string>
   </property>
-  <layout class="QVBoxLayout" name="progressLayout">
+  <layout class="QVBoxLayout" name="Layout">
    <item>
     <layout class="QGridLayout" name="gridLayout">
-     <item row="2" column="0" colspan="2">
+     <item row="2" column="0">
+      <widget class="QLabel" name="label_4">
+       <property name="text">
+        <string>邻近点个数:</string>
+       </property>
+      </widget>
+     </item>
+     <item row="2" column="1">
+      <widget class="QSpinBox" name="KnnPoint"/>
+     </item>
+     <item row="1" column="0" colspan="2">
       <widget class="QGroupBox" name="groupBox">
        <property name="title">
         <string>选择需要整理的数据</string>
@@ -43,27 +53,7 @@
        </layout>
       </widget>
      </item>
-     <item row="3" column="0">
-      <widget class="QLabel" name="label_4">
-       <property name="text">
-        <string>选择最近几点:</string>
-       </property>
-      </widget>
-     </item>
-     <item row="0" column="1">
-      <widget class="QLineEdit" name="bodySourceGrid"/>
-     </item>
-     <item row="3" column="1">
-      <widget class="QSpinBox" name="KnnPoint"/>
-     </item>
-     <item row="0" column="0">
-      <widget class="QLabel" name="label">
-       <property name="text">
-        <string>CFD源数据体网格:</string>
-       </property>
-      </widget>
-     </item>
-     <item row="1" column="0" colspan="2">
+     <item row="0" column="0" colspan="2">
       <widget class="QGroupBox" name="groupBox_2">
        <property name="title">
         <string>排气系统流场计算域离散参数设置</string>
@@ -193,9 +183,16 @@
      </item>
     </layout>
    </item>
+   <item>
+    <widget class="Line" name="line_2">
+     <property name="orientation">
+      <enum>Qt::Horizontal</enum>
+     </property>
+    </widget>
+   </item>
    <item>
     <widget class="QWidget" name="progressWidget" native="true">
-     <layout class="QVBoxLayout" name="verticalLayout_3">
+     <layout class="QVBoxLayout" name="progressLayout">
       <property name="leftMargin">
        <number>0</number>
       </property>

+ 6 - 4
src/IR/IRcalcDialog.cpp

@@ -4,6 +4,8 @@
 #include <QDebug>
 #include <QFileInfo>
 #include <QDir>
+#include <Settings/BusAPI.h>
+
 namespace IR
 {
 	IRCalcDialog::IRCalcDialog(QWidget *parent) :
@@ -31,7 +33,7 @@ namespace IR
 		//暂停、继续
 		connect(ui->pauseBnt,&QPushButton::clicked,this,[=](){
 			QProcess pauseProcess;
-			QString exe = "D:/project2023/pssuspend.exe";
+			QString exe = "./pssuspend.exe";
 			if(isRun)
 			{
 				ui->pauseBnt->setText("继续");
@@ -59,8 +61,8 @@ namespace IR
 
 	void IRCalcDialog::onStartBntClicked()
 	{
-		QString exe = "D:/project2023/workspace/IR/Optical-RMC-Code.exe";
-		_process->start(exe,QStringList()<< "D:/project2023/workspace/IR/IR_Files_Index.dat");
+		QString exe = "Optical-RMC-Code.exe";
+		_process->start(exe,QStringList()<< "IR_Files_Index.dat");
 		if(!_process->waitForStarted())
 		{
 			qDebug()<<"IR程序启动失败";
@@ -96,7 +98,7 @@ namespace IR
 		ui->startBnt->setDisabled(false);
 		isRun = false;
 
-		QString path = "D:/project2023/workspace/IR/Output";
+		QString path = Setting::BusAPI::instance()->getCurrentFileDir() + "/IR/Output";
 		QDir dir(path);
 		QStringList list = dir.entryList(QDir::Files);
 		foreach (const QString &fileName, list) 

+ 17 - 21
src/IR/IRcomponentDialog.cpp

@@ -70,8 +70,7 @@ namespace IR
 		QVector<IRComponetData> comp = IR::IRData::getInstance()->getComponentData();
 		if(comp.isEmpty())
 		{
-			Tecplot::TecplotData tec_ir = _irData->_irWallFile.data();
-
+			Tecplot::TecplotData tec_ir = _irData->irWallFile.data();
 			if(tec_ir.zone_count() == 0)
 			{
 				return;
@@ -83,29 +82,25 @@ namespace IR
 				comp[i].name = QString::fromStdString(tec_ir.zones()[i]->name());
 				comp[i].node = tec_ir.zones()[i]->nodesCount();
 				comp[i].grid = tec_ir.zones()[i]->elementsCount();
+
 			}
 
-			// IRData::getInstance()->setComponentData(comp);
+			IRData::getInstance()->setComponentData(comp);
 		}
 
-
-		for(int i = 0 ; i < comp.count() ; ++i)
+		ui->componentList->setRowCount(comp.size());
+		for(int i = 0 ; i < comp.size() ; ++i)
 		{
 			ui->componentList->setItem(i,0,new QTableWidgetItem(QString::number(i+1)));
 			ui->componentList->setItem(i,1,new QTableWidgetItem(comp[i].name));
 			ui->componentList->setItem(i,2,new QTableWidgetItem(QString::number(comp[i].node)));
 			ui->componentList->setItem(i,3,new QTableWidgetItem(QString::number(comp[i].grid)));
 			ui->componentList->setItem(i,4,new QTableWidgetItem(comp[i].emissivityName));
-					//单双面
-			QCheckBox *faceCheack = new QCheckBox;
-			QHBoxLayout* emissivityCheckLay = new QHBoxLayout;
-			QWidget* emissivityCheckWidget = new QWidget;
-			emissivityCheckLay->setMargin(0);
-			emissivityCheckLay->addWidget(faceCheack);
-			faceCheack->setChecked(comp[i].face);
-			emissivityCheckLay->setAlignment(faceCheack,Qt::AlignCenter);
-			emissivityCheckWidget->setLayout(emissivityCheckLay);
-			ui->componentList->setCellWidget(i,5,emissivityCheckWidget);
+
+			QTableWidgetItem* checkBoxItem = new QTableWidgetItem;
+			checkBoxItem->setCheckState(comp[i].face?Qt::Checked:Qt::Unchecked);
+			checkBoxItem->setFlags(checkBoxItem->flags() | Qt::ItemIsUserCheckable | Qt::ItemIsEnabled);
+			ui->componentList->setItem(i, 5, checkBoxItem);
 
 			ui->componentList->setItem(i,6,new QTableWidgetItem(comp[i].tempName));
 		}
@@ -163,9 +158,10 @@ namespace IR
 		// zoneMap[5].push_back(13+22);
 		// zoneMap[5].push_back(14+22);
 		// zoneMap[5].push_back(20+22);
+
 		for(int i = 0 ; i < ui->componentList->rowCount() ; ++i)
 		{
-			if(ui->componentList->item(i,6) == nullptr)
+			if(ui->componentList->item(i,6)->text().isEmpty())
 			{
 				QMessageBox::warning(this,"警告","部分温度参数未设置");
 				return;
@@ -173,8 +169,8 @@ namespace IR
 		}
 
 		_task->setWallMap(IR::IRData::getInstance()->_wallMap);
-		Tecplot::TecplotData cfd = _irData->_cfdWallFile.data();
-		Tecplot::TecplotData ir = _irData->_irWallFile.data();
+		Tecplot::TecplotData cfd = _irData->cfdWallFile.data();
+		Tecplot::TecplotData ir = _irData->irWallFile.data();
 		_task->setCfdData(cfd);
 		_task->setIrData(ir);
 		_task->setKnnToSearch(3);
@@ -192,15 +188,15 @@ namespace IR
 
 		for(int i = 0 ; i < rowCount ; ++i)
 		{
-			if(  ui->componentList->item(i,4) == nullptr
-			  || ui->componentList->item(i,6) == nullptr)
+			if(  ui->componentList->item(i,4)->text().isEmpty()
+			   || ui->componentList->item(i,6)->text().isEmpty())
 			{
 				QMessageBox::warning(this,"警告","部分参数未设置");
 				return;
 			}
 
 			comp[i].emissivityName = ui->componentList->item(i,4)->text();
-			comp[i].face = qobject_cast<QCheckBox*>(ui->componentList->cellWidget(i, 5))->isChecked();
+			comp[i].face = ui->componentList->item(i,5)->checkState();
 			comp[i].tempName = ui->componentList->item(i,6)->text();
 			comp[i].emissivity = _emissivity[i];
 

+ 37 - 19
src/IR/IRdataSingleton.cpp

@@ -122,26 +122,43 @@ namespace IR
 			return;
 		}
 		QTextStream out(&file);
-		out << "计算任务 (1-\"喷流+蒙皮\",2-\"蒙皮\",3-\"喷流\")" << "\n"
-			<< _paraData->calcTask << "\n"
-			<< "出口截面坐标(m),飞机重心坐标(m),探测距离(m),高度(m)" << "\n"
-			<< _paraData->exportFacePos << "   " << _paraData->planeGravityPos << "   " << _paraData->detectDistance << "    " << _paraData->height << "\n"
-			<< "流场轴向分段,流场周向分段,流场径向分段,气体类型" << "\n"
-			<< _paraData->flowAxisSegment << "   " << _paraData->flowCircumferenceSegment << "   " << _paraData->flowRadiusSegment << _paraData->gasType << "\n"
-			<< "计算短波 计算中波   计算长波	短波最小	短波最大  中波最小	中波最大	长波最小	长波最大	光谱分辨率" << "\n"
+		QString textInfo =  "计算任务 (1-\"喷流+蒙皮\",2-\"蒙皮\",3-\"喷流\")" ;
+		out << textInfo << "\n"
+			<< _paraData->calcTask << "\n";
+
+		textInfo = "出口截面坐标(m),飞机重心坐标(m),探测距离(m),高度(m)" ;
+		out << textInfo << "\n"
+			<< _paraData->exportFacePos << "   " << _paraData->planeGravityPos << "   " << _paraData->detectDistance << "    " << _paraData->height << "\n";
+
+		textInfo ="流场轴向分段,流场周向分段,流场径向分段,气体类型";
+		out << textInfo << "\n"
+			<< _paraData->flowAxisSegment << "   " << _paraData->flowCircumferenceSegment << "   " << _paraData->flowRadiusSegment << _paraData->gasType << "\n";
+
+		textInfo = "计算短波 计算中波   计算长波	短波最小	短波最大  中波最小	中波最大	长波最小	长波最大	光谱分辨率";
+		out << textInfo << "\n"
 			<< _paraData->calcShortWave << "   " << _paraData->calcMiddleWave << "   " << _paraData->calcLongWave << "   "
 			<< _paraData->shortWaveMin << "   " << _paraData->shortWaveMax << "   "
 			<< _paraData->middleWaveMin << "   "<< _paraData->middleWaveMax << "   "
-			<< _paraData->longWaveMin << "   " << _paraData->longWaveMax << "   " << _paraData->waveStep << "\n"
-			<< "射线步长(m)" << "\n"
-			<< _paraData->rayStep << "\n"
-			<< "热像图分辨率(0-320*240,1-640*480,2-800*600,3-1280*960,4-320*180,5-640*360,6-800*450,7-1280*720),每个像素上的射线数,单个视场角(°)" << "\n"
-			<< _paraData->heatResolution << "   " << _paraData->rayCount << "   " << _paraData->fieldAngle << "\n"
-			<< "是否计算光谱热像	波长间隔,方位角,俯仰角" << "\n"
-			<< _paraData->isLightHeat << "   " << _paraData->waveStep << "   " << _paraData->azimuth << "   " << _paraData->angleOfDip << "\n"
-			<< "探测面总数,每个探测面上探测点总数" << "\n"
-			<< _paraData->detectFaceCount << "   " << _paraData->detectPointCount << "\n"
-			<< "探测面角度,探测点角度,经度,纬度" << "\n";
+			<< _paraData->longWaveMin << "   " << _paraData->longWaveMax << "   " << _paraData->waveStep << "\n";
+
+		textInfo ="射线步长(m)";
+		out << textInfo << "\n"
+			<< _paraData->rayStep << "\n";
+
+		textInfo = "热像图分辨率(0-320*240,1-640*480,2-800*600,3-1280*960,4-320*180,5-640*360,6-800*450,7-1280*720),每个像素上的射线数,单个视场角(°)";
+		out << textInfo << "\n"
+			<< _paraData->heatResolution << "   " << _paraData->rayCount << "   " << _paraData->fieldAngle << "\n";
+
+		textInfo = "是否计算光谱热像	波长间隔,方位角,俯仰角";
+		out << textInfo << "\n"
+			<< _paraData->isLightHeat << "   " << _paraData->waveStep << "   " << _paraData->azimuth << "   " << _paraData->angleOfDip << "\n";
+
+		textInfo = "探测面总数,每个探测面上探测点总数";
+		out << textInfo << "\n"
+			<< _paraData->detectFaceCount << "   " << _paraData->detectPointCount << "\n";
+
+		textInfo = "探测面角度,探测点角度,经度,纬度";
+		out << textInfo << "\n";
 		for(auto it : _paraData->detectInfo)
 		{
 			out << it[0]  << "   " << it[1] << "   " << it[2] << "   " << it[3] << "\n";
@@ -191,10 +208,11 @@ namespace IR
 			return;
 		}
 		QTextStream out(&file);
-		out << "飞机部件编号    部件名称    节点数量    网格数量    发射率    单双面" << "\n";
+		QString titleName = "飞机部件编号    部件名称    节点数量    网格数量    发射率    单双面";
+		out << titleName << "\n" ;
 		for(int i = 0 ; i < _componetData.size() ; i ++ )
 		{
-			out << i << "\t" << _componetData.at(i).name << "\t" << _componetData.at(i).node << "\t"
+			out << i+1 << "\t" << _componetData.at(i).name << "\t" << _componetData.at(i).node << "\t"
 				<< _componetData.at(i).grid << "\t" << _componetData.at(i).emissivity << "\t" << _componetData.at(i).face << "\n";
 		}
 

+ 16 - 18
src/IR/IRdataSingleton.h

@@ -147,19 +147,19 @@ namespace IR
 	struct IRAPI IRComponetData
 	{
 		//部件名称
-		QString name;
+		QString name{};
 		//节点数量
-		int node;
+		int node = 0;
 		//网格数量
-		int grid;
+		int grid = 0;
 		//发射率编号
-		int  emissivity;
+		int  emissivity = 0;
 		//发射率名称 (界面使用)
-		QString emissivityName;
+		QString emissivityName {};
 		//单双面
-		bool face;
+		bool face = false;
 		//插值部件名称 (插值使用)
-		QString tempName;
+		QString tempName {};
 	};
 
 	class IRAPI IRData
@@ -237,20 +237,18 @@ namespace IR
 		//Ir体网格文件
 		QString _irBodyPath{};
 
-		QString _irWallInput{};
-		QString _irBodyInput{};
+		Tecplot::TecplotFile cfdWallFile;
+		Tecplot::TecplotFile cfdBodyFile;
+		Tecplot::TecplotFile irWallFile;
+		Tecplot::TecplotFile irBodyFile;
 
-		Tecplot::TecplotFile _cfdWallFile;
-		Tecplot::TecplotFile _cfdBodyFile;
-		Tecplot::TecplotFile _irWallFile;
-		Tecplot::TecplotFile _irBodyFile;
 
+		Tecplot::TecplotData* cfdWallTecData = nullptr;
+		Tecplot::TecplotData* cfdBodyTecData = nullptr;
+		Tecplot::TecplotData* irWallTecData = nullptr;
+		Tecplot::TecplotData* irBodyTecData = nullptr;
 
-		Tecplot::TecplotData* _cfdWallData = nullptr;
-		Tecplot::TecplotData* _cfdBodyData = nullptr;
-		Tecplot::TecplotData* _irWallData = nullptr;
-		Tecplot::TecplotData* _irBodyData = nullptr;
-
+		QVector<QVector<int>> irBodyPointData;
 
 
 

+ 19 - 6
src/IR/IRimportCfdResult.cpp

@@ -15,6 +15,7 @@ namespace IR
 		, ui(new Ui::IRimportCfdResult)
 	{
 		ui->setupUi(this);
+
 		ui->IRwallLine->setText(IRData::getInstance()->_irWallPath);
 		ui->wallLine->setText(IRData::getInstance()->_cfdWallPath);
 		ui->bodyLine->setText(IRData::getInstance()->_cfdBodyPath);
@@ -107,8 +108,8 @@ namespace IR
 				IRData::getInstance()->_cfdWallPath = ui->wallLine->text();
 			}
 
-			IRData::getInstance()->_cfdWallFile.setFilePath(ui->wallLine->text().toStdString());
-			IRData::getInstance()->_cfdWallFile.open();
+			IRData::getInstance()->cfdWallFile.setFilePath(ui->wallLine->text().toStdString());
+			IRData::getInstance()->cfdWallFile.open();
 
 		}
 
@@ -124,8 +125,10 @@ namespace IR
 				IRData::getInstance()->_cfdBodyPath = ui->bodyLine->text();
 			}
 
-			IRData::getInstance()->_cfdBodyFile.setFilePath(ui->bodyLine->text().toStdString());
-			IRData::getInstance()->_cfdBodyFile.open();
+			IRData::getInstance()->cfdBodyFile.setFilePath(ui->bodyLine->text().toStdString());
+
+			IRData::getInstance()->cfdBodyFile.start();
+
 		}
 
 		if(ui->irGroup->isChecked())
@@ -140,10 +143,20 @@ namespace IR
 				IRData::getInstance()->_irWallPath = ui->IRwallLine->text();
 			}
 
-			IRData::getInstance()->_irWallFile.setFilePath(ui->IRwallLine->text().toStdString());
-			IRData::getInstance()->_irWallFile.open();
+			IRData::getInstance()->irWallFile.setFilePath(ui->IRwallLine->text().toStdString());
+			IRData::getInstance()->irWallFile.start();
 
 		}
+
+		if(ui->irGroup->isChecked())
+			IRData::getInstance()->irWallFile.wait();
+
+		if(ui->bodyGroup->isChecked())
+			IRData::getInstance()->cfdBodyFile.wait();
+
+		if(ui->wallGroup->isChecked())
+			IRData::getInstance()->cfdWallFile.wait();
+
 		emit updateIrGridTree();
 		QDialog::accept();
 	}

+ 3 - 0
src/IR/IRimportCfdResult.h

@@ -8,8 +8,10 @@ namespace Ui {
 	class IRimportCfdResult;
 }
 
+
 namespace IR
 {
+	class IRData;
 	class IRAPI IRimportCfdResult : public QDialog {
 		Q_OBJECT
 
@@ -24,6 +26,7 @@ namespace IR
 
 	private:
 		Ui::IRimportCfdResult* ui;
+
 	};
 }
 

+ 1 - 1
src/IR/IRselectGridTempPart.cpp

@@ -31,7 +31,7 @@ namespace IR
 		});
 
 		IRData * data = IR::IRData::getInstance();
-		Tecplot::strings nameList =  data->_cfdWallFile.data().zone_names();
+		Tecplot::strings nameList =  data->cfdWallFile.data().zone_names();
 		for(auto it : nameList)
 		{
 			ui->tempList->addItem(QString::fromStdString(it));

+ 116 - 13
src/IR/InterpolationTask.cpp

@@ -225,7 +225,6 @@ namespace IR
 
 	QMap<int,QVector<int>> InterpolationWallTask::getWallMap()
 	{
-
 		return _wallMap;
 	}
 
@@ -244,6 +243,7 @@ namespace IR
 		//构建ir数据点云
 		PointCloud<double> irCloud;
 		generatePointCloudFromPoints(irCloud,_irBodyPoint);
+		// Range3d range3d_ir_cloud = generatePointCloudFromTecplotAsciiFile(irCloud,_irData);
 
 		using my_kd_tree_t = nanoflann::KDTreeSingleIndexAdaptor<
 			  nanoflann::L2_Simple_Adaptor<double, PointCloud<double>>,
@@ -253,27 +253,48 @@ namespace IR
 
 		nanoflann::KNNResultSet<double, size_t> resultSet(_nnToSearch);
 		int pointCount = irCloud.kdtree_get_point_count();
-		double querypt[3];
+		_indices.resize(_nnToSearch);
+		_distances.resize(_nnToSearch);
+		float currentPercent = 0;
 		for(int i = 0; i < pointCount ; ++i )
 		{
-			querypt[0] = irCloud.kdtree_get_pt(i,0);
-			querypt[1] = irCloud.kdtree_get_pt(i,1);
-			querypt[2] = irCloud.kdtree_get_pt(i,2);
+			_querypt[0] = irCloud.kdtree_get_pt(i,0);
+			_querypt[1] = irCloud.kdtree_get_pt(i,1);
+			_querypt[2] = irCloud.kdtree_get_pt(i,2);
 
 			resultSet.init(_indices.data(),_distances.data());
-			cfd_kd_tree_index.findNeighbors(resultSet,querypt);
-
-			_result.clear();
-
+			cfd_kd_tree_index.findNeighbors(resultSet,_querypt);
 			interpolatingFunction();
-
+			if((i+1) % 10000 ==0 || i == 0 || i == pointCount-1 )
+			{
+				currentPercent = ((i+1)/(float)pointCount)*100 ;
+				emit threadInfo(currentPercent,"*******[正在插值]*******");
+			}
 		}
 
 	}
 
 	bool InterpolationBodyTask::interpolatingFunction()
 	{
-
+		std::vector<std::vector<double>> xyz = _cfdData.getMix();
+
+		double part1 = 0 , part2 = 0 , neighborValue = 0 ;
+		int neighborPointIndex;
+		int varSize = _varIndex.size();
+		int pointIndexSize = _indices.size();
+		QVector<double> result;
+		for(int i = 0; i < varSize ; ++i)
+		{
+			for(int j = 0; j < pointIndexSize; ++j)
+			{
+				neighborPointIndex = _indices[j];
+				neighborValue = xyz[_varIndex[i]][neighborPointIndex];
+				part1 += (1/(_distances[j] * _distances[j]))*neighborValue;
+				part2 += 1/(_distances[j] * _distances[j]);
+			}
+			result.push_back(part1/part2);
+		}
+		_interpolationResult.push_back(result);
 
 		return true;
 	}
@@ -281,16 +302,86 @@ namespace IR
 	bool InterpolationBodyTask::writeInterpolationFile()
 	{
 
+		if(_interpolationResult.empty())
+			return false;
+
+		int varsSize = _interpolationResult[0].size();
+		_outputPath = Setting::BusAPI::instance()->getCurrentFileDir() + "/IR/Input/IR_gas_file.dat";
+
+		QFile file(_outputPath);
+		if(!file.open(QIODevice::WriteOnly | QIODevice::Text))
+		{
+			return false;
+		}
+		QTextStream out_file(&file);
+
+		Tecplot::TecplotZones zones = _cfdData.zones();
+		Tecplot::strings nodes = _cfdData.getNotes();
+		Tecplot::strings varList = _cfdData.varList();
+
+
+		out_file << "TITLE =  \"" << QString::fromStdString(_cfdData.title()) << "\"\n";
+		out_file << "VARIABLES = \"X\"\n" << "\"Y\"\n" <<  "\"Z\"\n" ;
+
+
+		for(int i = 0; i < _varIndex.size() ; i++)
+		{
+			out_file << "\""<< QString::fromStdString(varList[_varIndex[i]]) << "\"\n";
+		}
+
+		for(auto i : nodes)
+		{
+			out_file << " " << QString::fromStdString(i) << "\n";
+		}
+
+		int count = 0;
+
+		out_file << "ZONE T=\"IR_Flow_Mesh.DAT:1\"\n";
+		out_file << " STRANDID=0, SOLUTIONTIME=0 \n";
+
+		out_file << " I=" << _I << ", J=" << _J << ", k= " << _K << ", ZONETYPE=Ordered\n";
+
+		out_file << " DATAPACKING=POINT \n";
+
+		out_file << " DT =(";
+		for (size_t i = 0; i < (3 + _varIndex.size()) ; i++)
+		{
+			out_file << "SINGLE ";
+		}
+		out_file << ")\n";
+
+		for(int j = 0 ; j  < _irBodyPoint.size() ; j++)
+		{
+			out_file.setRealNumberPrecision(10);
+			out_file.setFieldAlignment(QTextStream::AlignLeft);
+			out_file.setRealNumberNotation(QTextStream::ScientificNotation);
+			out_file << " "
+					 << _irBodyPoint[j][0]
+					 << " " << _irBodyPoint[j][1]
+					 << " " << _irBodyPoint[j][2]
+					 << " " ;
+
+			for(int k = 0 ; k < varsSize ; k++)
+			{
+				out_file << _interpolationResult[count][0];
+			}
+
+			count ++;
+			out_file << "\n";
+		}
+
+		file.close();
 		return true;
 	}
 
 	void InterpolationBodyTask::run()
 	{
+		emit threadInfo(0,"开始壁面插值任务");
 		interpolation();
 
+		emit threadInfo(0,"正在写出文件");
 		writeInterpolationFile();
-
-		emit threadInfo(100,"done");
+		emit threadInfo(100,"完成");
 	}
 
 	void InterpolationBodyTask::setVarIndex(QVector<int> varIndex)
@@ -308,5 +399,17 @@ namespace IR
 		_irBodyPoint = data;
 	}
 
+	void InterpolationBodyTask::setIrBodyFile(Tecplot::TecplotData &irData)
+	{
+		_irData = irData;
+	}
+
+	void InterpolationBodyTask::setIJK(int i, int j , int k)
+	{
+		_I = i;
+		_J = j;
+		_K = k;
+	}
+
 }
 

+ 30 - 17
src/IR/InterpolationTask.h

@@ -45,21 +45,6 @@ namespace IR
 		double max_range_x, max_range_y, max_range_z;
 	};
 
-	template <typename T>
-	void generatePointCloudFromPoints(
-		PointCloud<T>& pc, QVector<QVector<T>> &points)
-	{
-		int pointCount = points.count();
-		pc.pts.resize(pointCount);
-
-		for(int i = 0 ; i < pointCount ; ++i)
-		{
-			pc.pts[i].x = points.at(i)[0];
-			pc.pts[i].y = points.at(i)[1];
-			pc.pts[i].z = points.at(i)[2];
-		}
-	}
-
 
 	template <typename T>
 	Range3d generatePointCloudFromTecplotAsciiFile(
@@ -88,6 +73,26 @@ namespace IR
 		return Range3d{max_range_x, max_range_y, max_range_z};
 	}
 
+
+	template <typename T>
+	void generatePointCloudFromPoints(
+		PointCloud<T>& pc, QVector<QVector<double>> & tf)
+	{
+		int pointCount = tf.size();
+		pc.pts.resize(pointCount);
+
+		double x = 0 ,y = 0 ,z = 0;
+		for(int i = 0; i < pointCount; i++)
+		{
+			x = tf[i][0];
+			y = tf[i][1];
+			z = tf[i][2];
+			pc.pts[i].x = x;
+			pc.pts[i].y = y;
+			pc.pts[i].z = z;
+		}
+	}
+
 	//for part to create point cloud
 	template <typename T>
 	Range3d generatePointCloudForParts(
@@ -213,16 +218,24 @@ namespace IR
 		QVector<int> getVarIndex();
 		//设置红外体网格点云数据
 		void setIrBodyPoint(QVector<QVector<double>> &data);
-
+		//设置IJK
+		void setIJK(int i, int j , int k);
+		//
+		void setIrBodyFile(Tecplot::TecplotData &irData);
 	private:
 		//需要输出的变量列表
 		QVector<int> _varIndex;
 		//红外圆柱体网格生成的点集合
 		QVector<QVector<double>> _irBodyPoint;
+		Tecplot::TecplotData _irData;
 
+		double _querypt[3];
 		QVector<size_t> _indices;
 		QVector<double> _distances;
-		QVector<double> _result;
+
+		int _I;
+		int _J;
+		int _K;
 		QVector<QVector<double>> _interpolationResult;
 	};
 

+ 2 - 2
src/IR/TecplotParser.cpp

@@ -4,6 +4,7 @@
 #include <fstream>
 #include <iostream>
 #include "TecplotZone.h"
+#include <QDebug>
 
 namespace Tecplot
 {
@@ -182,9 +183,9 @@ namespace Tecplot
 				else
 				{
 					TecplotNodes nodes;
+
 					while(std::getline(file, line) && line.find("ZONE T=") == std::string::npos)
 					{
-
 						std::vector<double> data;
 						strings s ;
 						split(line,s);
@@ -197,7 +198,6 @@ namespace Tecplot
 					}
 					zone->setNodes(nodes);
 				}
-
 				zones.push_back(zone);
 			}
 

+ 2 - 2
src/IR/TecplotZone.h

@@ -84,9 +84,9 @@ namespace Tecplot
 		size_t solutionTime_;
 
 		//节点数量 非ORDERED
-		size_t nodesCount_;
+		size_t nodesCount_ = 0;
 		//单元数量 非ORDERED
-		size_t elementsCount_;
+		size_t elementsCount_ = 0;
 		//面 仅用于基于面的有限元区域类型: polyganal / polyhedral
 		size_t facesCount_;
 		//总faces节点数

+ 3 - 2
src/MainWidgets/TreeWidget.cpp

@@ -485,8 +485,9 @@ namespace MainWidget
 			{
 				// _cfdItem->takeChild(1);
 				CFD::CFDSingleton::getInstance()->setMode(true);
-				IR::IRimportCfdResult dlg ;
-				dlg.show();
+				IR::IRimportCfdResult* dlg = new  IR::IRimportCfdResult;
+				connect(dlg,&IR::IRimportCfdResult::updateIrGridTree,this,&TreeWidget::updateIrTree);
+				dlg->exec();
 				break;
 			}
 			case CFDcalcChoose:

+ 4 - 4
src/MainWindow/dialogProjectMananger.cpp

@@ -45,10 +45,10 @@ namespace GUI
 		setVerificationfont(_isVerification);
 
 		//初始化参数界面
-		QString mpich2Path = Setting::BusAPI::instance()->getMpiCH2Path();
-		QString msMpiPath = Setting::BusAPI::instance()->getMsMpiPath();
-		ui->mpich2Line->setText(mpich2Path);
-		ui->msmpiLine->setText(msMpiPath);
+		// QString mpich2Path = Setting::BusAPI::instance()->getMpiCH2Path();
+		// QString msMpiPath = Setting::BusAPI::instance()->getMsMpiPath();
+		// ui->mpich2Line->setText(mpich2Path);
+		// ui->msmpiLine->setText(msMpiPath);
 
 	}