mirror of
https://github.com/NGSolve/netgen.git
synced 2024-12-25 05:20:34 +05:00
Merge branch 'split_faces_by_adjacent_domains' into 'master'
Utility function to split faces when they have more than two adjacent domains See merge request ngsolve/netgen!633
This commit is contained in:
commit
2e80cb34b6
@ -7152,6 +7152,53 @@ namespace netgen
|
|||||||
SetNextMajorTimeStamp();
|
SetNextMajorTimeStamp();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Mesh :: SplitFacesByAdjacentDomains ()
|
||||||
|
{
|
||||||
|
UpdateTopology();
|
||||||
|
std::map<std::tuple<int, int, int>, int> face_doms_2_new_face;
|
||||||
|
int nfaces = FaceDescriptors().Size();
|
||||||
|
Array<bool> first_visit(nfaces);
|
||||||
|
first_visit = true;
|
||||||
|
|
||||||
|
for (auto sei : Range(SurfaceElements()))
|
||||||
|
{
|
||||||
|
int eli0, eli1;
|
||||||
|
GetTopology().GetSurface2VolumeElement(sei+1, eli0, eli1);
|
||||||
|
auto & sel = (*this)[sei];
|
||||||
|
int face = sel.GetIndex();
|
||||||
|
int domin = VolumeElement(eli0).GetIndex();
|
||||||
|
int domout = eli1 ? VolumeElement(eli1).GetIndex() : 0;
|
||||||
|
if(domin < domout)
|
||||||
|
swap(domin, domout);
|
||||||
|
auto key = std::make_tuple(face, domin, domout);
|
||||||
|
if(face_doms_2_new_face.find(key) == face_doms_2_new_face.end())
|
||||||
|
{
|
||||||
|
if(!first_visit[face-1]) {
|
||||||
|
nfaces++;
|
||||||
|
FaceDescriptor new_fd = FaceDescriptors()[face-1];
|
||||||
|
new_fd.bcprop = nfaces;
|
||||||
|
new_fd.domin = domin;
|
||||||
|
new_fd.domout = domout;
|
||||||
|
AddFaceDescriptor(new_fd);
|
||||||
|
SetBCName(nfaces-1, new_fd.GetBCName());
|
||||||
|
face_doms_2_new_face[key] = nfaces;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
face_doms_2_new_face[key] = face;
|
||||||
|
auto & fd = FaceDescriptors()[face-1];
|
||||||
|
fd.domin = domin;
|
||||||
|
fd.domout = domout;
|
||||||
|
}
|
||||||
|
first_visit[face-1] = false;
|
||||||
|
}
|
||||||
|
sel.SetIndex(face_doms_2_new_face[key]);
|
||||||
|
}
|
||||||
|
SetNextMajorTimeStamp();
|
||||||
|
RebuildSurfaceElementLists ();
|
||||||
|
CalcSurfacesOfNode();
|
||||||
|
UpdateTopology();
|
||||||
|
}
|
||||||
|
|
||||||
void Mesh :: SetMaterial (int domnr, const string & mat)
|
void Mesh :: SetMaterial (int domnr, const string & mat)
|
||||||
{
|
{
|
||||||
if (domnr > materials.Size())
|
if (domnr > materials.Size())
|
||||||
|
@ -699,6 +699,8 @@ namespace netgen
|
|||||||
auto & GetCommunicator() const { return this->comm; }
|
auto & GetCommunicator() const { return this->comm; }
|
||||||
void SetCommunicator(NgMPI_Comm acomm);
|
void SetCommunicator(NgMPI_Comm acomm);
|
||||||
|
|
||||||
|
DLL_HEADER void SplitFacesByAdjacentDomains();
|
||||||
|
|
||||||
///
|
///
|
||||||
DLL_HEADER void SetMaterial (int domnr, const string & mat);
|
DLL_HEADER void SetMaterial (int domnr, const string & mat);
|
||||||
///
|
///
|
||||||
|
@ -1250,6 +1250,7 @@ DLL_HEADER void ExportNetgenMeshing(py::module &m)
|
|||||||
|
|
||||||
.def ("GetCD3Name", &Mesh::GetCD3Name)
|
.def ("GetCD3Name", &Mesh::GetCD3Name)
|
||||||
.def ("SetCD3Name", &Mesh::SetCD3Name)
|
.def ("SetCD3Name", &Mesh::SetCD3Name)
|
||||||
|
.def ("SplitFacesByAdjacentDomains", &Mesh::SplitFacesByAdjacentDomains)
|
||||||
.def("GetIdentifications", [](Mesh & self) -> py::list
|
.def("GetIdentifications", [](Mesh & self) -> py::list
|
||||||
{
|
{
|
||||||
py::list points;
|
py::list points;
|
||||||
|
Loading…
Reference in New Issue
Block a user