Browse files

Merge pull request #12738 from lindsayad/ad-work

A lot more automatic differentiation
  • Loading branch information...
friedmud committed Feb 4, 2019
2 parents 28eaab6 + 06fa9a8 commit ac83b4d3596e422438688484ba17b154516d9fb5
Showing 310 changed files with 5,960 additions and 1,433 deletions.
@@ -0,0 +1,12 @@
# AddADBCAction

The `AddADBCAction` is responsible for adding automatic differention
kernels, e.g. `ADBCs`. It adds both `ADBC<RESIDUAL>` and
`ADBC<JACOBIAN>` objects, which are responsible for computing the residual
and jacobian respectively.

!syntax description /ADBCs/AddADBCAction

!syntax parameters /ADBCs/AddADBCAction

!bibtex bibliography
@@ -0,0 +1,41 @@
# ADFunctionDirichletBC

!syntax description /ADBCs/ADFunctionDirichletBC<RESIDUAL>

## Description

`ADFunctionDirichletBC` is a generalization of [`DirichletBC`](/ which
imposes a possibly temporally- and spatially-dependent value defined
by a MOOSE [`Function`](/Functions/ object on a particular set of degrees of freedom
(DOFs) defined by the `boundary` parameter. That is, for a
PDE of the form

-\nabla^2 u &= f && \quad \in \Omega \\
u &= g(t,\vec{x}) && \quad \in \partial \Omega_D \\
\frac{\partial u}{\partial n} &= h(t,\vec{x}) && \quad \in \partial \Omega_N

where $\Omega \subset \mathbb{R}^n$ is the domain, and $\partial
\Omega = \partial \Omega_D \cup \partial \Omega_N$ is its boundary,
a `ADFunctionDirichletBC` object can be used to impose the
condition (2) if the function is well-defined for $\vec{x} \in
\partial \Omega_D$. In this case, the `function` parameter corresponds to a
MOOSE `Function` object which represents the mathematical function
$g(t,\vec{x})$, and the user must define one or more sidesets
corresponding to the boundary subset $\partial \Omega_D$ via the
`boundary` parameter.

Note that `ADFunctionDirichletBC` computes its Jacobian using automatic differentiation.

## Example Input Syntax

!listing test/tests/bcs/ad_bcs/ad_bc.i block=ADBCs

!syntax parameters /ADBCs/ADFunctionDirichletBC<RESIDUAL>

!syntax inputs /ADBCs/ADFunctionDirichletBC<RESIDUAL>

!syntax children /ADBCs/ADFunctionDirichletBC<RESIDUAL>
@@ -0,0 +1,37 @@
# ADLagrangeVecFunctionDirichletBC

!syntax description /ADBCs/ADLagrangeVecFunctionDirichletBC<RESIDUAL>

## Description

`ADLagrangeVecFunctionDirichletBC` is the extension of [`FunctionDirichletBC`](bcs/DirichletBC) to
Lagrange vector variables and is used for
imposing so-called "essential" boundary conditions on systems of
partial differential equations (PDEs). Such boundary conditions force
a particular set of degrees of freedom (DOFs) defined by the
`boundary` parameter to take on controllable values. This
class is appropriate to use for PDEs of the form
-\nabla^2 \vec{u} &= \vec{f} && \quad \in \Omega \\
\vec{u} &= \vec{g} && \quad \in \partial \Omega_D \\
\frac{\partial \vec{u}}{\partial n} &= \vec{h} && \quad \in \partial \Omega_N

where $\Omega \subset \mathbb{R}^n$ is the domain, and $\partial
\Omega = \partial \Omega_D \cup \partial \Omega_N$ is its boundary. In
this case, a `LagrangeVecFunctionDirichletBC` object is used to impose the condition (2)
on the subset of the boundary denoted by $\partial \Omega_D$. In this case,
$\vec{g}$ is supplied through the `Function` parameters `x_exact_soln`, `y_exact_soln`, and
`z_exact_soln`. If any of those parameters are not supplied by the user, they
take a default value of $0$. The user must define one
or more sidesets corresponding to the boundary subset $\partial \Omega_D$.

Note that this BC computes its Jacobian using automatic differentiation

!syntax parameters /ADBCs/ADLagrangeVecFunctionDirichletBC<RESIDUAL>

!syntax inputs /ADBCs/ADLagrangeVecFunctionDirichletBC<RESIDUAL>

!syntax children /ADBCs/ADLagrangeVecFunctionDirichletBC<RESIDUAL>
@@ -0,0 +1,13 @@
# ADVectorDiffusion

## Description

`ADVectorDiffusion` is analogous to [`Diffusion`](/
except it is applied to vector finite element variables and the Jacobian is
computed automatically using automatic differentiation.

!syntax parameters /ADKernels/ADVectorDiffusion<RESIDUAL>

!syntax inputs /ADKernels/ADVectorDiffusion<RESIDUAL>

!syntax children /ADKernels/ADVectorDiffusion<RESIDUAL>
@@ -0,0 +1,17 @@
# ADBCs System

A `BC` is an object that represents a PDE boundary condition. It is applied
to select boundaries of the simulation domain using the `boundary` parameter in
the relevant sub-block of the `ADBCs` block of a MOOSE input file. There are two
different flavors of `BCs`: `IntegratedBCs` and `NodalBCs`. `IntegratedBCs` are
integrated over the domain boundary and are imposed weakly. `NodalBCs` are
applied strongly at individual nodes and are not integrated. An `AD` prefix,
as in `ADNodalBC`, indicates that the Jacobians for subclasses deriving from the
parent type are computed using automatic differentiation. In an `ADBC` subclass the `computeQpResidual()` function +must+ be overridden.

## Custom ADBC Creation

To create a custom `ADNodalBC`, you can follow the pattern of the
[`ADFunctionDirichletBC`](/ object implemented and
included in the MOOSE framework. For demonstration of an `ADIntegratedBC`, you
can refer to the [`ADRobinBC`](/ADRobinBC.C) test object.
@@ -0,0 +1,28 @@
//* This file is part of the MOOSE framework
//* All rights reserved, see COPYRIGHT for full restrictions
//* Licensed under LGPL 2.1, please see LICENSE for details


#include "MooseADObjectAction.h"

class AddADBCAction;

template <>
InputParameters validParams<AddADBCAction>();

class AddADBCAction : public MooseADObjectAction
AddADBCAction(InputParameters params);

virtual void act() override;

@@ -41,6 +41,8 @@ class MooseADObjectAction : public Action
const std::string & getMooseObjectType() const { return _type; }

void flagDoingAD();

/// The Object type that is being created
std::string _type;
Oops, something went wrong.

0 comments on commit ac83b4d

Please sign in to comment.