www.mooseframework.org
MultiApp.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 // MOOSE includes
16 #include "MultiApp.h"
17 
18 #include "AppFactory.h"
19 #include "AuxiliarySystem.h"
20 #include "Console.h"
21 #include "Executioner.h"
22 #include "FEProblem.h"
23 #include "MooseMesh.h"
24 #include "MooseUtils.h"
25 #include "OutputWarehouse.h"
26 #include "RestartableDataIO.h"
27 #include "SetupInterface.h"
28 #include "UserObject.h"
29 #include "CommandLine.h"
30 #include "Conversion.h"
31 
32 #include "libmesh/mesh_tools.h"
33 #include "libmesh/numeric_vector.h"
34 
35 // C++ includes
36 #include <fstream>
37 #include <iomanip>
38 #include <iterator>
39 #include <algorithm>
40 
41 // Call to "uname"
42 #include <sys/utsname.h>
43 
44 template <>
47 {
49  params += validParams<SetupInterface>();
50 
51  params.addParam<bool>("use_displaced_mesh",
52  false,
53  "Whether or not this object should use the "
54  "displaced mesh for computation. Note that "
55  "in the case this is true but no "
56  "displacements are provided in the Mesh block "
57  "the undisplaced mesh will still be used.");
58  params.addParamNamesToGroup("use_displaced_mesh", "Advanced");
59 
60  std::ostringstream app_types_strings;
62  for (; it != AppFactory::instance().registeredObjectsEnd(); ++it)
63  app_types_strings << it->first << " ";
64  MooseEnum app_types_options(app_types_strings.str(), "", true);
65 
66  params.addParam<MooseEnum>("app_type",
67  app_types_options,
68  "The type of application to build (applications not "
69  "registered can be loaded with dynamic libraries. Master "
70  "application type will be used if not provided.");
71  params.addParam<std::string>("library_path",
72  "",
73  "Path to search for dynamic libraries (please "
74  "avoid committing absolute paths in addition to "
75  "MOOSE_LIBRARY_PATH)");
76  params.addParam<std::vector<Point>>(
77  "positions",
78  "The positions of the App locations. Each set of 3 values will represent a "
79  "Point. This and 'positions_file' cannot be both supplied. If this and "
80  "'positions_file' are not supplied, a single position (0,0,0) will be used");
81  params.addParam<std::vector<FileName>>("positions_file",
82  "A filename that should be looked in for positions. Each "
83  "set of 3 values in that file will represent a Point. "
84  "This and 'positions' cannot be both supplied");
85 
86  params.addRequiredParam<std::vector<FileName>>(
87  "input_files",
88  "The input file for each App. If this parameter only contains one input file "
89  "it will be used for all of the Apps. When using 'positions_from_file' it is "
90  "also admissable to provide one input_file per file.");
91  params.addParam<Real>("bounding_box_inflation",
92  0.01,
93  "Relative amount to 'inflate' the bounding box of this MultiApp.");
94 
95  params.addPrivateParam<MPI_Comm>("_mpi_comm");
96 
97  // Set the default execution time
98  params.set<MultiMooseEnum>("execute_on") = "timestep_begin";
99 
100  params.addParam<unsigned int>("max_procs_per_app",
101  std::numeric_limits<unsigned int>::max(),
102  "Maximum number of processors to give to each App in this "
103  "MultiApp. Useful for restricting small solves to just a few "
104  "procs so they don't get spread out");
105 
106  params.addParam<bool>(
107  "output_in_position",
108  false,
109  "If true this will cause the output from the MultiApp to be 'moved' by its position vector");
110 
111  params.addParam<Real>("reset_time",
112  std::numeric_limits<Real>::max(),
113  "The time at which to reset Apps given by the 'reset_apps' parameter. "
114  "Resetting an App means that it is destroyed and recreated, possibly "
115  "modeling the insertion of 'new' material for that app.");
116 
117  params.addParam<std::vector<unsigned int>>(
118  "reset_apps",
119  "The Apps that will be reset when 'reset_time' is hit. These are the App "
120  "'numbers' starting with 0 corresponding to the order of the App positions. "
121  "Resetting an App means that it is destroyed and recreated, possibly modeling "
122  "the insertion of 'new' material for that app.");
123 
124  params.addParam<Real>(
125  "move_time",
126  std::numeric_limits<Real>::max(),
127  "The time at which Apps designated by move_apps are moved to move_positions.");
128 
129  params.addParam<std::vector<unsigned int>>(
130  "move_apps",
131  "Apps, designated by their 'numbers' starting with 0 corresponding to the order "
132  "of the App positions, to be moved at move_time to move_positions");
133 
134  params.addParam<std::vector<Point>>("move_positions",
135  "The positions corresponding to each move_app.");
136 
137  params.addPrivateParam<bool>("use_positions", true);
138  params.declareControllable("enable");
139  params.registerBase("MultiApp");
140 
141  return params;
142 }
143 
145  : MooseObject(parameters),
146  SetupInterface(this),
147  Restartable(parameters, "MultiApps"),
148  _fe_problem(*parameters.getCheckedPointerParam<FEProblemBase *>("_fe_problem_base")),
149  _app_type(isParamValid("app_type") ? std::string(getParam<MooseEnum>("app_type"))
150  : _fe_problem.getMooseApp().type()),
151  _use_positions(getParam<bool>("use_positions")),
152  _input_files(getParam<std::vector<FileName>>("input_files")),
153  _total_num_apps(0),
154  _my_num_apps(0),
155  _first_local_app(0),
156  _orig_comm(getParam<MPI_Comm>("_mpi_comm")),
157  _my_comm(MPI_COMM_SELF),
158  _my_rank(0),
159  _inflation(getParam<Real>("bounding_box_inflation")),
160  _max_procs_per_app(getParam<unsigned int>("max_procs_per_app")),
161  _output_in_position(getParam<bool>("output_in_position")),
162  _reset_time(getParam<Real>("reset_time")),
163  _reset_apps(getParam<std::vector<unsigned int>>("reset_apps")),
164  _reset_happened(false),
165  _move_time(getParam<Real>("move_time")),
166  _move_apps(getParam<std::vector<unsigned int>>("move_apps")),
167  _move_positions(getParam<std::vector<Point>>("move_positions")),
168  _move_happened(false),
169  _has_an_app(true),
170  _backups(declareRestartableDataWithContext<SubAppBackups>("backups", this))
171 {
172  if (_use_positions)
173  {
174  // Fill in the _positions vector and initialize
175  fillPositions();
176  init(_positions.size());
177  }
178 }
179 
180 void
181 MultiApp::init(unsigned int num)
182 {
183  _total_num_apps = num;
184  buildComm();
185  _backups.reserve(_my_num_apps);
186  for (unsigned int i = 0; i < _my_num_apps; i++)
187  _backups.emplace_back(std::make_shared<Backup>());
188 }
189 
190 void
192 {
193  if (!_has_an_app)
194  return;
195 
197 
198  _apps.resize(_my_num_apps);
199 
200  // If the user provided an unregistered app type, see if we can load it dynamically
201  if (!AppFactory::instance().isRegistered(_app_type))
202  _app.dynamicAppRegistration(_app_type, getParam<std::string>("library_path"));
203 
204  for (unsigned int i = 0; i < _my_num_apps; i++)
206 }
207 
208 void
210 {
211  if (_move_apps.size() != _move_positions.size())
212  mooseError("The number of apps to move and the positions to move them to must be the same for "
213  "MultiApp ",
214  _name);
215 
216  if (isParamValid("positions") && isParamValid("positions_file"))
217  mooseError(
218  "Both 'positions' and 'positions_file' cannot be specified simultaneously in MultiApp ",
219  name());
220 
221  if (isParamValid("positions"))
222  {
223  _positions = getParam<std::vector<Point>>("positions");
224 
225  if (_positions.size() < _input_files.size())
226  mooseError("Not enough positions for the number of input files provided in MultiApp ",
227  name());
228  }
229  else if (isParamValid("positions_file"))
230  {
231  std::vector<FileName> positions_files = getParam<std::vector<FileName>>("positions_file");
232  std::vector<FileName> input_files = getParam<std::vector<FileName>>("input_files");
233 
234  if (input_files.size() != 1 && positions_files.size() != input_files.size())
235  mooseError("Number of input_files for MultiApp ",
236  name(),
237  " must either be only one or match the number of positions_file files");
238 
239  // Clear out the _input_files because we're going to rebuild it
240  if (input_files.size() != 1)
241  _input_files.clear();
242 
243  for (unsigned int p_file_it = 0; p_file_it < positions_files.size(); p_file_it++)
244  {
245  std::string positions_file = positions_files[p_file_it];
246 
247  std::vector<Real> positions_vec;
248 
249  // Read the file on the root processor then broadcast it
250  if (processor_id() == 0)
251  {
252  MooseUtils::checkFileReadable(positions_file);
253 
254  std::ifstream is(positions_file.c_str());
255  std::istream_iterator<Real> begin(is), end;
256  positions_vec.insert(positions_vec.begin(), begin, end);
257 
258  if (positions_vec.size() % LIBMESH_DIM != 0)
259  mooseError("Number of entries in 'positions_file' ",
260  positions_file,
261  " must be divisible by ",
262  LIBMESH_DIM,
263  " in MultiApp ",
264  name());
265  }
266 
267  // Bradcast the vector to all processors
268  std::size_t num_positions = positions_vec.size();
269  _communicator.broadcast(num_positions);
270  positions_vec.resize(num_positions);
271  _communicator.broadcast(positions_vec);
272 
273  for (unsigned int i = 0; i < positions_vec.size(); i += LIBMESH_DIM)
274  {
275  if (input_files.size() != 1)
276  _input_files.push_back(input_files[p_file_it]);
277 
278  Point position;
279 
280  // This is here so it will theoretically work with LIBMESH_DIM=1 or 2. That is completely
281  // untested!
282  for (unsigned int j = 0; j < LIBMESH_DIM; j++)
283  position(j) = positions_vec[i + j];
284 
285  _positions.push_back(position);
286  }
287  }
288  }
289  else
290  {
291  _positions = {Point()};
292 
293  if (_positions.size() < _input_files.size())
294  mooseError("Not enough positions for the number of input files provided in MultiApp ",
295  name());
296  }
297 
298  mooseAssert(_input_files.size() == 1 || _positions.size() == _input_files.size(),
299  "Number of positions and input files are not the same!");
300 }
301 
302 void
303 MultiApp::preTransfer(Real /*dt*/, Real target_time)
304 {
305  // First, see if any Apps need to be Reset
306  if (!_reset_happened && target_time + 1e-14 >= _reset_time)
307  {
308  _reset_happened = true;
309  for (auto & app : _reset_apps)
310  resetApp(app);
311  }
312 
313  // Now move any apps that should be moved
314  if (_use_positions && !_move_happened && target_time + 1e-14 >= _move_time)
315  {
316  _move_happened = true;
317  for (unsigned int i = 0; i < _move_apps.size(); i++)
319  }
320 }
321 
322 Executioner *
323 MultiApp::getExecutioner(unsigned int app)
324 {
325  if (!_has_an_app)
326  mooseError("No app for ", name(), " on processor ", _orig_rank);
327 
328  return _apps[globalAppToLocal(app)]->getExecutioner();
329 }
330 
331 void
333 {
334  for (const auto & app_ptr : _apps)
335  app_ptr->getExecutioner()->postExecute();
336 }
337 
338 void
340 {
341  for (unsigned int i = 0; i < _my_num_apps; i++)
342  _backups[i] = _apps[i]->backup();
343 }
344 
345 void
347 {
348  // Must be restarting / recovering so hold off on restoring
349  // Instead - the restore will happen in createApp()
350  // Note that _backups was already populated by dataLoad()
351  if (_apps.empty())
352  return;
353 
354  for (unsigned int i = 0; i < _my_num_apps; i++)
355  _apps[i]->restore(_backups[i]);
356 }
357 
358 BoundingBox
359 MultiApp::getBoundingBox(unsigned int app)
360 {
361  if (!_has_an_app)
362  mooseError("No app for ", name(), " on processor ", _orig_rank);
363 
364  FEProblemBase & problem = appProblemBase(app);
365 
366  BoundingBox bbox = {};
367  {
369  bbox = MeshTools::create_bounding_box(problem.mesh());
370  }
371 
372  Point min = bbox.min();
373  Point max = bbox.max();
374 
375  Point inflation_amount = (max - min) * _inflation;
376 
377  Point inflated_min = min - inflation_amount;
378  Point inflated_max = max + inflation_amount;
379 
380  // This is where the app is located. We need to shift by this amount.
381  Point p = position(app);
382 
383  Point shifted_min = inflated_min;
384  Point shifted_max = inflated_max;
385 
386  // If the problem is RZ then we're going to invent a box that would cover the whole "3D" app
387  // FIXME: Assuming all subdomains are the same coordinate system type!
388  if (problem.getCoordSystem(*(problem.mesh().meshSubdomains().begin())) == Moose::COORD_RZ)
389  {
390  shifted_min(0) = -inflated_max(0);
391  shifted_min(1) = inflated_min(1);
392  shifted_min(2) = -inflated_max(0);
393 
394  shifted_max(0) = inflated_max(0);
395  shifted_max(1) = inflated_max(1);
396  shifted_max(2) = inflated_max(0);
397  }
398 
399  // Shift them to the position they're supposed to be
400  shifted_min += p;
401  shifted_max += p;
402 
403  return BoundingBox(shifted_min, shifted_max);
404 }
405 
407 MultiApp::appProblemBase(unsigned int app)
408 {
409  if (!_has_an_app)
410  mooseError("No app for ", name(), " on processor ", _orig_rank);
411 
412  unsigned int local_app = globalAppToLocal(app);
413 
414  return _apps[local_app]->getExecutioner()->feProblem();
415 }
416 
417 FEProblem &
418 MultiApp::appProblem(unsigned int app)
419 {
421  "MultiApp::appProblem() is deprecated, call MultiApp::appProblemBase() instead.\n");
422  if (!_has_an_app)
423  mooseError("No app for ", name(), " on processor ", _orig_rank);
424 
425  unsigned int local_app = globalAppToLocal(app);
426 
427  return dynamic_cast<FEProblem &>(_apps[local_app]->getExecutioner()->feProblem());
428 }
429 
430 const UserObject &
431 MultiApp::appUserObjectBase(unsigned int app, const std::string & name)
432 {
433  if (!_has_an_app)
434  mooseError("No app for ", MultiApp::name(), " on processor ", _orig_rank);
435 
436  return appProblemBase(app).getUserObjectBase(name);
437 }
438 
439 Real
440 MultiApp::appPostprocessorValue(unsigned int app, const std::string & name)
441 {
442  if (!_has_an_app)
443  mooseError("No app for ", MultiApp::name(), " on processor ", _orig_rank);
444 
445  return appProblemBase(app).getPostprocessorValue(name);
446 }
447 
448 NumericVector<Number> &
449 MultiApp::appTransferVector(unsigned int app, std::string /*var_name*/)
450 {
452 }
453 
454 bool
455 MultiApp::hasLocalApp(unsigned int global_app)
456 {
457  if (_has_an_app && global_app >= _first_local_app &&
458  global_app <= _first_local_app + (_my_num_apps - 1))
459  return true;
460 
461  return false;
462 }
463 
464 MooseApp *
465 MultiApp::localApp(unsigned int local_app)
466 {
467  mooseAssert(local_app < _apps.size(), "Index out of range: " + Moose::stringify(local_app));
468  return _apps[local_app].get();
469 }
470 
471 void
472 MultiApp::resetApp(unsigned int global_app, Real time)
473 {
475 
476  if (hasLocalApp(global_app))
477  {
478  unsigned int local_app = globalAppToLocal(global_app);
479 
480  // Extract the file numbers from the output, so that the numbering is maintained after reset
481  std::map<std::string, unsigned int> m = _apps[local_app]->getOutputWarehouse().getFileNumbers();
482 
483  createApp(local_app, time);
484 
485  // Reset the file numbers of the newly reset apps
486  _apps[local_app]->getOutputWarehouse().setFileNumbers(m);
487  }
488 }
489 
490 void
491 MultiApp::moveApp(unsigned int global_app, Point p)
492 {
493  if (_use_positions)
494  {
495  _positions[global_app] = p;
496 
497  if (hasLocalApp(global_app))
498  {
499  unsigned int local_app = globalAppToLocal(global_app);
500 
502  _apps[local_app]->setOutputPosition(p);
503  }
504  }
505 }
506 
507 void
509 {
511  for (unsigned int i = 0; i < _apps.size(); i++)
512  _apps[i]->setOutputPosition(_app.getOutputPosition() + _positions[_first_local_app + i]);
513 }
514 
515 void
516 MultiApp::createApp(unsigned int i, Real start_time)
517 {
518 
519  // Define the app name
520  std::ostringstream multiapp_name;
521  std::string full_name;
522  multiapp_name << name() << std::setw(std::ceil(std::log10(_total_num_apps)))
523  << std::setprecision(0) << std::setfill('0') << std::right << _first_local_app + i;
524 
525  // Only add parent name if it the parent is not the main app
526  if (_app.multiAppLevel() > 0)
527  full_name = _app.name() + "_" + multiapp_name.str();
528  else
529  full_name = multiapp_name.str();
530 
532  app_params.set<FEProblemBase *>("_parent_fep") = &_fe_problem;
533  app_params.set<std::shared_ptr<CommandLine>>("_command_line") = _app.commandLine();
534  app_params.set<unsigned int>("_multiapp_level") = _app.multiAppLevel() + 1;
535  app_params.set<unsigned int>("_multiapp_number") = _first_local_app + i;
536  _apps[i].reset(AppFactory::instance().create(_app_type, full_name, app_params, _my_comm));
537  auto & app = _apps[i];
538 
539  std::string input_file = "";
540  if (_input_files.size() == 1) // If only one input file was provided, use it for all the solves
541  input_file = _input_files[0];
542  else
543  input_file = _input_files[_first_local_app + i];
544 
545  std::ostringstream output_base;
546 
547  // Create an output base by taking the output base of the master problem and appending
548  // the name of the multiapp + a number to it
549  if (!_app.getOutputFileBase().empty())
550  output_base << _app.getOutputFileBase() + "_";
551  else
552  {
553  std::string base = _app.getFileName();
554  size_t pos = base.find_last_of('.');
555  output_base << base.substr(0, pos) + "_out_";
556  }
557 
558  // Append the sub app name to the output file base
559  output_base << multiapp_name.str();
560  app->setGlobalTimeOffset(start_time);
561  app->setInputFileName(input_file);
562  app->setOutputFileBase(output_base.str());
563  app->setOutputFileNumbers(_app.getOutputWarehouse().getFileNumbers());
564  app->setRestart(_app.isRestarting());
565  app->setRecover(_app.isRecovering());
566 
567  // This means we have a backup of this app that we need to give to it
568  // Note: This won't do the restoration immediately. The Backup
569  // will be cached by the MooseApp object so that it can be used
570  // during FEProblemBase::initialSetup() during runInputFile()
571  if (_app.isRestarting() || _app.isRecovering())
572  app->restore(_backups[i]);
573 
574  if (_use_positions && getParam<bool>("output_in_position"))
575  app->setOutputPosition(_app.getOutputPosition() + _positions[_first_local_app + i]);
576 
577  // Update the MultiApp level for the app that was just created
578  app->setupOptions();
579  preRunInputFile();
580  app->runInputFile();
581 }
582 
583 void
585 {
586  int ierr;
587 
588  ierr = MPI_Comm_size(_orig_comm, &_orig_num_procs);
589  mooseCheckMPIErr(ierr);
590  ierr = MPI_Comm_rank(_orig_comm, &_orig_rank);
591  mooseCheckMPIErr(ierr);
592 
593  struct utsname sysInfo;
594  uname(&sysInfo);
595 
596  _node_name = sysInfo.nodename;
597 
598  // If we have more apps than processors then we're just going to divide up the work
599  if (_total_num_apps >= (unsigned)_orig_num_procs)
600  {
601  _my_comm = MPI_COMM_SELF;
602  _my_rank = 0;
603 
605  unsigned int jobs_left = _total_num_apps - (_my_num_apps * _orig_num_procs);
606 
607  if (jobs_left != 0)
608  {
609  // Spread the remaining jobs out over the first set of processors
610  if ((unsigned)_orig_rank < jobs_left) // (these are the "jobs_left_pids" ie the pids that are
611  // snatching up extra jobs)
612  {
613  _my_num_apps += 1;
615  }
616  else
617  {
618  unsigned int num_apps_in_jobs_left_pids = (_my_num_apps + 1) * jobs_left;
619  unsigned int distance_to_jobs_left_pids = _orig_rank - jobs_left;
620 
621  _first_local_app = num_apps_in_jobs_left_pids + (_my_num_apps * distance_to_jobs_left_pids);
622  }
623  }
624  else
626 
627  return;
628  }
629 
630  // In this case we need to divide up the processors that are going to work on each app
631  int rank;
632  ierr = MPI_Comm_rank(_orig_comm, &rank);
633  mooseCheckMPIErr(ierr);
634 
635  unsigned int procs_per_app = _orig_num_procs / _total_num_apps;
636 
637  if (_max_procs_per_app < procs_per_app)
638  procs_per_app = _max_procs_per_app;
639 
640  int my_app = rank / procs_per_app;
641  unsigned int procs_for_my_app = procs_per_app;
642 
643  if ((unsigned int)my_app > _total_num_apps - 1 && procs_for_my_app == _max_procs_per_app)
644  {
645  // If we've already hit the max number of procs per app then this processor
646  // won't have an app at all
647  _my_num_apps = 0;
648  _has_an_app = false;
649  }
650  else if ((unsigned int)my_app >=
651  _total_num_apps - 1) // The last app will gain any left-over procs
652  {
653  my_app = _total_num_apps - 1;
654  // procs_for_my_app += _orig_num_procs % _total_num_apps;
655  _first_local_app = my_app;
656  _my_num_apps = 1;
657  }
658  else
659  {
660  _first_local_app = my_app;
661  _my_num_apps = 1;
662  }
663 
664  if (_has_an_app)
665  {
666  ierr = MPI_Comm_split(_orig_comm, _first_local_app, rank, &_my_comm);
667  mooseCheckMPIErr(ierr);
668  ierr = MPI_Comm_rank(_my_comm, &_my_rank);
669  mooseCheckMPIErr(ierr);
670  }
671  else
672  {
673  ierr = MPI_Comm_split(_orig_comm, MPI_UNDEFINED, rank, &_my_comm);
674  mooseCheckMPIErr(ierr);
675  _my_rank = 0;
676  }
677 }
678 
679 unsigned int
680 MultiApp::globalAppToLocal(unsigned int global_app)
681 {
682  if (global_app >= _first_local_app && global_app <= _first_local_app + (_my_num_apps - 1))
683  return global_app - _first_local_app;
684 
685  _console << _first_local_app << " " << global_app << '\n';
686  mooseError("Invalid global_app!");
687 }
688 
689 void
691 {
692 }
const std::string & name() const
Get the name of the object.
Definition: MooseObject.h:47
registeredMooseAppIterator registeredObjectsBegin()
Returns iterators to the begin/end of the registered objects data structure: a name -> validParams fu...
Definition: AppFactory.h:129
bool hasLocalApp(unsigned int global_app)
Whether or not the given global app number is on this processor.
Definition: MultiApp.C:455
Point position(unsigned int app)
The physical position of a global App number.
Definition: MultiApp.h:222
std::vector< unsigned int > _reset_apps
The apps to be reset.
Definition: MultiApp.h:365
virtual void restore()
Restore the state of every Sub App.
Definition: MultiApp.C:346
A class for creating restricted objects.
Definition: Restartable.h:31
MultiApp(const InputParameters &parameters)
Definition: MultiApp.C:144
unsigned int _max_procs_per_app
Maximum number of processors to give to each app.
Definition: MultiApp.h:356
virtual void backup()
Save off the state of every Sub App.
Definition: MultiApp.C:339
bool isRecovering() const
Whether or not this is a "recover" calculation.
Definition: MooseApp.C:607
const bool _use_positions
Toggle use of "positions".
Definition: MultiApp.h:314
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
Definition: FEProblem.h:30
unsigned int multiAppLevel() const
The MultiApp Level.
Definition: MooseApp.h:465
Real getGlobalTimeOffset()
Each App has it&#39;s own local time.
Definition: MooseApp.h:207
Real _move_time
The time at which to move apps.
Definition: MultiApp.h:371
Real appPostprocessorValue(unsigned int app, const std::string &name)
Get a Postprocessor value for a specified global app.
Definition: MultiApp.C:440
int _orig_rank
The mpi "rank" of this processor in the original communicator.
Definition: MultiApp.h:341
const std::set< SubdomainID > & meshSubdomains() const
Returns a read-only reference to the set of subdomains currently present in the Mesh.
Definition: MooseMesh.C:2157
std::vector< std::shared_ptr< MooseApp > > _apps
Pointers to each of the Apps.
Definition: MultiApp.h:350
T & set(const std::string &name, bool quiet_mode=false)
Returns a writable reference to the named parameters.
virtual void parentOutputPositionChanged()
For apps outputting in position we need to change their output positions if their parent app moves...
Definition: MultiApp.C:508
std::vector< Point > _move_positions
The new positions for the apps to be moved.
Definition: MultiApp.h:377
Base class for MOOSE-based applications.
Definition: MooseApp.h:58
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
InputParameters validParams< SetupInterface >()
Real _inflation
Relative bounding box inflation.
Definition: MultiApp.h:353
FEProblemBase & _fe_problem
The FEProblemBase this MultiApp is part of.
Definition: MultiApp.h:305
bool _reset_happened
Whether or not apps have been reset.
Definition: MultiApp.h:368
const std::string & name() const
Get the name of the object.
Definition: MooseApp.h:70
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
int _orig_num_procs
The number of processors in the original comm.
Definition: MultiApp.h:338
virtual void preTransfer(Real dt, Real target_time)
Gets called just before transfers are done to the MultiApp (Which is just before the MultiApp is solv...
Definition: MultiApp.C:303
std::string getOutputFileBase()
Override the selection of the output file base name.
Definition: MooseApp.C:536
bool checkFileReadable(const std::string &filename, bool check_line_endings=false, bool throw_on_unreadable=true)
Checks to see if a file is readable (exists and permissions)
Definition: MooseUtils.C:121
MPI_Comm _orig_comm
The comm that was passed to us specifying our pool of processors.
Definition: MultiApp.h:332
virtual NumericVector< Number > & appTransferVector(unsigned int app, std::string var_name)
Get the vector to transfer to for this MultiApp.
Definition: MultiApp.C:449
std::shared_ptr< CommandLine > commandLine()
Get the command line.
Definition: MooseApp.h:265
Every object that can be built by the factory should be derived from this class.
Definition: MooseObject.h:36
PetscInt m
std::map< std::string, unsigned int > getFileNumbers()
Extracts the file numbers from the output objects.
virtual void fillPositions()
must fill in _positions with the positions of the sub-aps
Definition: MultiApp.C:209
bool _move_happened
Whether or not the move has happened.
Definition: MultiApp.h:380
Helper class for holding Sub-app backups.
Definition: MultiApp.h:47
Real _reset_time
The time at which to reset apps.
Definition: MultiApp.h:362
std::string _app_type
The type of application to build.
Definition: MultiApp.h:308
FEProblemBase & appProblemBase(unsigned int app)
Get the FEProblemBase for the global app is part of.
Definition: MultiApp.C:407
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition: MooseEnum.h:37
std::vector< unsigned int > _move_apps
The apps to be moved.
Definition: MultiApp.h:374
Executioners are objects that do the actual work of solving your problem.
Definition: Executioner.h:41
bool isParamValid(const std::string &name) const
Test if the supplied parameter is valid.
Definition: MooseObject.h:67
void buildComm()
Create an MPI communicator suitable for each app.
Definition: MultiApp.C:584
virtual void resetApp(unsigned int global_app, Real time=0.0)
"Reset" the App corresponding to the global App number passed in.
Definition: MultiApp.C:472
std::string stringify(const T &t)
conversion to string
Definition: Conversion.h:66
AuxiliarySystem & getAuxiliarySystem()
unsigned int _total_num_apps
The total number of apps to simulate.
Definition: MultiApp.h:323
unsigned int _my_num_apps
The number of apps this object is involved in simulating.
Definition: MultiApp.h:326
std::string _node_name
Node Name.
Definition: MultiApp.h:344
InputParameters validParams< MooseObject >()
Definition: MooseObject.C:22
static AppFactory & instance()
Get the instance of the AppFactory.
Definition: AppFactory.C:22
bool _has_an_app
Whether or not this processor as an App at all
Definition: MultiApp.h:383
SubAppBackups & _backups
Backups for each local App.
Definition: MultiApp.h:386
virtual NumericVector< Number > & solution() override
InputParameters validParams< MultiApp >()
Definition: MultiApp.C:46
void createApp(unsigned int i, Real start_time)
Helper function for creating an App instance.
Definition: MultiApp.C:516
unsigned int _first_local_app
The number of the first app on this processor.
Definition: MultiApp.h:329
void mooseDeprecated(Args &&...args) const
Definition: MooseObject.h:95
const std::string & _name
The name of this object, reference to value stored in InputParameters.
Definition: MooseObject.h:114
MatType type
MooseApp * localApp(unsigned int local_app)
Get the local MooseApp object.
Definition: MultiApp.C:465
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 init(unsigned int num)
Initialize the MultiApp by creating the provided number of apps.
Definition: MultiApp.C:181
virtual BoundingBox getBoundingBox(unsigned int app)
Get the BoundingBox for the mesh associated with app The bounding box will be shifted to be in the co...
Definition: MultiApp.C:359
Point getOutputPosition()
Get the output position.
Definition: MooseApp.h:177
MooseApp & _app
The MooseApp this object is associated with.
Definition: MooseObject.h:108
virtual Moose::CoordinateSystemType getCoordSystem(SubdomainID sid) override
FEProblem & appProblem(unsigned int app)
Get the FEProblem for the global app is part of.
Definition: MultiApp.C:418
virtual MooseMesh & mesh() override
virtual void postExecute()
Definition: MultiApp.C:332
bool _output_in_position
Whether or not to move the output of the MultiApp into position.
Definition: MultiApp.h:359
std::vector< Point > _positions
The positions of all of the apps.
Definition: MultiApp.h:311
int _my_rank
The mpi "rank" of this processor in the sub communicator.
Definition: MultiApp.h:347
PostprocessorValue & getPostprocessorValue(const PostprocessorName &name)
Get a reference to the value associated with the postprocessor.
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...
void mooseError(Args &&...args) const
Definition: MooseObject.h:80
std::vector< FileName > _input_files
The input file for each app&#39;s simulation.
Definition: MultiApp.h:317
ierr
bool isRestarting() const
Whether or not this is a "restart" calculation.
Definition: MooseApp.C:613
virtual void preRunInputFile()
call back executed right before app->runInputFile()
Definition: MultiApp.C:690
const ConsoleStream _console
An instance of helper class to write streams to the Console objects.
InputParameters getValidParams(const std::string &name)
Get valid parameters for the object.
Definition: AppFactory.C:50
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
registeredMooseAppIterator registeredObjectsEnd()
Definition: AppFactory.h:130
std::map< std::string, paramsPtr >::iterator registeredMooseAppIterator
alias for registered Object iterator
Definition: AppFactory.h:50
void dynamicAppRegistration(const std::string &app_name, std::string library_path)
Definition: MooseApp.C:885
MPI_Comm _my_comm
The MPI communicator this object is going to use.
Definition: MultiApp.h:335
const UserObject & getUserObjectBase(const std::string &name)
Get the user object by its name.
std::string getFileName(bool stripLeadingPath=true) const
Return the filename that was parsed.
Definition: MooseApp.C:834
virtual void moveApp(unsigned int global_app, Point p)
Move the global_app to Point p.
Definition: MultiApp.C:491
virtual Executioner * getExecutioner(unsigned int app)
Definition: MultiApp.C:323
Base class for user-specific data.
Definition: UserObject.h:42
OutputWarehouse & getOutputWarehouse()
Get the OutputWarehouse objects.
Definition: MooseApp.C:840
const UserObject & appUserObjectBase(unsigned int app, const std::string &name)
Get a UserObject base for a specific global app.
Definition: MultiApp.C:431
unsigned int globalAppToLocal(unsigned int global_app)
Map a global App number to the local number.
Definition: MultiApp.C:680