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 "libmesh/libmesh_config.h" 13 : 14 : #ifdef LIBMESH_HAVE_FPARSER 15 : 16 : #include "GeneralUserObject.h" 17 : #include "libmesh/fparser.hh" 18 : 19 : /** 20 : * This Userobject requests termination of the current solve based on 21 : * the values of Postprocessors (and a logical expression testing them) 22 : * 23 : * <((((((\\\ 24 : * / . }\ 25 : * ;--..--._|} 26 : * (\ '--/\--' ) 27 : * \\ | '-' :'| 28 : * \\ . -==- .-| 29 : * \\ \.__.' \--._ 30 : * [\\ __.--| // _/'--. 31 : * \ \\ .'-._ ('-----'/ __/ \ 32 : * \ \\ / __>| | '--. | 33 : * \ \\ | \ | / / / 34 : * \ '\ / \ | | _/ / 35 : * \ \ \ | | / / 36 : * \ \ \ / 37 : */ 38 : class Terminator : public GeneralUserObject 39 : { 40 : public: 41 : static InputParameters validParams(); 42 : 43 : Terminator(const InputParameters & parameters); 44 : 45 : virtual void initialSetup() override; 46 2419 : virtual void initialize() override {} 47 : virtual void execute() override; 48 2415 : virtual void finalize() override {} 49 : 50 : protected: 51 : /// handle output of the optional message 52 : void handleMessage(); 53 : 54 : /// What action the terminator takes when the criteria is met 55 : const enum class FailMode { HARD, SOFT, NONE } _fail_mode; 56 : 57 : /// What logging level the terminator message is output with 58 : const enum class MessageType { INFO, WARNING, ERROR, NONE } _msg_type; 59 : 60 : /// Postprocessor names 61 : std::vector<std::string> _pp_names; 62 : 63 : // Number of postprocessors the expression depends on 64 : unsigned int _pp_num; 65 : 66 : /// Postprocessor values 67 : std::vector<const PostprocessorValue *> _pp_values; 68 : 69 : /// Expression of the criterion, to be parsed for evaluation 70 : std::string _expression; 71 : 72 : /// Fparser object 73 : FunctionParserBase<Real> _fp; 74 : 75 : /// Fparser parameter buffer 76 : std::vector<Real> _params; 77 : }; 78 : 79 : #endif // LIBMESH_HAVE_FPARSER