1、完成文件write和read

2、完成json写入文件
3、修改v循环和w循环写入逻辑
feature/struct-menu-20241023
mzh 1 week ago
parent 011318054a
commit 0d8f1d50cd

@ -103,9 +103,7 @@ void CFDStructDataManager::initJson() {
}
void CFDStructDataManager::updateJson() {
qDebug() << "-----------";
m_dom.SetObject();
qDebug() << "++++++++++";
m_solverTimeModeManager->saveDataToDom(m_dom);
m_solverBasicModeManager->saveDataToDom(m_dom);
@ -131,9 +129,5 @@ void CFDStructDataManager::printJson() {
Writer<StringBuffer> writer(buffer);
m_dom.Accept(writer);
// freopen(caseJSONPath.c_str(), "w", stdout);
// std::cout << buffer.GetString() << std::endl;
// fclose(stdout);
CFDStructMainUtils::write(caseJSONPath, buffer.GetString());
}

@ -20,19 +20,18 @@ class CFDStructDataSolverMonitorAerodynamicManager;
class CFDStructDataSolverMonitorImpellerManager;
class CUIConfig;
class CFDSTRUCTDATAMANAGER_EXPORT CFDStructDataManager
{
public:
class CFDSTRUCTDATAMANAGER_EXPORT CFDStructDataManager {
public:
CFDStructDataManager();
static CFDStructDataManager *getInstance();
// 获取一个action的参数设置配置
CUIConfig *getActionParamUIConfig(SolutionAnalysisModuleProperty sig, QVariant idx);
private:
private:
void initDataManagers();
private:
private:
static CFDStructDataManager *m_instance;
CFDStructDataSolverTimeModeManager *m_solverTimeModeManager;
@ -57,13 +56,13 @@ private:
// 监控-叶轮机械性能曲线
CFDStructDataSolverMonitorImpellerManager *m_solverMonitorTubomachineryPerformanceManager;
public:
public:
void initJson();
void updateJson();
rapidjson::Document getJson();
void printJson();
private:
private:
rapidjson::Document m_dom;
};

@ -49,8 +49,15 @@ void CFDStructDataSolverNumericalMethodManager::saveDataToDom(rapidjson::Documen
{"region", 0, "numericMethod", "numMethodParm", "lussor"});
jsonAdd(dom, m_multigridLevels,
{"region", 0, "numericMethod", "numMethodParm", "gridLevelNum"});
jsonAdd(dom, m_cycleType,
{"region", 0, "numericMethod", "numMethodParm", "cycleType"});
// 循环类型如果是v循环的话写入1如果是w循环的话写入2
if (m_cycleType == 0) {
jsonAdd(dom, 1,
{"region", 0, "numericMethod", "numMethodParm", "cycleType"});
} else if (m_cycleType == 1) {
jsonAdd(dom, 2,
{"region", 0, "numericMethod", "numMethodParm", "cycleType"});
}
jsonAdd(dom, m_coarseGridCFL,
{"region", 0, "numericMethod", "numMethodParm", "coarseGridNum"});
jsonAdd(dom, m_fineGridCFL,

@ -1,20 +1,42 @@
#include "CFDStructMainUtils.h"
#include <direct.h>
#include <fstream>
#include <iostream>
#include <stdlib.h>
#include <string>
void CFDStructMainUtils::write(std::string path, std::string text) {
std::cout << "start write" << endl;
using namespace std;
char drive[_MAX_PATH], dir[_MAX_PATH], filename[_MAX_PATH], ext[_MAX_PATH];
_splitpath(path.c_str(), drive, dir, filename, ext);
_mkdir(dir);
freopen(path.c_str(), "w", stdout);
cout << text << endl;
fclose(stdout);
// if (FILE *file = fopen(path.c_str(), "w")) {
// fprintf(file, "%s", text.c_str());
// fclose(file);
// }
ofstream outfile(path);
outfile << text << endl;
outfile.close();
}
void CFDStructMainUtils::read(std::string path, std::string &text) {
std::string CFDStructMainUtils::read(std::string path) {
using namespace std;
string res;
ifstream infile(path);
if (infile.is_open()) {
cout << "openfile" << endl;
char c;
while (infile >> c)
res += c;
infile.close();
} else {
cout << "cant openfile" << endl;
}
return res;
}

@ -9,7 +9,8 @@ class CFDStructMAINAPI CFDStructMainUtils {
public:
static void write(std::string path, std::string text);
static void read(std::string path, std::string &text);
public:
static std::string read(std::string path);
};
#endif

@ -25,7 +25,9 @@ CFDStructOperatorsModelSolverProperty::CFDStructOperatorsModelSolverProperty(QOb
connect(btn, &QPushButton::clicked, this, [=]() {
qDebug() << "Save button has clicked";
CFDStructDataManager::getInstance()->updateJson();
qDebug() << "finish updateJson";
CFDStructDataManager::getInstance()->printJson();
qDebug() << "finish printJson";
});
connect(sigsCenter, &CFDStructSigsCenter::sig_solverModuleProperty, this, [=](SolutionAnalysisModuleProperty sig, QVariant idx) {

Loading…
Cancel
Save