https://mooseframework.inl.gov
Loading...
Searching...
No Matches
MultiAppVectorPostprocessorTransfer.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
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
25{
27 params.addRequiredParam<PostprocessorName>(
28 "postprocessor", "The name of the Postprocessors on the sub-app to transfer from/to.");
29 params.addRequiredParam<VectorPostprocessorName>("vector_postprocessor",
30 "The name of the VectorPostprocessor in "
31 "the MultiApp to transfer values "
32 "from/to.");
33 params.addRequiredParam<std::string>(
34 "vector_name", "Named vector quantity to transfer from/to in VectorPostprocessor.");
35 params.addClassDescription("This transfer distributes the N values of a "
36 "VectorPostprocessor to Postprocessors located in "
37 "N sub-apps or"
38 " collects Postprocessor values from N sub-apps "
39 "into a VectorPostprocessor");
41
42 return params;
43}
44
46 const InputParameters & parameters)
47 : MultiAppTransfer(parameters),
48 _sub_pp_name(getParam<PostprocessorName>("postprocessor")),
49 _master_vpp_name(getParam<VectorPostprocessorName>("vector_postprocessor")),
50 _vector_name(getParam<std::string>("vector_name"))
51{
52 if (_directions.size() != 1)
53 paramError("direction", "This transfer is only unidirectional");
54}
55
56void
58{
59 const VectorPostprocessorValue & vpp =
60 getToMultiApp()->problemBase().getVectorPostprocessorValueByName(_master_vpp_name,
62
63 // Execute VPP if it was specified to execute on transfers
67
68 if (vpp.size() != getToMultiApp()->numGlobalApps())
69 mooseError("VectorPostprocessor ",
71 " and number of sub-apps do not match: ",
72 vpp.size(),
73 "/",
74 getToMultiApp()->numGlobalApps());
75
76 for (unsigned int i = 0; i < getToMultiApp()->numGlobalApps(); ++i)
77 if (getToMultiApp()->hasLocalApp(i))
78 getToMultiApp()->appProblemBase(i).setPostprocessorValueByName(_sub_pp_name, vpp[i]);
79}
80
81void
83{
84 const VectorPostprocessorValue & vpp =
85 getFromMultiApp()->problemBase().getVectorPostprocessorValueByName(_master_vpp_name,
88
89 if (vpp.size() != getFromMultiApp()->numGlobalApps())
90 mooseError("VectorPostprocessor ",
92 " and number of sub-apps do not match: ",
93 vpp.size(),
94 "/",
95 getFromMultiApp()->numGlobalApps());
96
97 VectorPostprocessorValue value(getFromMultiApp()->numGlobalApps(), 0.0);
98 for (unsigned int i = 0; i < getFromMultiApp()->numGlobalApps(); ++i)
99 {
100 // To avoid duplication and thus a wrong pp value after summing value accross procs, we should
101 // ensure that value[i] is only set by one procs. To do this, we check isFirstLocalRank to see
102 // if the current proc is the first rank that subapp i lives on.
103 if (getFromMultiApp()->hasLocalApp(i) && getFromMultiApp()->isFirstLocalRank())
104 value[i] = getFromMultiApp()->appProblemBase(i).getPostprocessorValueByName(_sub_pp_name);
105 }
106
107 // Sum to distribute entries of 'value' accross all procs
108 for (auto & v : value)
110
111 getFromMultiApp()->problemBase().setVectorPostprocessorValueByName(
113}
114
115void
117{
118 TIME_SECTION(
119 "MultiAppVectorPostprocessorTransfer::execute()", 5, "Transferring a vector postprocessor");
120
123 else
125}
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
Definition MooseError.h:311
std::vector< Real > VectorPostprocessorValue
Definition MooseTypes.h:231
const ExecFlagType EXEC_TRANSFER
Definition Moose.C:57
registerMooseObject("MooseApp", MultiAppVectorPostprocessorTransfer)
virtual void computeUserObjectByName(const ExecFlagType &type, const Moose::AuxGroup &group, const std::string &name)
Compute an user object with the given name.
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.
void paramError(const std::string &param, Args... args) const
Emits an error prefixed with the file and line number of the given param (from the input file) along ...
Definition MooseBase.h:457
Base class for all MultiAppTransfer objects.
void errorIfObjectExecutesOnTransferInSourceApp(const std::string &object_name) const
Error if executing this MooseObject on EXEC_TRANSFER in a source multiapp (from_multiapp,...
static void addUserObjectExecutionCheckParam(InputParameters &params)
Add the execution order check parameter (to skip the warning if needed)
void checkParentAppUserObjectExecuteOn(const std::string &object_name) const
Checks the execute_on flags for user object transfers with user objects on the source app which is al...
const std::shared_ptr< MultiApp > getToMultiApp() const
Get the MultiApp to transfer data to.
static InputParameters validParams()
const std::shared_ptr< MultiApp > getFromMultiApp() const
Get the MultiApp to transfer data from.
Copies the values of a VectorPostprocessor from the parent application to postprocessors on each suba...
const std::string & _vector_name
Specific vector to transfer among the vectors in the parent VPP.
const PostprocessorName & _sub_pp_name
Name of the postprocessor on the MultiApp.
virtual void execute() override
Execute the transfer.
const VectorPostprocessorName & _master_vpp_name
Name of the VectorPostprocessor on the parent app.
MultiAppVectorPostprocessorTransfer(const InputParameters &parameters)
unsigned int size() const
Return the number of active items in the MultiMooseEnum.
@ FROM_MULTIAPP
Definition Transfer.h:71
MultiMooseEnum _directions
The directions this Transfer is to be executed on.
Definition Transfer.h:110
FEProblemBase & _fe_problem
Definition Transfer.h:97
MooseEnum _current_direction
Definition Transfer.h:106
const Parallel::Communicator & _communicator
@ POST_AUX
Definition MooseTypes.h:761
@ PRE_AUX
Definition MooseTypes.h:760