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 333199 : Executioner::validParams() 27 : { 28 333199 : InputParameters params = MooseObject::validParams(); 29 333199 : params += FixedPointSolve::validParams(); 30 333199 : params += Reporter::validParams(); 31 333199 : params += ReporterInterface::validParams(); 32 : 33 999597 : params.addParam<MooseEnum>("fixed_point_algorithm", 34 666398 : iterationMethods(), 35 : "The fixed point algorithm to converge the sequence of problems."); 36 : 37 333199 : params.addParam<bool>("verbose", false, "Set to true to print additional information"); 38 : 39 333199 : 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 333199 : params.registerBase("Executioner"); 46 : 47 333199 : params.addParamNamesToGroup("fixed_point_algorithm", "Fixed point iterations"); 48 333199 : params.addParamNamesToGroup("restart_file_base", "Restart"); 49 : 50 333199 : return params; 51 0 : } 52 : 53 57629 : Executioner::Executioner(const InputParameters & parameters) 54 : : MooseObject(parameters), 55 : Reporter(this), 56 : ReporterInterface(this), 57 : UserObjectInterface(this), 58 : PostprocessorInterface(this), 59 : Restartable(this, "Executioners"), 60 : PerfGraphInterface(this), 61 57629 : _fe_problem(*getCheckedPointerParam<FEProblemBase *>( 62 : "_fe_problem_base", "This might happen if you don't have a mesh")), 63 57629 : _iteration_method(getParam<MooseEnum>("fixed_point_algorithm")), 64 57629 : _restart_file_base(getParam<FileNameNoExtension>("restart_file_base")), 65 172887 : _verbose(getParam<bool>("verbose")) 66 : { 67 114383 : for (const auto i : make_range(_fe_problem.numNonlinearSystems())) 68 56754 : _fe_problem.getNonlinearSystemBase(i).setVerboseFlag(_verbose); 69 : 70 57629 : if (!_restart_file_base.empty()) 71 0 : _fe_problem.setRestartFile(_restart_file_base); 72 : 73 : // Instantiate the SolveObject for the MultiApp fixed point iteration algorithm 74 57629 : if (_iteration_method == "picard") 75 56477 : _fixed_point_solve = std::make_unique<PicardSolve>(*this); 76 1152 : else if (_iteration_method == "secant") 77 576 : _fixed_point_solve = std::make_unique<SecantSolve>(*this); 78 576 : else if (_iteration_method == "steffensen") 79 576 : _fixed_point_solve = std::make_unique<SteffensenSolve>(*this); 80 : 81 : // Propagate the verbosity down to the problem 82 57629 : if (_verbose) 83 1077 : _fe_problem.setVerboseProblem(_verbose); 84 57629 : } 85 : 86 88 : Executioner::Executioner(const InputParameters & parameters, bool) 87 : : MooseObject(parameters), 88 : Reporter(this), 89 : ReporterInterface(this), 90 : UserObjectInterface(this), 91 : PostprocessorInterface(this), 92 : Restartable(this, "Executioners"), 93 : PerfGraphInterface(this), 94 88 : _fe_problem(*getCheckedPointerParam<FEProblemBase *>( 95 : "_fe_problem_base", "This might happen if you don't have a mesh")), 96 88 : _iteration_method(getParam<MooseEnum>("fixed_point_algorithm")), 97 88 : _restart_file_base(getParam<FileNameNoExtension>("restart_file_base")), 98 264 : _verbose(getParam<bool>("verbose")) 99 : { 100 88 : if (!_restart_file_base.empty()) 101 0 : _fe_problem.setRestartFile(_restart_file_base); 102 88 : } 103 : 104 : Problem & 105 0 : Executioner::problem() 106 : { 107 0 : mooseDoOnce(mooseWarning("This method is deprecated, use feProblem() instead")); 108 0 : return _fe_problem; 109 : } 110 : 111 : FEProblemBase & 112 11251047 : Executioner::feProblem() 113 : { 114 11251047 : return _fe_problem; 115 : } 116 : 117 : PostprocessorValue & 118 118 : Executioner::addAttributeReporter(const std::string & name, Real initial_value) 119 : { 120 : // Get a reference to the value 121 118 : PostprocessorValue & value = declareValueByName<PostprocessorValue>(name, initial_value); 122 : 123 : // Create storage for the old/older values 124 118 : ReporterName r_name(this->name(), name); 125 118 : getReporterValueByName<PostprocessorValue>(r_name, 1); 126 118 : getReporterValueByName<PostprocessorValue>(r_name, 2); 127 : 128 118 : return value; 129 118 : }