From 6134717796f85fd4da1c3667dd1b6d15c4519b75 Mon Sep 17 00:00:00 2001 From: Christopher Lackner Date: Wed, 5 Oct 2016 19:48:18 +0200 Subject: [PATCH] setting bboundary names --- libsrc/csg/edgeflw.cpp | 13 ++++++++++++- libsrc/csg/genmesh.cpp | 15 --------------- libsrc/csg/splinesurface.cpp | 15 +++++++++++++++ libsrc/csg/splinesurface.hpp | 1 + libsrc/include/nginterface_v2_impl.hpp | 10 ++++++++-- libsrc/meshing/meshclass.cpp | 5 +++-- libsrc/meshing/meshtype.cpp | 8 ++++++++ libsrc/meshing/meshtype.hpp | 6 ++++++ 8 files changed, 53 insertions(+), 20 deletions(-) diff --git a/libsrc/csg/edgeflw.cpp b/libsrc/csg/edgeflw.cpp index 5a5e22a6..b060d683 100644 --- a/libsrc/csg/edgeflw.cpp +++ b/libsrc/csg/edgeflw.cpp @@ -485,7 +485,18 @@ namespace netgen layer, mesh); } - + + (*testout) << "refedges size: " << refedges.Size() << endl; + for(int i=0; i(geometry.GetSurface(refedges[i].surfnr1)); + if(splinesurface) + { + auto name = splinesurface->GetBCNameOf(specpoints[startpoints.Get(refedges[i].edgenr)].p,specpoints[endpoints.Get(refedges[i].edgenr)].p); + mesh.SetCD2Name(refedges[i].edgenr-1,*name); + } + } /* // not available ... diff --git a/libsrc/csg/genmesh.cpp b/libsrc/csg/genmesh.cpp index d0869662..9c5e78bf 100644 --- a/libsrc/csg/genmesh.cpp +++ b/libsrc/csg/genmesh.cpp @@ -339,21 +339,6 @@ namespace netgen fd.SetBCName ( mesh.GetBCNamePtr ( fd.BCProperty() - 1 ) ); } - int bbccnt = 0; - for (int k = 0; k < geom.GetNSurf(); k++){ - auto splinesurf = dynamic_cast (geom.GetSurface(k)); - if (splinesurf) - { - for( int i=0; i< splinesurf->GetNSplines(); i++) - { - string bcname = *splinesurf->GetBCName(i); - if(bcname != "default"){ - mesh.SetCD2Name(bbccnt,bcname); bbccnt++; } - } - } - } - - //!! for (int k = 1; k <= mesh.GetNFD(); k++) diff --git a/libsrc/csg/splinesurface.cpp b/libsrc/csg/splinesurface.cpp index 92c116ed..46fd7a73 100644 --- a/libsrc/csg/splinesurface.cpp +++ b/libsrc/csg/splinesurface.cpp @@ -19,6 +19,21 @@ void SplineSurface :: AppendPoint(const Point<3> & p, const double reffac, const splines.Append(spline); bcnames.Append(bcname); } + + string* SplineSurface :: GetBCNameOf (Point<3> p1, Point<3> p2) const + { + (*testout) << "segment: " << p1 << ", " << p2 << endl; + for(int i=0; iGetPoint(0) << ", " << splines[i]->GetPoint(1) << endl; + if (((splines[i]->GetPoint(0)-p1).Length()<1e-12 && (splines[i]->GetPoint(1)-p2).Length() < 1e-12) || ((splines[i]->GetPoint(0)-p2).Length() < 1e-12 && (splines[i]->GetPoint(1)-p1).Length() < 1e-12)) + { + (*testout) << "return bcname: " << *bcnames[i] << endl; + return bcnames[i]; + } + } + return new string("default"); + } double SplineSurface :: CalcFunctionValue (const Point<3> & point) const { diff --git a/libsrc/csg/splinesurface.hpp b/libsrc/csg/splinesurface.hpp index 63efa2c1..70809163 100644 --- a/libsrc/csg/splinesurface.hpp +++ b/libsrc/csg/splinesurface.hpp @@ -23,6 +23,7 @@ namespace netgen int GetNP() const { return geompoints.Size(); } const GeomPoint<3> & GetPoint(int i) const { return geompoints[i]; } string* GetBCName(int i) const { return bcnames[i]; } + string* GetBCNameOf(Point<3> p1, Point<3> p2) const; DLL_HEADER void AppendPoint(const Point<3> & p, const double reffac = 1., const bool hpref=false); void AppendSegment(SplineSeg<3>* spline, string* bcname); diff --git a/libsrc/include/nginterface_v2_impl.hpp b/libsrc/include/nginterface_v2_impl.hpp index b7689b8a..dd94d02f 100644 --- a/libsrc/include/nginterface_v2_impl.hpp +++ b/libsrc/include/nginterface_v2_impl.hpp @@ -13,7 +13,10 @@ NGX_INLINE DLL_HEADER int Ngx_Mesh :: GetElementIndex<0> (int nr) const template <> NGX_INLINE DLL_HEADER int Ngx_Mesh :: GetElementIndex<1> (int nr) const { - return (*mesh)[SegmentIndex(nr)].si; + if(mesh->GetDimension()==3) + return (*mesh)[SegmentIndex(nr)].cd2i; + else + return (*mesh)[SegmentIndex(nr)].si; } template <> @@ -63,7 +66,10 @@ NGX_INLINE DLL_HEADER Ng_Element Ngx_Mesh :: GetElement<1> (int nr) const Ng_Element ret; ret.type = NG_ELEMENT_TYPE(el.GetType()); - ret.index = el.si; + if(mesh->GetDimension()==2) + ret.index = el.si; + else + ret.index = el.edgenr; ret.points.num = el.GetNP(); ret.points.ptr = (int*)&(el[0]); diff --git a/libsrc/meshing/meshclass.cpp b/libsrc/meshing/meshclass.cpp index 18fb1635..ba19a36c 100644 --- a/libsrc/meshing/meshclass.cpp +++ b/libsrc/meshing/meshclass.cpp @@ -5773,6 +5773,7 @@ namespace netgen void Mesh :: SetCD2Name ( int cd2nr, const string & abcname ) { + (*testout) << "setCD2Name on edge " << cd2nr << " to " << abcname << endl; if (cd2nr >= cd2names.Size()) { int oldsize = cd2names.Size(); @@ -5780,7 +5781,7 @@ namespace netgen for(int i= oldsize; i<= cd2nr; i++) cd2names[i] = nullptr; } - if (cd2names[cd2nr]) delete cd2names[cd2nr]; + //if (cd2names[cd2nr]) delete cd2names[cd2nr]; if (abcname != "default") cd2names[cd2nr] = new string(abcname); else @@ -5794,7 +5795,7 @@ namespace netgen return defaultstring; if (cd2nr < 0 || cd2nr >= cd2names.Size()) - throw NgException ("illegal bc-number"); + return defaultstring; if (cd2names[cd2nr]) return *cd2names[cd2nr]; diff --git a/libsrc/meshing/meshtype.cpp b/libsrc/meshing/meshtype.cpp index 2dadf981..acad5a7f 100644 --- a/libsrc/meshing/meshtype.cpp +++ b/libsrc/meshing/meshtype.cpp @@ -2418,6 +2418,14 @@ namespace netgen return s; } + string EdgeDescriptor :: default_bcname = "default"; + void EdgeDescriptor :: SetBCName (string * bcn) + { + if(bcn) + bcname = bcn; + else + bcn = &default_bcname; + } diff --git a/libsrc/meshing/meshtype.hpp b/libsrc/meshing/meshtype.hpp index 78598a44..e4963934 100644 --- a/libsrc/meshing/meshtype.hpp +++ b/libsrc/meshing/meshtype.hpp @@ -1005,6 +1005,9 @@ namespace netgen { int tlosurf; int surfnr[2]; + int bcprop; + static string default_bcname; + string* bcname = &default_bcname; public: EdgeDescriptor () : tlosurf(-1) @@ -1015,6 +1018,9 @@ namespace netgen int TLOSurface() const { return tlosurf; } void SetTLOSurface (int nr) { tlosurf = nr; } + int BCProperty() const { return bcprop; } + void SetBCProperty (int bc) { bcprop = bc; } + void SetBCName (string* bcn); };