www.mooseframework.org
ElementsAlongLine.C
Go to the documentation of this file.
1 /****************************************************************/
2 /* DO NOT MODIFY THIS HEADER */
3 /* MOOSE - Multiphysics Object Oriented Simulation Environment */
4 /* */
5 /* (c) 2010 Battelle Energy Alliance, LLC */
6 /* ALL RIGHTS RESERVED */
7 /* */
8 /* Prepared by Battelle Energy Alliance, LLC */
9 /* Under Contract No. DE-AC07-05ID14517 */
10 /* With the U. S. Department of Energy */
11 /* */
12 /* See COPYRIGHT for full restrictions */
13 /****************************************************************/
14 
15 #include "ElementsAlongLine.h"
16 
17 // MOOSE includes
18 #include "LineSegment.h"
19 #include "RayTracing.h"
20 #include "MooseMesh.h"
21 
22 template <>
25 {
27 
28  params.addRequiredParam<Point>("start", "The beginning of the line");
29  params.addRequiredParam<Point>("end", "The end of the line");
30  return params;
31 }
32 
34  : GeneralVectorPostprocessor(parameters),
35  _start(getParam<Point>("start")),
36  _end(getParam<Point>("end")),
37  _elem_ids(declareVector("elem_ids"))
38 {
39  _fe_problem.mesh().errorIfDistributedMesh("ElementsAlongLine");
40 }
41 
42 void
44 {
45  _elem_ids.clear();
46 }
47 
48 void
50 {
51  std::vector<Elem *> intersected_elems;
52  std::vector<LineSegment> segments;
53 
54  std::unique_ptr<PointLocatorBase> pl = _fe_problem.mesh().getPointLocator();
56  _start, _end, _fe_problem.mesh(), *pl, intersected_elems, segments);
57 
58  unsigned int num_elems = intersected_elems.size();
59 
60  _elem_ids.resize(num_elems);
61 
62  for (unsigned int i = 0; i < num_elems; i++)
63  _elem_ids[i] = intersected_elems[i]->id();
64 }
ElementsAlongLine(const InputParameters &parameters)
Point _start
The beginning of the line.
This class is here to combine the VectorPostprocessor interface and the base class VectorPostprocesso...
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
Point _end
The end of the line.
void errorIfDistributedMesh(std::string name) const
Generate a unified error message if the underlying libMesh mesh is a DistributedMesh.
Definition: MooseMesh.C:2473
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...
InputParameters validParams< ElementsAlongLine >()
InputParameters validParams< GeneralVectorPostprocessor >()
virtual void initialize() override
Called before execute() is ever called so that data can be cleared.
virtual std::unique_ptr< PointLocatorBase > getPointLocator() const
Proxy function to get a (sub)PointLocator from either the underlying libMesh mesh (default)...
Definition: MooseMesh.C:2540
virtual void execute() override
Find the elements.
void elementsIntersectedByLine(const Point &p0, const Point &p1, const MeshBase &mesh, const PointLocatorBase &point_locator, std::vector< Elem * > &intersected_elems, std::vector< LineSegment > &segments)
Find all of the elements intersected by a line.
Definition: RayTracing.C:197
FEProblemBase & _fe_problem
Reference to the FEProblemBase for this user object.
Definition: UserObject.h:149
virtual MooseMesh & mesh() override
VectorPostprocessorValue & _elem_ids
The elements that intersect the line.