From 1cdc814f4e6b672cebb98f8831c165483e5b306f Mon Sep 17 00:00:00 2001 From: Michael Neunteufel Date: Mon, 6 Aug 2018 17:09:03 +0200 Subject: [PATCH] added BBBND material names --- libsrc/csg/csgeom.hpp | 2 +- libsrc/include/nginterface_v2_impl.hpp | 3 +- libsrc/meshing/meshclass.cpp | 42 ++++++++++++++++++++++++++ libsrc/meshing/meshclass.hpp | 15 +++++++++ libsrc/meshing/python_mesh.cpp | 5 ++- 5 files changed, 63 insertions(+), 4 deletions(-) diff --git a/libsrc/csg/csgeom.hpp b/libsrc/csg/csgeom.hpp index 7f66331e..24445584 100644 --- a/libsrc/csg/csgeom.hpp +++ b/libsrc/csg/csgeom.hpp @@ -226,7 +226,7 @@ namespace netgen void AddUserPoint (const Point<3> & p, double ref_factor = 0) - { userpoints.Append (UserPoint(p,1)); userpoints_ref_factor.Append (ref_factor); } + { userpoints.Append (UserPoint(p,userpoints.Size())); userpoints_ref_factor.Append (ref_factor); } void AddUserPoint (const UserPoint up, double ref_factor = 0) { userpoints.Append (up); userpoints_ref_factor.Append (ref_factor); } int GetNUserPoints () const diff --git a/libsrc/include/nginterface_v2_impl.hpp b/libsrc/include/nginterface_v2_impl.hpp index ee2e47d2..aa538761 100644 --- a/libsrc/include/nginterface_v2_impl.hpp +++ b/libsrc/include/nginterface_v2_impl.hpp @@ -217,8 +217,7 @@ const string & Ngx_Mesh :: GetMaterialCD<2> (int region_nr) const template <> NGX_INLINE DLL_HEADER const string & Ngx_Mesh :: GetMaterialCD<3> (int region_nr) const { - static string def("default"); - return def; + return mesh->GetCD3Name(region_nr); } diff --git a/libsrc/meshing/meshclass.cpp b/libsrc/meshing/meshclass.cpp index d49e37a4..bc79a563 100644 --- a/libsrc/meshing/meshclass.cpp +++ b/libsrc/meshing/meshclass.cpp @@ -5985,6 +5985,48 @@ namespace netgen return defaultstring; } + void Mesh :: SetNCD3Names( int ncd3n ) + { + if (cd3names.Size()) + for(int i=0; i= cd3names.Size()) + { + int oldsize = cd3names.Size(); + cd3names.SetSize(cd3nr+1); + for(int i= oldsize; i<= cd3nr; i++) + cd3names[i] = nullptr; + } + if (abcname != "default") + cd3names[cd3nr] = new string(abcname); + else + cd3names[cd3nr] = nullptr; + } + + string Mesh :: cd3_default_name = "default"; + const string & Mesh :: GetCD3Name (int cd3nr) const + { + static string defaultstring = "default"; + if (!cd3names.Size()) + return defaultstring; + + if (cd3nr < 0 || cd3nr >= cd3names.Size()) + return defaultstring; + + if (cd3names[cd3nr]) + return *cd3names[cd3nr]; + else + return defaultstring; + } + void Mesh :: SetUserData(const char * id, Array & data) { if(userdata_int.Used(id)) diff --git a/libsrc/meshing/meshclass.hpp b/libsrc/meshing/meshclass.hpp index 7b6ac3cd..2de6d3ee 100644 --- a/libsrc/meshing/meshclass.hpp +++ b/libsrc/meshing/meshclass.hpp @@ -96,6 +96,9 @@ namespace netgen /// labels for co dim 2 bboundary conditions Array cd2names; + /// labels for co dim 3 bbboundary conditions + Array cd3names; + /// Periodic surface, close surface, etc. identifications Identifications * ident; @@ -631,6 +634,18 @@ namespace netgen } size_t GetNCD2Names() const { return cd2names.Size(); } + DLL_HEADER void SetNCD3Names (int ncd3n); + DLL_HEADER void SetCD3Name (int cd3nr, const string & abcname); + + DLL_HEADER const string & GetCD3Name (int cd3nr ) const; + DLL_HEADER static string cd3_default_name; + string * GetCD3NamePtr (int cd3nr ) const + { + if (cd3nr < cd3names.Size() && cd3names[cd3nr]) return cd3names[cd3nr]; + return &cd3_default_name; + } + size_t GetNCD3Names() const { return cd3names.Size(); } + DLL_HEADER static string default_bc; string * GetBCNamePtr (int bcnr) const { return (bcnr < bcnames.Size() && bcnames[bcnr]) ? bcnames[bcnr] : &default_bc; } diff --git a/libsrc/meshing/python_mesh.cpp b/libsrc/meshing/python_mesh.cpp index bc729895..682239c4 100644 --- a/libsrc/meshing/python_mesh.cpp +++ b/libsrc/meshing/python_mesh.cpp @@ -663,7 +663,10 @@ DLL_HEADER void ExportNetgenMeshing(py::module &m) { return string(self.GetMaterial(domnr)); })) .def ("GetCD2Name", &Mesh::GetCD2Name) - .def("SetCD2Name", &Mesh::SetCD2Name) + .def ("SetCD2Name", &Mesh::SetCD2Name) + + .def ("GetCD3Name", &Mesh::GetCD3Name) + .def ("SetCD3Name", &Mesh::SetCD3Name) .def ("AddPointIdentification", [](Mesh & self, py::object pindex1, py::object pindex2, int identnr, int type) {