https://mooseframework.inl.gov
AverageValueConstraint.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 "AverageValueConstraint.h"
11 
12 // MOOSE includes
13 #include "Assembly.h"
14 #include "MooseVariableScalar.h"
15 
17 
20 {
22  params.addClassDescription("This class is used to enforce integral of phi with a "
23  "Lagrange multiplier approach.");
24  params.addRequiredParam<PostprocessorName>(
25  "pp_name", "Name of the Postprocessor value we are trying to equate with 'value'.");
26  params.addRequiredParam<Real>(
27  "value", "Given (constant) which we want the integral of the solution variable to match.");
28 
29  return params;
30 }
31 
33  : ScalarKernel(parameters),
34  _value(getParam<Real>("value")),
35  _pp_value(getPostprocessorValue("pp_name"))
36 {
37 }
38 
39 void
41 {
42 }
43 
44 Real
46 {
47  return _pp_value - _value;
48 }
49 
50 Real
52 {
53  // Note: Here, the true on-diagonal Jacobian contribution is
54  // actually zero, i.e. we are not making any approximation
55  // here. That is because the "lambda"-equation in this system of
56  // equations does not depend on lambda. For more information, see
57  // the detailed writeup [0].
58  //
59  // [0]: https://github.com/idaholab/large_media/blob/master/scalar_constraint_kernel.pdf
60  return 0.;
61 }
62 
63 void
65 {
66 }
67 
68 Real
70 {
71  // The off-diagonal contribution for this ScalarKernel (derivative
72  // wrt the "primal" field variable) is not _actually_ zero, but we
73  // are computing it elsewhere (see ScalarLagrangeMultiplier.C) so
74  // here we simply return zero. For more information on this, see the
75  // detailed writeup [0].
76  //
77  // [0]: https://github.com/idaholab/large_media/blob/master/scalar_constraint_kernel.pdf
78  return 0.;
79 }
virtual Real computeQpJacobian() override
registerMooseObject("MooseApp", AverageValueConstraint)
AverageValueConstraint(const InputParameters &parameters)
const PostprocessorValue & _pp_value
Name of the Postprocessor value we are trying to equate with &#39;value&#39;.
virtual Real computeQpOffDiagJacobianScalar(unsigned int jvar)
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
void addRequiredParam(const std::string &name, const std::string &doc_string)
This method adds a parameter and documentation string to the InputParameters object that will be extr...
This Kernel implements part of the equation that enforces the constraint of.
virtual Real computeQpResidual() override
virtual void computeOffDiagJacobianScalar(unsigned int jvar) override
Computes jacobian block with respect to a scalar variable.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
void addClassDescription(const std::string &doc_string)
This method adds a description of the class that will be displayed in the input file syntax dump...
virtual void reinit() override
Reinitialization method called before each call to computeResidual()
static InputParameters validParams()
Definition: ScalarKernel.C:14
static InputParameters validParams()
Real _value
Given (constant) which we want the integral of the solution variable to match.