https://mooseframework.inl.gov
Loading...
Searching...
No Matches
FVScalarLagrangeMultiplierInterface.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
11#include "MooseVariableScalar.h"
12#include "Assembly.h"
13
16{
19 "This class should be inherited to create interface penalties in finite volume.");
20 params.addRequiredCoupledVar("lambda", "The name of the scalar lagrange multiplier");
21
22 return params;
23}
24
26 const InputParameters & params)
27 : FVInterfaceKernel(params),
28 _lambda_var(*getScalarVar("lambda", 0)),
29 _lambda(adCoupledScalarValue("lambda"))
30{
31 if (var1().sys().number() != var2().sys().number())
32 mooseError(this->type(), " does not support multiple nonlinear systems!");
33}
34
35void
37{
38 setupData(fi);
39
40 const auto r = MetaPhysicL::raw_value(_lambda[0]) * fi.faceArea() * fi.faceCoord();
41
42 // Primal residual
45
46 // LM residual. We may not have any actual ScalarKernels in our simulation so we need to manually
47 // make sure the scalar residuals get cached for later addition
48 const auto lm_r = MetaPhysicL::raw_value(computeQpResidual()) * fi.faceArea() * fi.faceCoord();
50 std::array<Real, 1>{{lm_r}},
53}
54
55void
57{
58 setupData(fi);
59
60 // Primal
61 const auto primal_r = _lambda[0] * fi.faceArea() * fi.faceCoord();
64
65 // LM
66 const auto lm_r = computeQpResidual() * fi.faceArea() * fi.faceCoord();
67 mooseAssert(_lambda_var.dofIndices().size() == 1, "We should only have one dof");
69 std::array<ADReal, 1>{{lm_r}},
72}
Base class for creating kernels that interface physics between subdomains.
void addResidualAndJacobianToVariable1(const ADReal &residual)
Add a residual and its Jacobian contribution to variable1 on subdomain1.
static InputParameters validParams()
void addResidualAndJacobianToVariable2(const ADReal &residual)
Add a residual and its Jacobian contribution to variable2 on subdomain2.
void addResidualToVariable2(Real residual)
Add a residual contribution to variable2 on subdomain2.
void setupData(const FaceInfo &fi)
setup data useful for this object
const MooseVariableFV< Real > & var1() const
Assembly & _assembly
The Assembly object.
void addResidualToVariable1(Real residual)
Add a residual contribution to variable1 on subdomain1.
const MooseVariableFV< Real > & var2() const
const ADVariableValue & _lambda
The Lagrange Multiplier value.
void computeResidual(const FaceInfo &fi) override final
Compute the residual on the supplied face.
void computeJacobian(const FaceInfo &fi) override final
Compute the jacobian on the supplied face.
const MooseVariableScalar & _lambda_var
The Lagrange Multiplier variable.
FVScalarLagrangeMultiplierInterface(const InputParameters &params)
ADReal computeQpResidual() override=0
This data structure is used to store geometric and variable related metadata about each cell face in ...
Definition FaceInfo.h:38
Real faceArea() const
Returns the face area of face id.
Definition FaceInfo.h:64
Real & faceCoord()
Sets/gets the coordinate transformation factor (for e.g.
Definition FaceInfo.h:68
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
void addRequiredCoupledVar(const std::string &name, const std::string &doc_string)
This method adds a coupled variable name pair.
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.
const std::string & type() const
Get the type of this class.
Definition MooseBase.h:93
void mooseError(Args &&... args) const
Emits an error prefixed with object name and type and optionally a file path to the top-level block p...
Definition MooseBase.h:271
virtual const std::vector< dof_id_type > & dofIndices() const
Get local DoF indices.
void scalingFactor(const std::vector< Real > &factor)
Set the scaling factor for this variable.
void addResidualsAndJacobian(Assembly &assembly, const Residuals &residuals, const Indices &dof_indices, Real scaling_factor)
Add the provided incoming residuals and derivatives for the Jacobian, corresponding to the provided d...
void addResiduals(Assembly &assembly, const Residuals &residuals, const Indices &dof_indices, Real scaling_factor)
Add the provided incoming residuals corresponding to the provided dof indices.
auto raw_value(const Eigen::Map< T > &in)