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 : // Moose includes 11 : #include "Executioner.h" 12 : 13 : #include "MooseApp.h" 14 : #include "MooseMesh.h" 15 : #include "FEProblem.h" 16 : #include "NonlinearSystem.h" 17 : #include "SlepcSupport.h" 18 : #include "SecantSolve.h" 19 : #include "SteffensenSolve.h" 20 : 21 : // C++ includes 22 : #include <vector> 23 : #include <limits> 24 : 25 : InputParameters 26 342271 : Executioner::validParams() 27 : { 28 342271 : InputParameters params = MooseObject::validParams(); 29 342271 : params += FixedPointSolve::validParams(); 30 342271 : params += Reporter::validParams(); 31 342271 : params += ReporterInterface::validParams(); 32 : 33 1026813 : params.addParam<MooseEnum>("fixed_point_algorithm", 34 684542 : iterationMethods(), 35 : "The fixed point algorithm to converge the sequence of problems."); 36 : 37 342271 : params.addParam<bool>("verbose", false, "Set to true to print additional information"); 38 : 39 342271 : params.addDeprecatedParam<FileNameNoExtension>( 40 : "restart_file_base", 41 : "", 42 : "File base name used for restart", 43 : "Please use \"Problem/restart_file_base\" instead"); 44 : 45 : // An executioner should never be disabled 46 342271 : params.suppressParameter<bool>("enable"); 47 : 48 342271 : params.registerBase("Executioner"); 49 : 50 342271 : params.addParamNamesToGroup("fixed_point_algorithm", "Fixed point iterations"); 51 342271 : params.addParamNamesToGroup("restart_file_base", "Restart"); 52 : 53 : // Whether or not this executioner supports --test-restep capability 54 342271 : params.addPrivateParam<bool>("_supports_test_restep", false); 55 : 56 342271 : return params; 57 0 : } 58 : 59 62153 : Executioner::Executioner(const InputParameters & parameters) 60 : : MooseObject(parameters), 61 : Reporter(this), 62 : ReporterInterface(this), 63 : UserObjectInterface(this), 64 : PostprocessorInterface(this), 65 : Restartable(this, "Executioners"), 66 : PerfGraphInterface(this), 67 62153 : _fe_problem(*getCheckedPointerParam<FEProblemBase *>( 68 : "_fe_problem_base", "This might happen if you don't have a mesh")), 69 62153 : _iteration_method(getParam<MooseEnum>("fixed_point_algorithm")), 70 62153 : _restart_file_base(getParam<FileNameNoExtension>("restart_file_base")), 71 186459 : _verbose(getParam<bool>("verbose")) 72 : { 73 123265 : for (const auto i : make_range(_fe_problem.numNonlinearSystems())) 74 61112 : _fe_problem.getNonlinearSystemBase(i).setVerboseFlag(_verbose); 75 : 76 62153 : if (!_restart_file_base.empty()) 77 0 : _fe_problem.setRestartFile(_restart_file_base); 78 : 79 62153 : if (!getParam<bool>("_supports_test_restep") && _app.testReStep()) 80 1793 : mooseInfo("This Executioner does not support --test-restep; solve will behave as normal"); 81 : 82 : // Instantiate the SolveObject for the MultiApp fixed point iteration algorithm 83 62153 : if (_iteration_method == "picard") 84 60903 : _fixed_point_solve = std::make_unique<PicardSolve>(*this); 85 1250 : else if (_iteration_method == "secant") 86 626 : _fixed_point_solve = std::make_unique<SecantSolve>(*this); 87 624 : else if (_iteration_method == "steffensen") 88 624 : _fixed_point_solve = std::make_unique<SteffensenSolve>(*this); 89 : 90 : // Propagate the verbosity down to the problem 91 62153 : if (_verbose) 92 1141 : _fe_problem.setVerboseProblem(_verbose); 93 62153 : } 94 : 95 88 : Executioner::Executioner(const InputParameters & parameters, bool) 96 : : MooseObject(parameters), 97 : Reporter(this), 98 : ReporterInterface(this), 99 : UserObjectInterface(this), 100 : PostprocessorInterface(this), 101 : Restartable(this, "Executioners"), 102 : PerfGraphInterface(this), 103 88 : _fe_problem(*getCheckedPointerParam<FEProblemBase *>( 104 : "_fe_problem_base", "This might happen if you don't have a mesh")), 105 88 : _iteration_method(getParam<MooseEnum>("fixed_point_algorithm")), 106 88 : _restart_file_base(getParam<FileNameNoExtension>("restart_file_base")), 107 264 : _verbose(getParam<bool>("verbose")) 108 : { 109 88 : if (!_restart_file_base.empty()) 110 0 : _fe_problem.setRestartFile(_restart_file_base); 111 : 112 88 : if (!getParam<bool>("_supports_test_restep") && _app.testReStep()) 113 0 : mooseInfo("This Executioner does not support --test-restep; solve will behave as normal"); 114 88 : } 115 : 116 : Problem & 117 0 : Executioner::problem() 118 : { 119 0 : mooseDoOnce(mooseWarning("This method is deprecated, use feProblem() instead")); 120 0 : return _fe_problem; 121 : } 122 : 123 : FEProblemBase & 124 11816367 : Executioner::feProblem() 125 : { 126 11816367 : return _fe_problem; 127 : } 128 : 129 : PostprocessorValue & 130 129 : Executioner::addAttributeReporter(const std::string & name, Real initial_value) 131 : { 132 : // Get a reference to the value 133 129 : PostprocessorValue & value = declareValueByName<PostprocessorValue>(name, initial_value); 134 : 135 : // Create storage for the old/older values 136 129 : ReporterName r_name(this->name(), name); 137 129 : getReporterValueByName<PostprocessorValue>(r_name, 1); 138 129 : getReporterValueByName<PostprocessorValue>(r_name, 2); 139 : 140 129 : return value; 141 129 : }