Skip to content
Permalink
Browse files

Merge pull request #13261 from tophmatthews/ad_pressure_13260

ADBCs
  • Loading branch information...
lindsayad committed Apr 30, 2019
2 parents 4732bad + c2b58fd commit 2d219d339aa486d1a03d72452638f7d3fbbaaa2d
Showing with 3,493 additions and 33 deletions.
  1. +1 −0 .gitignore
  2. +23 −0 framework/doc/content/source/bcs/ADFunctionPresetBC.md
  3. +21 −0 framework/doc/content/source/bcs/ADPresetBC.md
  4. +1 −1 framework/doc/content/source/bcs/FunctionPresetBC.md
  5. +1 −1 framework/doc/content/source/bcs/PresetBC.md
  6. +43 −0 framework/doc/content/source/kernels/ADBodyForce.md
  7. +4 −0 framework/include/base/MooseObject.h
  8. +41 −0 framework/include/bcs/ADFunctionPresetBC.h
  9. +5 −1 framework/include/bcs/ADIntegratedBC.h
  10. +6 −4 framework/include/bcs/ADNodalBC.h
  11. +35 −0 framework/include/bcs/ADPresetBC.h
  12. +40 −0 framework/include/bcs/ADPresetNodalBC.h
  13. +2 −1 framework/include/bcs/PresetBC.h
  14. +1 −1 framework/include/bcs/PresetNodalBC.h
  15. +49 −0 framework/include/kernels/ADBodyForce.h
  16. +2 −2 framework/include/kernels/ADKernel.h
  17. +1 −2 framework/include/materials/ADMaterial.h
  18. +3 −0 framework/include/systems/NonlinearSystemBase.h
  19. +33 −0 framework/src/bcs/ADFunctionPresetBC.C
  20. +5 −3 framework/src/bcs/ADIntegratedBC.C
  21. +31 −0 framework/src/bcs/ADPresetBC.C
  22. +44 −0 framework/src/bcs/ADPresetNodalBC.C
  23. +43 −0 framework/src/kernels/ADBodyForce.C
  24. +14 −0 framework/src/systems/NonlinearSystemBase.C
  25. +24 −0 modules/tensor_mechanics/doc/content/source/bcs/ADPressure.md
  26. +3 −0 modules/tensor_mechanics/doc/content/syntax/BCs/Pressure/index.md
  27. +3 −0 modules/tensor_mechanics/include/actions/PressureAction.h
  28. +46 −0 modules/tensor_mechanics/include/bcs/ADPressure.h
  29. +30 −5 modules/tensor_mechanics/src/actions/PressureAction.C
  30. +55 −0 modules/tensor_mechanics/src/bcs/ADPressure.C
  31. +5 −1 modules/tensor_mechanics/src/kernels/ADStressDivergenceRZTensors.C
  32. +5 −1 modules/tensor_mechanics/src/kernels/ADStressDivergenceTensors.C
  33. +131 −0 modules/tensor_mechanics/test/tests/ad_1D_spherical/finiteStrain_1DSphere_hollow.i
  34. +1 −0 modules/tensor_mechanics/test/tests/ad_1D_spherical/gold/finiteStrain_1DSphere_hollow_out.e
  35. +1 −0 modules/tensor_mechanics/test/tests/ad_1D_spherical/gold/smallStrain_1DSphere_out.e
  36. +132 −0 modules/tensor_mechanics/test/tests/ad_1D_spherical/smallStrain_1DSphere.i
  37. +69 −0 modules/tensor_mechanics/test/tests/ad_1D_spherical/tests
  38. +99 −0 modules/tensor_mechanics/test/tests/ad_2D_geometries/2D-RZ_centerline_VLC.i
  39. +212 −0 modules/tensor_mechanics/test/tests/ad_2D_geometries/2D-RZ_finiteStrain_resid.i
  40. +206 −0 modules/tensor_mechanics/test/tests/ad_2D_geometries/2D-RZ_finiteStrain_test.i
  41. +1 −0 modules/tensor_mechanics/test/tests/ad_2D_geometries/2D-RZ_mesh.e
  42. +163 −0 modules/tensor_mechanics/test/tests/ad_2D_geometries/2D-RZ_test.i
  43. +225 −0 modules/tensor_mechanics/test/tests/ad_2D_geometries/3D-RZ_finiteStrain_test.i
  44. +1 −0 modules/tensor_mechanics/test/tests/ad_2D_geometries/gold/2D-RZ_centerline_VLC_out.csv
  45. +1 −0 modules/tensor_mechanics/test/tests/ad_2D_geometries/gold/2D-RZ_finiteStrain_resid_bbar_out.e
  46. +1 −0 modules/tensor_mechanics/test/tests/ad_2D_geometries/gold/2D-RZ_finiteStrain_resid_out.e
  47. +1 −0 modules/tensor_mechanics/test/tests/ad_2D_geometries/gold/2D-RZ_finiteStrain_test_out.e
  48. +1 −0 modules/tensor_mechanics/test/tests/ad_2D_geometries/gold/2D-RZ_incremental_strain_bbar_test_out.e
  49. +1 −0 modules/tensor_mechanics/test/tests/ad_2D_geometries/gold/2D-RZ_incremental_strain_test_out.e
  50. +1 −0 modules/tensor_mechanics/test/tests/ad_2D_geometries/gold/2D-RZ_smallstrain_bbar_test_out.e
  51. +1 −0 modules/tensor_mechanics/test/tests/ad_2D_geometries/gold/2D-RZ_test_out.e
  52. +1 −0 modules/tensor_mechanics/test/tests/ad_2D_geometries/gold/3D-RZ_finiteStrain_test_out.e
  53. +1 −0 modules/tensor_mechanics/test/tests/ad_2D_geometries/square.e
  54. +165 −0 modules/tensor_mechanics/test/tests/ad_2D_geometries/tests
  55. +115 −0 modules/tensor_mechanics/test/tests/ad_finite_strain_jacobian/3d_bar.i
  56. +111 −0 modules/tensor_mechanics/test/tests/ad_finite_strain_jacobian/bending_jacobian.i
  57. +1 −0 modules/tensor_mechanics/test/tests/ad_finite_strain_jacobian/gold/3d_bar_out.e
  58. +1 −0 modules/tensor_mechanics/test/tests/ad_finite_strain_jacobian/gold/bending_jacobian_bbar_out.e
  59. +1 −0 modules/tensor_mechanics/test/tests/ad_finite_strain_jacobian/gold/bending_jacobian_out.e
  60. +101 −0 modules/tensor_mechanics/test/tests/ad_finite_strain_jacobian/tests
  61. +139 −0 modules/tensor_mechanics/test/tests/ad_isotropic_elasticity_tensor/2D-axisymmetric_rz_test.i
  62. +89 −0 modules/tensor_mechanics/test/tests/ad_isotropic_elasticity_tensor/bulk_modulus_shear_modulus_test.i
  63. +1 −0 ...les/tensor_mechanics/test/tests/ad_isotropic_elasticity_tensor/gold/2D-axisymmetric_rz_test_out.e
  64. +1 −0 ...or_mechanics/test/tests/ad_isotropic_elasticity_tensor/gold/bulk_modulus_shear_modulus_test_out.e
  65. +1 −0 ...s/tensor_mechanics/test/tests/ad_isotropic_elasticity_tensor/gold/lambda_shear_modulus_test_out.e
  66. +1 −0 ...mechanics/test/tests/ad_isotropic_elasticity_tensor/gold/youngs_modulus_poissons_ratio_test_out.e
  67. +89 −0 modules/tensor_mechanics/test/tests/ad_isotropic_elasticity_tensor/lambda_shear_modulus_test.i
  68. +74 −0 modules/tensor_mechanics/test/tests/ad_isotropic_elasticity_tensor/tests
  69. +98 −0 ...s/tensor_mechanics/test/tests/ad_isotropic_elasticity_tensor/youngs_modulus_poissons_ratio_test.i
  70. +3 −3 modules/tensor_mechanics/test/tests/ad_plastic/power_law_creep.i
  71. +1 −0 modules/tensor_mechanics/test/tests/ad_pressure/gold/pressure_test_out.e
  72. +1 −0 modules/tensor_mechanics/test/tests/ad_pressure/pressure_test.e
  73. +144 −0 modules/tensor_mechanics/test/tests/ad_pressure/pressure_test.i
  74. +63 −0 modules/tensor_mechanics/test/tests/ad_pressure/tests
  75. +16 −0 modules/tensor_mechanics/test/tests/finite_strain_jacobian/tests
  76. +2 −1 modules/tensor_mechanics/test/tests/pressure/pressure_test.i
  77. +69 −0 test/tests/bcs/ad_bc_preset_nodal/bc_function_preset.i
  78. +58 −0 test/tests/bcs/ad_bc_preset_nodal/bc_preset_nodal.i
  79. +1 −0 test/tests/bcs/ad_bc_preset_nodal/gold/bc_func_out.e
  80. +1 −0 test/tests/bcs/ad_bc_preset_nodal/gold/bc_preset_out.e
  81. +40 −0 test/tests/bcs/ad_bc_preset_nodal/tests
  82. +0 −1 test/tests/bcs/bc_preset_nodal/tests
  83. +90 −0 test/tests/bcs/function_dirichlet_bc/ad-function_dirichlet_bc_test.i
  84. +1 −0 test/tests/bcs/function_dirichlet_bc/gold/ad-out.e
  85. +19 −0 test/tests/bcs/function_dirichlet_bc/tests
  86. +79 −0 test/tests/kernels/ad_2d_diffusion/2d_diffusion_bodyforce_test.i
  87. +4 −5 test/tests/kernels/{2d_diffusion/parallel_diffusion_test.i → ad_2d_diffusion/2d_diffusion_test.i}
  88. +1 −0 test/tests/kernels/ad_2d_diffusion/gold/ad-bodyforce_out.e
  89. +1 −0 test/tests/kernels/ad_2d_diffusion/gold/ad-out.e
  90. +1 −0 test/tests/kernels/ad_2d_diffusion/gold/bodyforce_out.e
  91. +1 −0 test/tests/kernels/ad_2d_diffusion/gold/out.e
  92. +1 −0 test/tests/kernels/ad_2d_diffusion/square.e
  93. +38 −0 test/tests/kernels/ad_2d_diffusion/tests
@@ -200,6 +200,7 @@ python/MooseDocs/test/output
!python/MooseDocs/test/gold/**/*.json
!python/MooseDocs/test/gold/**/*.html
!python/MooseDocs/test/gold/**/*.tex
.ruby-version

# Chigger
!python/chigger/tests/**/gold/*.png
@@ -0,0 +1,23 @@
# ADFunctionPresetBC

!syntax description /BCs/ADFunctionPresetBC

## Description

The `ADFunctionPresetBC` takes the same inputs as
[ADFunctionDirichletBC](/ADFunctionDirichletBC.md) and also acts as a
Dirichlet boundary condition. However, the implementation is slightly different;
`ADFunctionPresetBC` causes the value of the boundary condition to be applied before the
solve begins where [ADFunctionDirichletBC](/ADFunctionDirichletBC.md)
enforces the boundary condition as the solve
progresses. In certain situations, one is better than another.

## Example Input Syntax

!listing test/tests/bcs/ad_bc_preset_nodal/bc_function_preset.i block=BCs

!syntax parameters /BCs/ADFunctionPresetBC

!syntax inputs /BCs/ADFunctionPresetBC

!syntax children /BCs/ADFunctionPresetBC
@@ -0,0 +1,21 @@
# ADPresetBC

!syntax description /BCs/ADPresetBC

## Description

The `ADPresetBC` takes the same inputs as [DirichletBC](/DirichletBC.md)
and also acts as a Dirichlet boundary condition. However, the implementation is slightly different;
`PresetBC` causes the value of the boundary condition to be applied before the solve begins where
[DirichletBC](/DirichletBC.md) enforces the boundary condition as the solve progresses. In
certain situations, one is better than another.

## Example Input Syntax

!listing test/tests/bcs/ad_bc_preset_nodal/bc_preset_nodal.i block=BCs

!syntax parameters /BCs/ADPresetBC

!syntax inputs /BCs/ADPresetBC

!syntax children /BCs/ADPresetBC
@@ -6,7 +6,7 @@

The `FunctionPresetBC` takes the same inputs as
[FunctionDirichletBC](/FunctionDirichletBC.md) and also acts as a
Dirichlet boundary condition. However, the implementation is slightly different.
Dirichlet boundary condition. However, the implementation is slightly different;
`FunctionPresetBC` causes the value of the boundary condition to be applied before the
solve begins where [FunctionDirichletBC](/FunctionDirichletBC.md)
enforces the boundary condition as the solve
@@ -6,7 +6,7 @@

The `PresetBC` takes the same inputs as [DirichletBC](/DirichletBC.md)
and also acts as a Dirichlet
boundary condition. However, the implementation is slightly different. `PresetBC` causes
boundary condition. However, the implementation is slightly different; `PresetBC` causes
the value of the boundary condition to be applied before the solve begins where
[DirichletBC](/DirichletBC.md) enforces the boundary
condition as the solve progresses. In certain
@@ -0,0 +1,43 @@
# ADBodyForce

## Description

`ADBodyForce` implements a force term in momentum transport or structural
mechanics or a source term in species/mass transport. The strong form, given a
domain $\Omega$ is defined as

\begin{equation}
\underbrace{-f}_{\textrm{ADBodyForce}} + \sum_{i=1}^n \beta_i = 0 \in \Omega
\end{equation}
where $f$ is the source term (negative if a sink) and the second term on the
left hand side represents the strong forms of other kernels. The `ADBodyForce`
weak form, in inner-product notation, is defined as

\begin{equation}
R_i(u_h) = (\psi_i, -f) \quad \forall \psi_i,
\end{equation}
where the $\psi_i$ are the test functions, and $u_h$ are the trial solutions in
the finite dimensional space $\mathcal{S}^h$ for the unknown ($u$).

The force is constructed through a user supplied constant $c$,
[function](/Functions/index.md) value evaluated at the current time and
quadrature point $f$, and/or [postprocessor](/Postprocessors/index.md)
value $p$. The constant $c$, supplied through the parameter `value`, may also be
controlled over the course of a transient simulation with a
[`Controls`](/Controls/index.md) block. $c$, $f$, $p$ are supplied
through the input parameters `value`, `function`, and `postprocessor`
respectively. Not supplying $c$, $f$, or $p$ through its corresponding
parameter is equivalent to setting its value to unity.

## Example Syntax

The case below demonstrates the use of `ADBodyForce` where the force term is
supplied solely through the a function (denoted by `function`):

!listing test/tests/bcs/ad_bc_preset_nodal/bc_function_preset.i block=Kernels

!syntax parameters /Kernels/ADBodyForce

!syntax inputs /Kernels/ADBodyForce

!syntax children /Kernels/ADBodyForce
@@ -16,6 +16,10 @@

#include "libmesh/parallel_object.h"

#define usingMooseObjectMembers \
using MooseObject::isParamValid; \
using MooseObject::paramError

class MooseApp;
class MooseObject;

@@ -0,0 +1,41 @@
//* 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 "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;
};
@@ -57,6 +57,9 @@ class ADIntegratedBCTempl : public IntegratedBCBase, public MooseVariableInterfa

/// The ad version of JxW
const MooseArray<typename Moose::RealType<compute_stage>::type> & _ad_JxW;

/// The AD version of coord
const MooseArray<typename Moose::RealType<compute_stage>::type> & _ad_coord;
};

template <ComputeStage compute_stage>
@@ -68,6 +71,8 @@ declareADValidParams(ADIntegratedBC);
declareADValidParams(ADVectorIntegratedBC);

#define usingTemplIntegratedBCMembers(type) \
usingMooseObjectMembers; \
usingCoupleableMembers; \
using ADIntegratedBCTempl<type, compute_stage>::_test; \
using ADIntegratedBCTempl<type, compute_stage>::_qp; \
using ADIntegratedBCTempl<type, compute_stage>::_i; \
@@ -82,7 +87,6 @@ declareADValidParams(ADVectorIntegratedBC);
using ADIntegratedBCTempl<type, compute_stage>::_assembly; \
using ADIntegratedBCTempl<type, compute_stage>::_local_ke; \
using ADIntegratedBCTempl<type, compute_stage>::_j; \
using ADIntegratedBCTempl<type, compute_stage>::_JxW; \
using ADIntegratedBCTempl<type, compute_stage>::_coord; \
using ADIntegratedBCTempl<type, compute_stage>::_qrule; \
using ADIntegratedBCTempl<type, compute_stage>::_normals; \
@@ -13,7 +13,7 @@
#include "MooseVariableInterface.h"

/**
* Base class for deriving any boundary condition of a integrated type
* Base class for deriving any automatic differentiation boundary condition of a integrated type
*/
template <typename T, ComputeStage compute_stage>
class ADNodalBCTempl : public NodalBCBase, public MooseVariableInterface<T>
@@ -52,14 +52,16 @@ declareADValidParams(ADNodalBC);
declareADValidParams(ADVectorNodalBC);

#define usingTemplNodalBCMembers(type) \
usingMooseObjectMembers; \
using ADNodalBCTempl<type, compute_stage>::_u; \
using ADNodalBCTempl<type, compute_stage>::_var; \
using ADNodalBCTempl<type, compute_stage>::_current_node; \
using ADNodalBCTempl<type, compute_stage>::_t; \
using ADNodalBCTempl<type, compute_stage>::computeResidual; \
using ADNodalBCTempl<type, compute_stage>::computeJacobian; \
using ADNodalBCTempl<type, compute_stage>::computeOffDiagJacobian; \
using ADNodalBCTempl<type, compute_stage>::getFunction; \
using ADNodalBCTempl<type, compute_stage>::variable; \
using ADNodalBCTempl<type, compute_stage>::paramError; \
using ADNodalBCTempl<type, compute_stage>::isParamValid
using ADNodalBCTempl<type, compute_stage>::variable

#define usingNodalBCMembers usingTemplNodalBCMembers(Real)
#define usingVectorNodalBCMembers usingTemplNodalBCMembers(RealVectorValue)
@@ -0,0 +1,35 @@
//* 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 "ADPresetNodalBC.h"

template <ComputeStage>
class ADPresetBC;

declareADValidParams(ADPresetBC);

/**
* Defines a boundary condition that (pre)sets the solution at the boundary
* to be a user specified value.
*/
template <ComputeStage compute_stage>
class ADPresetBC : public ADPresetNodalBC<compute_stage>
{
public:
ADPresetBC(const InputParameters & parameters);

protected:
virtual ADReal computeQpValue() override;

const Real & _value;

usingPresetNodalBCMembers;
};
@@ -0,0 +1,40 @@
//* 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 "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;
};
@@ -17,7 +17,8 @@ template <>
InputParameters validParams<PresetBC>();

/**
* TODO:
* Defines a boundary condition that (pre)sets the solution at the boundary
* to be a user specified value.
*/
class PresetBC : public PresetNodalBC
{
@@ -17,7 +17,7 @@ template <>
InputParameters validParams<PresetNodalBC>();

/**
* TODO
* Base class for nodal BCs that (pre)set the solution vector entries.
*/
class PresetNodalBC : public NodalBC
{
@@ -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

#pragma once

#include "ADKernelValue.h"

// Forward Declaration
template <ComputeStage>
class ADBodyForce;
class Function;

declareADValidParams(ADBodyForce);

/**
* This kernel implements a generic functional
* body force term:
* $ - c \cdof f \cdot \phi_i $
*
* The coefficient and function both have defaults
* equal to 1.0.
*/
template <ComputeStage compute_stage>
class ADBodyForce : public ADKernelValue<compute_stage>
{
public:
ADBodyForce(const InputParameters & parameters);

protected:
virtual ADReal precomputeQpResidual() override;

/// Scale factor
const Real & _scale;

/// Optional function value
Function & _function;

/// Optional Postprocessor value
const PostprocessorValue & _postprocessor;

usingKernelValueMembers;
using KernelBase::_q_point;
};
@@ -15,6 +15,7 @@
#include "metaphysicl/dualnumber.h"

#define usingTemplKernelMembers(type) \
usingMooseObjectMembers; \
usingCoupleableMembers; \
usingBlockRestrictableMembers; \
usingFunctionInterfaceMembers; \
@@ -50,8 +51,7 @@
using ADKernelTempl<type, compute_stage>::accumulateTaggedLocalResidual; \
using ADKernelTempl<type, compute_stage>::accumulateTaggedLocalMatrix; \
using ADKernelTempl<type, compute_stage>::variable; \
using ADKernelTempl<type, compute_stage>::paramError; \
using ADKernelTempl<type, compute_stage>::isParamValid
using ADKernelTempl<type, compute_stage>::getPostprocessorValue

#define usingKernelMembers usingTemplKernelMembers(Real)
#define usingVectorKernelMembers usingTemplKernelMembers(RealVectorValue)
Oops, something went wrong.

0 comments on commit 2d219d3

Please sign in to comment.
You can’t perform that action at this time.