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 3705 : AddRayTracingObjectAction::validParams() 20 : { 21 3705 : return MooseObjectAction::validParams(); 22 : } 23 : 24 3705 : AddRayTracingObjectAction::AddRayTracingObjectAction(const InputParameters & params) 25 3705 : : MooseObjectAction(params) 26 : { 27 3705 : } 28 : 29 : void 30 3661 : AddRayTracingObjectAction::act() 31 : { 32 : RayTracingStudy * rts = nullptr; 33 : 34 : // Query into UserObjects 35 : std::vector<UserObject *> uos; 36 3661 : auto query = _problem->theWarehouse().query().condition<AttribSystem>("UserObject"); 37 : 38 : // Object has a study: see if it exists 39 7322 : if (_moose_object_pars.isParamSetByUser("study")) 40 : { 41 287 : const auto study_name = _moose_object_pars.get<UserObjectName>("study"); 42 287 : query.condition<AttribName>(study_name); 43 : query.queryInto(uos); 44 : 45 287 : if (uos.empty()) 46 4 : mooseError(_type, " '", _name, "': Could not find the requested study '", study_name, "'."); 47 : 48 283 : rts = dynamic_cast<RayTracingStudy *>(uos[0]); 49 283 : 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 13632 : for (auto & uo : uos) 63 : { 64 10262 : RayTracingStudy * rts_temp = dynamic_cast<RayTracingStudy *>(uo); 65 10262 : if (rts_temp) 66 : { 67 3374 : 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 3370 : 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 3645 : _moose_object_pars.set<RayTracingStudy *>("_ray_tracing_study") = rts; 93 : 94 3645 : addRayTracingObject(); 95 3633 : }