Toast++  1.0.2 (r.539)
Forward and inverse modelling in optical tomography
node.h
1 // -*-C++-*-
2 // ==========================================================================
3 // Module libfe
4 // File node.h
5 // Declaration of class Node
6 //
7 // Inheritance:
8 // ------------
9 // RVector ----> Point ----> Node
10 // ==========================================================================
11 
12 #ifndef __NODE_H
13 #define __NODE_H
14 
15 #define BND_NONE 0
16 #define BND_DIRICHLET 3
17 #define BND_NEUMANN 5
18 #define BND_ROBIN (BND_DIRICHLET & BND_NEUMANN)
19 #define BND_ANY (BND_DIRICHLET | BND_NEUMANN)
20 #define BND_INTERNAL 2 // physical boundary for extrapolated b.c.
21 #define INTERNAL BND_NONE
22 #define XLAYER_INTERNAL 4 // internal nodes in extrapolation band
23 #define BND_VOID 8
24 
25 // ==========================================================================
26 // prototypes
27 
28 class Node;
29 
30 FELIB void Swap (Node &n1, Node &n2);
31 FELIB double Dist (const Node &n1, const Node &n2);
32 FELIB std::istream& operator>> (std::istream& is, Node& nd);
33 FELIB std::ostream& operator<< (std::ostream& os, Node& nd);
34 
35 
36 // ==========================================================================
37 // class Node
38 
39 class FELIB Node : public Point {
40 public:
41  // constructors
42  Node ();
43  Node (int dim, char _bndtp = BND_NONE);
44  Node (const Node& nd);
45 
46  void Copy (const Node &nd);
47  // as operator= but reallocates *this, so dimensions need not be the same
48 
49  // assignment operators
50  Node &operator= (const Node &nd);
51 
52  Node &operator= (const Point &pt);
53 
54  // relational operators
55  bool operator== (const Node& nd) const;
56  bool operator!= (const Node& nd) const;
57 
58  friend FELIB void Swap (Node &n1, Node &n2);
59  // Swap two nodes. Assumes same dimension
60 
61  friend FELIB double Dist (const Node &n1, const Node &n2);
62  // distance between two nodes
63 
64  // boundary type-related functions
65  char BndTp() const { return bndtp; }
66  bool isInternalInterface() const { return bndtp == 2; } // label 'I'
67  bool isBnd() const { return bndtp != 0 && bndtp != 2; }
68  bool isAnyBnd() const { return bndtp != 0 ; }
69  void SetBndTp (char _bndtp) { bndtp = _bndtp; }
70  double Phi () const { return phi; }
71 
72  // region-related functions
73  int Region() const { return region; }
74  void SetRegion (int _region) { region = _region; }
75 
76  // I/O
77  friend FELIB std::istream& operator>> (std::istream& i, Node& nd);
78  friend FELIB std::ostream& operator<< (std::ostream& o, Node& nd);
79 
80 protected:
81  char bndtp; // id for boundary type
82  int region; // region number (-1 = no region)
83  double phi; // Dirichlet condition (assumes bndtp=BND_DIRICHLET)
84 };
85 
86 
87 // ==========================================================================
88 // external variables, defined in node.cc
89 
90 #ifndef __NODE_CC
91 extern char BndId[8];
92 // character identifier for boundary type, defined in node.cc
93 #endif // !__NODE_CC
94 
95 #endif // !__NODE_H
96 
void Copy(const TVector &v)
Vector copy. Replaces the vector with a copy of 'v'.
Definition: node.h:39
friend std::istream & operator>>(std::istream &is, TVector< double > &v)
Read vector from input stream.
friend std::ostream & operator<<(std::ostream &os, const TVector< double > &v)
Write vector to output stream.
Definition: point.h:18
friend bool operator!=(const TVector< double > &v1, const TVector< double > &v2)
Vector comparison (relational operator)
friend bool operator==(const TVector< double > &v1, const TVector< double > &v2)
Vector comparison (relational operator)