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 : #pragma once 11 : 12 : #include "MooseArray.h" 13 : #include "MooseFunctorForward.h" 14 : #include "MooseTypes.h" 15 : #include "ThreeMaterialPropertyInterface.h" 16 : 17 : #include <array> 18 : #include <set> 19 : #include <string> 20 : #include <vector> 21 : 22 : template <typename> 23 : class MooseVariableFE; 24 : class Assembly; 25 : class MooseObject; 26 : class MooseVariableDependencyInterface; 27 : class SystemBase; 28 : class TransientInterface; 29 : struct ADResidualsPacket; 30 : 31 : /** 32 : * Method-neutral assembly data and operations for an element-and-trace scalar hybridized DG 33 : * discretization. 34 : * 35 : * The directly assembled variables are an element-interior scalar and its facet trace. Derived 36 : * helpers provide the method-specific volume and face weak forms. 37 : */ 38 : class ElementAndTraceScalarHDGAssemblyHelper : public ThreeMaterialPropertyInterface 39 : { 40 : public: 41 : static InputParameters validParams(); 42 : 43 : ElementAndTraceScalarHDGAssemblyHelper(const MooseObject * moose_obj, 44 : MooseVariableDependencyInterface * mvdi, 45 : const TransientInterface * ti, 46 : SystemBase & sys, 47 : const Assembly & assembly, 48 : THREAD_ID tid, 49 : const std::set<SubdomainID> & blocks_ids, 50 : const std::set<BoundaryID> & boundary_ids); 51 : 52 : /// Resizes the element-interior and facet residual vectors for the current element. 53 : void resizeResiduals(); 54 : 55 : /// Assembles the element-interior equation's volume contribution. 56 : virtual void scalarVolume() = 0; 57 : 58 : /// Assembles the element-interior equation's face contribution. 59 : virtual void scalarFace() = 0; 60 : 61 : /// Assembles the facet equation's interior-face contribution. 62 : virtual void lmFace() = 0; 63 : 64 : /// Assembles the element-interior equation on a Dirichlet boundary. 65 : virtual void scalarDirichlet(const Moose::Functor<Real> & dirichlet_value) = 0; 66 : 67 : /// Enforces a Dirichlet value in the facet equation. 68 : void lmDirichlet(const Moose::Functor<Real> & dirichlet_value); 69 : 70 : /// Applies a prescribed flux in the facet equation. 71 : void lmPrescribedFlux(const Moose::Functor<Real> & flux_value); 72 : 73 : /** 74 : * @returns The residuals and degree of freedom indices on which this helper operates 75 : */ 76 : std::array<ADResidualsPacket, 2> taggingData() const; 77 : 78 : /** 79 : * @returns The facet variable as a set 80 : */ 81 : std::set<std::string> additionalROVariables(); 82 : 83 865 : virtual ~ElementAndTraceScalarHDGAssemblyHelper() = default; 84 : 85 : protected: 86 : /// Transient state used to evaluate boundary functors. 87 : const TransientInterface & _ti; 88 : 89 : /// Element-interior scalar variable. 90 : const MooseVariableFE<Real> & _u_var; 91 : 92 : /// Facet trace variable. 93 : const MooseVariableFE<Real> & _u_face_var; 94 : 95 : /// Degree-of-freedom indices for the element-interior scalar. 96 : const std::vector<dof_id_type> & _u_dof_indices; 97 : 98 : /// Degree-of-freedom indices for the facet trace. 99 : const std::vector<dof_id_type> & _lm_u_dof_indices; 100 : 101 : /// Element-interior scalar values at quadrature points. 102 : const MooseArray<ADReal> & _u_sol; 103 : 104 : /// Facet trace values at face quadrature points. 105 : const MooseArray<ADReal> & _lm_u_sol; 106 : 107 : /// Element-interior scalar test functions. 108 : const MooseArray<std::vector<Real>> & _scalar_phi; 109 : 110 : /// Gradients of the element-interior scalar test functions. 111 : const MooseArray<std::vector<RealVectorValue>> & _grad_scalar_phi; 112 : 113 : /// Element-interior scalar test functions evaluated on a face. 114 : const MooseArray<std::vector<Real>> & _scalar_phi_face; 115 : 116 : /// Facet trace test functions evaluated on a face. 117 : const MooseArray<std::vector<Real>> & _lm_phi_face; 118 : 119 : /// Current element volume. 120 : const Real & _elem_volume; 121 : 122 : /// Current side area. 123 : const Real & _side_area; 124 : 125 : /// Current element. 126 : const Elem * const & _current_elem; 127 : 128 : /// Current element-side index. 129 : const unsigned int & _current_side; 130 : 131 : /// Current side element. 132 : const Elem * const & _current_side_elem; 133 : 134 : /// Element quadrature weights including the transformed Jacobian. 135 : const MooseArray<Real> & _JxW; 136 : 137 : /// Element quadrature rule. 138 : const libMesh::QBase * const & _qrule; 139 : 140 : /// Physical element quadrature points. 141 : const MooseArray<Point> & _q_point; 142 : 143 : /// Face quadrature weights including the transformed Jacobian. 144 : const MooseArray<Real> & _JxW_face; 145 : 146 : /// Face quadrature rule. 147 : const libMesh::QBase * const & _qrule_face; 148 : 149 : /// Physical face quadrature points. 150 : const MooseArray<Point> & _q_point_face; 151 : 152 : /// Outward unit normals on the current face. 153 : const MooseArray<Point> & _normals; 154 : 155 : /// Residual for the element-interior scalar equation. 156 : DenseVector<ADReal> _scalar_re; 157 : 158 : /// Residual for the facet trace equation. 159 : DenseVector<ADReal> _lm_re; 160 : }; 161 : 162 : inline void 163 745794 : ElementAndTraceScalarHDGAssemblyHelper::resizeResiduals() 164 : { 165 745794 : _scalar_re.resize(_u_dof_indices.size()); 166 745794 : _lm_re.resize(_lm_u_dof_indices.size()); 167 745794 : }