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)
// 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,

View File

@ -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";
}

View File

@ -181,13 +181,21 @@ namespace netgen
return 0;
vlam[2] = 1.-vlam[0] - vlam[1];
NgArray<int> edges;
// NgArray<int> edges;
auto & topology = mesh.GetTopology();
/*
topology.GetSurfaceElementEdges(velement, edges);
Array<SegmentIndex> segs(edges.Size());
for(auto i : Range(edges))
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))
{
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<AnisotropicClusters> (*this);
ident = make_unique<Identifications> (*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<ParallelMeshTopology> (*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<string*> & Mesh :: GetRegionNamesCD (int codim)
Array<string*> & Mesh :: GetRegionNamesCD (int codim)
{
switch (codim)
{

View File

@ -129,16 +129,16 @@ namespace netgen
NgArray<EdgeDescriptor> edgedecoding;
/// sub-domain materials
NgArray<string*> materials;
Array<string*> materials;
/// labels for boundary conditions
NgArray<string*> bcnames;
Array<string*> bcnames;
/// labels for co dim 2 bboundary conditions
NgArray<string*> cd2names;
Array<string*> cd2names;
/// labels for co dim 3 bbboundary conditions
NgArray<string*> cd3names;
Array<string*> cd3names;
/// Periodic surface, close surface, etc. identifications
unique_ptr<Identifications> 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<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 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<int> & volume_weights, NgArray<int> & surface_weights,
NgArray<int> & segment_weights);
NgArray<int> & 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<int> & neloc );
DLL_HEADER void ParallelMetis (int nproc);
DLL_HEADER void ParallelMetis (NgArray<int> & volume_weights, NgArray<int> & surface_weights,
NgArray<int> & segment_weights);
void PartHybridMesh (); // NgArray<int> & neloc );
void PartDualHybridMesh (); // NgArray<int> & neloc );
void PartDualHybridMesh2D (); // ( NgArray<int> & neloc );
NgArray<int> & 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<int> & neloc) const;
void SendMesh ( ) const;
/// loads a mesh sent from master processor
void ReceiveParallelMesh ();

View File

@ -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;
}

View File

@ -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; }

View File

@ -1236,7 +1236,7 @@ DLL_HEADER void ExportNetgenMeshing(py::module &m)
else
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;
for (auto name : codimnames)

View File

@ -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;
}
}