From aca46c49c87202b3dea65041e5aef99a653e7a3d Mon Sep 17 00:00:00 2001 From: Christopher Lackner Date: Wed, 1 Sep 2021 14:34:30 +0200 Subject: [PATCH 1/2] add SetDomainLayer for geom2d --- libsrc/geom2d/geometry2d.hpp | 12 +++++++++++- libsrc/geom2d/python_geom2d.cpp | 1 + 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/libsrc/geom2d/geometry2d.hpp b/libsrc/geom2d/geometry2d.hpp index daab8d12..08c3fc9d 100644 --- a/libsrc/geom2d/geometry2d.hpp +++ b/libsrc/geom2d/geometry2d.hpp @@ -250,7 +250,17 @@ namespace netgen if ( layer.Size() ) return layer[domnr-1]; else return 1; } - + void SetDomainLayer (int domnr, int layernr) + { + auto old_size = layer.Size(); + if(domnr > old_size) + { + layer.SetSize(domnr); + for(size_t i = old_size; i < domnr; i++) + layer[i] = 1; + } + layer[domnr-1] = layernr; + } string GetBCName (int bcnr) const; void SetBCName (int bcnr, string name); diff --git a/libsrc/geom2d/python_geom2d.cpp b/libsrc/geom2d/python_geom2d.cpp index 2b01e566..83e44f6c 100644 --- a/libsrc/geom2d/python_geom2d.cpp +++ b/libsrc/geom2d/python_geom2d.cpp @@ -49,6 +49,7 @@ NGCORE_API_EXPORT void ExportGeom2d(py::module &m) })) .def(NGSPickle()) .def("Load",&SplineGeometry2d::Load) + .def("SetDomainLayer", &SplineGeometry2d::SetDomainLayer) .def("AppendPoint", FunctionPointer ([](SplineGeometry2d &self, double px, double py, double maxh, double hpref, string name) { From f53dad83aec59c9893b40b5bad3ef423478380dd Mon Sep 17 00:00:00 2001 From: Matthias Hochsteger Date: Wed, 1 Sep 2021 14:38:45 +0200 Subject: [PATCH 2/2] layer property for Solid2d --- libsrc/geom2d/csg2d.cpp | 4 ++++ libsrc/geom2d/csg2d.hpp | 7 +++++++ libsrc/geom2d/python_geom2d.cpp | 1 + 3 files changed, 12 insertions(+) diff --git a/libsrc/geom2d/csg2d.cpp b/libsrc/geom2d/csg2d.cpp index dd8cf21a..dfee7fba 100644 --- a/libsrc/geom2d/csg2d.cpp +++ b/libsrc/geom2d/csg2d.cpp @@ -2183,7 +2183,11 @@ shared_ptr CSG2d :: GenerateSplineGeometry() } } if(!is_solid_degenerated) + { geo->SetMaterial(dom, s.name); + if(s.layer != 1) + geo->SetDomainLayer(dom, s.layer); + } else dom--; // degenerated solid, use same domain index again } diff --git a/libsrc/geom2d/csg2d.hpp b/libsrc/geom2d/csg2d.hpp index afc1e654..fbe705a9 100644 --- a/libsrc/geom2d/csg2d.hpp +++ b/libsrc/geom2d/csg2d.hpp @@ -630,6 +630,7 @@ struct Solid2d { Array polys; + int layer = 1; string name = MAT_DEFAULT; Solid2d() = default; @@ -708,6 +709,12 @@ struct Solid2d return *this; } + Solid2d & Layer(int layer_) + { + layer = layer_; + return *this; + } + Box<2> GetBoundingBox() const; }; diff --git a/libsrc/geom2d/python_geom2d.cpp b/libsrc/geom2d/python_geom2d.cpp index 83e44f6c..dc14bd67 100644 --- a/libsrc/geom2d/python_geom2d.cpp +++ b/libsrc/geom2d/python_geom2d.cpp @@ -433,6 +433,7 @@ NGCORE_API_EXPORT void ExportGeom2d(py::module &m) .def("Mat", &Solid2d::Mat) .def("BC", &Solid2d::BC) .def("Maxh", &Solid2d::Maxh) + .def("Layer", &Solid2d::Layer) .def("Copy", [](Solid2d & self) -> Solid2d { return self; }) .def("Move", &Solid2d::Move)