www.mooseframework.org
FullSolveMultiApp.C
Go to the documentation of this file.
1 /****************************************************************/
2 /* DO NOT MODIFY THIS HEADER */
3 /* MOOSE - Multiphysics Object Oriented Simulation Environment */
4 /* */
5 /* (c) 2010 Battelle Energy Alliance, LLC */
6 /* ALL RIGHTS RESERVED */
7 /* */
8 /* Prepared by Battelle Energy Alliance, LLC */
9 /* Under Contract No. DE-AC07-05ID14517 */
10 /* With the U. S. Department of Energy */
11 /* */
12 /* See COPYRIGHT for full restrictions */
13 /****************************************************************/
14 
15 #include "FullSolveMultiApp.h"
16 #include "LayeredSideFluxAverage.h"
17 #include "Executioner.h"
18 
19 // libMesh
20 #include "libmesh/mesh_tools.h"
21 
22 template <>
25 {
27  return params;
28 }
29 
31  : MultiApp(parameters), _solved(false)
32 {
33 }
34 
35 void
37 {
39 
40  if (_has_an_app)
41  {
43 
45 
46  // Grab Executioner from each app
47  for (unsigned int i = 0; i < _my_num_apps; i++)
48  {
49  auto & app = _apps[i];
50  Executioner * ex = app->getExecutioner();
51 
52  if (!ex)
53  mooseError("Executioner does not exist!");
54 
55  ex->init();
56 
57  _executioners[i] = ex;
58  }
59  }
60 }
61 
62 bool
63 FullSolveMultiApp::solveStep(Real /*dt*/, Real /*target_time*/, bool auto_advance)
64 {
65  if (!auto_advance)
66  mooseError("FullSolveMultiApp is not compatible with auto_advance=false");
67 
68  if (!_has_an_app)
69  return true;
70 
71  if (_solved)
72  return true;
73 
75 
76  int rank;
77  int ierr;
78  ierr = MPI_Comm_rank(_orig_comm, &rank);
79  mooseCheckMPIErr(ierr);
80 
81  bool last_solve_converged = true;
82  for (unsigned int i = 0; i < _my_num_apps; i++)
83  {
84  Executioner * ex = _executioners[i];
85  ex->execute();
86  if (!ex->lastSolveConverged())
87  last_solve_converged = false;
88  }
89 
90  _solved = true;
91 
92  return last_solve_converged;
93 }
InputParameters validParams< FullSolveMultiApp >()
virtual void initialSetup() override
Gets called at the beginning of the simulation before this object is asked to do its job...
std::vector< std::shared_ptr< MooseApp > > _apps
Pointers to each of the Apps.
Definition: MultiApp.h:350
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
bool _solved
Whether or not this MultiApp has already been solved.
MPI_Comm _orig_comm
The comm that was passed to us specifying our pool of processors.
Definition: MultiApp.h:332
virtual void execute()=0
Pure virtual execute function MUST be overridden by children classes.
FullSolveMultiApp(const InputParameters &parameters)
std::vector< Executioner * > _executioners
InputParameters validParams< MultiApp >()
Definition: MultiApp.C:46
Executioners are objects that do the actual work of solving your problem.
Definition: Executioner.h:41
unsigned int _my_num_apps
The number of apps this object is involved in simulating.
Definition: MultiApp.h:326
bool _has_an_app
Whether or not this processor as an App at all
Definition: MultiApp.h:383
virtual bool lastSolveConverged()
Whether or not the last solve converged.
Definition: Executioner.C:174
virtual void init()
Initialize the executioner.
Definition: Executioner.C:130
virtual void initialSetup() override
Gets called at the beginning of the simulation before this object is asked to do its job...
Definition: MultiApp.C:191
void mooseError(Args &&...args) const
Definition: MooseObject.h:80
ierr
A MultiApp represents one or more MOOSE applications that are running simultaneously.
Definition: MultiApp.h:59
virtual bool solveStep(Real dt, Real target_time, bool auto_advance=true) override
Re-solve all of the Apps.
MPI_Comm _my_comm
The MPI communicator this object is going to use.
Definition: MultiApp.h:335