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 "ERF_NumericalConstants.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.
37 {
38  amrex::RealVect const edge(a_edge_point1 - a_edge_point0);
39  amrex::Real const edge_length = edge.vectorLength();
40 
41  AMREX_ALWAYS_ASSERT(edge_length > zero);
42 
43  amrex::RealVect edge_normal = edge / edge_length;
44 
45  amrex::Real np_dot_ne = a_plane_normal.dotProduct(edge_normal);
46 
47  // if ( amrex::Math::abs(np_dot_ne) < std::numeric_limits<amrex::Real>::min() )
48  if ( amrex::Math::abs(np_dot_ne) < amrex::Real(10.0) * std::numeric_limits<amrex::Real>::epsilon() )
49  { return 0; }
50 
51  a_intersection_dist = a_plane_normal.dotProduct(a_plane_point)
52  - a_plane_normal.dotProduct(a_edge_point0);
53  a_intersection_dist /= np_dot_ne;
54 
55  a_intersection_point = a_edge_point0 + a_intersection_dist*edge_normal;
56 
57  if (zero <= a_intersection_dist && a_intersection_dist <= edge_length) { return 1;}
58 
59  return 0;
60 }
AMREX_ALWAYS_ASSERT(bx.length()[2]==khi+1)
constexpr amrex::Real zero
Definition: ERF_NumericalConstants.H:29
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: