https://mooseframework.inl.gov
ExtraIDIntegralReporter.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 
13 
16 {
18  params.addRequiredParam<std::vector<VariableName>>(
19  "variable", "The names of the variables that this ExtraIDIntegralReporter operates on");
20  params.addRequiredParam<std::vector<ExtraElementIDName>>(
21  "id_name", "The list of extra ids name by which to separate integrals.");
22  params.addParam<std::vector<SubdomainName>>(
23  "block", "The list of blocks (ids or names) that this object will be applied");
24  params.addClassDescription("This ExtraIDIntegralReporter source code is to integrate variables "
25  "based on parsed extra IDs based on reporter system.");
26  return params;
27 }
28 
30  : GeneralReporter(parameters),
31  _extra_id_data(declareValueByName<ExtraIDData>("extra_id_data", REPORTER_MODE_REPLICATED))
32 {
33  // add Extra ID Integral VPP
34  auto var_names = getParam<std::vector<VariableName>>("variable");
35  auto extra_id_names = getParam<std::vector<ExtraElementIDName>>("id_name");
36  InputParameters vpp_params =
37  _app.getFactory().getValidParams("ExtraIDIntegralVectorPostprocessor");
38  vpp_params.set<std::vector<VariableName>>("variable")
39  .insert(vpp_params.set<std::vector<VariableName>>("variable").end(),
40  var_names.begin(),
41  var_names.end());
42  vpp_params.set<std::vector<ExtraElementIDName>>("id_name").insert(
43  vpp_params.set<std::vector<ExtraElementIDName>>("id_name").end(),
44  extra_id_names.begin(),
45  extra_id_names.end());
46  if (isParamValid("block"))
47  {
48  auto blocks = getParam<std::vector<SubdomainName>>("block");
49  vpp_params.set<std::vector<SubdomainName>>("block").insert(
50  vpp_params.set<std::vector<SubdomainName>>("block").end(), blocks.begin(), blocks.end());
51  }
52  if (isParamValid("execute_on"))
53  vpp_params.set<ExecFlagEnum>("execute_on") = getParam<ExecFlagEnum>("execute_on");
54  const VectorPostprocessorName vpp_name = _name + "_extra_id_vpp";
55  _fe_problem.addVectorPostprocessor("ExtraIDIntegralVectorPostprocessor", vpp_name, vpp_params);
57 
58  // fill out exta_id_info;
59  _extra_id_data.names.insert(
60  _extra_id_data.names.end(), extra_id_names.begin(), extra_id_names.end());
61 
62  const auto & unique_extra_ids = _vpp_object->getUniqueExtraIds();
63  _extra_id_data.unique_ids.resize(unique_extra_ids.size());
64  for (unsigned int i = 0; i < unique_extra_ids.size(); ++i)
66  (*unique_extra_ids[i]).begin(),
67  (*unique_extra_ids[i]).end());
68 
71  _extra_id_data.variables.end(), var_names.begin(), var_names.end());
72 }
73 
74 void
75 to_json(nlohmann::json & json, const ExtraIDIntegralReporter::ExtraIDData & extra_id_data)
76 {
77  auto & info = json["extra_id_data"];
78  info["num_id_name"] = extra_id_data.names.size();
79  info["id_name"] = extra_id_data.names;
80  info["num_values_per_integral"] = extra_id_data.integrals.size();
81  info["map_id_to_value"] = extra_id_data.unique_ids;
82 
83  auto & integrals = json["integrals"];
84  integrals["num_variables"] = extra_id_data.variables.size();
85  integrals["variable_names"] = extra_id_data.variables;
86  for (unsigned int i = 0; i < extra_id_data.variables.size(); ++i)
87  {
88  std::string name = extra_id_data.variables[i] + "_integral";
89  integrals[name] = (*extra_id_data.integrals[i]);
90  }
91 }
92 void
94 {
95 }
96 
97 void
99 {
100 }
std::string name(const ElemQuality q)
A MultiMooseEnum object to hold "execute_on" flags.
Definition: ExecFlagEnum.h:21
std::vector< ExtraElementIDName > names
T & getUserObject(const std::string &name, unsigned int tid=0) const
Get the user object by its name.
const std::string & _name
The name of this class.
Definition: MooseBase.h:359
MPI_Info info
char ** blocks
Reporter object that has a single execution of the "execute" method for for each execute flag...
void dataLoad(std::istream &, ExtraIDIntegralReporter::ExtraIDData &, void *)
T & set(const std::string &name, bool quiet_mode=false)
Returns a writable reference to the named parameters.
InputParameters getValidParams(const std::string &name) const
Get valid parameters for the object.
Definition: Factory.C:68
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
static InputParameters validParams()
const std::vector< VectorPostprocessorValue * > & getUniqueExtraIds() const
Return extra ID list.
std::vector< VectorPostprocessorValue * > integrals
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...
Factory & getFactory()
Retrieve a writable reference to the Factory associated with this App.
Definition: MooseApp.h:394
std::vector< std::vector< dof_id_type > > unique_ids
registerMooseObject("MooseApp", ExtraIDIntegralReporter)
static InputParameters validParams()
virtual void addVectorPostprocessor(const std::string &pp_name, const std::string &name, InputParameters &parameters)
void dataStore(std::ostream &, ExtraIDIntegralReporter::ExtraIDData &, void *)
void to_json(nlohmann::json &json, const ExtraIDIntegralReporter::ExtraIDData &extra_id_data)
MooseApp & _app
The MOOSE application this is associated with.
Definition: MooseBase.h:353
ExtraIDIntegralReporter(const InputParameters &parameters)
const std::vector< VectorPostprocessorValue * > & getIntegrals() const
Return Integral values.
const ExtraIDIntegralVectorPostprocessor * _vpp_object
FEProblemBase & _fe_problem
Reference to the FEProblemBase for this user object.
Definition: UserObject.h:211
This ExtraIDIntegralVectorPostprocessor source code is to integrate variables based on parsed extra I...
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...
void addParam(const std::string &name, const S &value, const std::string &doc_string)
These methods add an optional parameter and a documentation string to the InputParameters object...
const ReporterMode REPORTER_MODE_REPLICATED
bool isParamValid(const std::string &name) const
Test if the supplied parameter is valid.
Definition: MooseBase.h:195