forked from idaholab/moose
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
84 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
//* This file is part of the MOOSE framework | ||
//* https://www.mooseframework.org | ||
//* | ||
//* All rights reserved, see COPYRIGHT for full restrictions | ||
//* https://github.com/idaholab/moose/blob/master/COPYRIGHT | ||
//* | ||
//* Licensed under LGPL 2.1, please see LICENSE for details | ||
//* https://www.gnu.org/licenses/lgpl-2.1.html | ||
|
||
#pragma once | ||
|
||
#include "ADKernel.h" | ||
|
||
// Forward Declaration | ||
template <ComputeStage> | ||
class ADMatReaction; | ||
|
||
declareADValidParams(ADMatReaction); | ||
|
||
/** | ||
* This kernel adds to the residual a contribution of \f$ -L*v \f$ where \f$ L \f$ is a material | ||
* property and \f$ v \f$ is a variable (nonlinear or coupled). | ||
*/ | ||
template <ComputeStage compute_stage> | ||
class ADMatReaction : public ADKernel<compute_stage> | ||
{ | ||
public: | ||
ADMatReaction(const InputParameters & parameters); | ||
virtual void initialSetup(); | ||
|
||
protected: | ||
virtual ADReal computeQpResidual(); | ||
|
||
/** | ||
* Kernel variable (can be nonlinear or coupled variable) | ||
* (For constrained Allen-Cahn problems, v = lambda | ||
* where lambda is the Lagrange multiplier) | ||
*/ | ||
const ADVariableValue & _v; | ||
|
||
/// Reaction rate | ||
const ADMaterialProperty(Real) & _mob; | ||
|
||
usingKernelMembers; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
//* This file is part of the MOOSE framework | ||
//* https://www.mooseframework.org | ||
//* | ||
//* All rights reserved, see COPYRIGHT for full restrictions | ||
//* https://github.com/idaholab/moose/blob/master/COPYRIGHT | ||
//* | ||
//* Licensed under LGPL 2.1, please see LICENSE for details | ||
//* https://www.gnu.org/licenses/lgpl-2.1.html | ||
|
||
#include "ADMatReaction.h" | ||
|
||
registerADMooseObject("PhaseFieldApp", ADMatReaction); | ||
|
||
defineADValidParams( | ||
ADMatReaction, | ||
ADKernel, | ||
params.addCoupledVar("v", | ||
"Set this to make v a coupled variable, otherwise it will use the " | ||
"kernel's nonlinear variable for v"); | ||
params.addClassDescription("Kernel to add -L*v, where L=reaction rate, v=variable"); | ||
params.addParam<MaterialPropertyName>("mob_name", | ||
"L", | ||
"The reaction rate used with the kernel");); | ||
|
||
template <ComputeStage compute_stage> | ||
ADMatReaction<compute_stage>::ADMatReaction(const InputParameters & parameters) | ||
: ADKernel<compute_stage>(parameters), | ||
_v(isCoupled("v") ? adCoupledValue("v") : _u), | ||
_mob(adGetADMaterialProperty<Real>("mob_name")) | ||
{ | ||
} | ||
|
||
template <ComputeStage compute_stage> | ||
ADReal | ||
ADMatReaction<compute_stage>::computeQpResidual() | ||
{ | ||
return -_mob[_qp] * _test[_i][_qp] * _v[_qp]; | ||
} |