Toast++  1.0.2 (r.539)
Forward and inverse modelling in optical tomography
tri3_qr.h
1 // -*-C++-*-
2 // ==========================================================================
3 // Module libfe
4 // File tri3.h
5 // Declaration of class Triangle3_qr
6 // An alternative implementation which uses Gaussian quadrature
7 //
8 // Inheritance:
9 // ------------
10 // Element ----> Element2D ----> Triangle3
11 // ==========================================================================
12 
13 #ifndef __TRI3_QR_H
14 #define __TRI3_QR_H
15 
16 #define TRI3_STORE_COORDS
17 
18 class Triangle3_qr: public Element2D {
19 public:
20 
21  Triangle3_qr () { Node = new int[nNode()]; }
22  Triangle3_qr (const Triangle3_qr& el);
23  ~Triangle3_qr () { delete []Node; }
24 
25  void Initialise (const NodeList &nlist);
26 
27  BYTE Type () const { return ELID_TRI3QR; }
28  // returns element type id
29 
30  int nNode() const { return 3; }
31  // returns number of nodes per element
32 
33  int nSide () const { return 3; };
34  // number of sides per element
35 
36  int nSideNode (int /*side*/) const { return 2; };
37  // returns number of nodes attached to side 'side'
38 
39  int SideNode (int side, int node) const;
40  // returns number of 'node'-th node of side 'side'
41 
42  const Matrix &Jacobian() const { return jac; }
43  // Return the element's 2x2 Jacobian matrix required for mapping
44  // between local and global coordinates
45 
46  double DetJ() const { return djac; }
47  // Determinant of the Jacobian
48 
49  Point Local (const NodeList& nlist, const Point& glob) const;
50  // returns the local coordinate corresponding to global coordinate 'glob'
51 
52  Point NodeLocal (int node) const;
53  // returns local coordinates of node 'node'
54 
55  RVector DirectionCosine (int side, Matrix& jacin);
56  // returns a vector of direction cosines in global coordinates of the
57  // normal to side 'side'.
58 
59 // ##########################################################################
60 // requires update from here!
61 
62  bool LContains (const Point& loc) const;
63  // returns TRUE if point 'loc' (in local coordinates of the element) is
64  // within the standard triangle
65 
66  bool GContains (const Point& glob, const NodeList& nlist) const;
67  // returns TRUE if point 'glob' (in global coordinates) is within the
68  // element. nlist is the mesh node coordinate list
69 
70  RVector LocalShapeF (const Point &loc) const;
71  // vector of shape functions u_i(loc) at point 'loc' given in local
72  // element coordinates
73 
74  Matrix LocalShapeD (const Point &loc) const;
75  // 2x3 matrix of shape function derivatives (d u_j)/(d x_i) at point 'loc'
76  // given in local element coordinates
77 
78  RVector GlobalShapeF (const NodeList& nlist, const Point& glob) const;
79  // returns the shape functions for each node at a point, given in global
80  // coordinates
81 
82  Matrix GlobalShapeD (const NodeList& nlist, const Point& glob) const;
83  // returns derivatives of shape functions in global coordinates at point
84  // `glob', given in global coordinates
85 
86  double IntFFF (int i, int j, int k) const;
87  // returns a single element of integral over element of product of three
88  // shape functions:
89  // IntFFF = Int_el { F_i(r) * F_j(r) * F_k(r) } dr
90 
91 #ifdef UNDEF
92  // MS 29.6.99 Removed because incompatible with quadratic shape functions
93 
94  void IntFFF (double &iii, double &iij, double &ijk) const;
95  // returns the values of the FFF tensor for:
96  // all indices equal (iii)
97  // two indices equal (iij)
98  // all indices different (ijk)
99 #endif
100 
101  SymMatrix IntPFF (const RVector& P) const;
102  // Returns integral over element of product of two shape functions and a
103  // function P defined on nodes:
104  // PFF = Int_el { P(r) F_i(r) F_J(r) } dr
105  // Vector P contains the complete nodal solution for the mesh
106 
107  double IntPFF (int i, int j, const RVector& P) const;
108  // Returns a single element of IntPFF
109 
110  double IntFDD (int i, int j, int k) const
111  { return (j >= k ? intdd[j][k] : intdd[k][j]) * 0.3333333333; }
112  // returns a single element of integral over element:
113  // IntFDD = Int_el { F_i(r) * D_j(r) * D_k(r) } dr
114 
115  SymMatrix IntPDD (const RVector& P) const
116  { return intdd * ((P[Node[0]]+P[Node[1]]+P[Node[2]])/3.0); }
117  // Returns integral over element of product of two shape derivatives and a
118  // function P defined in nodal basis:
119  // PDD = Int_el { P(r) D_i(r) D_j(r) } dr
120  // Vector P contains the complete nodal solution for the mesh
121 
122  double IntPDD (int i, int j, const RVector &P) const {
123  RANGE_CHECK(i >= 0 && i < 3 && j >= 0 && j < 3);
124  return (i >= j ? intdd[i][j] : intdd[j][i]) *
125  ((P[Node[0]]+P[Node[1]]+P[Node[2]])/3.0);
126  }
127  // Returns a single element of IntPDD
128 
129  SymMatrix BndIntPFF (const RVector &P) const
130  { return intbff * ((P[Node[0]]+P[Node[1]]+P[Node[2]])/3.0); }
131  // This is a hack! Really P would have to be taken into the integral,
132  // rather than just averaged.
133 
134  double BndIntPFF (int i, int j, const RVector &P) const {
135  RANGE_CHECK(i >= 0 && i < 3 && j >= 0 && j < 3);
136  return (i >= j ? intbff[i][j] : intbff[j][i])
137  * ((P[Node[0]]+P[Node[1]]+P[Node[2]])/3.0);
138  }
139  // Returns a single element of BndIntPFF
140 
141  // SymMatrix FTF_bnd (const Matrix &geom, int side);
142  // returns line integral of Fi(T) Fj along side `side' (0-2)
143 
144  // int QuadRule (const double **wght, const Point **absc) const;
145  // calculates abscissae and weights for numerical quadrature rules on
146  // standard element, return number of points
147 
148  // int BndQuadRule (int side, double** wght, Point** absc, double* coeff);
149  // returns weights and abscissae of a line quadrature rule along `side'
150  // `coeff' is a scaling factor. Return value is number of points
151 
152  // double UnitLength (Point& /*loc*/, Matrix& geom, int side);
153  // returns the unit length along the specified element side; used for line
154  // integrations
155 
156  // void ConvLineQuadrature (Point** absc, double* labsc, int nqp, int side,
157  // double* coeff);
158  // forms line integration rule along side from equivalent 1d integration
159  // rule
160 
161  int GlobalIntersection (const NodeList &nlist, const Point &p1,
162  const Point &p2, Point **list);
163  // Same as 'Intersection' but p1 and p2 given in global coords
164  // The return list however is still in local coords
165 
166  int Intersection (const Point &p1, const Point &p2, Point** pi);
167  // creates a list of points where the line defined by p1 and p2 intersects
168  // the element (in local coordinates) or starts/ends within the element.
169  // Returns the length of the list
170 
171 protected:
172 
173  double ComputeSize (const NodeList &nlist) const;
174  // area of triangle in global coordinates
175 
176  SymMatrix ComputeIntFF (const NodeList &nlist) const;
177  // Returns integral over element of product of shape functions:
178  // FF = Int_el { F_i(r) F_j(r) } dr
179 
180  SymMatrix ComputeIntDD (const NodeList &nlist) const;
181  // Returns integral over element of product of shape derivatives:
182  // DD = Int_el { D_i(r) D_j(r) } dr
183 
184  SymMatrix ComputeBndIntFF (const NodeList& nlist) const;
185  // Returns line integral of product of two shape functions along sides of
186  // the element which belong to the mesh boundary
187  // If the element does not contain any boundary sides then the returned
188  // matrix is empty.
189 
190 private:
191  SquareMatrix jac;
192  // 2x2 matrix of derivatives of global coordinates with respect to local
193 
194  double djac;
195  // determinant of jac
196 
197  double intfff_scale[3];
198  // factors for calculating IntFFF(i,j,k)
199 
200 #ifdef TRI3_STORE_COORDS
201  double n0x, n0y, n1x, n1y, n2x, n2y;
202 #endif
203 };
204 
205 #endif // !__TRI3_QR_H
Definition: ndlist.h:14
Definition: node.h:39
Definition: point.h:18
Definition: tri3_qr.h:18