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; }
void CFDStructDataManagerBase::saveDataToDom(rapidjson::Document &dom) {}
// 写入json
void CFDStructDataManagerBase::jsonAdd(rapidjson::Document &document,
QVariant value, QVector<QVariant> path) {

@ -17,7 +17,10 @@ class CFDSTRUCTDATAMANAGER_EXPORT CFDStructDataManagerBase : public QObject {
~CFDStructDataManagerBase();
// 获取参数界面的配置
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:
protected:

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

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

Loading…
Cancel
Save