|
|
|
|
|
#ifndef NMCALCULATIONDLLPEBISOLVERTASK_H
|
|
|
|
|
|
#define NMCALCULATIONDLLPEBISOLVERTASK_H
|
|
|
|
|
|
|
|
|
|
|
|
#include <QThread>
|
|
|
|
|
|
#include <QString>
|
|
|
|
|
|
#include <QVector>
|
|
|
|
|
|
#include <iostream>
|
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
#include <Windows.h>
|
|
|
|
|
|
#include "nmCalculationDefine.h"
|
|
|
|
|
|
#include "nmCalculation_global.h"
|
|
|
|
|
|
#include "pch.h"
|
|
|
|
|
|
|
|
|
|
|
|
class nmDataAnalyzeManager;
|
|
|
|
|
|
|
|
|
|
|
|
// 主窗口现在直接创建DLL求解线程任务,因此类需要导出,供nmSubWnd模块跨DLL使用。
|
|
|
|
|
|
class NMCALCULATION_EXPORT nmCalculationDllPebiSolverTask : public QThread {
|
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
public:
|
|
|
|
|
|
/**
|
|
|
|
|
|
* @brief 创建绑定到指定分析窗口的 PEBI 求解任务。
|
|
|
|
|
|
* @param sPostprocessingDir 后处理文件输出目录。
|
|
|
|
|
|
* @param pDataManager 任务所属数据管理器,不转移所有权。
|
|
|
|
|
|
* @param parent Qt 父对象。
|
|
|
|
|
|
*/
|
|
|
|
|
|
nmCalculationDllPebiSolverTask(QString sPostprocessingDir,
|
|
|
|
|
|
nmDataAnalyzeManager* pDataManager = nullptr,
|
|
|
|
|
|
QObject *parent = nullptr);
|
|
|
|
|
|
~nmCalculationDllPebiSolverTask();
|
|
|
|
|
|
|
|
|
|
|
|
/** @brief QThread 入口,记录本次 execute() 的成功状态并发送完成信号。 */
|
|
|
|
|
|
void run();
|
|
|
|
|
|
// PSO 等待线程结束后通过该接口判断本次结果是否可以继续参与误差计算.
|
|
|
|
|
|
// 返回 false 时调用方会丢弃本次结果, 防止复用上一粒子留下的旧曲线.
|
|
|
|
|
|
bool wasSuccessful() const;
|
|
|
|
|
|
/** @brief 获取本次DLL内部求解耗时,单位为毫秒。 */
|
|
|
|
|
|
int getSolveTimeMs() const;
|
|
|
|
|
|
/** @brief 获取本次求解的PEBI网格数量。 */
|
|
|
|
|
|
int getPebiCount() const;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* @brief 按显示井名设置自动拟合目标井,内部立即转换并保存 WellCode。
|
|
|
|
|
|
* @note 井名为空或查找失败时保持完整结果保存模式。
|
|
|
|
|
|
*/
|
|
|
|
|
|
void setAutoFitTargetWell(const QString& wellName);
|
|
|
|
|
|
/** @brief 返回自动拟合目标井的原始压力结果副本。 */
|
|
|
|
|
|
QVector<QVector<double> > getAutoFitResultPressure() const;
|
|
|
|
|
|
/** @brief 返回自动拟合目标井的双对数结果副本。 */
|
|
|
|
|
|
QVector<QVector<double> > getAutoFitResultLogLog() const;
|
|
|
|
|
|
/** @brief 返回自动拟合目标井的半对数结果副本。 */
|
|
|
|
|
|
QVector<QVector<double> > getAutoFitResultSemiLog() const;
|
|
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
/** @brief 执行当前唯一的 PEBI 求解模式。 */
|
|
|
|
|
|
bool execute();
|
|
|
|
|
|
|
|
|
|
|
|
/** @brief 构造 DLL 输入、执行求解并提交仍然有效的结果。 */
|
|
|
|
|
|
bool execPebiMode();
|
|
|
|
|
|
/** @brief 按求解器井顺序将压力、双对数和半对数结果映射回井对象。 */
|
|
|
|
|
|
bool savePebiModeResult(HX_NWTM_MODEL_OUTPUT& p1,
|
|
|
|
|
|
int nModelType,
|
|
|
|
|
|
const HX_NWTM_GRID_OUTPUT1& oGridOutput);
|
|
|
|
|
|
|
|
|
|
|
|
/** @brief 输出精简版 DLL 输入日志,用于定位求解异常。 */
|
|
|
|
|
|
void logHX_NWTM_MODEL_INPUT_Simplified(const HX_NWTM_MODEL_INPUT& p0);
|
|
|
|
|
|
/** @brief 将完整 DLL 输入保存到文本文件,成功时返回 true。 */
|
|
|
|
|
|
bool saveHX_NWTM_MODEL_INPUT_ToTxt(const HX_NWTM_MODEL_INPUT& p0, const QString& filePath);
|
|
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
QString m_sPostprocessingDir; ///< 本次求解使用的后处理输出目录。
|
|
|
|
|
|
/** @brief 创建任务时捕获所属数据中心,工作线程不得读取全局当前窗口。 */
|
|
|
|
|
|
nmDataAnalyzeManager* m_pDataManager;
|
|
|
|
|
|
/** @brief 创建任务时捕获网格输入版本,防止回填过期网格上的结果。 */
|
|
|
|
|
|
quint64 m_nGridInputRevision;
|
|
|
|
|
|
/** @brief 创建任务时捕获求解输入版本,防止角色或参数变化后回填旧结果。 */
|
|
|
|
|
|
quint64 m_nResultInputRevision;
|
|
|
|
|
|
bool m_lastRunSucceeded; ///< run() 保存的执行状态,供等待线程安全读取。
|
|
|
|
|
|
/** @brief 本次DLL内部求解耗时,单位为毫秒。 */
|
|
|
|
|
|
int m_nSolveTimeMs;
|
|
|
|
|
|
/** @brief 本次求解的PEBI网格数量。 */
|
|
|
|
|
|
int m_nPebiCount;
|
|
|
|
|
|
QString m_sAutoFitTargetWellCode; ///< 自动拟合目标井 WellCode;空值表示保存完整结果。
|
|
|
|
|
|
QVector<QVector<double> > m_autoFitResultPressure; ///< 目标井原始压力结果。
|
|
|
|
|
|
QVector<QVector<double> > m_autoFitResultLogLog; ///< 目标井双对数结果。
|
|
|
|
|
|
QVector<QVector<double> > m_autoFitResultSemiLog; ///< 目标井半对数结果。
|
|
|
|
|
|
|
|
|
|
|
|
private slots:
|
|
|
|
|
|
//void slotTaskUpdateProgress();
|
|
|
|
|
|
|
|
|
|
|
|
signals:
|
|
|
|
|
|
void sig_calculateDone(bool isSuccessed);
|
|
|
|
|
|
//void sigTaskProgressUpdated(int progress);
|
|
|
|
|
|
//void sigResSolverProgressUpdated(int progress);
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif // NMCALCULATIONDLLPEBISOLVERTASK_H
|