From ca6d4eb85eac09796316681355ee28fa730ff9ca Mon Sep 17 00:00:00 2001 From: mzh Date: Thu, 7 Nov 2024 11:54:39 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E5=9C=A8=E5=B1=9E=E6=80=A7=E9=9D=A2?= =?UTF-8?q?=E6=9D=BF=E4=B8=8B=E6=B7=BB=E5=8A=A0Save=E6=8C=89=E9=92=AE?= =?UTF-8?q?=EF=BC=8C=E5=B9=B6=E8=BF=9E=E6=8E=A5=E4=BF=9D=E5=AD=98json?= =?UTF-8?q?=E5=87=BD=E6=95=B0=EF=BC=88=E7=9B=AE=E5=89=8D=E6=9C=89bug?= =?UTF-8?q?=EF=BC=8C=E9=9C=80=E8=A6=81=E7=82=B9=E5=87=BB=E4=B8=A4=E4=B8=8B?= =?UTF-8?q?=E6=89=8D=E8=83=BD=E4=BF=9D=E5=AD=98json=EF=BC=9B=E7=AC=AC?= =?UTF-8?q?=E4=B8=80=E6=AC=A1=E7=82=B9=E5=87=BB=E8=83=BD=E5=A4=9F=E6=A3=80?= =?UTF-8?q?=E6=B5=8B=EF=BC=8C=E4=BD=86=E6=98=AF=E6=B2=A1=E8=83=BD=E8=A7=A6?= =?UTF-8?q?=E5=8F=91=E4=BF=9D=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CFDStructDataManager.cpp | 68 ++++++++----------- .../CFDStructOperatorsModelSolverProperty.cpp | 59 +++++++++------- Resources/case-01.json | 18 ++++- 3 files changed, 79 insertions(+), 66 deletions(-) diff --git a/CFDStruct/CFDStructDataManager/CFDStructDataManager.cpp b/CFDStruct/CFDStructDataManager/CFDStructDataManager.cpp index 568e6aa..eeee5d4 100644 --- a/CFDStruct/CFDStructDataManager/CFDStructDataManager.cpp +++ b/CFDStruct/CFDStructDataManager/CFDStructDataManager.cpp @@ -1,97 +1,89 @@ #include "CFDStructDataManager.h" -#include "CFDStructDataSolverTimeModeManager.h" #include "CFDStructDataSolverBasicModelManager.h" #include "CFDStructDataSolverKvislManager.h" #include "CFDStructDataSolverNumericalMethodManager.h" +#include "CFDStructDataSolverTimeModeManager.h" -#include "CFDStructDataSolverSportsAttributesManager.h" #include "CFDStructDataSolverBoundaryConditionManager.h" -#include "CFDStructDataSolverInitializationManager.h" -#include "CFDStructDataSolverReferenceQuantityManager.h" #include "CFDStructDataSolverComputingControlManager.h" -#include "CFDStructDataSolverMonitorResidualManager.h" +#include "CFDStructDataSolverInitializationManager.h" #include "CFDStructDataSolverMonitorAerodynamicManager.h" #include "CFDStructDataSolverMonitorImpellerManager.h" +#include "CFDStructDataSolverMonitorResidualManager.h" +#include "CFDStructDataSolverReferenceQuantityManager.h" +#include "CFDStructDataSolverSportsAttributesManager.h" #include "CUIProperty/CUIConfig.h" -#include #include +#include CFDStructDataManager *CFDStructDataManager::m_instance = NULL; -CFDStructDataManager::CFDStructDataManager() -{ +CFDStructDataManager::CFDStructDataManager() { this->initDataManagers(); this->initJson(); } -CFDStructDataManager *CFDStructDataManager::getInstance() -{ - if (m_instance == nullptr) - { +CFDStructDataManager *CFDStructDataManager::getInstance() { + if (m_instance == nullptr) { m_instance = new CFDStructDataManager; } return m_instance; } -CUIConfig *CFDStructDataManager::getActionParamUIConfig(SolutionAnalysisModuleProperty sig, QVariant idx) -{ - if (m_solverBoundaryConditionManager == nullptr) - { +CUIConfig *CFDStructDataManager::getActionParamUIConfig(SolutionAnalysisModuleProperty sig, QVariant idx) { + if (m_solverBoundaryConditionManager == nullptr) { qDebug() << "manager is null"; } CUIConfig *res = nullptr; - - switch (sig) - { + switch (sig) { case SolutionAnalysisModuleProperty::Time_Mode: res = m_solverTimeModeManager->getParamUIConfig(); break; case SolutionAnalysisModuleProperty::Basic_Model: res = m_solverBasicModeManager->getParamUIConfig(); - break; + break; case SolutionAnalysisModuleProperty::Viscosity_Model: res = m_solverKvislManager->getParamUIConfig(); - break; + break; case SolutionAnalysisModuleProperty::NUumerical_Methods: res = m_solverNumericalMethodManager->getParamUIConfig(); - break; + break; case SolutionAnalysisModuleProperty::Motion_Properties: res = m_solverSportsAttributesManager->getParamUIConfig(); - break; + break; case SolutionAnalysisModuleProperty::Boundary_Conditions: res = m_solverBoundaryConditionManager->getParamUIConfig(); - break; + break; case SolutionAnalysisModuleProperty::Initialization: res = m_solverInitializationManager->getParamUIConfig(); - break; + break; case SolutionAnalysisModuleProperty::Computational_Control_Reference_Quantity: res = m_solverReferenceQuantityManager->getParamUIConfig(); - break; + break; case SolutionAnalysisModuleProperty::Computational_Control: res = m_solverComputingControlManager->getParamUIConfig(); - break; + break; case SolutionAnalysisModuleProperty::Monitors_Residual: res = m_solverMonitorResidualManager->getParamUIConfig(); - break; + break; case SolutionAnalysisModuleProperty::Monitors_AerodynamicForce: res = m_solverMonitorAerodynamicForceManager->getParamUIConfig(); - break; + break; case SolutionAnalysisModuleProperty::Monitors_Tubomachinery_Performance: res = m_solverMonitorTubomachineryPerformanceManager->getParamUIConfig(); - break; + break; default: break; } - if(res == nullptr) + if (res == nullptr) qDebug() << "DataManager return null CUIConfig"; return res; } -void CFDStructDataManager::initDataManagers() -{ +void CFDStructDataManager::initDataManagers() { m_solverTimeModeManager = new CFDStructDataSolverTimeModeManager; m_solverBasicModeManager = new CFDStructDataSolverBasicModelManager; m_solverKvislManager = new CFDStructDataSolverKvislManager; @@ -106,13 +98,11 @@ void CFDStructDataManager::initDataManagers() m_solverMonitorTubomachineryPerformanceManager = new CFDStructDataSolverMonitorImpellerManager; } -void CFDStructDataManager::initJson() -{ +void CFDStructDataManager::initJson() { m_dom.SetObject(); } -void CFDStructDataManager::updateJson() -{ +void CFDStructDataManager::updateJson() { m_dom.SetObject(); m_solverTimeModeManager->saveDataToDom(m_dom); @@ -129,10 +119,8 @@ void CFDStructDataManager::updateJson() m_solverMonitorTubomachineryPerformanceManager->saveDataToDom(m_dom); } - #include -void CFDStructDataManager::printJson() -{ +void CFDStructDataManager::printJson() { using namespace rapidjson; StringBuffer buffer; diff --git a/CFDStruct/CFDStructOperatorsModel/CFDStructOperatorsModelSolverProperty.cpp b/CFDStruct/CFDStructOperatorsModel/CFDStructOperatorsModelSolverProperty.cpp index b4d5bef..383bba4 100644 --- a/CFDStruct/CFDStructOperatorsModel/CFDStructOperatorsModelSolverProperty.cpp +++ b/CFDStruct/CFDStructOperatorsModel/CFDStructOperatorsModelSolverProperty.cpp @@ -1,58 +1,71 @@ #include "CFDStructOperatorsModelSolverProperty.h" -#include "CFDStructOperatorsModelSolverProperty.h" #include "GUIFrame/MainWindow.h" #include "GUIFrame/PropertyWidget.h" -#include "FITK_Kernel/FITKAppFramework/FITKAppFramework.h" -#include "FITK_Kernel/FITKAppFramework/FITKGlobalData.h" #include "CFDStruct/CUIProperty/CUIPropertyWidget.h" -#include "CUIProperty/CUIConfig.h" #include "CFDStructDataManager/CFDStructDataManager.h" #include "CFDStructDataManager/CFDStructSigsCenter.h" +#include "CUIProperty/CUIConfig.h" +#include "FITK_Kernel/FITKAppFramework/FITKAppFramework.h" +#include "FITK_Kernel/FITKAppFramework/FITKGlobalData.h" -#include #include +#include +#include +#include -CFDStructOperatorsModelSolverProperty* CFDStructOperatorsModelSolverProperty::m_instance = nullptr; -CFDStructOperatorsModelSolverProperty::CFDStructOperatorsModelSolverProperty(QObject *parent) : QObject(parent) -{ - CFDStructSigsCenter* sigsCenter = CFDStructSigsCenter::getInstance(); - connect(sigsCenter, &CFDStructSigsCenter::sig_solverModuleProperty, this, [ = ](SolutionAnalysisModuleProperty sig, QVariant idx) { +CFDStructOperatorsModelSolverProperty *CFDStructOperatorsModelSolverProperty::m_instance = nullptr; +CFDStructOperatorsModelSolverProperty::CFDStructOperatorsModelSolverProperty(QObject *parent) : QObject(parent) { + CFDStructSigsCenter *sigsCenter = CFDStructSigsCenter::getInstance(); + + // 定义保存按钮 + QPushButton *btn = new QPushButton("Save"); + // 连接保存的信号 + connect(btn, &QPushButton::clicked, this, [=]() { + qDebug() << "Save button has clicked"; + emit CFDStructSigsCenter::getInstance() -> sig_solverSaveData(); + }); + // 保存数据 + connect(sigsCenter, &CFDStructSigsCenter::sig_solverSaveData, this, [=]() { + this->CFDStructOperatorsModeSolverSaveData(); + }); + + connect(sigsCenter, &CFDStructSigsCenter::sig_solverModuleProperty, this, [=](SolutionAnalysisModuleProperty sig, QVariant idx) { if (sig == SolutionAnalysisModuleProperty::UNKNOW) { return; } m_module = sig; - GUI::MainWindow* mainWindow = dynamic_cast(FITKAPP->getGlobalData()->getMainWindow()); + GUI::MainWindow *mainWindow = dynamic_cast(FITKAPP->getGlobalData()->getMainWindow()); if (mainWindow == nullptr) { return; } - GUI::PropertyWidget* propertyWidget = mainWindow->getPropertyWidget(); + GUI::PropertyWidget *propertyWidget = mainWindow->getPropertyWidget(); if (propertyWidget == nullptr) { return; } - CUIConfig* uiConfig = CFDStructDataManager::getInstance()->getActionParamUIConfig(sig, idx); - QWidget* widget = new CUIPropertyWidget(nullptr, uiConfig); - if(widget != nullptr) + CUIConfig *uiConfig = CFDStructDataManager::getInstance()->getActionParamUIConfig(sig, idx); + QWidget *widget = new CUIPropertyWidget(nullptr, uiConfig); + + // 添加保存按钮 + widget->layout()->addWidget(btn); + + if (widget != nullptr) propertyWidget->setWidget(widget); return; }); } - - -CFDStructOperatorsModelSolverProperty *CFDStructOperatorsModelSolverProperty::getInstance() -{ +CFDStructOperatorsModelSolverProperty *CFDStructOperatorsModelSolverProperty::getInstance() { if (m_instance == nullptr) { m_instance = new CFDStructOperatorsModelSolverProperty; } return m_instance; } -void CFDStructOperatorsModelSolverProperty::CFDStructOperatorsModeSolverSaveData() -{ - CFDStructSigsCenter* sigsCenter = CFDStructSigsCenter::getInstance(); - connect(sigsCenter, &CFDStructSigsCenter::sig_solverSaveData, this, [ = ]() { +void CFDStructOperatorsModelSolverProperty::CFDStructOperatorsModeSolverSaveData() { + CFDStructSigsCenter *sigsCenter = CFDStructSigsCenter::getInstance(); + connect(sigsCenter, &CFDStructSigsCenter::sig_solverSaveData, this, [=]() { CFDStructDataManager::getInstance()->updateJson(); CFDStructDataManager::getInstance()->printJson(); }); diff --git a/Resources/case-01.json b/Resources/case-01.json index 91fd4c9..05bdff9 100644 --- a/Resources/case-01.json +++ b/Resources/case-01.json @@ -19,7 +19,12 @@ "chimeraMesh": 0, "refValue": { "rgas_mean": 0.0, - "gamma": 0.0 + "gamma": 0.0, + "pressure": -6.2774385622041928e66, + "temperature": -6.2774385622041928e66, + "refLength": -6.2774385622041928e66, + "refArea": -6.2774385622041928e66, + "jx": "" }, "numericMethod": { "numMethodParm": { @@ -47,10 +52,17 @@ "stepType": 1.0, "timeStep": 1.0, "timeStepsNumber": 10, - "Timeverage": 0 + "Timeverage": 0, + "savedSteps": -842150451 }, "steady": { - "iters": 1000 + "iters": 1000, + "savedIters": -842150451 + }, + "mpi": { + "core": 0, + "on": 0, + "type": 0 } } } \ No newline at end of file