https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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
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
40void
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}
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
Definition MooseError.h:311
const ReporterMode REPORTER_MODE_DISTRIBUTED
registerMooseObject("MooseApp", ReporterPositions)
const ReporterData & getReporterData() const
Provides const access the ReporterData object.
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.
T & set(const std::string &name, bool quiet_mode=false)
Returns a writable reference to the named parameters.
Positions objects are under the hood Reporters.
Definition Positions.h:21
std::vector< std::vector< Point > > _positions_2d
2D storage for all the positions
Definition Positions.h:95
void clearPositions()
Clear all positions vectors.
Definition Positions.C:154
std::vector< Point > & _positions
For now, only the 1D vector will be shared across all ranks.
Definition Positions.h:92
static InputParameters validParams()
Definition Positions.C:15
virtual void finalize() override
In charge of reduction across all ranks & sorting for consistent output.
Definition Positions.C:220
bool _initialized
Whether the positions object has been initialized. This must be set by derived objects.
Definition Positions.h:116
const T & getReporterValue(const ReporterName &reporter_name, const MooseObject &consumer, const ReporterMode &mode, const std::size_t time_index=0) const
Method for returning read only references to Reporter values.
Positions from a Reporter.
void initialize() override
In charge of computing / loading the positions.
ReporterPositions(const InputParameters &parameters)
static InputParameters validParams()
FEProblemBase & _fe_problem
Reference to the FEProblemBase for this user object.