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 "AddRayTracingObjectAction.h" 11 : 12 : // Local Includes 13 : #include "RayTracingStudy.h" 14 : 15 : // MOOSE includes 16 : #include "TheWarehouse.h" 17 : 18 : InputParameters 19 7256 : AddRayTracingObjectAction::validParams() 20 : { 21 7256 : return MooseObjectAction::validParams(); 22 : } 23 : 24 7256 : AddRayTracingObjectAction::AddRayTracingObjectAction(const InputParameters & params) 25 7256 : : MooseObjectAction(params) 26 : { 27 7256 : } 28 : 29 : void 30 7212 : AddRayTracingObjectAction::act() 31 : { 32 : RayTracingStudy * rts = nullptr; 33 : 34 : // Query into UserObjects 35 : std::vector<UserObject *> uos; 36 7212 : auto query = _problem->theWarehouse().query().condition<AttribSystem>("UserObject"); 37 : 38 : // Object has a study: see if it exists 39 14424 : if (_moose_object_pars.isParamSetByUser("study")) 40 : { 41 581 : const auto study_name = _moose_object_pars.get<UserObjectName>("study"); 42 581 : query.condition<AttribName>(study_name); 43 : query.queryInto(uos); 44 : 45 581 : if (uos.empty()) 46 4 : mooseError(_type, " '", _name, "': Could not find the requested study '", study_name, "'."); 47 : 48 577 : rts = dynamic_cast<RayTracingStudy *>(uos[0]); 49 577 : if (!rts) 50 4 : mooseError(_type, 51 : " '", 52 4 : _name, 53 : "' requested the study ", 54 : study_name, 55 : " but the provided study is not a RayTracingStudy-derived object."); 56 : } 57 : // Object doesn't have a study: find one and only one study to associate with it 58 : else 59 : { 60 : query.queryInto(uos); 61 : 62 27597 : for (auto & uo : uos) 63 : { 64 20970 : RayTracingStudy * rts_temp = dynamic_cast<RayTracingStudy *>(uo); 65 20970 : if (rts_temp) 66 : { 67 6631 : if (rts) 68 4 : mooseError("While constructing the ", 69 : _type, 70 : " '", 71 : _name, 72 : "', multiple RayTracingStudy objects were found.\n\nYou must associate one " 73 : "of the RayTracingStudy objects by setting the 'study' parameter in ", 74 4 : _type, 75 : " '", 76 4 : _name, 77 : "'"); 78 : 79 : rts = rts_temp; 80 : } 81 : } 82 : 83 6627 : if (!rts) 84 4 : mooseError( 85 4 : _type, 86 : " '", 87 4 : _name, 88 : "' did not provide a RayTracingStudy to associate with via the 'study' parameter " 89 : "and a study was not found.\n\nYou must add a RayTracingStudy to use said object."); 90 : } 91 : 92 7196 : _moose_object_pars.set<RayTracingStudy *>("_ray_tracing_study") = rts; 93 : 94 7196 : addRayTracingObject(); 95 7184 : }