https://mooseframework.inl.gov
Loading...
Searching...
No Matches
DGKernelBase.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 "DGKernelBase.h"
11#include "MooseVariable.h"
12#include "Problem.h"
13#include "SubProblem.h"
14#include "SystemBase.h"
15#include "MaterialData.h"
16#include "ParallelUniqueId.h"
17
18#include "libmesh/dof_map.h"
19#include "libmesh/dense_vector.h"
20#include "libmesh/numeric_vector.h"
21#include "libmesh/dense_subvector.h"
22#include "libmesh/libmesh_common.h"
23#include "libmesh/quadrature.h"
24
27{
32 params.addParam<bool>("use_displaced_mesh",
33 false,
34 "Whether or not this object should use the "
35 "displaced mesh for computation. Note that in "
36 "the case this is true but no displacements "
37 "are provided in the Mesh block the "
38 "undisplaced mesh will still be used.");
39 params.addParamNamesToGroup("use_displaced_mesh", "Advanced");
40
41 params.addDeprecatedParam<std::vector<AuxVariableName>>(
42 "save_in",
43 {},
44 "The name of auxiliary variables to save this Kernel's residual contributions to. "
45 " Everything about that variable must match everything about this variable (the "
46 "type, what blocks it's on, etc.)",
47 "Add this object's residual to a tagged vector with 'extra_vector_tags', then transfer that "
48 "vector into an auxiliary variable with a TagVectorAux");
49 params.addDeprecatedParam<std::vector<AuxVariableName>>(
50 "diag_save_in",
51 {},
52 "The name of auxiliary variables to save this Kernel's diagonal Jacobian "
53 "contributions to. Everything about that variable must match everything "
54 "about this variable (the type, what blocks it's on, etc.)",
55 "Add this object's Jacobian to a tagged matrix with 'extra_matrix_tags', then transfer that "
56 "matrix diagonal into an auxiliary variable with a TagMatrixAux");
57 params.addParamNamesToGroup("diag_save_in save_in", "Advanced");
58
59 // DG Kernels always need one layer of ghosting.
60 params.addRelationshipManager("ElementSideNeighborLayers",
64
65 params.addParam<std::vector<BoundaryName>>(
66 "exclude_boundary", "The internal side sets to be excluded from this kernel.");
67 params.registerBase("DGKernel");
68 params.registerSystemAttributeName("DGKernel");
69
70 return params;
71}
72
74 : NeighborResidualObject(parameters),
76 BoundaryRestrictable(this, false), // false for _not_ nodal
78 TwoMaterialPropertyInterface(this, blockIDs(), boundaryIDs()),
80 _current_elem(_assembly.elem()),
81 _current_elem_volume(_assembly.elemVolume()),
82
83 _neighbor_elem(_assembly.neighbor()),
84 _neighbor_elem_volume(_assembly.neighborVolume()),
85
86 _current_side(_assembly.side()),
87 _current_side_elem(_assembly.sideElem()),
88 _current_side_volume(_assembly.sideElemVolume()),
89
90 _coord_sys(_assembly.coordSystem()),
91 _q_point(_assembly.qPointsFace()),
92 _qrule(_assembly.qRuleFace()),
93 _JxW(_assembly.JxWFace()),
94 _coord(_assembly.coordTransformation()),
95 _normals(_assembly.normals()),
96
97 _save_in_strings(parameters.get<std::vector<AuxVariableName>>("save_in")),
98 _diag_save_in_strings(parameters.get<std::vector<AuxVariableName>>("diag_save_in"))
99{
100 // Gather information on broken boundaries
101 std::vector<BoundaryName> bnd = isParamValid("exclude_boundary")
102 ? getParam<std::vector<BoundaryName>>("exclude_boundary")
103 : std::vector<BoundaryName>(0);
104 auto bnd_ids = _mesh.getBoundaryIDs(bnd);
105
106 // check if the broken boundary ids are valid
107 auto & valid_ids = _mesh.meshSidesetIds();
108 std::vector<BoundaryName> diff;
109 for (unsigned int i = 0; i < bnd_ids.size(); ++i)
110 if (valid_ids.find(bnd_ids[i]) == valid_ids.end())
111 diff.push_back(bnd[i]);
112 if (!diff.empty())
113 {
114 auto msg = "DGKernel '" + name() +
115 "' contains the following boundary names that do not exist on the mesh: " +
116 Moose::stringify(diff, ", ");
117 paramError("exclude_boundary", msg);
118 }
119
120 _excluded_boundaries.insert(bnd_ids.begin(), bnd_ids.end());
121}
122
123void
125{
126 if (!excludeBoundary())
127 {
129
130 // Compute the residual for this element
132
133 // Compute the residual for the neighbor
135 }
136}
137
138void
140{
141 if (!excludeBoundary())
142 {
144
145 // Compute element-element Jacobian
147
148 // Compute element-neighbor Jacobian
150
151 // Compute neighbor-element Jacobian
153
154 // Compute neighbor-neighbor Jacobian
156 }
157}
158
159void
160DGKernelBase::computeOffDiagJacobian(const unsigned int jvar_num)
161{
162 if (!excludeBoundary())
163 {
164 const auto & jvar = getVariable(jvar_num);
165
166 if (jvar_num == variable().number())
168 else
169 {
171
172 // Compute element-element Jacobian
174
175 // Compute element-neighbor Jacobian
177
178 // Compute neighbor-element Jacobian
180
181 // Compute neighbor-neighbor Jacobian
183 }
184 }
185}
186
187bool
189{
190 if (_excluded_boundaries.empty())
191 return false;
192
193 auto boundary_ids = _mesh.getBoundaryIDs(_current_elem, _current_side);
194 for (auto bid : boundary_ids)
195 if (_excluded_boundaries.find(bid) != _excluded_boundaries.end())
196 return true;
197
198 // make sure we will also break on the neighboring side
199 unsigned int neighbor_side = _neighbor_elem->which_neighbor_am_i(_current_elem);
200 boundary_ids = _mesh.getBoundaryIDs(_neighbor_elem, neighbor_side);
201 for (auto bid : boundary_ids)
202 if (_excluded_boundaries.find(bid) != _excluded_boundaries.end())
203 return true;
204
205 return false;
206}
207
208void
209DGKernelBase::prepareShapes(const unsigned int var_num)
210{
212}
An interface that restricts an object to subdomains via the 'blocks' input parameter.
static InputParameters validParams()
/class BoundaryRestrictable /brief Provides functionality for limiting the object to certain boundary...
static InputParameters validParams()
virtual void computeJacobian() override
Computes the jacobian for the current side.
std::set< BoundaryID > _excluded_boundaries
Broken boundaries.
virtual void computeOffDiagElemNeighJacobian(Moose::DGJacobianType type, const MooseVariableFEBase &jvar)=0
Computes the element-element off-diagonal Jacobian.
virtual void computeElemNeighResidual(Moose::DGResidualType type)=0
Computes the residual for this element or the neighbor.
virtual void computeResidual() override
Computes the residual for the current side.
const unsigned int & _current_side
Current side.
virtual void computeOffDiagJacobian(unsigned int jvar) override
Computes d-residual / d-jvar...
bool excludeBoundary() const
Check current element if it contains broken boundary.
static InputParameters validParams()
Factory constructor initializes all internal references needed for residual computation.
const Elem *const & _current_elem
Current element.
virtual void computeElemNeighJacobian(Moose::DGJacobianType type)=0
Computes the element/neighbor-element/neighbor Jacobian.
DGKernelBase(const InputParameters &parameters)
const Elem *const & _neighbor_elem
The neighboring element.
void prepareShapes(unsigned int var_num) override final
Prepare shape functions.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
void registerSystemAttributeName(const std::string &value)
This method is used to define the MOOSE system name that is used by the TheWarehouse object for stori...
void addParamNamesToGroup(const std::string &space_delim_names, const std::string group_name)
This method takes a space delimited list of parameter names and adds them to the specified group name...
void addParam(const std::string &name, const S &value, const std::string &doc_string)
These methods add an optional parameter and a documentation string to the InputParameters object.
void addDeprecatedParam(const std::string &name, const T &value, const std::string &doc_string, const std::string &deprecation_message)
void registerBase(const std::string &value)
This method must be called from every base "Moose System" to create linkage with the Action System.
void addRelationshipManager(const std::string &name, Moose::RelationshipManagerType rm_type, Moose::RelationshipManagerInputParameterCallback input_parameter_callback=nullptr)
Tells MOOSE about a RelationshipManager that this object needs.
const std::string & name() const
Get the name of the class.
Definition MooseBase.h:103
void paramError(const std::string &param, Args... args) const
Emits an error prefixed with the file and line number of the given param (from the input file) along ...
Definition MooseBase.h:466
bool isParamValid(const std::string &name) const
Test if the supplied parameter is valid.
Definition MooseBase.h:199
const std::set< BoundaryID > & meshSidesetIds() const
Returns a read-only reference to the set of sidesets currently present in the Mesh.
Definition MooseMesh.C:3291
std::vector< BoundaryID > getBoundaryIDs(const Elem *const elem, const unsigned short int side) const
Returns a vector of boundary IDs for the requested element on the requested side.
Definition MooseMesh.C:3034
Intermediate base class that ties together all the interfaces for getting MooseVariables with the Moo...
This is a base class for objects that can provide residual contributions for both local and neighbor ...
static InputParameters validParams()
THREAD_ID _tid
The thread ID for this kernel.
virtual void precalculateJacobian()
MooseMesh & _mesh
Reference to this Kernel's mesh object.
virtual const MooseVariableBase & variable() const =0
Returns the variable that this object operates on.
const MooseVariableFieldBase & getVariable(unsigned int jvar_num) const
Retrieve the variable object from our system associated with jvar_num.
SubProblem & _subproblem
Reference to this kernel's SubProblem.
virtual void precalculateOffDiagJacobian(unsigned int)
virtual void precalculateResidual()
virtual void prepareFaceShapes(unsigned int var, const THREAD_ID tid)=0
This interface is designed for DGKernel, InternalSideUserObject, InterfaceUserObject,...
@ Element
Definition MooseTypes.h:804
@ Neighbor
Definition MooseTypes.h:805
std::string stringify(const T &t)
conversion to string
Definition Conversion.h:65
@ NeighborNeighbor
Definition MooseTypes.h:813
@ ElementElement
Definition MooseTypes.h:810
@ NeighborElement
Definition MooseTypes.h:812
@ ElementNeighbor
Definition MooseTypes.h:811