1、完成基本模型,数据从json中写入配置

feature/struct-menu-20241023
mzh 1 week ago
parent bd9fe0cd1c
commit 656306477c

@ -14,8 +14,6 @@ CFDStructDataManagerBase::~CFDStructDataManagerBase() {
CUIConfig *CFDStructDataManagerBase::getParamUIConfig() { return nullptr; } CUIConfig *CFDStructDataManagerBase::getParamUIConfig() { return nullptr; }
void CFDStructDataManagerBase::saveDataToDom(rapidjson::Document &dom) {}
// 写入json // 写入json
void CFDStructDataManagerBase::jsonAdd(rapidjson::Document &document, void CFDStructDataManagerBase::jsonAdd(rapidjson::Document &document,
QVariant value, QVector<QVariant> path) { QVariant value, QVector<QVariant> path) {

@ -17,7 +17,10 @@ class CFDSTRUCTDATAMANAGER_EXPORT CFDStructDataManagerBase : public QObject {
~CFDStructDataManagerBase(); ~CFDStructDataManagerBase();
// 获取参数界面的配置 // 获取参数界面的配置
virtual CUIConfig *getParamUIConfig(); virtual CUIConfig *getParamUIConfig();
virtual void saveDataToDom(rapidjson::Document &dom); // 将数据存入dom
virtual void saveDataToDom(rapidjson::Document &dom) = 0;
// 将数据从dom中读出
virtual void readDataFromDom(rapidjson::Document &dom) = 0;
signals: signals:
protected: protected:

@ -1,43 +1,54 @@
#include "CFDStructDataSolverBasicModelManager.h" #include "CFDStructDataSolverBasicModelManager.h"
#include "CUIProperty/CUIConfig.h"
#include "CFDStructMain/CFDStructDefine.h" #include "CFDStructMain/CFDStructDefine.h"
#include "CFDStructSigsCenter.h" #include "CFDStructSigsCenter.h"
#include "CUIProperty/CUIConfig.h"
CFDStructDataSolverBasicModelManager::CFDStructDataSolverBasicModelManager(QObject *parent) : CFDStructDataManagerBase(parent) CFDStructDataSolverBasicModelManager::CFDStructDataSolverBasicModelManager(QObject *parent) : CFDStructDataManagerBase(parent) {
{
m_uiConfig = nullptr; m_uiConfig = nullptr;
} }
CFDStructDataSolverBasicModelManager::~CFDStructDataSolverBasicModelManager() CFDStructDataSolverBasicModelManager::~CFDStructDataSolverBasicModelManager() {
{ if (m_uiConfig != nullptr) {
if (m_uiConfig != nullptr)
{
delete m_uiConfig; delete m_uiConfig;
m_uiConfig = nullptr; m_uiConfig = nullptr;
} }
connect(m_cuiSigsCenter, &CUISigsCenter::sig_cuiPropertyChanged, this, [=](int semaphore){ connect(m_cuiSigsCenter, &CUISigsCenter::sig_cuiPropertyChanged, this, [=](int semaphore) {
emit CFDStructSigsCenter::getInstance()->sig_solverTimeModeDataChanged(); emit CFDStructSigsCenter::getInstance() -> sig_solverTimeModeDataChanged();
}); });
} }
CUIConfig *CFDStructDataSolverBasicModelManager::getParamUIConfig() CUIConfig *CFDStructDataSolverBasicModelManager::getParamUIConfig() {
{ if (m_FluidProperties == 0)
if(m_FluidProperties == 0)
return this->genFluidPropertiesOffUIConfig(); return this->genFluidPropertiesOffUIConfig();
if(m_FluidProperties == 1) if (m_FluidProperties == 1)
return this->genFluidPropertiesOnUIConfig(); return this->genFluidPropertiesOnUIConfig();
return this->genFluidPropertiesOnUIConfig(); return this->genFluidPropertiesOnUIConfig();
} }
void CFDStructDataSolverBasicModelManager::saveDataToDom(rapidjson::Document &dom) void CFDStructDataSolverBasicModelManager::saveDataToDom(rapidjson::Document &dom) {
{ jsonAdd(dom, m_FlowModel, {"region", 0, "flowType"});
jsonAdd(dom,m_FlowModel,{"region",0, "flowType",}); jsonAdd(dom, m_OverlayNetwork, {"region", 0, "chimeraMesh"});
jsonAdd(dom,m_OverlayNetwork,{"region",0, "chimeraMesh",}); jsonAdd(dom, m_Rgasmean, {"region", 0, "refValue", "rgas_mean"});
jsonAdd(dom,m_Rgasmean,{"region",0, "refValue", "rgas_mean",}); jsonAdd(dom, m_Gmean, {"region", 0, "refValue", "gamma"});
jsonAdd(dom,m_Gmean,{"region",0, "refValue", "gamma",}); jsonAdd(dom, m_Prlmean, {"region", 0, "solver", "turbModel", "RANS", "params", "Prl"});
jsonAdd(dom,m_Prlmean,{"region",0, "solver", "turbModel", "RANS", "params", "Prl",}); jsonAdd(dom, m_Prtmean, {"region", 0, "solver", "turbModel", "RANS", "params", "Prt"});
jsonAdd(dom,m_Prtmean,{"region",0, "solver", "turbModel", "RANS", "params", "Prt",}); }
void CFDStructDataSolverBasicModelManager::readDataFromDom(rapidjson::Document &dom) {
QVariant temp;
jsonRead(dom, temp, {"region", 0, "flowType"});
m_FlowModel = temp.toInt();
jsonRead(dom, temp, {"region", 0, "chimeraMesh"});
m_OverlayNetwork = temp.toInt();
jsonRead(dom, temp, {"region", 0, "refValue", "rgas_mean"});
m_Rgasmean = temp.toDouble();
jsonRead(dom, temp, {"region", 0, "refValue", "gamma"});
m_Gmean = temp.toDouble();
jsonRead(dom, temp, {"region", 0, "solver", "turbModel", "RANS", "params", "Prl"});
m_Prlmean = temp.toDouble();
jsonRead(dom, temp, {"region", 0, "solver", "turbModel", "RANS", "params", "Prt"});
m_Prtmean = temp.toDouble();
} }
/** /**
@ -45,8 +56,7 @@ void CFDStructDataSolverBasicModelManager::saveDataToDom(rapidjson::Document &do
* *
* @return * @return
*/ */
CUIConfig *CFDStructDataSolverBasicModelManager::genFluidPropertiesOffUIConfig() CUIConfig *CFDStructDataSolverBasicModelManager::genFluidPropertiesOffUIConfig() {
{
return new CUIConfig({ return new CUIConfig({
{"type", "Widget"}, {"type", "Widget"},
}, },
@ -58,13 +68,14 @@ CUIConfig *CFDStructDataSolverBasicModelManager::genFluidPropertiesOffUIConfig()
{new CUIConfig({ {new CUIConfig({
{"type", "Item"}, {"name", tr("Compressible Flow")} // 选项:可压缩流动 {"type", "Item"}, {"name", tr("Compressible Flow")} // 选项:可压缩流动
})}), })}),
new CUIConfig({// 下拉框:流动模型 new CUIConfig({
{"type", "ComboBox"}, // 下拉框:流动模型
{"name", tr("Flow Model")}, {"type", "ComboBox"},
{"value_type",CUI_DATA_TYPE::CUI_DATA_TYPE_INT}, {"name", tr("Flow Model")},
{"value_origin",QVA_GLOBAL(&m_FlowModel)}, {"value_type", CUI_DATA_TYPE::CUI_DATA_TYPE_INT},
{"semaphore",1}, {"value_origin", QVA_GLOBAL(&m_FlowModel)},
}, {"semaphore", 1},
},
{new CUIConfig({// 选项:外流 {new CUIConfig({// 选项:外流
{"type", "Item"}, {"type", "Item"},
{"name", tr("Internal Flow")}}), {"name", tr("Internal Flow")}}),
@ -74,23 +85,24 @@ CUIConfig *CFDStructDataSolverBasicModelManager::genFluidPropertiesOffUIConfig()
new CUIConfig({// 选项:多级叶轮机械 new CUIConfig({// 选项:多级叶轮机械
{"type", "Item"}, {"type", "Item"},
{"name", tr("Multistage Turbomachinery")}})}), {"name", tr("Multistage Turbomachinery")}})}),
new CUIConfig({// 方形勾选:重叠网络 new CUIConfig({
{"type", "CheckBox"}, // 方形勾选:重叠网络
{"name", tr("Overlay Network")}, {"type", "CheckBox"},
{"value_type",CUI_DATA_TYPE::CUI_DATA_TYPE_INT}, {"name", tr("Overlay Network")},
{"value_origin",QVA_GLOBAL(&m_OverlayNetwork)}, {"value_type", CUI_DATA_TYPE::CUI_DATA_TYPE_INT},
{"value_origin", QVA_GLOBAL(&m_OverlayNetwork)},
}), }),
new CUIConfig({// 方形选择按钮:流体属性 new CUIConfig({
{"type", "CheckBox"}, // 方形选择按钮:流体属性
{"name", tr("Fluid Properties")}, {"type", "CheckBox"},
{"value_type",CUI_DATA_TYPE::CUI_DATA_TYPE_INT}, {"name", tr("Fluid Properties")},
{"value_origin",QVA_GLOBAL(&m_FluidProperties)}, {"value_type", CUI_DATA_TYPE::CUI_DATA_TYPE_INT},
{"semaphore",1}, {"value_origin", QVA_GLOBAL(&m_FluidProperties)},
{"semaphore", 1},
})}); })});
} }
CUIConfig *CFDStructDataSolverBasicModelManager::genFluidPropertiesOnUIConfig() CUIConfig *CFDStructDataSolverBasicModelManager::genFluidPropertiesOnUIConfig() {
{
return new CUIConfig({ return new CUIConfig({
{"type", "Widget"}, {"type", "Widget"},
}, },
@ -102,12 +114,13 @@ CUIConfig *CFDStructDataSolverBasicModelManager::genFluidPropertiesOnUIConfig()
{new CUIConfig({ {new CUIConfig({
{"type", "Item"}, {"name", tr("Compressible Flow")} // 选项:可压缩流动 {"type", "Item"}, {"name", tr("Compressible Flow")} // 选项:可压缩流动
})}), })}),
new CUIConfig({// 下拉框:流动模型 new CUIConfig({
{"type", "ComboBox"}, // 下拉框:流动模型
{"name", tr("Flow Model")}, {"type", "ComboBox"},
{"value_type",CUI_DATA_TYPE::CUI_DATA_TYPE_INT}, {"name", tr("Flow Model")},
{"value_origin",QVA_GLOBAL(&m_FlowModel)}, {"value_type", CUI_DATA_TYPE::CUI_DATA_TYPE_INT},
}, {"value_origin", QVA_GLOBAL(&m_FlowModel)},
},
{new CUIConfig({// 选项:外流 {new CUIConfig({// 选项:外流
{"type", "Item"}, {"type", "Item"},
{"name", tr("Internal Flow")}}), {"name", tr("Internal Flow")}}),
@ -117,52 +130,59 @@ CUIConfig *CFDStructDataSolverBasicModelManager::genFluidPropertiesOnUIConfig()
new CUIConfig({// 选项:多级叶轮机械 new CUIConfig({// 选项:多级叶轮机械
{"type", "Item"}, {"type", "Item"},
{"name", tr("Multistage Turbomachinery")}})}), {"name", tr("Multistage Turbomachinery")}})}),
new CUIConfig({// 方形勾选:重叠网络 new CUIConfig({
{"type", "CheckBox"}, // 方形勾选:重叠网络
{"name", tr("Overlay Network")}, {"type", "CheckBox"},
{"value_type",CUI_DATA_TYPE::CUI_DATA_TYPE_INT}, {"name", tr("Overlay Network")},
{"value_origin",QVA_GLOBAL(&m_OverlayNetwork)}, {"value_type", CUI_DATA_TYPE::CUI_DATA_TYPE_INT},
{"value_origin", QVA_GLOBAL(&m_OverlayNetwork)},
}), }),
new CUIConfig({// 圆形选择按钮:流体属性 new CUIConfig({
{"type", "CheckBox"}, // 圆形选择按钮:流体属性
{"name", tr("Fluid Properties")}, {"type", "CheckBox"},
{"value_type",CUI_DATA_TYPE::CUI_DATA_TYPE_INT}, {"name", tr("Fluid Properties")},
{"value_origin",QVA_GLOBAL(&m_FluidProperties)}, {"value_type", CUI_DATA_TYPE::CUI_DATA_TYPE_INT},
{"semaphore",1}, {"value_origin", QVA_GLOBAL(&m_FluidProperties)},
{"semaphore", 1},
}), }),
new CUIConfig({// 组,流体属性下的内容 new CUIConfig({// 组,流体属性下的内容
{"type", "GroupBox"}, {"type", "GroupBox"},
{"name", tr("Fluid Properties")}}, {"name", tr("Fluid Properties")}},
{ {
new CUIConfig({// 气体成分 new CUIConfig({
{"type", "LineEdit"}, // 气体成分
{"name", tr("Gas Composition")}, {"type", "LineEdit"},
{"value_type",CUI_DATA_TYPE::CUI_DATA_TYPE_STRING}, {"name", tr("Gas Composition")},
{"value_origin",QVA_GLOBAL(&m_GasComposition)}, {"value_type", CUI_DATA_TYPE::CUI_DATA_TYPE_STRING},
}), {"value_origin", QVA_GLOBAL(&m_GasComposition)},
new CUIConfig({// 气体常数 }),
{"type", "LineEdit"}, new CUIConfig({
{"name", tr("rgasmean")}, // 气体常数
{"value_type",CUI_DATA_TYPE::CUI_DATA_TYPE_DOUBLE}, {"type", "LineEdit"},
{"value_origin",QVA_GLOBAL(&m_Rgasmean)}, {"name", tr("rgasmean")},
}), {"value_type", CUI_DATA_TYPE::CUI_DATA_TYPE_DOUBLE},
new CUIConfig({// 比热比 {"value_origin", QVA_GLOBAL(&m_Rgasmean)},
{"type", "LineEdit"}, }),
{"name", tr("gmean")}, new CUIConfig({
{"value_type",CUI_DATA_TYPE::CUI_DATA_TYPE_DOUBLE}, // 比热比
{"value_origin",QVA_GLOBAL(&m_Gmean)}, {"type", "LineEdit"},
}), {"name", tr("gmean")},
new CUIConfig({// 层流普朗特数 {"value_type", CUI_DATA_TYPE::CUI_DATA_TYPE_DOUBLE},
{"type", "LineEdit"}, {"value_origin", QVA_GLOBAL(&m_Gmean)},
{"name", tr("prlmean")}, }),
{"value_type",CUI_DATA_TYPE::CUI_DATA_TYPE_DOUBLE}, new CUIConfig({
{"value_origin",QVA_GLOBAL(&m_Prlmean)}, // 层流普朗特数
}), {"type", "LineEdit"},
new CUIConfig({// 湍流普朗特数 {"name", tr("prlmean")},
{"type", "LineEdit"}, {"value_type", CUI_DATA_TYPE::CUI_DATA_TYPE_DOUBLE},
{"name", tr("prtmean")}, {"value_origin", QVA_GLOBAL(&m_Prlmean)},
{"value_type",CUI_DATA_TYPE::CUI_DATA_TYPE_DOUBLE}, }),
{"value_origin",QVA_GLOBAL(&m_Prtmean)}, new CUIConfig({
}), // 湍流普朗特数
{"type", "LineEdit"},
{"name", tr("prtmean")},
{"value_type", CUI_DATA_TYPE::CUI_DATA_TYPE_DOUBLE},
{"value_origin", QVA_GLOBAL(&m_Prtmean)},
}),
})}); })});
} }

@ -19,7 +19,9 @@ public:
CUIConfig* getParamUIConfig(); CUIConfig* getParamUIConfig();
void saveDataToDom(rapidjson::Document &dom); void saveDataToDom(rapidjson::Document &dom);
private: void readDataFromDom(rapidjson::Document &dom);
private:
// 生成流体属性关闭界面配置 // 生成流体属性关闭界面配置
CUIConfig* genFluidPropertiesOffUIConfig(); CUIConfig* genFluidPropertiesOffUIConfig();
// 生成流体属性开启界面配置 // 生成流体属性开启界面配置

Loading…
Cancel
Save