chombo-discharge
CD_LocationImplem.H
Go to the documentation of this file.
1 /* chombo-discharge
2  * Copyright © 2021 SINTEF Energy Research.
3  * Please refer to Copyright.txt and LICENSE in the chombo-discharge root directory.
4  */
5 
12 #ifndef CD_LocationImplem_H
13 #define CD_LocationImplem_H
14 
15 // Our includes
16 #include <CD_Location.H>
17 #include <CD_NamespaceHeader.H>
18 
19 inline RealVect
20 Location::position(const Location::Cell a_position, const VolIndex& a_vof, const EBISBox& a_ebisbox, const Real& a_dx)
21 {
22 
23  RealVect ret;
24 
25  switch (a_position) {
26  case Location::Cell::Center: {
27  ret = RealVect(a_vof.gridIndex()) + 0.5 * RealVect::Unit;
28 
29  break;
30  }
31  case Location::Cell::Centroid: {
32  ret = RealVect(a_vof.gridIndex()) + 0.5 * RealVect::Unit + a_ebisbox.centroid(a_vof);
33 
34  break;
35  }
36  case Location::Cell::Boundary: {
37  ret = RealVect(a_vof.gridIndex()) + 0.5 * RealVect::Unit + a_ebisbox.bndryCentroid(a_vof);
38 
39  break;
40  }
41  default: {
42  MayDay::Error("LeastSquares::position -- bad location input.");
43 
44  break;
45  }
46  }
47 
48  ret *= a_dx;
49 
50  return ret;
51 }
52 
53 inline RealVect
54 Location::position(const Location::Face a_position, const FaceIndex& a_face, const EBISBox& a_ebisbox, const Real& a_dx)
55 {
56  RealVect ret;
57  const IntVect iv = a_face.gridIndex(Side::Hi);
58 
59  switch (a_position) {
60  case Location::Face::Center: {
61  ret = (RealVect(iv) + 0.5 * RealVect::Unit) - 0.5 * BASISREALV(a_face.direction());
62 
63  break;
64  }
65  case Location::Face::Centroid: {
66  ret = (RealVect(iv) + 0.5 * RealVect::Unit) - 0.5 * BASISREALV(a_face.direction());
67 
68  const RealVect faceCentroid = a_ebisbox.centroid(a_face);
69 
70  for (int dir = 0; dir < SpaceDim; dir++) { // Direction a_face is undefined.
71  if (dir != a_face.direction()) {
72  ret[dir] += faceCentroid[dir];
73  }
74  }
75 
76  break;
77  }
78  default: {
79  MayDay::Error("LeastSquares::positon - bad location input.");
80 
81  break;
82  }
83  }
84 
85  ret *= a_dx;
86 
87  return ret;
88 }
89 
90 #include <CD_NamespaceFooter.H>
91 
92 #endif
Declaration of cell positions.
RealVect position(const Location::Cell a_location, const VolIndex &a_vof, const EBISBox &a_ebisbox, const Real &a_dx)
Compute the position (ignoring the "origin) of a Vof.
Definition: CD_LocationImplem.H:20
Cell
Enum for distinguishing between cell locations.
Definition: CD_Location.H:30
Face
Enum for distinguishing between face locations.
Definition: CD_Location.H:40