https://mooseframework.inl.gov
Loading...
Searching...
No Matches
BackfaceCullingStudyTest.C
Go to the documentation of this file.
1//* This file is part of the MOOSE framework
2//* https://mooseframework.inl.gov
3//*
4//* All rights reserved, see COPYRIGHT for full restrictions
5//* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6//*
7//* Licensed under LGPL 2.1, please see LICENSE for details
8//* https://www.gnu.org/licenses/lgpl-2.1.html
9
11
12// Local includes
13#include "TraceRay.h"
14
16
19{
20 auto params = LotsOfRaysRayStudy::validParams();
21 return params;
22}
23
25 : LotsOfRaysRayStudy(parameters)
26{
27 // Use backface culling
28 for (const auto tid : make_range(libMesh::n_threads()))
30}
31
32void
38
39void
45
46void
48{
49 _normals.clear();
50
51 for (const Elem * elem : _mesh.getMesh().active_element_ptr_range())
52 {
53 std::vector<Point> normals(elem->n_sides());
54 for (const auto s : elem->side_index_range())
55 normals[s] = RayTracingStudy::getSideNormal(elem, s, 0);
56 _normals.emplace(elem, std::move(normals));
57 }
58}
59
60const Point *
62{
63 const auto find = _normals.find(elem);
64 if (find == _normals.end())
65 mooseError("Failed to find normal for elem ", elem->id());
66
67 const auto & normals = find->second;
68 mooseAssert(normals.size() == elem->n_sides(), "Normals not sized properly");
69 return normals.data();
70}
registerMooseObject("RayTracingTestApp", BackfaceCullingStudyTest)
unsigned int THREAD_ID
A test study that tests the use of backface culling in TraceRay.
static InputParameters validParams()
std::unordered_map< const Elem *, std::vector< Point > > _normals
BackfaceCullingStudyTest(const InputParameters &parameters)
const Point * getElemNormals(const Elem *elem, const THREAD_ID tid) override
Gets the outward normals for a given element.
A RayTracingStudy used for generating a lot of rays for testing purposes.
static InputParameters validParams()
virtual void meshChanged()
void mooseError(Args &&... args) const
MeshBase & getMesh()
MooseMesh & _mesh
The Mesh.
TraceRay & traceRay(const THREAD_ID tid)
Gets the threaded TraceRay object for tid.
virtual const Point & getSideNormal(const Elem *elem, const unsigned short side, const THREAD_ID tid)
Get the outward normal for a given element side.
virtual void initialSetup()
void setBackfaceCulling(const bool backface_culling)
Enable or disable the use of element normals for backface culling through the getElemNormals() method...
Definition TraceRay.h:105
unsigned int n_threads()