netgen/libsrc/geom2d/geometry2d.hpp

220 lines
5.0 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:
2018-12-06 21:53:44 +05:00
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;
2018-01-08 20:45:53 +05:00
/// perform anisotropic refinement (hp-refinement) to edge
double hpref_left;
2018-01-08 20:45:53 +05:00
/// perform anisotropic refinement (hp-refinement) to edge
double hpref_right;
2011-02-28 17:59:27 +05:00
///
int layer;
2018-12-06 21:53:44 +05:00
SplineSegExt (SplineSeg<2> & hseg)
: seg(&hseg)
2011-02-28 17:59:27 +05:00
{
layer = 1;
}
2018-12-06 21:53:44 +05:00
// default constructor for archive
SplineSegExt() {}
2011-02-28 17:59:27 +05:00
2013-02-06 18:55:47 +06:00
~SplineSegExt ()
{
2018-12-06 21:53:44 +05:00
delete seg;
}
virtual void DoArchive(Archive& ar)
{
ar & seg & leftdom & rightdom & reffak & hmax & bc & copyfrom
& hpref_left & hpref_right & layer;
2013-02-06 18:55:47 +06:00
}
2011-02-28 17:59:27 +05:00
virtual const GeomPoint<2> & StartPI () const
{
2018-12-06 21:53:44 +05:00
return seg->StartPI();
2011-02-28 17:59:27 +05:00
}
virtual const GeomPoint<2> & EndPI () const
{
2018-12-06 21:53:44 +05:00
return seg->EndPI();
2011-02-28 17:59:27 +05:00
}
virtual Point<2> GetPoint (double t) const
{
2018-12-06 21:53:44 +05:00
return seg->GetPoint(t);
2011-02-28 17:59:27 +05:00
}
virtual Vec<2> GetTangent (const double t) const
{
2018-12-06 21:53:44 +05:00
return seg->GetTangent(t);
2011-02-28 17:59:27 +05:00
}
virtual void GetDerivatives (const double t,
Point<2> & point,
Vec<2> & first,
Vec<2> & second) const
{
2018-12-06 21:53:44 +05:00
seg->GetDerivatives (t, point, first, second);
2011-02-28 17:59:27 +05:00
}
virtual void GetCoeff (Vector & coeffs) const
{
2018-12-06 21:53:44 +05:00
seg->GetCoeff (coeffs);
2011-02-28 17:59:27 +05:00
}
virtual void GetPoints (int n, Array<Point<2> > & points) const
{
2018-12-06 21:53:44 +05:00
seg->GetPoints (n, points);
2011-02-28 17:59:27 +05:00
}
virtual double MaxCurvature () const
{
2018-12-06 21:53:44 +05:00
return seg->MaxCurvature();
2011-02-28 17:59:27 +05:00
}
virtual string GetType () const
{
2018-12-06 21:53:44 +05:00
return seg->GetType();
2011-02-28 17:59:27 +05:00
}
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
{
2018-12-06 21:53:44 +05:00
return seg->InConvexHull (p, eps);
2016-09-07 12:05:03 +05:00
}
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 ) ;
2018-12-14 16:01:58 +05:00
void DoArchive(Archive& ar)
{
SplineGeometry<2>::DoArchive(ar);
ar & materials & maxh & quadmeshing & tensormeshing & layer & bcnames & elto0;
}
2011-02-28 17:59:27 +05:00
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