mirror of
https://github.com/NGSolve/netgen.git
synced 2025-01-26 21:00:34 +05:00
1d mesh with 0d boundary elements
This commit is contained in:
parent
4176c41670
commit
3a937d1f36
@ -7,7 +7,7 @@ NGX_INLINE DLL_HEADER Ng_Point Ngx_Mesh :: GetPoint (int nr) const
|
||||
template <>
|
||||
NGX_INLINE DLL_HEADER int Ngx_Mesh :: GetElementIndex<0> (int nr) const
|
||||
{
|
||||
return 0;
|
||||
return (*mesh).pointelements[nr].index;
|
||||
}
|
||||
|
||||
template <>
|
||||
@ -29,6 +29,33 @@ NGX_INLINE DLL_HEADER int Ngx_Mesh :: GetElementIndex<3> (int nr) const
|
||||
return (*mesh)[ElementIndex(nr)].GetIndex();
|
||||
}
|
||||
|
||||
|
||||
template <>
|
||||
NGX_INLINE DLL_HEADER Ng_Element Ngx_Mesh :: GetElement<0> (int nr) const
|
||||
{
|
||||
const Element0d & el = mesh->pointelements[nr];
|
||||
|
||||
Ng_Element ret;
|
||||
ret.type = NG_PNT;
|
||||
ret.index = el.index;
|
||||
|
||||
ret.points.num = 1;
|
||||
ret.points.ptr = (int*)&el.pnum;
|
||||
|
||||
ret.vertices.num = 1;
|
||||
ret.vertices.ptr = (int*)&el.pnum;
|
||||
|
||||
ret.edges.num = 0;
|
||||
ret.edges.ptr = NULL;
|
||||
|
||||
ret.faces.num = 0;
|
||||
ret.faces.ptr = NULL;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
template <>
|
||||
NGX_INLINE DLL_HEADER Ng_Element Ngx_Mesh :: GetElement<1> (int nr) const
|
||||
{
|
||||
|
@ -120,7 +120,7 @@ namespace netgen
|
||||
{
|
||||
switch (dim)
|
||||
{
|
||||
case 0: return 0; // mesh -> GetNV();
|
||||
case 0: return mesh -> pointelements.Size();
|
||||
case 1: return mesh -> GetNSeg();
|
||||
case 2: return mesh -> GetNSE();
|
||||
case 3: return mesh -> GetNE();
|
||||
@ -147,13 +147,30 @@ namespace netgen
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
template <> DLL_HEADER Ng_Element Ngx_Mesh :: GetElement<0> (int nr) const
|
||||
{
|
||||
cout << "Netgen does not support 0-D elements" << endl;
|
||||
Ng_Element ret;
|
||||
return ret;
|
||||
}
|
||||
const Element0d & el = mesh->pointelements[nr];
|
||||
|
||||
Ng_Element ret;
|
||||
ret.type = NG_PNT;
|
||||
ret.index = el.index;
|
||||
|
||||
ret.points.num = 1;
|
||||
ret.points.ptr = (int*)&el.pnum;
|
||||
|
||||
ret.vertices.num = 1;
|
||||
ret.vertices.ptr = (int*)&el.pnum;
|
||||
|
||||
ret.edges.num = 0;
|
||||
ret.edges.ptr = NULL;
|
||||
|
||||
ret.faces.num = 0;
|
||||
ret.faces.ptr = NULL;
|
||||
|
||||
return ret;
|
||||
}
|
||||
*/
|
||||
/*
|
||||
template <> DLL_HEADER Ng_Element Ngx_Mesh :: GetElement<1> (int nr) const
|
||||
{
|
||||
@ -508,7 +525,9 @@ namespace netgen
|
||||
double * x,
|
||||
double * dxdxi) const
|
||||
{
|
||||
cout << "1D not supported" << endl;
|
||||
PointIndex pnum = mesh->pointelements[elnr].pnum;
|
||||
if (x) x[0] = (*mesh)[pnum](0);
|
||||
if (dxdxi) dxdxi[0] = 0;
|
||||
}
|
||||
|
||||
|
||||
@ -574,7 +593,8 @@ namespace netgen
|
||||
double * x, size_t sx,
|
||||
double * dxdxi, size_t sdxdxi) const
|
||||
{
|
||||
cout << "1D not supported" << endl;
|
||||
for (int i = 0; i < npts; i++)
|
||||
ElementTransformation<0,1> (elnr, xi + i*sxi, x+i*sx, dxdxi+i*sdxdxi);
|
||||
}
|
||||
|
||||
|
||||
|
@ -247,9 +247,8 @@ namespace netgen
|
||||
|
||||
const Array<Segment> & LineSegments() const { return segments; }
|
||||
Array<Segment> & LineSegments() { return segments; }
|
||||
|
||||
|
||||
|
||||
|
||||
Array<Element0d> pointelements; // only via python interface
|
||||
|
||||
DLL_HEADER SurfaceElementIndex AddSurfaceElement (const Element2d & el);
|
||||
void DeleteSurfaceElement (int eli)
|
||||
|
@ -914,6 +914,11 @@ namespace netgen
|
||||
|
||||
|
||||
|
||||
ostream & operator<<(ostream & s, const Element0d & el)
|
||||
{
|
||||
s << el.pnum << ", index = " << el.index;
|
||||
return s;
|
||||
}
|
||||
|
||||
|
||||
ostream & operator<<(ostream & s, const Element2d & el)
|
||||
|
@ -907,7 +907,14 @@ namespace netgen
|
||||
ostream & operator<<(ostream & s, const Segment & seg);
|
||||
|
||||
|
||||
class Element0d
|
||||
{
|
||||
public:
|
||||
PointIndex pnum;
|
||||
int index;
|
||||
};
|
||||
|
||||
ostream & operator<<(ostream & s, const Element0d & el);
|
||||
|
||||
// class Surface;
|
||||
// class FaceDescriptor;
|
||||
|
@ -208,7 +208,7 @@ DLL_HEADER void ExportNetgenMeshing()
|
||||
)),
|
||||
"create segment element"
|
||||
)
|
||||
.def("__repr__", &ToString<Element>)
|
||||
.def("__repr__", &ToString<Segment>)
|
||||
.add_property("vertices",
|
||||
FunctionPointer ([](const Segment & self) -> bp::list
|
||||
{
|
||||
@ -228,6 +228,33 @@ DLL_HEADER void ExportNetgenMeshing()
|
||||
;
|
||||
|
||||
|
||||
bp::class_<Element0d>("Element0D")
|
||||
.def("__init__", bp::make_constructor
|
||||
(FunctionPointer ([](PointIndex vertex, int index)
|
||||
{
|
||||
Element0d * tmp = new Element0d;
|
||||
tmp->pnum = vertex;
|
||||
tmp->index = index;
|
||||
return tmp;
|
||||
}),
|
||||
bp::default_call_policies(),
|
||||
(bp::arg("vertex"),
|
||||
bp::arg("index")=1
|
||||
)),
|
||||
"create point element"
|
||||
)
|
||||
.def("__repr__", &ToString<Element0d>)
|
||||
.add_property("vertices",
|
||||
FunctionPointer ([](const Element0d & self) -> bp::list
|
||||
{
|
||||
bp::list li;
|
||||
li.append (self.pnum);
|
||||
return li;
|
||||
}))
|
||||
;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
bp::class_<FaceDescriptor>("FaceDescriptor")
|
||||
@ -263,6 +290,7 @@ DLL_HEADER void ExportNetgenMeshing()
|
||||
ExportArray<Element>();
|
||||
ExportArray<Element2d>();
|
||||
ExportArray<Segment>();
|
||||
ExportArray<Element0d>();
|
||||
ExportArray<MeshPoint,PointIndex::BASE,PointIndex>();
|
||||
ExportArray<FaceDescriptor>();
|
||||
;
|
||||
@ -323,6 +351,11 @@ DLL_HEADER void ExportNetgenMeshing()
|
||||
static_cast<Array<Segment>&(Mesh::*)()> (&Mesh::LineSegments),
|
||||
bp::return_value_policy<bp::reference_existing_object>())
|
||||
|
||||
.def("Elements0D", FunctionPointer([] (Mesh & self) -> Array<Element0d>&
|
||||
{
|
||||
return self.pointelements;
|
||||
} ),
|
||||
bp::return_value_policy<bp::reference_existing_object>())
|
||||
|
||||
.def("Points",
|
||||
static_cast<Mesh::T_POINTS&(Mesh::*)()> (&Mesh::Points),
|
||||
@ -355,6 +388,11 @@ DLL_HEADER void ExportNetgenMeshing()
|
||||
{
|
||||
return self.AddSegment (el);
|
||||
}))
|
||||
|
||||
.def ("Add", FunctionPointer ([](Mesh & self, const Element0d & el)
|
||||
{
|
||||
return self.pointelements.Append (el);
|
||||
}))
|
||||
|
||||
.def ("Add", FunctionPointer ([](Mesh & self, const FaceDescriptor & fd)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user