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 : #include "SurrogateModelInterface.h" 11 : #include "SurrogateTrainer.h" 12 : #include "SurrogateModel.h" 13 : #include "SubProblem.h" 14 : #include "MooseTypes.h" 15 : 16 : InputParameters 17 12650 : SurrogateModelInterface::validParams() 18 : { 19 12650 : return emptyInputParameters(); 20 : } 21 : 22 5483 : SurrogateModelInterface::SurrogateModelInterface(const MooseObject * moose_object) 23 5483 : : _smi_params(moose_object->parameters()), 24 5483 : _smi_feproblem(*_smi_params.get<FEProblemBase *>("_fe_problem_base")), 25 5483 : _smi_tid(_smi_params.have_parameter<THREAD_ID>("_tid") ? _smi_params.get<THREAD_ID>("_tid") : 0) 26 : { 27 5483 : } 28 : 29 : template <> 30 : SurrogateModel & 31 1294 : SurrogateModelInterface::getSurrogateModelByName(const UserObjectName & name) const 32 : { 33 : std::vector<SurrogateModel *> models; 34 1294 : _smi_feproblem.theWarehouse() 35 1294 : .query() 36 1294 : .condition<AttribName>(name) 37 1294 : .condition<AttribSystem>("SurrogateModel") 38 : .queryInto(models); 39 1294 : if (models.empty()) 40 0 : mooseError("Unable to find a SurrogateModel object with the name '" + name + "'"); 41 1294 : return *(models[0]); 42 1294 : } 43 : 44 : template <> 45 : SurrogateModel & 46 58 : SurrogateModelInterface::getSurrogateModel(const std::string & name) const 47 : { 48 58 : return getSurrogateModelByName<SurrogateModel>(_smi_params.get<UserObjectName>(name)); 49 : } 50 : 51 : template <> 52 : SurrogateTrainerBase & 53 1265 : SurrogateModelInterface::getSurrogateTrainerByName(const UserObjectName & name) const 54 : { 55 1265 : return _smi_feproblem.getUserObject<SurrogateTrainerBase>(name); 56 : } 57 : 58 : template <> 59 : SurrogateTrainerBase & 60 0 : SurrogateModelInterface::getSurrogateTrainer(const std::string & name) const 61 : { 62 0 : return getSurrogateTrainerByName<SurrogateTrainerBase>(_smi_params.get<UserObjectName>(name)); 63 : }