https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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
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
DualNumber< Real, DNDerivativeType, true > ADReal
registerMooseObject("NavierStokesApp", INSADEnergySource)
static InputParameters validParams()
virtual const std::set< SubdomainID > & blockIDs() const
MooseVariable * getVar(const std::string &var_name, unsigned int comp)
unsigned int coupledComponents(const std::string &var_name) const
virtual bool isCoupled(const std::string &var_name, unsigned int i=0) const
T & getUserObject(const std::string &name, unsigned int tid=0) const
Computes an arbitrary volumetric heat source (or sink).
INSADEnergySource(const InputParameters &parameters)
ADReal precomputeQpResidual() override
const ADMaterialProperty< Real > & _temperature_source_strong_residual
static InputParameters validParams()
Object for tracking what kernels have been added to an INSAD simulation.
void set(const std::string &name, const T &value, SubdomainID sub_id)
Set the internal parameter name to value.
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
void addClassDescription(const std::string &doc_string)
void addCoupledVar(const std::string &name, const std::string &doc_string)
unsigned int _qp
const std::string & name() const
void paramError(const std::string &param, Args... args) const
void mooseError(Args &&... args) const
bool isParamValid(const std::string &name) const
FEProblemBase & _fe_problem