https://mooseframework.inl.gov
ReporterPointMarker.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 "ReporterPointMarker.h"
11 #include "FEProblemBase.h"
12 
14 
17 {
19  params.addClassDescription("Marks the region inside or empty if it contains a reporter defined "
20  "point for refinement or coarsening.");
21  params.addRequiredParam<ReporterName>("x_coord_name", "reporter x-coordinate name");
22  params.addRequiredParam<ReporterName>("y_coord_name", "reporter y-coordinate name");
23  params.addRequiredParam<ReporterName>("z_coord_name", "reporter z-coordinate name");
24  MooseEnum marker_states = Marker::markerStates();
26  "inside", marker_states, "How to mark elements containing a point");
28  "empty", marker_states, "How to mark elements not containing a point");
29  return params;
30 }
31 
33  : Marker(parameters),
34  ReporterInterface(this),
35  _inside(parameters.get<MooseEnum>("inside").getEnum<MarkerValue>()),
36  _empty(parameters.get<MooseEnum>("empty").getEnum<MarkerValue>()),
37  _x_coord(getReporterValue<std::vector<Real>>("x_coord_name", REPORTER_MODE_REPLICATED)),
38  _y_coord(getReporterValue<std::vector<Real>>("y_coord_name", REPORTER_MODE_REPLICATED)),
39  _z_coord(getReporterValue<std::vector<Real>>("z_coord_name", REPORTER_MODE_REPLICATED))
40 {
41 }
42 
43 void
45 {
47  _pl->enable_out_of_mesh_mode();
48  const auto npoints = _x_coord.size();
49  if (npoints != _y_coord.size() || npoints != _z_coord.size())
50  mooseError("The coordinate vectors are a different size. \n",
51  " x_coord size = ",
52  npoints,
53  "; y_coord size = ",
54  _y_coord.size(),
55  "; z_coord size = ",
56  _z_coord.size());
57 
58  _point_elems.clear();
59  for (std::size_t i = 0; i < npoints; ++i)
60  {
61  Point pt(_x_coord[i], _y_coord[i], _z_coord[i]);
62  const auto elem = (*_pl)(pt);
63  if (elem)
64  _point_elems.insert(elem->id());
65  }
66 }
67 
70 {
71  return (_point_elems.count(_current_elem->id()) ? _inside : _empty);
72 }
registerMooseObject("MooseApp", ReporterPointMarker)
std::unique_ptr< libMesh::PointLocatorBase > _pl
Pointer to PointLocatorBase object.
FEProblemBase & _fe_problem
Definition: Marker.h:111
T * get(const std::unique_ptr< T > &u)
The MooseUtils::get() specializations are used to support making forwards-compatible code changes fro...
Definition: MooseUtils.h:1155
Definition: Marker.h:41
const Elem *const & _current_elem
Pointer to the current element being considered in the marker element-based loop. ...
Definition: Marker.h:122
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
const MarkerValue _inside
marker value to give elements containing a point
MarkerValue
This mirrors the main refinement flag values in libMesh in Elem::RefinementState but adds "dont_mark"...
Definition: Marker.h:59
const std::vector< Real > & _z_coord
z coordinate
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...
const std::vector< Real > & _y_coord
y coordinate
virtual void markerSetup() override
Is called before any element looping is started so any "global" computation can be done...
static InputParameters validParams()
const MarkerValue _empty
marker for elements not containing points
Interface to allow object to consume Reporter values.
static MooseEnum markerStates()
Helper function for getting the valid refinement flag states a marker can use as a MooseEnum...
Definition: Marker.C:62
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition: MooseEnum.h:33
const std::vector< Real > & _x_coord
x coordinate
std::set< dof_id_type > _point_elems
list of sort uniqued elements containing points
Marks all elements as inside/empty if they do/don&#39;t contain a point.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
virtual MooseMesh & mesh() override
void mooseError(Args &&... args) const
Emits an error prefixed with object name and type and optionally a file path to the top-level block p...
Definition: MooseBase.h:267
virtual MarkerValue computeElementMarker() override
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:3733
ReporterPointMarker(const InputParameters &parameters)
const ReporterMode REPORTER_MODE_REPLICATED
static InputParameters validParams()
Definition: Marker.C:19
The Reporter system is comprised of objects that can contain any number of data values.
Definition: ReporterName.h:30