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 "DiffusionLHDGAssemblyHelper.h"
11 : #include "DiffusionLHDGDirichletBC.h"
12 :
13 : registerMooseObject("MooseApp", DiffusionLHDGDirichletBC);
14 :
15 : InputParameters
16 14743 : DiffusionLHDGDirichletBC::validParams()
17 : {
18 14743 : auto params = IntegratedBC::validParams();
19 14743 : params.addClassDescription("Weakly imposes Dirichlet boundary conditions for a "
20 : "hybridized discretization of a diffusion equation");
21 14743 : params.addRequiredParam<MooseFunctorName>("functor",
22 : "The Dirichlet value for the diffusing specie");
23 14743 : params += DiffusionLHDGAssemblyHelper::validParams();
24 14743 : params.setDocString("variable", "The diffusing specie concentration");
25 14743 : return params;
26 0 : }
27 :
28 240 : DiffusionLHDGDirichletBC::DiffusionLHDGDirichletBC(const InputParameters & parameters)
29 : : IntegratedBC(parameters),
30 240 : DiffusionLHDGAssemblyHelper(this, this, this, this, _fe_problem, _sys, _tid),
31 240 : _dirichlet_val(getFunctor<Real>("functor")),
32 240 : _cached_side(libMesh::invalid_uint)
33 : {
34 240 : }
35 :
36 : void
37 240 : DiffusionLHDGDirichletBC::initialSetup()
38 : {
39 : // This check must occur after FEProblemBase::init()
40 240 : checkCoupling();
41 240 : }
42 :
43 : void
44 33264 : DiffusionLHDGDirichletBC::computeResidual()
45 : {
46 : // For notation, please read "A superconvergent LDG-hybridizable Galerkin method for second-order
47 : // elliptic problems" by Cockburn
48 :
49 33264 : _vector_re.resize(_qu_dof_indices.size());
50 33264 : _scalar_re.resize(_u_dof_indices.size());
51 33264 : _lm_re.resize(_lm_u_dof_indices.size());
52 :
53 : // qu, u
54 33264 : vectorDirichletResidual(
55 33264 : _dirichlet_val, _JxW, *_qrule, _normals, _current_elem, _current_side, _q_point, _vector_re);
56 33264 : scalarDirichletResidual(_qu_sol,
57 : _u_sol,
58 : _dirichlet_val,
59 : _JxW,
60 33264 : *_qrule,
61 : _normals,
62 33264 : _current_elem,
63 33264 : _current_side,
64 : _q_point,
65 33264 : _scalar_re);
66 :
67 : // Set the LMs on these Dirichlet boundary faces to 0
68 33264 : createIdentityResidual(_JxW, *_qrule, _lm_phi_face, _lm_u_sol, _lm_re);
69 :
70 33264 : addResiduals(_assembly, _vector_re, _qu_dof_indices, _grad_u_var.scalingFactor());
71 33264 : addResiduals(_assembly, _scalar_re, _u_dof_indices, _u_var.scalingFactor());
72 33264 : addResiduals(_assembly, _lm_re, _lm_u_dof_indices, _u_face_var.scalingFactor());
73 33264 : }
74 :
75 : void
76 21896 : DiffusionLHDGDirichletBC::computeJacobian()
77 : {
78 21896 : _scalar_vector_jac.resize(_u_dof_indices.size(), _qu_dof_indices.size());
79 21896 : _scalar_scalar_jac.resize(_u_dof_indices.size(), _u_dof_indices.size());
80 21896 : _lm_lm_jac.resize(_lm_u_dof_indices.size(), _lm_u_dof_indices.size());
81 :
82 21896 : scalarDirichletJacobian(_JxW, *_qrule, _normals, _scalar_vector_jac, _scalar_scalar_jac);
83 21896 : createIdentityJacobian(_JxW, *_qrule, _lm_phi_face, _lm_lm_jac);
84 :
85 43792 : addJacobian(
86 21896 : _assembly, _scalar_vector_jac, _u_dof_indices, _qu_dof_indices, _u_var.scalingFactor());
87 43792 : addJacobian(
88 21896 : _assembly, _scalar_scalar_jac, _u_dof_indices, _u_dof_indices, _u_var.scalingFactor());
89 43792 : addJacobian(
90 21896 : _assembly, _lm_lm_jac, _lm_u_dof_indices, _lm_u_dof_indices, _u_face_var.scalingFactor());
91 21896 : }
92 :
93 : void
94 452 : DiffusionLHDGDirichletBC::jacobianSetup()
95 : {
96 452 : _cached_elem = nullptr;
97 452 : _cached_side = libMesh::invalid_uint;
98 452 : }
99 :
100 : void
101 65688 : DiffusionLHDGDirichletBC::computeOffDiagJacobian(const unsigned int)
102 : {
103 65688 : if ((_cached_elem != _current_elem) || (_cached_side != _current_side))
104 : {
105 21896 : computeJacobian();
106 21896 : _cached_elem = _current_elem;
107 21896 : _cached_side = _current_side;
108 : }
109 65688 : }
|