1、完成timemode的json写入

feature/struct-menu-20241023
mzh 1 week ago
parent c55c61c4e0
commit f13f51948e

@ -23,6 +23,7 @@ CFDStructDataManager *CFDStructDataManager::m_instance = NULL;
CFDStructDataManager::CFDStructDataManager() CFDStructDataManager::CFDStructDataManager()
{ {
this->initDataManagers(); this->initDataManagers();
this->initJson();
} }
CFDStructDataManager *CFDStructDataManager::getInstance() CFDStructDataManager *CFDStructDataManager::getInstance()
@ -41,32 +42,46 @@ CUIConfig *CFDStructDataManager::getActionParamUIConfig(SolutionAnalysisModulePr
qDebug() << "manager is null"; qDebug() << "manager is null";
} }
CUIConfig *res = nullptr; CUIConfig *res = nullptr;
switch (sig) switch (sig)
{ {
case SolutionAnalysisModuleProperty::Time_Mode: case SolutionAnalysisModuleProperty::Time_Mode:
res = m_solverTimeModeManager->getParamUIConfig(); res = m_solverTimeModeManager->getParamUIConfig();
break;
case SolutionAnalysisModuleProperty::Basic_Model: case SolutionAnalysisModuleProperty::Basic_Model:
res = m_solverBasicModeManager->getParamUIConfig(); res = m_solverBasicModeManager->getParamUIConfig();
break;
case SolutionAnalysisModuleProperty::Viscosity_Model: case SolutionAnalysisModuleProperty::Viscosity_Model:
res = m_solverKvislManager->getParamUIConfig(); res = m_solverKvislManager->getParamUIConfig();
break;
case SolutionAnalysisModuleProperty::NUumerical_Methods: case SolutionAnalysisModuleProperty::NUumerical_Methods:
res = m_solverNumericalMethodManager->getParamUIConfig(); res = m_solverNumericalMethodManager->getParamUIConfig();
break;
case SolutionAnalysisModuleProperty::Motion_Properties: case SolutionAnalysisModuleProperty::Motion_Properties:
res = m_solverSportsAttributesManager->getParamUIConfig(); res = m_solverSportsAttributesManager->getParamUIConfig();
break;
case SolutionAnalysisModuleProperty::Boundary_Conditions: case SolutionAnalysisModuleProperty::Boundary_Conditions:
res = m_solverBoundaryConditionManager->getParamUIConfig(); res = m_solverBoundaryConditionManager->getParamUIConfig();
break;
case SolutionAnalysisModuleProperty::Initialization: case SolutionAnalysisModuleProperty::Initialization:
res = m_solverInitializationManager->getParamUIConfig(); res = m_solverInitializationManager->getParamUIConfig();
break;
case SolutionAnalysisModuleProperty::Computational_Control_Reference_Quantity: case SolutionAnalysisModuleProperty::Computational_Control_Reference_Quantity:
res = m_solverReferenceQuantityManager->getParamUIConfig(); res = m_solverReferenceQuantityManager->getParamUIConfig();
break;
case SolutionAnalysisModuleProperty::Computational_Control: case SolutionAnalysisModuleProperty::Computational_Control:
res = m_solverComputingControlManager->getParamUIConfig(); res = m_solverComputingControlManager->getParamUIConfig();
break;
case SolutionAnalysisModuleProperty::Monitors_Residual: case SolutionAnalysisModuleProperty::Monitors_Residual:
res = m_solverMonitorResidualManager->getParamUIConfig(); res = m_solverMonitorResidualManager->getParamUIConfig();
break;
case SolutionAnalysisModuleProperty::Monitors_AerodynamicForce: case SolutionAnalysisModuleProperty::Monitors_AerodynamicForce:
res = m_solverMonitorAerodynamicForceManager->getParamUIConfig(); res = m_solverMonitorAerodynamicForceManager->getParamUIConfig();
break;
case SolutionAnalysisModuleProperty::Monitors_Tubomachinery_Performance: case SolutionAnalysisModuleProperty::Monitors_Tubomachinery_Performance:
res = m_solverMonitorTubomachineryPerformanceManager->getParamUIConfig(); res = m_solverMonitorTubomachineryPerformanceManager->getParamUIConfig();
break;
default: default:
break; break;
} }
@ -93,13 +108,11 @@ void CFDStructDataManager::initDataManagers()
void CFDStructDataManager::initJson() void CFDStructDataManager::initJson()
{ {
m_dom.Clear();
m_dom.SetObject(); m_dom.SetObject();
} }
void CFDStructDataManager::updateJson() void CFDStructDataManager::updateJson()
{ {
m_dom.Clear();
m_dom.SetObject(); m_dom.SetObject();
m_solverTimeModeManager->saveDataToDom(m_dom); m_solverTimeModeManager->saveDataToDom(m_dom);

@ -24,7 +24,7 @@ void CFDStructDataManagerBase::saveDataToDom(rapidjson::Document &dom)
} }
// 写入json // 写入json
void jsonAdd(rapidjson::Document &document, QVariant value, QVector<QVariant> path) void CFDStructDataManagerBase::jsonAdd(rapidjson::Document &document, QVariant value, QVector<QVariant> path)
{ {
using namespace rapidjson; using namespace rapidjson;

@ -25,7 +25,8 @@ signals:
protected: protected:
CUIConfig* m_uiConfig = nullptr; CUIConfig* m_uiConfig = nullptr;
CUISigsCenter* m_cuiSigsCenter = nullptr; CUISigsCenter* m_cuiSigsCenter = nullptr;
void jsonAdd(rapidjson::Document& document, QVariant value, QVector<QVariant> path); protected:
virtual void jsonAdd(rapidjson::Document& document, QVariant value, QVector<QVariant> path);
}; };
#endif // CFDSTRUCTDATAMANAGERBASE_H #endif // CFDSTRUCTDATAMANAGERBASE_H

@ -4,10 +4,11 @@
#include "CFDStructSigsCenter.h" #include "CFDStructSigsCenter.h"
#include "CUIProperty/CUISigsCenter.h" #include "CUIProperty/CUISigsCenter.h"
#include <QVariant> #include <QVariant>
#include "CFDStructDataManagerBase.h"
//#include <rapidjson/document.h> #include <rapidjson/document.h>
//#include <rapidjson/writer.h> #include <rapidjson/writer.h>
//#include <rapidjson/stringbuffer.h> #include <rapidjson/stringbuffer.h>
CFDStructDataSolverTimeModeManager::CFDStructDataSolverTimeModeManager(QObject *parent) : CFDStructDataManagerBase(parent) CFDStructDataSolverTimeModeManager::CFDStructDataSolverTimeModeManager(QObject *parent) : CFDStructDataManagerBase(parent)
@ -46,7 +47,13 @@ CUIConfig *CFDStructDataSolverTimeModeManager::getParamUIConfig()
void CFDStructDataSolverTimeModeManager::saveDataToDom(rapidjson::Document &dom) void CFDStructDataSolverTimeModeManager::saveDataToDom(rapidjson::Document &dom)
{ {
jsonAdd(dom,m_runtype,{"region",0,"solver","time"});
jsonAdd(dom,m_innerIters,{"couplingSolver", "unSteady", "innerIters",});
jsonAdd(dom,m_iters,{"couplingSolver", "steady", "iters",});
jsonAdd(dom,m_alf0,{"couplingSolver", "unSteady", "stepType",});
jsonAdd(dom,m_realdt,{"couplingSolver", "unSteady", "timeStep",});
jsonAdd(dom,m_nstep,{"couplingSolver", "unSteady", "timeStepsNumber",});
jsonAdd(dom,m_timeaverage,{"couplingSolver", "unSteady", "Timeverage",});
} }
CUIConfig *CFDStructDataSolverTimeModeManager::genSteadyModeUIConfig() CUIConfig *CFDStructDataSolverTimeModeManager::genSteadyModeUIConfig()
@ -73,7 +80,7 @@ CUIConfig *CFDStructDataSolverTimeModeManager::genSteadyModeUIConfig()
{"type", "LineEdit"}, {"type", "LineEdit"},
{"name", "iteration count"}, {"name", "iteration count"},
{"value_type", CUI_DATA_TYPE_INT}, {"value_type", CUI_DATA_TYPE_INT},
{"value_origin", QVA_GLOBAL(&m_mcyc)}, {"value_origin", QVA_GLOBAL(&m_iters)},
}) })
}); });
} }
@ -120,7 +127,7 @@ CUIConfig *CFDStructDataSolverTimeModeManager::genUnsteadyModeUIConfig()
{"type", "LineEdit"}, {"type", "LineEdit"},
{"name", "mcyc"}, {"name", "mcyc"},
{"value_type", CUI_DATA_TYPE_INT}, {"value_type", CUI_DATA_TYPE_INT},
{"value_origin", QVA_GLOBAL(&m_mcyc)}, {"value_origin", QVA_GLOBAL(&m_iters)},
}), }),
new CUIConfig({ new CUIConfig({
{"type", "CheckBox"}, {"type", "CheckBox"},

@ -25,8 +25,10 @@ signals:
private: private:
// 时间模式定常0非定常1 // 时间模式定常0非定常1
int m_runtype = 0; int m_runtype = 0;
// 时间模式定常0则是迭代步数时间模式非定常1则是内迭代步数 // 内迭代步数
int m_mcyc = 1000; int m_innerIters = 1000;
// 迭代步数
int m_iters = 1000;
// 步长模式 >=1 // 步长模式 >=1
double m_alf0 = 1.0; double m_alf0 = 1.0;
// 时间步长 >0 // 时间步长 >0

@ -11,6 +11,7 @@ INCLUDEPATH += \
../../ \ ../../ \
include(./CFDStructMain.pri) include(./CFDStructMain.pri)
include(./rapidjson.pri)
win32{ win32{

@ -30,6 +30,7 @@
#include <FITK_Kernel/FITKCore/FITKActionOperator.h> #include <FITK_Kernel/FITKCore/FITKActionOperator.h>
#include "CFDStructDataManager/CFDStructSigsCenter.h" #include "CFDStructDataManager/CFDStructSigsCenter.h"
#include "CFDStructDataManager/CFDStructDataManager.h"
namespace GUI namespace GUI
{ {
@ -232,10 +233,21 @@ namespace GUI
return; return;
} }
int objID = item->data(1, 0).toInt(); int objID = item->data(1, 0).toInt();
if(item->data(2,0) == 999){
qDebug()<<"Save is clicked";
CFDStructDataManager::getInstance()->initJson();
CFDStructDataManager::getInstance()->updateJson();
CFDStructDataManager::getInstance()->printJson();
}
SolutionAnalysisTreeEnum treeType = item->data(2, 0).value<SolutionAnalysisTreeEnum>(); SolutionAnalysisTreeEnum treeType = item->data(2, 0).value<SolutionAnalysisTreeEnum>();
Interface::FITKGeoEnum::FITKGeometryComType geometryType = item->data(3, 0).value<Interface::FITKGeoEnum::FITKGeometryComType>(); Interface::FITKGeoEnum::FITKGeometryComType geometryType = item->data(3, 0).value<Interface::FITKGeoEnum::FITKGeometryComType>();
SolutionAnalysisModuleProperty sig = SolutionAnalysisModuleProperty::UNKNOW; SolutionAnalysisModuleProperty sig = SolutionAnalysisModuleProperty::UNKNOW;
switch (treeType) { switch (treeType) {
case SolutionAnalysisTreeEnum::SATree_ComputationalSetupTimeMode: case SolutionAnalysisTreeEnum::SATree_ComputationalSetupTimeMode:
sig = SolutionAnalysisModuleProperty::Time_Mode; sig = SolutionAnalysisModuleProperty::Time_Mode;

@ -0,0 +1,9 @@
win32{
INCLUDEPATH += ../../Tools/rapidjson-1.1.0/include/ \
}
unix{
INCLUDEPATH += ../../Tools/rapidjson-1.1.0/include/ \
}
Loading…
Cancel
Save