https://mooseframework.inl.gov
Loading...
Searching...
No Matches
XFEMSingleVariableConstraint.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
12// MOOSE includes
13#include "Assembly.h"
14#include "ElementPairInfo.h"
15#include "FEProblem.h"
17#include "XFEM.h"
18#include "Function.h"
19
20#include "libmesh/quadrature.h"
21
23
26{
28 params.addParam<Real>("alpha",
29 100,
30 "Stabilization parameter in Nitsche's formulation and penalty factor "
31 "in the Penalty Method. In Nitsche's formulation this should be as "
32 "small as possible while the method is still stable; while in the "
33 "Penalty Method you want this to be quite large (e.g. 1e6).");
34 params.addParam<FunctionName>("jump", 0, "Jump at the interface. Can be a Real or FunctionName.");
35 params.addParam<FunctionName>(
36 "jump_flux", 0, "Flux jump at the interface. Can be a Real or FunctionName.");
37 params.addParam<UserObjectName>(
38 "geometric_cut_userobject",
39 "Name of GeometricCutUserObject associated with this constraint.");
40 params.addParam<bool>(
41 "use_penalty",
42 false,
43 "Use the Penalty instead of Nitsche (Nitsche only works for simple diffusion problems).");
44 params.addClassDescription("Enforce constraints on the value or flux associated with a variable "
45 "at an XFEM interface.");
46 return params;
47}
48
50 : ElemElemConstraint(parameters),
51 _alpha(getParam<Real>("alpha")),
52 _jump(getFunction("jump")),
53 _jump_flux(getFunction("jump_flux")),
54 _use_penalty(getParam<bool>("use_penalty"))
55{
56 _xfem = std::dynamic_pointer_cast<XFEM>(_fe_problem.getXFEM());
57 if (_xfem == nullptr)
58 mooseError("Problem casting to XFEM in XFEMSingleVariableConstraint");
59
60 const UserObject * uo =
61 &(_fe_problem.getUserObjectBase(getParam<UserObjectName>("geometric_cut_userobject")));
62
63 if (dynamic_cast<const GeometricCutUserObject *>(uo) == nullptr)
64 mooseError("UserObject casting to GeometricCutUserObject in XFEMSingleVariableConstraint");
65
66 _interface_id = _xfem->getGeometricCutID(dynamic_cast<const GeometricCutUserObject *>(uo));
67}
68
70
71void
77
78Real
80{
81 Real r = 0;
82
83 switch (type)
84 {
85 case Moose::Element:
86 if (!_use_penalty)
87 {
88 r -= (0.5 * _grad_u[_qp] * _interface_normal +
90 _test[_i][_qp];
91 r -= (_u[_qp] - _u_neighbor[_qp]) * 0.5 * _grad_test[_i][_qp] * _interface_normal;
92 r += 0.5 * _grad_test[_i][_qp] * _interface_normal * _jump.value(_t, _u[_qp]);
93 }
94 r += 0.5 * _test[_i][_qp] * _jump_flux.value(_t, _u[_qp]);
95 r += _alpha * (_u[_qp] - _u_neighbor[_qp] - _jump.value(_t, _u[_qp])) * _test[_i][_qp];
96 break;
97
98 case Moose::Neighbor:
99 if (!_use_penalty)
100 {
101 r += (0.5 * _grad_u[_qp] * _interface_normal +
107 }
109 r -= _alpha * (_u[_qp] - _u_neighbor[_qp] - _jump.value(_t, _u_neighbor[_qp])) *
111 break;
112 }
113 return r;
114}
115
116Real
118{
119 Real r = 0;
120
121 switch (type)
122 {
124 if (!_use_penalty)
125 r += -0.5 * _grad_phi[_j][_qp] * _interface_normal * _test[_i][_qp] -
127 r += _alpha * _phi[_j][_qp] * _test[_i][_qp];
128 break;
129
131 if (!_use_penalty)
134 r -= _alpha * _phi_neighbor[_j][_qp] * _test[_i][_qp];
135 break;
136
138 if (!_use_penalty)
141 r -= _alpha * _phi[_j][_qp] * _test_neighbor[_i][_qp];
142 break;
143
145 if (!_use_penalty)
149 break;
150 }
151
152 return r;
153}
registerMooseObject("XFEMApp", XFEMSingleVariableConstraint)
unsigned int _qp
const VariableTestValue & _test_neighbor
const VariableGradient & _grad_u
const VariablePhiValue & _phi_neighbor
FEProblemBase & _fe_problem
const VariablePhiValue & _phi
const VariablePhiGradient & _grad_phi_neighbor
const VariableTestGradient & _grad_test_neighbor
virtual void reinitConstraintQuadrature(const ElementPairInfo &element_pair_info)
unsigned int _j
const VariableGradient & _grad_u_neighbor
const VariablePhiGradient & _grad_phi
const VariableValue & _u
unsigned int _i
const VariableValue & _u_neighbor
const VariableTestValue & _test
const VariableTestGradient & _grad_test
static InputParameters validParams()
unsigned int _interface_id
std::shared_ptr< XFEMInterface > getXFEM()
const UserObject & getUserObjectBase(const std::string &name, const THREAD_ID tid=0) const
virtual Real value(Real t, const Point &p) const
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
void addClassDescription(const std::string &doc_string)
const std::string & type() const
void mooseError(Args &&... args) const
virtual Real computeQpJacobian(Moose::DGJacobianType type) override
virtual Real computeQpResidual(Moose::DGResidualType type) override
std::shared_ptr< XFEM > _xfem
Pointer to the XFEM controller object.
bool _use_penalty
Use penalty formulation.
const Function & _jump
Change in variable value at the interface.
const Function & _jump_flux
Change in flux of variable value at the interface.
XFEMSingleVariableConstraint(const InputParameters &parameters)
Point _interface_normal
Vector normal to the internal interface.
Real _alpha
Stabilization parameter in Nitsche's formulation and penalty factor in the Penalty Method.
virtual void reinitConstraintQuadrature(const ElementPairInfo &element_pair_info) override
DGResidualType
DGJacobianType
NeighborNeighbor
ElementElement
NeighborElement
ElementNeighbor