https://mooseframework.inl.gov
Loading...
Searching...
No Matches
SurfaceElement.C
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#include "SurfaceElement.h"
11
12#include <algorithm>
13
14SurfaceElement::SurfaceElement(const Elem * elem, const Point & normal)
15 : _elem(elem), _normal(normal)
16{
17 mooseAssert(elem, "Element must not be null");
18
19 if (!MooseUtils::absoluteFuzzyEqual(_normal.norm(), 1))
20 mooseError("SurfaceElement: normal vector must be unit length, length = ", _normal.norm());
21}
22
23Real
25{
26 const BoundingBox bbox = _elem->loose_bounding_box();
27 const Point d = bbox.second - bbox.first; // (dx, dy, dz), each >= 0
28
29 // The longest diagonal of the projected AABB (its shadow on the plane orthogonal to
30 // normal_dir) is the search radius that must cover this element's projected footprint.
31 // Projecting only the main diagonal (dx, dy, dz) underestimates it whenever that diagonal
32 // is nearly parallel to normal_dir. The projected footprint diameter is the max projected
33 // length over all four space diagonals (dx, +/-dy, +/-dz); their negatives have identical
34 // projected length, so these four combinations are exhaustive.
35 Real max_projected = 0.0;
36 for (const Real sy : {1.0, -1.0})
37 for (const Real sz : {1.0, -1.0})
38 {
39 const Point diag(d(0), sy * d(1), sz * d(2));
40 const Point tangent_vec = diag - normal_dir * (diag * normal_dir);
41 max_projected = std::max(max_projected, tangent_vec.norm());
42 }
43
44 return max_projected;
45}
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
Definition MooseError.h:311
SurfaceElement(const Elem *elem, const Point &normal)
Constructor takes a pointer to a surface element and its precomputed unit normal.
Real getProjectedBoundingBoxDiagonal(const Point &normal_dir) const
Compute the length of the element bounding-box diagonal projected onto a plane orthogonal to a given ...
const Elem * _elem
Pointer to the libMesh element representing this surface face.
const Elem & elem() const
Getter for the underlying element.
const Point _normal
Unit normal vector of the surface element.