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 175112 : Executioner::validParams() 27 : { 28 175112 : InputParameters params = MooseObject::validParams(); 29 175112 : params += FixedPointSolve::validParams(); 30 175112 : params += Reporter::validParams(); 31 175112 : params += ReporterInterface::validParams(); 32 : 33 525336 : params.addParam<MooseEnum>("fixed_point_algorithm", 34 350224 : iterationMethods(), 35 : "The fixed point algorithm to converge the sequence of problems."); 36 : 37 700448 : params.addParam<bool>("verbose", false, "Set to true to print additional information"); 38 : 39 1050672 : 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 350224 : params.suppressParameter<bool>("enable"); 47 : 48 350224 : params.registerBase("Executioner"); 49 : 50 700448 : params.addParamNamesToGroup("fixed_point_algorithm", "MultiApp fixed point iterations"); 51 525336 : params.addParamNamesToGroup("restart_file_base", "Restart"); 52 : 53 : // Whether or not this executioner supports --test-restep capability 54 350224 : params.addPrivateParam<bool>("_supports_test_restep", false); 55 : 56 175112 : return params; 57 0 : } 58 : 59 61512 : 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 184536 : _fe_problem(*getCheckedPointerParam<FEProblemBase *>( 68 : "_fe_problem_base", "This might happen if you don't have a mesh")), 69 123024 : _iteration_method(getParam<MooseEnum>("fixed_point_algorithm")), 70 123024 : _restart_file_base(getParam<FileNameNoExtension>("restart_file_base")), 71 430584 : _verbose(getParam<bool>("verbose")) 72 : { 73 122260 : for (const auto i : make_range(_fe_problem.numNonlinearSystems())) 74 60748 : _fe_problem.getNonlinearSystemBase(i).setVerboseFlag(_verbose); 75 : 76 61512 : if (!_restart_file_base.empty()) 77 0 : _fe_problem.setRestartFile(_restart_file_base); 78 : 79 184536 : if (!getParam<bool>("_supports_test_restep") && _app.testReStep()) 80 2024 : 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 61512 : if (_iteration_method == "picard") 84 60362 : _fixed_point_solve = std::make_unique<PicardSolve>(*this); 85 1150 : else if (_iteration_method == "secant") 86 576 : _fixed_point_solve = std::make_unique<SecantSolve>(*this); 87 574 : else if (_iteration_method == "steffensen") 88 574 : _fixed_point_solve = std::make_unique<SteffensenSolve>(*this); 89 61512 : } 90 : 91 75 : Executioner::Executioner(const InputParameters & parameters, bool) 92 : : MooseObject(parameters), 93 : Reporter(this), 94 : ReporterInterface(this), 95 : UserObjectInterface(this), 96 : PostprocessorInterface(this), 97 : Restartable(this, "Executioners"), 98 : PerfGraphInterface(this), 99 225 : _fe_problem(*getCheckedPointerParam<FEProblemBase *>( 100 : "_fe_problem_base", "This might happen if you don't have a mesh")), 101 150 : _iteration_method(getParam<MooseEnum>("fixed_point_algorithm")), 102 150 : _restart_file_base(getParam<FileNameNoExtension>("restart_file_base")), 103 525 : _verbose(getParam<bool>("verbose")) 104 : { 105 75 : if (!_restart_file_base.empty()) 106 0 : _fe_problem.setRestartFile(_restart_file_base); 107 : 108 225 : if (!getParam<bool>("_supports_test_restep") && _app.testReStep()) 109 0 : mooseInfo("This Executioner does not support --test-restep; solve will behave as normal"); 110 75 : } 111 : 112 : Problem & 113 0 : Executioner::problem() 114 : { 115 0 : mooseDoOnce(mooseWarning("This method is deprecated, use feProblem() instead")); 116 0 : return _fe_problem; 117 : } 118 : 119 : FEProblemBase & 120 10927971 : Executioner::feProblem() 121 : { 122 10927971 : return _fe_problem; 123 : } 124 : 125 : PostprocessorValue & 126 113 : Executioner::addAttributeReporter(const std::string & name, Real initial_value) 127 : { 128 : // Get a reference to the value 129 113 : PostprocessorValue & value = declareValueByName<PostprocessorValue>(name, initial_value); 130 : 131 : // Create storage for the old/older values 132 113 : ReporterName r_name(this->name(), name); 133 113 : getReporterValueByName<PostprocessorValue>(r_name, 1); 134 113 : getReporterValueByName<PostprocessorValue>(r_name, 2); 135 : 136 113 : return value; 137 113 : }