mirror of
https://github.com/NGSolve/netgen.git
synced 2024-12-24 04:50:34 +05:00
meshing from python in 2d
This commit is contained in:
parent
4e258c7b2e
commit
714385724c
@ -356,9 +356,6 @@ DLL_HEADER void ExportCSG()
|
||||
{
|
||||
// testout = new ofstream ("test.out");
|
||||
shared_ptr<Mesh> dummy;
|
||||
cout << "Genrate Mesh" << endl;
|
||||
// cout << "Genrate Mesh, params = " << param << endl;
|
||||
// cout << "geom, bbox = " << geo.BoundingBox() << endl;
|
||||
geo.FindIdenticSurfaces(1e-8 * geo.MaxSize());
|
||||
geo.GenerateMesh (dummy, param, 0, 6);
|
||||
ng_geometry.reset (&geo, NOOP_Deleter);
|
||||
|
@ -9,12 +9,29 @@
|
||||
using namespace netgen;
|
||||
namespace bp = boost::python;
|
||||
|
||||
namespace netgen
|
||||
{
|
||||
extern std::shared_ptr<NetgenGeometry> ng_geometry;
|
||||
}
|
||||
|
||||
|
||||
DLL_HEADER void ExportGeom2d()
|
||||
{
|
||||
ModuleScope module("geom2d");
|
||||
|
||||
bp::class_<SplineGeometry2d, boost::noncopyable>("SplineGeometry")
|
||||
bp::class_<SplineGeometry2d, shared_ptr<SplineGeometry2d>, boost::noncopyable>("SplineGeometry")
|
||||
.def("__init__", bp::make_constructor
|
||||
(FunctionPointer
|
||||
([](const string & filename)
|
||||
{
|
||||
cout << "load geometry";
|
||||
ifstream ist(filename);
|
||||
auto geom = make_shared<SplineGeometry2d>();
|
||||
geom->Load (filename.c_str());
|
||||
ng_geometry = geom;
|
||||
return geom;
|
||||
})))
|
||||
|
||||
.def("Load",&SplineGeometry2d::Load)
|
||||
.def("AppendPoint", FunctionPointer([](SplineGeometry2d &self, double px, double py)
|
||||
{
|
||||
@ -201,10 +218,11 @@ DLL_HEADER void ExportGeom2d()
|
||||
//cout << i << " : " << self.splines[i]->GetPoint(0.1) << " , " << self.splines[i]->GetPoint(0.5) << endl;
|
||||
}
|
||||
}))
|
||||
.def("GenerateMesh", FunctionPointer([](SplineGeometry2d &self, MeshingParameters & mparam)
|
||||
.def("GenerateMesh", FunctionPointer([](shared_ptr<SplineGeometry2d> self, MeshingParameters & mparam)
|
||||
{
|
||||
shared_ptr<Mesh> mesh;
|
||||
self.GenerateMesh(mesh, mparam, 0, 0);
|
||||
shared_ptr<Mesh> mesh = make_shared<Mesh> ();
|
||||
ng_geometry = self;
|
||||
self->GenerateMesh(mesh, mparam, 0, 0);
|
||||
return mesh;
|
||||
}))
|
||||
|
||||
|
@ -15,7 +15,8 @@ extern void Ng_PrintDest(const char * s);
|
||||
//the dots for progression of program
|
||||
void PrintDot(char ch)
|
||||
{
|
||||
if (printdots)
|
||||
// if (printdots)
|
||||
if (printmessage_importance >= 4)
|
||||
{
|
||||
char st[2];
|
||||
st[0] = ch;
|
||||
|
@ -1,4 +1,4 @@
|
||||
install(FILES __init__.py meshing.py csg.py
|
||||
install(FILES __init__.py meshing.py csg.py geom2d.py
|
||||
DESTINATION ${PYTHON_PACKAGES_INSTALL_DIR}/netgen
|
||||
COMPONENT netgen
|
||||
)
|
||||
|
@ -1,3 +1,4 @@
|
||||
python_PYTHON = __init__.py meshing.py csg.py
|
||||
python_PYTHON = __init__.py meshing.py csg.py geom2d.py
|
||||
|
||||
|
||||
|
||||
|
@ -21,8 +21,8 @@ def VS (obj):
|
||||
|
||||
|
||||
|
||||
def csg_meshing_func (geom, maxh):
|
||||
return GenerateMesh (geom, MeshingParameters (maxh=maxh))
|
||||
def csg_meshing_func (geom, **args):
|
||||
return GenerateMesh (geom, MeshingParameters (**args))
|
||||
|
||||
CSGeometry.GenerateMesh = csg_meshing_func
|
||||
|
||||
|
@ -1,11 +1,33 @@
|
||||
from nglib.meshing import *
|
||||
from nglib.geom2d import *
|
||||
|
||||
geom = SplineGeometry()
|
||||
geom.Load("square.in2d")
|
||||
|
||||
param = MeshingParameters()
|
||||
param.maxh = 0.05
|
||||
|
||||
m1 = geom.GenerateMesh (param)
|
||||
|
||||
from netgen import __platform
|
||||
if __platform.startswith('linux') or __platform.startswith('darwin'):
|
||||
# Linux or Mac OS X
|
||||
from libgeom2d.geom2d import *
|
||||
# import libcsgvis.csgvis as csgvis
|
||||
# from libcsgvis.csgvis import MouseMove
|
||||
from libmesh.meshing import *
|
||||
if __platform.startswith('win'):
|
||||
# Windows
|
||||
from nglib.geom2d import *
|
||||
# import nglib.csgvis as csgvis
|
||||
# from nglib.csgvis import MouseMove
|
||||
from nglib.meshing import *
|
||||
|
||||
|
||||
|
||||
|
||||
unit_square = SplineGeometry()
|
||||
pi1 = unit_square.AppendPoint(0,0)
|
||||
pi2 = unit_square.AppendPoint(1,0)
|
||||
pi3 = unit_square.AppendPoint(1,1)
|
||||
pi4 = unit_square.AppendPoint(0,1)
|
||||
unit_square.Append(["line",pi1,pi2], bc=1)
|
||||
unit_square.Append(["line",pi2,pi3], bc=2)
|
||||
unit_square.Append(["line",pi3,pi4], bc=3)
|
||||
unit_square.Append(["line",pi4,pi1], bc=4)
|
||||
|
||||
|
||||
all = ['SplineGeometry', 'unit_square']
|
||||
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user