Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
ElmerCSC
GitHub Repository: ElmerCSC/elmerfem
Path: blob/devel/meshgen2d/src/include/GeometryEdge.h
3203 views
1
#if !defined( BL_GEOMETRYEDGE_H )
2
#define BL_GEOMETRYEDGE_H
3
4
#include <fstream>
5
#include <vector>
6
#include <map>
7
8
#include "GeometryNode.h"
9
#include "MeshNode.h"
10
#include "BoundaryElement.h"
11
12
enum edge_type { VIRTUAL = 0, OUTER, INNER };
13
14
class BGMesh;
15
16
typedef std::map< int, Node * > NodeMap;
17
typedef std::map< int, Node * >::iterator NodeMapIt;
18
19
class GeometryEdge
20
{
21
public:
22
friend std::ostream& operator<< (std::ostream& o, const GeometryEdge& A);
23
24
GeometryEdge( int nSegments = 0 );
25
GeometryEdge( const int t, int nSegments = 0 );
26
~GeometryEdge() { }
27
28
void addNode(GeometryNode* a) { dots.push_back(a); }
29
30
void addBGMesh(BGMesh *m) { bgMeshes.push_back(m); }
31
32
virtual int size() { return nodes.size(); }
33
34
virtual void discretize( NodeMap& allNodes );
35
36
void exportNodes(std::vector<Node*>& strip, int direction);
37
38
virtual void exportGeometryNodes(
39
std::vector<GeometryNode*>& strip, const int direction)
40
{
41
if( direction > 0 )
42
std::copy( dots.begin(), dots.end(), std::back_inserter( strip ) );
43
else
44
std::copy( dots.rbegin(), dots.rend(), std::back_inserter( strip ) );
45
}
46
47
void elements(std::vector< BoundaryElement * >& strip, int direction);
48
49
GeometryNode* base() { return dots.front(); }
50
GeometryNode* end() { return dots.back(); }
51
52
void setBoundaryTag( const int t ) { boundaryTag = t; }
53
void makeOuter() { type = OUTER; }
54
void makeInner() { type = INNER; }
55
void makeVirtual() { type = VIRTUAL; }
56
57
bool isVirtual() { return type == VIRTUAL; }
58
bool isOuter() { return type == OUTER; }
59
60
bool isConstant() { return segments > 0; }
61
void setSegments(int s) { segments = s; }
62
63
void midNodes( Node*& a, Node*& b, int dir );
64
65
int tag;
66
67
void getGridPoints(double ox, double oy, double cellsize, std::vector<int> &x, std::vector<int> &y, std::vector<double> &delta);
68
protected:
69
void discretizeConstantSegment( int nSeg, NodeMap& allNodes, GeometryNode *from, GeometryNode *to );
70
void discretizeGradedSegment( NodeMap& allNodes, GeometryNode *from, GeometryNode *to );
71
72
double interpolate(double x, double y);
73
74
std::vector< GeometryNode* > dots;
75
std::vector<Node*> nodes;
76
77
int segments;
78
int boundaryTag;
79
edge_type type;
80
81
std::vector< BoundaryElement * > bels;
82
83
std::vector< BGMesh * > bgMeshes;
84
};
85
86
std::ostream& operator<< (std::ostream& o, const GeometryEdge& A);
87
88
#endif /* BL_GEOMETRYEDGE_H */
89
90