diff --git a/CFDStruct/CFDStructDataManager/CFDStructDataSolverNumericalMethodManager.cpp b/CFDStruct/CFDStructDataManager/CFDStructDataSolverNumericalMethodManager.cpp index 3b9794f..d2786f7 100644 --- a/CFDStruct/CFDStructDataManager/CFDStructDataSolverNumericalMethodManager.cpp +++ b/CFDStruct/CFDStructDataManager/CFDStructDataSolverNumericalMethodManager.cpp @@ -35,8 +35,16 @@ void CFDStructDataSolverNumericalMethodManager::saveDataToDom(rapidjson::Documen {"region", 0, "numericMethod", "numMethodParm", "limiter"}); jsonAdd(dom, m_timeFormat, {"region", 0, "numericMethod", "numMethodParm", "timeType"}); - jsonAdd(dom, m_iterationMethod, - {"region", 0, "numericMethod", "numMethodParm", "iterType"}); + // 此变量在ui中对应下拉框,但仅有一个选项,并且json值不为0,所以该变量不需要读取 + // jsonAdd(dom, m_iterationMethod, + // {"region", 0, "numericMethod", "numMethodParm", "iterType"}); + if (m_timeFormat == 0) { + jsonAdd(dom, 2, + {"region", 0, "numericMethod", "numMethodParm", "iterType"}); + } else if (m_timeFormat == 1) { + jsonAdd(dom, 1, + {"region", 0, "numericMethod", "numMethodParm", "iterType"}); + } jsonAdd(dom, m_relaxationFactor, {"region", 0, "numericMethod", "numMethodParm", "lussor"}); jsonAdd(dom, m_multigridLevels, @@ -51,10 +59,78 @@ void CFDStructDataSolverNumericalMethodManager::saveDataToDom(rapidjson::Documen {"region", 0, "numericMethod", "numMethodParm", "cfl"}); jsonAdd(dom, m_EntropyCorrectionType, {"region", 0, "numericMethod", "numMethodParm", "EntropyFixVal"}); +} - // TODO 时间格式,会随定常和非定常变化 - // TODO 迭代方法,会随定常和非定常变化 - // TODO 熵修正类型,未确定 +void CFDStructDataSolverNumericalMethodManager::readDataFromDom(rapidjson::Document &dom) { + QVariant temp; + jsonRead(dom, temp, + {"region", 0, "numericMethod", "numMethodParm", "generalFmt"}); + if (temp != QVariant()) { + m_fluxFormat = temp.toInt(); + } + jsonRead(dom, temp, + {"region", 0, "numericMethod", "numMethodParm", "twojamson"}); + if (temp != QVariant()) { + m_secondOrderArtificialViscosity = temp.toDouble(); + } + jsonRead(dom, temp, + {"region", 0, "numericMethod", "numMethodParm", "fourjamson"}); + if (temp != QVariant()) { + m_fourthOrderArtificialViscosity = temp.toDouble(); + } + jsonRead(dom, temp, + {"region", 0, "numericMethod", "numMethodParm", "accuracy"}); + if (temp != QVariant()) { + m_spaceAccuracy = temp.toInt(); + } + jsonRead(dom, temp, + {"region", 0, "numericMethod", "numMethodParm", "limiter"}); + if (temp != QVariant()) { + m_limiter = temp.toInt(); + } + jsonRead(dom, temp, + {"region", 0, "numericMethod", "numMethodParm", "timeType"}); + if (temp != QVariant()) { + m_timeFormat = temp.toInt(); + } + // 此变量在ui中对应下拉框,但仅有一个选项,并且json值不为0,所以该变量不需要读取 + // jsonRead(dom, m_iterationMethod, + // {"region", 0, "numericMethod", "numMethodParm", "iterType"}); + jsonRead(dom, temp, + {"region", 0, "numericMethod", "numMethodParm", "lussor"}); + if (temp != QVariant()) { + m_relaxationFactor = temp.toDouble(); + } + jsonRead(dom, temp, + {"region", 0, "numericMethod", "numMethodParm", "gridLevelNum"}); + if (temp != QVariant()) { + m_multigridLevels = temp.toInt(); + } + jsonRead(dom, temp, + {"region", 0, "numericMethod", "numMethodParm", "cycleType"}); + if (temp != QVariant()) { + m_cycleType = temp.toInt(); + } + jsonRead(dom, temp, + {"region", 0, "numericMethod", "numMethodParm", "coarseGridNum"}); + if (temp != QVariant()) { + m_coarseGridCFL = temp.toDouble(); + } + jsonRead(dom, temp, + {"region", 0, "numericMethod", "numMethodParm", "fineGridNum"}); + if (temp != QVariant()) { + m_fineGridCFL = temp.toDouble(); + } + jsonRead(dom, temp, + {"region", 0, "numericMethod", "numMethodParm", "cfl"}); + if (temp != QVariant()) { + m_turbulentCFL = temp.toDouble(); + } + jsonRead(dom, temp, + {"region", 0, "numericMethod", "numMethodParm", "EntropyFixVal"}); + if (temp != QVariant()) { + m_EntropyCorrectionType = temp.toInt(); + } } CUIConfig *CFDStructDataSolverNumericalMethodManager::genJamesonModeUIConfig() { diff --git a/CFDStruct/CFDStructDataManager/CFDStructDataSolverNumericalMethodManager.h b/CFDStruct/CFDStructDataManager/CFDStructDataSolverNumericalMethodManager.h index 37fc8c0..547b92c 100644 --- a/CFDStruct/CFDStructDataManager/CFDStructDataSolverNumericalMethodManager.h +++ b/CFDStruct/CFDStructDataManager/CFDStructDataSolverNumericalMethodManager.h @@ -4,33 +4,33 @@ #ifndef CFDSTRUCTDATASOLVERNUMERICALMETHODEMANAGER_H #define CFDSTRUCTDATASOLVERNUMERICALMETHODEMANAGER_H -#include #include "CFDStructDataManager_global.h" +#include class CUIConfig; -class CFDSTRUCTDATAMANAGER_EXPORT CFDStructDataSolverNumericalMethodManager : public CFDStructDataManagerBase -{ +class CFDSTRUCTDATAMANAGER_EXPORT CFDStructDataSolverNumericalMethodManager : public CFDStructDataManagerBase { Q_OBJECT -public: + public: explicit CFDStructDataSolverNumericalMethodManager(QObject *parent = nullptr); ~CFDStructDataSolverNumericalMethodManager(); - CUIConfig* getParamUIConfig(); + CUIConfig *getParamUIConfig(); void saveDataToDom(rapidjson::Document &dom); -private: + void readDataFromDom(rapidjson::Document &dom); + + private: // 生成Jameson的界面配置 - CUIConfig* genJamesonModeUIConfig(); + CUIConfig *genJamesonModeUIConfig(); // 生成Roe界面配置 - CUIConfig* genRoeModeUIConfig(); + CUIConfig *genRoeModeUIConfig(); // 生成AUSMDY界面配置 - CUIConfig* genAUSMDYModeUIConfig(); + CUIConfig *genAUSMDYModeUIConfig(); // 生成AUSMPWP界面配置 - CUIConfig* genAUSMPWPModeUIConfig(); -signals: - -private: + CUIConfig *genAUSMPWPModeUIConfig(); + signals: + private: // 通量格式 /** * @brief m_fluxFormat @@ -69,16 +69,34 @@ private: // 时间格式 /** - * @brief m_timeFormat - * 0-隐式 - * 1-隐式二阶差分 - */ + * @brief m_timeFormat + * 0-隐式 + * 1-隐式二阶差分 + * + * ---------------上面是原来的--------------------- + * ---------------下面是新的--------------------- + * 在时间格式是*定常*的时候 + * 0-隐式 + * 1-显式 + * + * 在时间格式是*非定常*的时候 + * 0-隐式二阶差分 + */ int m_timeFormat = 0; // 迭代方法 /** * @brief m_iterationMethod * 0-LUSGS + * + * ---------old---------- + * ---------new----------- + * 选择为隐式或隐式二阶差分的时候, + * 仅有一个选项,LUSGS,在json中对应值为2 + * + * 选择显式的时候 + * 仅有一个选项,五级龙格库塔,在json中对应值为1 + * */ int m_iterationMethod = 0; @@ -105,7 +123,7 @@ private: // 湍流CFL数 double m_turbulentCFL = 1.0; - //熵修正类型 + // 熵修正类型 /** * @brief m_EntropyCorrectionType * 0-Harten-Hyman @@ -114,9 +132,8 @@ private: */ int m_EntropyCorrectionType; - //收敛稳定化 + // 收敛稳定化 int m_ConvergenceStabilization = 0; - }; #endif // CFDSTRUCTDATASOLVERNUMERICALMETHODMANAGER_H