https://mooseframework.inl.gov
FaceInfo.h
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://mooseframework.inl.gov
3 //*
4 //* All rights reserved, see COPYRIGHT for full restrictions
5 //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6 //*
7 //* Licensed under LGPL 2.1, please see LICENSE for details
8 //* https://www.gnu.org/licenses/lgpl-2.1.html
9 
10 #pragma once
11 
12 #include "MooseTypes.h"
13 #include "ElemInfo.h"
14 #include "MooseError.h"
15 
16 #include "libmesh/vector_value.h"
17 #include "libmesh/remote_elem.h"
18 #include "libmesh/elem_side_builder.h"
19 
20 #include <map>
21 #include <set>
22 #include <memory>
23 
24 class MooseMesh;
25 namespace libMesh
26 {
27 class Elem;
28 class Node;
29 }
30 
37 class FaceInfo
38 {
39 public:
40  FaceInfo(const ElemInfo * elem_info,
41  unsigned int side,
42  const dof_id_type id,
43  libMesh::ElemSideBuilder & side_builder);
44 
52  enum class VarFaceNeighbors
53  {
54  BOTH,
55  NEITHER,
56  ELEM,
57  NEIGHBOR
58  };
59 
61  dof_id_type id() const { return _id; }
62 
64  Real faceArea() const { return _face_area; }
65 
68  Real & faceCoord() { return _face_coord; }
69  Real faceCoord() const { return _face_coord; }
70 
72  const Point & normal() const { return _normal; }
73 
75  const Point & faceCentroid() const { return _face_centroid; }
76 
79  Point skewnessCorrectionVector() const;
80 
85  const Elem & elem() const { return *(_elem_info->elem()); }
86  const Elem * elemPtr() const { return _elem_info->elem(); }
87  const Elem & neighbor() const;
88  const Elem * neighborPtr() const { return _neighbor_info ? _neighbor_info->elem() : nullptr; }
89  const ElemInfo * elemInfo() const { return _elem_info; }
90  const ElemInfo * neighborInfo() const { return _neighbor_info; }
92 
99  const Point & elemCentroid() const { return _elem_info->centroid(); }
100  const Point & neighborCentroid() const;
102 
109 
113  unsigned int elemSideID() const { return _elem_side_id; }
114  unsigned int neighborSideID() const { return _neighbor_side_id; }
116 
118  VarFaceNeighbors faceType(const std::pair<unsigned int, unsigned int> & var_sys) const;
121  VarFaceNeighbors & faceType(const std::pair<unsigned int, unsigned int> & var_sys);
122 
124  const std::set<BoundaryID> & boundaryIDs() const { return _boundary_ids; }
125 
127  std::set<BoundaryID> & boundaryIDs() { return _boundary_ids; }
128 
130  Real elemVolume() const { return _elem_info->volume(); }
131 
133  Real neighborVolume() const;
134 
136  Real gC() const { return _gc; }
137 
142  const Point & dCN() const { return _d_cn; }
143 
148  Real dCNMag() const { return _d_cn_mag; }
149 
155  const Point & eCN() const { return _e_cn; }
156 
161 
166  void computeInternalCoefficients(const ElemInfo * const neighbor_info);
167 
173 
174 private:
177  std::vector<std::vector<VarFaceNeighbors>> & faceType() { return _face_types_by_var; }
178 
180  const ElemInfo * const _elem_info;
182 
184 
186  Point _normal;
187 
189 
191  const unsigned int _elem_side_id;
192  unsigned int _neighbor_side_id;
193 
196 
198  Point _d_cn;
199  Point _e_cn;
200 
203 
206 
210  std::vector<std::vector<VarFaceNeighbors>> _face_types_by_var;
211 
213  std::set<BoundaryID> _boundary_ids;
214 
216  friend MooseMesh;
217 };
218 
219 inline const Elem &
221 {
222  mooseAssert(_neighbor_info,
223  "FaceInfo object 'const Elem & neighbor()' is called but neighbor element pointer "
224  "is null. This occurs for faces at the domain boundary");
225  return *(_neighbor_info->elem());
226 }
227 
229 FaceInfo::faceType(const std::pair<unsigned int, unsigned int> & var_sys) const
230 {
231  mooseAssert(var_sys.second < _face_types_by_var.size(), "System number out of bounds!");
232  mooseAssert(var_sys.first < _face_types_by_var[var_sys.second].size(),
233  "Variable number out of bounds!");
234  return _face_types_by_var[var_sys.second][var_sys.first];
235 }
236 
238 FaceInfo::faceType(const std::pair<unsigned int, unsigned int> & var_sys)
239 {
240  mooseAssert(var_sys.second < _face_types_by_var.size(), "System number out of bounds!");
241  mooseAssert(var_sys.first < _face_types_by_var[var_sys.second].size(),
242  "Variable number out of bounds!");
243  return _face_types_by_var[var_sys.second][var_sys.first];
244 }
245 
246 inline const Point &
248 {
249  mooseAssert(_neighbor_info,
250  "The neighbor is not defined on this faceInfo! A possible explanation is that the "
251  "face is a (physical/processor) boundary face.");
252  return _neighbor_info->centroid();
253 }
254 
255 inline SubdomainID
257 {
259 }
260 
261 inline Real
263 {
264  mooseAssert(_neighbor_info,
265  "The neighbor is not defined on this faceInfo! A possible explanation is that the "
266  "face is a (physical/processor) boundary face.");
267  return _neighbor_info->volume();
268 }
const ElemInfo * _neighbor_info
Definition: FaceInfo.h:181
Point _e_cn
Definition: FaceInfo.h:199
processor_id_type processor_id() const
Definition: FaceInfo.h:160
void computeInternalCoefficients(const ElemInfo *const neighbor_info)
Takes the ElemInfo of the neighbor cell and computes interpolation weights together with other quanti...
Definition: FaceInfo.C:39
const std::set< BoundaryID > & boundaryIDs() const
Const getter for every associated boundary ID.
Definition: FaceInfo.h:124
Point skewnessCorrectionVector() const
Returns the skewness-correction vector (vector between the approximate and real face centroids)...
Definition: FaceInfo.C:74
Real elemVolume() const
Return the element volume.
Definition: FaceInfo.h:130
const Elem & elem() const
Definition: FaceInfo.h:85
const ElemInfo * neighborInfo() const
Definition: FaceInfo.h:90
const Elem * elem() const
Definition: ElemInfo.h:34
const Point & faceCentroid() const
Returns the coordinates of the face centroid.
Definition: FaceInfo.h:75
friend MooseMesh
Allows access to private members from moose mesh only.
Definition: FaceInfo.h:216
const ElemInfo * elemInfo() const
Definition: FaceInfo.h:89
unsigned int elemSideID() const
Definition: FaceInfo.h:113
std::set< BoundaryID > _boundary_ids
the set of boundary ids that this face is associated with
Definition: FaceInfo.h:213
Real & faceCoord()
Sets/gets the coordinate transformation factor (for e.g.
Definition: FaceInfo.h:68
const Point & neighborCentroid() const
Definition: FaceInfo.h:247
The following methods are specializations for using the libMesh::Parallel::packed_range_* routines fo...
std::set< BoundaryID > & boundaryIDs()
Returns the set of boundary ids for all boundaries that include this face.
Definition: FaceInfo.h:127
Real faceArea() const
Returns the face area of face id.
Definition: FaceInfo.h:64
unsigned int neighborSideID() const
Definition: FaceInfo.h:114
Real _d_cn_mag
the distance norm between neighbor and element centroids
Definition: FaceInfo.h:202
std::vector< std::vector< VarFaceNeighbors > > & faceType()
Getter for the face type for every stored variable.
Definition: FaceInfo.h:177
Real neighborVolume() const
Return the neighbor volume.
Definition: FaceInfo.h:262
const SubdomainID INVALID_BLOCK_ID
Definition: MooseTypes.C:20
SubdomainID elemSubdomainID() const
Definition: FaceInfo.h:106
uint8_t processor_id_type
This data structure is used to store geometric and variable related metadata about each cell face in ...
Definition: FaceInfo.h:37
FaceInfo(const ElemInfo *elem_info, unsigned int side, const dof_id_type id, libMesh::ElemSideBuilder &side_builder)
Definition: FaceInfo.C:19
const Point & centroid() const
Definition: ElemInfo.h:36
Real _gc
Geometric weighting factor for face value interpolation.
Definition: FaceInfo.h:205
const Elem * neighborPtr() const
Definition: FaceInfo.h:88
const Point & elemCentroid() const
Returns the element centroids of the elements on the elem and neighbor sides of the face...
Definition: FaceInfo.h:99
Real gC() const
Return the geometric weighting factor.
Definition: FaceInfo.h:136
VarFaceNeighbors
This enum is used to indicate which side(s) of a face a particular variable is defined on...
Definition: FaceInfo.h:52
MooseMesh wraps a libMesh::Mesh object and enhances its capabilities by caching additional data and s...
Definition: MooseMesh.h:93
const Elem & neighbor() const
Definition: FaceInfo.h:220
const dof_id_type _id
Definition: FaceInfo.h:183
const Point & normal() const
Returns the unit normal vector for the face oriented outward from the face&#39;s elem element...
Definition: FaceInfo.h:72
const processor_id_type _processor_id
Definition: FaceInfo.h:188
void computeBoundaryCoefficients()
Computes the interpolation weights and similar quantities with the assumption that the face is on a b...
Definition: FaceInfo.C:60
Real dCNMag() const
Definition: FaceInfo.h:148
const Elem * elemPtr() const
Definition: FaceInfo.h:86
Real faceCoord() const
Definition: FaceInfo.h:69
const unsigned int _elem_side_id
the elem local side id
Definition: FaceInfo.h:191
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
const Point & eCN() const
Definition: FaceInfo.h:155
unsigned int _neighbor_side_id
Definition: FaceInfo.h:192
const ElemInfo *const _elem_info
the elem and neighbor elems
Definition: FaceInfo.h:180
dof_id_type id() const
Return the ID of the face.
Definition: FaceInfo.h:61
SubdomainID neighborSubdomainID() const
Definition: FaceInfo.h:256
Real _face_coord
Definition: FaceInfo.h:185
std::vector< std::vector< VarFaceNeighbors > > _face_types_by_var
A vector that provides the information about what face type this is for each variable.
Definition: FaceInfo.h:210
Point _d_cn
the distance vector between neighbor and element centroids
Definition: FaceInfo.h:198
Point _face_centroid
Definition: FaceInfo.h:195
Class used for caching additional information for elements such as the volume and centroid...
Definition: ElemInfo.h:25
Point _normal
Definition: FaceInfo.h:186
Real volume() const
Definition: ElemInfo.h:35
SubdomainID subdomain_id() const
We return the subdomain ID of the corresponding libmesh element.
Definition: ElemInfo.h:43
const Point & dCN() const
Definition: FaceInfo.h:142
uint8_t dof_id_type
Real _face_area
Definition: FaceInfo.h:194