21 const unsigned int dim)
22 : _comm(), _mesh(
std::make_unique<Mesh>(_comm,
dim))
25 _mesh->add_point(Point(bbox.min()(0), bbox.min()(1), bbox.min()(2)), 0, 0);
26 _mesh->add_point(Point(bbox.max()(0), bbox.min()(1), bbox.min()(2)), 1, 0);
29 _mesh->add_point(Point(bbox.max()(0), bbox.max()(1), bbox.min()(2)), 2, 0);
30 _mesh->add_point(Point(bbox.min()(0), bbox.max()(1), bbox.min()(2)), 3, 0);
34 _mesh->add_point(Point(bbox.min()(0), bbox.min()(1), bbox.max()(2)), 4, 0);
35 _mesh->add_point(Point(bbox.max()(0), bbox.min()(1), bbox.max()(2)), 5, 0);
36 _mesh->add_point(Point(bbox.max()(0), bbox.max()(1), bbox.max()(2)), 6, 0);
37 _mesh->add_point(Point(bbox.min()(0), bbox.max()(1), bbox.max()(2)), 7, 0);
44 elem = Elem::build(EDGE2).release();
46 elem = Elem::build(QUAD4).release();
48 elem = Elem::build(HEX8).release();
49 elem =
_mesh->add_elem(elem);
50 elem->subdomain_id() = 0;
51 elem->processor_id(0);
53 for (
unsigned int n = 0; n <
_mesh->n_nodes(); ++n)
54 elem->set_node(n,
_mesh->node_ptr(n));
57 _mesh->skip_partitioning(
true);
58 _mesh->prepare_for_use();
67 mooseAssert(std::abs(1.0 - direction.norm()) < TOLERANCE,
"Unnormalized direction");
69 const Elem * elem =
_mesh->elem_ptr(0);
73 Real best_intersection_distance = -std::numeric_limits<Real>::max();
76 Point intersection_point;
78 Real intersection_distance;
82 for (
const auto s : elem->side_index_range())
88 intersected = TraceRayTools::sideIntersectedByLine<Hex8>(elem,
94 intersection_distance,
97#ifdef DEBUG_RAY_INTERSECTIONS
102 else if (elem->dim() == 2)
104 intersected = TraceRayTools::sideIntersectedByLine<Quad4>(elem,
110 intersection_distance,
113#ifdef DEBUG_RAY_INTERSECTIONS
122 const Point dummy_end = point + 1.01 * direction *
_hmax;
127 intersection_distance = (elem->point(s) - point).norm();
128 intersection_point = elem->point(s);
132 if (intersected && intersection_distance > best_intersection_distance)
134 best_intersection_distance = intersection_distance;
135 best_intersection_point = intersection_point;
139 return best_intersection_point;