netgen/libsrc/meshing/improve3.hpp

126 lines
3.5 KiB
C++
Raw Normal View History

2009-01-13 04:40:13 +05:00
#ifndef FILE_IMPROVE3
#define FILE_IMPROVE3
2011-07-25 17:33:19 +06:00
extern double CalcTotalBad (const Mesh::T_POINTS & points,
const Mesh::T_VOLELEMENTS & elements,
const MeshingParameters & mp);
2009-01-13 04:40:13 +05:00
///
class MeshOptimize3d
{
2011-07-25 17:33:19 +06:00
const MeshingParameters & mp;
2009-01-13 04:40:13 +05:00
public:
2011-07-25 17:33:19 +06:00
MeshOptimize3d (const MeshingParameters & amp) : mp(amp) { ; }
2009-01-13 04:40:13 +05:00
void CombineImprove (Mesh & mesh, OPTIMIZEGOAL goal = OPT_QUALITY);
void SplitImprove (Mesh & mesh, OPTIMIZEGOAL goal = OPT_QUALITY);
void SwapImprove (Mesh & mesh, OPTIMIZEGOAL goal = OPT_QUALITY,
const BitArray * working_elements = NULL);
void SwapImproveSurface (Mesh & mesh, OPTIMIZEGOAL goal = OPT_QUALITY,
const BitArray * working_elements = NULL,
2019-07-09 13:39:16 +05:00
const NgArray< NgArray<int,PointIndex::BASE>* > * idmaps = NULL);
2009-01-13 04:40:13 +05:00
void SwapImprove2 (Mesh & mesh, OPTIMIZEGOAL goal = OPT_QUALITY);
2011-07-25 17:33:19 +06:00
double
CalcBad (const Mesh::T_POINTS & points, const Element & elem, double h)
{
if (elem.GetType() == TET)
return CalcTetBadness (points[elem[0]], points[elem[1]],
points[elem[2]], points[elem[3]], h, mp);
return 0;
}
double CalcTotalBad (const Mesh::T_POINTS & points,
const Mesh::T_VOLELEMENTS & elements)
{
return netgen::CalcTotalBad (points, elements, mp);
}
};
2009-01-13 04:40:13 +05:00
inline double
2011-07-25 17:33:19 +06:00
CalcBad (const Mesh::T_POINTS & points, const Element & elem, double h, const MeshingParameters & mp)
{
if (elem.GetType() == TET)
return CalcTetBadness (points[elem[0]], points[elem[1]],
2011-07-25 14:40:23 +06:00
points[elem[2]], points[elem[3]], h, mp);
return 0;
}
2009-01-13 04:40:13 +05:00
extern int WrongOrientation (const Mesh::T_POINTS & points, const Element & el);
/* Functional depending of inner point inside triangular surface */
class MinFunctionSum : public MinFunction
{
protected:
2019-07-09 13:39:16 +05:00
NgArray<MinFunction*> functions;
2009-01-13 04:40:13 +05:00
public:
virtual double Func (const Vector & x) const;
virtual void Grad (const Vector & x, Vector & g) const;
virtual double FuncGrad (const Vector & x, Vector & g) const;
virtual double FuncDeriv (const Vector & x, const Vector & dir, double & deriv) const;
virtual double GradStopping (const Vector & x) const;
void AddFunction(MinFunction & fun);
const MinFunction & Function(int i) const;
MinFunction & Function(int i);
};
class PointFunction1 : public MinFunction
{
Mesh::T_POINTS & points;
2019-07-09 13:39:16 +05:00
const NgArray<INDEX_3> & faces;
2011-07-25 17:33:19 +06:00
const MeshingParameters & mp;
2009-01-13 04:40:13 +05:00
double h;
public:
PointFunction1 (Mesh::T_POINTS & apoints,
2019-07-09 13:39:16 +05:00
const NgArray<INDEX_3> & afaces,
2011-07-25 17:33:19 +06:00
const MeshingParameters & amp,
2009-01-13 04:40:13 +05:00
double ah);
virtual double Func (const Vector & x) const;
virtual double FuncDeriv (const Vector & x, const Vector & dir, double & deriv) const;
virtual double FuncGrad (const Vector & x, Vector & g) const;
virtual double GradStopping (const Vector & x) const;
};
class JacobianPointFunction : public MinFunction
{
public:
Mesh::T_POINTS & points;
const Mesh::T_VOLELEMENTS & elements;
TABLE<INDEX> elementsonpoint;
PointIndex actpind;
bool onplane;
Vec<3> nv;
public:
JacobianPointFunction (Mesh::T_POINTS & apoints,
const Mesh::T_VOLELEMENTS & aelements);
2014-08-19 17:01:15 +06:00
virtual ~JacobianPointFunction () { ; }
2009-01-13 04:40:13 +05:00
virtual void SetPointIndex (PointIndex aactpind);
virtual double Func (const Vector & x) const;
virtual double FuncGrad (const Vector & x, Vector & g) const;
virtual double FuncDeriv (const Vector & x, const Vector & dir, double & deriv) const;
inline void SetNV(const Vec<3> & anv) {nv = anv; onplane = true;}
inline void UnSetNV(void) {onplane = false;}
};
#endif