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 
20 
23 {
25  params.addClassDescription("Performs a complete simulation during each execution.");
26  params.addParam<bool>(
27  "no_backup_and_restore",
28  false,
29  "True to turn off backup/restore for this multiapp. This is useful when doing steady-state "
30  "Picard iterations where we want to use the solution of previous Picard iteration as the "
31  "initial guess of the current Picard iteration");
32  params.addParam<bool>(
33  "keep_full_output_history",
34  false,
35  "Whether or not to keep the full output history when this multiapp has multiple entries");
36  return params;
37 }
38 
40 
41 void
43 {
44  if (getParam<bool>("no_backup_and_restore"))
45  return;
46  else
48 }
49 
50 void
52 {
53  if (getParam<bool>("no_backup_and_restore"))
54  return;
55  else
57 }
58 
59 void
61 {
63 
64  if (_has_an_app)
65  {
67 
69 
70  // Grab Executioner from each app
71  for (unsigned int i = 0; i < _my_num_apps; i++)
72  {
73  auto & app = _apps[i];
74  Executioner * ex = app->getExecutioner();
75 
76  if (!ex)
77  mooseError("Executioner does not exist!");
78 
79  ex->init();
80 
81  _executioners[i] = ex;
82  }
83  }
84 }
85 
86 bool
87 FullSolveMultiApp::solveStep(Real /*dt*/, Real /*target_time*/, bool auto_advance)
88 {
89  if (!auto_advance)
90  mooseError("FullSolveMultiApp is not compatible with auto_advance=false");
91 
92  if (!_has_an_app)
93  return true;
94 
96 
97  int rank;
98  int ierr;
99  ierr = MPI_Comm_rank(_communicator.get(), &rank);
100  mooseCheckMPIErr(ierr);
101 
102  bool last_solve_converged = true;
103  for (unsigned int i = 0; i < _my_num_apps; i++)
104  {
105  // reset output system if desired
106  if (!getParam<bool>("keep_full_output_history"))
107  _apps[i]->getOutputWarehouse().reset();
108 
109  Executioner * ex = _executioners[i];
110  ex->execute();
111  if (!ex->lastSolveConverged())
112  last_solve_converged = false;
113  }
114 
115  return last_solve_converged;
116 }
Executioner::init
virtual void init()
Initialize the executioner.
Definition: Executioner.h:53
MultiApp::_my_comm
MPI_Comm & _my_comm
The MPI communicator this object is going to use.
Definition: MultiApp.h:360
defineLegacyParams
defineLegacyParams(FullSolveMultiApp)
Moose::ScopedCommSwapper
Definition: Moose.h:216
MultiApp::_my_num_apps
unsigned int _my_num_apps
The number of apps this object is involved in simulating.
Definition: MultiApp.h:348
MooseObject::mooseError
void mooseError(Args &&... args) const
Definition: MooseObject.h:141
MultiApp::validParams
static InputParameters validParams()
Definition: MultiApp.C:44
InputParameters::addParam
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.
Definition: InputParameters.h:1198
FullSolveMultiApp::initialSetup
virtual void initialSetup() override
Gets called at the beginning of the simulation before this object is asked to do its job.
Definition: FullSolveMultiApp.C:60
Executioner
Executioners are objects that do the actual work of solving your problem.
Definition: Executioner.h:32
FullSolveMultiApp::_executioners
std::vector< Executioner * > _executioners
Definition: FullSolveMultiApp.h:44
FullSolveMultiApp.h
MultiApp::_has_an_app
bool _has_an_app
Whether or not this processor as an App at all
Definition: MultiApp.h:420
FullSolveMultiApp::backup
virtual void backup() override
Save off the state of every Sub App.
Definition: FullSolveMultiApp.C:42
MultiApp
A MultiApp represents one or more MOOSE applications that are running simultaneously.
Definition: MultiApp.h:57
Executioner::execute
virtual void execute()=0
Pure virtual execute function MUST be overridden by children classes.
LayeredSideFluxAverage.h
Executioner.h
InputParameters
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
Definition: InputParameters.h:53
FullSolveMultiApp::FullSolveMultiApp
FullSolveMultiApp(const InputParameters &parameters)
Definition: FullSolveMultiApp.C:39
MultiApp::_apps
std::vector< std::shared_ptr< MooseApp > > _apps
Pointers to each of the Apps.
Definition: MultiApp.h:375
FullSolveMultiApp
This type of MultiApp will do a full solve when it is asked to take a step.
Definition: FullSolveMultiApp.h:24
InputParameters::addClassDescription
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.
Definition: InputParameters.C:70
ierr
ierr
Definition: PetscDMMoose.C:1270
MultiApp::backup
virtual void backup()
Save off the state of every Sub App.
Definition: MultiApp.C:407
MultiApp::restore
virtual void restore()
Restore the state of every Sub App.
Definition: MultiApp.C:416
MultiApp::initialSetup
virtual void initialSetup() override
Gets called at the beginning of the simulation before this object is asked to do its job.
Definition: MultiApp.C:237
FullSolveMultiApp::validParams
static InputParameters validParams()
Definition: FullSolveMultiApp.C:22
registerMooseObject
registerMooseObject("MooseApp", FullSolveMultiApp)
FullSolveMultiApp::restore
virtual void restore() override
Restore the state of every Sub App.
Definition: FullSolveMultiApp.C:51
Executioner::lastSolveConverged
virtual bool lastSolveConverged() const =0
Whether or not the last solve converged.
FullSolveMultiApp::solveStep
virtual bool solveStep(Real dt, Real target_time, bool auto_advance=true) override
Re-solve all of the Apps.
Definition: FullSolveMultiApp.C:87