https://mooseframework.inl.gov
MassContinuityAssemblyHelper.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 "MooseTypes.h"
12 #include "MooseObject.h"
14 #include "MooseMesh.h"
15 #include "Assembly.h"
16 #include "SystemBase.h"
17 #include "TransientInterface.h"
18 
19 using namespace libMesh;
20 
23 {
25  params.addRequiredCoupledVar("interior_velocity_vars",
26  "The velocity variables on the element interiors");
27  params.addRequiredParam<std::vector<MooseFunctorName>>(
28  "face_velocity_functors", "The velocity variables on element faces/facets");
29  return params;
30 }
31 
33  const MooseObject * const moose_obj,
35  const TransientInterface * const ti,
36  const MooseMesh & mesh,
37  SystemBase & sys,
38  const Assembly & assembly,
39  const THREAD_ID tid,
40  const std::set<SubdomainID> & block_ids,
41  const std::set<BoundaryID> & boundary_ids)
43  moose_obj, mvdi, ti, sys, assembly, tid, block_ids, boundary_ids),
44  ADFunctorInterface(moose_obj),
45  _coord_sys(assembly.coordSystem()),
46  _rz_radial_coord(mesh.getAxisymmetricRadialCoord())
47 
48 {
49  for (const auto & interior_vel_var_name :
50  moose_obj->getParam<std::vector<VariableName>>("interior_velocity_vars"))
51  {
52  const auto & var = sys.getFieldVariable<Real>(tid, interior_vel_var_name);
53  _interior_vels.push_back(&var.adSln());
54  _interior_vel_grads.push_back(&var.adGradSln());
55  }
56  for (const auto & face_vel_functor_name :
57  moose_obj->getParam<std::vector<MooseFunctorName>>("face_velocity_functors"))
58  _face_vels.push_back(&getFunctorByName<ADReal>(face_vel_functor_name));
59 
60  if (mesh.dimension() != _interior_vels.size())
61  moose_obj->paramError(
62  "interior_velocity_vars",
63  "The number of interior velocity variables must be equal to the mesh dimension");
64  if (mesh.dimension() != _face_vels.size())
65  moose_obj->paramError(
66  "face_velocity_functors",
67  "The number of face velocity functors must be equal to the mesh dimension");
68 }
69 
70 void
72 {
73  for (const auto qp : make_range(_qrule->n_points()))
74  {
75  ADReal divergence = 0;
76  for (const auto d : index_range(_interior_vel_grads))
77  {
78  divergence += (*_interior_vel_grads[d])[qp](d);
81  }
82  const auto qp_term = _JxW[qp] * divergence;
83  for (const auto i : index_range(_scalar_phi))
84  _scalar_re(i) -= qp_term * _scalar_phi[i][qp];
85  }
86 }
87 
88 void
90 {
91 }
92 
93 void
95 {
96  for (const auto qp : make_range(_qrule_face->n_points()))
97  {
98  ADRealVectorValue interior_vel, face_vel;
99  for (const auto d : index_range(_interior_vels))
100  {
101  interior_vel(d) = (*_interior_vels[d])[qp];
102  face_vel(d) = (*_face_vels[d])(
104  _ti.determineState());
105  }
106  const auto qp_term = (interior_vel - face_vel) * _normals[qp] * _JxW_face[qp];
107  for (const auto i : index_range(_lm_re))
108  _lm_re(i) += _lm_phi_face[i][qp] * qp_term;
109  }
110 }
const MooseArray< Point > & _normals
const MooseArray< std::vector< Real > > & _lm_phi_face
void paramError(const std::string &param, Args... args) const
const T & getParam(const std::string &name) const
T divergence(const TensorValue< T > &gradient, const VectorType &value, const PointType &point, const Moose::CoordinateSystemType &coord_sys, const unsigned int rz_radial_coord)
Compute the divergence of a vector given its matrix of derivatives.
const unsigned int _rz_radial_coord
The radial coordinate index for RZ coordinate systems.
Moose::StateArg determineState() const
const MooseArray< std::vector< Real > > & _scalar_phi
const MooseArray< Real > & _JxW_face
std::vector< const Moose::Functor< ADReal > * > _face_vels
The velocity functors used to evalute the velocity on element face quadrature points.
MeshBase & mesh
const MooseArray< Point > & _q_point
The following methods are specializations for using the Parallel::packed_range_* routines for a vecto...
MassContinuityAssemblyHelper(const MooseObject *const moose_obj, MooseVariableDependencyInterface *const mvdi, const TransientInterface *const ti, const MooseMesh &mesh, SystemBase &sys, const Assembly &assembly, const THREAD_ID tid, const std::set< SubdomainID > &block_ids, const std::set< BoundaryID > &boundary_ids)
unsigned int n_points() const
std::vector< const ADVariableGradient * > _interior_vel_grads
The velocity gradients at interior element quadrature points.
const MooseArray< Point > & _q_point_face
const libMesh::QBase *const & _qrule
static InputParameters validParams()
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
const Moose::CoordinateSystemType _coord_sys
The coordinate system.
MooseVariableFE< T > & getFieldVariable(THREAD_ID tid, const std::string &var_name)
IntRange< T > make_range(T beg, T end)
const TransientInterface & _ti
const libMesh::QBase *const & _qrule_face
auto index_range(const T &sizable)
std::vector< const ADVariableValue * > _interior_vels
The velocities at interior element quadrature points.
const MooseArray< Real > & _JxW
unsigned int THREAD_ID