https://mooseframework.inl.gov
ReporterPositions.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 "ReporterPositions.h"
11 
13 
16 {
18  params.addRequiredParam<std::vector<ReporterName>>("reporters",
19  "Reporter(s) containing the positions");
20 
21  // Use reporter ordering
22  params.set<bool>("auto_sort") = false;
23  // User reporter broadcasting behavior
24  params.set<bool>("auto_broadcast") = false;
25 
26  params.addClassDescription(
27  "Import positions from one or more reporters, for example other Positions");
28  return params;
29 }
30 
32 {
33  // Attempt to obtain the positions. Will only succeed for other Positions at this point
34  initialize();
35  // Sort if needed
36  finalize();
37  // TODO Check execute_on. I'm not sure how to retrieve execute_on for reporters.
38 }
39 
40 void
42 {
44 
45  const auto & positions_reporters = getParam<std::vector<ReporterName>>("reporters");
46  _positions_2d.resize(positions_reporters.size());
47 
48  for (const auto r_it : index_range(positions_reporters))
49  {
50  const std::string & reporter_name = positions_reporters[r_it];
51 
52  const auto & reporter_data = _fe_problem.getReporterData();
53  if (reporter_data.getReporterContextBase(reporter_name).getProducerModeEnum() ==
55  mooseError("Distributed reporter not implemented yet");
56  const auto & data = reporter_data.getReporterValue<std::vector<Point>>(reporter_name);
57 
58  for (const auto & d : data)
59  {
60  _positions.push_back(d);
61  _positions_2d[r_it].push_back(d);
62  }
63  }
64  _initialized = true;
65 }
static InputParameters validParams()
Definition: Positions.C:15
Positions from a Reporter.
void clearPositions()
Clear all positions vectors.
Definition: Positions.C:154
Positions objects are under the hood Reporters.
Definition: Positions.h:20
T & set(const std::string &name, bool quiet_mode=false)
Returns a writable reference to the named parameters.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
registerMooseObject("MooseApp", ReporterPositions)
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...
bool _initialized
Whether the positions object has been initialized. This must be set by derived objects.
Definition: Positions.h:116
std::vector< std::vector< Point > > _positions_2d
2D storage for all the positions
Definition: Positions.h:95
const ReporterData & getReporterData() const
Provides const access the ReporterData object.
ReporterPositions(const InputParameters &parameters)
std::vector< Point > & _positions
For now, only the 1D vector will be shared across all ranks.
Definition: Positions.h:92
const ReporterMode REPORTER_MODE_DISTRIBUTED
FEProblemBase & _fe_problem
Reference to the FEProblemBase for this user object.
Definition: UserObject.h:211
void initialize() override
In charge of computing / loading the positions.
virtual void finalize() override
In charge of reduction across all ranks & sorting for consistent output.
Definition: Positions.C:220
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
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...
auto index_range(const T &sizable)
static InputParameters validParams()