netgen/libsrc/geom2d/geometry2d.hpp

208 lines
4.6 KiB
C++
Raw Normal View History

2009-01-13 04:40:13 +05:00
#ifndef FILE_GEOMETRY2D
#define FILE_GEOMETRY2D
/* *************************************************************************/
/* File: geometry2d.hpp */
/* Author: Joachim Schoeberl */
/* Date: 20. Jul. 02 */
/* *************************************************************************/
#include <myadt.hpp>
#include <gprim.hpp>
2009-09-07 17:50:13 +06:00
2011-02-28 18:34:54 +05:00
// #include "../gprim/spline.hpp"
2011-02-28 19:17:25 +05:00
// #include "../gprim/splinegeometry.hpp"
2009-01-13 04:40:13 +05:00
#include "geom2dmesh.hpp"
2009-09-07 17:50:13 +06:00
2011-02-28 17:59:27 +05:00
namespace netgen
{
class SplineSegExt : public SplineSeg<2>
{
public:
2011-02-28 18:34:54 +05:00
const SplineSeg<2> & seg;
2011-02-28 17:59:27 +05:00
/// left domain
int leftdom;
/// right domain
int rightdom;
/// refinement at line
double reffak;
/// maximal h;
double hmax;
/// boundary condition number
int bc;
/// copy spline mesh from other spline (-1.. do not copy)
int copyfrom;
/// perfrom anisotropic refinement (hp-refinement) to edge
double hpref_left;
2011-02-28 17:59:27 +05:00
/// perfrom anisotropic refinement (hp-refinement) to edge
double hpref_right;
2011-02-28 17:59:27 +05:00
///
int layer;
2011-02-28 18:34:54 +05:00
SplineSegExt (const SplineSeg<2> & hseg)
2011-02-28 17:59:27 +05:00
: seg(hseg)
{
layer = 1;
}
2013-02-06 18:55:47 +06:00
~SplineSegExt ()
{
delete &seg;
}
2011-02-28 17:59:27 +05:00
virtual const GeomPoint<2> & StartPI () const
{
return seg.StartPI();
}
virtual const GeomPoint<2> & EndPI () const
{
return seg.EndPI();
}
virtual Point<2> GetPoint (double t) const
{
return seg.GetPoint(t);
}
virtual Vec<2> GetTangent (const double t) const
{
return seg.GetTangent(t);
}
virtual void GetDerivatives (const double t,
Point<2> & point,
Vec<2> & first,
Vec<2> & second) const
{
seg.GetDerivatives (t, point, first, second);
}
virtual void GetCoeff (Vector & coeffs) const
{
seg.GetCoeff (coeffs);
}
virtual void GetPoints (int n, Array<Point<2> > & points) const
{
seg.GetPoints (n, points);
}
virtual double MaxCurvature () const
{
return seg.MaxCurvature();
}
virtual string GetType () const
{
return seg.GetType();
}
2012-08-27 22:07:27 +06:00
virtual double CalcCurvature (double t) const
{
Point<2> point;
Vec<2> first, second;
GetDerivatives (t, point, first, second);
double curv = fabs(first(0)*second(1)-first(1)*second(0)) / pow(first.Length(), 3);
return curv;
}
2016-09-07 12:05:03 +05:00
virtual bool InConvexHull (Point<2> p, double eps) const
{
return seg.InConvexHull (p, eps);
}
2011-02-28 17:59:27 +05:00
};
class SplineGeometry2d : public SplineGeometry<2>, public NetgenGeometry
{
protected:
Array<char*> materials;
Array<double> maxh;
Array<bool> quadmeshing;
Array<bool> tensormeshing;
Array<int> layer;
Array<string*> bcnames;
double elto0 = 1.0;
2011-02-28 17:59:27 +05:00
public:
2011-09-02 18:36:54 +06:00
DLL_HEADER virtual ~SplineGeometry2d();
2011-02-28 17:59:27 +05:00
2011-09-02 18:36:54 +06:00
DLL_HEADER void Load (const char * filename);
2011-02-28 17:59:27 +05:00
2011-09-02 18:36:54 +06:00
DLL_HEADER void LoadData( ifstream & infile );
DLL_HEADER void LoadDataNew ( ifstream & infile );
DLL_HEADER void LoadDataV2 ( ifstream & infile );
2011-02-28 17:59:27 +05:00
void TestComment ( ifstream & infile ) ;
const SplineSegExt & GetSpline (const int i) const
{
return dynamic_cast<const SplineSegExt&> (*splines[i]);
}
SplineSegExt & GetSpline (const int i)
{
return dynamic_cast<SplineSegExt&> (*splines[i]);
}
DLL_HEADER virtual int GenerateMesh (shared_ptr<Mesh> & mesh, MeshingParameters & mparam);
2011-02-28 17:59:27 +05:00
2012-08-27 22:07:27 +06:00
void PartitionBoundary (MeshingParameters & mp, double h, Mesh & mesh2d);
2011-02-28 17:59:27 +05:00
void CopyEdgeMesh (int from, int to, Mesh & mesh2d, Point3dTree & searchtree);
2015-09-12 18:02:56 +05:00
void GetMaterial (int domnr, char* & material );
void SetMaterial (int domnr, const string & material);
2011-02-28 17:59:27 +05:00
double GetDomainMaxh ( const int domnr );
2015-10-21 20:49:23 +05:00
void SetDomainMaxh ( const int domnr, double maxh );
2011-02-28 17:59:27 +05:00
bool GetDomainQuadMeshing ( int domnr )
{
if ( quadmeshing.Size() ) return quadmeshing[domnr-1];
else return false;
}
bool GetDomainTensorMeshing ( int domnr )
{
if ( tensormeshing.Size() ) return tensormeshing[domnr-1];
else return false;
}
int GetDomainLayer ( int domnr )
{
if ( layer.Size() ) return layer[domnr-1];
else return 1;
}
string GetBCName (int bcnr) const;
void SetBCName (int bcnr, string name);
int GetBCNumber (string name) const; // 0 if not exists
int AddBCName (string name);
2011-02-28 17:59:27 +05:00
string * BCNamePtr ( const int bcnr );
2011-09-02 18:36:54 +06:00
DLL_HEADER virtual Refinement & GetRefinement () const;
2011-02-28 17:59:27 +05:00
};
}
2009-01-13 04:40:13 +05:00
#endif