//cip 2016-7-24 h14chang@gmail.com
//X,Y点
//保存数据结果到文件 (x,y) x∈【0,1】y[x]
void CFDtest::save2file(QVector<double> y)
{
int n = (int)(1.0/step1+0.5);//分段数
if (QMessageBox::question(NULL,QStringLiteral("保存结果"), QStringLiteral("是否保存?"), QMessageBox::Save, QMessageBox::Ignore) == QMessageBox::Save)
{
QString saveName;
//获取文件保存名和路径
saveName = QFileDialog::getSaveFileName(this, QStringLiteral("保存计算结果到tecplot文件"),saveName,tr("*.dat"));
if (saveName.size() == 0)
{
QMessageBox::information(NULL, QStringLiteral("保存出现错误"),QStringLiteral("文件名为空,无法保存"));
}
else
{
place(".dat","");
QString fileName = saveName + ".dat";
QFile file(fileName);
file.open(QIODevice::WriteOnly);
file.close();
if (!file.open((QIODevice::WriteOnly) | QIODevice::Text))
{
QMessageBox::warning(this,"error","can't open",QMessageBox::Yes);
}
QTextStream dat(&file);//写入文件数值解
dat<<"VARIABLES=\"X\",\"Y\""<<"\n";
dat<<"ZONE T=\""<<uiboBox_method->currentIndex()<<"_"<<uiboBox_step->currentText()<<"\" I="<<QString("%1, F=POINT").arg(n+1)<<"\n";//t
ecplot文件头
for (int i=0;i<n+1;i++)
{
dat<<step1*i<<" "<<y[i]<<"\n";
}
dat<<"\n";
//QTextStream dat(&file);//写入文件解析解
dat<<"VARIABLES=\"X\",\"Y\""<<"\n";
dat<<"ZONE T=\""<<uiboBox_method->currentIndex()<<"_"<<uiboBox_step->currentText()<<"_as\" I="<<QString("%1, F=POINT").arg(n+1)<<"\n";
for (int i=0;i<n+1;i++)
{
dat<<step1*i<<" "<<-0.25*sin(2.0*step1*i)+step1*i<<"\n";
}
file.close();
}
}
}
//X Y Psi
//保存二维区域结果到文件(x,y,psi)x∈【0,1】y∈【0,1】 psi[x,y]
void CFDtest::save2file2(Matrix psi)
{
int n = (int)(1.0/step2+0.5);//分段数
if (QMessageBox::question(NULL,QStringLiteral("保存结果"), QStringLiteral("是否保存?"), QMessageBox::Save, QMessageBox::Ignore) == QMessageBox::Save)
{
QString saveName;
saveName = QFileDialog::getSaveFileName(this, QStringLiteral("保存计算结果到tecplot文件"),saveName,tr("*.dat"));
if (saveName.size() == 0)
{
QMessageBox::information(NULL, QStringLiteral("保存出现错误"),QStringLiteral("文件名为空,无法保存"));
}
else
{
place(".dat","");
QString fileName = saveName + ".dat";
QFile file(fileName);
file.open(QIODevice::WriteOnly);
file.close();
if (!file.open((QIODevice::WriteOnly) | QIODevice::Text))
{
QMessageBox::warning(this,"error","can't open",QMessageBox::Yes);
}
QTextStream dat(&file);//写入文件数值解
dat<<"VARIABLES=\"X\",\"Y\",\"Psi\""<<"\n";
dat<<"ZONE T=\""<<uiboBox_solution->currentIndex()<<"_"<<uiboBox_step2->currentText()<<"\" I="<<QString("%1").arg(n+1)<<" J="<<QString("%1, F=POINT").arg(n+1)<<"\n";//tecplot文件头
for (int i=0;i<n+1;i++)
{
getsavefilename for (int j=0;j<n+1;j++)
{
dat<<step2*i<<" "<<step2*j<<" "<<psi[i][j]<<"\n";
}
}
dat<<"\n";
//QTextStream dat(&file);//写入解析解
dat<<"VARIABLES=\"X\",\"Y\",\"Psi\""<<"\n";
dat<<"ZONE T=\""<<uiboBox_solution->currentIndex()<<"_"<<uiboBox_step2->currentText()<<"_as \" I="<<QString("%1").arg(n+1)<<" J="<<QString("%1, F=POINT").arg(n+1)<<"\n";
for (int i=0;i<n+1;i++)
{
for (int j=0;j<n+1;j++)
{
dat<<step2*i<<" "<<step2*j<<" "<<step2*step2*i*j-sin(step2*i)*cos(step2*j)*0.5<<"\n";
}
}
file.close();
}
}
}
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论