mirror of
https://github.com/NGSolve/netgen.git
synced 2024-11-12 00:59:16 +05:00
Merge branch 'respect_only3d_domain_nr_in_meshopt' into 'master'
Respect mp.only3d_domain_nr in volume mesh optimization See merge request ngsolve/netgen!549
This commit is contained in:
commit
d2f0182ee0
@ -323,7 +323,7 @@ void MeshOptimize3d :: CombineImprove (Mesh & mesh,
|
|||||||
(*testout) << "Total badness = " << totalbad << endl;
|
(*testout) << "Total badness = " << totalbad << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto elementsonnode = mesh.CreatePoint2ElementTable();
|
auto elementsonnode = mesh.CreatePoint2ElementTable(nullopt, mp.only3D_domain_nr);
|
||||||
|
|
||||||
Array<std::tuple<PointIndex,PointIndex>> edges;
|
Array<std::tuple<PointIndex,PointIndex>> edges;
|
||||||
BuildEdgeList(mesh, elementsonnode, edges);
|
BuildEdgeList(mesh, elementsonnode, edges);
|
||||||
@ -567,7 +567,7 @@ void MeshOptimize3d :: SplitImprove (Mesh & mesh,
|
|||||||
double bad = 0.0;
|
double bad = 0.0;
|
||||||
double badmax = 0.0;
|
double badmax = 0.0;
|
||||||
|
|
||||||
auto elementsonnode = mesh.CreatePoint2ElementTable();
|
auto elementsonnode = mesh.CreatePoint2ElementTable(nullopt, mp.only3D_domain_nr);
|
||||||
|
|
||||||
Array<double> elerrs(ne);
|
Array<double> elerrs(ne);
|
||||||
|
|
||||||
@ -1312,13 +1312,16 @@ void MeshOptimize3d :: SwapImprove (Mesh & mesh, OPTIMIZEGOAL goal,
|
|||||||
if(el.Flags().fixed)
|
if(el.Flags().fixed)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
if(mp.only3D_domain_nr && mp.only3D_domain_nr != el.GetIndex())
|
||||||
|
continue;
|
||||||
|
|
||||||
for (auto pi : el.PNums())
|
for (auto pi : el.PNums())
|
||||||
if(!free_points[pi])
|
if(!free_points[pi])
|
||||||
free_points.SetBitAtomic(pi);
|
free_points.SetBitAtomic(pi);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
auto elementsonnode = mesh.CreatePoint2ElementTable(free_points);
|
auto elementsonnode = mesh.CreatePoint2ElementTable(free_points, mp.only3D_domain_nr );
|
||||||
|
|
||||||
NgArray<ElementIndex> hasbothpoints;
|
NgArray<ElementIndex> hasbothpoints;
|
||||||
|
|
||||||
@ -2480,7 +2483,8 @@ void MeshOptimize3d :: SwapImprove2 (Mesh & mesh, OPTIMIZEGOAL goal)
|
|||||||
|
|
||||||
// find elements on node
|
// find elements on node
|
||||||
|
|
||||||
auto elementsonnode = mesh.CreatePoint2ElementTable();
|
auto elementsonnode = mesh.CreatePoint2ElementTable(nullopt, mp.only3D_domain_nr);
|
||||||
|
// todo: respect mp.only3D_domain_nr
|
||||||
|
|
||||||
for (SurfaceElementIndex sei = 0; sei < nse; sei++)
|
for (SurfaceElementIndex sei = 0; sei < nse; sei++)
|
||||||
for (int j = 0; j < 3; j++)
|
for (int j = 0; j < 3; j++)
|
||||||
@ -2685,7 +2689,7 @@ void MeshOptimize3d :: SplitImprove2 (Mesh & mesh)
|
|||||||
static Timer topt("Optimize");
|
static Timer topt("Optimize");
|
||||||
|
|
||||||
int ne = mesh.GetNE();
|
int ne = mesh.GetNE();
|
||||||
auto elements_of_point = mesh.CreatePoint2ElementTable();
|
auto elements_of_point = mesh.CreatePoint2ElementTable(nullopt, mp.only3D_domain_nr);
|
||||||
int ntasks = 4*ngcore::TaskManager::GetNumThreads();
|
int ntasks = 4*ngcore::TaskManager::GetNumThreads();
|
||||||
|
|
||||||
const char * savetask = multithread.task;
|
const char * savetask = multithread.task;
|
||||||
|
@ -6814,7 +6814,7 @@ namespace netgen
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Table<ElementIndex, PointIndex> Mesh :: CreatePoint2ElementTable(std::optional<BitArray> points) const
|
Table<ElementIndex, PointIndex> Mesh :: CreatePoint2ElementTable(std::optional<BitArray> points, int domain) const
|
||||||
{
|
{
|
||||||
if(points)
|
if(points)
|
||||||
{
|
{
|
||||||
@ -6826,6 +6826,9 @@ namespace netgen
|
|||||||
if(el.IsDeleted())
|
if(el.IsDeleted())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if(domain && el.GetIndex() != domain)
|
||||||
|
return;
|
||||||
|
|
||||||
for (PointIndex pi : el.PNums())
|
for (PointIndex pi : el.PNums())
|
||||||
if(free_points[pi])
|
if(free_points[pi])
|
||||||
table.Add (pi, ei);
|
table.Add (pi, ei);
|
||||||
@ -6839,6 +6842,9 @@ namespace netgen
|
|||||||
if(el.IsDeleted())
|
if(el.IsDeleted())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if(domain && el.GetIndex() != domain)
|
||||||
|
return;
|
||||||
|
|
||||||
for (PointIndex pi : el.PNums())
|
for (PointIndex pi : el.PNums())
|
||||||
table.Add (pi, ei);
|
table.Add (pi, ei);
|
||||||
}, GetNP());
|
}, GetNP());
|
||||||
|
@ -797,7 +797,7 @@ namespace netgen
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
DLL_HEADER Table<ElementIndex, PointIndex> CreatePoint2ElementTable(std::optional<BitArray> points = std::nullopt) const;
|
DLL_HEADER Table<ElementIndex, PointIndex> CreatePoint2ElementTable(std::optional<BitArray> points = std::nullopt, int domain = 0) const;
|
||||||
DLL_HEADER Table<SurfaceElementIndex, PointIndex> CreatePoint2SurfaceElementTable( int faceindex=0 ) const;
|
DLL_HEADER Table<SurfaceElementIndex, PointIndex> CreatePoint2SurfaceElementTable( int faceindex=0 ) const;
|
||||||
|
|
||||||
DLL_HEADER bool PureTrigMesh (int faceindex = 0) const;
|
DLL_HEADER bool PureTrigMesh (int faceindex = 0) const;
|
||||||
|
@ -304,22 +304,20 @@ namespace netgen
|
|||||||
public:
|
public:
|
||||||
Mesh::T_POINTS & points;
|
Mesh::T_POINTS & points;
|
||||||
const Array<Element, ElementIndex> & elements;
|
const Array<Element, ElementIndex> & elements;
|
||||||
Table<int, PointIndex> &elementsonpoint;
|
Table<ElementIndex, PointIndex> &elementsonpoint;
|
||||||
bool own_elementsonpoint;
|
bool own_elementsonpoint;
|
||||||
const MeshingParameters & mp;
|
const MeshingParameters & mp;
|
||||||
PointIndex actpind;
|
PointIndex actpind;
|
||||||
double h;
|
double h;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PointFunction (Mesh::T_POINTS & apoints,
|
PointFunction (Mesh & mesh, const MeshingParameters & amp);
|
||||||
const Array<Element, ElementIndex> & aelements,
|
|
||||||
const MeshingParameters & amp);
|
|
||||||
PointFunction (const PointFunction & pf);
|
PointFunction (const PointFunction & pf);
|
||||||
virtual ~PointFunction () { if(own_elementsonpoint) delete &elementsonpoint; }
|
virtual ~PointFunction () { if(own_elementsonpoint) delete &elementsonpoint; }
|
||||||
virtual void SetPointIndex (PointIndex aactpind);
|
virtual void SetPointIndex (PointIndex aactpind);
|
||||||
void SetLocalH (double ah) { h = ah; }
|
void SetLocalH (double ah) { h = ah; }
|
||||||
double GetLocalH () const { return h; }
|
double GetLocalH () const { return h; }
|
||||||
const Table<int, PointIndex> & GetPointToElementTable() { return elementsonpoint; };
|
const Table<ElementIndex, PointIndex> & GetPointToElementTable() { return elementsonpoint; };
|
||||||
virtual double PointFunctionValue (const Point<3> & pp) const;
|
virtual double PointFunctionValue (const Point<3> & pp) const;
|
||||||
virtual double PointFunctionValueGrad (const Point<3> & pp, Vec<3> & grad) const;
|
virtual double PointFunctionValueGrad (const Point<3> & pp, Vec<3> & grad) const;
|
||||||
virtual double PointFunctionValueDeriv (const Point<3> & pp, const Vec<3> & dir, double & deriv) const;
|
virtual double PointFunctionValueDeriv (const Point<3> & pp, const Vec<3> & dir, double & deriv) const;
|
||||||
@ -332,23 +330,26 @@ namespace netgen
|
|||||||
: points(pf.points), elements(pf.elements), elementsonpoint(pf.elementsonpoint), own_elementsonpoint(false), mp(pf.mp)
|
: points(pf.points), elements(pf.elements), elementsonpoint(pf.elementsonpoint), own_elementsonpoint(false), mp(pf.mp)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
PointFunction :: PointFunction (Mesh::T_POINTS & apoints,
|
PointFunction :: PointFunction (Mesh & mesh, const MeshingParameters & amp)
|
||||||
const Array<Element, ElementIndex> & aelements,
|
: points(mesh.Points()), elements(mesh.VolumeElements()), elementsonpoint(* new Table<ElementIndex,PointIndex>()), own_elementsonpoint(true), mp(amp)
|
||||||
const MeshingParameters & amp)
|
|
||||||
: points(apoints), elements(aelements), elementsonpoint(* new Table<int,PointIndex>()), own_elementsonpoint(true), mp(amp)
|
|
||||||
{
|
{
|
||||||
static Timer tim("PointFunction - build elementsonpoint table"); RegionTimer reg(tim);
|
static Timer tim("PointFunction - build elementsonpoint table"); RegionTimer reg(tim);
|
||||||
elementsonpoint = ngcore::CreateSortedTable<int, PointIndex>( elements.Range(),
|
BitArray free_points(points.Size()+PointIndex::BASE);
|
||||||
[&](auto & table, ElementIndex ei)
|
free_points.Clear();
|
||||||
|
|
||||||
|
ParallelForRange(elements.Range(), [&] (auto myrange)
|
||||||
{
|
{
|
||||||
const auto & el = elements[ei];
|
for (ElementIndex eli : myrange)
|
||||||
|
{
|
||||||
if(el.NP()!=4)
|
const auto & el = elements[eli];
|
||||||
return;
|
if(el.Flags().fixed || el.NP()!=4 || (mp.only3D_domain_nr && mp.only3D_domain_nr != el.GetIndex()) )
|
||||||
|
for (auto pi : el.PNums())
|
||||||
for (PointIndex pi : el.PNums())
|
if(free_points[pi])
|
||||||
table.Add (pi, ei);
|
free_points.SetBitAtomic(pi);
|
||||||
}, points.Size());
|
}
|
||||||
|
});
|
||||||
|
free_points.Invert();
|
||||||
|
elementsonpoint = mesh.CreatePoint2ElementTable(free_points, mp.only3D_domain_nr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PointFunction :: SetPointIndex (PointIndex aactpind)
|
void PointFunction :: SetPointIndex (PointIndex aactpind)
|
||||||
@ -493,19 +494,15 @@ namespace netgen
|
|||||||
{
|
{
|
||||||
DenseMatrix m;
|
DenseMatrix m;
|
||||||
public:
|
public:
|
||||||
CheapPointFunction (Mesh::T_POINTS & apoints,
|
CheapPointFunction (Mesh & mesh, const MeshingParameters & amp);
|
||||||
const Array<Element, ElementIndex> & aelements,
|
|
||||||
const MeshingParameters & amp);
|
|
||||||
virtual void SetPointIndex (PointIndex aactpind);
|
virtual void SetPointIndex (PointIndex aactpind);
|
||||||
virtual double PointFunctionValue (const Point<3> & pp) const;
|
virtual double PointFunctionValue (const Point<3> & pp) const;
|
||||||
virtual double PointFunctionValueGrad (const Point<3> & pp, Vec<3> & grad) const;
|
virtual double PointFunctionValueGrad (const Point<3> & pp, Vec<3> & grad) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
CheapPointFunction :: CheapPointFunction (Mesh::T_POINTS & apoints,
|
CheapPointFunction :: CheapPointFunction (Mesh & mesh, const MeshingParameters & amp)
|
||||||
const Array<Element, ElementIndex> & aelements,
|
: PointFunction (mesh, amp)
|
||||||
const MeshingParameters & amp)
|
|
||||||
: PointFunction (apoints, aelements, amp)
|
|
||||||
{
|
{
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
@ -1348,14 +1345,14 @@ void Mesh :: ImproveMesh (const MeshingParameters & mp, OPTIMIZEGOAL goal)
|
|||||||
int np = GetNP();
|
int np = GetNP();
|
||||||
int ne = GetNE();
|
int ne = GetNE();
|
||||||
|
|
||||||
PointFunction pf_glob(points, volelements, mp);
|
PointFunction pf_glob(*this, mp);
|
||||||
|
|
||||||
auto & elementsonpoint = pf_glob.GetPointToElementTable();
|
auto & elementsonpoint = pf_glob.GetPointToElementTable();
|
||||||
|
|
||||||
const auto & getDofs = [&] (int i)
|
const auto & getDofs = [&] (int i)
|
||||||
{
|
{
|
||||||
i += PointIndex::BASE;
|
i += PointIndex::BASE;
|
||||||
return FlatArray<int>(elementsonpoint[i].Size(), elementsonpoint[i].Data());
|
return FlatArray<ElementIndex>(elementsonpoint[i].Size(), elementsonpoint[i].Data());
|
||||||
};
|
};
|
||||||
|
|
||||||
Array<int> colors(points.Size());
|
Array<int> colors(points.Size());
|
||||||
|
Loading…
Reference in New Issue
Block a user