https://mooseframework.inl.gov
INSADMomentumCoupledForce.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 #include "INSADObjectTracker.h"
12 #include "FEProblemBase.h"
13 
15 
18 {
20  params.addClassDescription(
21  "Computes a body force due to a coupled vector variable or a vector function");
22  params.addCoupledVar(
23  "coupled_vector_var",
24  "The coupled vector variable applying the force. Positive variable components represent "
25  "momentum sources in that component direction, e.g. if the x-component is positive then this "
26  "object imposes a momentum source in the +x direction. Multiple variable names can be "
27  "provided; the result will be a summed force.");
28  params.addParam<std::vector<FunctionName>>(
29  "vector_function",
30  "A vector function which can be used to stand-in for the 'coupled_vector_var' param. "
31  "Multiple function names can be provided; the result will be a summed force");
32  return params;
33 }
34 
36  : ADVectorKernelValue(parameters),
37  _coupled_force_strong_residual(
38  getADMaterialProperty<RealVectorValue>("coupled_force_strong_residual"))
39 {
40  bool has_coupled = isCoupled("coupled_vector_var");
41  bool has_function = isParamValid("vector_function");
42  if (!has_coupled && !has_function)
43  mooseError("Either the 'coupled_vector_var' or 'vector_function' param must be set for the "
44  "'INSADMomentumCoupledForce' object");
45 
46  // Bypass the UserObjectInterface method because it requires a UserObjectName param which we
47  // don't need
48  auto & obj_tracker = const_cast<INSADObjectTracker &>(
49  _fe_problem.getUserObject<INSADObjectTracker>("ins_ad_object_tracker"));
50  for (const auto block_id : blockIDs())
51  {
52  obj_tracker.set("has_coupled_force", true, block_id);
53  if (has_coupled)
54  obj_tracker.set(
55  "coupled_force_var", getParam<std::vector<VariableName>>("coupled_vector_var"), block_id);
56  if (has_function)
57  obj_tracker.set("coupled_force_vector_function",
58  getParam<std::vector<FunctionName>>("vector_function"),
59  block_id);
60  }
61 }
62 
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)
void set(const std::string &name, const T &value, SubdomainID sub_id)
Set the internal parameter name to value.
registerMooseObject("NavierStokesApp", INSADMomentumCoupledForce)
virtual const std::set< SubdomainID > & blockIDs() const
bool isParamValid(const std::string &name) const
FEProblemBase & _fe_problem
const T & getParam(const std::string &name) const
ADRealVectorValue precomputeQpResidual() override
INSADMomentumCoupledForce(const InputParameters &parameters)
void addCoupledVar(const std::string &name, const std::string &doc_string)
const ADMaterialProperty< RealVectorValue > & _coupled_force_strong_residual
Computes a body force due to a coupled vector variable or vector function.
static InputParameters validParams()
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