OPAL (Object Oriented Parallel Accelerator Library) 2024.2
OPAL
BoundaryGeometry.cpp File Reference
#include "Structure/BoundaryGeometry.h"
#include <algorithm>
#include <cmath>
#include <ctime>
#include <filesystem>
#include <fstream>
#include <string>
#include "H5hut.h"
#include <cfloat>
#include "AbstractObjects/OpalData.h"
#include "Algorithms/PartBunchBase.h"
#include "Expressions/SRefExpr.h"
#include "Elements/OpalBeamline.h"
#include "Physics/Physics.h"
#include "Utilities/OpalException.h"
#include "Utilities/Options.h"
#include <gsl/gsl_sys.h>
#include <boost/filesystem.hpp>
Include dependency graph for BoundaryGeometry.cpp:

Go to the source code of this file.

Classes

class  Triangle
 
class  Ray
 
class  Voxel
 

Namespaces

namespace  cmp_diff
 
namespace  cmp_ulp_obsolete
 
namespace  cmp_ulp
 

Macros

#define SQR(x)   ((x)*(x))
 
#define PointID(triangle_id, vertex_id)   Triangles_m[triangle_id][vertex_id]
 
#define Point(triangle_id, vertex_id)   Points_m[Triangles_m[triangle_id][vertex_id]]
 
#define FUNC_EQ(x, y)
 
#define FUNC_EQ_ZERO(x)
 
#define FUNC_LE(x, y)
 
#define FUNC_LE_ZERO(x)
 
#define FUNC_LT(x, y)
 
#define FUNC_LT_ZERO(x)
 
#define FUNC_GE(x, y)
 
#define FUNC_GE_ZERO(x)
 
#define FUNC_GT(x, y)
 
#define FUNC_GT_ZERO(x)
 
#define INSIDE   0
 
#define OUTSIDE   1
 
#define LERP(a, b, t)   (a + t * (b - a))
 
#define mapPoint2VoxelIndices(pt, i, j, k)
 

Functions

bool cmp_diff::almost_eq (double A, double B, double maxDiff=1e-15, double maxRelDiff=DBL_EPSILON)
 
bool cmp_diff::almost_eq_zero (double A, double maxDiff=1e-15)
 
bool cmp_diff::eq (double x, double y)
 
bool cmp_diff::eq_zero (double x)
 
bool cmp_diff::le (double x, double y)
 
bool cmp_diff::le_zero (double x)
 
bool cmp_diff::lt (double x, double y)
 
bool cmp_diff::lt_zero (double x)
 
bool cmp_diff::ge (double x, double y)
 
bool cmp_diff::ge_zero (double x)
 
bool cmp_diff::gt (double x, double y)
 
bool cmp_diff::gt_zero (double x)
 
bool cmp_ulp_obsolete::almost_eq (double A, double B, double maxDiff=1e-20, int maxUlps=1000)
 
bool cmp_ulp_obsolete::almost_eq_zero (double A, double maxDiff=1e-15)
 
bool cmp_ulp_obsolete::eq (double x, double y)
 
bool cmp_ulp_obsolete::eq_zero (double x)
 
bool cmp_ulp_obsolete::le (double x, double y)
 
bool cmp_ulp_obsolete::le_zero (double x)
 
bool cmp_ulp_obsolete::lt (double x, double y)
 
bool cmp_ulp_obsolete::lt_zero (double x)
 
bool cmp_ulp_obsolete::ge (double x, double y)
 
bool cmp_ulp_obsolete::ge_zero (double x)
 
bool cmp_ulp_obsolete::gt (double x, double y)
 
bool cmp_ulp_obsolete::gt_zero (double x)
 
bool cmp_ulp::almost_eq (double A, double B, double maxDiff=1e-20, int maxUlps=1000)
 
bool cmp_ulp::almost_eq_zero (double A, double maxDiff=1e-15)
 
bool cmp_ulp::eq (double x, double y)
 
bool cmp_ulp::eq_zero (double x)
 
bool cmp_ulp::le (double x, double y)
 
bool cmp_ulp::le_zero (double x)
 
bool cmp_ulp::lt (double x, double y)
 
bool cmp_ulp::lt_zero (double x)
 
bool cmp_ulp::ge (double x, double y)
 
bool cmp_ulp::ge_zero (double x)
 
bool cmp_ulp::gt (double x, double y)
 
bool cmp_ulp::gt_zero (double x)
 
static int face_plane (const Vector_t &p)
 
static int bevel_2d (const Vector_t &p)
 
static int bevel_3d (const Vector_t &p)
 
static int check_point (const Vector_t &p1, const Vector_t &p2, const double alpha, const int mask)
 
static int check_line (const Vector_t &p1, const Vector_t &p2, const int outcode_diff)
 
static int SIGN3 (Vector_t A)
 
static int point_triangle_intersection (const Vector_t &p, const Triangle &t)
 
static int triangle_intersects_cube (const Triangle &t)
 
static Vector_t normalVector (const Vector_t &A, const Vector_t &B, const Vector_t &C)
 
static double computeArea (const Vector_t &A, const Vector_t &B, const Vector_t &C)
 
static double magnitude (const Vector_t &v)
 

Variables

Informgmsg
 
constexpr double EPS = 10e-15
 

Macro Definition Documentation

◆ FUNC_EQ

#define FUNC_EQ (   x,
 
)
Value:
inline bool eq(double x, double y) { \
return almost_eq(x, y); \
}
bool almost_eq(double A, double B, double maxDiff=1e-20, int maxUlps=1000)
bool eq(double x, double y)

Definition at line 63 of file BoundaryGeometry.cpp.

◆ FUNC_EQ_ZERO

#define FUNC_EQ_ZERO (   x)
Value:
inline bool eq_zero(double x) { \
return almost_eq_zero(x); \
}
bool eq_zero(double x)
bool almost_eq_zero(double A, double maxDiff=1e-15)

Definition at line 67 of file BoundaryGeometry.cpp.

◆ FUNC_GE

#define FUNC_GE (   x,
 
)
Value:
inline bool ge(double x, double y) { \
if (almost_eq(x, y)) { \
return true; \
} \
return x > y; \
}
bool ge(double x, double y)

Definition at line 99 of file BoundaryGeometry.cpp.

◆ FUNC_GE_ZERO

#define FUNC_GE_ZERO (   x)
Value:
inline bool ge_zero(double x) { \
if (almost_eq_zero(x)) { \
return true; \
} \
return x > 0.0; \
}
bool ge_zero(double x)

Definition at line 106 of file BoundaryGeometry.cpp.

◆ FUNC_GT

#define FUNC_GT (   x,
 
)
Value:
inline bool gt(double x, double y) { \
if (almost_eq(x, y)) { \
return false; \
} \
return x > y; \
}
bool gt(double x, double y)

Definition at line 113 of file BoundaryGeometry.cpp.

◆ FUNC_GT_ZERO

#define FUNC_GT_ZERO (   x)
Value:
inline bool gt_zero(double x) { \
if (almost_eq_zero(x)) { \
return false; \
} \
return x > 0.0; \
}
bool gt_zero(double x)

Definition at line 120 of file BoundaryGeometry.cpp.

◆ FUNC_LE

#define FUNC_LE (   x,
 
)
Value:
inline bool le(double x, double y) { \
if (almost_eq(x, y)) { \
return true; \
} \
return x < y; \
}
bool le(double x, double y)

Definition at line 71 of file BoundaryGeometry.cpp.

◆ FUNC_LE_ZERO

#define FUNC_LE_ZERO (   x)
Value:
inline bool le_zero(double x) { \
if (almost_eq_zero(x)) { \
return true; \
} \
return x < 0.0; \
}
bool le_zero(double x)

Definition at line 78 of file BoundaryGeometry.cpp.

◆ FUNC_LT

#define FUNC_LT (   x,
 
)
Value:
inline bool lt(double x, double y) { \
if (almost_eq(x, y)) { \
return false; \
} \
return x < y; \
}
bool lt(double x, double y)

Definition at line 85 of file BoundaryGeometry.cpp.

◆ FUNC_LT_ZERO

#define FUNC_LT_ZERO (   x)
Value:
inline bool lt_zero(double x) { \
if (almost_eq_zero(x)) { \
return false; \
} \
return x < 0.0; \
}
bool lt_zero(double x)

Definition at line 92 of file BoundaryGeometry.cpp.

◆ INSIDE

#define INSIDE   0

Definition at line 415 of file BoundaryGeometry.cpp.

◆ LERP

#define LERP (   a,
  b,
 
)    (a + t * (b - a))

◆ mapPoint2VoxelIndices

#define mapPoint2VoxelIndices (   pt,
  i,
  j,
 
)
Value:
{ \
i = floor ((pt[0] - voxelMesh_m.minExtent [0]) / voxelMesh_m.sizeOfVoxel[0]); \
j = floor ((pt[1] - voxelMesh_m.minExtent [1]) / voxelMesh_m.sizeOfVoxel[1]); \
k = floor ((pt[2] - voxelMesh_m.minExtent [2]) / voxelMesh_m.sizeOfVoxel[2]); \
if (!(0 <= i && i < voxelMesh_m.nr_m[0] && \
0 <= j && j < voxelMesh_m.nr_m[1] && \
0 <= k && k < voxelMesh_m.nr_m[2])) { \
*gmsg << level2 \
<< "* " << __func__ << ":" \
<< " WARNING: pt=" << pt \
<< " is outside the bbox" \
<< " i=" << i \
<< " j=" << j \
<< " k=" << k \
<< endl; \
} \
}
Inform * gmsg
Definition: Main.cpp:70
PETE_TUTree< FnFloor, typename T::PETE_Expr_t > floor(const PETE_Expr< T > &l)
Definition: PETE.h:733
Inform & level2(Inform &inf)
Definition: Inform.cpp:46
Inform & endl(Inform &inf)
Definition: Inform.cpp:42

Definition at line 1543 of file BoundaryGeometry.cpp.

◆ OUTSIDE

#define OUTSIDE   1

Definition at line 416 of file BoundaryGeometry.cpp.

◆ Point

#define Point (   triangle_id,
  vertex_id 
)    Points_m[Triangles_m[triangle_id][vertex_id]]

Definition at line 49 of file BoundaryGeometry.cpp.

◆ PointID

#define PointID (   triangle_id,
  vertex_id 
)    Triangles_m[triangle_id][vertex_id]

Definition at line 48 of file BoundaryGeometry.cpp.

◆ SQR

#define SQR (   x)    ((x)*(x))

Definition at line 47 of file BoundaryGeometry.cpp.

Function Documentation

◆ bevel_2d()

static int bevel_2d ( const Vector_t p)
inlinestatic

Definition at line 494 of file BoundaryGeometry.cpp.

References cmp_ulp::gt().

Referenced by triangle_intersects_cube().

Here is the call graph for this function:

◆ bevel_3d()

static int bevel_3d ( const Vector_t p)
inlinestatic

Definition at line 520 of file BoundaryGeometry.cpp.

References cmp_ulp::gt().

Referenced by triangle_intersects_cube().

Here is the call graph for this function:

◆ check_line()

static int check_line ( const Vector_t p1,
const Vector_t p2,
const int  outcode_diff 
)
inlinestatic

Definition at line 570 of file BoundaryGeometry.cpp.

References check_point(), INSIDE, and OUTSIDE.

Referenced by triangle_intersects_cube().

Here is the call graph for this function:

◆ check_point()

static int check_point ( const Vector_t p1,
const Vector_t p2,
const double  alpha,
const int  mask 
)
inlinestatic

Definition at line 545 of file BoundaryGeometry.cpp.

References Physics::alpha, face_plane(), and LERP.

Referenced by check_line().

Here is the call graph for this function:

◆ computeArea()

static double computeArea ( const Vector_t A,
const Vector_t B,
const Vector_t C 
)
inlinestatic

Definition at line 928 of file BoundaryGeometry.cpp.

References dot(), and sqrt().

Referenced by BoundaryGeometry::initialize().

Here is the call graph for this function:

◆ face_plane()

static int face_plane ( const Vector_t p)
inlinestatic

Definition at line 474 of file BoundaryGeometry.cpp.

References cmp_ulp::gt(), and cmp_ulp::lt().

Referenced by check_point(), and triangle_intersects_cube().

Here is the call graph for this function:

◆ magnitude()

static double magnitude ( const Vector_t v)
inlinestatic

◆ normalVector()

static Vector_t normalVector ( const Vector_t A,
const Vector_t B,
const Vector_t C 
)
inlinestatic

Definition at line 916 of file BoundaryGeometry.cpp.

References cross(), cmp_ulp::gt_zero(), magnitude(), PAssert, SQR, and sqrt().

Referenced by BoundaryGeometry::initialize().

Here is the call graph for this function:

◆ point_triangle_intersection()

static int point_triangle_intersection ( const Vector_t p,
const Triangle t 
)
static

Definition at line 605 of file BoundaryGeometry.cpp.

References cross(), cmp_ulp::gt(), INSIDE, cmp_ulp::lt(), max(), min(), OUTSIDE, SIGN3(), Triangle::v1(), Triangle::v2(), and Triangle::v3().

Referenced by triangle_intersects_cube().

Here is the call graph for this function:

◆ SIGN3()

static int SIGN3 ( Vector_t  A)
inlinestatic

Definition at line 596 of file BoundaryGeometry.cpp.

References EPS.

Referenced by point_triangle_intersection().

◆ triangle_intersects_cube()

static int triangle_intersects_cube ( const Triangle t)
static

Variable Documentation

◆ EPS

constexpr double EPS = 10e-15
constexpr

Definition at line 594 of file BoundaryGeometry.cpp.

Referenced by SIGN3().

◆ gmsg