Line data Source code
1 : //* This file is part of the MOOSE framework 2 : //* https://mooseframework.inl.gov 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 : #pragma once 11 : 12 : #include "MultiApp.h" 13 : 14 : #include "libmesh/numeric_vector.h" 15 : 16 : class TransientBase; 17 : 18 : /** 19 : * MultiApp Implementation for Transient Apps. 20 : * In particular, this is important because TransientMultiApps 21 : * will be taken into account in the time step selection process. 22 : */ 23 : class TransientMultiApp : public MultiApp 24 : { 25 : public: 26 : static InputParameters validParams(); 27 : 28 : TransientMultiApp(const InputParameters & parameters); 29 : 30 : virtual NumericVector<Number> & appTransferVector(unsigned int app, 31 : std::string var_name) override; 32 : 33 : virtual void initialSetup() override; 34 : 35 : virtual bool solveStep(Real dt, Real target_time, bool auto_advance = true) override; 36 : 37 : virtual void incrementTStep(Real target_time) override; 38 : 39 : virtual void finishStep(bool recurse_through_multiapp_levels = false) override; 40 : 41 : virtual void resetApp(unsigned int global_app, Real time) override; 42 : 43 : /** 44 : * Finds the smallest dt from among any of the apps. 45 : */ 46 : Real computeDT(); 47 : 48 : private: 49 : /** 50 : * Setup the executioner for the local app. 51 : * 52 : * @param i The local app number for the app that needs to be setup. 53 : * @param time The time to set as the current time for the App 54 : */ 55 : void setupApp(unsigned int i, Real time = 0.0); 56 : 57 : std::vector<TransientBase *> _transient_executioners; 58 : 59 : bool _sub_cycling; 60 : bool _interpolate_transfers; 61 : bool _detect_steady_state; 62 : Real _steady_state_tol; 63 : bool _output_sub_cycles; 64 : 65 : unsigned int _max_failures; 66 : bool _tolerate_failure; 67 : 68 : unsigned int _failures; 69 : 70 : bool _catch_up; 71 : Real _max_catch_up_steps; 72 : 73 : /// Is it our first time through the execution loop? 74 : bool & _first; 75 : 76 : /// The variables that have been transferred to. Used when doing transfer interpolation. This will be cleared after each solve. 77 : std::vector<std::string> _transferred_vars; 78 : 79 : /// The DoFs associated with all of the currently transferred variables. 80 : std::set<dof_id_type> _transferred_dofs; 81 : 82 : std::vector<std::map<std::string, unsigned int>> _output_file_numbers; 83 : 84 : bool _auto_advance; 85 : 86 : std::set<unsigned int> _reset; 87 : 88 : /// Flag for toggling console output on sub cycles 89 : bool _print_sub_cycles; 90 : }; 91 : 92 : /** 93 : * Utility class for catching solve failure errors so that MOOSE 94 : * can recover state before continuing. 95 : */ 96 : class MultiAppSolveFailure : public std::runtime_error 97 : { 98 : public: 99 97 : MultiAppSolveFailure(const std::string & error) throw() : runtime_error(error) {} 100 : 101 : MultiAppSolveFailure(const MultiAppSolveFailure & e) throw() : runtime_error(e) {} 102 : 103 97 : ~MultiAppSolveFailure() throw() {} 104 : };