Loading [MathJax]/extensions/tex2jax.js
https://mooseframework.inl.gov
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends
NearestPositionsDivision.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 #include "MooseMesh.h"
12 #include "Positions.h"
13 
14 #include "libmesh/mesh_base.h"
15 #include "libmesh/elem.h"
16 
18 
21 {
23  params.addClassDescription("Divide the mesh using a nearest-point / voronoi algorithm, with the "
24  "points coming from a Positions object");
25  params.addRequiredParam<PositionsName>(
26  "positions", "The name of the Positions object to form the nearest-neighbor division with");
27  return params;
28 }
29 
31  : MeshDivision(parameters),
32  _nearest_positions_obj(&_fe_problem->getPositionsObject(getParam<PositionsName>("positions")))
33 {
35  _mesh_fully_indexed = true;
36 }
37 
38 void
40 {
42 }
43 
44 unsigned int
46 {
47  const bool initial = _fe_problem->getCurrentExecuteOnFlag() == EXEC_INITIAL;
48  return _nearest_positions_obj->getNearestPositionIndex(elem.vertex_average(), initial);
49 }
50 
51 unsigned int
53 {
54  const bool initial = _fe_problem->getCurrentExecuteOnFlag() == EXEC_INITIAL;
56 }
registerMooseObject("MooseApp", NearestPositionsDivision)
virtual void initialize() override
Set up any data members that would be necessary to obtain the division indices.
NearestPositionsDivision(const InputParameters &parameters)
const ExecFlagType & getCurrentExecuteOnFlag() const
Return/set the current execution flag.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
static InputParameters validParams()
Divides the mesh based on a nearest-neighbor algorithm applied to the positions from a Positions obje...
Base class for MeshDivision objects.
Definition: MeshDivision.h:35
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...
unsigned int getNearestPositionIndex(const Point &target, bool initial) const
Find the nearest Position index for a given point.
Definition: Positions.C:96
unsigned int getNumPositions(bool initial=false) const
}
Definition: Positions.h:37
bool _mesh_fully_indexed
Whether the mesh is fully covered / indexed, all elements and points have a valid index...
Definition: MeshDivision.h:77
void setNumDivisions(const unsigned int ndivs)
Set the number of divisions.
Definition: MeshDivision.h:65
const FEProblemBase *const _fe_problem
Pointer to the problem, needed to retrieve pointers to various objects.
Definition: MeshDivision.h:71
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...
const Positions *const _nearest_positions_obj
static InputParameters validParams()
Class constructor.
Definition: MeshDivision.C:14
virtual unsigned int divisionIndex(const Point &pt) const override
Return the index of the division to which the point belongs.
const ExecFlagType EXEC_INITIAL
Definition: Moose.C:28