diff --git a/libsrc/interface/writeOpenFOAM15x.cpp b/libsrc/interface/writeOpenFOAM15x.cpp index 21eac489..f6e67eb4 100644 --- a/libsrc/interface/writeOpenFOAM15x.cpp +++ b/libsrc/interface/writeOpenFOAM15x.cpp @@ -215,7 +215,8 @@ namespace netgen // Check if the face is a surface element (boundary face) // if not, add the current volume element and the corresponding face into // the owner list - int surfelem = meshtopo.GetFace2SurfaceElement1(absfacenr); + // int surfelem = meshtopo.GetFace2SurfaceElement1(absfacenr); + int surfelem = meshtopo.GetFace2SurfaceElement(absfacenr-1)+1; if(!surfelem) { // If it is a new face which has not been listed before, diff --git a/libsrc/interface/writeuser.cpp b/libsrc/interface/writeuser.cpp index b4f5f033..5c85ef90 100644 --- a/libsrc/interface/writeuser.cpp +++ b/libsrc/interface/writeuser.cpp @@ -770,7 +770,8 @@ void WriteEdgeElementFormat (const Mesh & mesh, outfile << nsurfelem << "\n"; for (int i = 1; i <= nsurfelem; i++) { - Element2d el = mesh.SurfaceElement(i); + SurfaceElementIndex sei(i-1); + Element2d el = mesh[sei]; if (invertsurf) el.Invert(); outfile.width(4); @@ -784,15 +785,16 @@ void WriteEdgeElementFormat (const Mesh & mesh, outfile << el.PNum(j); } - top->GetSurfaceElementEdges(i,edges); + // top->GetSurfaceElementEdges(i,edges); + auto edges = top->GetEdges(sei); outfile << endl << " "; outfile.width(8); outfile << edges.Size(); - for (int j=1; j <= edges.Size(); j++) + for (int j=0; j < edges.Size(); j++) { outfile << " "; outfile.width(8); - outfile << edges[j-1]; + outfile << edges[j]+1; } outfile << "\n"; } diff --git a/libsrc/meshing/meshclass.cpp b/libsrc/meshing/meshclass.cpp index 0843350a..6551576f 100644 --- a/libsrc/meshing/meshclass.cpp +++ b/libsrc/meshing/meshclass.cpp @@ -181,13 +181,21 @@ namespace netgen return 0; vlam[2] = 1.-vlam[0] - vlam[1]; - NgArray edges; + // NgArray edges; auto & topology = mesh.GetTopology(); + + /* topology.GetSurfaceElementEdges(velement, edges); Array segs(edges.Size()); for(auto i : Range(edges)) segs[i] = topology.GetSegmentOfEdge(edges[i]); - + */ + auto hedges = topology.GetEdges(SurfaceElementIndex(velement-1)); + Array segs(hedges.Size()); + for(auto i : Range(hedges)) + segs[i] = topology.GetSegmentOfEdge(hedges[i]+1); + + for(auto i : Range(segs)) { if(IsInvalid(segs[i])) @@ -224,12 +232,7 @@ namespace netgen Mesh :: Mesh () : topology(*this), surfarea(*this) { - // boundaryedges = nullptr; - // surfelementht = nullptr; - // segmentht = nullptr; - lochfunc = {nullptr}; - // mglevels = 1; elementsearchtree = nullptr; elementsearchtreets = NextTimeStamp(); majortimestamp = timestamp = NextTimeStamp(); @@ -242,9 +245,6 @@ namespace netgen clusters = make_unique (*this); ident = make_unique (*this); - hpelements = NULL; - coarsemesh = NULL; - ps_startelement = 0; geomtype = NO_GEOM; @@ -252,7 +252,6 @@ namespace netgen bcnames.SetSize(0); cd2names.SetSize(0); - // this->comm = netgen :: ng_comm; #ifdef PARALLEL paralleltop = make_unique (*this); #endif @@ -261,17 +260,6 @@ namespace netgen Mesh :: ~Mesh() { - // delete lochfunc; - // delete boundaryedges; - // delete surfelementht; - // delete segmentht; - // delete curvedelems; - // delete clusters; - // delete ident; - // delete elementsearchtree; - // delete coarsemesh; - // delete hpelements; - for (int i = 0; i < materials.Size(); i++) delete materials[i]; for(int i = 0; i < userdata_int.Size(); i++) @@ -922,17 +910,17 @@ namespace netgen } int cntmat = 0; - for (i = 1; i <= materials.Size(); i++) - if (materials.Get(i) && materials.Get(i)->length()) + for (int i = 0; i < materials.Size(); i++) + if (materials[i] && materials[i]->length()) cntmat++; if (cntmat) { outfile << "materials" << endl; outfile << cntmat << endl; - for (i = 1; i <= materials.Size(); i++) - if (materials.Get(i) && materials.Get(i)->length()) - outfile << i << " " << *materials.Get(i) << endl; + for (int i = 0; i < materials.Size(); i++) + if (materials[i] && materials[i]->length()) + outfile << i+1 << " " << *materials[i] << endl; } @@ -7437,14 +7425,14 @@ namespace netgen materials.Elem(domnr) = new char[strlen(mat)+1]; strcpy (materials.Elem(domnr), mat); */ - materials.Elem(domnr) = new string(mat); + materials[domnr-1] = new string(mat); } string Mesh :: defaultmat = "default"; const string & Mesh :: GetMaterial (int domnr) const { if (domnr <= materials.Size()) - return *materials.Get(domnr); + return *materials[domnr-1]; static string emptystring("default"); return emptystring; } @@ -7588,7 +7576,7 @@ namespace netgen } - NgArray & Mesh :: GetRegionNamesCD (int codim) + Array & Mesh :: GetRegionNamesCD (int codim) { switch (codim) { diff --git a/libsrc/meshing/meshclass.hpp b/libsrc/meshing/meshclass.hpp index d7afa8ec..c83ee575 100644 --- a/libsrc/meshing/meshclass.hpp +++ b/libsrc/meshing/meshclass.hpp @@ -129,16 +129,16 @@ namespace netgen NgArray edgedecoding; /// sub-domain materials - NgArray materials; + Array materials; /// labels for boundary conditions - NgArray bcnames; + Array bcnames; /// labels for co dim 2 bboundary conditions - NgArray cd2names; + Array cd2names; /// labels for co dim 3 bbboundary conditions - NgArray cd3names; + Array cd3names; /// Periodic surface, close surface, etc. identifications unique_ptr ident; @@ -713,7 +713,7 @@ namespace netgen DLL_HEADER static string defaultmat; const string * GetMaterialPtr (int domnr) const // 1-based { - return domnr <= materials.Size() ? materials.Get(domnr) : &defaultmat; + return domnr <= materials.Size() ? materials[domnr-1] : &defaultmat; } DLL_HEADER void SetNBCNames ( int nbcn ); @@ -752,7 +752,7 @@ namespace netgen { return (bcnr < bcnames.Size() && bcnames[bcnr]) ? bcnames[bcnr] : &default_bc; } - DLL_HEADER NgArray & GetRegionNamesCD (int codim); + DLL_HEADER Array & GetRegionNamesCD (int codim); DLL_HEADER std::string_view GetRegionName(const Segment & el) const; DLL_HEADER std::string_view GetRegionName(const Element2d & el) const; @@ -959,7 +959,7 @@ namespace netgen /// distributes the master-mesh to local meshes DLL_HEADER void Distribute (); DLL_HEADER void Distribute (NgArray & volume_weights, NgArray & surface_weights, - NgArray & segment_weights); + NgArray & segment_weights); /// find connection to parallel meshes @@ -969,20 +969,19 @@ namespace netgen // void FindExchangeFaces (); /// use metis to decompose master mesh - DLL_HEADER void ParallelMetis (int nproc); // NgArray & neloc ); + DLL_HEADER void ParallelMetis (int nproc); DLL_HEADER void ParallelMetis (NgArray & volume_weights, NgArray & surface_weights, - NgArray & segment_weights); - - void PartHybridMesh (); // NgArray & neloc ); - void PartDualHybridMesh (); // NgArray & neloc ); - void PartDualHybridMesh2D (); // ( NgArray & neloc ); + NgArray & segment_weights); + void PartHybridMesh (); + void PartDualHybridMesh (); + void PartDualHybridMesh2D (); /// send mesh from master to local procs void SendRecvMesh (); /// send mesh to parallel machine, keep global mesh at master - void SendMesh ( ) const; // Mesh * mastermesh, NgArray & neloc) const; + void SendMesh ( ) const; /// loads a mesh sent from master processor void ReceiveParallelMesh (); diff --git a/libsrc/meshing/parallelmesh.cpp b/libsrc/meshing/parallelmesh.cpp index 29b76dbe..7fe12d5d 100644 --- a/libsrc/meshing/parallelmesh.cpp +++ b/libsrc/meshing/parallelmesh.cpp @@ -1345,13 +1345,10 @@ namespace netgen if (nparts == 1) { for (int i = 0; i < GetNE(); i++) - // VolumeElement(i+1).SetPartition(1); vol_partition[i]= 1; for (int i = 0; i < GetNSE(); i++) - // SurfaceElement(i+1).SetPartition(1); surf_partition[i] = 1; for (int i = 0; i < GetNSeg(); i++) - // LineSegment(i+1).SetPartition(1); seg_partition[i] = 1; } @@ -1370,23 +1367,14 @@ namespace netgen NULL, NULL, &edgecut, &epart[0], &npart[0]); tm.Stop(); - - /* - METIS_PartMeshNodal (&ne, &nn, &eptr[0], &eind[0], NULL, NULL, &nparts, - NULL, NULL, - &edgecut, &epart[0], &npart[0]); - */ + PrintMessage (3, "metis complete"); - // cout << "done" << endl; for (int i = 0; i < GetNE(); i++) - // VolumeElement(i+1).SetPartition(epart[i] + 1); vol_partition[i]= epart[i] + 1; for (int i = 0; i < GetNSE(); i++) - // SurfaceElement(i+1).SetPartition(epart[i+GetNE()] + 1); surf_partition[i] = epart[i+GetNE()] + 1; for (int i = 0; i < GetNSeg(); i++) - // LineSegment(i+1).SetPartition(epart[i+GetNE()+GetNSE()] + 1); seg_partition[i] = epart[i+GetNE()+GetNSE()] + 1; } diff --git a/libsrc/meshing/paralleltop.hpp b/libsrc/meshing/paralleltop.hpp index 8c180176..9c8b61a1 100644 --- a/libsrc/meshing/paralleltop.hpp +++ b/libsrc/meshing/paralleltop.hpp @@ -78,9 +78,9 @@ namespace netgen [[deprecated("Use L2G(pi) instead!")]] void SetLoc2Glob_Vert (int locnum, int globnum) { glob_vert[locnum-1] = globnum; } - // [[deprecated("Try to avoid global enumration!")]] + [[deprecated("Try to avoid global enumration!")]] void SetLoc2Glob_Edge (int locnum, int globnum) { glob_edge[locnum-1] = globnum; } - // [[deprecated("Try to avoid global enumration!")]] + [[deprecated("Try to avoid global enumration!")]] void SetLoc2Glob_Face (int locnum, int globnum) { glob_face[locnum-1] = globnum; } // [[deprecated("Try to avoid global enumration!")]] void SetLoc2Glob_VolEl (int locnum, int globnum) { glob_el[locnum-1] = globnum; } diff --git a/libsrc/meshing/python_mesh.cpp b/libsrc/meshing/python_mesh.cpp index 102d8b55..ca799e18 100644 --- a/libsrc/meshing/python_mesh.cpp +++ b/libsrc/meshing/python_mesh.cpp @@ -1236,7 +1236,7 @@ DLL_HEADER void ExportNetgenMeshing(py::module &m) else throw Exception("either 'dim' or 'codim' must be specified"); - NgArray & codimnames = self.GetRegionNamesCD (codim); + Array & codimnames = self.GetRegionNamesCD (codim); std::vector names; for (auto name : codimnames) diff --git a/libsrc/meshing/topology.cpp b/libsrc/meshing/topology.cpp index 96a4a89e..bb1d209b 100644 --- a/libsrc/meshing/topology.cpp +++ b/libsrc/meshing/topology.cpp @@ -2408,7 +2408,10 @@ namespace netgen if (!surfel.IsValid()) { // GetSurfaceElementEdges (surfel, fedges); - GetEdges (surfel, fedges); + auto hedges = GetEdges (surfel); + fedges.SetSize(hedges.Size()); + for (int i : Range(hedges)) + fedges[i]=hedges[i]; return; } }