https://mooseframework.inl.gov
INSADEnergySource.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 
10 #include "INSADEnergySource.h"
11 #include "INSADObjectTracker.h"
12 #include "FEProblemBase.h"
13 
14 registerMooseObject("NavierStokesApp", INSADEnergySource);
15 
18 {
20  params.addClassDescription("Computes an arbitrary volumetric heat source (or sink).");
21  params.addCoupledVar(
22  "source_variable",
23  "Variable describing the volumetric heat source. Note that if this variable evaluates to a "
24  "negative number, then this object will be an energy sink");
25  params.addParam<FunctionName>(
26  "source_function",
27  "Function describing the volumetric heat source. Note that if this function evaluates to a "
28  "negative number, then this object will be an energy sink");
29  return params;
30 }
31 
33  : ADKernelValue(parameters),
34  _temperature_source_strong_residual(
35  getADMaterialProperty<Real>("temperature_source_strong_residual"))
36 {
37  bool has_coupled = isCoupled("source_variable");
38  bool has_function = isParamValid("source_function");
39  if (!has_coupled && !has_function)
40  mooseError("Either the 'source_variable' or 'source_function' param must be set for the "
41  "'INSADMomentumCoupledForce' object");
42  else if (has_coupled && has_function)
43  mooseError("Both the 'source_variable' or 'source_function' param are set for the "
44  "'INSADMomentumCoupledForce' object. Please use one or the other.");
45 
46  if (has_coupled && coupledComponents("source_variable") != 1)
47  paramError("source_variable", "Only expect one variable for the 'source_variable' parameter");
48 
49  // Bypass the UserObjectInterface method because it requires a UserObjectName param which we
50  // don't need
51  auto & obj_tracker = const_cast<INSADObjectTracker &>(
52  _fe_problem.getUserObject<INSADObjectTracker>("ins_ad_object_tracker"));
53  for (const auto block_id : blockIDs())
54  {
55  obj_tracker.set("has_heat_source", true, block_id);
56  if (has_coupled)
57  obj_tracker.set("heat_source_var", getVar("source_variable", 0)->name(), block_id);
58  else if (has_function)
59  obj_tracker.set("heat_source_function", getParam<FunctionName>("source_function"), block_id);
60  }
61 }
62 
63 ADReal
65 {
67 }
virtual bool isCoupled(const std::string &var_name, unsigned int i=0) const
T & getUserObject(const std::string &name, unsigned int tid=0) const
static InputParameters validParams()
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
const ADMaterialProperty< Real > & _temperature_source_strong_residual
void set(const std::string &name, const T &value, SubdomainID sub_id)
Set the internal parameter name to value.
MooseVariable * getVar(const std::string &var_name, unsigned int comp)
virtual const std::set< SubdomainID > & blockIDs() const
DualNumber< Real, DNDerivativeType, true > ADReal
virtual const std::string & name() const
bool isParamValid(const std::string &name) const
static InputParameters validParams()
Computes an arbitrary volumetric heat source (or sink).
FEProblemBase & _fe_problem
void paramError(const std::string &param, Args... args) const
ADReal precomputeQpResidual() override
void addCoupledVar(const std::string &name, const std::string &doc_string)
registerMooseObject("NavierStokesApp", INSADEnergySource)
unsigned int coupledComponents(const std::string &var_name) const
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
INSADEnergySource(const InputParameters &parameters)
void mooseError(Args &&... args) const
void addClassDescription(const std::string &doc_string)
Object for tracking what kernels have been added to an INSAD simulation.
unsigned int _qp