www.mooseframework.org
MaskedBodyForce.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
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 "MaskedBodyForce.h"
11 #include "Function.h"
12 
13 registerMooseObject("PhaseFieldApp", MaskedBodyForce);
14 
17 {
19  params.addClassDescription("Kernel that defines a body force modified by a material mask");
20  params.addParam<MaterialPropertyName>("mask", "Material property defining the mask");
21  params.addCoupledVar("args", "Vector of nonlinear variable arguments this object depends on");
22  params.deprecateCoupledVar("args", "coupled_variables", "02/27/2024");
23  return params;
24 }
25 
28  _mask(getMaterialProperty<Real>("mask")),
29  _v_name(_var.name()),
30  _dmaskdv(getMaterialPropertyDerivative<Real>("mask", _v_name)),
31  _dmaskdarg(_n_args)
32 {
33  // Get derivatives of mask wrt coupled variables
34  for (unsigned int i = 0; i < _n_args; ++i)
35  _dmaskdarg[i] = &getMaterialPropertyDerivative<Real>("mask", i);
36 }
37 
38 void
40 {
41  validateNonlinearCoupling<Real>("mask");
42 }
43 
44 Real
46 {
47  return BodyForce::computeQpResidual() * _mask[_qp];
48 }
49 
50 Real
52 {
53  return _dmaskdv[_qp] * BodyForce::computeQpResidual() * _phi[_j][_qp];
54 }
55 
56 Real
58 {
59  const unsigned int cvar = mapJvarToCvar(jvar);
60  return (*_dmaskdarg[cvar])[_qp] * BodyForce::computeQpResidual() * _phi[_j][_qp];
61 }
virtual Real computeQpOffDiagJacobian(unsigned int jvar)
static InputParameters validParams()
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
virtual Real computeQpResidual()
const MaterialProperty< Real > & _mask
virtual GenericReal< is_ad > computeQpResidual() override
static InputParameters validParams()
const std::string name
Definition: Setup.h:20
MaskedBodyForce(const InputParameters &parameters)
void deprecateCoupledVar(const std::string &old_name, const std::string &new_name, const std::string &removal_date)
void addCoupledVar(const std::string &name, const std::string &doc_string)
const MaterialProperty< Real > & _dmaskdv
derivative of the mask wrt the kernel&#39;s nonlinear variable
registerMooseObject("PhaseFieldApp", MaskedBodyForce)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
std::vector< const MaterialProperty< Real > * > _dmaskdarg
Reaction rate derivatives w.r.t. other coupled variables.
void addClassDescription(const std::string &doc_string)
virtual Real computeQpJacobian()
virtual void initialSetup()
This kernel creates a body force that is modified by a mask defined as a material.