// netgen网格生成库的C++接口,传入边界、井筒、裂缝、断层和复合区,生成二维三角形网格。 // 作者:万义钊 // 日期:2025年1月28日,除夕 // 版本:1.0 #pragma once namespace nglib { #include "nglib.h" } using namespace nglib; #include #include #include enum BOUND_TYPE { CONST_PRESSURE, CONST_RATE, GEO_LIMIT }; enum BOUND_SHAPE { CIRCLE, RECTANGLE, POLYGON }; enum WELL_TYPE { VERTICAL, VERTICAL_FRACTURED, MULTI_FRACED_HORIZONTAL }; struct Point { double x, y, z; std::vector pointData; Point(double x0, double y0) { x = x0; y = y0; } Point() {}; // 拷贝构造函数 Point(const Point &other) { // std::cout << "Copy constructor called" << std::endl; x = other.x; // 复制数据 y = other.y; z = other.z; pointData = other.pointData; } }; struct Cell { int type; std::vector pointIndices; std::vector cellData; Cell(const Cell &other) { type = other.type; pointIndices = other.pointIndices; cellData = other.cellData; } Cell() {} }; class Line { public: Point p1; Point p2; }; // 裂缝线 class Frac : public Line { public: Frac(Point p1, Point p2) { this->p1 = p1; this->p2 = p2; } Frac() {} // 交点 int nIntersect; // 交点数量 std::vector vector_interPoint; // 交点坐标 }; // 定义外边界的线 class Segment : public Line { public: Segment(Point p1, Point p2) { this->p1 = p1; this->p2 = p2; } Segment() {} BOUND_TYPE boundType; // 边界线的边界条件类型 int nNumNodes; // 边界线上的网格点数 }; // 外边界的基类 class CBoundShape { public: BOUND_SHAPE boundShape; // 定义外边界类型,0为圆形,1为四边形,2为多边形 // 表示多边形(包括四边形)的参数 int nNumSegs; // 边的数量 std::vector vecSegments; // 边 // 表示圆形 Point cCenter; double dRadius; int nNodeNum; BOUND_TYPE boundType; }; // 多边形,内部的复合区域 class CBoundPolygon : public CBoundShape { public: int nNumSegs; // 边的数量 std::vector vecSegments; // 边 }; // 表示井筒圆形边界 class CBoundWell { public: CBoundWell(){wellType=VERTICAL;}//默认井为直井 public: WELL_TYPE wellType; //直井的几何参数,wellType=VERTICAL Point cCenter; double dRadius; int nNodeNum; BOUND_TYPE boundType; //直井压裂井独有的参数,wellType=VERTICAL_FRACTURED //直井的中心和半径仍然使用cCenter和dRaduis表示 double dHf;//裂缝半长 double dTheata;//裂缝角度(相对于x轴) //多段压裂水平井的参数,cCenter表示水平井中心点坐标,wellType=MULTI_FRACED_HORIZONTAL double dLength;//长度 double dBeta;//角度 int nFracNum;//压裂裂缝的数量 std::vector vecFracs;//压裂裂缝 }; #ifdef __cplusplus extern "C" { #endif __declspec(dllexport) Ng_Mesh *NgMeshGen2D(std::string strFileIn2D); __declspec(dllexport) Ng_Mesh *NgMeshGen2DByIn2d(std::vector wells, std::vector limits, std::vector faults, std::vector fracs, CBoundShape shape); __declspec(dllexport) void Ng2VTK(Ng_Mesh *mesh); #ifdef __cplusplus } #endif