parent faces

This commit is contained in:
Joachim Schoeberl 2021-02-17 23:32:15 +01:00
parent 87e472b6fc
commit e9e3d52b45
5 changed files with 84 additions and 38 deletions

View File

@ -345,6 +345,8 @@ namespace netgen
void Curve (int order); void Curve (int order);
int GetCurveOrder (); int GetCurveOrder ();
void EnableTable (string name, bool set);
void Refine (NG_REFINEMENT_TYPE reftype, void Refine (NG_REFINEMENT_TYPE reftype,
void (*taskmanager)(function<void(int,int)>) = &DummyTaskManager2, void (*taskmanager)(function<void(int,int)>) = &DummyTaskManager2,
void (*tracer)(string, bool) = &DummyTracer2); void (*tracer)(string, bool) = &DummyTracer2);

View File

@ -1137,6 +1137,13 @@ namespace netgen
return mesh->GetCurvedElements().GetOrder(); return mesh->GetCurvedElements().GetOrder();
} }
void Ngx_Mesh :: EnableTable (string name, bool set)
{
mesh->GetTopology().EnableTable (name, set);
}
template <> template <>
DLL_HEADER void Ngx_Mesh :: SetRefinementFlag<2> (size_t elnr, bool flag) DLL_HEADER void Ngx_Mesh :: SetRefinementFlag<2> (size_t elnr, bool flag)
{ {

View File

@ -1129,15 +1129,20 @@ project_boundaries : Optional[str] = None
.def ("EnableTable", [] (Mesh & self, string name, bool set) .def ("EnableTable", [] (Mesh & self, string name, bool set)
{ {
const_cast<MeshTopology&>(self.GetTopology()).EnableTable(name, set);
/*
if (name == "edges") if (name == "edges")
const_cast<MeshTopology&>(self.GetTopology()).SetBuildEdges(set); const_cast<MeshTopology&>(self.GetTopology()).SetBuildEdges(set);
else if (name == "faces") else if (name == "faces")
const_cast<MeshTopology&>(self.GetTopology()).SetBuildFaces(set); const_cast<MeshTopology&>(self.GetTopology()).SetBuildFaces(set);
else if (name == "parentedges") else if (name == "parentedges")
const_cast<MeshTopology&>(self.GetTopology()).SetBuildHierarchy(set); const_cast<MeshTopology&>(self.GetTopology()).SetBuildParentEdges(set);
else if (name == "parentfaces")
const_cast<MeshTopology&>(self.GetTopology()).SetBuildParentFaces(set);
else else
throw Exception ("noting known about table "+name +"\n" throw Exception ("noting known about table "+name +"\n"
"knwon are 'edges', 'faces', 'parentedges'"); "knwon are 'edges', 'faces', 'parentedges', 'parentfaces'");
*/
}, },
py::arg("name"), py::arg("set")=true) py::arg("name"), py::arg("set")=true)

View File

@ -55,6 +55,24 @@ namespace netgen
bool MeshTopology :: NeedsUpdate() const bool MeshTopology :: NeedsUpdate() const
{ return (timestamp <= mesh->GetTimeStamp()); } { return (timestamp <= mesh->GetTimeStamp()); }
void MeshTopology :: EnableTable (string name, bool set)
{
if (name == "edges")
SetBuildEdges(set);
else if (name == "faces")
SetBuildFaces(set);
else if (name == "parentedges")
SetBuildParentEdges(set);
else if (name == "parentfaces")
SetBuildParentFaces(set);
else
throw Exception ("noting known about table "+name +"\n"
"knwon are 'edges', 'faces', 'parentedges', 'parentfaces'");
}
template <typename FUNC> template <typename FUNC>
void LoopOverEdges (const Mesh & mesh, MeshTopology & top, PointIndex v, void LoopOverEdges (const Mesh & mesh, MeshTopology & top, PointIndex v,
FUNC func) FUNC func)
@ -679,7 +697,7 @@ namespace netgen
} ); } );
if (build_hierarchy) if (build_parent_edges)
{ {
static Timer t("build_hierarchy"); RegionTimer reg(t); static Timer t("build_hierarchy"); RegionTimer reg(t);
cnt = 0; cnt = 0;
@ -1438,10 +1456,12 @@ namespace netgen
// NgProfiler::StopTimer (timer2c); // NgProfiler::StopTimer (timer2c);
if (build_hierarchy) if (build_parent_faces)
{ {
// tets only // tets only
cout << "build face hierarchy:" << endl;
cout << "f2v = " << face2vert << endl;
ngcore::ClosedHashTable<INT<3>, int> v2f(nv); ngcore::ClosedHashTable<INT<3>, int> v2f(nv);
for (auto i : Range(face2vert)) for (auto i : Range(face2vert))
{ {
@ -1459,38 +1479,49 @@ namespace netgen
for (auto i : Range(nfa)) for (auto i : Range(nfa))
{ {
INT<3,PointIndex> f3(face2vert[i][0], face2vert[i][1], face2vert[i][2]); INT<3,PointIndex> f3(face2vert[i][0], face2vert[i][1], face2vert[i][2]);
PointIndex vmax = Max(f3);
if (vmax >= mesh->mlbetweennodes.Size()+PointIndex::BASE)
continue;
auto parents = mesh->mlbetweennodes[vmax];
// is face part of one parent face (boundary-face) ? // find a vertex, such that one of its parent is a trig vertex
for (int j = 0; j < 2; j++)
for (int k = 0; k < 3; k++)
{ {
if (f3.Contains(parents[j])) PointIndex v3 = f3[k];
if (v3 >= mesh->mlbetweennodes.Size()+PointIndex::BASE)
continue;
auto parents = mesh->mlbetweennodes[v3];
// is face part of one parent face (boundary-face) ?
for (int j = 0; j < 2; j++)
{ {
PointIndex v0 = parents[j]; if (f3.Contains(parents[j]))
PointIndex v1 = parents[1-j]; {
PointIndex v0 = parents[j];
// the third one, on the tip PointIndex v1 = parents[1-j];
PointIndex v2 = f3[0]+f3[1]+f3[2] - v0 - v1;
// the third one, on the tip
int classnr = 0; PointIndex v2 = f3[0]+f3[1]+f3[2] - v0 - v3;
if (v0 > v1) { Swap (v0, v1); classnr += 1; }
if (v1 > v2) { Swap (v1, v2); classnr += 2; } INT<3> parentverts(v0, v1, v2);
if (v0 > v1) { Swap (v0, v1); classnr += 4; } parentverts.Sort();
INT<3> parentverts(v0, v1, v2);
int pafacenr = v2f[parentverts]; int classnr = 0;
cout << "parent-face = " << pafacenr << endl; if (v2 > v3) { Swap (v2, v3); classnr += 1; }
parent_faces[i] = { classnr, { pafacenr, -1, -1, -1 } }; if (v0 > v1) { Swap (v0, v1); classnr += 2; }
if (v1 > v2) { Swap (v1, v2); classnr += 4; }
if (v0 > v1) { Swap (v0, v1); classnr += 8; }
if (v2f.Used(parentverts))
{
int pafacenr = v2f[parentverts];
cout << "parent-face = " << pafacenr << endl;
parent_faces[i] = { classnr, { pafacenr, -1, -1, -1 } };
}
}
} }
} }
} }
} }
} }

View File

@ -45,7 +45,8 @@ class MeshTopology
const Mesh * mesh; const Mesh * mesh;
bool buildedges; bool buildedges;
bool buildfaces; bool buildfaces;
bool build_hierarchy = false; // may be changed to default = false bool build_parent_edges = false; // may be changed to default = false
bool build_parent_faces = false; // may be changed to default = false
NgArray<INDEX_2> edge2vert; NgArray<INDEX_2> edge2vert;
NgArray<INDEX_4> face2vert; NgArray<INDEX_4> face2vert;
@ -80,14 +81,14 @@ public:
{ buildedges = be; } { buildedges = be; }
void SetBuildFaces (bool bf) void SetBuildFaces (bool bf)
{ buildfaces = bf; } { buildfaces = bf; }
void SetBuildHierarchy (bool bh) { build_hierarchy = bh; } void SetBuildParentEdges (bool bh) { build_parent_edges = bh; }
void SetBuildParentFaces (bool bh) { build_parent_faces = bh; }
bool HasEdges () const void EnableTable (string name, bool set);
{ return buildedges; }
bool HasFaces () const bool HasEdges () const { return buildedges; }
{ return buildfaces; } bool HasFaces () const { return buildfaces; }
bool HasParentEdges () const bool HasParentEdges () const { return build_parent_edges; }
{ return build_hierarchy; }
void Update(NgTaskManager tm = &DummyTaskManager, NgTracer tracer = &DummyTracer); void Update(NgTaskManager tm = &DummyTaskManager, NgTracer tracer = &DummyTracer);
bool NeedsUpdate() const; bool NeedsUpdate() const;