https://mooseframework.inl.gov
Loading...
Searching...
No Matches
ElementsAlongLine.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 "ElementsAlongLine.h"
11
12// MOOSE includes
13#include "LineSegment.h"
14#include "RayTracing.h"
15#include "MooseMesh.h"
16
18
21{
23
24 params.addRequiredParam<Point>("start", "The beginning of the line");
25 params.addRequiredParam<Point>("end", "The end of the line");
26 params.addClassDescription("Outputs the IDs of every element intersected by a user-defined line");
27 return params;
28}
29
31 : GeneralVectorPostprocessor(parameters),
32 _start(getParam<Point>("start")),
33 _end(getParam<Point>("end")),
34 _elem_ids(declareVector("elem_ids"))
35{
36 _fe_problem.mesh().errorIfDistributedMesh("ElementsAlongLine");
37}
38
39void
44
45void
47{
48 std::vector<Elem *> intersected_elems;
49 std::vector<LineSegment> segments;
50
51 std::unique_ptr<libMesh::PointLocatorBase> pl = _fe_problem.mesh().getPointLocator();
53 _start, _end, _fe_problem.mesh(), *pl, intersected_elems, segments);
54
55 unsigned int num_elems = intersected_elems.size();
56
57 _elem_ids.resize(num_elems);
58
59 for (unsigned int i = 0; i < num_elems; i++)
60 _elem_ids[i] = intersected_elems[i]->id();
61}
registerMooseObject("MooseApp", ElementsAlongLine)
Get 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.
ElementsAlongLine(const InputParameters &parameters)
VectorPostprocessorValue & _elem_ids
The elements that intersect the line.
static InputParameters validParams()
Point _start
The beginning of the line.
virtual void execute() override
Find the elements.
Point _end
The end of the line.
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.
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.