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