mirror of
https://github.com/NGSolve/netgen.git
synced 2024-11-12 00:59:16 +05:00
Merge branch 'boundarylayer_allow_different_mats' into 'master'
allow different materials in boundarylayer depending on bc name See merge request ngsolve/netgen!539
This commit is contained in:
commit
616c04934a
@ -7,6 +7,7 @@
|
|||||||
#include "../geom2d/csg2d.hpp"
|
#include "../geom2d/csg2d.hpp"
|
||||||
|
|
||||||
#include <set>
|
#include <set>
|
||||||
|
#include <regex>
|
||||||
|
|
||||||
namespace netgen
|
namespace netgen
|
||||||
{
|
{
|
||||||
@ -562,8 +563,22 @@ namespace netgen
|
|||||||
if(seg.edgenr > max_edge_nr)
|
if(seg.edgenr > max_edge_nr)
|
||||||
max_edge_nr = seg.edgenr;
|
max_edge_nr = seg.edgenr;
|
||||||
|
|
||||||
new_mat_nr = mesh.GetNDomains() +1;
|
int ndom = mesh.GetNDomains();
|
||||||
mesh.SetMaterial(new_mat_nr, params.new_mat);
|
ndom_old = ndom;
|
||||||
|
|
||||||
|
new_mat_nrs.SetSize(mesh.FaceDescriptors().Size() + 1);
|
||||||
|
new_mat_nrs = -1;
|
||||||
|
for(auto [bcname, matname] : params.new_mat)
|
||||||
|
{
|
||||||
|
mesh.SetMaterial(++ndom, matname);
|
||||||
|
regex pattern(bcname);
|
||||||
|
for(auto i : Range(1, mesh.GetNFD()+1))
|
||||||
|
{
|
||||||
|
auto& fd = mesh.GetFaceDescriptor(i);
|
||||||
|
if(regex_match(fd.GetBCName(), pattern))
|
||||||
|
new_mat_nrs[i] = ndom;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
domains = params.domains;
|
domains = params.domains;
|
||||||
if(!params.outside)
|
if(!params.outside)
|
||||||
@ -606,8 +621,8 @@ namespace netgen
|
|||||||
int new_si = mesh.GetNFD()+1;
|
int new_si = mesh.GetNFD()+1;
|
||||||
surfacefacs[i] = isIn ? 1. : -1.;
|
surfacefacs[i] = isIn ? 1. : -1.;
|
||||||
// -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_nr : fd.DomainIn(),
|
FaceDescriptor new_fd(-1, isIn ? new_mat_nrs[i] : fd.DomainIn(),
|
||||||
isIn ? fd.DomainOut() : new_mat_nr, -1);
|
isIn ? fd.DomainOut() : new_mat_nrs[i], -1);
|
||||||
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;
|
||||||
@ -1050,7 +1065,7 @@ namespace netgen
|
|||||||
if(surfacefacs[sel.GetIndex()] > 0) Swap(points[0], points[2]);
|
if(surfacefacs[sel.GetIndex()] > 0) Swap(points[0], points[2]);
|
||||||
for(auto i : Range(points))
|
for(auto i : Range(points))
|
||||||
el[sel.PNums().Size() + i] = points[i];
|
el[sel.PNums().Size() + i] = points[i];
|
||||||
el.SetIndex(new_mat_nr);
|
el.SetIndex(new_mat_nrs[sel.GetIndex()]);
|
||||||
mesh.AddVolumeElement(el);
|
mesh.AddVolumeElement(el);
|
||||||
}
|
}
|
||||||
Element2d newel = sel;
|
Element2d newel = sel;
|
||||||
@ -1238,10 +1253,10 @@ namespace netgen
|
|||||||
for(auto i : Range(1, nfd_old+1))
|
for(auto i : Range(1, nfd_old+1))
|
||||||
if(si_map[i] != -1)
|
if(si_map[i] != -1)
|
||||||
{
|
{
|
||||||
if(mesh.GetFaceDescriptor(mesh.GetNFD()).DomainIn() == new_mat_nr)
|
if(auto dom = mesh.GetFaceDescriptor(si_map[i]).DomainIn(); dom > ndom_old)
|
||||||
mesh.GetFaceDescriptor(i).SetDomainOut(new_mat_nr);
|
mesh.GetFaceDescriptor(i).SetDomainOut(dom);
|
||||||
else
|
else
|
||||||
mesh.GetFaceDescriptor(i).SetDomainIn(new_mat_nr);
|
mesh.GetFaceDescriptor(i).SetDomainIn(mesh.GetFaceDescriptor(si_map[i]).DomainOut());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ public:
|
|||||||
// parameters by Philippose ..
|
// parameters by Philippose ..
|
||||||
Array<int> surfid;
|
Array<int> surfid;
|
||||||
Array<double> heights;
|
Array<double> heights;
|
||||||
string new_mat;
|
map<string, string> new_mat;
|
||||||
BitArray domains;
|
BitArray domains;
|
||||||
bool outside = false; // set the boundary layer on the outside
|
bool outside = false; // set the boundary layer on the outside
|
||||||
bool grow_edges = false;
|
bool grow_edges = false;
|
||||||
@ -42,7 +42,8 @@ class BoundaryLayerTool
|
|||||||
|
|
||||||
BitArray domains, is_edge_moved, is_boundary_projected, is_boundary_moved;
|
BitArray domains, is_edge_moved, is_boundary_projected, is_boundary_moved;
|
||||||
Array<SegmentIndex> moved_segs;
|
Array<SegmentIndex> moved_segs;
|
||||||
int max_edge_nr, new_mat_nr, nfd_old;
|
int max_edge_nr, nfd_old, ndom_old;
|
||||||
|
Array<int> new_mat_nrs;
|
||||||
int np, nseg, nse, ne;
|
int np, nseg, nse, ne;
|
||||||
double height;
|
double height;
|
||||||
|
|
||||||
|
@ -1253,7 +1253,7 @@ DLL_HEADER void ExportNetgenMeshing(py::module &m)
|
|||||||
.def ("BoundaryLayer2", GenerateBoundaryLayer2, py::arg("domain"), py::arg("thicknesses"), py::arg("make_new_domain")=true, py::arg("boundaries")=Array<int>{})
|
.def ("BoundaryLayer2", GenerateBoundaryLayer2, py::arg("domain"), py::arg("thicknesses"), py::arg("make_new_domain")=true, py::arg("boundaries")=Array<int>{})
|
||||||
.def ("BoundaryLayer", [](Mesh & self, variant<string, int> boundary,
|
.def ("BoundaryLayer", [](Mesh & self, variant<string, int> boundary,
|
||||||
variant<double, py::list> thickness,
|
variant<double, py::list> thickness,
|
||||||
string material,
|
variant<string, map<string, string>> material,
|
||||||
variant<string, int> domain, bool outside,
|
variant<string, int> domain, bool outside,
|
||||||
optional<string> project_boundaries,
|
optional<string> project_boundaries,
|
||||||
bool grow_edges, bool limit_growth_vectors)
|
bool grow_edges, bool limit_growth_vectors)
|
||||||
@ -1298,7 +1298,10 @@ DLL_HEADER void ExportNetgenMeshing(py::module &m)
|
|||||||
for(int i = 1; i<=self.GetNFD(); i++)
|
for(int i = 1; i<=self.GetNFD(); i++)
|
||||||
if(boundaries.Test(i))
|
if(boundaries.Test(i))
|
||||||
blp.surfid.Append(i);
|
blp.surfid.Append(i);
|
||||||
blp.new_mat = material;
|
if(string* mat = get_if<string>(&material); mat)
|
||||||
|
blp.new_mat = { { ".*", *mat } };
|
||||||
|
else
|
||||||
|
blp.new_mat = *get_if<map<string, string>>(&material);
|
||||||
|
|
||||||
if(project_boundaries.has_value())
|
if(project_boundaries.has_value())
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user