forked from idaholab/moose
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
17 changed files
with
382 additions
and
15 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
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,44 @@ | ||
//* 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 | ||
|
||
#ifndef ADFUNCTIONPRESETBC_H | ||
#define ADFUNCTIONPRESETBC_H | ||
|
||
#include "ADPresetNodalBC.h" | ||
|
||
// Forward Declarations | ||
template <ComputeStage> | ||
class ADFunctionPresetBC; | ||
class Function; | ||
|
||
declareADValidParams(ADFunctionPresetBC); | ||
|
||
/** | ||
* Defines a boundary condition that forces the value to be a user specified | ||
* function at the boundary. | ||
*/ | ||
template <ComputeStage compute_stage> | ||
class ADFunctionPresetBC : public ADPresetNodalBC<compute_stage> | ||
{ | ||
public: | ||
ADFunctionPresetBC(const InputParameters & parameters); | ||
|
||
protected: | ||
/** | ||
* Evaluate the function at the current quadrature point and timestep. | ||
*/ | ||
virtual ADReal computeQpValue() override; | ||
|
||
/// Function being used for evaluation of this BC | ||
Function & _func; | ||
|
||
usingPresetNodalBCMembers; | ||
}; | ||
|
||
#endif // ADFUNCTIONPRESETBC_H |
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
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,37 @@ | ||
//* 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 | ||
|
||
#ifndef ADPRESETBC_H | ||
#define ADPRESETBC_H | ||
|
||
#include "ADPresetNodalBC.h" | ||
|
||
template <ComputeStage> | ||
class ADPresetBC; | ||
|
||
declareADValidParams(ADPresetBC); | ||
|
||
/** | ||
* TODO: | ||
*/ | ||
template <ComputeStage compute_stage> | ||
class ADPresetBC : public ADPresetNodalBC<compute_stage> | ||
{ | ||
public: | ||
ADPresetBC(const InputParameters & parameters); | ||
|
||
protected: | ||
virtual ADReal computeQpValue() override; | ||
|
||
const Real & _value; | ||
|
||
usingPresetNodalBCMembers; | ||
}; | ||
|
||
#endif // ADPRESETBC_H |
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,43 @@ | ||
//* 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 | ||
|
||
#ifndef ADPRESETNODALBC_H | ||
#define ADPRESETNODALBC_H | ||
|
||
#include "ADNodalBC.h" | ||
|
||
#define usingPresetNodalBCMembers \ | ||
usingNodalBCMembers; \ | ||
using ADPresetNodalBC<compute_stage>::computeQpValue | ||
|
||
template <ComputeStage> | ||
class ADPresetNodalBC; | ||
|
||
declareADValidParams(ADPresetNodalBC); | ||
|
||
/** | ||
* Base class for automatic differentiation nodal BCs that (pre)set the solution | ||
* vector entries. | ||
*/ | ||
template <ComputeStage compute_stage> | ||
class ADPresetNodalBC : public ADNodalBC<compute_stage> | ||
{ | ||
public: | ||
ADPresetNodalBC(const InputParameters & parameters); | ||
|
||
void computeValue(NumericVector<Number> & current_solution); | ||
|
||
protected: | ||
virtual ADResidual computeQpResidual() override; | ||
virtual ADReal computeQpValue() = 0; | ||
|
||
usingNodalBCMembers; | ||
}; | ||
|
||
#endif // ADPRESETNODALBC_H |
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
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,33 @@ | ||
//* 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 "ADFunctionPresetBC.h" | ||
#include "Function.h" | ||
|
||
registerADMooseObject("MooseApp", ADFunctionPresetBC); | ||
|
||
defineADValidParams( | ||
ADFunctionPresetBC, | ||
ADPresetNodalBC, | ||
params.addRequiredParam<FunctionName>("function", "The forcing function."); | ||
params.addClassDescription( | ||
"The same as FunctionDirichletBC except the value is applied before the solve begins");); | ||
|
||
template <ComputeStage compute_stage> | ||
ADFunctionPresetBC<compute_stage>::ADFunctionPresetBC(const InputParameters & parameters) | ||
: ADPresetNodalBC<compute_stage>(parameters), _func(getFunction("function")) | ||
{ | ||
} | ||
|
||
template <ComputeStage compute_stage> | ||
ADReal | ||
ADFunctionPresetBC<compute_stage>::computeQpValue() | ||
{ | ||
return _func.value(_t, *_current_node); | ||
} |
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,31 @@ | ||
//* 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 "ADPresetBC.h" | ||
|
||
registerADMooseObject("MooseApp", ADPresetBC); | ||
|
||
defineADValidParams( | ||
ADPresetBC, ADPresetNodalBC, params.addRequiredParam<Real>("value", "Value of the BC"); | ||
params.declareControllable("value"); | ||
params.addClassDescription( | ||
"Similar to DirichletBC except the value is applied before the solve begins");); | ||
|
||
template <ComputeStage compute_stage> | ||
ADPresetBC<compute_stage>::ADPresetBC(const InputParameters & parameters) | ||
: ADPresetNodalBC<compute_stage>(parameters), _value(adGetParam<Real>("value")) | ||
{ | ||
} | ||
|
||
template <ComputeStage compute_stage> | ||
ADReal | ||
ADPresetBC<compute_stage>::computeQpValue() | ||
{ | ||
return _value; | ||
} |
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,44 @@ | ||
//* 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 "ADPresetNodalBC.h" | ||
|
||
// MOOSE includes | ||
#include "MooseVariableFE.h" | ||
|
||
#include "libmesh/numeric_vector.h" | ||
|
||
defineADValidParams(ADPresetNodalBC, | ||
ADNodalBC, | ||
params.addClassDescription( | ||
"Nodal boundary condition base class with preset solution vector values.")); | ||
|
||
template <ComputeStage compute_stage> | ||
ADPresetNodalBC<compute_stage>::ADPresetNodalBC(const InputParameters & parameters) | ||
: ADNodalBC<compute_stage>(parameters) | ||
{ | ||
} | ||
|
||
template <ComputeStage compute_stage> | ||
void | ||
ADPresetNodalBC<compute_stage>::computeValue(NumericVector<Number> & current_solution) | ||
{ | ||
dof_id_type & dof_idx = _var.nodalDofIndex(); | ||
current_solution.set(dof_idx, MetaPhysicL::raw_value(computeQpValue())); | ||
} | ||
|
||
template <ComputeStage compute_stage> | ||
ADResidual | ||
ADPresetNodalBC<compute_stage>::computeQpResidual() | ||
{ | ||
return _u - computeQpValue(); | ||
} | ||
|
||
// explicit instantiation is required for AD base classes | ||
adBaseClass(ADPresetBC); |
24 changes: 24 additions & 0 deletions
24
modules/tensor_mechanics/doc/content/source/bcs/ADPressure.md
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,24 @@ | ||
# ADPressure | ||
|
||
!syntax description /ADBCs/ADPressure<RESIDUAL> | ||
|
||
## Description | ||
|
||
The boundary condition, `ADPressure` applies a force to a mesh boundary in the | ||
magnitude specified by the user. A `component` of the normal vector to the mesh | ||
surface (0, 1, or 2 corresponding to the $\hat{x}$, $\hat{y}$, and $\hat{z}$ | ||
vector components) is used to determine the direction in which to apply the | ||
traction. The boundary condition is always applied to the displaced mesh and | ||
uses forward mode automatic differentiation to compute an exact Jacobian | ||
contribution (this is contingent on coupling only AD enabled objects in the | ||
parameters). | ||
|
||
The magnitude of the `ADPressure` boundary condition can be specified as either | ||
a constant scalar factor (use the input parameter `constant`), a factor from a | ||
`function`, a factor from a `postprocessor`, or any combination thereof. | ||
|
||
!syntax parameters /ADBCs/ADPressure<RESIDUAL> | ||
|
||
!syntax inputs /ADBCs/ADPressure<RESIDUAL> | ||
|
||
!syntax children /ADBCs/ADPressure<RESIDUAL> |
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,49 @@ | ||
//* 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 | ||
|
||
#ifndef ADPRESSURE_H | ||
#define ADPRESSURE_H | ||
|
||
#include "ADIntegratedBC.h" | ||
|
||
class Function; | ||
|
||
template <ComputeStage> | ||
class ADPressure; | ||
|
||
declareADValidParams(ADPressure); | ||
|
||
/** | ||
* ADPressure applies a pressure on a given boundary in the direction defined by component | ||
*/ | ||
template <ComputeStage compute_stage> | ||
class ADPressure : public ADIntegratedBC<compute_stage> | ||
{ | ||
public: | ||
ADPressure(const InputParameters & parameters); | ||
|
||
protected: | ||
ADResidual computeQpResidual() override; | ||
|
||
/// displacement component to apply the kernel to | ||
const int _component; | ||
|
||
///@{ Pressure value constant factor, function factor, and postprocessor factor | ||
const Real _constant; | ||
Function * const _function; | ||
const PostprocessorValue * const _postprocessor; | ||
///@} | ||
|
||
/// _alpha Parameter for HHT time integration scheme | ||
const Real _alpha; | ||
|
||
usingIntegratedBCMembers; | ||
}; | ||
|
||
#endif // ADPRESSURE_H |
Oops, something went wrong.