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 "GeneralReporter.h" 13 : #include "OptimizeSolve.h" 14 : 15 : class Optimize; 16 : 17 : class OptimizationInfo : public GeneralReporter 18 : { 19 : public: 20 : static InputParameters validParams(); 21 : 22 : OptimizationInfo(const InputParameters & parameters); 23 : 24 2556 : virtual void initialize() override {} 25 : virtual void execute() override; 26 2556 : virtual void finalize() override {} 27 : 28 : private: 29 : Optimize * _optimization_executioner = nullptr; 30 : const MultiMooseEnum & _items; 31 : 32 : std::vector<double> & _functionValue; 33 : std::vector<double> & _gnorm; 34 : std::vector<double> & _cnorm; 35 : std::vector<double> & _xdiff; 36 : std::vector<int> & _currentIterate; 37 : std::vector<int> & _objectiveIterate; 38 : std::vector<int> & _gradientIterate; 39 : std::vector<int> & _hessianIterate; 40 : std::vector<int> & _functionSolves; 41 : 42 : // Helper to perform optional declaration based on "_items" from MeshInfo.h 43 : template <typename T> 44 : T & declareHelper(const std::string & item_name, const ReporterMode mode); 45 : }; 46 : 47 : template <typename T> 48 : T & 49 540 : OptimizationInfo::declareHelper(const std::string & item_name, const ReporterMode mode) 50 : { 51 540 : if (!_items.isValid() || _items.isValueSet(item_name)) 52 : { 53 1872 : return declareValueByName<T>(item_name, mode); 54 : } 55 : 56 72 : return declareUnusedValue<T>(); 57 : }