-
Notifications
You must be signed in to change notification settings - Fork 3
/
media_cellface.hpp
416 lines (322 loc) · 13.7 KB
/
media_cellface.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
// media_cellface.hpp
//
// The CellFace class hierarchy offers a set of classes that define the
// bounding surfaces of MediumCell objects. CellFace is a pure virtual base
// class defining an interface for interacting with the bounding surfaces of
// various geometries.
//
// CellFace
// ./-------------^-------------\.
// | | |
// PlaneFace CylinderFace SphereFace
//
//
// Additionaly a few supporting classes are defined here:
//
// o class GCAD_RetVal
//
//
#ifndef MEDIA_CELLFACE_H_
#define MEDIA_CELLFACE_H_
//
#include <cassert>
#include "geom.hpp"
//////
// CLASSES: -- Forward Declarations --
//
// FROM OTHER HEADERS: (Referenced here by pointer only -
// no need to include full header.)
class MediumCell; /* Defined in media.hpp */
class RTCoef; /* Defined in rtcoef.hpp */
class RayArcAttributes; /* Defined in raypath.hpp */
//////
// CLASSES: Definitions
//
// INCLUDING:
//
// o class GCAD_RetVal (Helper class to pack up a complex return value)
// o class CellFace
//
//////
// CLASS: GCAD_RetVal
//
// This class encapsulates the return value of the GetCircArcDistToFace()
// member function.
//
class GCAD_RetVal{
protected:
Real mEntry;
Real mExit;
Real mHalf;
bool mContinuous;
//std::vector<Real> mForwardRegion;
public:
GCAD_RetVal(Real enter, Real exit, Real half, bool continuous);
GCAD_RetVal();
Real Entry() const {return mEntry;}
Real Exit() const {return mExit;}
Real Half() const {return mHalf;}
bool Continuous() const {return mContinuous;}
// std::vector<Real> GetForwardRegion() const {return mForwardRegion;}
bool Inside (const Real & theta) const;
bool IsProper (const GCAD_RetVal & a, const GCAD_RetVal & b, const GCAD_RetVal & c) const;
};
//////
// CLASS: CellFace
//
// ENCAPS:
//
// This class encapsulates a single "face" of a polyhedral
// MediumCell, and is used to store attributes of that face, such as
// its interconnectivity to the faces of other MediumCells, spatial
// orientation of the face, reflection/transmission properties, etc.
//
class CellFace {
public:
// ::::::::::::::::::::::::::::::::::::::
// ::: Enumerations (CellFace Class) :::
// ::::::::::::::::::::::::::::::::::::::
enum face_id_e { // Provides a numbering scheme to ID the
// faces on a given MediumCell
F_TOP = 0, // Used by two-faced cells, e.g. the
F_BOTTOM = 1, // Cylinder cells, and Spherical shells.
F_SIDE = 2, // This used by Cylinder cells for loss face.
FACE_A = 0, // Used by four-faced cells, e.g. the
FACE_B = 1, // tetrahedral cells
FACE_C = 2,
FACE_D = 3
};
protected:
// :::::::::::::::::::::::::::::::::::::
// ::: Member Data (CellFace Class) :::
// :::::::::::::::::::::::::::::::::::::
// ::::::
// :: Face Flags: (These code what "happens"
// : at a given interface)
//
bool mCollect; // True if data-collection should occur when a
// phonon interacts with this face.
bool mReflect; // True if this face represents a hard-reflection
// (e.g, free surface) interface.
bool mAdjoin; // True if MediumCell adjoins another cell through
// this face.
bool mGridDiscon; // True if the grid specified an attribute
// discontinuity across this interface, as
// indicated by grid duplicity on the defining
// nodes of the face. (Or in other words, if
// the nodes have two attribute sets, one
// applying "just above" the node and one
// "just under".)
// ::::::
// :: Linkage: (These members encode the connectivity
// : of faces and cells)
//
CellFace * mpOther; // Points to corresponding CellFace on
// the adjoining cell.
MediumCell * mpCell; // Cell object to which this face belongs.
// ::::::::::::::::::::::::::::::::::::::
// ::: Constructors (CellFace Class) :::
// ::::::::::::::::::::::::::::::::::::::
//
// (Callable only by derived class constructors.)
//
CellFace(MediumCell * pOwner) :
mCollect ( false ),
mReflect ( false ),
mAdjoin ( false ),
mGridDiscon ( false ),
mpOther ( nullptr ),
mpCell ( pOwner ) {}
public:
// ::::::::::::::::::::::::::::::::::::::::::::::
// ::: Property-Set Methods (CellFace Class) :::
// ::::::::::::::::::::::::::::::::::::::::::::::
void SetCollect(bool state) {mCollect = state;}
void SetReflect(bool state) {mReflect = state;}
void SetDiscontinuous(bool state) {mGridDiscon = state;}
void LinkTo(CellFace & other, bool disc);
// Handles book-keeping of linking two complimentary
// CellFaces together. The caller is responsible for
// determining whether the CellFace linkage spans a
// grid-indicated discontinuity.
void LinkTo(CellFace & other);
// This version assumes that the discontinuity state
// has already been set. If either face is marked
// discontiuous, then this method will ensure that
// both will be marked as discontinuous.
// ::::::::::::::::::::::::::::::::::::::::::::::
// ::: Property-Get Methods (CellFace Class) :::
// ::::::::::::::::::::::::::::::::::::::::::::::
bool IsCollectionFace() const {return mCollect;}
bool IsReflectionFace() const {return mReflect;}
bool GridDiscontinuity() const {return mGridDiscon;}
bool HasNeighbor() const {return mAdjoin;}
// :::::::::::::::::::::::::::::::::::::::::::::::::::
// ::: Linkage Reference Methods (CellFace Class) :::
// :::::::::::::::::::::::::::::::::::::::::::::::::::
MediumCell & Cell() {
return *mpCell;
}
MediumCell & OtherCell() {
return *(mpOther->mpCell);
}
MediumCell & Cell() const {
return *mpCell;
}
MediumCell & OtherCell() const {
return *(mpOther->mpCell);
}
// :::::::::::::::::::::::::::::::::::::::::::
// ::: Interface Methods (CellFace Class) :::
// :::::::::::::::::::::::::::::::::::::::::::
//
// These are what derived classes MUST define:
//
virtual R3::XYZ Normal(R3::XYZ loc) const = 0;
// Outward-pointing surface normal unit vector.
virtual Real GetDistanceAboveFace(const R3::XYZ & loc) const = 0;
// Computes direct (shortest, straight-line) distance from the nearest
// point on the face to the given point. Positive result implies point
// lies "above" the face, negative that the point lies "below."
// "Above" means the side pointed to by the surface normal.
virtual Real LinearRayDistToExit(const R3::XYZ & loc, const R3::XYZ & dir) const = 0;
// Computes the linear, straight-line, ray-directed distance from the
// starting point to the point of intersection with the face, to be
// interpretted as a distance until exiting the volume bounded by the
// face. Finite return value implies ray crosses or crossed from
// inside-to-out (exiting). Positive value implies exit is in future,
// negative implies point has already exited (sits outside the face).
// Returns special value +inf if the ray either crosses from out-to-in
// (entering) or is inside and parallel and can never exit, or -inf if
// the line is outside and parallel and is/was forever outside. (More
// details at PlaneFace::LinearRayDistToExit() definition).
// :::::::::::::::::::::::::::::::::::::::::::::::
// ::: Interrogative Methods (CellFace Class) :::
// :::::::::::::::::::::::::::::::::::::::::::::::
Real VelocityJump(const R3::XYZ & loc) const;
// Returns a number characterizing the fractional
// velocity jump across the interface.
RTCoef GetRTBasis(const R3::XYZ & loc, const R3::XYZ & dir) const;
// Returns an RTCoef object with the basis information (which depends
// on the incidence angle to the CellFace). NOTE: This depends on
// virtual method Normal(), but does not itself need to be virtual, so
// it's not.
};
//////
// CLASS: PlaneFace
// FROM: CellFace
//
// Planar CellFace with a fixed normal direction. Bounds RCUCylinder
// and Tetra model cells.
//
class PlaneFace : public CellFace {
protected:
// ::::::
// :: Geometry: (Determines the positioning and
// : orientation of the face)
//
R3::XYZ mNormal; // Surface normal pointing outward from
// MediumCell (unit magnitude)
R3::XYZ mPoint; // A location known to be on the cellface.
public:
// :::::::::::::::::::::::::::::::::::::::
// ::: Constructors (PlaneFace Class) :::
// :::::::::::::::::::::::::::::::::::::::
PlaneFace (const R3::XYZ & N1, const R3::XYZ & N2, const R3::XYZ & N3,
MediumCell * powner);
PlaneFace (const R3::XYZ & N1, const R3::XYZ & N2, const R3::XYZ & N3,
const R3::XYZ & N4, MediumCell * powner);
// First three nodes define corners of a face.
// The fourth node determines which point is
// outside.
// ::::::::::::::::::::::::::::::::::::::::::::::::
// ::: Interrogative Methods (PlaneFace Class) :::
// ::::::::::::::::::::::::::::::::::::::::::::::::
virtual R3::XYZ Normal(R3::XYZ loc) const override {return mNormal;}
virtual Real GetDistanceAboveFace(const R3::XYZ & loc) const override;
virtual Real LinearRayDistToExit(const R3::XYZ & loc, const R3::XYZ & dir) const override;
GCAD_RetVal GetCircArcDistToFace(const Real & R, const R3::XYZ & C, const R3::Matrix & S) const;
// Similar to LinearRayDistToExit except it computes
// distance along a circular arc path.
};
//////
// CLASS: CylinderFace
// FROM: CellFace
//
// Cylindrical CellFace centered on the origin, coaxial with z-axis. Only one
// surface and it points cylindrically away from the axis. Used primarily to
// bound the outer "loss" edge of the RCUCylinder derivative of the MediumCell
// classes.
//
class CylinderFace : public CellFace {
protected:
// ::::::
// :: Geometry: (Determines the positioning and
// : orientation of the face)
//
Real mRadius; // Radius of cylinder.
Real mRad2; // Precomputed Radius-Squared
public:
// :::::::::::::::::::::::::::::::::::::::::
// ::: Constructors CylinderFace Class) :::
// :::::::::::::::::::::::::::::::::::::::::
CylinderFace (Real radius, MediumCell * powner = nullptr);
// ::::::::::::::::::::::::::::::::::::::::::::::::::
// ::: Property-Set Methods (CylinderFace Class) :::
// ::::::::::::::::::::::::::::::::::::::::::::::::::
void SetRadius(Real radius) {assert(radius>0); mRadius=radius; mRad2=radius*radius;}
// (Use as a loss-face for RCUCylinder class creates need to set
// radius post-construction.)
// :::::::::::::::::::::::::::::::::::::::::::::::::::
// ::: Interrogative Methods (CylinderFace Class) :::
// :::::::::::::::::::::::::::::::::::::::::::::::::::
virtual R3::XYZ Normal(R3::XYZ loc) const override;
virtual Real GetDistanceAboveFace(const R3::XYZ & loc) const override;
virtual Real LinearRayDistToExit(const R3::XYZ & loc, const R3::XYZ & dir) const override;
};
//////
// CLASS: SphereFace
// FROM: CellFace
//
// Spherical CellFace centered on the origin. Surface normal can either point
// away from origin (making it an outer surface to a spherical shell) or
// toward origin (making it an inner surface). Bounds SphereShell family of
// MediumCell classes. The operations of this class depend intrinsicially on
// the sphere being centered on the origin.
//
class SphereFace : public CellFace {
protected:
// ::::::
// :: Geometry: (Determines the positioning and
// : orientation of the face)
//
Real mRadius; // Radius of sphere. Strictly Positive implies outward-
// pointing surface normal, negative or zero implies
// inward-facing normal.
Real mRad2; // Precomputed Radius-Squared.
public:
// :::::::::::::::::::::::::::::::::::::::
// ::: Constructors SphereFace Class) :::
// :::::::::::::::::::::::::::::::::::::::
SphereFace (Real radius, face_id_e toporbottom, MediumCell * powner);
// Construct SphereFace as an outward-normal (toporbottom==F_TOP) or
// inward-normal (toporbottom==F_BOTTOM) spherical surface of radius
// 'radius'. Argument 'radius' must be non-negative (but can be zero).
// :::::::::::::::::::::::::::::::::::::::::::::::::
// ::: Interrogative Methods (SphereFace Class) :::
// :::::::::::::::::::::::::::::::::::::::::::::::::
bool IsOutwardNormal() const {return (mRadius>0);}
// ::::::::::::::::::::::::::::::::::::::::::::::::::::::
// ::: Interface-Required Methods (SphereFace Class) :::
// ::::::::::::::::::::::::::::::::::::::::::::::::::::::
virtual R3::XYZ Normal(R3::XYZ loc) const override;
virtual Real GetDistanceAboveFace(const R3::XYZ & loc) const override;
virtual Real LinearRayDistToExit(const R3::XYZ & loc, const R3::XYZ & dir) const override;
Real CircularArcDistToExit(const R3::XYZ & loc, const R3::XYZ & dir, const RayArcAttributes & arc) const;
// Similar to LinearRayDistToExit() except assumes path along a
// circular arc, the geometry of which has already been computed and
// is passed in in a RayArcAttributes arg.
};
///
#endif //#ifndef MEDIA_H_
//