https://mooseframework.inl.gov
Loading...
Searching...
No Matches
PeriodicRayBC.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
10#include "PeriodicRayBC.h"
11
12#include "RayTracingStudy.h"
13#include "PeriodicBCHelper.h"
14
15#include "libmesh/periodic_boundaries.h"
16#include "libmesh/periodic_boundary.h"
17
19
20const std::string PeriodicRayBC::periodic_boundaries_param = "_periodic_boundaries";
21
24{
25 auto params = GeneralRayBC::validParams();
27
28 // To be filled with the PeriodicBoundaries object from the
29 // SetupPeriodicRayBCAction, and is also used to identify
30 // before construction that this object is a PeriodicRayBC
31 params.addPrivateParam<const libMesh::PeriodicBoundaries *>(periodic_boundaries_param, nullptr);
32
33 // This is now set via auto_direction or primary and secondary
34 params.suppressParameter<std::vector<BoundaryName>>("boundary");
35
36 params.addClassDescription("A RayBC that enforces periodic boundaries.");
37
38 return params;
39}
40
42 : GeneralRayBC(params),
43 _periodic_boundaries(
44 *getCheckedPointerParam<const libMesh::PeriodicBoundaries *>(periodic_boundaries_param)),
45 _point_locator(_mesh.getPointLocator()),
46 _periodic_applied(0),
47 _periodic_neighbor(nullptr)
48{
49}
50
51bool
56
57void
58PeriodicRayBC::onBoundary(const unsigned int num_applying)
59{
60 // No need to do anything if the Ray's gonna die anyway
61 if (!currentRay()->shouldContinue())
62 return;
63
64 // The current side we're on, which isn't the physical
65 // side we're currently at if we've applied multiple periodic
66 // boundaries
67 unsigned int current_side = _current_intersected_side;
68
69 // Reset shared state between calls; needed in the event that
70 // we are applying multiple periodic boundary conditions. Begin
71 // out with the actual intersection information (the neighbor
72 // is cleared once all boundaries are applied for a single Ray)
74 {
77 }
78 // We do have a periodic neighbor, which means we're applying
79 // more than one periodic boundary and need to find the side
80 // from the last topological neighbor
81 else
82 {
83 mooseAssert(num_applying > 1, "Should be applying multiple");
85 }
86
87 // The PeriodicBoundary object associated with the periodic boundary
88 const auto periodic_boundary = _periodic_boundaries.boundary(_current_bnd_id);
89 if (!periodic_boundary)
90 mooseError("Failed to find periodic boundary\n\n", currentRay()->getInfo());
91
92 // Move the point; this translation could happen multiple times if we are
93 // applying more than one periodic boundary, which is why the state
94 // is shared outside of onBoundary()
95 _periodic_point = periodic_boundary->get_corresponding_pos(_periodic_point);
96
97 // Find the topological neighbor
98 unsigned int periodic_side;
100 _current_bnd_id, *_point_locator, _periodic_neighbor, current_side, &periodic_side);
101 mooseAssert(_periodic_neighbor, "Should be set");
104 "Topological neighbor at ", _periodic_point, " is remote\n\n", currentRay()->getInfo());
105
106 // We've done all translations, so actually move the Ray
107 if (++_periodic_applied == num_applying)
108 {
109 currentRay()->changePointElemSide(_periodic_point, *_periodic_neighbor, periodic_side, {});
110 _periodic_neighbor = nullptr;
112 }
113}
registerMooseObject("RayTracingApp", PeriodicRayBC)
static InputParameters validParams()
bool have_parameter(std::string_view name) const
void mooseError(Args &&... args) const
unsigned int sideWithBoundaryID(const Elem *const elem, const BoundaryID boundary_id) const
static InputParameters validParams()
RayBC that enforces periodic boundaries.
static InputParameters validParams()
static bool isPeriodicRayBC(const InputParameters &params)
Whether or not the RayBC params belong to a PeriodicRayBC.
virtual void onBoundary(const unsigned int num_applying) override final
Called on a Ray on the boundary to apply the Ray boundary condition.
const std::unique_ptr< libMesh::PointLocatorBase > _point_locator
Point locator used for searching periodic boundary points.
static const std::string periodic_boundaries_param
Name of the parameter that stores the PeriodicBoundaries pointer.
Point _periodic_point
unsigned int _periodic_applied
State variables for applying periodic boundary conditions.
const libMesh::PeriodicBoundaries & _periodic_boundaries
The PeriodicBoundaries object.
PeriodicRayBC(const InputParameters &params)
const Elem * _periodic_neighbor
const Point & _current_intersection_point
The current intersection point on the boundary.
const BoundaryID & _current_bnd_id
The ID of the current intersected boundary.
MooseMesh & _mesh
The MooseMesh.
const unsigned short & _current_intersected_side
The side that _current_ray intersects (if any)
const std::shared_ptr< Ray > & currentRay() const
Gets the current Ray that this is working on.
const Elem *const & _current_elem
The current Elem that _current_ray is tracing through.
PeriodicBoundaryBase * boundary(boundary_id_type id)
const Elem * neighbor(boundary_id_type boundary_id, const PointLocatorBase &point_locator, const Elem *e, unsigned int side, unsigned int *neigh_side=nullptr) const
The following methods are specializations for using the Parallel::packed_range_* routines for a vecto...
const RemoteElem * remote_elem