Line data Source code
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 "NavierStokesLHDGVelocityDirichletBC.h"
11 :
12 : registerMooseObject("NavierStokesApp", NavierStokesLHDGVelocityDirichletBC);
13 :
14 : InputParameters
15 704 : NavierStokesLHDGVelocityDirichletBC::validParams()
16 : {
17 704 : auto params = IntegratedBC::validParams();
18 704 : params += NavierStokesLHDGAssemblyHelper::validParams();
19 704 : params.addClassDescription("Weakly imposes Dirichlet boundary conditions for the velocity for a "
20 : "hybridized discretization of the Navier-Stokes equations");
21 1408 : params.addRequiredParam<MooseFunctorName>("dirichlet_u",
22 : "The Dirichlet value for the x-component of velocity");
23 1408 : params.addRequiredParam<MooseFunctorName>("dirichlet_v",
24 : "The Dirichlet value for the y-component of velocity");
25 1408 : params.addParam<MooseFunctorName>(
26 1408 : "dirichlet_w", 0, "The Dirichlet value for the z-component of velocity");
27 1408 : params.renameParam("variable", "u", "The x-component of velocity");
28 704 : return params;
29 0 : }
30 :
31 352 : NavierStokesLHDGVelocityDirichletBC::NavierStokesLHDGVelocityDirichletBC(
32 352 : const InputParameters & parameters)
33 : : IntegratedBC(parameters),
34 352 : NavierStokesLHDGAssemblyHelper(this, this, this, this, _fe_problem, _sys, _mesh, _tid),
35 352 : _cached_side(libMesh::invalid_uint)
36 : {
37 352 : if (_mesh.dimension() > 2 && !isParamSetByUser("dirichlet_w"))
38 0 : paramError("dirichlet_w",
39 : "For a 3D simulation, the Dirichlet value of the z-velocity must be supplied");
40 :
41 704 : _dirichlet_vel[0] = &getFunctor<Real>("dirichlet_u");
42 704 : _dirichlet_vel[1] = &getFunctor<Real>("dirichlet_v");
43 704 : _dirichlet_vel[2] = &getFunctor<Real>("dirichlet_w");
44 352 : }
45 :
46 : void
47 352 : NavierStokesLHDGVelocityDirichletBC::initialSetup()
48 : {
49 : // This check must occur after FEProblemBase::init()
50 352 : checkCoupling();
51 352 : }
52 :
53 : void
54 1286 : NavierStokesLHDGVelocityDirichletBC::jacobianSetup()
55 : {
56 1286 : _cached_elem = nullptr;
57 1286 : _cached_side = libMesh::invalid_uint;
58 1286 : }
59 :
60 : void
61 160958 : NavierStokesLHDGVelocityDirichletBC::computeOffDiagJacobian(const unsigned int)
62 : {
63 160958 : if ((_cached_elem != _current_elem) || (_cached_side != _current_side))
64 : {
65 22994 : computeJacobian();
66 22994 : _cached_elem = _current_elem;
67 22994 : _cached_side = _current_side;
68 : }
69 160958 : }
70 :
71 : void
72 80540 : NavierStokesLHDGVelocityDirichletBC::computeResidual()
73 : {
74 80540 : _grad_u_vel_re.resize(_qu_dof_indices.size());
75 80540 : _u_vel_re.resize(_u_dof_indices.size());
76 80540 : _lm_u_vel_re.resize(_lm_u_dof_indices.size());
77 80540 : _grad_v_vel_re.resize(_qv_dof_indices.size());
78 80540 : _v_vel_re.resize(_v_dof_indices.size());
79 80540 : _lm_v_vel_re.resize(_lm_v_dof_indices.size());
80 80540 : _p_re.resize(_p_dof_indices.size());
81 :
82 : // qu, u, lm_u
83 80540 : vectorDirichletResidual(*_dirichlet_vel[0],
84 : _JxW,
85 80540 : *_qrule,
86 : _normals,
87 80540 : _current_elem,
88 80540 : _current_side,
89 : _q_point,
90 : _grad_u_vel_re);
91 80540 : scalarDirichletResidual(_qu_sol,
92 : _u_sol,
93 : 0,
94 80540 : _dirichlet_vel,
95 : _JxW,
96 80540 : *_qrule,
97 : _normals,
98 80540 : _current_elem,
99 80540 : _current_side,
100 : _q_point,
101 : _u_vel_re);
102 :
103 : // qv, v, lm_v
104 80540 : vectorDirichletResidual(*_dirichlet_vel[1],
105 : _JxW,
106 80540 : *_qrule,
107 : _normals,
108 80540 : _current_elem,
109 80540 : _current_side,
110 : _q_point,
111 : _grad_v_vel_re);
112 80540 : scalarDirichletResidual(_qv_sol,
113 : _v_sol,
114 : 1,
115 : _dirichlet_vel,
116 : _JxW,
117 80540 : *_qrule,
118 : _normals,
119 80540 : _current_elem,
120 80540 : _current_side,
121 : _q_point,
122 : _v_vel_re);
123 :
124 : // p
125 80540 : pressureDirichletResidual(
126 80540 : _dirichlet_vel, _JxW, *_qrule, _normals, _current_elem, _current_side, _q_point, _p_re);
127 :
128 : // Set the LMs on these Dirichlet boundary faces to 0
129 80540 : createIdentityResidual(_JxW, *_qrule, _lm_phi_face, _lm_u_sol, _lm_u_vel_re);
130 80540 : createIdentityResidual(_JxW, *_qrule, _lm_phi_face, _lm_v_sol, _lm_v_vel_re);
131 :
132 80540 : addResiduals(_assembly, _grad_u_vel_re, _qu_dof_indices, _grad_u_var.scalingFactor());
133 80540 : addResiduals(_assembly, _u_vel_re, _u_dof_indices, _u_var.scalingFactor());
134 80540 : addResiduals(_assembly, _lm_u_vel_re, _lm_u_dof_indices, _u_face_var.scalingFactor());
135 80540 : addResiduals(_assembly, _grad_v_vel_re, _qv_dof_indices, _grad_v_var.scalingFactor());
136 80540 : addResiduals(_assembly, _v_vel_re, _v_dof_indices, _v_var.scalingFactor());
137 80540 : addResiduals(_assembly, _lm_v_vel_re, _lm_v_dof_indices, _v_face_var.scalingFactor());
138 80540 : addResiduals(_assembly, _p_re, _p_dof_indices, _pressure_var.scalingFactor());
139 80540 : }
140 :
141 : void
142 22994 : NavierStokesLHDGVelocityDirichletBC::computeJacobian()
143 : {
144 22994 : _u_grad_u_jac.resize(_u_dof_indices.size(), _qu_dof_indices.size());
145 22994 : _u_u_jac.resize(_u_dof_indices.size(), _u_dof_indices.size());
146 22994 : _u_p_jac.resize(_u_dof_indices.size(), _p_dof_indices.size());
147 22994 : _v_grad_v_jac.resize(_v_dof_indices.size(), _qv_dof_indices.size());
148 22994 : _v_v_jac.resize(_v_dof_indices.size(), _v_dof_indices.size());
149 22994 : _v_p_jac.resize(_v_dof_indices.size(), _p_dof_indices.size());
150 22994 : _lm_u_lm_u_jac.resize(_lm_u_dof_indices.size(), _lm_u_dof_indices.size());
151 22994 : _lm_v_lm_v_jac.resize(_lm_v_dof_indices.size(), _lm_v_dof_indices.size());
152 :
153 : // qu, u, lm_u
154 22994 : scalarDirichletJacobian(0, _JxW, *_qrule, _normals, _u_grad_u_jac, _u_u_jac, _u_p_jac);
155 :
156 : // qv, v, lm_v
157 22994 : scalarDirichletJacobian(1, _JxW, *_qrule, _normals, _v_grad_v_jac, _v_v_jac, _v_p_jac);
158 :
159 : // Set the LMs on these Dirichlet boundary faces to 0
160 22994 : createIdentityJacobian(_JxW, *_qrule, _lm_phi_face, _lm_u_lm_u_jac);
161 22994 : createIdentityJacobian(_JxW, *_qrule, _lm_phi_face, _lm_v_lm_v_jac);
162 :
163 22994 : addJacobian(_assembly, _u_grad_u_jac, _u_dof_indices, _qu_dof_indices, _u_var.scalingFactor());
164 22994 : addJacobian(_assembly, _u_u_jac, _u_dof_indices, _u_dof_indices, _u_var.scalingFactor());
165 22994 : addJacobian(_assembly, _u_p_jac, _u_dof_indices, _p_dof_indices, _u_var.scalingFactor());
166 22994 : addJacobian(_assembly, _v_grad_v_jac, _v_dof_indices, _qv_dof_indices, _v_var.scalingFactor());
167 22994 : addJacobian(_assembly, _v_v_jac, _v_dof_indices, _v_dof_indices, _v_var.scalingFactor());
168 22994 : addJacobian(_assembly, _v_p_jac, _v_dof_indices, _p_dof_indices, _v_var.scalingFactor());
169 22994 : addJacobian(
170 22994 : _assembly, _lm_u_lm_u_jac, _lm_u_dof_indices, _lm_u_dof_indices, _u_face_var.scalingFactor());
171 22994 : addJacobian(
172 22994 : _assembly, _lm_v_lm_v_jac, _lm_v_dof_indices, _lm_v_dof_indices, _v_face_var.scalingFactor());
173 22994 : }
|