https://mooseframework.inl.gov
NavierStokesLHDGKernel.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 "NavierStokesLHDGKernel.h"
11 #include "MooseVariableFE.h"
12 #include "MooseVariableScalar.h"
13 #include "FEProblemBase.h"
14 
16 
19 {
20  auto params = HDGKernel::validParams();
22  params.addParam<MooseFunctorName>(
23  "body_force_x", 0, "Body force for the momentum equation in the x-direction");
24  params.addParam<MooseFunctorName>(
25  "body_force_y", 0, "Body force for the momentum equation in the y-direction");
26  params.addParam<MooseFunctorName>(
27  "body_force_z", 0, "Body force for the momentum equation in the z-direction");
28  params.addParam<MooseFunctorName>(
29  "pressure_mms_forcing_function",
30  0,
31  "A forcing function for the pressure (mass) equation for conducting MMS studies");
32  params.addClassDescription("Implements the steady incompressible Navier-Stokes equations for a "
33  "hybridized discretization");
34  params.renameParam("variable", "u", "The x-component of velocity");
35  return params;
36 }
37 
39  : HDGKernel(parameters),
40  NavierStokesLHDGAssemblyHelper(this, this, this, this, _fe_problem, _sys, _mesh, _tid),
41  // body forces
42  _body_force_x(getFunctor<Real>("body_force_x")),
43  _body_force_y(getFunctor<Real>("body_force_y")),
44  _body_force_z(getFunctor<Real>("body_force_z")),
45  _pressure_mms_forcing_function(getFunctor<Real>("pressure_mms_forcing_function")),
46  _qrule_face(_assembly.qRuleFace()),
47  _q_point_face(_assembly.qPointsFace()),
48  _JxW_face(_assembly.JxWFace()),
49  _normals(_assembly.normals()),
50  _current_side(_assembly.side())
51 {
52  if (_mesh.dimension() > 2)
53  mooseError("This class only supports 2D simulations at this time");
54 
55  _body_forces.push_back(&_body_force_x);
56  _body_forces.push_back(&_body_force_y);
57  _body_forces.push_back(&_body_force_z);
58 }
59 
60 void
62 {
67  _p_re.resize(_p_dof_indices.size());
69 
70  // qu and u
74 
75  // qv and v
79 
80  // p
83 
92 }
93 
94 void
96 {
114  _p_dof_indices.size());
115 
116  // qu and u
119 
120  // qv and v
123 
124  // p
126 
127  addJacobian(
129  addJacobian(
131  addJacobian(
133  addJacobian(
146  {
157  }
158 }
159 
160 void
162 {
163  const Elem * const neigh = _current_elem->neighbor_ptr(_current_side);
164 
171  _p_re.resize(_p_dof_indices.size());
172 
173  // qu, u, lm_u
178 
179  // qv, v, lm_v
184 
185  // p
187 
195 }
196 
197 void
199 {
200  const Elem * const neigh = _current_elem->neighbor_ptr(_current_side);
201 
226 
227  // qu, u, lm_u
230  _JxW_face,
231  *_qrule_face,
232  _normals,
234  _u_u_jac,
235  _u_lm_u_jac,
236  _u_p_jac,
237  _u_lm_u_jac,
238  _u_lm_v_jac);
239  lmFaceJacobian(0,
240  _JxW_face,
241  *_qrule_face,
242  _normals,
243  neigh,
245  _lm_u_u_jac,
247  _lm_u_p_jac,
250 
251  // qv, v, lm_v
254  _JxW_face,
255  *_qrule_face,
256  _normals,
258  _v_v_jac,
259  _v_lm_v_jac,
260  _v_p_jac,
261  _v_lm_u_jac,
262  _v_lm_v_jac);
263  lmFaceJacobian(1,
264  _JxW_face,
265  *_qrule_face,
266  _normals,
267  neigh,
269  _lm_v_v_jac,
271  _lm_v_p_jac,
274 
275  // p
277 
278  addJacobian(
285  addJacobian(
287  addJacobian(
289  addJacobian(
291  addJacobian(
293  addJacobian(
295  addJacobian(
302  addJacobian(
304  addJacobian(
306  addJacobian(
308  addJacobian(
310  addJacobian(
312  addJacobian(
314  addJacobian(
316 }
317 
318 void
320 {
321  // This check must occur after FEProblemBase::init()
322  checkCoupling();
323 }
324 
325 void
327 {
328  _cached_elem = nullptr;
329 }
330 
331 void
333 {
335  {
336  computeJacobian();
338  }
339 }
340 
341 std::set<std::string>
343 {
344  std::set<std::string> covered_vars = {_grad_u_var.name(),
345  _u_face_var.name(),
346  _v_var.name(),
347  _grad_v_var.name(),
348  _v_face_var.name(),
349  _pressure_var.name()};
350  if (_enclosure_lm_var)
351  covered_vars.insert(_enclosure_lm_var->name());
352  return covered_vars;
353 }
void pressureVolumeJacobian(const MooseArray< Real > &JxW, const libMesh::QBase &qrule, DenseMatrix< Number > &p_u_vel_jac, DenseMatrix< Number > &p_v_vel_jac, DenseMatrix< Number > &p_global_lm_jac, DenseMatrix< Number > &global_lm_p_jac)
Compute the volumetric contributions to the pressure Jacobian, e.g.
MooseMesh & _mesh
const std::vector< dof_id_type > & _lm_u_dof_indices
const MooseArray< Number > & _u_sol
const std::vector< dof_id_type > *const _global_lm_dof_indices
virtual void computeJacobian() override
Compute this object&#39;s entire element interior Jacobian, both on- and off-diagonal.
void lmFaceJacobian(const unsigned int vel_component, const MooseArray< Real > &JxW_face, const libMesh::QBase &qrule_face, const MooseArray< Point > &normals, const Elem *const neigh, DenseMatrix< Number > &lm_vec_jac, DenseMatrix< Number > &lm_scalar_jac, DenseMatrix< Number > &lm_lm_jac, DenseMatrix< Number > &lm_p_jac, DenseMatrix< Number > &lm_lm_u_vel_jac, DenseMatrix< Number > &lm_lm_v_vel_jac)
const MooseVariableFE< Real > & _v_var
const unsigned int & _current_side
The current side when doing face evaluations.
void vectorVolumeJacobian(const MooseArray< Real > &JxW, const libMesh::QBase &qrule, DenseMatrix< Number > &vector_vector_jac, DenseMatrix< Number > &vector_scalar_jac)
const Moose::Functor< Real > & _body_force_x
const std::vector< dof_id_type > & _u_dof_indices
void vectorFaceResidual(const MooseArray< Number > &lm_sol, const MooseArray< Real > &JxW_face, const libMesh::QBase &qrule_face, const MooseArray< Point > &normals, DenseVector< Number > &vector_re)
virtual void computeOffDiagJacobian(unsigned int jvar) override
Forwards to computeJacobian() the first time this is called for a given element.
const MooseArray< Real > & _JxW
void pressureVolumeResidual(const Moose::Functor< Real > &pressure_mms_forcing_function, const MooseArray< Real > &JxW, const libMesh::QBase &qrule, const Elem *const current_elem, const MooseArray< Point > &q_point, DenseVector< Number > &pressure_re, DenseVector< Number > &global_lm_re)
Compute the volumetric contributions to the pressure residual, e.g.
const Moose::Functor< Real > & _pressure_mms_forcing_function
void resize(const unsigned int n)
void addResiduals(Assembly &assembly, const Residuals &residuals, const Indices &dof_indices, Real scaling_factor)
const MooseVariableFE< Real > & _v_face_var
const std::string & name() const override
const MooseArray< libMesh::Gradient > & _qu_sol
void pressureFaceJacobian(const MooseArray< Real > &JxW_face, const libMesh::QBase &qrule_face, const MooseArray< Point > &normals, DenseMatrix< Number > &p_lm_u_vel_jac, DenseMatrix< Number > &p_lm_v_vel_jac)
void scalarFaceResidual(const MooseArray< Gradient > &vector_sol, const MooseArray< Number > &scalar_sol, const MooseArray< Number > &lm_sol, const unsigned int vel_component, const MooseArray< Real > &JxW_face, const libMesh::QBase &qrule_face, const MooseArray< Point > &normals, DenseVector< Number > &scalar_re)
const std::vector< dof_id_type > & _qv_dof_indices
Containers for dof indices.
void scalarVolumeJacobian(const unsigned int vel_component, const MooseArray< Real > &JxW, const libMesh::QBase &qrule, DenseMatrix< Number > &scalar_vector_jac, DenseMatrix< Number > &scalar_u_vel_jac, DenseMatrix< Number > &scalar_v_vel_jac, DenseMatrix< Number > &scalar_p_jac)
Compute the volumetric contributions to a velocity Jacobian.
const std::vector< dof_id_type > & _qu_dof_indices
virtual void computeResidualOnSide() override
void addJacobian(Assembly &assembly, const Residuals &residuals, const Indices &dof_indices, Real scaling_factor)
void scalarFaceJacobian(const unsigned int vel_component, const MooseArray< Real > &JxW_face, const libMesh::QBase &qrule_face, const MooseArray< Point > &normals, DenseMatrix< Number > &scalar_vector_jac, DenseMatrix< Number > &scalar_scalar_jac, DenseMatrix< Number > &scalar_lm_jac, DenseMatrix< Number > &scalar_p_jac, DenseMatrix< Number > &scalar_lm_u_vel_jac, DenseMatrix< Number > &scalar_lm_v_vel_jac)
std::vector< const Moose::Functor< Real > * > _body_forces
const MooseArray< Real > & _JxW_face
transformed Jacobian weights on the current element face
virtual unsigned int dimension() const
void vectorVolumeResidual(const MooseArray< Gradient > &vector_sol, const MooseArray< Number > &scalar_sol, const MooseArray< Real > &JxW, const libMesh::QBase &qrule, DenseVector< Number > &vector_re)
const MooseArray< Point > & _normals
face normals
const QBase *const & _qrule
const MooseVariableFE< RealVectorValue > & _grad_v_var
const std::vector< dof_id_type > & _lm_v_dof_indices
const std::vector< dof_id_type > & _v_dof_indices
virtual void initialSetup() override
Implements the steady incompressible Navier-Stokes equations for a hybridized discretization.
Assembly & _assembly
void vectorFaceJacobian(const MooseArray< Real > &JxW_face, const libMesh::QBase &qrule_face, const MooseArray< Point > &normals, DenseMatrix< Number > &vector_lm_jac)
const MooseVariableFE< Real > & _pressure_var
const MooseVariableFE< Real > & _u_face_var
const std::vector< dof_id_type > & _p_dof_indices
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
static InputParameters validParams()
void pressureFaceResidual(const MooseArray< Real > &JxW_face, const libMesh::QBase &qrule_face, const MooseArray< Point > &normals, DenseVector< Number > &pressure_re)
const MooseVariableFE< Real > & _u_var
NavierStokesLHDGKernel(const InputParameters &parameters)
const MooseArray< Number > & _lm_u_sol
void resize(const unsigned int new_m, const unsigned int new_n)
void mooseError(Args &&... args) const
const Moose::Functor< Real > & _body_force_z
virtual void jacobianSetup() override
const MooseArray< Gradient > & _qv_sol
local solutions at quadrature points
const Elem *const & _current_elem
const QBase *const & _qrule_face
The face quadrature rule.
const MooseVariableFE< RealVectorValue > & _grad_u_var
static InputParameters validParams()
void lmFaceResidual(const MooseArray< Gradient > &vector_sol, const MooseArray< Number > &scalar_sol, const MooseArray< Number > &lm_sol, const unsigned int vel_component, const MooseArray< Real > &JxW_face, const libMesh::QBase &qrule_face, const MooseArray< Point > &normals, const Elem *const neigh, DenseVector< Number > &lm_re)
virtual std::set< std::string > additionalROVariables() override
Implements all the methods for assembling a hybridized local discontinuous Galerkin (LDG-H)...
void scalarVolumeResidual(const MooseArray< Gradient > &vel_gradient, const unsigned int vel_component, const Moose::Functor< Real > &body_force, const MooseArray< Real > &JxW, const libMesh::QBase &qrule, const Elem *const current_elem, const MooseArray< Point > &q_point, DenseVector< Number > &scalar_re)
Compute the volumetric contributions to a velocity residual for a provided velocity gradient and stre...
const MooseArray< Point > & _q_point
void scalingFactor(const std::vector< Real > &factor)
virtual void computeJacobianOnSide() override
const MooseVariableScalar *const _enclosure_lm_var
virtual void computeResidual() override
const Moose::Functor< Real > & _body_force_y