https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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),
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
43void
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
const ReporterMode REPORTER_MODE_REPLICATED
registerMooseObject("MooseApp", ReporterPointMarker)
virtual MooseMesh & mesh() override
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.
static InputParameters validParams()
Definition Marker.C:19
const Elem *const & _current_elem
Pointer to the current element being considered in the marker element-based loop.
Definition Marker.h:122
MarkerValue
This mirrors the main refinement flag values in libMesh in Elem::RefinementState but adds "dont_mark"...
Definition Marker.h:60
static MooseEnum markerStates()
Helper function for getting the valid refinement flag states a marker can use as a MooseEnum.
Definition Marker.C:62
FEProblemBase & _fe_problem
Definition Marker.h:111
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:271
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition MooseEnum.h:55
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
Interface to allow object to consume Reporter values.
The Reporter system is comprised of objects that can contain any number of data values.
Marks all elements as inside/empty if they do/don't contain a point.
std::unique_ptr< libMesh::PointLocatorBase > _pl
Pointer to PointLocatorBase object.
static InputParameters validParams()
virtual MarkerValue computeElementMarker() override
const std::vector< Real > & _x_coord
x coordinate
std::set< dof_id_type > _point_elems
list of sort uniqued elements containing points
const MarkerValue _empty
marker for elements not containing points
virtual void markerSetup() override
Is called before any element looping is started so any "global" computation can be done.
const MarkerValue _inside
marker value to give elements containing a point
const std::vector< Real > & _y_coord
y coordinate
ReporterPointMarker(const InputParameters &parameters)
const std::vector< Real > & _z_coord
z coordinate