counting num vertices in parallel

This commit is contained in:
Joachim Schoeberl 2023-05-21 14:35:09 +02:00
parent f1162b6cc3
commit 472073c22b
2 changed files with 23 additions and 3 deletions

View File

@ -628,7 +628,7 @@ namespace ngcore
FlatArray<T> View (FlatArray<T> fa) { return fa; }
template <typename T, typename TI>
auto Max (FlatArray<T,TI> array, T max = std::numeric_limits<T>::min()) -> T
auto Max (FlatArray<T,TI> array, typename std::remove_const<T>::type max = std::numeric_limits<T>::min()) -> T
{
for (auto & v : array)
if (v > max) max = v;
@ -636,7 +636,7 @@ namespace ngcore
}
template <typename T, typename TI>
auto Min (FlatArray<T,TI> array, T min = std::numeric_limits<T>::max()) -> T
auto Min (FlatArray<T,TI> array, typename std::remove_const<T>::type min = std::numeric_limits<T>::max()) -> T
{
for (auto & v : array)
if (v < min) min = v;

View File

@ -6810,8 +6810,9 @@ namespace netgen
void Mesh :: ComputeNVertices ()
{
numvertices = 0;
numvertices = 0;
/*
for (const Element & el : VolumeElements())
for (PointIndex v : el.Vertices())
if (v > numvertices) numvertices = v;
@ -6821,6 +6822,25 @@ namespace netgen
if (v > numvertices) numvertices = v;
numvertices += 1-PointIndex::BASE;
*/
numvertices = 0;
numvertices =
ParallelReduce (VolumeElements().Size(),
[&](size_t nr)
{
return int(Max(VolumeElements()[nr].Vertices()));
},
[](auto a, auto b) { return a > b ? a : b; },
numvertices);
numvertices =
ParallelReduce (SurfaceElements().Size(),
[&](size_t nr)
{
return int(Max(SurfaceElements()[nr].Vertices()));
},
[](auto a, auto b) { return a > b ? a : b; },
numvertices);
numvertices += 1-PointIndex::BASE;
}
int Mesh :: GetNV () const