You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
nmWTAI-Platform/Src/nmNum/nmData/nmDataHorizontalWell.cpp

112 lines
4.2 KiB
C++

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#include "nmDataHorizontalWell.h"
nmDataHorizontalWell::nmDataHorizontalWell() : nmDataWellBase() {
m_drainAngle = nmDataAttribute("Drain angle", 0.00000, "o", UNIT_TYPE_ANGLE, QStringList(), QStringList() <<"o" <<"radian");
// 水平井
//m_eWellType = NM_WELL_MODEL::;
this->connectAttributeSignals();
}
// 拷贝构造函数
nmDataHorizontalWell::nmDataHorizontalWell(const nmDataHorizontalWell& other)
: nmDataWellBase()
{
*this = other; // 使用赋值运算符实现
this->connectAttributeSignals();
}
// 赋值运算符
nmDataHorizontalWell& nmDataHorizontalWell::operator=(const nmDataHorizontalWell& other) {
if (this != &other) {
nmDataWellBase::operator=(other);
m_drainAngle = other.m_drainAngle;
}
return *this;
}
nmDataWellBase* nmDataHorizontalWell::clone() const {
return new nmDataHorizontalWell(*this);
}
// 序列化 nmDataHorizontalWell 为 RapidJSON Value
rapidjson::Value nmDataHorizontalWell::ToJsonValue(rapidjson::Document::AllocatorType& allocator) const
{
// 序列化井基础参数
rapidjson::Value horizontalWellObject = nmDataWellBase::ToJsonValue(allocator);
// 序列化 nmDataAttribute 类型的成员
// 调用 nmDataAttribute 自身的 ToJsonValue 方法进行递归序列化
horizontalWellObject.AddMember("DrainAngle", m_drainAngle.ToJsonValue(allocator), allocator);
return horizontalWellObject; // 返回序列化后的 RapidJSON Value
}
// 从 RapidJSON Value 反序列化数据到 nmDataHorizontalWell
void nmDataHorizontalWell::FromJsonValue(const rapidjson::Value& jsonValue)
{
// 反序列化井基础参数
nmDataWellBase::FromJsonValue(jsonValue);
// 反序列化 nmDataAttribute 类型的成员
// 调用 nmDataAttribute 自身的 FromJsonValue 方法进行递归反序列化
if (jsonValue.HasMember("DrainAngle") && jsonValue["DrainAngle"].IsObject()) {
m_drainAngle.FromJsonValue(jsonValue["DrainAngle"]);
}
}
void nmDataHorizontalWell::connectAttributeSignals() {
// 水平井属性
connect(&m_drainAngle, SIGNAL(sigValueChanged()), this, SIGNAL(sigWellDataChanged()));
}
void nmDataHorizontalWell::getPerforationAllowedMdRange(nmDataPerforation* pPerfToValidate,
double& dUpperAllowedMd,
double& dLowerAllowedMd)
{
// 1. 获取井筒的整体MD范围作为默认边界
// 对于水平井第一条射孔起点为井筒MD起点
double dWellboreTopMd = m_vecPerforations[0]->getMdStart().getValue().toDouble();
double dWellboreBottomMd = dWellboreTopMd + m_wellLength.getValue().toDouble();
// 初始化允许范围为整个井筒的MD范围
dUpperAllowedMd = dWellboreTopMd;
dLowerAllowedMd = dWellboreBottomMd;
// 2. 获取当前正在操作的射孔段的当前MD值
double dCurrentPerfMdStart = pPerfToValidate->getMdStart().getValue().toDouble();
double dCurrentPerfMdEnd = pPerfToValidate->getMdEnd().getValue().toDouble();
// 3. 遍历所有射孔段,找到与当前射孔段相邻的上下边界
foreach(nmDataPerforation* pOtherPerf, m_vecPerforations) {
if(pOtherPerf == pPerfToValidate) {
continue;
}
double dOtherStart = pOtherPerf->getMdStart().getValue().toDouble();
double dOtherEnd = pOtherPerf->getMdEnd().getValue().toDouble();
// 检查在当前射孔段上方的其他射孔段
// 如果 pOtherPerf 的结束MD 小于或等于当前射孔段的起始MD (考虑容差)
if(dOtherEnd <= dCurrentPerfMdStart + DBL_EPSILON) {
dUpperAllowedMd = qMax(dUpperAllowedMd, dOtherEnd);
}
// 检查在当前射孔段下方的其他射孔段
// 如果 pOtherPerf 的起始MD 大于或等于当前射孔段的结束MD (考虑容差)
else if(dOtherStart >= dCurrentPerfMdEnd - DBL_EPSILON) {
dLowerAllowedMd = qMin(dLowerAllowedMd, dOtherStart);
}
}
// 4. 最后,确保计算出的范围不超出井筒的物理范围
dUpperAllowedMd = qMax(dUpperAllowedMd, dWellboreTopMd);
dLowerAllowedMd = qMin(dLowerAllowedMd, dWellboreBottomMd);
}
void nmDataHorizontalWell::setDrainAngle(const nmDataAttribute& attr) {
m_drainAngle = attr;
}
nmDataAttribute& nmDataHorizontalWell::getDrainAngle() {
return m_drainAngle;
}