https://mooseframework.inl.gov
AddRayTracingObjectAction.C
Go to the documentation of this file.
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 
11 
12 // Local Includes
13 #include "RayTracingStudy.h"
14 
15 // MOOSE includes
16 #include "TheWarehouse.h"
17 
20 {
22 }
23 
25  : MooseObjectAction(params)
26 {
27 }
28 
29 void
31 {
32  RayTracingStudy * rts = nullptr;
33 
34  // Query into UserObjects
35  std::vector<UserObject *> uos;
36  auto query = _problem->theWarehouse().query().condition<AttribSystem>("UserObject");
37 
38  // Object has a study: see if it exists
40  {
41  const auto study_name = _moose_object_pars.get<UserObjectName>("study");
42  query.condition<AttribName>(study_name);
43  query.queryInto(uos);
44 
45  if (uos.empty())
46  mooseError(_type, " '", _name, "': Could not find the requested study '", study_name, "'.");
47 
48  rts = dynamic_cast<RayTracingStudy *>(uos[0]);
49  if (!rts)
51  " '",
52  _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  for (auto & uo : uos)
63  {
64  RayTracingStudy * rts_temp = dynamic_cast<RayTracingStudy *>(uo);
65  if (rts_temp)
66  {
67  if (rts)
68  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  _type,
75  " '",
76  _name,
77  "'");
78 
79  rts = rts_temp;
80  }
81  }
82 
83  if (!rts)
84  mooseError(
85  _type,
86  " '",
87  _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  _moose_object_pars.set<RayTracingStudy *>("_ray_tracing_study") = rts;
93 
95 }
static InputParameters validParams()
std::vector< std::pair< R1, R2 > > get(const std::string &param1, const std::string &param2) const
static InputParameters validParams()
T & set(const std::string &name, bool quiet_mode=false)
AddRayTracingObjectAction(const InputParameters &params)
const std::string _name
query_obj query
bool isParamSetByUser(const std::string &name) const
std::string _type
InputParameters _moose_object_pars
void mooseError(Args &&... args) const
std::shared_ptr< FEProblemBase > & _problem
virtual void addRayTracingObject()=0
Calls addObject on the problem to add the desired object after _ray_tracing_study is set in _moose_ob...
Base class for Ray tracing studies that will generate Rays and then propagate all of them to terminat...