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 
16 using namespace libMesh;
17 
20 {
21  auto params = IPHDGAssemblyHelper::validParams();
22  params.addRequiredCoupledVar("interior_velocity_vars",
23  "The velocity variables on the element interiors");
24  params.addRequiredParam<std::vector<MooseFunctorName>>(
25  "face_velocity_functors", "The velocity variables on element faces/facets");
26  return params;
27 }
28 
30  const MooseObject * const moose_obj,
32  const TransientInterface * const ti,
33  const MooseMesh & mesh,
34  SystemBase & sys,
35  const Assembly & assembly,
36  const THREAD_ID tid,
37  const std::set<SubdomainID> & block_ids,
38  const std::set<BoundaryID> & boundary_ids)
39  : IPHDGAssemblyHelper(moose_obj, mvdi, ti, sys, assembly, tid, block_ids, boundary_ids),
40  ADFunctorInterface(moose_obj),
41  _coord_sys(assembly.coordSystem()),
42  _rz_radial_coord(mesh.getAxisymmetricRadialCoord())
43 
44 {
45  for (const auto & interior_vel_var_name :
46  moose_obj->getParam<std::vector<VariableName>>("interior_velocity_vars"))
47  {
48  const auto & var = sys.getFieldVariable<Real>(tid, interior_vel_var_name);
49  _interior_vels.push_back(&var.adSln());
50  _interior_vel_grads.push_back(&var.adGradSln());
51  }
52  for (const auto & face_vel_functor_name :
53  moose_obj->getParam<std::vector<MooseFunctorName>>("face_velocity_functors"))
54  _face_vels.push_back(&getFunctorByName<ADReal>(face_vel_functor_name));
55 
56  if (mesh.dimension() != _interior_vels.size())
57  moose_obj->paramError(
58  "interior_velocity_vars",
59  "The number of interior velocity variables must be equal to the mesh dimension");
60  if (mesh.dimension() != _face_vels.size())
61  moose_obj->paramError(
62  "face_velocity_functors",
63  "The number of face velocity functors must be equal to the mesh dimension");
64 }
65 
66 void
68 {
69  for (const auto qp : make_range(_ip_qrule->n_points()))
70  {
71  ADReal divergence = 0;
72  for (const auto d : index_range(_interior_vel_grads))
73  {
74  divergence += (*_interior_vel_grads[d])[qp](d);
77  }
78  const auto qp_term = _ip_JxW[qp] * divergence;
79  for (const auto i : index_range(_scalar_phi))
80  _scalar_re(i) -= qp_term * _scalar_phi[i][qp];
81  }
82 }
83 
84 void
86 {
87 }
88 
89 void
91 {
92  for (const auto qp : make_range(_ip_qrule_face->n_points()))
93  {
94  ADRealVectorValue interior_vel, face_vel;
95  for (const auto d : index_range(_interior_vels))
96  {
97  interior_vel(d) = (*_interior_vels[d])[qp];
98  face_vel(d) = (*_face_vels[d])(
101  _ti.determineState());
102  }
103  const auto qp_term = (interior_vel - face_vel) * _ip_normals[qp] * _ip_JxW_face[qp];
104  for (const auto i : index_range(_lm_re))
105  _lm_re(i) += _lm_phi_face[i][qp] * qp_term;
106  }
107 }
DenseVector< ADReal > _scalar_re
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.
DenseVector< ADReal > _lm_re
const unsigned int _rz_radial_coord
The radial coordinate index for RZ coordinate systems.
const unsigned int & _ip_current_side
Moose::StateArg determineState() const
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< std::vector< Real > > & _lm_phi_face
The following methods are specializations for using the Parallel::packed_range_* routines for a vecto...
const QBase *const & _ip_qrule_face
const TransientInterface & _ti
const Elem *const & _ip_current_elem
const MooseArray< Real > & _ip_JxW
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)
const MooseArray< Point > & _ip_normals
const QBase *const & _ip_qrule
const MooseArray< Point > & _ip_q_point_face
unsigned int n_points() const
std::vector< const ADVariableGradient * > _interior_vel_grads
The velocity gradients at interior element quadrature points.
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)
const MooseArray< Real > & _ip_JxW_face
IntRange< T > make_range(T beg, T end)
const MooseArray< Point > & _ip_q_point
static InputParameters validParams()
auto index_range(const T &sizable)
std::vector< const ADVariableValue * > _interior_vels
The velocities at interior element quadrature points.
unsigned int THREAD_ID
const MooseArray< std::vector< Real > > & _scalar_phi