Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
ElmerCSC
GitHub Repository: ElmerCSC/elmerfem
Path: blob/devel/ElmerGUI/netgen/libsrc/geom2d/splinegeometry.hpp
3206 views
1
/*
2
3
4
JS, Nov 2007
5
6
7
The 2D/3D template-base classes should go into the libsrc/gprim directory
8
9
in geom2d only 2D - Geometry classes (with material properties etc.)
10
11
12
*/
13
14
15
16
17
18
#ifndef _FILE_SPLINEGEOMETRY
19
#define _FILE_SPLINEGEOMETRY
20
#include "../csg/csgparser.hpp"
21
22
///
23
extern void LoadBoundarySplines (const char * filename,
24
ARRAY < GeomPoint<2> > & geompoints,
25
ARRAY < SplineSeg<2>* > & splines,
26
double & elto0);
27
///
28
extern void PartitionBoundary (const ARRAY < SplineSeg<2>* > & splines,
29
double h, double elto0,
30
Mesh & mesh2d);
31
32
33
// allow to turn off messages: cover all couts !!
34
extern int printmessage_importance;
35
36
template < int D >
37
class SplineGeometry
38
{
39
ARRAY < GeomPoint<D> > geompoints;
40
ARRAY < SplineSeg<D>* > splines;
41
double elto0;
42
ARRAY<char*> materials;
43
ARRAY<string*> bcnames;
44
ARRAY<double> maxh;
45
ARRAY<bool> quadmeshing;
46
ARRAY<bool> tensormeshing;
47
48
private:
49
void AppendSegment(SplineSeg<D> * spline, const int leftdomain, const int rightdomain,
50
const int bc,
51
const double reffac, const bool hprefleft, const bool hprefright,
52
const int copyfrom);
53
54
public:
55
~SplineGeometry();
56
57
int Load (const ARRAY<double> & raw_data, const int startpos = 0);
58
void Load (const char * filename);
59
void CSGLoad (CSGScanner & scan);
60
61
void LoadData( ifstream & infile );
62
void LoadDataNew ( ifstream & infile );
63
void LoadDataV2 ( ifstream & infile );
64
65
void PartitionBoundary (double h, Mesh & mesh2d);
66
67
void GetRawData (ARRAY<double> & raw_data) const;
68
69
void CopyEdgeMesh (int from, int to, Mesh & mesh2d, Point3dTree & searchtree);
70
71
const ARRAY<SplineSeg<D>*> & GetSplines () const
72
{ return splines; }
73
74
int GetNSplines (void) const { return splines.Size(); }
75
string GetSplineType (const int i) const { return splines[i]->GetType(); }
76
SplineSeg<D> & GetSpline (const int i) {return *splines[i];}
77
const SplineSeg<D> & GetSpline (const int i) const {return *splines[i];}
78
79
void GetBoundingBox (Box<D> & box) const;
80
Box<D> GetBoundingBox () const
81
{ Box<D> box; GetBoundingBox (box); return box; }
82
83
int GetNP () const { return geompoints.Size(); }
84
const GeomPoint<D> & GetPoint(int i) const { return geompoints[i]; }
85
86
void SetGrading (const double grading);
87
void AppendPoint (const double x, const double y, const double reffac = 1., const bool hpref = false);
88
void AppendPoint (const Point<D> & p, const double reffac = 1., const bool hpref = false);
89
90
void AppendLineSegment (const int n1, const int n2,
91
const int leftdomain, const int rightdomain, const int bc = -1,
92
const double reffac = 1.,
93
const bool hprefleft = false, const bool hprefright = false,
94
const int copyfrom = -1);
95
void AppendSplineSegment (const int n1, const int n2, const int n3,
96
const int leftdomain, const int rightdomain, const int bc = -1,
97
const double reffac = 1.,
98
const bool hprefleft = false, const bool hprefright = false,
99
const int copyfrom = -1);
100
void AppendCircleSegment (const int n1, const int n2, const int n3,
101
const int leftdomain, const int rightdomain, const int bc = -1,
102
const double reffac = 1.,
103
const bool hprefleft = false, const bool hprefright = false,
104
const int copyfrom = -1);
105
void AppendDiscretePointsSegment (const ARRAY< Point<D> > & points,
106
const int leftdomain, const int rightdomain, const int bc = -1,
107
const double reffac = 1.,
108
const bool hprefleft = false, const bool hprefright = false,
109
const int copyfrom = -1);
110
void TestComment ( ifstream & infile ) ;
111
void GetMaterial( const int domnr, char* & material );
112
113
double GetDomainMaxh ( const int domnr );
114
bool GetDomainQuadMeshing ( int domnr )
115
{
116
if ( quadmeshing.Size() ) return quadmeshing[domnr-1];
117
else return false;
118
}
119
bool GetDomainTensorMeshing ( int domnr )
120
{
121
if ( tensormeshing.Size() ) return tensormeshing[domnr-1];
122
else return false;
123
}
124
125
string GetBCName ( const int bcnr ) const;
126
127
string * BCNamePtr ( const int bcnr );
128
};
129
130
131
void MeshFromSpline2D (SplineGeometry<2> & geometry,
132
Mesh *& mesh,
133
MeshingParameters & mp);
134
135
136
137
typedef SplineGeometry<2> SplineGeometry2d;
138
139
140
#endif // _FILE_SPLINEGEOMETRY
141
142