From f13f51948e47b140c47692c2041c764d202012db Mon Sep 17 00:00:00 2001 From: mzh Date: Wed, 6 Nov 2024 16:26:01 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E5=AE=8C=E6=88=90timemode=E7=9A=84js?= =?UTF-8?q?on=E5=86=99=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CFDStructDataManager.cpp | 17 +++++++++++++++-- .../CFDStructDataManagerBase.cpp | 2 +- .../CFDStructDataManagerBase.h | 3 ++- .../CFDStructDataSolverTimeModeManager.cpp | 19 +++++++++++++------ .../CFDStructDataSolverTimeModeManager.h | 6 ++++-- CFDStruct/CFDStructMain/CFDStructMain.pro | 1 + CFDStruct/CFDStructMain/CFDTreeWidget.cpp | 12 ++++++++++++ CFDStruct/CFDStructMain/rapidjson.pri | 9 +++++++++ 8 files changed, 57 insertions(+), 12 deletions(-) create mode 100644 CFDStruct/CFDStructMain/rapidjson.pri diff --git a/CFDStruct/CFDStructDataManager/CFDStructDataManager.cpp b/CFDStruct/CFDStructDataManager/CFDStructDataManager.cpp index cd260b4..551e058 100644 --- a/CFDStruct/CFDStructDataManager/CFDStructDataManager.cpp +++ b/CFDStruct/CFDStructDataManager/CFDStructDataManager.cpp @@ -23,6 +23,7 @@ CFDStructDataManager *CFDStructDataManager::m_instance = NULL; CFDStructDataManager::CFDStructDataManager() { this->initDataManagers(); + this->initJson(); } CFDStructDataManager *CFDStructDataManager::getInstance() @@ -41,32 +42,46 @@ CUIConfig *CFDStructDataManager::getActionParamUIConfig(SolutionAnalysisModulePr qDebug() << "manager is null"; } CUIConfig *res = nullptr; + + switch (sig) { case SolutionAnalysisModuleProperty::Time_Mode: res = m_solverTimeModeManager->getParamUIConfig(); + break; case SolutionAnalysisModuleProperty::Basic_Model: res = m_solverBasicModeManager->getParamUIConfig(); + break; case SolutionAnalysisModuleProperty::Viscosity_Model: res = m_solverKvislManager->getParamUIConfig(); + break; case SolutionAnalysisModuleProperty::NUumerical_Methods: res = m_solverNumericalMethodManager->getParamUIConfig(); + break; case SolutionAnalysisModuleProperty::Motion_Properties: res = m_solverSportsAttributesManager->getParamUIConfig(); + break; case SolutionAnalysisModuleProperty::Boundary_Conditions: res = m_solverBoundaryConditionManager->getParamUIConfig(); + break; case SolutionAnalysisModuleProperty::Initialization: res = m_solverInitializationManager->getParamUIConfig(); + break; case SolutionAnalysisModuleProperty::Computational_Control_Reference_Quantity: res = m_solverReferenceQuantityManager->getParamUIConfig(); + break; case SolutionAnalysisModuleProperty::Computational_Control: res = m_solverComputingControlManager->getParamUIConfig(); + break; case SolutionAnalysisModuleProperty::Monitors_Residual: res = m_solverMonitorResidualManager->getParamUIConfig(); + break; case SolutionAnalysisModuleProperty::Monitors_AerodynamicForce: res = m_solverMonitorAerodynamicForceManager->getParamUIConfig(); + break; case SolutionAnalysisModuleProperty::Monitors_Tubomachinery_Performance: res = m_solverMonitorTubomachineryPerformanceManager->getParamUIConfig(); + break; default: break; } @@ -93,13 +108,11 @@ void CFDStructDataManager::initDataManagers() void CFDStructDataManager::initJson() { - m_dom.Clear(); m_dom.SetObject(); } void CFDStructDataManager::updateJson() { - m_dom.Clear(); m_dom.SetObject(); m_solverTimeModeManager->saveDataToDom(m_dom); diff --git a/CFDStruct/CFDStructDataManager/CFDStructDataManagerBase.cpp b/CFDStruct/CFDStructDataManager/CFDStructDataManagerBase.cpp index f52144c..3faf3f0 100644 --- a/CFDStruct/CFDStructDataManager/CFDStructDataManagerBase.cpp +++ b/CFDStruct/CFDStructDataManager/CFDStructDataManagerBase.cpp @@ -24,7 +24,7 @@ void CFDStructDataManagerBase::saveDataToDom(rapidjson::Document &dom) } // 写入json -void jsonAdd(rapidjson::Document &document, QVariant value, QVector path) +void CFDStructDataManagerBase::jsonAdd(rapidjson::Document &document, QVariant value, QVector path) { using namespace rapidjson; diff --git a/CFDStruct/CFDStructDataManager/CFDStructDataManagerBase.h b/CFDStruct/CFDStructDataManager/CFDStructDataManagerBase.h index 48ff94f..5a9cbea 100644 --- a/CFDStruct/CFDStructDataManager/CFDStructDataManagerBase.h +++ b/CFDStruct/CFDStructDataManager/CFDStructDataManagerBase.h @@ -25,7 +25,8 @@ signals: protected: CUIConfig* m_uiConfig = nullptr; CUISigsCenter* m_cuiSigsCenter = nullptr; - void jsonAdd(rapidjson::Document& document, QVariant value, QVector path); +protected: + virtual void jsonAdd(rapidjson::Document& document, QVariant value, QVector path); }; #endif // CFDSTRUCTDATAMANAGERBASE_H diff --git a/CFDStruct/CFDStructDataManager/CFDStructDataSolverTimeModeManager.cpp b/CFDStruct/CFDStructDataManager/CFDStructDataSolverTimeModeManager.cpp index 80f4331..ad5d7dd 100644 --- a/CFDStruct/CFDStructDataManager/CFDStructDataSolverTimeModeManager.cpp +++ b/CFDStruct/CFDStructDataManager/CFDStructDataSolverTimeModeManager.cpp @@ -4,10 +4,11 @@ #include "CFDStructSigsCenter.h" #include "CUIProperty/CUISigsCenter.h" #include +#include "CFDStructDataManagerBase.h" -//#include -//#include -//#include +#include +#include +#include CFDStructDataSolverTimeModeManager::CFDStructDataSolverTimeModeManager(QObject *parent) : CFDStructDataManagerBase(parent) @@ -46,7 +47,13 @@ CUIConfig *CFDStructDataSolverTimeModeManager::getParamUIConfig() 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() @@ -73,7 +80,7 @@ CUIConfig *CFDStructDataSolverTimeModeManager::genSteadyModeUIConfig() {"type", "LineEdit"}, {"name", "iteration count"}, {"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"}, {"name", "mcyc"}, {"value_type", CUI_DATA_TYPE_INT}, - {"value_origin", QVA_GLOBAL(&m_mcyc)}, + {"value_origin", QVA_GLOBAL(&m_iters)}, }), new CUIConfig({ {"type", "CheckBox"}, diff --git a/CFDStruct/CFDStructDataManager/CFDStructDataSolverTimeModeManager.h b/CFDStruct/CFDStructDataManager/CFDStructDataSolverTimeModeManager.h index d97792a..5baaed8 100644 --- a/CFDStruct/CFDStructDataManager/CFDStructDataSolverTimeModeManager.h +++ b/CFDStruct/CFDStructDataManager/CFDStructDataSolverTimeModeManager.h @@ -25,8 +25,10 @@ signals: private: // 时间模式:定常0,非定常1 int m_runtype = 0; - // 时间模式:定常0,则是迭代步数;时间模式:非定常1,则是内迭代步数 - int m_mcyc = 1000; + // 内迭代步数 + int m_innerIters = 1000; + // 迭代步数 + int m_iters = 1000; // 步长模式 >=1 double m_alf0 = 1.0; // 时间步长 >0 diff --git a/CFDStruct/CFDStructMain/CFDStructMain.pro b/CFDStruct/CFDStructMain/CFDStructMain.pro index de8e6ef..3bd15be 100644 --- a/CFDStruct/CFDStructMain/CFDStructMain.pro +++ b/CFDStruct/CFDStructMain/CFDStructMain.pro @@ -11,6 +11,7 @@ INCLUDEPATH += \ ../../ \ include(./CFDStructMain.pri) +include(./rapidjson.pri) win32{ diff --git a/CFDStruct/CFDStructMain/CFDTreeWidget.cpp b/CFDStruct/CFDStructMain/CFDTreeWidget.cpp index 9988e42..1699a79 100644 --- a/CFDStruct/CFDStructMain/CFDTreeWidget.cpp +++ b/CFDStruct/CFDStructMain/CFDTreeWidget.cpp @@ -30,6 +30,7 @@ #include #include "CFDStructDataManager/CFDStructSigsCenter.h" +#include "CFDStructDataManager/CFDStructDataManager.h" namespace GUI { @@ -232,10 +233,21 @@ namespace GUI return; } 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(); Interface::FITKGeoEnum::FITKGeometryComType geometryType = item->data(3, 0).value(); SolutionAnalysisModuleProperty sig = SolutionAnalysisModuleProperty::UNKNOW; + + switch (treeType) { case SolutionAnalysisTreeEnum::SATree_ComputationalSetupTimeMode: sig = SolutionAnalysisModuleProperty::Time_Mode; diff --git a/CFDStruct/CFDStructMain/rapidjson.pri b/CFDStruct/CFDStructMain/rapidjson.pri new file mode 100644 index 0000000..3ada785 --- /dev/null +++ b/CFDStruct/CFDStructMain/rapidjson.pri @@ -0,0 +1,9 @@ +win32{ + INCLUDEPATH += ../../Tools/rapidjson-1.1.0/include/ \ +} + + +unix{ + INCLUDEPATH += ../../Tools/rapidjson-1.1.0/include/ \ + +}