www.mooseframework.org
FullSolveMultiApp.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 
10 #include "FullSolveMultiApp.h"
11 #include "LayeredSideFluxAverage.h"
12 #include "Executioner.h"
13 
14 // libMesh
15 #include "libmesh/mesh_tools.h"
16 
18 
19 template <>
22 {
24  params.addParam<bool>(
25  "no_backup_and_restore",
26  false,
27  "True to turn off backup/restore for this multiapp. This is useful when doing steady-state "
28  "Picard iterations where we want to use the solution of previous Picard iteration as the "
29  "initial guess of the current Picard iteration");
30  params.addParam<bool>(
31  "keep_full_output_history",
32  false,
33  "Whether or not to keep the full output history when this multiapp has multiple entries");
34  return params;
35 }
36 
38 
39 void
41 {
42  if (getParam<bool>("no_backup_and_restore"))
43  return;
44  else
46 }
47 
48 void
50 {
51  if (getParam<bool>("no_backup_and_restore"))
52  return;
53  else
55 }
56 
57 void
59 {
61 
62  if (_has_an_app)
63  {
65 
67 
68  // Grab Executioner from each app
69  for (unsigned int i = 0; i < _my_num_apps; i++)
70  {
71  auto & app = _apps[i];
72  Executioner * ex = app->getExecutioner();
73 
74  if (!ex)
75  mooseError("Executioner does not exist!");
76 
77  ex->init();
78 
79  _executioners[i] = ex;
80  }
81  }
82 }
83 
84 bool
85 FullSolveMultiApp::solveStep(Real /*dt*/, Real /*target_time*/, bool auto_advance)
86 {
87  if (!auto_advance)
88  mooseError("FullSolveMultiApp is not compatible with auto_advance=false");
89 
90  if (!_has_an_app)
91  return true;
92 
94 
95  int rank;
96  int ierr;
97  ierr = MPI_Comm_rank(_communicator.get(), &rank);
98  mooseCheckMPIErr(ierr);
99 
100  bool last_solve_converged = true;
101  for (unsigned int i = 0; i < _my_num_apps; i++)
102  {
103  // reset output system if desired
104  if (!getParam<bool>("keep_full_output_history"))
105  _apps[i]->getOutputWarehouse().reset();
106 
107  Executioner * ex = _executioners[i];
108  ex->execute();
109  if (!ex->lastSolveConverged())
110  last_solve_converged = false;
111  }
112 
113  return last_solve_converged;
114 }
InputParameters validParams< FullSolveMultiApp >()
virtual void restore()
Restore the state of every Sub App.
Definition: MultiApp.C:409
virtual void initialSetup() override
Gets called at the beginning of the simulation before this object is asked to do its job...
virtual void backup()
Save off the state of every Sub App.
Definition: MultiApp.C:400
virtual void init()
Initialize the executioner.
Definition: Executioner.h:51
std::vector< std::shared_ptr< MooseApp > > _apps
Pointers to each of the Apps.
Definition: MultiApp.h:373
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
void mooseError(Args &&... args) const
Definition: MooseObject.h:147
virtual void execute()=0
Pure virtual execute function MUST be overridden by children classes.
FullSolveMultiApp(const InputParameters &parameters)
std::vector< Executioner * > _executioners
virtual void backup() override
Save off the state of every Sub App.
InputParameters validParams< MultiApp >()
Definition: MultiApp.C:43
Executioners are objects that do the actual work of solving your problem.
Definition: Executioner.h:32
unsigned int _my_num_apps
The number of apps this object is involved in simulating.
Definition: MultiApp.h:346
bool _has_an_app
Whether or not this processor as an App at all
Definition: MultiApp.h:418
registerMooseObject("MooseApp", FullSolveMultiApp)
virtual void initialSetup() override
Gets called at the beginning of the simulation before this object is asked to do its job...
Definition: MultiApp.C:233
virtual void restore() override
Restore the state of every Sub App.
void addParam(const std::string &name, const S &value, const std::string &doc_string)
These methods add an option parameter and a documentation string to the InputParameters object...
ierr
virtual bool lastSolveConverged() const =0
Whether or not the last solve converged.
A MultiApp represents one or more MOOSE applications that are running simultaneously.
Definition: MultiApp.h:57
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:358
This type of MultiApp will do a full solve when it is asked to take a step.