https://mooseframework.inl.gov
Loading...
Searching...
No Matches
IntersectionPointsAlongLine.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// MOOSE includes
13#include "LineSegment.h"
14#include "RayTracing.h"
15#include "MooseMesh.h"
16
18
21{
24 "Get the intersection points for all of the elements that are intersected by a line.");
25 params.addRequiredParam<Point>("start", "The beginning of the line");
26 params.addRequiredParam<Point>("end", "The end of the line");
27 return params;
28}
29
31 : GeneralVectorPostprocessor(parameters),
32 _start(getParam<Point>("start")),
33 _end(getParam<Point>("end")),
34 _x_intersections(declareVector("x"))
35#if LIBMESH_DIM > 1
36 ,
37 _y_intersections(declareVector("y"))
38#if LIBMESH_DIM > 2
39 ,
40 _z_intersections(declareVector("z"))
41#endif
42#endif
43{
45#if LIBMESH_DIM > 1
47#if LIBMESH_DIM > 2
49#endif
50#endif
51
52 _fe_problem.mesh().errorIfDistributedMesh("IntersectionPointsAlongLine");
53}
54
55void
57{
58 for (unsigned int i = 0; i < _intersections.size(); i++)
60}
61
62void
64{
65 std::vector<Elem *> intersected_elems;
66 std::vector<LineSegment> segments;
67
68 std::unique_ptr<libMesh::PointLocatorBase> pl = _fe_problem.mesh().getPointLocator();
69
70 // We may not have any elements along the given line; if so then
71 // that shouldn't throw a libMesh error.
72 pl->enable_out_of_mesh_mode();
73
75 _start, _end, _fe_problem.mesh(), *pl, intersected_elems, segments);
76
77 const unsigned int num_elems = intersected_elems.size();
78
79 // Quick return in case no elements were found
80 if (num_elems == 0)
81 return;
82
83 for (const auto i : make_range(Moose::dim))
84 _intersections[i]->resize(num_elems + 1);
85
86 // Add the beginning point
87 for (const auto i : make_range(Moose::dim))
88 (*_intersections[i])[0] = _start(i);
89
90 // Add the ending point of every segment
91 for (unsigned int i = 0; i < num_elems; i++)
92 {
93 LineSegment & segment = segments[i];
94
95 const Point & end_point = segment.end();
96
97 for (const auto j : make_range(Moose::dim))
98 (*_intersections[j])[i + 1] = end_point(j);
99 }
100}
registerMooseObject("MooseApp", IntersectionPointsAlongLine)
sideset clear()
if(!dmm->_nl) SETERRQ(PETSC_COMM_WORLD
virtual MooseMesh & mesh() override
This class is here to combine the VectorPostprocessor interface and the base class VectorPostprocesso...
static InputParameters validParams()
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
void addRequiredParam(const std::string &name, const std::string &doc_string)
This method adds a parameter and documentation string to the InputParameters object that will be extr...
void addClassDescription(const std::string &doc_string)
This method adds a description of the class that will be displayed in the input file syntax dump.
Get the intersection points for all of the elements that are intersected by a line.
virtual void initialize() override
Called before execute() is ever called so that data can be cleared.
Point _start
The beginning of the line.
VectorPostprocessorValue & _z_intersections
IntersectionPointsAlongLine(const InputParameters &parameters)
std::vector< VectorPostprocessorValue * > _intersections
Tie them together for convenience.
VectorPostprocessorValue & _x_intersections
The elements that intersect the line.
virtual void execute() override
Find the elements.
VectorPostprocessorValue & _y_intersections
The LineSegment class is used by the LineMaterialSamplerBase class and for some ray tracing stuff.
Definition LineSegment.h:31
const Point & end() const
Ending of the line segment.
Definition LineSegment.h:90
virtual std::unique_ptr< libMesh::PointLocatorBase > getPointLocator() const
Proxy function to get a (sub)PointLocator from either the underlying libMesh mesh (default),...
Definition MooseMesh.C:3838
void errorIfDistributedMesh(std::string name) const
Generate a unified error message if the underlying libMesh mesh is a DistributedMesh.
Definition MooseMesh.C:3718
FEProblemBase & _fe_problem
Reference to the FEProblemBase for this user object.
void elementsIntersectedByLine(const Point &p0, const Point &p1, const MeshBase &mesh, const libMesh::PointLocatorBase &point_locator, std::vector< Elem * > &intersected_elems, std::vector< LineSegment > &segments)
Find all of the elements intersected by a line.
static constexpr std::size_t dim
This is the dimension of all vector and tensor datastructures used in MOOSE.
Definition Moose.h:165