ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
ERF_EBCutCell.H File Reference

Defines cut-cell geometry reconstruction from EB plane intersections. More...

#include <AMReX_REAL.H>
#include <AMReX_Array.H>
#include <AMReX_RealBox.H>
#include <AMReX_RealVect.H>
#include <AMReX_Algorithm.H>
#include <AMReX_EBCellFlag.H>
#include <AMReX_GpuPrint.H>
#include "ERF_EBPolygon.H"
Include dependency graph for ERF_EBCutCell.H:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  eb_cut_cell_
 Reconstructs geometric moments for one EB cut cell. More...
 
struct  eb_cut_cell_::path_data
 Intersection metadata for one ordered edge path in the cut-cell box. More...
 

Functions

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE int intersect_plane_edge (amrex::RealVect const &a_plane_point, amrex::RealVect const &a_plane_normal, amrex::RealVect const &a_edge_point0, amrex::RealVect const &a_edge_point1, amrex::RealVect &a_intersection_point, amrex::Real &a_intersection_dist)
 Intersect a plane with a line segment. More...
 

Detailed Description

Defines cut-cell geometry reconstruction from EB plane intersections.

Function Documentation

◆ intersect_plane_edge()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE int intersect_plane_edge ( amrex::RealVect const &  a_plane_point,
amrex::RealVect const &  a_plane_normal,
amrex::RealVect const &  a_edge_point0,
amrex::RealVect const &  a_edge_point1,
amrex::RealVect &  a_intersection_point,
amrex::Real a_intersection_dist 
)

Intersect a plane with a line segment.

Parameters
a_plane_pointPoint on the plane.
a_plane_normalUnit normal for the plane.
a_edge_point0First endpoint of the edge.
a_edge_point1Second endpoint of the edge.
[out]a_intersection_pointIntersection point when the edge crosses the plane.
[out]a_intersection_distDistance from a_edge_point0 to the intersection.
Returns
1 if the segment intersects the plane, otherwise 0.
36 {
37  amrex::RealVect const edge(a_edge_point1 - a_edge_point0);
38  amrex::Real const edge_length = edge.vectorLength();
39 
40  AMREX_ALWAYS_ASSERT(edge_length > zero);
41 
42  amrex::RealVect edge_normal = edge / edge_length;
43 
44  amrex::Real np_dot_ne = a_plane_normal.dotProduct(edge_normal);
45 
46  // if ( amrex::Math::abs(np_dot_ne) < std::numeric_limits<amrex::Real>::min() )
47  if ( amrex::Math::abs(np_dot_ne) < amrex::Real(10.0) * std::numeric_limits<amrex::Real>::epsilon() )
48  { return 0; }
49 
50  a_intersection_dist = a_plane_normal.dotProduct(a_plane_point)
51  - a_plane_normal.dotProduct(a_edge_point0);
52  a_intersection_dist /= np_dot_ne;
53 
54  a_intersection_point = a_edge_point0 + a_intersection_dist*edge_normal;
55 
56  if (zero <= a_intersection_dist && a_intersection_dist <= edge_length) { return 1;}
57 
58  return 0;
59 }
constexpr amrex::Real zero
Definition: ERF_Constants.H:8
AMREX_ALWAYS_ASSERT(bx.length()[2]==khi+1)
amrex::Real Real
Definition: ERF_ShocInterface.H:19
real(c_double), parameter epsilon
Definition: ERF_module_model_constants.F90:12

Referenced by eb_cut_cell_::calc_edge_intersections(), and eb_cut_cell_::path_data::set().

Here is the call graph for this function:
Here is the caller graph for this function: