mirror of
https://github.com/NGSolve/netgen.git
synced 2025-01-27 13:20:34 +05:00
1D meshes
This commit is contained in:
parent
507b370a6f
commit
570d81c8cb
@ -608,6 +608,32 @@ namespace netgen
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template <>
|
||||||
|
DLL_HEADER int Ngx_Mesh :: FindElementOfPoint <1>
|
||||||
|
(double * hp, double * lami,
|
||||||
|
bool build_searchtree,
|
||||||
|
int * const indices, int numind) const
|
||||||
|
|
||||||
|
{
|
||||||
|
if (mesh->GetDimension() != 1)
|
||||||
|
throw NgException("FindElementOfPoint<1> called for multidim mesh");
|
||||||
|
|
||||||
|
Point<3> p(hp[0], 0,0);
|
||||||
|
for (SegmentIndex si = 0; si < mesh->GetNSeg(); si++)
|
||||||
|
{
|
||||||
|
auto & seg = (*mesh)[si];
|
||||||
|
Point<3> p1 = (*mesh)[seg[0]];
|
||||||
|
Point<3> p2 = (*mesh)[seg[1]];
|
||||||
|
double lam = (p(0)-p1(0)) / (p2(0)-p1(0));
|
||||||
|
if (lam >= -1e-10 && lam <= 1+1e-10)
|
||||||
|
{
|
||||||
|
lami[0] = 1-lam;
|
||||||
|
return si;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
DLL_HEADER int Ngx_Mesh :: FindElementOfPoint <2>
|
DLL_HEADER int Ngx_Mesh :: FindElementOfPoint <2>
|
||||||
(double * p, double * lami,
|
(double * p, double * lami,
|
||||||
|
@ -158,18 +158,24 @@ DLL_HEADER void ExportNetgenMeshing()
|
|||||||
|
|
||||||
bp::class_<Segment>("Element1D")
|
bp::class_<Segment>("Element1D")
|
||||||
.def("__init__", bp::make_constructor
|
.def("__init__", bp::make_constructor
|
||||||
(FunctionPointer ([](bp::list vertices, bp::list surfaces)
|
(FunctionPointer ([](bp::list vertices, bp::list surfaces, int index)
|
||||||
{
|
{
|
||||||
Segment * tmp = new Segment;
|
Segment * tmp = new Segment;
|
||||||
for (int i = 0; i < 2; i++)
|
for (int i = 0; i < 2; i++)
|
||||||
(*tmp)[i] = bp::extract<PointIndex>(vertices[i]);
|
(*tmp)[i] = bp::extract<PointIndex>(vertices[i]);
|
||||||
|
tmp -> si = index;
|
||||||
tmp->surfnr1 = bp::extract<int>(surfaces[0]);
|
if (len(surfaces))
|
||||||
tmp->surfnr2 = bp::extract<int>(surfaces[1]);
|
{
|
||||||
|
tmp->surfnr1 = bp::extract<int>(surfaces[0]);
|
||||||
|
tmp->surfnr2 = bp::extract<int>(surfaces[1]);
|
||||||
|
}
|
||||||
return tmp;
|
return tmp;
|
||||||
}),
|
}),
|
||||||
bp::default_call_policies(),
|
bp::default_call_policies(),
|
||||||
(bp::arg("vertices"),bp::arg("surfaces"))),
|
(bp::arg("vertices"),
|
||||||
|
bp::arg("surfaces")=bp::list(),
|
||||||
|
bp::arg("index")=1
|
||||||
|
)),
|
||||||
"create segment element"
|
"create segment element"
|
||||||
)
|
)
|
||||||
.def("__repr__", &ToString<Element>)
|
.def("__repr__", &ToString<Element>)
|
||||||
@ -233,11 +239,16 @@ DLL_HEADER void ExportNetgenMeshing()
|
|||||||
.def("Load", FunctionPointer
|
.def("Load", FunctionPointer
|
||||||
([](Mesh & self, const string & filename)
|
([](Mesh & self, const string & filename)
|
||||||
{
|
{
|
||||||
ifstream input(filename);
|
istream * infile;
|
||||||
self.Load(input);
|
if (filename.find(".vol.gz") != string::npos)
|
||||||
|
infile = new igzstream (filename.c_str());
|
||||||
|
else
|
||||||
|
infile = new ifstream (filename.c_str());
|
||||||
|
// ifstream input(filename);
|
||||||
|
self.Load(*infile);
|
||||||
for (int i = 0; i < geometryregister.Size(); i++)
|
for (int i = 0; i < geometryregister.Size(); i++)
|
||||||
{
|
{
|
||||||
NetgenGeometry * hgeom = geometryregister[i]->LoadFromMeshFile (input);
|
NetgenGeometry * hgeom = geometryregister[i]->LoadFromMeshFile (*infile);
|
||||||
if (hgeom)
|
if (hgeom)
|
||||||
{
|
{
|
||||||
ng_geometry.reset (hgeom);
|
ng_geometry.reset (hgeom);
|
||||||
@ -248,6 +259,8 @@ DLL_HEADER void ExportNetgenMeshing()
|
|||||||
// static_cast<void(Mesh::*)(const string & name)>(&Mesh::Load))
|
// static_cast<void(Mesh::*)(const string & name)>(&Mesh::Load))
|
||||||
.def("Save", static_cast<void(Mesh::*)(const string & name)const>(&Mesh::Save))
|
.def("Save", static_cast<void(Mesh::*)(const string & name)const>(&Mesh::Save))
|
||||||
|
|
||||||
|
.add_property("dim", &Mesh::GetDimension, &Mesh::SetDimension)
|
||||||
|
|
||||||
.def("Elements3D",
|
.def("Elements3D",
|
||||||
static_cast<Array<Element>&(Mesh::*)()> (&Mesh::VolumeElements),
|
static_cast<Array<Element>&(Mesh::*)()> (&Mesh::VolumeElements),
|
||||||
bp::return_value_policy<bp::reference_existing_object>())
|
bp::return_value_policy<bp::reference_existing_object>())
|
||||||
|
Loading…
Reference in New Issue
Block a user