|
|
|
|
|
// netgen-2010.cpp : <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̨Ӧ<CCA8>ó<EFBFBD><C3B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڵ㡣
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
|
|
#include "stdafx.h"
|
|
|
|
|
|
#include "../meshgene/netgenmesh.h"
|
|
|
|
|
|
#include "windows.h"
|
|
|
|
|
|
std::vector<Point> calculateRectangleVertices(
|
|
|
|
|
|
Point p1, // <20><><EFBFBD><EFBFBD>
|
|
|
|
|
|
Point p2, // <20>յ<EFBFBD>
|
|
|
|
|
|
double width // <20><><EFBFBD>ο<EFBFBD><CEBF><EFBFBD>
|
|
|
|
|
|
)
|
|
|
|
|
|
{
|
|
|
|
|
|
double dx = p2.x - p1.x;
|
|
|
|
|
|
double dy = p2.y - p1.y;
|
|
|
|
|
|
double length = std::sqrt(dx * dx + dy * dy);
|
|
|
|
|
|
|
|
|
|
|
|
if (length == 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>յ<EFBFBD><D5B5>غϣ<D8BA><CFA3><EFBFBD><DEB7><EFBFBD><EFBFBD>ɾ<EFBFBD><C9BE><EFBFBD>
|
|
|
|
|
|
return std::vector<Point>();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// <20><>λ<EFBFBD><CEBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ࣩ
|
|
|
|
|
|
double nx = -dy / length;
|
|
|
|
|
|
double ny = dx / length;
|
|
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD>ƫ<EFBFBD><C6AB>
|
|
|
|
|
|
double half_width = width / 2;
|
|
|
|
|
|
double offset_x = half_width * nx;
|
|
|
|
|
|
double offset_y = half_width * ny;
|
|
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>ĸ<EFBFBD><C4B8><EFBFBD><EFBFBD>㣨<EFBFBD><E3A3A8>ʱ<EFBFBD><CAB1>˳<EFBFBD><CBB3><EFBFBD><EFBFBD>
|
|
|
|
|
|
std::vector<Point> vertices(4);
|
|
|
|
|
|
vertices[0] = Point(p1.x + offset_x, p1.y + offset_y); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
vertices[1] = Point(p1.x - offset_x, p1.y - offset_y); // <20><><EFBFBD><EFBFBD><EFBFBD>Ҳ<EFBFBD>
|
|
|
|
|
|
vertices[2] = Point(p2.x - offset_x, p2.y - offset_y); // <20>յ<EFBFBD><D5B5>Ҳ<EFBFBD>
|
|
|
|
|
|
vertices[3] = Point(p2.x + offset_x, p2.y + offset_y); // <20>յ<EFBFBD><D5B5><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
|
|
return vertices;
|
|
|
|
|
|
}
|
|
|
|
|
|
int _tmain(int argc, _TCHAR *argv[])
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
HMODULE hMod = LoadLibrary("meshgene.dll");
|
|
|
|
|
|
if (NULL == hMod)
|
|
|
|
|
|
{
|
|
|
|
|
|
std::cout << "meshgene.dll<6C><6C><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>\n";
|
|
|
|
|
|
return 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
CBoundShape shape;
|
|
|
|
|
|
shape.boundShape = POLYGON;
|
|
|
|
|
|
shape.nNumSegs = 4;
|
|
|
|
|
|
Segment seg1;
|
|
|
|
|
|
seg1.p1 = Point(-1000, -1000);
|
|
|
|
|
|
seg1.p2 = Point(1000, -1000);
|
|
|
|
|
|
Segment seg2;
|
|
|
|
|
|
seg2.p1 = Point(1000, -1000);
|
|
|
|
|
|
seg2.p2 = Point(1000, 1000);
|
|
|
|
|
|
Segment seg3;
|
|
|
|
|
|
seg3.p1 = Point(1000, 1000);
|
|
|
|
|
|
seg3.p2 = Point(-1000, 1000);
|
|
|
|
|
|
Segment seg4;
|
|
|
|
|
|
seg4.p1 = Point(-1000, 1000);
|
|
|
|
|
|
seg4.p2 = Point(-1000, -1000);
|
|
|
|
|
|
|
|
|
|
|
|
shape.vecSegments.push_back(seg1);
|
|
|
|
|
|
shape.vecSegments.push_back(seg2);
|
|
|
|
|
|
shape.vecSegments.push_back(seg3);
|
|
|
|
|
|
shape.vecSegments.push_back(seg4);
|
|
|
|
|
|
|
|
|
|
|
|
shape.cCenter = Point(0, 0);
|
|
|
|
|
|
shape.dRadius = 1000;
|
|
|
|
|
|
|
|
|
|
|
|
CBoundWell w1, w2;
|
|
|
|
|
|
w1.cCenter = Point(-10, 0);
|
|
|
|
|
|
w1.dRadius = 0.1;
|
|
|
|
|
|
|
|
|
|
|
|
w2.wellType=VERTICAL_FRACTURED;
|
|
|
|
|
|
w2.dHf=10;
|
|
|
|
|
|
w2.dTheata=30;
|
|
|
|
|
|
w2.cCenter = Point(50, 0);
|
|
|
|
|
|
w2.dRadius = 0.1;
|
|
|
|
|
|
|
|
|
|
|
|
CBoundWell w3;
|
|
|
|
|
|
w3.wellType=MULTI_FRACED_HORIZONTAL;
|
|
|
|
|
|
w3.cCenter=Point(142,-226);
|
|
|
|
|
|
w3.dBeta=20;
|
|
|
|
|
|
w3.dLength=200;
|
|
|
|
|
|
w3.nFracNum=10;
|
|
|
|
|
|
w3.dHf=10;
|
|
|
|
|
|
|
|
|
|
|
|
std::vector<CBoundWell> wells;
|
|
|
|
|
|
wells.push_back(w1);
|
|
|
|
|
|
wells.push_back(w2);
|
|
|
|
|
|
wells.push_back(w3);
|
|
|
|
|
|
|
|
|
|
|
|
CBoundPolygon limit;
|
|
|
|
|
|
limit.boundShape = POLYGON;
|
|
|
|
|
|
limit.nNumSegs = 5;
|
|
|
|
|
|
limit.vecSegments.push_back(Segment(Point(-516.2335347838829, -58.37577524138442), Point(-592.72401802758, -180.9965861656542)));
|
|
|
|
|
|
limit.vecSegments.push_back(Segment(Point(-592.72401802758, -180.9965861656542), Point(-485.12090993338666, -280.2195626173259)));
|
|
|
|
|
|
limit.vecSegments.push_back(Segment(Point(-485.12090993338666, -280.2195626173259), Point(-328.9162066043042, -229.04373034669038)));
|
|
|
|
|
|
limit.vecSegments.push_back(Segment(Point(-328.9162066043042, -229.04373034669038), Point(-376.36137535544276, -90.33591813134171)));
|
|
|
|
|
|
limit.vecSegments.push_back(Segment(Point(-376.36137535544276, -90.33591813134171), Point(-516.2335347838829, -58.37577524138442)));
|
|
|
|
|
|
std::vector<CBoundPolygon> limits;
|
|
|
|
|
|
limits.push_back(limit);
|
|
|
|
|
|
|
|
|
|
|
|
CBoundPolygon fault;
|
|
|
|
|
|
std::vector<CBoundPolygon> faults;
|
|
|
|
|
|
Point fp1(-267.3, 174.8);
|
|
|
|
|
|
Point fp2(316.7, 178.6);
|
|
|
|
|
|
std::vector<Point> vertices = calculateRectangleVertices(fp1, fp2, 0.2);
|
|
|
|
|
|
|
|
|
|
|
|
fault.boundShape = POLYGON;
|
|
|
|
|
|
fault.nNumSegs = 4;
|
|
|
|
|
|
for (int i = 0; i < 3; ++i)
|
|
|
|
|
|
{
|
|
|
|
|
|
fault.vecSegments.push_back(Segment(vertices[i], vertices[i + 1]));
|
|
|
|
|
|
}
|
|
|
|
|
|
fault.vecSegments.push_back(Segment(vertices[3], vertices[0]));
|
|
|
|
|
|
|
|
|
|
|
|
faults.push_back(fault);
|
|
|
|
|
|
|
|
|
|
|
|
std::vector<Frac> fracs;
|
|
|
|
|
|
// fracs.push_back(Frac(Point(-295.4590458689436, 135.24645349343746), Point(161.25020791914517, 312.55990051563924)));
|
|
|
|
|
|
fracs.push_back(Frac(Point(-326.1597927937205, 460.0597222992292), Point(165.83631020744383, 459.08547259031593)));
|
|
|
|
|
|
fracs.push_back(Frac(Point(37.37000102969455, -657.4918218469559), Point(358.8407220536865, -289.8115658489835)));
|
|
|
|
|
|
|
|
|
|
|
|
typedef Ng_Mesh *(*NgMeshGen2DByIn2d)(std::vector<CBoundWell> wells, std::vector<CBoundPolygon> limits, std::vector<CBoundPolygon> faults, std::vector<Frac> fracs, CBoundShape shape);
|
|
|
|
|
|
// Get the address of the Ng_Mesh function
|
|
|
|
|
|
NgMeshGen2DByIn2d meshgene1 = (NgMeshGen2DByIn2d)GetProcAddress(hMod, "NgMeshGen2DByIn2d");
|
|
|
|
|
|
if (NULL == meshgene1)
|
|
|
|
|
|
{
|
|
|
|
|
|
FreeLibrary(hMod);
|
|
|
|
|
|
std::cout << "meshgene<EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>غ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD>ȡʧ<EFBFBD>ܣ<EFBFBD>\n";
|
|
|
|
|
|
return 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
Ng_Mesh *mesh = meshgene1(wells, limits, faults, fracs, shape);
|
|
|
|
|
|
|
|
|
|
|
|
typedef void *(*Ng2VTK)(Ng_Mesh *);
|
|
|
|
|
|
Ng2VTK mesh2vtk = (Ng2VTK)GetProcAddress(hMod, "Ng2VTK");
|
|
|
|
|
|
if (NULL == mesh2vtk)
|
|
|
|
|
|
{
|
|
|
|
|
|
FreeLibrary(hMod);
|
|
|
|
|
|
std::cout << "Ng2VTK<EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>غ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD>ȡʧ<EFBFBD>ܣ<EFBFBD>\n";
|
|
|
|
|
|
return 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
mesh2vtk(mesh);
|
|
|
|
|
|
|
|
|
|
|
|
FreeLibrary(hMod);
|
|
|
|
|
|
}
|