|
|
|
|
@ -1,4 +1,6 @@
|
|
|
|
|
#include "nmDataAutomaticFitting.h"
|
|
|
|
|
#include <QCoreApplication>
|
|
|
|
|
#include <QtCore/qnumeric.h>
|
|
|
|
|
|
|
|
|
|
nmDataAutomaticFitting::nmDataAutomaticFitting()
|
|
|
|
|
{
|
|
|
|
|
@ -44,7 +46,8 @@ nmDataAutomaticFitting::nmDataAutomaticFitting(const nmDataAutomaticFitting& oth
|
|
|
|
|
nmDataAutomaticFitting& nmDataAutomaticFitting::operator=(const nmDataAutomaticFitting& other)
|
|
|
|
|
{
|
|
|
|
|
if (this != &other) {
|
|
|
|
|
// 复制参数选择标志
|
|
|
|
|
// 复制多井参数及原单井配置
|
|
|
|
|
m_modelParameters = other.m_modelParameters;
|
|
|
|
|
m_permeabilitySelected = other.m_permeabilitySelected;
|
|
|
|
|
m_skinSelected = other.m_skinSelected;
|
|
|
|
|
m_wellboreStorageSelected = other.m_wellboreStorageSelected;
|
|
|
|
|
@ -111,11 +114,51 @@ rapidjson::Value nmDataAutomaticFitting::ToJsonValue(rapidjson::Document::Alloca
|
|
|
|
|
fittingObject.AddMember("AlgorithmName", rapidjson::Value(m_algorithmName.toStdString().c_str(), allocator).Move(), allocator);
|
|
|
|
|
fittingObject.AddMember("SurrogateScreeningEnabled", m_surrogateScreeningEnabled, allocator);
|
|
|
|
|
|
|
|
|
|
// 多井配置仍存放在原自动拟合节点中,敏感性配置复用同一序列化。
|
|
|
|
|
rapidjson::Value parameters(rapidjson::kArrayType);
|
|
|
|
|
for(int i = 0; i < m_modelParameters.size(); ++i) {
|
|
|
|
|
const nmFitParameter& p = m_modelParameters[i];
|
|
|
|
|
rapidjson::Value item(rapidjson::kObjectType);
|
|
|
|
|
item.AddMember("WellCode", rapidjson::Value(p.wellCode.toUtf8().constData(), allocator).Move(), allocator);
|
|
|
|
|
item.AddMember("WellName", rapidjson::Value(p.wellName.toUtf8().constData(), allocator).Move(), allocator);
|
|
|
|
|
item.AddMember("Type", p.type, allocator);
|
|
|
|
|
item.AddMember("Selected", p.selected, allocator);
|
|
|
|
|
item.AddMember("Initial", p.initial, allocator);
|
|
|
|
|
item.AddMember("Lower", p.lower, allocator);
|
|
|
|
|
item.AddMember("Upper", p.upper, allocator);
|
|
|
|
|
parameters.PushBack(item, allocator);
|
|
|
|
|
}
|
|
|
|
|
fittingObject.AddMember("ModelParameters", parameters, allocator);
|
|
|
|
|
|
|
|
|
|
return fittingObject;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void nmDataAutomaticFitting::FromJsonValue(const rapidjson::Value& jsonValue)
|
|
|
|
|
{
|
|
|
|
|
// 缺失列表表示旧版单井设置;非法项不进入优化向量。
|
|
|
|
|
m_modelParameters.clear();
|
|
|
|
|
if(jsonValue.HasMember("ModelParameters") && jsonValue["ModelParameters"].IsArray()) {
|
|
|
|
|
const rapidjson::Value& items = jsonValue["ModelParameters"];
|
|
|
|
|
for(rapidjson::SizeType i = 0; i < items.Size(); ++i) {
|
|
|
|
|
const rapidjson::Value& item = items[i];
|
|
|
|
|
if(!item.IsObject() || !item.HasMember("Type") || !item["Type"].IsInt() ||
|
|
|
|
|
item["Type"].GetInt() < 0 || item["Type"].GetInt() > 5 ||
|
|
|
|
|
!item.HasMember("Initial") || !item["Initial"].IsNumber() ||
|
|
|
|
|
!item.HasMember("Lower") || !item["Lower"].IsNumber() ||
|
|
|
|
|
!item.HasMember("Upper") || !item["Upper"].IsNumber()) continue;
|
|
|
|
|
nmFitParameter p;
|
|
|
|
|
p.type = item["Type"].GetInt();
|
|
|
|
|
if(item.HasMember("WellCode") && item["WellCode"].IsString()) p.wellCode = QString::fromUtf8(item["WellCode"].GetString());
|
|
|
|
|
if(item.HasMember("WellName") && item["WellName"].IsString()) p.wellName = QString::fromUtf8(item["WellName"].GetString());
|
|
|
|
|
p.initial = item["Initial"].GetDouble();
|
|
|
|
|
p.lower = item["Lower"].GetDouble();
|
|
|
|
|
p.upper = item["Upper"].GetDouble();
|
|
|
|
|
if(!qIsFinite(p.initial) || !qIsFinite(p.lower) || !qIsFinite(p.upper) || p.lower > p.upper) continue;
|
|
|
|
|
p.selected = item.HasMember("Selected") && item["Selected"].IsBool() && item["Selected"].GetBool();
|
|
|
|
|
m_modelParameters.append(p);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 反序列化参数选择标志
|
|
|
|
|
if (jsonValue.HasMember("PermeabilitySelected") && jsonValue["PermeabilitySelected"].IsBool()) {
|
|
|
|
|
m_permeabilitySelected = jsonValue["PermeabilitySelected"].GetBool();
|
|
|
|
|
@ -268,3 +311,56 @@ void nmDataAutomaticFitting::setAlgorithmName(const QString& algorithmName) { m_
|
|
|
|
|
|
|
|
|
|
bool nmDataAutomaticFitting::getSurrogateScreeningEnabled() const { return m_surrogateScreeningEnabled; }
|
|
|
|
|
void nmDataAutomaticFitting::setSurrogateScreeningEnabled(bool enabled) { m_surrogateScreeningEnabled = enabled; }
|
|
|
|
|
|
|
|
|
|
QString nmFitParameter::name() const
|
|
|
|
|
{
|
|
|
|
|
// 井参数携带井名,共用参数保持原名称和翻译。
|
|
|
|
|
const char* names[] = {"Permeability", "Skin", "Wellbore storage", "Porosity", "Fracture conductivity", "Fracture half length"};
|
|
|
|
|
const QString label = QCoreApplication::translate("nmWxAutomaticFitting", names[type]);
|
|
|
|
|
return wellCode.isEmpty() ? label : wellName + " / " + label;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString nmFitParameter::code() const
|
|
|
|
|
{
|
|
|
|
|
// 结果面板继续使用已有 XML 参数编码。
|
|
|
|
|
const char* codes[] = {"K", "Skin", "C", "phi", "Dfc", "FractureHalfLength"};
|
|
|
|
|
return codes[type];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString nmFitParameter::unit() const
|
|
|
|
|
{
|
|
|
|
|
// 与既有六参数的基准单位一致。
|
|
|
|
|
const char* units[] = {"mD", "", "m^3/MPa", "", "mD.m", "m"};
|
|
|
|
|
return units[type];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString nmFitParameter::samplingKey() const
|
|
|
|
|
{
|
|
|
|
|
// 同井同参数才与敏感性采样互斥。
|
|
|
|
|
const QString names[] = {"k", "Skin", "C", QString(QChar(0x03c6)), "Dfc", "FractureHalfLength"};
|
|
|
|
|
return wellCode.isEmpty() ? names[type] : wellCode + "/" + names[type];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QVector<nmFitParameter>& nmDataAutomaticFitting::getModelParameters()
|
|
|
|
|
{
|
|
|
|
|
// 窗口在自己的配置副本上编辑。
|
|
|
|
|
return m_modelParameters;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const QVector<nmFitParameter>& nmDataAutomaticFitting::getModelParameters() const
|
|
|
|
|
{
|
|
|
|
|
// 后台计算只读取启动前冻结的设置。
|
|
|
|
|
return m_modelParameters;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool nmDataAutomaticFitting::hasSelectedParameters() const
|
|
|
|
|
{
|
|
|
|
|
// 新配置检查完整多井列表,旧配置兼容原六个勾选标志。
|
|
|
|
|
if(!m_modelParameters.isEmpty()) {
|
|
|
|
|
for(int i = 0; i < m_modelParameters.size(); ++i)
|
|
|
|
|
if(m_modelParameters[i].selected) return true;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return m_permeabilitySelected || m_skinSelected || m_wellboreStorageSelected ||
|
|
|
|
|
m_porositySelected || m_fractureConductivitySelected || m_fractureHalfLengthSelected;
|
|
|
|
|
}
|
|
|
|
|
|