ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
eb_cut_cell_ Class Reference

Reconstructs geometric moments for one EB cut cell. More...

#include <ERF_EBCutCell.H>

Collaboration diagram for eb_cut_cell_:

Classes

struct  path_data
 Intersection metadata for one ordered edge path in the cut-cell box. More...
 

Public Member Functions

AMREX_GPU_HOST_DEVICE eb_cut_cell_ (amrex::EBCellFlag const &a_flag, amrex::RealBox const &a_rbox, amrex::RealVect const &a_point, amrex::RealVect const &a_normal)
 Construct cut-cell geometry from a cell flag, box, EB point, and EB normal. More...
 
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE bool isCovered () const noexcept
 Return true if the reconstructed cell is covered. More...
 
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE bool isRegular () const noexcept
 Return true if the reconstructed cell is regular. More...
 
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE bool isSingleValued () const noexcept
 Return true if the reconstructed cell is single-valued. More...
 
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void set_covered ()
 Mark the reconstructed cell as covered. More...
 
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void set_regular ()
 Mark the reconstructed cell as regular and fill regular face areas. More...
 
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real volume () const
 Return the physical volume of the reconstructed cell. More...
 
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real areaLo (int const idir) const noexcept
 Return the low-side face area in one coordinate direction. More...
 
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real areaHi (int const idir) const noexcept
 Return the high-side face area in one coordinate direction. More...
 
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real areaBoun () const noexcept
 Return the EB boundary area inside the cell. More...
 
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::RealVect centLo (int const idir) const noexcept
 Return the low-side face centroid in one coordinate direction. More...
 
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::RealVect centHi (int const idir) const noexcept
 Return the high-side face centroid in one coordinate direction. More...
 
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::RealVect centBoun () const noexcept
 Return the EB boundary centroid. More...
 
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::RealVect normBoun () const noexcept
 Return the EB boundary normal. More...
 
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::RealVect centVol () const noexcept
 Return the volume centroid of the reconstructed cell. More...
 
void debug (int const a_face=-1)
 Print cut-cell diagnostics on CPU builds. More...
 

Private Member Functions

AMREX_GPU_HOST_DEVICE void calc_edge_intersections ()
 Compute all edge-plane intersections and populate polygon vertices. More...
 
AMREX_GPU_HOST_DEVICE void set_covered_regular_cell_vertices ()
 Populate polygon vertices for cells that are fully covered or regular. More...
 

Private Attributes

amrex::RealBox const m_rbox
 
amrex::RealVect const m_eb_point
 
amrex::RealVect const m_eb_normal
 
amrex::Real m_invert
 
amrex::RealVect m_rbox_area
 
amrex::EBCellFlag m_flag
 
polygon_ m_F1
 
polygon_ m_F2
 
polygon_ m_F3
 
polygon_ m_F4
 
polygon_ m_F5
 
polygon_ m_F6
 
amrex::Array< amrex::RealVect, m_max_facesm_cellface_cent
 
amrex::RealVect m_cell_cent
 
amrex::RealVect m_dx
 
polygon_ m_F7
 
amrex::Array< polygon_ const *const, 3 > m_lo_faces {&m_F4, &m_F5, &m_F1}
 
amrex::Array< polygon_ const *const, 3 > m_hi_faces {&m_F2, &m_F6, &m_F3}
 
amrex::Array< int const, 3 > m_lo_faces_id {3,4,0}
 
amrex::Array< int const, 3 > m_hi_faces_id {1,5,2}
 

Static Private Attributes

static constexpr int m_max_faces = 6
 

Detailed Description

Reconstructs geometric moments for one EB cut cell.

The class clips a rectangular cell by a planar EB approximation and exposes volume, face areas, centroids, boundary area, boundary centroid, and boundary normal data used by auxiliary face-centered EB factories.

Constructor & Destructor Documentation

◆ eb_cut_cell_()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE eb_cut_cell_::eb_cut_cell_ ( amrex::EBCellFlag const &  a_flag,
amrex::RealBox const &  a_rbox,
amrex::RealVect const &  a_point,
amrex::RealVect const &  a_normal 
)

Construct cut-cell geometry from a cell flag, box, EB point, and EB normal.

Parameters
a_flagAMReX EB cell flag for the cell.
a_rboxPhysical-space cell box.
a_pointPoint on the EB plane.
a_normalUnit normal for the EB plane.
336  : m_rbox(a_rbox)
337  , m_eb_point(a_point)
338  , m_eb_normal(a_normal)
339  , m_invert(zero)
340  , m_F1(a_point, a_normal)
341  , m_F2(a_point, a_normal)
342  , m_F3(a_point, a_normal)
343  , m_F4(a_point, a_normal)
344  , m_F5(a_point, a_normal)
345  , m_F6(a_point, a_normal)
346  , m_cellface_cent({amrex::RealVect(zero), amrex::RealVect(zero), amrex::RealVect(zero),
347  amrex::RealVect(zero), amrex::RealVect(zero), amrex::RealVect(zero)})
348 {
349  using namespace amrex;
350 
351  m_rbox_area[0] = m_rbox.length(1)*m_rbox.length(2);
352  m_rbox_area[1] = m_rbox.length(0)*m_rbox.length(2);
353  m_rbox_area[2] = m_rbox.length(0)*m_rbox.length(1);
354 
355  amrex::RealVect v0(m_rbox.lo(0), m_rbox.lo(1), m_rbox.lo(2));
356  amrex::RealVect v1(m_rbox.hi(0), m_rbox.lo(1), m_rbox.lo(2));
357  amrex::RealVect v2(m_rbox.lo(0), m_rbox.hi(1), m_rbox.lo(2));
358  amrex::RealVect v3(m_rbox.lo(0), m_rbox.lo(1), m_rbox.hi(2));
359  amrex::RealVect v4(m_rbox.hi(0), m_rbox.lo(1), m_rbox.hi(2));
360  amrex::RealVect v5(m_rbox.hi(0), m_rbox.hi(1), m_rbox.lo(2));
361  amrex::RealVect v6(m_rbox.lo(0), m_rbox.hi(1), m_rbox.hi(2));
362  amrex::RealVect v7(m_rbox.hi(0), m_rbox.hi(1), m_rbox.hi(2));
363 
364  // Centroids of cell faces
365 
366  m_cellface_cent[0] = fourth * ( v0 + v2 + v5 + v1 ); // F1
367  m_cellface_cent[1] = fourth * ( v1 + v5 + v7 + v4 ); // F2
368  m_cellface_cent[2] = fourth * ( v3 + v4 + v7 + v6 ); // F3
369  m_cellface_cent[3] = fourth * ( v0 + v3 + v6 + v2 ); // F4
370  m_cellface_cent[4] = fourth * ( v0 + v1 + v4 + v3 ); // F5
371  m_cellface_cent[5] = fourth * ( v2 + v5 + v7 + v6 ); // F6
372 
373  // Cell centroid
374 
375  m_cell_cent[0] = myhalf * ( m_rbox.lo(0) + m_rbox.hi(0) );
376  m_cell_cent[1] = myhalf * ( m_rbox.lo(1) + m_rbox.hi(1) );
377  m_cell_cent[2] = myhalf * ( m_rbox.lo(2) + m_rbox.hi(2) );
378 
379  // Cell size
380 
381  m_dx[0] = m_rbox.hi(0) - m_rbox.lo(0);
382  m_dx[1] = m_rbox.hi(1) - m_rbox.lo(1);
383  m_dx[2] = m_rbox.hi(2) - m_rbox.lo(2);
384 
385  if (a_flag.isCovered() ) {
386 
387  set_covered();
388 
389  } else if (a_flag.isRegular() ) {
390 
391  set_regular();
392 
393  } else { // Check that the box and plane intersect.
394 
395  amrex::RealVect c = myhalf*(v0 + v7);
396  amrex::RealVect e = v7 - c;
397 
398  amrex::Real r = e[0]*amrex::Math::abs(a_normal[0]) +
399  e[1]*amrex::Math::abs(a_normal[1]) +
400  e[2]*amrex::Math::abs(a_normal[2]);
401 
402  amrex::Real s = amrex::Math::abs(c.dotProduct(a_normal)
403  - a_point.dotProduct(a_normal));
404 
405  if (s > r) {
406  if ((a_normal.dotProduct(v0) - a_normal.dotProduct(a_point)) > zero)
407  { set_covered(); } else { set_regular(); }
408  } else { m_flag.setSingleValued(); }
409  }
410 
411  if ( m_flag.isSingleValued() ) {
412 
413  m_invert = ((m_eb_normal.dotProduct(v0) - m_eb_normal.dotProduct(m_eb_point)) > zero) ? zero : one;
414 
416 
417  } // end singleValued
418 
419  m_F1.define();
420  m_F2.define();
421  m_F3.define();
422  m_F4.define();
423  m_F5.define();
424  m_F6.define();
425  m_F7.define();
426 
427  // For covered and regular cut cells, add vertices to utilize e.g., get_centroid.
428  if ( !m_flag.isSingleValued() ) {
430  }
431 
432 }
constexpr amrex::Real one
Definition: ERF_NumericalConstants.H:30
constexpr amrex::Real fourth
Definition: ERF_NumericalConstants.H:35
constexpr amrex::Real zero
Definition: ERF_NumericalConstants.H:29
constexpr amrex::Real myhalf
Definition: ERF_NumericalConstants.H:34
amrex::Real Real
Definition: ERF_ShocInterface.H:19
AMREX_GPU_HOST_DEVICE void calc_edge_intersections()
Compute all edge-plane intersections and populate polygon vertices.
Definition: ERF_EBCutCell.H:499
polygon_ m_F6
Definition: ERF_EBCutCell.H:301
amrex::RealVect m_rbox_area
Definition: ERF_EBCutCell.H:290
amrex::RealVect m_cell_cent
Definition: ERF_EBCutCell.H:305
amrex::RealVect m_dx
Definition: ERF_EBCutCell.H:306
amrex::RealVect const m_eb_point
Definition: ERF_EBCutCell.H:285
amrex::Real m_invert
Definition: ERF_EBCutCell.H:288
amrex::RealBox const m_rbox
Definition: ERF_EBCutCell.H:284
AMREX_GPU_HOST_DEVICE void set_covered_regular_cell_vertices()
Populate polygon vertices for cells that are fully covered or regular.
Definition: ERF_EBCutCell.H:972
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void set_regular()
Mark the reconstructed cell as regular and fill regular face areas.
Definition: ERF_EBCutCell.H:106
polygon_ m_F1
Definition: ERF_EBCutCell.H:296
polygon_ m_F3
Definition: ERF_EBCutCell.H:298
amrex::EBCellFlag m_flag
Definition: ERF_EBCutCell.H:292
polygon_ m_F5
Definition: ERF_EBCutCell.H:300
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void set_covered()
Mark the reconstructed cell as covered.
Definition: ERF_EBCutCell.H:100
polygon_ m_F7
Definition: ERF_EBCutCell.H:309
amrex::RealVect const m_eb_normal
Definition: ERF_EBCutCell.H:286
polygon_ m_F2
Definition: ERF_EBCutCell.H:297
polygon_ m_F4
Definition: ERF_EBCutCell.H:299
amrex::Array< amrex::RealVect, m_max_faces > m_cellface_cent
Definition: ERF_EBCutCell.H:304
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void define()
Finalize polygon ordering and compute its area.
Definition: ERF_EBPolygon.H:97
Definition: ERF_ConsoleIO.cpp:15

Member Function Documentation

◆ areaBoun()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real eb_cut_cell_::areaBoun ( ) const
inlinenoexcept

Return the EB boundary area inside the cell.

173  {
174  return m_F7.area();
175  }
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real area() const noexcept
Return the polygon area.
Definition: ERF_EBPolygon.H:188

Referenced by eb_aux_::define().

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

◆ areaHi()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real eb_cut_cell_::areaHi ( int const  idir) const
inlinenoexcept

Return the high-side face area in one coordinate direction.

Parameters
idirCoordinate direction.
163  {
164  AMREX_ASSERT( idir >= 0 && idir < AMREX_SPACEDIM );
165  if (m_flag.isCovered() ) { return zero; }
166  if (m_flag.isRegular() ) { return m_hi_faces[idir]->area(); }
167  amrex::Real const area(m_hi_faces[idir]->area());
168  return m_invert*area + (one-m_invert)*(m_rbox_area[idir] - area);
169  }
amrex::Array< polygon_ const *const, 3 > m_hi_faces
Definition: ERF_EBCutCell.H:312

Referenced by centVol(), and eb_aux_::define().

Here is the caller graph for this function:

◆ areaLo()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real eb_cut_cell_::areaLo ( int const  idir) const
inlinenoexcept

Return the low-side face area in one coordinate direction.

Parameters
idirCoordinate direction.
150  {
151  AMREX_ASSERT( idir >=0 && idir < AMREX_SPACEDIM );
152  if (m_flag.isCovered() ) { return zero; }
153  if (m_flag.isRegular() ) { return m_lo_faces[idir]->area(); }
154  amrex::Real const area(m_lo_faces[idir]->area());
155  return m_invert*area + (one-m_invert)*(m_rbox_area[idir] - area);
156  }
amrex::Array< polygon_ const *const, 3 > m_lo_faces
Definition: ERF_EBCutCell.H:311

Referenced by centVol(), and eb_aux_::define().

Here is the caller graph for this function:

◆ calc_edge_intersections()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void eb_cut_cell_::calc_edge_intersections ( )
private

Compute all edge-plane intersections and populate polygon vertices.

500 {
501  using namespace amrex;
502 
503  amrex::RealVect v0(m_rbox.lo(0), m_rbox.lo(1), m_rbox.lo(2));
504  amrex::RealVect v1(m_rbox.hi(0), m_rbox.lo(1), m_rbox.lo(2));
505  amrex::RealVect v2(m_rbox.lo(0), m_rbox.hi(1), m_rbox.lo(2));
506  amrex::RealVect v3(m_rbox.lo(0), m_rbox.lo(1), m_rbox.hi(2));
507  amrex::RealVect v4(m_rbox.hi(0), m_rbox.lo(1), m_rbox.hi(2));
508  amrex::RealVect v5(m_rbox.hi(0), m_rbox.hi(1), m_rbox.lo(2));
509  amrex::RealVect v6(m_rbox.lo(0), m_rbox.hi(1), m_rbox.hi(2));
510  amrex::RealVect v7(m_rbox.hi(0), m_rbox.hi(1), m_rbox.hi(2));
511 
512 // #ifndef AMREX_USE_GPU
513 
514  bool print_initial = ( Math::abs(m_eb_point[0]-Real(1.666667e-01))<Real(1.e-4) &&
515  Math::abs(m_eb_point[1]+Real(4.194018e-01))<Real(1.e-4) &&
516  Math::abs(m_eb_point[2]+Real(1.666667e-01))<Real(1.e-4) );
517  const bool print_F1 = print_initial && false;
518  const bool print_F2 = print_initial && false;
519  const bool print_F3 = print_initial && false;
520  const bool print_F4 = print_initial && false;
521  const bool print_F5 = print_initial && false;
522  const bool print_F6 = print_initial && false;
523  const bool print_F7 = print_initial && false;
524 // #endif
525 
526  m_F1.add_vertex(v0); if(print_F1) AMREX_DEVICE_PRINTF("%s \n","Initial: add v0 -> F1");
527  m_F4.add_vertex(v0); if(print_F4) AMREX_DEVICE_PRINTF("%s \n","Initial: add v0 -> F4");
528  m_F5.add_vertex(v0); if(print_F5) AMREX_DEVICE_PRINTF("%s \n","Initial: add v0 -> F5");
529 
530  int add_v7(1);
531 
532  amrex::RealVect vIP;
533  amrex::Real distIP;
534 
535  amrex::Array<bool,8> vertex_intersected{}; // true if vertex has been intersected within a path.
536 
537  //------------------------------------------------------------
538  // STEP 1: Predefine edge-plane intersections along 6 paths.
539  // Check how the edges intersect the plane and whether the configuration is valid.
540  // If the configuration is not valid, adjust it.
541  //------------------------------------------------------------
542 
543  amrex::Array<path_data,3> p1, p2, p3;
544  path_data p4, p5, p6;
545 
546  // Path 1: v0->v1->v4->v7
547  p1[0].set(m_eb_point, m_eb_normal, v0, v1);
548  p1[1].set(m_eb_point, m_eb_normal, v1, v4);
549  p1[2].set(m_eb_point, m_eb_normal, v4, v7);
550 
551  // Path 2: v0->v2->v5->v7
552  p2[0].set(m_eb_point, m_eb_normal, v0, v2);
553  p2[1].set(m_eb_point, m_eb_normal, v2, v5);
554  p2[2].set(m_eb_point, m_eb_normal, v5, v7);
555 
556  // Path 3: v0->v3->v6->v7
557  p3[0].set(m_eb_point, m_eb_normal, v0, v3);
558  p3[1].set(m_eb_point, m_eb_normal, v3, v6);
559  p3[2].set(m_eb_point, m_eb_normal, v6, v7);
560 
561  // Path 4: v1->v5
562  p4.set(m_eb_point, m_eb_normal, v1, v5);
563 
564  // Path 5: v2->v6
565  p5.set(m_eb_point, m_eb_normal, v2, v6);
566 
567  // Path 6: v3->v4
568  p6.set(m_eb_point, m_eb_normal, v3, v4);
569 
570  //------------------------------------------------------------
571  // STEP 2: Add vertices to faces.
572  //------------------------------------------------------------
573 
574  // Path 1
575  {
576  int cuts(0);
577  for (int i = 0; i < 8; ++i) vertex_intersected[i] = false;
578 
579  if (p1[0].intersected) {
580  if (p1[0].intersected_start) {
581  m_F1.add_vertex(v0); if(print_F1) AMREX_DEVICE_PRINTF("%s \n","Path 1: v0--v1: add v0 -> F1");
582  m_F4.add_vertex(v0); if(print_F4) AMREX_DEVICE_PRINTF("%s \n","Path 1: v0--v1: add v0 -> F4");
583  m_F5.add_vertex(v0); if(print_F5) AMREX_DEVICE_PRINTF("%s \n","Path 1: v0--v1: add v0 -> F5");
584  m_F7.add_vertex(v0); if(print_F7) AMREX_DEVICE_PRINTF("%s \n","Path 1: v0--v1: add v0 -> F7");
585  if (!vertex_intersected[0]) {
586  vertex_intersected[0] = true;
587  ++cuts;
588  }
589  } else if (p1[0].intersected_end) {
590  m_F1.add_vertex(v1); if(print_F1) AMREX_DEVICE_PRINTF("%s \n","Path 1: v0--v1: add v1 -> F1");
591  m_F2.add_vertex(v1); if(print_F2) AMREX_DEVICE_PRINTF("%s \n","Path 1: v0--v1: add v1 -> F2");
592  m_F5.add_vertex(v1); if(print_F5) AMREX_DEVICE_PRINTF("%s \n","Path 1: v0--v1: add v1 -> F5");
593  m_F7.add_vertex(v1); if(print_F7) AMREX_DEVICE_PRINTF("%s \n","Path 1: v0--v1: add v1 -> F7");
594  if (!vertex_intersected[1]) {
595  vertex_intersected[1] = true;
596  ++cuts;
597  }
598  } else {
599  m_F1.add_vertex(p1[0].vIP); if(print_F1) AMREX_DEVICE_PRINTF("%s \n","Path 1: v0--v1: add vIP -> F1");
600  m_F5.add_vertex(p1[0].vIP); if(print_F5) AMREX_DEVICE_PRINTF("%s \n","Path 1: v0--v1: add vIP -> F5");
601  m_F7.add_vertex(p1[0].vIP); if(print_F7) AMREX_DEVICE_PRINTF("%s \n","Path 1: v0--v1: add vIP -> F7");
602  ++cuts;
603  }
604 
605  } // Path 1: v0--v1
606 
607  if (cuts%2 == 0) {
608  m_F1.add_vertex(v1); if(print_F1) AMREX_DEVICE_PRINTF("%s \n","Path 1: after v0--v1, cuts-mod-2==0: add v1 -> F1");
609  m_F2.add_vertex(v1); if(print_F2) AMREX_DEVICE_PRINTF("%s \n","Path 1: after v0--v1, cuts-mod-2==0: add v1 -> F2");
610  m_F5.add_vertex(v1); if(print_F5) AMREX_DEVICE_PRINTF("%s \n","Path 1: after v0--v1, cuts-mod-2==0: add v1 -> F5");
611  }
612 
613  if (p1[1].intersected) {
614  if (p1[1].intersected_start) {
615  m_F1.add_vertex(v1); if(print_F1) AMREX_DEVICE_PRINTF("%s \n","Path 1: v1--v4: add v1 -> F1");
616  m_F2.add_vertex(v1); if(print_F2) AMREX_DEVICE_PRINTF("%s \n","Path 1: v1--v4: add v1 -> F2");
617  m_F5.add_vertex(v1); if(print_F5) AMREX_DEVICE_PRINTF("%s \n","Path 1: v1--v4: add v1 -> F5");
618  m_F7.add_vertex(v1); if(print_F7) AMREX_DEVICE_PRINTF("%s \n","Path 1: v1--v4: add v1 -> F7");
619  if (!vertex_intersected[1]) {
620  vertex_intersected[1] = true;
621  ++cuts;
622  }
623  } else if (p1[1].intersected_end) {
624  m_F2.add_vertex(v4); if(print_F2) AMREX_DEVICE_PRINTF("%s \n","Path 1: v1--v4: add v4 -> F2");
625  m_F3.add_vertex(v4); if(print_F3) AMREX_DEVICE_PRINTF("%s \n","Path 1: v1--v4: add v4 -> F3");
626  m_F5.add_vertex(v4); if(print_F5) AMREX_DEVICE_PRINTF("%s \n","Path 1: v1--v4: add v4 -> F5");
627  m_F7.add_vertex(v4); if(print_F7) AMREX_DEVICE_PRINTF("%s \n","Path 1: v1--v4: add v4 -> F7");
628  if (!vertex_intersected[4]) {
629  vertex_intersected[4] = true;
630  ++cuts;
631  }
632  } else {
633  m_F2.add_vertex(p1[1].vIP); if(print_F2) AMREX_DEVICE_PRINTF("%s \n","Path 1: v1--v4: add vIP -> F2");
634  m_F5.add_vertex(p1[1].vIP); if(print_F5) AMREX_DEVICE_PRINTF("%s \n","Path 1: v1--v4: add vIP -> F5");
635  m_F7.add_vertex(p1[1].vIP); if(print_F7) AMREX_DEVICE_PRINTF("%s \n","Path 1: v1--v4: add vIP -> F7");
636  ++cuts;
637  }
638 
639  } // P1: v1--v4
640 
641  if (cuts%2 == 0) {
642  m_F2.add_vertex(v4); if(print_F2) AMREX_DEVICE_PRINTF("%s \n","Path 1: after v1--v4, cuts-mod-2==0: add v4 -> F2");
643  m_F3.add_vertex(v4); if(print_F3) AMREX_DEVICE_PRINTF("%s \n","Path 1: after v1--v4, cuts-mod-2==0: add v4 -> F3");
644  m_F5.add_vertex(v4); if(print_F5) AMREX_DEVICE_PRINTF("%s \n","Path 1: after v1--v4, cuts-mod-2==0: add v4 -> F5");
645  }
646 
647  if (p1[2].intersected) {
648  if (p1[2].intersected_start) {
649  m_F2.add_vertex(v4); if(print_F2) AMREX_DEVICE_PRINTF("%s \n","Path 1: v4--v7: add v4 -> F2");
650  m_F3.add_vertex(v4); if(print_F3) AMREX_DEVICE_PRINTF("%s \n","Path 1: v4--v7: add v4 -> F3");
651  m_F5.add_vertex(v4); if(print_F5) AMREX_DEVICE_PRINTF("%s \n","Path 1: v4--v7: add v4 -> F5");
652  m_F7.add_vertex(v4); if(print_F7) AMREX_DEVICE_PRINTF("%s \n","Path 1: v4--v7: add v4 -> F7");
653  if (!vertex_intersected[4]) {
654  vertex_intersected[4] = true;
655  ++cuts;
656  }
657  } else if (p1[2].intersected_end) {
658  m_F2.add_vertex(v7); if(print_F2) AMREX_DEVICE_PRINTF("%s \n","Path 1: v4--v7: add v7 -> F2");
659  m_F3.add_vertex(v7); if(print_F3) AMREX_DEVICE_PRINTF("%s \n","Path 1: v4--v7: add v7 -> F3");
660  m_F6.add_vertex(v7); if(print_F6) AMREX_DEVICE_PRINTF("%s \n","Path 1: v4--v7: add v7 -> F6");
661  m_F7.add_vertex(v7); if(print_F7) AMREX_DEVICE_PRINTF("%s \n","Path 1: v4--v7: add v7 -> F7");
662  if (!vertex_intersected[7]) {
663  vertex_intersected[7] = true;
664  ++cuts;
665  }
666  } else {
667  m_F2.add_vertex(p1[2].vIP); if(print_F2) AMREX_DEVICE_PRINTF("%s \n","Path 1: v4--v7: add vIP -> F2");
668  m_F3.add_vertex(p1[2].vIP); if(print_F3) AMREX_DEVICE_PRINTF("%s \n","Path 1: v4--v7: add vIP -> F3");
669  m_F7.add_vertex(p1[2].vIP); if(print_F7) AMREX_DEVICE_PRINTF("%s \n","Path 1: v4--v7: add vIP -> F7");
670  ++cuts;
671  }
672 
673  } // P1: v4--v7
674 
675  if (cuts == 2 && add_v7) {
676  if (!intersect_plane_edge(m_eb_point, m_eb_normal, v0, v7, vIP, distIP)) {
677  m_F2.add_vertex(v7); if(print_F2) AMREX_DEVICE_PRINTF("%s \n","Path 1: after v4--v7, cuts == 2 && add_v7: add v7 -> F2");
678  m_F3.add_vertex(v7); if(print_F3) AMREX_DEVICE_PRINTF("%s \n","Path 1: after v4--v7, cuts == 2 && add_v7: add v7 -> F3");
679  m_F6.add_vertex(v7); if(print_F6) AMREX_DEVICE_PRINTF("%s \n","Path 1: after v4--v7, cuts == 2 && add_v7: add v7 -> F6");
680  add_v7 = 0;
681  }
682  }
683  } // end Path 1
684 
685  // Path 4
686  if (p4.intersected) {
687  if (p4.intersected_start) {
688  m_F1.add_vertex(v1); if(print_F1) AMREX_DEVICE_PRINTF("%s \n","Path 4: v1--v5: add v1 -> F1");
689  m_F2.add_vertex(v1); if(print_F2) AMREX_DEVICE_PRINTF("%s \n","Path 4: v1--v5: add v1 -> F2");
690  m_F5.add_vertex(v1); if(print_F5) AMREX_DEVICE_PRINTF("%s \n","Path 4: v1--v5: add v1 -> F5");
691  m_F7.add_vertex(v1); if(print_F7) AMREX_DEVICE_PRINTF("%s \n","Path 4: v1--v5: add v1 -> F7");
692  } else if (p4.intersected_end) {
693  m_F1.add_vertex(v5); if(print_F1) AMREX_DEVICE_PRINTF("%s \n","Path 4: v1--v5: add v5 -> F1");
694  m_F2.add_vertex(v5); if(print_F2) AMREX_DEVICE_PRINTF("%s \n","Path 4: v1--v5: add v5 -> F2");
695  m_F6.add_vertex(v5); if(print_F6) AMREX_DEVICE_PRINTF("%s \n","Path 4: v1--v5: add v5 -> F6");
696  m_F7.add_vertex(v5); if(print_F7) AMREX_DEVICE_PRINTF("%s \n","Path 4: v1--v5: add v5 -> F7");
697  } else {
698  m_F1.add_vertex(p4.vIP); if(print_F1) AMREX_DEVICE_PRINTF("%s \n","Path 4: v1--v5: add vIP -> F1");
699  m_F2.add_vertex(p4.vIP); if(print_F2) AMREX_DEVICE_PRINTF("%s \n","Path 4: v1--v5: add vIP -> F2");
700  m_F7.add_vertex(p4.vIP); if(print_F7) AMREX_DEVICE_PRINTF("%s \n","Path 4: v1--v5: add vIP -> F7");
701  }
702  }
703 
704  // Path 2
705  { int cuts(0);
706  for (int i = 0; i < 8; ++i) vertex_intersected[i] = false;
707 
708  if (p2[0].intersected) {
709  if (p2[0].intersected_start) {
710  m_F1.add_vertex(v0); if(print_F1) AMREX_DEVICE_PRINTF("%s \n","Path 2: v0--v2: add v0 -> F1");
711  m_F4.add_vertex(v0); if(print_F4) AMREX_DEVICE_PRINTF("%s \n","Path 2: v0--v2: add v0 -> F4");
712  m_F5.add_vertex(v0); if(print_F5) AMREX_DEVICE_PRINTF("%s \n","Path 2: v0--v2: add v0 -> F5");
713  m_F7.add_vertex(v0); if(print_F7) AMREX_DEVICE_PRINTF("%s \n","Path 2: v0--v2: add v0 -> F7");
714  if (!vertex_intersected[0]) {
715  vertex_intersected[0] = true;
716  ++cuts;
717  }
718  } else if (p2[0].intersected_end) {
719  m_F1.add_vertex(v2); if(print_F1) AMREX_DEVICE_PRINTF("%s \n","Path 2: v0--v2: add v2 -> F1");
720  m_F4.add_vertex(v2); if(print_F4) AMREX_DEVICE_PRINTF("%s \n","Path 2: v0--v2: add v2 -> F4");
721  m_F6.add_vertex(v2); if(print_F6) AMREX_DEVICE_PRINTF("%s \n","Path 2: v0--v2: add v2 -> F6");
722  m_F7.add_vertex(v2); if(print_F7) AMREX_DEVICE_PRINTF("%s \n","Path 2: v0--v2: add v2 -> F7");
723  if (!vertex_intersected[2]) {
724  vertex_intersected[2] = true;
725  ++cuts;
726  }
727  } else {
728  m_F1.add_vertex(p2[0].vIP); if(print_F1) AMREX_DEVICE_PRINTF("%s \n","Path 2: v0--v2: add vIP -> F1");
729  m_F4.add_vertex(p2[0].vIP); if(print_F4) AMREX_DEVICE_PRINTF("%s \n","Path 2: v0--v2: add vIP -> F4");
730  m_F7.add_vertex(p2[0].vIP); if(print_F7) AMREX_DEVICE_PRINTF("%s \n","Path 2: v0--v2: add vIP -> F7");
731  ++cuts;
732  }
733 
734  } // P2: v0--v2
735 
736  if (cuts%2 == 0) {
737  m_F1.add_vertex(v2); if(print_F1) AMREX_DEVICE_PRINTF("%s \n","Path 2: after v0--v2, cuts-mod-2==0: add v2 -> F1");
738  m_F4.add_vertex(v2); if(print_F4) AMREX_DEVICE_PRINTF("%s \n","Path 2: after v0--v2, cuts-mod-2==0: add v2 -> F4");
739  m_F6.add_vertex(v2); if(print_F6) AMREX_DEVICE_PRINTF("%s \n","Path 2: after v0--v2, cuts-mod-2==0: add v2 -> F6");
740  }
741 
742  if (p2[1].intersected) {
743  if (p2[1].intersected_start) {
744  m_F1.add_vertex(v2); if(print_F1) AMREX_DEVICE_PRINTF("%s \n","Path 2: v2--v5: add v2 -> F1");
745  m_F4.add_vertex(v2); if(print_F4) AMREX_DEVICE_PRINTF("%s \n","Path 2: v2--v5: add v2 -> F4");
746  m_F6.add_vertex(v2); if(print_F6) AMREX_DEVICE_PRINTF("%s \n","Path 2: v2--v5: add v2 -> F6");
747  m_F7.add_vertex(v2); if(print_F7) AMREX_DEVICE_PRINTF("%s \n","Path 2: v2--v5: add v2 -> F7");
748  if (!vertex_intersected[2]) {
749  vertex_intersected[2] = true;
750  ++cuts;
751  }
752  } else if (p2[1].intersected_end) {
753  m_F1.add_vertex(v5); if(print_F1) AMREX_DEVICE_PRINTF("%s \n","Path 2: v2--v5: add v5 -> F1");
754  m_F2.add_vertex(v5); if(print_F2) AMREX_DEVICE_PRINTF("%s \n","Path 2: v2--v5: add v5 -> F2");
755  m_F6.add_vertex(v5); if(print_F6) AMREX_DEVICE_PRINTF("%s \n","Path 2: v2--v5: add v5 -> F6");
756  m_F7.add_vertex(v5); if(print_F7) AMREX_DEVICE_PRINTF("%s \n","Path 2: v2--v5: add v5 -> F7");
757  if (!vertex_intersected[5]) {
758  vertex_intersected[5] = true;
759  ++cuts;
760  }
761  } else {
762  m_F1.add_vertex(p2[1].vIP); if(print_F1) AMREX_DEVICE_PRINTF("%s \n","Path 2: v2--v5: add vIP -> F1");
763  m_F6.add_vertex(p2[1].vIP); if(print_F6) AMREX_DEVICE_PRINTF("%s \n","Path 2: v2--v5: add vIP -> F6");
764  m_F7.add_vertex(p2[1].vIP); if(print_F7) AMREX_DEVICE_PRINTF("%s \n","Path 2: v2--v5: add vIP -> F7");
765  ++cuts;
766  }
767  }
768 
769  if (cuts%2 == 0) {
770  m_F1.add_vertex(v5); if(print_F1) AMREX_DEVICE_PRINTF("%s \n","Path 2: after v2--v5, cuts-mod-2==0: add v5 -> F1");
771  m_F2.add_vertex(v5); if(print_F2) AMREX_DEVICE_PRINTF("%s \n","Path 2: after v2--v5, cuts-mod-2==0: add v5 -> F2");
772  m_F6.add_vertex(v5); if(print_F6) AMREX_DEVICE_PRINTF("%s \n","Path 2: after v2--v5, cuts-mod-2==0: add v5 -> F6");
773  }
774 
775  if (p2[2].intersected) {
776  if (p2[2].intersected_start) {
777  m_F1.add_vertex(v5); if(print_F1) AMREX_DEVICE_PRINTF("%s \n","Path 2: v5--v7: add v5 -> F1");
778  m_F2.add_vertex(v5); if(print_F2) AMREX_DEVICE_PRINTF("%s \n","Path 2: v5--v7: add v5 -> F2");
779  m_F6.add_vertex(v5); if(print_F6) AMREX_DEVICE_PRINTF("%s \n","Path 2: v5--v7: add v5 -> F6");
780  m_F7.add_vertex(v5); if(print_F7) AMREX_DEVICE_PRINTF("%s \n","Path 2: v5--v7: add v5 -> F7");
781  if (!vertex_intersected[5]) {
782  vertex_intersected[5] = true;
783  ++cuts;
784  }
785  } else if (p2[2].intersected_end) {
786  m_F2.add_vertex(v7); if(print_F2) AMREX_DEVICE_PRINTF("%s \n","Path 2: v5--v7: add v7 -> F2");
787  m_F3.add_vertex(v7); if(print_F3) AMREX_DEVICE_PRINTF("%s \n","Path 2: v5--v7: add v7 -> F3");
788  m_F6.add_vertex(v7); if(print_F6) AMREX_DEVICE_PRINTF("%s \n","Path 2: v5--v7: add v7 -> F6");
789  m_F7.add_vertex(v7); if(print_F7) AMREX_DEVICE_PRINTF("%s \n","Path 2: v5--v7: add v7 -> F7");
790  if (!vertex_intersected[7]) {
791  vertex_intersected[7] = true;
792  ++cuts;
793  }
794  } else {
795  m_F2.add_vertex(p2[2].vIP); if(print_F2) AMREX_DEVICE_PRINTF("%s \n","Path 2: v5--v7: add vIP -> F2");
796  m_F6.add_vertex(p2[2].vIP); if(print_F6) AMREX_DEVICE_PRINTF("%s \n","Path 2: v5--v7: add vIP -> F6");
797  m_F7.add_vertex(p2[2].vIP); if(print_F7) AMREX_DEVICE_PRINTF("%s \n","Path 2: v5--v7: add vIP -> F7");
798  ++cuts;
799  }
800  } // Path 2: v5--v7
801 
802  if (cuts == 2 && add_v7) {
803  if (!intersect_plane_edge(m_eb_point, m_eb_normal, v0, v7, vIP, distIP)) {
804  m_F2.add_vertex(v7); if(print_F2) AMREX_DEVICE_PRINTF("%s \n","Path 2: after v5--v7, cuts == 2 && add_v7: add v7 -> F2");
805  m_F3.add_vertex(v7); if(print_F3) AMREX_DEVICE_PRINTF("%s \n","Path 2: after v5--v7, cuts == 2 && add_v7: add v7 -> F3");
806  m_F6.add_vertex(v7); if(print_F6) AMREX_DEVICE_PRINTF("%s \n","Path 2: after v5--v7, cuts == 2 && add_v7: add v7 -> F6");
807  add_v7 = 0;
808  }
809  }
810 
811  } // end Path 2
812 
813  // Path 5
814  if (p5.intersected) {
815  if (p5.intersected_start) {
816  m_F1.add_vertex(v2); if(print_F1) AMREX_DEVICE_PRINTF("%s \n","Path 5: v2--v6: add v2 -> F1");
817  m_F4.add_vertex(v2); if(print_F4) AMREX_DEVICE_PRINTF("%s \n","Path 5: v2--v6: add v2 -> F4");
818  m_F6.add_vertex(v2); if(print_F6) AMREX_DEVICE_PRINTF("%s \n","Path 5: v2--v6: add v2 -> F6");
819  m_F7.add_vertex(v2); if(print_F7) AMREX_DEVICE_PRINTF("%s \n","Path 5: v2--v6: add v2 -> F7");
820  } else if (p5.intersected_end) {
821  m_F3.add_vertex(v6); if(print_F3) AMREX_DEVICE_PRINTF("%s \n","Path 5: v2--v6: add v6 -> F3");
822  m_F4.add_vertex(v6); if(print_F4) AMREX_DEVICE_PRINTF("%s \n","Path 5: v2--v6: add v6 -> F4");
823  m_F6.add_vertex(v6); if(print_F6) AMREX_DEVICE_PRINTF("%s \n","Path 5: v2--v6: add v6 -> F6");
824  m_F7.add_vertex(v6); if(print_F7) AMREX_DEVICE_PRINTF("%s \n","Path 5: v2--v6: add v6 -> F7");
825  } else {
826  m_F4.add_vertex(p5.vIP); if(print_F4) AMREX_DEVICE_PRINTF("%s \n","Path 5: v2--v6: add vIP -> F4");
827  m_F6.add_vertex(p5.vIP); if(print_F6) AMREX_DEVICE_PRINTF("%s \n","Path 5: v2--v6: add vIP -> F6");
828  m_F7.add_vertex(p5.vIP); if(print_F7) AMREX_DEVICE_PRINTF("%s \n","Path 5: v2--v6: add vIP -> F7");
829  }
830  } // end Path 5
831 
832 
833  // Path 3
834  { int cuts(0);
835  for (int i = 0; i < 8; ++i) vertex_intersected[i] = false;
836 
837  if (p3[0].intersected) {
838  if (p3[0].intersected_start) {
839  m_F1.add_vertex(v0); if(print_F1) AMREX_DEVICE_PRINTF("%s \n","Path 3: v0--v3: add v0 -> F1");
840  m_F4.add_vertex(v0); if(print_F4) AMREX_DEVICE_PRINTF("%s \n","Path 3: v0--v3: add v0 -> F4");
841  m_F5.add_vertex(v0); if(print_F5) AMREX_DEVICE_PRINTF("%s \n","Path 3: v0--v3: add v0 -> F5");
842  m_F7.add_vertex(v0); if(print_F7) AMREX_DEVICE_PRINTF("%s \n","Path 3: v0--v3: add v0 -> F7");
843  if (!vertex_intersected[0]) {
844  vertex_intersected[0] = true;
845  ++cuts;
846  }
847  } else if (p3[0].intersected_end) {
848  m_F3.add_vertex(v3); if(print_F3) AMREX_DEVICE_PRINTF("%s \n","Path 3: v0--v3: add v3 -> F3");
849  m_F4.add_vertex(v3); if(print_F4) AMREX_DEVICE_PRINTF("%s \n","Path 3: v0--v3: add v3 -> F4");
850  m_F5.add_vertex(v3); if(print_F5) AMREX_DEVICE_PRINTF("%s \n","Path 3: v0--v3: add v3 -> F5");
851  m_F7.add_vertex(v3); if(print_F7) AMREX_DEVICE_PRINTF("%s \n","Path 3: v0--v3: add v3 -> F7");
852  if (!vertex_intersected[3]) {
853  vertex_intersected[3] = true;
854  ++cuts;
855  }
856  } else {
857  m_F4.add_vertex(p3[0].vIP); if(print_F4) AMREX_DEVICE_PRINTF("%s \n","Path 3: v0--v3: add vIP -> F4");
858  m_F5.add_vertex(p3[0].vIP); if(print_F5) AMREX_DEVICE_PRINTF("%s \n","Path 3: v0--v3: add vIP -> F5");
859  m_F7.add_vertex(p3[0].vIP); if(print_F7) AMREX_DEVICE_PRINTF("%s \n","Path 3: v0--v3: add vIP -> F7");
860  ++cuts;
861  }
862 
863  } // P3: v0--v3
864 
865  if (cuts%2 == 0) {
866  m_F3.add_vertex(v3); if(print_F3) AMREX_DEVICE_PRINTF("%s \n","Path 3: after v0--v3, cuts-mod-2 == 0: add v3 -> F3");
867  m_F4.add_vertex(v3); if(print_F4) AMREX_DEVICE_PRINTF("%s \n","Path 3: after v0--v3, cuts-mod-2 == 0: add v3 -> F4");
868  m_F5.add_vertex(v3); if(print_F5) AMREX_DEVICE_PRINTF("%s \n","Path 3: after v0--v3, cuts-mod-2 == 0: add v3 -> F5");
869  }
870 
871  if (p3[1].intersected) {
872  if (p3[1].intersected_start) {
873  m_F3.add_vertex(v3); if(print_F3) AMREX_DEVICE_PRINTF("%s \n","Path 3: v3--v6: add v3 -> F3");
874  m_F4.add_vertex(v3); if(print_F4) AMREX_DEVICE_PRINTF("%s \n","Path 3: v3--v6: add v3 -> F4");
875  m_F5.add_vertex(v3); if(print_F5) AMREX_DEVICE_PRINTF("%s \n","Path 3: v3--v6: add v3 -> F5");
876  m_F7.add_vertex(v3); if(print_F7) AMREX_DEVICE_PRINTF("%s \n","Path 3: v3--v6: add v3 -> F7");
877  if (!vertex_intersected[3]) {
878  vertex_intersected[3] = true;
879  ++cuts;
880  }
881  } else if (p3[1].intersected_end) {
882  m_F3.add_vertex(v6); if(print_F3) AMREX_DEVICE_PRINTF("%s \n","Path 3: v3--v6: add v6 -> F3");
883  m_F4.add_vertex(v6); if(print_F4) AMREX_DEVICE_PRINTF("%s \n","Path 3: v3--v6: add v6 -> F4");
884  m_F6.add_vertex(v6); if(print_F6) AMREX_DEVICE_PRINTF("%s \n","Path 3: v3--v6: add v6 -> F6");
885  m_F7.add_vertex(v6); if(print_F7) AMREX_DEVICE_PRINTF("%s \n","Path 3: v3--v6: add v6 -> F7");
886  if (!vertex_intersected[6]) {
887  vertex_intersected[6] = true;
888  ++cuts;
889  }
890  } else {
891  m_F3.add_vertex(p3[1].vIP); if(print_F3) AMREX_DEVICE_PRINTF("%s \n","Path 3: v3--v6: add vIP -> F3");
892  m_F4.add_vertex(p3[1].vIP); if(print_F4) AMREX_DEVICE_PRINTF("%s \n","Path 3: v3--v6: add vIP -> F4");
893  m_F7.add_vertex(p3[1].vIP); if(print_F7) AMREX_DEVICE_PRINTF("%s \n","Path 3: v3--v6: add vIP -> F7");
894  ++cuts;
895  }
896 
897  } // P3: v3--v6
898 
899  if (cuts%2 == 0) {
900  m_F3.add_vertex(v6); if(print_F3) AMREX_DEVICE_PRINTF("%s \n","Path 3: after v3--v6, cuts-mod-2 == 0: add v6 -> F3");
901  m_F4.add_vertex(v6); if(print_F4) AMREX_DEVICE_PRINTF("%s \n","Path 3: after v3--v6, cuts-mod-2 == 0: add v6 -> F4");
902  m_F6.add_vertex(v6); if(print_F6) AMREX_DEVICE_PRINTF("%s \n","Path 3: after v3--v6, cuts-mod-2 == 0: add v6 -> F6");
903  }
904 
905  if (p3[2].intersected) {
906  if (p3[2].intersected_start) {
907  m_F3.add_vertex(v6); if(print_F3) AMREX_DEVICE_PRINTF("%s \n","Path 3: v6--v7: add v6 -> F3");
908  m_F4.add_vertex(v6); if(print_F4) AMREX_DEVICE_PRINTF("%s \n","Path 3: v6--v7: add v6 -> F4");
909  m_F6.add_vertex(v6); if(print_F6) AMREX_DEVICE_PRINTF("%s \n","Path 3: v6--v7: add v6 -> F6");
910  m_F7.add_vertex(v6); if(print_F7) AMREX_DEVICE_PRINTF("%s \n","Path 3: v6--v7: add v6 -> F7");
911  if (!vertex_intersected[6]) {
912  vertex_intersected[6] = true;
913  ++cuts;
914  }
915  } else if (p3[2].intersected_end) {
916  m_F2.add_vertex(v7); if(print_F2) AMREX_DEVICE_PRINTF("%s \n","Path 3: v6--v7: add v7 -> F2");
917  m_F3.add_vertex(v7); if(print_F3) AMREX_DEVICE_PRINTF("%s \n","Path 3: v6--v7: add v7 -> F3");
918  m_F6.add_vertex(v7); if(print_F6) AMREX_DEVICE_PRINTF("%s \n","Path 3: v6--v7: add v7 -> F6");
919  m_F7.add_vertex(v7); if(print_F7) AMREX_DEVICE_PRINTF("%s \n","Path 3: v6--v7: add v7 -> F7");
920  if (!vertex_intersected[7]) {
921  vertex_intersected[7] = true;
922  ++cuts;
923  }
924  } else {
925  m_F3.add_vertex(p3[2].vIP); if(print_F3) AMREX_DEVICE_PRINTF("%s \n","Path 3: v6--v7: add vIP -> F3");
926  m_F6.add_vertex(p3[2].vIP); if(print_F6) AMREX_DEVICE_PRINTF("%s \n","Path 3: v6--v7: add vIP -> F6");
927  m_F7.add_vertex(p3[2].vIP); if(print_F7) AMREX_DEVICE_PRINTF("%s \n","Path 3: v6--v7: add vIP -> F7");
928  ++cuts;
929  }
930  } // P3: v6--v7
931 
932  if (cuts == 2 && add_v7) {
933  if (!intersect_plane_edge(m_eb_point, m_eb_normal, v0, v7, vIP, distIP)) {
934  m_F2.add_vertex(v7); if(print_F2) AMREX_DEVICE_PRINTF("%s \n","Path 3: after v6--v7, cuts == 2 && add_v7: add v7 -> F2");
935  m_F3.add_vertex(v7); if(print_F3) AMREX_DEVICE_PRINTF("%s \n","Path 3: after v6--v7, cuts == 2 && add_v7: add v7 -> F3");
936  m_F6.add_vertex(v7); if(print_F6) AMREX_DEVICE_PRINTF("%s \n","Path 3: after v6--v7, cuts == 2 && add_v7: add v7 -> F6");
937  add_v7 = 0;
938  }
939  }
940 
941  } // end Path 3
942 
943  // Path 6
944  if (p6.intersected) {
945  if (p6.intersected_start) {
946  m_F3.add_vertex(v3); if(print_F3) AMREX_DEVICE_PRINTF("%s \n","Path 6: v3--v4: add v3 -> F3");
947  m_F4.add_vertex(v3); if(print_F4) AMREX_DEVICE_PRINTF("%s \n","Path 6: v3--v4: add v3 -> F4");
948  m_F5.add_vertex(v3); if(print_F5) AMREX_DEVICE_PRINTF("%s \n","Path 6: v3--v4: add v3 -> F5");
949  m_F7.add_vertex(v3); if(print_F7) AMREX_DEVICE_PRINTF("%s \n","Path 6: v3--v4: add v3 -> F7");
950  } else if (p6.intersected_end) {
951  m_F2.add_vertex(v4); if(print_F2) AMREX_DEVICE_PRINTF("%s \n","Path 6: v3--v4: add v4 -> F2");
952  m_F3.add_vertex(v4); if(print_F3) AMREX_DEVICE_PRINTF("%s \n","Path 6: v3--v4: add v4 -> F3\n");
953  m_F5.add_vertex(v4); if(print_F5) AMREX_DEVICE_PRINTF("%s \n","Path 6: v3--v4: add v4 -> F5");
954  m_F7.add_vertex(v4); if(print_F7) AMREX_DEVICE_PRINTF("%s \n","Path 6: v3--v4: add v4 -> F7");
955  } else {
956  m_F3.add_vertex(p6.vIP); if(print_F3) AMREX_DEVICE_PRINTF("%s \n","Path 6: v3--v4: add vIP -> F3");
957  m_F5.add_vertex(p6.vIP); if(print_F5) AMREX_DEVICE_PRINTF("%s \n","Path 6: v3--v4: add vIP -> F5");
958  m_F7.add_vertex(p6.vIP); if(print_F7) AMREX_DEVICE_PRINTF("%s \n","Path 6: v3--v4: add vIP -> F7");
959  }
960  } // end Path 6
961 
962  if (print_F1 || print_F2 || print_F3 || print_F4 || print_F5 || print_F6 || print_F7) {
963  AMREX_DEVICE_PRINTF("%s \n"," ");
964  }
965 
966 }
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.
Definition: ERF_EBCutCell.H:31
AMREX_GPU_HOST_DEVICE void add_vertex(amrex::RealVect const &a_v)
Add a unique vertex to the polygon.
Definition: ERF_EBPolygon.H:64
Here is the call graph for this function:

◆ centBoun()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::RealVect eb_cut_cell_::centBoun ( ) const
inlinenoexcept

Return the EB boundary centroid.

227  {
228  amrex::RealVect cent{zero,zero,zero};
229  if (m_flag.isSingleValued()) {
230  cent = m_F7.get_centroid();
231  }
232  return cent;
233  }
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::RealVect get_centroid() const noexcept
Return the polygon centroid from its sub-triangulation.
Definition: ERF_EBPolygon.H:206

Referenced by eb_aux_::define().

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

◆ centHi()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::RealVect eb_cut_cell_::centHi ( int const  idir) const
inlinenoexcept

Return the high-side face centroid in one coordinate direction.

Parameters
idirCoordinate direction.
206  {
207  AMREX_ASSERT( idir >=0 && idir < AMREX_SPACEDIM );
208  amrex::RealVect cent = m_cellface_cent[ m_hi_faces_id[idir] ];
209  if (m_flag.isCovered() || m_flag.isRegular() ) {
210  // Default cent
211  } else {
212  amrex::Real const area_R = m_hi_faces[idir]->area();
213  if (amrex::almostEqual(area_R,zero) || amrex::almostEqual(area_R, m_rbox_area[idir]) ){
214  // Default cent
215  } else {
216  amrex::RealVect cent_O = cent;
217  amrex::RealVect cent_R = m_hi_faces[idir]->get_centroid();
218  amrex::Real const area_C = m_rbox_area[idir] - area_R;
219  cent = m_invert * cent_R + (one-m_invert) * ((one+area_R/area_C)*cent_O - area_R/area_C*cent_R);
220  }
221  }
222  return cent;
223  }
amrex::Array< int const, 3 > m_hi_faces_id
Definition: ERF_EBCutCell.H:315

Referenced by eb_aux_::define().

Here is the caller graph for this function:

◆ centLo()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::RealVect eb_cut_cell_::centLo ( int const  idir) const
inlinenoexcept

Return the low-side face centroid in one coordinate direction.

Parameters
idirCoordinate direction.
182  {
183  AMREX_ASSERT( idir >=0 && idir < AMREX_SPACEDIM );
184  amrex::RealVect cent = m_cellface_cent[ m_lo_faces_id[idir] ];
185  if (m_flag.isCovered() || m_flag.isRegular() ) {
186  // Default cent
187  } else {
188  amrex::Real const area_R = m_lo_faces[idir]->area();
189  if (amrex::almostEqual(area_R,zero) || amrex::almostEqual(area_R, m_rbox_area[idir]) ){
190  // Default cent
191  } else {
192  amrex::RealVect cent_O = cent;
193  amrex::RealVect cent_R = m_lo_faces[idir]->get_centroid();
194  amrex::Real const area_C = m_rbox_area[idir] - area_R;
195  cent = m_invert * cent_R + (one-m_invert) * ((one+area_R/area_C)*cent_O - area_R/area_C*cent_R);
196  }
197  }
198  return cent;
199  }
amrex::Array< int const, 3 > m_lo_faces_id
Definition: ERF_EBCutCell.H:314

Referenced by eb_aux_::define().

Here is the caller graph for this function:

◆ centVol()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::RealVect eb_cut_cell_::centVol ( ) const
inlinenoexcept

Return the volume centroid of the reconstructed cell.

247  {
248  amrex::RealVect vcent = m_cell_cent;
249  if (m_flag.isSingleValued()) {
250  amrex::Real xm = m_rbox.lo(0);
251  amrex::Real xp = m_rbox.hi(0);
252  amrex::Real ym = m_rbox.lo(1);
253  amrex::Real yp = m_rbox.hi(1);
254  amrex::Real zm = m_rbox.lo(2);
255  amrex::Real zp = m_rbox.hi(2);
256 
257  amrex::Real axm = areaLo(0);
258  amrex::Real axp = areaHi(0);
259  amrex::Real aym = areaLo(1);
260  amrex::Real ayp = areaHi(1);
261  amrex::Real azm = areaLo(2);
262  amrex::Real azp = areaHi(2);
263 
264  amrex::Real barea = m_F7.area();
265  amrex::RealVect bcent = m_F7.get_centroid();
266 
267  amrex::Real vol = volume();
268 
269  vcent[0] = myhalf * ( - xm * xm * axm + xp * xp * axp + bcent[0] * bcent[0] * m_eb_normal[0] * barea ) / vol;
270  vcent[1] = myhalf * ( - ym * ym * aym + yp * yp * ayp + bcent[1] * bcent[1] * m_eb_normal[1] * barea ) / vol;
271  vcent[2] = myhalf * ( - zm * zm * azm + zp * zp * azp + bcent[2] * bcent[2] * m_eb_normal[2] * barea ) / vol;
272  }
273  return vcent;
274  }
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real volume() const
Return the physical volume of the reconstructed cell.
Definition: ERF_EBCutCell.H:125
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real areaLo(int const idir) const noexcept
Return the low-side face area in one coordinate direction.
Definition: ERF_EBCutCell.H:150
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real areaHi(int const idir) const noexcept
Return the high-side face area in one coordinate direction.
Definition: ERF_EBCutCell.H:163

Referenced by eb_aux_::define().

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

◆ debug()

void eb_cut_cell_::debug ( int const  a_face = -1)

Print cut-cell diagnostics on CPU builds.

Parameters
a_faceFace identifier to report, or -1 for all faces.
13  {
14 
15  amrex::Print() << "\n\nDEBUG THIS "
16  << "--------------------------------------"
17  << "\nisCovered? " << isCovered()
18  << "\nisRegular? " << isRegular()
19  << "\nisSingleValued? " << isSingleValued()
20  << "\n";
21 
22  if ( isCovered() || isRegular() ) { return; }
23 
24  amrex::RealVect v0(m_rbox.lo(0), m_rbox.lo(1), m_rbox.lo(2));
25  amrex::RealVect v7(m_rbox.hi(0), m_rbox.hi(1), m_rbox.hi(2));
26 
27  amrex::Print() << "\n"
28  << "lo: " << v0 << '\n'
29  << "hi: " << v7 << '\n'
30  << "p: " << m_eb_point << '\n'
31  << "n: " << m_eb_normal << '\n'
32  << "invert? " << m_invert << "\n\n";
33 
34  amrex::Print() << "Edge intersections:\n";
36  amrex::Print() << '\n';
37 
38  if ( a_face == -1 || a_face == 1 ) { m_F1.report(1, v0); }
39  if ( a_face == -1 || a_face == 2 ) { m_F2.report(2, v0); }
40  if ( a_face == -1 || a_face == 3 ) { m_F3.report(3, v0); }
41  if ( a_face == -1 || a_face == 4 ) { m_F4.report(4, v0); }
42  if ( a_face == -1 || a_face == 5 ) { m_F5.report(5, v0); }
43  if ( a_face == -1 || a_face == 6 ) { m_F6.report(6, v0); }
44  if ( a_face == -1 || a_face == 7 ) { m_F7.report(7, v0); }
45 }
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE bool isRegular() const noexcept
Return true if the reconstructed cell is regular.
Definition: ERF_EBCutCell.H:92
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE bool isSingleValued() const noexcept
Return true if the reconstructed cell is single-valued.
Definition: ERF_EBCutCell.H:96
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE bool isCovered() const noexcept
Return true if the reconstructed cell is covered.
Definition: ERF_EBCutCell.H:88
void report(int const a_id, amrex::RealVect a_v0)
Print a diagnostic report for the polygon on CPU builds.
Definition: ERF_EBPolygon.H:239

Referenced by eb_aux_::define().

Here is the caller graph for this function:

◆ isCovered()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE bool eb_cut_cell_::isCovered ( ) const
inlinenoexcept

Return true if the reconstructed cell is covered.

88 { return m_flag.isCovered(); }

Referenced by eb_aux_::define().

Here is the caller graph for this function:

◆ isRegular()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE bool eb_cut_cell_::isRegular ( ) const
inlinenoexcept

Return true if the reconstructed cell is regular.

92 { return m_flag.isRegular(); }

Referenced by eb_aux_::define().

Here is the caller graph for this function:

◆ isSingleValued()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE bool eb_cut_cell_::isSingleValued ( ) const
inlinenoexcept

Return true if the reconstructed cell is single-valued.

96 { return m_flag.isSingleValued(); }

◆ normBoun()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::RealVect eb_cut_cell_::normBoun ( ) const
inlinenoexcept

Return the EB boundary normal.

237  {
238  amrex::RealVect normal{zero,zero,zero};
239  if (m_flag.isSingleValued()) {
240  normal = m_eb_normal;
241  }
242  return normal;
243  }

◆ set_covered()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void eb_cut_cell_::set_covered ( )
inline

Mark the reconstructed cell as covered.

100  {
101  m_flag.setCovered();
102  }

◆ set_covered_regular_cell_vertices()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void eb_cut_cell_::set_covered_regular_cell_vertices ( )
private

Populate polygon vertices for cells that are fully covered or regular.

973 {
974  using namespace amrex;
975 
976  RealVect v0(m_rbox.lo(0), m_rbox.lo(1), m_rbox.lo(2));
977  RealVect v1(m_rbox.hi(0), m_rbox.lo(1), m_rbox.lo(2));
978  RealVect v2(m_rbox.lo(0), m_rbox.hi(1), m_rbox.lo(2));
979  RealVect v3(m_rbox.lo(0), m_rbox.lo(1), m_rbox.hi(2));
980  RealVect v4(m_rbox.hi(0), m_rbox.lo(1), m_rbox.hi(2));
981  RealVect v5(m_rbox.hi(0), m_rbox.hi(1), m_rbox.lo(2));
982  RealVect v6(m_rbox.lo(0), m_rbox.hi(1), m_rbox.hi(2));
983  RealVect v7(m_rbox.hi(0), m_rbox.hi(1), m_rbox.hi(2));
984 
985  // Add vertices in the order of outward normal vector
986 
987  m_F1.add_vertex(v0);
988  m_F1.add_vertex(v2);
989  m_F1.add_vertex(v5);
990  m_F1.add_vertex(v1);
991 
992  m_F2.add_vertex(v1);
993  m_F2.add_vertex(v5);
994  m_F2.add_vertex(v7);
995  m_F2.add_vertex(v4);
996 
997  m_F3.add_vertex(v3);
998  m_F3.add_vertex(v4);
999  m_F3.add_vertex(v7);
1000  m_F3.add_vertex(v6);
1001 
1002  m_F4.add_vertex(v0);
1003  m_F4.add_vertex(v3);
1004  m_F4.add_vertex(v6);
1005  m_F4.add_vertex(v2);
1006 
1007  m_F5.add_vertex(v0);
1008  m_F5.add_vertex(v1);
1009  m_F5.add_vertex(v4);
1010  m_F5.add_vertex(v3);
1011 
1012  m_F6.add_vertex(v2);
1013  m_F6.add_vertex(v5);
1014  m_F6.add_vertex(v7);
1015  m_F6.add_vertex(v6);
1016 
1017 }
Here is the call graph for this function:

◆ set_regular()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void eb_cut_cell_::set_regular ( )
inline

Mark the reconstructed cell as regular and fill regular face areas.

106  {
107 
108  m_flag.setRegular();
109 
110  m_F1.set_area( m_rbox.length(0)*m_rbox.length(1) );
111  m_F3.set_area( m_rbox.length(0)*m_rbox.length(1) );
112 
113  m_F2.set_area( m_rbox.length(1)*m_rbox.length(2) );
114  m_F4.set_area( m_rbox.length(1)*m_rbox.length(2) );
115 
116  m_F5.set_area( m_rbox.length(0)*m_rbox.length(2) );
117  m_F6.set_area( m_rbox.length(0)*m_rbox.length(2) );
118 
120 
121  }
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void set_area(amrex::Real const &a_area)
Set the polygon area directly.
Definition: ERF_EBPolygon.H:88
Here is the call graph for this function:

◆ volume()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real eb_cut_cell_::volume ( ) const
inline

Return the physical volume of the reconstructed cell.

125  {
126 
127  if (m_flag.isCovered() ) { return zero; }
128  if (m_flag.isRegular() ) { return m_rbox.volume(); }
129 
131 
132  amrex::Real const* lo = m_rbox.lo();
133  amrex::RealVect v0(lo[0], lo[1], lo[2]);
134 
135  if (m_F2.ok() ) { volume += m_F2.area() * m_F2.distance(v0); }
136  if (m_F3.ok() ) { volume += m_F3.area() * m_F3.distance(v0); }
137  if (m_F6.ok() ) { volume += m_F6.area() * m_F6.distance(v0); }
138  if (m_F7.ok() ) { volume += m_F7.area() * m_F7.distance(v0); }
139 
140  volume /= three;
141 
142  return m_invert*volume + (one-m_invert)*(m_rbox.volume()-volume);
143  }
constexpr amrex::Real three
Definition: ERF_NumericalConstants.H:32
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE int ok() const noexcept
Return whether the polygon has been defined with a valid area state.
Definition: ERF_EBPolygon.H:183
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real distance(amrex::RealVect const &a_point) const noexcept
Return the perpendicular distance from this polygon to a point.
Definition: ERF_EBPolygon.H:198

Referenced by centVol(), and eb_aux_::define().

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

Member Data Documentation

◆ m_cell_cent

amrex::RealVect eb_cut_cell_::m_cell_cent
private

Referenced by centVol().

◆ m_cellface_cent

amrex::Array<amrex::RealVect,m_max_faces> eb_cut_cell_::m_cellface_cent
private

Referenced by centHi(), and centLo().

◆ m_dx

amrex::RealVect eb_cut_cell_::m_dx
private

◆ m_eb_normal

amrex::RealVect const eb_cut_cell_::m_eb_normal
private

◆ m_eb_point

amrex::RealVect const eb_cut_cell_::m_eb_point
private

Referenced by calc_edge_intersections().

◆ m_F1

◆ m_F2

◆ m_F3

◆ m_F4

◆ m_F5

◆ m_F6

◆ m_F7

polygon_ eb_cut_cell_::m_F7
private

◆ m_flag

amrex::EBCellFlag eb_cut_cell_::m_flag
private

◆ m_hi_faces

amrex::Array<polygon_ const* const,3> eb_cut_cell_::m_hi_faces {&m_F2, &m_F6, &m_F3}
private

Referenced by areaHi(), and centHi().

◆ m_hi_faces_id

amrex::Array<int const,3> eb_cut_cell_::m_hi_faces_id {1,5,2}
private

Referenced by centHi().

◆ m_invert

amrex::Real eb_cut_cell_::m_invert
private

Referenced by areaHi(), areaLo(), centHi(), centLo(), and volume().

◆ m_lo_faces

amrex::Array<polygon_ const* const,3> eb_cut_cell_::m_lo_faces {&m_F4, &m_F5, &m_F1}
private

Referenced by areaLo(), and centLo().

◆ m_lo_faces_id

amrex::Array<int const,3> eb_cut_cell_::m_lo_faces_id {3,4,0}
private

Referenced by centLo().

◆ m_max_faces

constexpr int eb_cut_cell_::m_max_faces = 6
staticconstexprprivate

◆ m_rbox

amrex::RealBox const eb_cut_cell_::m_rbox
private

◆ m_rbox_area

amrex::RealVect eb_cut_cell_::m_rbox_area
private

Referenced by areaHi(), areaLo(), centHi(), and centLo().


The documentation for this class was generated from the following files: