correctly set domin and domout at sides

This commit is contained in:
Christopher Lackner 2023-03-30 23:21:58 +02:00
parent 5b4af26d7d
commit 9c1db9a6f3
2 changed files with 32 additions and 7 deletions

View File

@ -613,9 +613,6 @@ namespace netgen
surfacefacs.SetSize(nfd_old+1); surfacefacs.SetSize(nfd_old+1);
surfacefacs = 0.0; surfacefacs = 0.0;
// create new FaceDescriptors // create new FaceDescriptors
domain_map.SetSize(mesh.GetNDomains()+1);
for(auto i : Range(mesh.GetNDomains()+1))
domain_map[i] = i;
for(auto i : Range(1, nfd_old+1)) for(auto i : Range(1, nfd_old+1))
{ {
const auto& fd = mesh.GetFaceDescriptor(i); const auto& fd = mesh.GetFaceDescriptor(i);
@ -629,7 +626,6 @@ namespace netgen
// -1 surf nr is so that curving does not do anything // -1 surf nr is so that curving does not do anything
FaceDescriptor new_fd(-1, isIn ? new_mat_nrs[i] : fd.DomainIn(), FaceDescriptor new_fd(-1, isIn ? new_mat_nrs[i] : fd.DomainIn(),
isIn ? fd.DomainOut() : new_mat_nrs[i], -1); isIn ? fd.DomainOut() : new_mat_nrs[i], -1);
domain_map[isIn ? fd.DomainIn() : fd.DomainOut()] = new_mat_nrs[i];
new_fd.SetBCProperty(new_si); new_fd.SetBCProperty(new_si);
mesh.AddFaceDescriptor(new_fd); mesh.AddFaceDescriptor(new_fd);
si_map[i] = new_si; si_map[i] = new_si;
@ -665,8 +661,9 @@ namespace netgen
auto isIn = domains.Test(fd.DomainIn()); auto isIn = domains.Test(fd.DomainIn());
auto isOut = domains.Test(fd.DomainOut()); auto isOut = domains.Test(fd.DomainOut());
int si = params.sides_keep_surfaceindex ? facei : -1; int si = params.sides_keep_surfaceindex ? facei : -1;
FaceDescriptor new_fd(si, domain_map[fd.DomainIn()], // domin and domout can only be set later
domain_map[fd.DomainOut()], si); FaceDescriptor new_fd(si, -1,
-1, si);
new_fd.SetBCProperty(new_si); new_fd.SetBCProperty(new_si);
mesh.AddFaceDescriptor(new_fd); mesh.AddFaceDescriptor(new_fd);
si_map[facei] = new_si; si_map[facei] = new_si;
@ -1371,6 +1368,33 @@ namespace netgen
} }
} }
void BoundaryLayerTool :: SetDomInOutSides()
{
BitArray done(mesh.GetNFD()+1);
done.Clear();
for(auto sei : Range(mesh.SurfaceElements()))
{
auto& sel = mesh[sei];
auto index = sel.GetIndex();
if(done.Test(index))
continue;
done.SetBit(index);
auto& fd = mesh.GetFaceDescriptor(index);
if(fd.DomainIn() != -1)
continue;
int e1, e2;
mesh.GetTopology().GetSurface2VolumeElement(sei+1, e1, e2);
if(e1 == 0)
fd.SetDomainIn(0);
else
fd.SetDomainIn(mesh.VolumeElement(e1).GetIndex());
if(e2 == 0)
fd.SetDomainOut(0);
else
fd.SetDomainOut(mesh.VolumeElement(e2).GetIndex());
}
}
void BoundaryLayerTool :: AddSegments() void BoundaryLayerTool :: AddSegments()
{ {
if(have_single_segments) if(have_single_segments)
@ -1451,6 +1475,7 @@ namespace netgen
mesh.GetTopology().ClearEdges(); mesh.GetTopology().ClearEdges();
mesh.SetNextMajorTimeStamp(); mesh.SetNextMajorTimeStamp();
mesh.UpdateTopology(); mesh.UpdateTopology();
SetDomInOutSides();
MeshingParameters mp; MeshingParameters mp;
mp.optimize3d ="m"; mp.optimize3d ="m";
mp.optsteps3d = 4; mp.optsteps3d = 4;

View File

@ -45,7 +45,6 @@ class BoundaryLayerTool
Array<SegmentIndex> moved_segs; Array<SegmentIndex> moved_segs;
int max_edge_nr, nfd_old, ndom_old; int max_edge_nr, nfd_old, ndom_old;
Array<int> new_mat_nrs; Array<int> new_mat_nrs;
Array<int> domain_map;
BitArray moved_surfaces; BitArray moved_surfaces;
int np, nseg, nse, ne; int np, nseg, nse, ne;
double height; double height;
@ -70,6 +69,7 @@ class BoundaryLayerTool
void InsertNewElements(FlatArray<Array<pair<SegmentIndex, int>>, SegmentIndex> segmap, const BitArray & in_surface_direction); void InsertNewElements(FlatArray<Array<pair<SegmentIndex, int>>, SegmentIndex> segmap, const BitArray & in_surface_direction);
void SetDomInOut(); void SetDomInOut();
void SetDomInOutSides();
void AddSegments(); void AddSegments();
void FixVolumeElements(); void FixVolumeElements();