Toast++  1.0.2 (r.539)
Forward and inverse modelling in optical tomography
tri3D6.h
1 // -*-C++-*-
2 // ==========================================================================
3 // Module libfe
4 // File tri3D6.h
5 // Declaration of class Triangle3D6 (as Triangle6 but points are 3D)
6 //
7 // 6-noded triangle for implementation of quadratic shape functions
8 //
9 // Node arrangement: N2 N3 is on side 0
10 // ----------------- + N4 is on side 1
11 // |\ N5 is on side 2
12 // | \ ---------------
13 // | \ The local element has node coordinates
14 // N5+ +N4 N0 = (0,0)
15 // | \ N1 = (1,0)
16 // | \ N2 = (0,1)
17 // | \ N3 = (0.5,0)
18 // N0+---+---+N1 N4 = (0.5,0.5)
19 // N3 N5 = (0,0.5)
20 //
21 // Inheritance:
22 // ------------
23 // Element
24 // ---> Element_Unstructured
25 // ---> Element_Unstructured_2D
26 // ---> Triangle6
27 // ---> Triangle3D6
28 // ==========================================================================
29 #ifndef __TRI3D6_H
30 #define __TRI3D6_H
31 
32 #include "toastdef.h"
33 
34 const int n_gauss=7;
35 const double beta1=0.47014206410511508;
36 const double beta2=0.10128650732345633;
37 const double alfa1=0.0597158717897698;
38 const double alfa2=0.7974269853530873;
39 
40 const double xg_1[7]={1./3.,alfa1,beta1,beta1,alfa2,beta2,beta2};
41 const double xg_2[7]={1./3.,beta1,alfa1,beta1,beta2,alfa2,beta2};
42 const double xg_3[7]={1./3.,beta1,beta1,alfa1,beta2,beta2,alfa2};
43 
44 const double wg[7]={0.225/2.,0.13239415278850619/2.,0.13239415278850619/2.,
45  0.13239415278850619/2.,
46  0.12593918054482713/2.,0.12593918054482713/2.,
47  0.12593918054482713/2.};
48 
49 class Surface;
50 RVector FELIB cross3 (RVector& a, RVector& b);
51 
52 class FELIB Triangle3D6: public Triangle6 {
53 public:
54 
55  Triangle3D6();
56  Triangle3D6 (const Triangle3D6& el);
57  ~Triangle3D6();
58  // constructors, destructor
59 
60  void Initialise (const NodeList& nlist);
61 
62  BYTE Type () const { return ELID_TRI3D6; }
63  // returns element type id
64 
65  int Dimension (void) const { return 3; }
66 
67  // unsigned long GetCaps () const { return ELCAPS_SUBSAMPLING; }
68  // Return element capability flags
69 
70  // int nNode() const { return 3; }
71  // returns number of nodes per element
72 
73  // int nSide () const { return 3; };
74  // number of sides per element
75 
76  // int nSideNode (int /*side*/) const { return 2; };
77  // returns number of nodes attached to side 'side'
78 
79  // int SideNode (int side, int node) const;
80  // returns number of 'node'-th node of side 'side'
81 
82  // double SideSize (int sd, const NodeList &nlist) const;
83  // returns length of side 'sd'
84 
85  Point Local (const NodeList& nlist, const Point& glob) const;
86  // returns the local coordinate corresponding to global coordinate 'glob'
87 
88  // Point NodeLocal (int node) const;
89  // returns local coordinates of node 'node'
90 
91  Point SurfToLocal (int side, const Point &p) const;
92  // Map 1-D surface point p (0-1) along side 'side' into 2-D local coords
93 
94  RVector DirectionCosine (int side, RDenseMatrix &jacin);
95  // returns a vector of direction cosines in global coordinates of the
96  // normal to side 'side'.
97 
98  // const RVector &LNormal (int side) const;
99 
100  // bool LContains (const Point& loc, bool pad = true) const;
101  // returns TRUE if point 'loc' (in local coordinates of the element) is
102  // within the standard triangle
103 
104  bool GContains (const Point& glob, const NodeList& nlist) const;
105  // returns TRUE if point 'glob' (in global coordinates) is within the
106  // element. nlist is the mesh node coordinate list
107 
108  // RVector LocalShapeF (const Point &loc) const;
109  // vector of shape functions u_i(loc) at point 'loc' given in local
110  // element coordinates
111 
112  // RDenseMatrix LocalShapeD (const Point &loc) const;
113  // 2x3 matrix of shape function derivatives (d u_j)/(d x_i) at point 'loc'
114  // given in local element coordinates
115 
116  RVector GlobalShapeF (const NodeList& nlist, const Point& glob) const;
117  // returns the shape functions for each node at a point, given in global
118  // coordinates
119 
120  RDenseMatrix GlobalShapeD (const NodeList& nlist, const Point& glob) const;
121  // returns derivatives of shape functions in global coordinates at point
122  // `glob', given in global coordinates
123 
124  // double IntF (int i) const;
125 
126  // RSymMatrix IntFF () const;
127  // Return integral over element of product of shape functions:
128  // FF = Int_el { F_i(r) F_j(r) } dr
129 
130  // int QuadRule (int order, const double **wght, const Point **absc) const;
131 
132  // double IntFF (int i, int j) const;
133  // Return a single element of IntFF
134 
135  // double IntFFF (int i, int j, int k) const;
136  // returns a single element of integral over element of product of three
137  // shape functions:
138  // IntFFF = Int_el { F_i(r) * F_j(r) * F_k(r) } dr
139 
140 #ifdef UNDEF
141  // MS 29.6.99 Removed because incompatible with quadratic shape functions
142 
143  // void IntFFF (double &iii, double &iij, double &ijk) const;
144  // returns the values of the FFF tensor for:
145  // all indices equal (iii)
146  // two indices equal (iij)
147  // all indices different (ijk)
148 #endif
149 
150  // RSymMatrix IntPFF (const RVector& P) const;
151  // Returns integral over element of product of two shape functions and a
152  // function P defined on nodes:
153  // PFF = Int_el { P(r) F_i(r) F_J(r) } dr
154  // Vector P contains the complete nodal solution for the mesh
155 
156  // double IntPFF (int i, int j, const RVector& P) const;
157  // Returns a single element of IntPFF
158 
159  // RVector IntFD (int i, int j) const;
160  // Returns single (vector) element of FD integral over element:
161  // IntFD = Int_el { F_i(r) D_j(r) } dr
162 
163  // double IntFDD (int i, int j, int k) const
164  // { return intdd.Get(j,k) * 0.3333333333; }
165  // returns a single element of integral over element:
166  // IntFDD = Int_el { F_i(r) * D_j(r) * D_k(r) } dr
167 
168  // RSymMatrix IntPDD (const RVector& P) const
169  // { return intdd * ((P[Node[0]]+P[Node[1]]+P[Node[2]])/3.0); }
170  // Returns integral over element of product of two shape derivatives and a
171  // function P defined in nodal basis:
172  // PDD = Int_el { P(r) D_i(r) D_j(r) } dr
173  // Vector P contains the complete nodal solution for the mesh
174 
175  // double IntPDD (int i, int j, const RVector &P) const
176  // { return intdd.Get(i,j) * ((P[Node[0]]+P[Node[1]]+P[Node[2]])/3.0); }
177  // Returns a single element of IntPDD
178 
179  // RSymMatrix BndIntPFF (const RVector &P) const
180  // { return intbff * ((P[Node[0]]+P[Node[1]]+P[Node[2]])/3.0); }
181  // This is a hack! Really P would have to be taken into the integral,
182  // rather than just averaged.
183 
184  // double BndIntPFF (int i, int j, const RVector &P) const
185  // { return intbff.Get(i,j) * ((P[Node[0]]+P[Node[1]]+P[Node[2]])/3.0); }
186  // Returns a single element of BndIntPFF
187 
188  // double IntFd (int i, int j, int k) const;
189  // Returns a single element of Int [u_i du_j/dx_k] dr
190 
191  // double IntPd (const RVector &P, int j, int k) const;
192  // Returns Int [p(r) du_j/dx_k] dr where p(r) is defined by its nodal
193  // basis coefficients P.
194 
195  // double IntFdd (int i, int j, int k, int l, int m) const;
196  // Int u_i du_j/dx_l du_k/dx_m dr
197 
198  // double IntPdd (const RVector &p, int j, int k, int l, int m) const;
199  // Int f(r) du_j/dx_l du_k/dx_m dr
200  // where f(r) is given as a nodal vector
201 
202  // RSymMatrix Intdd() const;
203  // returns matrix of mixed derivatives
204 
205  // double BndIntFFSide (int i, int j, int sd);
206  // Int [u_i u_j] dr along side sd
207 
208  // RVector BndIntFX (int side, double (*func)(const Point&),
209  // const NodeList &nlist) const;
210  // See element.h for description
211 
212 // RVector BndIntFCos (int side, const Surface *surf, const RVector &cntcos,
213 // double sigma, double sup, const NodeList &nlist) const;
214  // See element.h for description
215 
216 // RVector BndIntFCos (int side, const RVector &cntcos, double a,
217 // const NodeList &nlist) const;
218  // See element.h for description
219 
220 
221 // RVector BndIntFDelta (int side, const Surface *surf, const RVector &pos,
222 // const NodeList &nlist) const;
223  // See element.h for description
224 
225  // int GetLocalSubsampleAbsc (const Point *&absc) const;
226  // returns abscissae in local coords for numerical integration by uniform
227  // subsampling. Return value is the number of samples returned in 'absc'
228 
229  // int GetBndSubsampleAbsc (int side, const Point *&absc) const;
230  // abscissae for numerical integration over boundary side in local
231  // coordinates of boundary element (dim-1). Use SurfToLocal to convert
232  // into local element coordinates
233 
234  int GlobalIntersection (const NodeList &nlist, const Point &p1,
235  const Point &p2, Point **list);
236  // Same as 'Intersection' but p1 and p2 given in global coords
237  // The return list however is still in local coords
238 
239  // int Intersection (const Point &p1, const Point &p2, Point** pi);
240  // creates a list of points where the line defined by p1 and p2 intersects
241  // the element (in local coordinates) or starts/ends within the element.
242  // Returns the length of the list
243 
244 
245  double IntUnitSphereP (const NodeList& nlist, const RVector& P) const;
246  double IntUnitSpherePFF(const NodeList& nlist, const int i, const int j, const RVector& P) const;
247  double IntUnitSphereFF (const NodeList& nlist, const int i, const int j) const;
248 
249  RDenseMatrix LocaltoGlobalMat () const {
250  return MapLocaltoGlobal; }
251 
252  RDenseMatrix GlobaltoLocalMat () const {
253  return inverse(MapLocaltoGlobal); }
254 
255 
256  RDenseMatrix FTAMat () const ;
257 
258 
259 protected:
260 
261  // double ComputeSize (const NodeList &nlist) const;
262  // area of triangle in global coordinates
263 
264  // RSymMatrix ComputeIntDD (const NodeList &nlist) const;
265  // Returns integral over element of product of shape derivatives:
266  // DD = Int_el { D_i(r) D_j(r) } dr
267 
268  // void ComputeIntFD (const NodeList &nlist);
269  // Calculates the FD integrals over the element:
270  // IntFD = Int_el { F_i(r) D_j(r) } dr
271 
272  // RSymMatrix ComputeBndIntFF (const NodeList& nlist) const;
273  // Returns line integral of product of two shape functions along sides of
274  // the element which belong to the mesh boundary
275  // If the element does not contain any boundary sides then the returned
276  // matrix is empty.
277 
278 private:
279 
280  // double *intfd_0, *intfd_1;
281  // IntFD matrix storage
282 
283  // double a0, b0, c0, a1, b1, c1, a2, b2, c2;
284  // triangle geometry parameters
285 
286 #ifdef TRI3_STORE_INTFF
287  // RSymMatrix intff;
288  // stores integral over element of product of shape functions
289  // Int_el { F_i(r) F_j(r) } dr
290  // set by Initialise
291 #endif
292  RDenseMatrix Map2Dto3D;
293  RDenseMatrix Map3Dto2D;
294  RDenseMatrix MapLocaltoGlobal;
295  RVector *V2D;
296  RVector uspts[6]; // used by unit sphere integration
297 };
298 
299 #endif
Definition: ndlist.h:14
RVector GlobalShapeF(const NodeList &nlist, const Point &glob) const
Returns the values of the shape functions at a global point.
Templated vector class.
Definition: vector.h:39
RVector DirectionCosine(int side, RDenseMatrix &jacin)
Returns the direction cosines of a side normal.
Definition: surface.h:21
Definition: tri3D6.h:52
RDenseMatrix GlobalShapeD(const NodeList &nlist, const Point &glob) const
Returns the values of the shape function derivatives at a global point.
Definition: point.h:18
int Dimension(void) const
Returns the spatial dimension of the element.
Definition: tri3D6.h:65
A 6-noded 2-dimensional triangle element with straight sides and second-order shape functions...
Definition: tri6.h:51
Point Local(const NodeList &nlist, const Point &glob) const
Maps a point from global to local element coordinates.
bool GContains(const Point &glob, const NodeList &nlist) const
Checks if a global point coordinate is inside the element.
virtual Point SurfToLocal(int side, const Point &p) const
Maps a point from surface coordinates to local element coordinates.
Definition: element.h:302
#define ELID_TRI3D6
6-noded surface triangle
Definition: element.h:47
Dense matrix class.
Definition: crmatrix.h:38
BYTE Type() const
Returns an element type identifier.
Definition: tri3D6.h:62
void Initialise(const NodeList &nlist)
Element initialisation.