diff --git a/.gitignore b/.gitignore index e51b6bf..ef11555 100644 --- a/.gitignore +++ b/.gitignore @@ -35,4 +35,11 @@ Src4/.qmake.stash Src4/nmWTAI.pro* Src4/Makefile Src4/nmNum/Makefile +Src4/nmNum/nmCalculation/Win32 +Src4/nmNum/nmCalculation/debug +Src4/nmNum/nmCalculation/release +Src4/nmNum/nmCalculation/Makefile* +Src4/nmNum/nmCalculation/*.pro.user +Src4/nmNum/nmCalculation/*.vcxproj* +Src4/nmNum/nmCalculation/*.pdb Bin-versions \ No newline at end of file diff --git a/Bin/TestOfWTAI/TestDemo3/TestDemo3.db b/Bin/TestOfWTAI/TestDemo3/TestDemo3.db index 8e912a9..ec0164f 100644 Binary files a/Bin/TestOfWTAI/TestDemo3/TestDemo3.db and b/Bin/TestOfWTAI/TestDemo3/TestDemo3.db differ diff --git a/Include/nmNum/nmCalculation/nmCalculation.h b/Include/nmNum/nmCalculation/nmCalculation.h new file mode 100644 index 0000000..b7cff68 --- /dev/null +++ b/Include/nmNum/nmCalculation/nmCalculation.h @@ -0,0 +1,12 @@ +#ifndef NMCALCULATION_H +#define NMCALCULATION_H + +#include "nmCalculation_global.h" + +class NMCALCULATION_EXPORT NmCalculation +{ +public: + NmCalculation(); +}; + +#endif // NMCALCULATION_H diff --git a/Include/nmNum/nmCalculation/nmCalculationDefine.h b/Include/nmNum/nmCalculation/nmCalculationDefine.h new file mode 100644 index 0000000..f2a7f5c --- /dev/null +++ b/Include/nmNum/nmCalculation/nmCalculationDefine.h @@ -0,0 +1,6 @@ +#ifndef NMCALCULATIONDEFINE_H +#define NMCALCULATIONDEFINE_H + + + +#endif // NMCALCULATIONDEFINE_H diff --git a/Include/nmNum/nmCalculation/nmCalculationGeo.h b/Include/nmNum/nmCalculation/nmCalculationGeo.h new file mode 100644 index 0000000..8fb685c --- /dev/null +++ b/Include/nmNum/nmCalculation/nmCalculationGeo.h @@ -0,0 +1,26 @@ +#ifndef NMCALCULATIONGEO_H +#define NMCALCULATIONGEO_H + +#include +#include +#include "nmCalculationGeoDataOutline.h" +#include "nmCalculationGeoDataWell.h" + +class nmCalculationGeo +{ +public: +// nmCalculationGeo(); + // 构造函数 + nmCalculationGeo(const nmCalculationGeoDataOutline &outline, const QVector& wellList, double lc); + void generate2DFile(const QString& outputFileName); + void generate3DFile(const QString& outputFileName); +private: + QString generateOCCGeoCodes(bool is3D = true); + + //基础网格大小设置 + nmCalculationGeoDataOutline m_outline;//存储多边形的点 + QVector m_vWellList; // 存储圆心数据 + double m_dGridSize;// 基础网格大小设置 +}; + +#endif // NMCALCULATIONGEO_H diff --git a/Include/nmNum/nmCalculation/nmCalculationGeoDataOutline.h b/Include/nmNum/nmCalculation/nmCalculationGeoDataOutline.h new file mode 100644 index 0000000..4f37819 --- /dev/null +++ b/Include/nmNum/nmCalculation/nmCalculationGeoDataOutline.h @@ -0,0 +1,18 @@ +#ifndef NMCALCULATIONGEODATAOUTLINE_H +#define NMCALCULATIONGEODATAOUTLINE_H + +#include +#include + +class nmCalculationGeoDataOutline +{ +public: + nmCalculationGeoDataOutline(const QVector points); + const QVector &points() const; + void setPoints(const QVector &newVPoints); + +private: + QVector m_vPoints; +}; + +#endif // NMCALCULATIONGEODATAOUTLINE_H diff --git a/Include/nmNum/nmCalculation/nmCalculationGeoDataWell.h b/Include/nmNum/nmCalculation/nmCalculationGeoDataWell.h new file mode 100644 index 0000000..8dee103 --- /dev/null +++ b/Include/nmNum/nmCalculation/nmCalculationGeoDataWell.h @@ -0,0 +1,32 @@ +#ifndef NMCALCULATIONGEODATAWELL_H +#define NMCALCULATIONGEODATAWELL_H + +#include +#include +#include + +class nmCalculationGeoDataWell +{ +public: + // 默认构造函数 + nmCalculationGeoDataWell(); + // 带参数构造函数 + nmCalculationGeoDataWell(const QPointF& center, double radius, int roundPointCount); + // 拷贝构造函数 + nmCalculationGeoDataWell(const nmCalculationGeoDataWell& other); + // 重载赋值运算符 + nmCalculationGeoDataWell& operator=(const nmCalculationGeoDataWell& other); + + QPointF center() const; + void setCenter(QPointF newCenter); + double radius() const; + void setRadius(double newDRadius); + int roundPointCount() const; + void setRoundPointCount(int newIRoundPointCount); +public: + QPointF m_center; // 圆心位置 + double m_dRadius; // 半径 + int m_iRoundPointCount; // 圆周网格数量,用于加密 +}; + +#endif // NMCALCULATIONGEODATAWELL_H diff --git a/Include/nmNum/nmCalculation/nmCalculationGeoSurface.h b/Include/nmNum/nmCalculation/nmCalculationGeoSurface.h new file mode 100644 index 0000000..80d4ad1 --- /dev/null +++ b/Include/nmNum/nmCalculation/nmCalculationGeoSurface.h @@ -0,0 +1,18 @@ +#ifndef NMCALCULATIONGEOSURFACE_H +#define NMCALCULATIONGEOSURFACE_H + +#include +#include "nmCalculationGeoDataOutline.h" + +class nmCalculationGeoSurface +{ +public: + nmCalculationGeoSurface(const nmCalculationGeoDataOutline& outline, const double& gridSize = 0.1); + + QString generateSurfaceGeoCodes(); +private: + nmCalculationGeoDataOutline m_outline; + double m_dGridSize;// 基础网格大小设置 +}; + +#endif // NMCALCULATIONGEOSURFACE_H diff --git a/Include/nmNum/nmCalculation/nmCalculationGeoWell.h b/Include/nmNum/nmCalculation/nmCalculationGeoWell.h new file mode 100644 index 0000000..6a3fc61 --- /dev/null +++ b/Include/nmNum/nmCalculation/nmCalculationGeoWell.h @@ -0,0 +1,19 @@ +#ifndef NMCALCULATIONGEOWELL_H +#define NMCALCULATIONGEOWELL_H + +#include +#include +#include "nmCalculationGeoDataWell.h" + +class nmCalculationGeoWell +{ +public: + nmCalculationGeoWell(const QVector& wellList); + + //创建井的方法 + QString generateWellGeoCodes(int index); +private: + QVector m_vWellList; +}; + +#endif // NMCALCULATIONGEOWELL_H diff --git a/Include/nmNum/nmCalculation/nmCalculationGrid.h b/Include/nmNum/nmCalculation/nmCalculationGrid.h new file mode 100644 index 0000000..8daea23 --- /dev/null +++ b/Include/nmNum/nmCalculation/nmCalculationGrid.h @@ -0,0 +1,11 @@ +#ifndef NMCALCULATIONGRID_H +#define NMCALCULATIONGRID_H + + +class nmCalculationGrid +{ +public: + nmCalculationGrid(); +}; + +#endif // NMCALCULATIONGRID_H diff --git a/Include/nmNum/nmCalculation/nmCalculationSolver.h b/Include/nmNum/nmCalculation/nmCalculationSolver.h new file mode 100644 index 0000000..c5ff5ef --- /dev/null +++ b/Include/nmNum/nmCalculation/nmCalculationSolver.h @@ -0,0 +1,30 @@ +#ifndef NMCALCULATIONSOLVER_H +#define NMCALCULATIONSOLVER_H + +#include +#include +#include "nmCalculation_global.h" +#include "singlePhaseSolver.h" + +using namespace std; +class CWell; +class NMCALCULATION_EXPORT nmCalculationSolver +{ +public: + nmCalculationSolver(); + + // ִ⣬Ҫ vtkļϢÿԲġ뾶 + bool execSolve(QString vtkFilePath, QString reservoirParamFilePath, QString wellsParamFilePath, QString dllDir, QString outputFile); + +private: + // ΪȡҪ + void readVTK(QString vtkFlePath); + // ȡϢ㡢cellϢ + bool readMesh(std::string fname, std::vector &points, std::vector &cells); + // ȡͲ + bool readReservoirParamters(std::string fname, double* pBaseData); + // ȡϢļھÿھ + bool readWells(std::string fname, int& numWell, CWell* well); +}; + +#endif // NMCALCULATIONSOLVER_H diff --git a/Include/nmNum/nmCalculation/nmCalculation_global.h b/Include/nmNum/nmCalculation/nmCalculation_global.h new file mode 100644 index 0000000..4ab894b --- /dev/null +++ b/Include/nmNum/nmCalculation/nmCalculation_global.h @@ -0,0 +1,12 @@ +#ifndef NMCALCULATION_GLOBAL_H +#define NMCALCULATION_GLOBAL_H + +#include + +#if defined(NM_CALCULATION_LIBRARY) + #define NMCALCULATION_EXPORT Q_DECL_EXPORT +#else + #define NMCALCULATION_EXPORT Q_DECL_IMPORT +#endif + +#endif // NMCALCULATION_GLOBAL_H diff --git a/Include/nmNum/nmData/nmDataGeo.h b/Include/nmNum/nmData/nmDataGeo.h index da166e8..9da92df 100644 --- a/Include/nmNum/nmData/nmDataGeo.h +++ b/Include/nmNum/nmData/nmDataGeo.h @@ -19,6 +19,8 @@ public: // 构造函数 nmDataGeo(const QVector&points, const QVector& circlesPoint, double lc); void generate2DFile(const QString& fileName); + // 写井的信息,包括:井的圆心,半径 + void generateWells(const QString& fileName); void generate3DFile(const QString& fileName); private: QString createFile(bool is3D = true); diff --git a/Include/nmNum/nmData/nmDataGeoOutline.h b/Include/nmNum/nmData/nmDataGeoOutline.h index 66e79ec..be93045 100644 --- a/Include/nmNum/nmData/nmDataGeoOutline.h +++ b/Include/nmNum/nmData/nmDataGeoOutline.h @@ -17,9 +17,9 @@ public: QString createOutline(); private: - QVectorm_points;//存储多边形的点 + QVectorm_points; // 存储多边形的点 - double m_lc;//基础网格大小设置 + double m_lc; // 基础网格大小设置 }; diff --git a/Src/nmNum/nmCalculation/nmCalculation.cpp b/Src/nmNum/nmCalculation/nmCalculation.cpp new file mode 100644 index 0000000..f7e113b --- /dev/null +++ b/Src/nmNum/nmCalculation/nmCalculation.cpp @@ -0,0 +1,5 @@ +#include "nmCalculation.h" + +NmCalculation::NmCalculation() +{ +} diff --git a/Src/nmNum/nmCalculation/nmCalculationGeo.cpp b/Src/nmNum/nmCalculation/nmCalculationGeo.cpp new file mode 100644 index 0000000..eab024f --- /dev/null +++ b/Src/nmNum/nmCalculation/nmCalculationGeo.cpp @@ -0,0 +1,64 @@ +#include "nmCalculationGeo.h" +#include +#include +#include + +#include "nmCalculationGeoSurface.h" +#include "nmCalculationGeoWell.h" + +nmCalculationGeo::nmCalculationGeo(const nmCalculationGeoDataOutline &outline, const QVector& wellList, double lc): m_outline(outline), + m_vWellList(wellList), m_dGridSize(lc) +{ +} + +QString nmCalculationGeo::generateOCCGeoCodes(bool is3D) +{ + int flag = 0; + QStringList geoLines; + // 生成线、面 + nmCalculationGeoSurface surface(m_outline, m_dGridSize); + geoLines.append(surface.generateSurfaceGeoCodes()); + // 对于井做处理 + flag = flag + m_vWellList.size(); + nmCalculationGeoWell wells(m_vWellList); + geoLines.append(wells.generateWellGeoCodes(flag)); + geoLines.append("Transfinite Surface(1) = {1}; "); + + if (is3D) { + // 设置网格厚度,目前只支持单层网格 + double gridThickness = 0.2; + geoLines.append(QString("Extrude {0, 0, %1} {Surface{1};Layers{1};Recombine;}").arg(gridThickness)); + } + + return geoLines.join("\n"); +} + +void nmCalculationGeo::generate2DFile(const QString& fileName) +{ + QFile file(fileName); + + //检查 + if(!file.open(QIODevice::WriteOnly | QIODevice::Text)) { + qWarning("Cannot open file for writing: %s", qPrintable(file.errorString())); + return; + } + + QTextStream out(&file); + out << generateOCCGeoCodes(false); + file.close(); +} + +void nmCalculationGeo::generate3DFile(const QString& fileName) +{ + QFile file(fileName); + + //检查 + if(!file.open(QIODevice::WriteOnly | QIODevice::Text)) { + qWarning("Cannot open file for writing: %s", qPrintable(file.errorString())); + return; + } + + QTextStream out(&file); + out << generateOCCGeoCodes(); + file.close(); +} diff --git a/Src/nmNum/nmCalculation/nmCalculationGeoDataOutline.cpp b/Src/nmNum/nmCalculation/nmCalculationGeoDataOutline.cpp new file mode 100644 index 0000000..e94d243 --- /dev/null +++ b/Src/nmNum/nmCalculation/nmCalculationGeoDataOutline.cpp @@ -0,0 +1,15 @@ +#include "nmCalculationGeoDataOutline.h" + +nmCalculationGeoDataOutline::nmCalculationGeoDataOutline(const QVector points): m_vPoints(points) +{ +} + +const QVector &nmCalculationGeoDataOutline::points() const +{ + return m_vPoints; +} + +void nmCalculationGeoDataOutline::setPoints(const QVector &newVPoints) +{ + m_vPoints = newVPoints; +} diff --git a/Src/nmNum/nmCalculation/nmCalculationGeoDataWell.cpp b/Src/nmNum/nmCalculation/nmCalculationGeoDataWell.cpp new file mode 100644 index 0000000..80cd217 --- /dev/null +++ b/Src/nmNum/nmCalculation/nmCalculationGeoDataWell.cpp @@ -0,0 +1,56 @@ +#include "nmCalculationGeoDataWell.h" + +nmCalculationGeoDataWell::nmCalculationGeoDataWell() +{ +} + +nmCalculationGeoDataWell::nmCalculationGeoDataWell(const QPointF& center, double radius, int roundPointCount) + : m_center(center), m_dRadius(radius), m_iRoundPointCount(roundPointCount) {} + +nmCalculationGeoDataWell::nmCalculationGeoDataWell(const nmCalculationGeoDataWell& other) +{ + m_center = other.m_center; + m_dRadius = other.m_dRadius; + m_iRoundPointCount = other.m_iRoundPointCount; +} + +nmCalculationGeoDataWell& nmCalculationGeoDataWell::operator=(const nmCalculationGeoDataWell& other) +{ + if (this != &other) { + m_center = other.m_center; + m_dRadius = other.m_dRadius; + m_iRoundPointCount = other.m_iRoundPointCount; + } + + return *this; +} + +int nmCalculationGeoDataWell::roundPointCount() const +{ + return m_iRoundPointCount; +} + +void nmCalculationGeoDataWell::setRoundPointCount(int newIRoundPointCount) +{ + m_iRoundPointCount = newIRoundPointCount; +} + +double nmCalculationGeoDataWell::radius() const +{ + return m_dRadius; +} + +void nmCalculationGeoDataWell::setRadius(double newDRadius) +{ + m_dRadius = newDRadius; +} + +QPointF nmCalculationGeoDataWell::center() const +{ + return m_center; +} + +void nmCalculationGeoDataWell::setCenter(QPointF newCenter) +{ + m_center = newCenter; +} diff --git a/Src/nmNum/nmCalculation/nmCalculationGeoSurface.cpp b/Src/nmNum/nmCalculation/nmCalculationGeoSurface.cpp new file mode 100644 index 0000000..bbd5381 --- /dev/null +++ b/Src/nmNum/nmCalculation/nmCalculationGeoSurface.cpp @@ -0,0 +1,50 @@ +#include "nmCalculationGeoSurface.h" + +#include + +nmCalculationGeoSurface::nmCalculationGeoSurface(const nmCalculationGeoDataOutline& outline, const double& gridSize): m_outline(outline), m_dGridSize(gridSize) +{ +} + +//面的文件部分的创造 +QString nmCalculationGeoSurface::generateSurfaceGeoCodes() +{ + QStringList geoLines; + QVector points = m_outline.points(); + geoLines.append(QString("SetFactory(\"OpenCASCADE\");"));//加入OCC + + for(int i = 0; i < points.size(); ++i) { + const QPointF& point = points[i]; + //点:point部分多边形相关点的坐标以及网格划分的基础网格大小 + geoLines.append(QString("Point(%1)={%2,%3,0,%4};") + .arg(i + 1) + .arg(point.x()) + .arg(point.y()) + .arg(m_dGridSize)); + } + + for(int i = 0; i < points.size(); i++) { + //线:规定多边形的两点连接成线 + geoLines.append(QString("Line(%1)={%2,%3};") + .arg(i + 1) + .arg(i + 1) + .arg((i + 1) % points.size() + 1)); + } + + QStringList pointIndexList; + //面:多线封闭连接成面 + pointIndexList.append("Line Loop(1) = {"); + + for (int i = 1; i <= points.size(); ++i) { + pointIndexList.append(QString::number(i)); + + if (i < points.size()) { + pointIndexList.append(","); + } + } + + pointIndexList.append("};"); + geoLines.append(pointIndexList.join("")); + geoLines.append("Plane Surface(1) = {1};");//面:单独的面 + return geoLines.join("\n"); +} diff --git a/Src/nmNum/nmCalculation/nmCalculationGeoWell.cpp b/Src/nmNum/nmCalculation/nmCalculationGeoWell.cpp new file mode 100644 index 0000000..0a4f6ea --- /dev/null +++ b/Src/nmNum/nmCalculation/nmCalculationGeoWell.cpp @@ -0,0 +1,41 @@ +#include "nmCalculationGeoWell.h" + +#include + +nmCalculationGeoWell::nmCalculationGeoWell(const QVector& wellList): m_vWellList(wellList) +{ +} + +QString nmCalculationGeoWell::generateWellGeoCodes(int index) +{ + QStringList circleLines; + + // 单独的 Sphere 的文件内容 + for (int i = 0; i < m_vWellList.size(); i++) { + const nmCalculationGeoDataWell & well = m_vWellList[i]; + circleLines.append(QString("Sphere(%1) = {%2, %3, 0, %4};") + .arg(i + 1) // 编号 + .arg(well.center().x()) // x坐标 + .arg(well.center().y()) // y坐标 + .arg(well.radius())); // 圆的半径 + } + + // 添加布尔差异的定义 + // qDebug()< +#include +#include +#include +#include + +nmCalculationSolver::nmCalculationSolver() +{ +} + +bool nmCalculationSolver::execSolve(QString vtkFilePath, QString reservoirParamFilePath, QString wellsParamFilePath, QString dllDir, QString outputFile) +{ + // 读取点、cell信息 + std::vector points; + std::vector cells; + this->readMesh(vtkFilePath.toStdString(), points, cells); + // 读取油藏信息 + double *pBaseData; + pBaseData = new double[8]; + this->readReservoirParamters(reservoirParamFilePath.toStdString(), pBaseData); + // 读取井的属性信息 + int nWellNum; + CWell* wWell = NULL; + this->readWells(wellsParamFilePath.toStdString(), nWellNum, wWell); + QString dllPath = dllDir + "singlePhaseSolverDll.dll"; + //LPCWSTR name; + //wchar_t* str2 = new wchar_t[dllPath.size() + 1]; + //int len1 = dllPath.toWCharArray(str2); + //str2[len1] = '\0';//不添加这个,会有乱码 + //name = str2; +// HMODULE hMod = LoadLibrary(name); + //HMODULE hMod = LoadLibrary(L"E:\01-Projects\16-CNPC\16-nmWTAI-gitea\Bin\Temp\Nm\Solver\singlePhaseSolverDll.dll"); + //int err = GetLastError(); +// if (NULL == hMod) { +// std::cout << "singlePhaseSolver.dll加载失败!\n"; +// delete[] pBaseData; +// delete[] wWell; +// return false; +// } +// typedef int(*Solver)(double*, std::vector, std::vector, int, CWell*, +// std::vector> &, std::vector>> &); +// // Get the address of the trinomial function +// Solver solverFun = (Solver)GetProcAddress(hMod, "singlePhaseSolver"); +// if (NULL == solverFun) { +// FreeLibrary(hMod); +// std::cout << "singlePhaseSolver文件加载函数地址获取失败!\n"; +// delete[] pBaseData; +// delete[] wWell; +// return false; +// } + QLibrary library(dllPath); + + // 加载动态库: + if (library.load()) { + qDebug() << "Library loaded successfully."; + } else { + qDebug() << "Failed to load library:" << library.errorString(); + } + + // 获取函数指针并调用函数: + typedef int(*Solver)(double*, std::vector, std::vector, int, CWell*, + std::vector> &, std::vector>> &); + Solver solverFun = (Solver)library.resolve("singlePhaseSolver"); + + if (solverFun) { + qDebug() << "Success to resolve function"; + } else { + qDebug() << "Failed to resolve function:" << library.errorString(); + } + std::vector> vecBP; + std::vector>> vecFieldPre; + // 调用求解器求解 + solverFun(pBaseData, points, cells, nWellNum, wWell, vecBP, vecFieldPre); +// FreeLibrary(hMod); + delete[] pBaseData; + delete[] wWell; + return true; +} + +bool nmCalculationSolver::readMesh(std::string fname, std::vector &points, std::vector &cells) +{ + std::ifstream file(fname); + + if (!file.is_open()) { + return false; + } + + // Skip header + std::string line; + + for (int i = 0; i < 4; ++i) { + std::getline(file, line); + } + + // Read points + std::getline(file, line); + std::istringstream iss(line); + std::string keyword; + int pointCount; + iss >> keyword >> pointCount; + points.resize(pointCount); + + for (int i = 0; i < points.size(); i++) { + Point& point = points[i]; + file >> point.x >> point.y >> point.z; + } + +// Read cells + std::getline(file, line); // Skip empty line + std::getline(file, line); + std::getline(file, line); + iss = std::istringstream(line); + int cellCount, totalListSize; + iss >> keyword >> cellCount >> totalListSize; + cells.resize(cellCount); + +// for (Cell& cell : cells) { + for (int i = 0; i < cells.size(); i++) { + Cell& cell = cells[i]; + int cellPointSize; + file >> cellPointSize; + cell.pointIndices.resize(cellPointSize); +// for (int& index : cell.pointIndices) { + std::cout << cellPointSize; + + for (int j = 0; j < cell.pointIndices.size(); j++) { + int& index = cell.pointIndices[j]; + file >> index; + } + } + +// Read cell types + std::getline(file, line); // Skip empty line + std::getline(file, line); + std::getline(file, line); + iss = std::istringstream(line); + iss >> keyword >> cellCount; + +// for (Cell& cell : cells) { + for (int i = 0; i < cells.size(); i++) { + Cell& cell = cells[i]; + file >> cell.type; + } + +// Read point data + std::getline(file, line); // Skip empty line + std::getline(file, line); + std::getline(file, line); + iss = std::istringstream(line); + int dataCount; + iss >> keyword >> dataCount; + std::getline(file, line); + std::getline(file, line); + +// for (Point& point : points) { + for (int i = 0; i < points.size(); i++) { + Point& point = points[i]; + point.pointData.resize(1); + file >> point.pointData[0]; + } + + return 1; +} + +bool nmCalculationSolver::readReservoirParamters(std::string fname, double* pBaseData) +{ + std::ifstream file(fname); + + if (!file.is_open()) { + return false; + } + + for (int i = 0; i < 8; ++i) { + file >> pBaseData[i]; + } + + return true; +} + +bool nmCalculationSolver::readWells(std::string fname, int& numWell, CWell* well) +{ + std::fstream f(fname); + + if (!f.is_open()) { + return false; + } + + f >> numWell; + well = new CWell[numWell]; + + for (int i = 0; i < numWell; ++i) { + f >> well[i].dRc >> well[i].dSkin >> well[i].dC >> well[i].nTimeNumQ; + + if (well[i].nTimeNumQ > 1) { + well[i].bisMultFlow = true; + } + + for (int j = 0; j < well[i].nTimeNumQ; ++j) { + f >> well[i].pdTimeQ[j] >> well[i].pdQ[j]; + } + } + + return true; +} diff --git a/Src/nmNum/nmData/nmDataGeo.cpp b/Src/nmNum/nmData/nmDataGeo.cpp index e1e43a8..fae1540 100644 --- a/Src/nmNum/nmData/nmDataGeo.cpp +++ b/Src/nmNum/nmData/nmDataGeo.cpp @@ -45,6 +45,28 @@ void nmDataGeo::generate2DFile(const QString& fileName) file.close(); } +void nmDataGeo::generateWells(const QString &fileName) +{ + QFile file(fileName); + + //检查 + if(!file.open(QIODevice::WriteOnly | QIODevice::Text)) { + qWarning("Cannot open file for writing: %s", qPrintable(file.errorString())); + return; + } + + QTextStream out(&file); + out << m_circlesPoint.size() << endl; + + // 写井的信息 + for (int i = 0; i < m_circlesPoint.size(); i++) { + CircleWell& well = m_circlesPoint[i]; + out << well.center.x() << " " << well.center.y() << " " << well.r << " "<< well.pointCount < outlinePoints, QVectorwriteLog("Gen grid command output: " + output); - qDebug()<<"Gen grid command output: " + output; + qDebug() << "Gen grid command output: " + output; // 设置恢复 QDir::setCurrent(currentDir); } diff --git a/Src/nmNum/nmSubWnd/nmSubWndMain.cpp b/Src/nmNum/nmSubWnd/nmSubWndMain.cpp index 9825371..70a5b12 100644 --- a/Src/nmNum/nmSubWnd/nmSubWndMain.cpp +++ b/Src/nmNum/nmSubWnd/nmSubWndMain.cpp @@ -43,6 +43,7 @@ #include "nmWxGridVTKContainerWidget.h" #include "nmWxSelectWellsDlg.h" #include "nmWxSelectWellsWidget.h" +#include "nmCalculationSolver.h" #include "nmObjPointWell.h" @@ -932,7 +933,19 @@ void nmSubWndMain::generationMesh() void nmSubWndMain::solveAndAnalyze() { + // vtk文件 + QString sFileGrid = ZxBaseUtil::getDirOf(s_Dir_Temp, "Nm/PreProcessing") + "mesh.vtk"; + // 油藏参数文件 + QString sFileReservoirParamters = ZxBaseUtil::getDirOf(s_Dir_Temp, "Nm/PreProcessing") + "par.txt"; + // 井数据文件 + QString sFileWell = ZxBaseUtil::getDirOf(s_Dir_Temp, "Nm/PreProcessing") + "wells.txt"; + // dll路径 + QString dllDir = ZxBaseUtil::getDirOf(s_Dir_Temp, "Nm/Solver"); + // 后处理文件路径 + QString postDir = ZxBaseUtil::getDirOf(s_Dir_Temp, "Nm/PostProcessing"); // 调用求解器 + nmCalculationSolver solver; + solver.execSolve(sFileGrid, sFileReservoirParamters, sFileWell, dllDir, postDir); } void nmSubWndMain::triggerToolBarAction(int index) diff --git a/Src4/nmNum/nmCalculation/nmCalculation.pro b/Src4/nmNum/nmCalculation/nmCalculation.pro new file mode 100644 index 0000000..270940b --- /dev/null +++ b/Src4/nmNum/nmCalculation/nmCalculation.pro @@ -0,0 +1,18 @@ +QT -= gui + +TARGET = nmCalculation +TEMPLATE = lib +DEFINES += NM_CALCULATION_LIBRARY + +include(../../setting.pri) + +# You can make your code fail to compile if it uses deprecated APIs. +# In order to do so, uncomment the following line. +#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 + +SOURCES += $${wtSrc}/nmNum/nmCalculation/*.cpp +HEADERS += $${wtInclude}/nmNum/nmCalculation/*.h + + +INCLUDEPATH += $${wtInclude}/nmNum/nmCalculation \ + $${geoHome}/3rd/SinglePhaseSolver/include diff --git a/Src4/nmNum/nmNum.pro b/Src4/nmNum/nmNum.pro index 0290020..53c704b 100644 --- a/Src4/nmNum/nmNum.pro +++ b/Src4/nmNum/nmNum.pro @@ -9,5 +9,6 @@ addSubdirs(nmData) addSubdirs(nmPlot) addSubdirs(nmSubWnd) addSubdirs(nmSubWxs) +addSubdirs(nmCalculation) fixDepends() diff --git a/Src4/nmNum/nmSubWnd/nmSubWnd.pro b/Src4/nmNum/nmSubWnd/nmSubWnd.pro index b0303f7..aae8f92 100644 --- a/Src4/nmNum/nmSubWnd/nmSubWnd.pro +++ b/Src4/nmNum/nmSubWnd/nmSubWnd.pro @@ -67,6 +67,9 @@ INCLUDEPATH += $${wtInclude}/nmNum/nmXml INCLUDEPATH += $${wtInclude}/nmNum/nmSubWxs INCLUDEPATH += $${wtInclude}/nmNum/nmSubWnd +INCLUDEPATH += $${wtInclude}/nmNum/nmCalculation +INCLUDEPATH += $${geoHome}/3rd/SinglePhaseSolver/include + SOURCES += $${wtSrc}/nmNum/nmSubWnd/*.cpp HEADERS += $${wtInclude}/nmNum/nmSubWnd/*.h @@ -85,5 +88,5 @@ LIBS += -lmProjectManager -lmSubWnd -lmToolPvt LIBS += -lnmData -lnmXml -lnmPlot -lnmSubWxs LIBS += -lmGuiJob -LIBS += -liAlgMath +LIBS += -liAlgMath -lnmCalculation