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/ML/Training/include/netgenmesh.h

167 lines
3.2 KiB
C

// netgen网格生成库的C++接口,传入边界、井筒、裂缝、断层和复合区,生成二维三角形网格。
// 作者:万义钊
// 日期2025年1月28日除夕
// 版本1.0
#pragma once
namespace nglib
{
#include "nglib.h"
}
using namespace nglib;
#include <iostream>
#include <string>
#include <vector>
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<double> 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<int> pointIndices;
std::vector<double> 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<Point> 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<Segment> vecSegments; // 边
// 表示圆形
Point cCenter;
double dRadius;
int nNodeNum;
BOUND_TYPE boundType;
};
// 多边形,内部的复合区域
class CBoundPolygon : public CBoundShape
{
public:
int nNumSegs; // 边的数量
std::vector<Segment> 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<Frac> vecFracs;//压裂裂缝
};
#ifdef __cplusplus
extern "C"
{
#endif
__declspec(dllexport) Ng_Mesh *NgMeshGen2D(std::string strFileIn2D);
__declspec(dllexport) Ng_Mesh *NgMeshGen2DByIn2d(std::vector<CBoundWell> wells, std::vector<CBoundPolygon> limits, std::vector<CBoundPolygon> faults, std::vector<Frac> fracs, CBoundShape shape);
__declspec(dllexport) void Ng2VTK(Ng_Mesh *mesh);
#ifdef __cplusplus
}
#endif