NgArray -> Array bcnames etc

This commit is contained in:
Joachim Schoeberl 2025-01-05 18:19:21 +01:00
parent 1f70e62fc7
commit 59e5974a28
8 changed files with 47 additions and 66 deletions

View File

@ -215,7 +215,8 @@ namespace netgen
// Check if the face is a surface element (boundary face) // Check if the face is a surface element (boundary face)
// if not, add the current volume element and the corresponding face into // if not, add the current volume element and the corresponding face into
// the owner list // the owner list
int surfelem = meshtopo.GetFace2SurfaceElement1(absfacenr); // int surfelem = meshtopo.GetFace2SurfaceElement1(absfacenr);
int surfelem = meshtopo.GetFace2SurfaceElement(absfacenr-1)+1;
if(!surfelem) if(!surfelem)
{ {
// If it is a new face which has not been listed before, // If it is a new face which has not been listed before,

View File

@ -770,7 +770,8 @@ void WriteEdgeElementFormat (const Mesh & mesh,
outfile << nsurfelem << "\n"; outfile << nsurfelem << "\n";
for (int i = 1; i <= nsurfelem; i++) for (int i = 1; i <= nsurfelem; i++)
{ {
Element2d el = mesh.SurfaceElement(i); SurfaceElementIndex sei(i-1);
Element2d el = mesh[sei];
if (invertsurf) if (invertsurf)
el.Invert(); el.Invert();
outfile.width(4); outfile.width(4);
@ -784,15 +785,16 @@ void WriteEdgeElementFormat (const Mesh & mesh,
outfile << el.PNum(j); outfile << el.PNum(j);
} }
top->GetSurfaceElementEdges(i,edges); // top->GetSurfaceElementEdges(i,edges);
auto edges = top->GetEdges(sei);
outfile << endl << " "; outfile << endl << " ";
outfile.width(8); outfile.width(8);
outfile << edges.Size(); outfile << edges.Size();
for (int j=1; j <= edges.Size(); j++) for (int j=0; j < edges.Size(); j++)
{ {
outfile << " "; outfile << " ";
outfile.width(8); outfile.width(8);
outfile << edges[j-1]; outfile << edges[j]+1;
} }
outfile << "\n"; outfile << "\n";
} }

View File

@ -181,12 +181,20 @@ namespace netgen
return 0; return 0;
vlam[2] = 1.-vlam[0] - vlam[1]; vlam[2] = 1.-vlam[0] - vlam[1];
NgArray<int> edges; // NgArray<int> edges;
auto & topology = mesh.GetTopology(); auto & topology = mesh.GetTopology();
/*
topology.GetSurfaceElementEdges(velement, edges); topology.GetSurfaceElementEdges(velement, edges);
Array<SegmentIndex> segs(edges.Size()); Array<SegmentIndex> segs(edges.Size());
for(auto i : Range(edges)) for(auto i : Range(edges))
segs[i] = topology.GetSegmentOfEdge(edges[i]); segs[i] = topology.GetSegmentOfEdge(edges[i]);
*/
auto hedges = topology.GetEdges(SurfaceElementIndex(velement-1));
Array<SegmentIndex> segs(hedges.Size());
for(auto i : Range(hedges))
segs[i] = topology.GetSegmentOfEdge(hedges[i]+1);
for(auto i : Range(segs)) for(auto i : Range(segs))
{ {
@ -224,12 +232,7 @@ namespace netgen
Mesh :: Mesh () Mesh :: Mesh ()
: topology(*this), surfarea(*this) : topology(*this), surfarea(*this)
{ {
// boundaryedges = nullptr;
// surfelementht = nullptr;
// segmentht = nullptr;
lochfunc = {nullptr}; lochfunc = {nullptr};
// mglevels = 1;
elementsearchtree = nullptr; elementsearchtree = nullptr;
elementsearchtreets = NextTimeStamp(); elementsearchtreets = NextTimeStamp();
majortimestamp = timestamp = NextTimeStamp(); majortimestamp = timestamp = NextTimeStamp();
@ -242,9 +245,6 @@ namespace netgen
clusters = make_unique<AnisotropicClusters> (*this); clusters = make_unique<AnisotropicClusters> (*this);
ident = make_unique<Identifications> (*this); ident = make_unique<Identifications> (*this);
hpelements = NULL;
coarsemesh = NULL;
ps_startelement = 0; ps_startelement = 0;
geomtype = NO_GEOM; geomtype = NO_GEOM;
@ -252,7 +252,6 @@ namespace netgen
bcnames.SetSize(0); bcnames.SetSize(0);
cd2names.SetSize(0); cd2names.SetSize(0);
// this->comm = netgen :: ng_comm;
#ifdef PARALLEL #ifdef PARALLEL
paralleltop = make_unique<ParallelMeshTopology> (*this); paralleltop = make_unique<ParallelMeshTopology> (*this);
#endif #endif
@ -261,17 +260,6 @@ namespace netgen
Mesh :: ~Mesh() 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++) for (int i = 0; i < materials.Size(); i++)
delete materials[i]; delete materials[i];
for(int i = 0; i < userdata_int.Size(); i++) for(int i = 0; i < userdata_int.Size(); i++)
@ -922,17 +910,17 @@ namespace netgen
} }
int cntmat = 0; int cntmat = 0;
for (i = 1; i <= materials.Size(); i++) for (int i = 0; i < materials.Size(); i++)
if (materials.Get(i) && materials.Get(i)->length()) if (materials[i] && materials[i]->length())
cntmat++; cntmat++;
if (cntmat) if (cntmat)
{ {
outfile << "materials" << endl; outfile << "materials" << endl;
outfile << cntmat << endl; outfile << cntmat << endl;
for (i = 1; i <= materials.Size(); i++) for (int i = 0; i < materials.Size(); i++)
if (materials.Get(i) && materials.Get(i)->length()) if (materials[i] && materials[i]->length())
outfile << i << " " << *materials.Get(i) << endl; outfile << i+1 << " " << *materials[i] << endl;
} }
@ -7437,14 +7425,14 @@ namespace netgen
materials.Elem(domnr) = new char[strlen(mat)+1]; materials.Elem(domnr) = new char[strlen(mat)+1];
strcpy (materials.Elem(domnr), mat); strcpy (materials.Elem(domnr), mat);
*/ */
materials.Elem(domnr) = new string(mat); materials[domnr-1] = new string(mat);
} }
string Mesh :: defaultmat = "default"; string Mesh :: defaultmat = "default";
const string & Mesh :: GetMaterial (int domnr) const const string & Mesh :: GetMaterial (int domnr) const
{ {
if (domnr <= materials.Size()) if (domnr <= materials.Size())
return *materials.Get(domnr); return *materials[domnr-1];
static string emptystring("default"); static string emptystring("default");
return emptystring; return emptystring;
} }
@ -7588,7 +7576,7 @@ namespace netgen
} }
NgArray<string*> & Mesh :: GetRegionNamesCD (int codim) Array<string*> & Mesh :: GetRegionNamesCD (int codim)
{ {
switch (codim) switch (codim)
{ {

View File

@ -129,16 +129,16 @@ namespace netgen
NgArray<EdgeDescriptor> edgedecoding; NgArray<EdgeDescriptor> edgedecoding;
/// sub-domain materials /// sub-domain materials
NgArray<string*> materials; Array<string*> materials;
/// labels for boundary conditions /// labels for boundary conditions
NgArray<string*> bcnames; Array<string*> bcnames;
/// labels for co dim 2 bboundary conditions /// labels for co dim 2 bboundary conditions
NgArray<string*> cd2names; Array<string*> cd2names;
/// labels for co dim 3 bbboundary conditions /// labels for co dim 3 bbboundary conditions
NgArray<string*> cd3names; Array<string*> cd3names;
/// Periodic surface, close surface, etc. identifications /// Periodic surface, close surface, etc. identifications
unique_ptr<Identifications> ident; unique_ptr<Identifications> ident;
@ -713,7 +713,7 @@ namespace netgen
DLL_HEADER static string defaultmat; DLL_HEADER static string defaultmat;
const string * GetMaterialPtr (int domnr) const // 1-based 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 ); DLL_HEADER void SetNBCNames ( int nbcn );
@ -752,7 +752,7 @@ namespace netgen
{ return (bcnr < bcnames.Size() && bcnames[bcnr]) ? bcnames[bcnr] : &default_bc; } { return (bcnr < bcnames.Size() && bcnames[bcnr]) ? bcnames[bcnr] : &default_bc; }
DLL_HEADER NgArray<string*> & GetRegionNamesCD (int codim); DLL_HEADER Array<string*> & GetRegionNamesCD (int codim);
DLL_HEADER std::string_view GetRegionName(const Segment & el) const; DLL_HEADER std::string_view GetRegionName(const Segment & el) const;
DLL_HEADER std::string_view GetRegionName(const Element2d & el) const; DLL_HEADER std::string_view GetRegionName(const Element2d & el) const;
@ -969,20 +969,19 @@ namespace netgen
// void FindExchangeFaces (); // void FindExchangeFaces ();
/// use metis to decompose master mesh /// use metis to decompose master mesh
DLL_HEADER void ParallelMetis (int nproc); // NgArray<int> & neloc ); DLL_HEADER void ParallelMetis (int nproc);
DLL_HEADER void ParallelMetis (NgArray<int> & volume_weights, NgArray<int> & surface_weights, DLL_HEADER void ParallelMetis (NgArray<int> & volume_weights, NgArray<int> & surface_weights,
NgArray<int> & segment_weights); NgArray<int> & segment_weights);
void PartHybridMesh (); // NgArray<int> & neloc ); void PartHybridMesh ();
void PartDualHybridMesh (); // NgArray<int> & neloc ); void PartDualHybridMesh ();
void PartDualHybridMesh2D (); // ( NgArray<int> & neloc ); void PartDualHybridMesh2D ();
/// send mesh from master to local procs /// send mesh from master to local procs
void SendRecvMesh (); void SendRecvMesh ();
/// send mesh to parallel machine, keep global mesh at master /// send mesh to parallel machine, keep global mesh at master
void SendMesh ( ) const; // Mesh * mastermesh, NgArray<int> & neloc) const; void SendMesh ( ) const;
/// loads a mesh sent from master processor /// loads a mesh sent from master processor
void ReceiveParallelMesh (); void ReceiveParallelMesh ();

View File

@ -1345,13 +1345,10 @@ namespace netgen
if (nparts == 1) if (nparts == 1)
{ {
for (int i = 0; i < GetNE(); i++) for (int i = 0; i < GetNE(); i++)
// VolumeElement(i+1).SetPartition(1);
vol_partition[i]= 1; vol_partition[i]= 1;
for (int i = 0; i < GetNSE(); i++) for (int i = 0; i < GetNSE(); i++)
// SurfaceElement(i+1).SetPartition(1);
surf_partition[i] = 1; surf_partition[i] = 1;
for (int i = 0; i < GetNSeg(); i++) for (int i = 0; i < GetNSeg(); i++)
// LineSegment(i+1).SetPartition(1);
seg_partition[i] = 1; seg_partition[i] = 1;
} }
@ -1371,22 +1368,13 @@ namespace netgen
&edgecut, &epart[0], &npart[0]); &edgecut, &epart[0], &npart[0]);
tm.Stop(); tm.Stop();
/*
METIS_PartMeshNodal (&ne, &nn, &eptr[0], &eind[0], NULL, NULL, &nparts,
NULL, NULL,
&edgecut, &epart[0], &npart[0]);
*/
PrintMessage (3, "metis complete"); PrintMessage (3, "metis complete");
// cout << "done" << endl;
for (int i = 0; i < GetNE(); i++) for (int i = 0; i < GetNE(); i++)
// VolumeElement(i+1).SetPartition(epart[i] + 1);
vol_partition[i]= epart[i] + 1; vol_partition[i]= epart[i] + 1;
for (int i = 0; i < GetNSE(); i++) for (int i = 0; i < GetNSE(); i++)
// SurfaceElement(i+1).SetPartition(epart[i+GetNE()] + 1);
surf_partition[i] = epart[i+GetNE()] + 1; surf_partition[i] = epart[i+GetNE()] + 1;
for (int i = 0; i < GetNSeg(); i++) for (int i = 0; i < GetNSeg(); i++)
// LineSegment(i+1).SetPartition(epart[i+GetNE()+GetNSE()] + 1);
seg_partition[i] = epart[i+GetNE()+GetNSE()] + 1; seg_partition[i] = epart[i+GetNE()+GetNSE()] + 1;
} }

View File

@ -78,9 +78,9 @@ namespace netgen
[[deprecated("Use L2G(pi) instead!")]] [[deprecated("Use L2G(pi) instead!")]]
void SetLoc2Glob_Vert (int locnum, int globnum) { glob_vert[locnum-1] = globnum; } 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; } 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; } void SetLoc2Glob_Face (int locnum, int globnum) { glob_face[locnum-1] = globnum; }
// [[deprecated("Try to avoid global enumration!")]] // [[deprecated("Try to avoid global enumration!")]]
void SetLoc2Glob_VolEl (int locnum, int globnum) { glob_el[locnum-1] = globnum; } void SetLoc2Glob_VolEl (int locnum, int globnum) { glob_el[locnum-1] = globnum; }

View File

@ -1236,7 +1236,7 @@ DLL_HEADER void ExportNetgenMeshing(py::module &m)
else else
throw Exception("either 'dim' or 'codim' must be specified"); throw Exception("either 'dim' or 'codim' must be specified");
NgArray<string*> & codimnames = self.GetRegionNamesCD (codim); Array<string*> & codimnames = self.GetRegionNamesCD (codim);
std::vector<string> names; std::vector<string> names;
for (auto name : codimnames) for (auto name : codimnames)

View File

@ -2408,7 +2408,10 @@ namespace netgen
if (!surfel.IsValid()) if (!surfel.IsValid())
{ {
// GetSurfaceElementEdges (surfel, fedges); // GetSurfaceElementEdges (surfel, fedges);
GetEdges (surfel, fedges); auto hedges = GetEdges (surfel);
fedges.SetSize(hedges.Size());
for (int i : Range(hedges))
fedges[i]=hedges[i];
return; return;
} }
} }