18#include "libmesh/communicator.h"
19#include "libmesh/point.h"
21#include "nlohmann/json.h"
89 processor_id_type nprocs,
91 processor_id_type min_app_procs,
92 processor_id_type max_app_procs,
93 bool batch_mode =
false);
155 virtual void preTransfer(Real dt, Real target_time);
170 virtual bool solveStep(Real dt, Real target_time,
bool auto_advance =
true) = 0;
204 virtual void restore(
bool force =
true);
273 std::string var_name);
318 const Point &
position(
unsigned int app)
const;
332 virtual void resetApp(
unsigned int global_app, Real time = 0.0);
340 virtual void moveApp(
unsigned int global_app, Point p);
390 virtual std::vector<std::string>
cliArgs()
const;
408 void createApp(
unsigned int i, Real start_time);
455 void init(
unsigned int num_apps,
bool batch_mode =
false);
492 getMultiAppName(
const std::string & base_name, dof_id_type index, dof_id_type total);
554 std::vector<std::shared_ptr<MooseApp>>
_apps;
621 std::vector<std::vector<std::unique_ptr<libMesh::NumericVector<Real>>>>
_end_solutions;
LocalRankConfig rankConfig(processor_id_type rank, processor_id_type nprocs, dof_id_type napps, processor_id_type min_app_procs, processor_id_type max_app_procs, bool batch_mode=false)
Returns app partitioning information relevant to the given rank for a multiapp scenario with the give...
void dataStore(std::ostream &stream, SubAppBackups &backups, void *context)
void dataLoad(std::istream &stream, SubAppBackups &backups, void *context)
Executioners are objects that do the actual work of solving your problem.
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
Base class for MOOSE-based applications.
const InputParameters & parameters() const
Get the parameters of the object.
const std::string & name() const
Get the name of the class.
Every object that can be built by the factory should be derived from this class.
Base class for all MultiAppTransfer objects.
A MultiApp represents one or more MOOSE applications that are running simultaneously.
std::vector< Real > _reset_times
The times at which to reset apps.
bool hasApp()
Whether or not this MultiApp has an app on this processor.
virtual void postExecute()
Method called at the end of the simulation (after finalize).
libMesh::Parallel::Communicator _my_communicator
The communicator object that holds the MPI_Comm that we're going to use.
virtual void finalize()
Method called towards the end of the simulation to execute on final.
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...
std::vector< std::string > _cli_args_from_file
CommandLine arguments from files.
const bool & _wait_for_first_app_init
Whether to create the first app on rank 0 while all other MPI ranks are idle.
bool usingPositions() const
Whether or not this MultiApp is using positions or its own way for constructing sub-apps.
bool runningInPosition() const
Whether or not this MultiApp is being run in position, eg with the coordinate transform already appli...
virtual std::vector< std::string > cliArgs() const
function that provides cli_args to subapps
void buildComm()
Create an MPI communicator suitable for each app.
Real _inflation
Relative bounding box inflation.
unsigned int numLocalApps()
std::vector< unsigned int > _positions_index_offsets
The offsets, in case multiple Positions objects are specified.
void keepSolutionDuringRestore(bool keep_solution_during_restore)
Preserve the solution from the previous simulation, and it is used as an initial guess for the next r...
bool _output_in_position
Whether or not to move the output of the MultiApp into position.
std::vector< bool > _has_bounding_box
Flag if this multi-app computed its bounding box (valid only for non-displaced meshes)
processor_id_type _min_procs_per_app
Minimum number of processors to give to each app.
bool isRootProcessor()
Whether or not this processor is the "root" processor for the sub communicator.
virtual void resetApp(unsigned int global_app, Real time=0.0)
"Reset" the App corresponding to the global App number passed in.
FEProblemBase & appProblemBase(unsigned int app)
Get the FEProblemBase for the global app desired.
bool isFirstLocalRank() const
std::string _app_type
The type of application to build.
int _my_rank
The mpi "rank" of this processor in the sub communicator.
virtual void restore(bool force=true)
Restore the state of every Sub App.
virtual void moveApp(unsigned int global_app, Point p)
Move the global_app to Point p.
const Real _global_time_offset
The offset time so the MultiApp local time relative to the global time.
Real _move_time
The time at which to move apps.
bool needsRestoration()
Whether or not this MultiApp should be restored at the beginning of each Picard iteration.
const PerfID _backup_timer
void createApp(unsigned int i, Real start_time)
Helper function for creating an App instance.
static std::string getMultiAppName(const std::string &base_name, dof_id_type index, dof_id_type total)
Helper for constructing the name of the multiapp.
int _orig_num_procs
The number of processors in the original comm.
std::vector< libMesh::BoundingBox > _bounding_box
This multi-app's bounding box.
std::vector< unsigned int > _npositions_inputfile
Number of positions for each input file.
std::optional< std::string > _cli_args_param
The parameter that was used to set the command line args, if any.
void setupPositions()
Called just after construction to allow derived classes to set _positions and create sub-apps accordi...
virtual void initialSetup() override
Method to be called in main-app initial setup for create sub-apps if using positions is false.
std::vector< MultiAppTransfer * > _associated_transfers
Transfers associated with this multiapp.
virtual void incrementTStep(Real)
Advances the multi-apps time step which is important for dt selection.
MPI_Comm & _my_comm
The MPI communicator this object is going to use.
bool hasLocalApp(unsigned int global_app) const
Whether or not the given global app number is on this processor.
virtual void preRunInputFile()
call back executed right before app->runInputFile()
const PerfID _restore_timer
unsigned int _first_local_app
The number of the first app on this processor.
Point _bounding_box_padding
Additional padding added to the bounding box, useful for 1D meshes.
std::vector< const Positions * > _positions_objs
The positions of all of the apps, using the Positions system.
const Point & position(unsigned int app) const
The physical position of a global App number.
bool _has_an_app
Whether or not this processor as an App at all
processor_id_type _max_procs_per_app
Maximum number of processors to give to each app.
bool _move_happened
Whether or not the move has happened.
void createApps()
Create the provided number of apps.
bool _keep_aux_solution_during_restore
Flag indicates if or not restart the auxiliary system from the latest auxiliary solution.
std::vector< std::vector< std::unique_ptr< libMesh::NumericVector< Real > > > > _end_solutions
The solution from the end of the previous solve, this is cloned from the Nonlinear solution during re...
std::vector< unsigned int > _move_apps
The apps to be moved.
virtual void finishStep(bool=false)
Calls multi-apps executioners' endStep and postStep methods which creates output and advances time (n...
const PerfID _solve_step_timer
Timers.
int _orig_rank
The mpi "rank" of this processor in the original communicator.
MPI_Comm & comm()
Get the MPI communicator this MultiApp is operating on.
FEProblem & appProblem(unsigned int app)
Get the FEProblem for the global app is part of.
virtual void backup()
Save off the state of every Sub App.
const bool _no_restore
Whether or not to skip restoring completely.
const bool _use_positions
Toggle use of "positions".
void readCommandLineArguments()
Fill command line arguments for sub apps.
void init(unsigned int num_apps, bool batch_mode=false)
Build communicators and reserve backups.
bool _keep_solution_during_restore
Flag indicates if or not restart from the latest solution.
static InputParameters validParams()
virtual void preExecute()
std::string _output_base
The output file basename for each multiapp.
Real appPostprocessorValue(unsigned int app, const std::string &name)
Get a Postprocessor value for a specified global app.
void addAssociatedTransfer(MultiAppTransfer &transfer)
Add a transfer that is associated with this multiapp.
unsigned int firstLocalApp()
const MPI_Comm & _orig_comm
The original comm handle.
FEProblemBase & _fe_problem
The FEProblemBase this MultiApp is part of.
unsigned int _total_num_apps
The total number of apps to simulate.
unsigned int globalAppToLocal(unsigned int global_app)
Map a global App number to the local number.
SubAppBackups & _sub_app_backups
The cached subapp backups (passed from the parent app)
std::vector< std::shared_ptr< MooseApp > > _apps
Pointers to each of the Apps.
std::vector< bool > _reset_happened
Whether or not apps have been reset at each time.
MooseApp * localApp(unsigned int local_app)
Get the local MooseApp object.
void setAppOutputFileBase()
Sets all the app's output file bases.
virtual std::vector< std::string > getCommandLineArgs(const unsigned int local_app)
const UserObject & appUserObjectBase(unsigned int app, const std::string &name)
Get a UserObject base for a specific global app.
LocalRankConfig _rank_config
The app configuration resulting from calling init.
std::vector< std::unique_ptr< NumericVector< Real > > > _end_aux_solutions
The auxiliary solution from the end of the previous solve, this is cloned from the auxiliary solution...
virtual bool propagateRecoverToSubApps() const
Whether or not to propagate the parent's recover state (the –recover and –test-checkpoint-half-transi...
std::string _node_name
Node Name.
FEProblemBase & problemBase()
Get the FEProblemBase this MultiApp is part of.
virtual void fillPositions()
must fill in _positions with the positions of the sub-aps
unsigned int _my_num_apps
The number of apps this object is involved in simulating.
virtual Executioner * getExecutioner(unsigned int app)
const PerfID _reset_timer
const std::vector< CLIArgString > & _cli_args
CommandLine arguments (controllable!)
std::vector< FileName > _input_files
The input file for each app's simulation.
unsigned int numGlobalApps() const
virtual void createLocalApp(const unsigned int i)
Create the i-th local app.
std::vector< Point > _move_positions
The new positions for the apps to be moved.
std::vector< Point > _positions
The positions of all of the apps, using input constant vectors (to be deprecated)
virtual libMesh::NumericVector< libMesh::Number > & appTransferVector(unsigned int app, std::string var_name)
Get the vector to transfer to for this MultiApp.
virtual void parentOutputPositionChanged()
For apps outputting in position we need to change their output positions if their parent app moves.
virtual bool solveStep(Real dt, Real target_time, bool auto_advance=true)=0
Re-solve all of the Apps.
const bool _run_in_position
Whether to run the child apps with their meshes transformed with the coordinate transforms.
static void transformBoundingBox(libMesh::BoundingBox &box, const MultiAppCoordTransform &transform)
Transform a bounding box according to the transformations in the provided coordinate transformation o...
virtual libMesh::BoundingBox getBoundingBox(unsigned int app, bool displaced_mesh, const MultiAppCoordTransform *coord_transform=nullptr)
Get the BoundingBox for the mesh associated with app The bounding box will be shifted to be in the co...
std::vector< unsigned int > _reset_apps
The apps to be reset.
Interface for objects interacting with the PerfGraph.
Positions objects are under the hood Reporters.
A class for creating restricted objects.
Helper class for holding Sub-app backups.
Base class for user-specific data.
The following methods are specializations for using the libMesh::Parallel::packed_range_* routines fo...
Holds app partitioning information relevant to the a particular rank for a multiapp scenario.
dof_id_type num_local_sims
The number of simulations that should/will be run locally on this rank.
dof_id_type first_local_sim_index
The (global) index of the first local simulation for this rank.
processor_id_type my_first_rank
For every rank working on a subapp, we store the first rank on each process to make the communication...
bool is_first_local_rank
This is true if this rank is the primary/zero rank for a (sub)app slot.
dof_id_type num_local_apps
The number of (sub)apps that should/will be run locally on this rank.
dof_id_type first_local_app_index
The (global) index of the first local app for this rank.