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