www.mooseframework.org
MultiAppVectorPostprocessorTransfer.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
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 
12 // MOOSE includes
13 #include "MooseTypes.h"
14 #include "FEProblem.h"
15 #include "MultiApp.h"
16 
17 // libMesh
18 #include "libmesh/meshfree_interpolation.h"
19 #include "libmesh/system.h"
20 
22 
23 template <>
26 {
28  params.addRequiredParam<PostprocessorName>(
29  "postprocessor", "The name of the Postprocessors on the sub-app to transfer from/to.");
30  params.addRequiredParam<VectorPostprocessorName>("vector_postprocessor",
31  "The name of the VectorPostprocessor in "
32  "the MultiApp to transfer values "
33  "from/to.");
34  params.addRequiredParam<std::string>(
35  "vector_name", "Named vector quantity to transfer from/to in VectorPostprocessor.");
36  params.addClassDescription("This transfer distributes the N values of a "
37  "VectorPostprocessor to Postprocessors located in "
38  "N sub-apps or"
39  " collects Postprocessor values from N sub-apps "
40  "into a VectorPostprocessor");
41  return params;
42 }
43 
45  const InputParameters & parameters)
46  : MultiAppTransfer(parameters),
47  _sub_pp_name(getParam<PostprocessorName>("postprocessor")),
48  _master_vpp_name(getParam<VectorPostprocessorName>("vector_postprocessor")),
49  _vector_name(getParam<std::string>("vector_name"))
50 {
51 }
52 
53 void
55 {
57  _multi_app->problemBase().getVectorPostprocessorValue(_master_vpp_name, _vector_name, false);
58 
59  if (vpp.size() != _multi_app->numGlobalApps())
60  mooseError("VectorPostprocessor ",
62  " and number of sub-apps do not match: ",
63  vpp.size(),
64  "/",
65  _multi_app->numGlobalApps());
66 
67  for (unsigned int i = 0; i < _multi_app->numGlobalApps(); ++i)
68  if (_multi_app->hasLocalApp(i))
69  _multi_app->appProblemBase(i).getPostprocessorValue(_sub_pp_name) = vpp[i];
70 }
71 
72 void
74 {
76  _multi_app->problemBase().getVectorPostprocessorValue(_master_vpp_name, _vector_name, false);
77 
78  if (vpp.size() != _multi_app->numGlobalApps())
79  mooseError("VectorPostprocessor ",
81  " and number of sub-apps do not match: ",
82  vpp.size(),
83  "/",
84  _multi_app->numGlobalApps());
85 
86  // set all values to zero to make communication easier
87  for (auto & v : vpp)
88  v = 0.0;
89 
90  for (unsigned int i = 0; i < _multi_app->numGlobalApps(); ++i)
91  if (_multi_app->hasLocalApp(i))
92  vpp[i] = _multi_app->appProblemBase(i).getPostprocessorValue(_sub_pp_name);
93 
94  for (auto & v : vpp)
95  _communicator.sum(v);
96 }
97 
98 void
100 {
101  _console << "Beginning VectorPostprocessorTransfer " << name() << std::endl;
102 
103  if (_direction == FROM_MULTIAPP)
105  else
107 
108  _console << "Finished PostprocessorTransfer " << name() << std::endl;
109 }
InputParameters validParams< MultiAppVectorPostprocessorTransfer >()
registerMooseObject("MooseApp", MultiAppVectorPostprocessorTransfer)
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
void mooseError(Args &&... args) const
Definition: MooseObject.h:147
std::shared_ptr< MultiApp > _multi_app
The MultiApp this Transfer is transferring data to or from.
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...
Copies the values of a VectorPostprocessor from the Master to postprocessors on each MultiApp or coll...
virtual void execute() override
Execute the transfer.
std::vector< Real > VectorPostprocessorValue
Definition: MooseTypes.h:155
InputParameters validParams< MultiAppTransfer >()
Base class for all MultiAppTransfer objects.
const std::string & name() const
Get the name of the object.
Definition: MooseObject.h:59
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...
const ConsoleStream _console
An instance of helper class to write streams to the Console objects.
const MooseEnum _direction
Whether we&#39;re transferring to or from the MultiApp.
MultiAppVectorPostprocessorTransfer(const InputParameters &parameters)