Skip to content
Permalink
Browse files

Merge pull request #13019 from dschwen/advectortimederivative_13017

 Add vector time derivative
  • Loading branch information...
lindsayad committed Mar 7, 2019
2 parents 3da7fe0 + eb3dc1c commit 19a3d8261784a922ecb04f45154dc36d715f4138
@@ -0,0 +1,40 @@
# ADVectorTimeDerivative

## Description

The `ADVectorTimeDerivative` kernel implements a simple time derivative for the
domain $\Omega$ given by

\begin{equation}
\underbrace{\frac{\partial \vec u}{\partial t}}_{\textrm{ADVectorTimeDerivative}} +
\sum_{i=1}^n \beta_i = 0 \in \Omega.
\end{equation}

where the second term on the left hand side corresponds to the strong forms of
other kernels. The corresponding `ADVectorTimeDerivative` weak form using
inner-product notation is

\begin{equation}
R_i(\vec u_h) = (\vec \psi_i, \frac{\partial \vec u_h}{\partial t}) \quad \forall \psi_i,
\end{equation}

where $\vec u_h$ is the approximate solution and $\vec \psi_i$ is a finite
element test function.

The Jacobian is computed through automatic differentiation. More information
about time kernels can be found on the Kernels description
[page](syntax/Kernels/index.md).

## Example Syntax

Time derivative terms are ubiquitous in any transient simulation. The kernel
block for a transient diffusion problem that demonstrates the
`ADVectorTimeDerivative` syntax is shown below:

!listing test/tests/kernels/ad_transient_diffusion/ad_transient_vector_diffusion.i block=Kernels

!syntax parameters /Kernels/ADVectorTimeDerivative<RESIDUAL>

!syntax inputs /Kernels/ADVectorTimeDerivative<RESIDUAL>

!syntax children /Kernels/ADVectorTimeDerivative<RESIDUAL>
@@ -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

#ifndef ADVECTORTIMEDERIVATIVE_H
#define ADVECTORTIMEDERIVATIVE_H

#include "ADTimeKernel.h"

// Forward Declaration
template <ComputeStage>
class ADVectorTimeDerivative;

declareADValidParams(ADVectorTimeDerivative);

template <ComputeStage compute_stage>
class ADVectorTimeDerivative : public ADVectorTimeKernel<compute_stage>
{
public:
ADVectorTimeDerivative(const InputParameters & parameters);

protected:
virtual ADResidual computeQpResidual() override;

usingVectorTimeKernelMembers;
};

#endif // ADVECTORTIMEDERIVATIVE_H
@@ -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 "ADVectorTimeDerivative.h"

registerADMooseObject("MooseApp", ADVectorTimeDerivative);

defineADValidParams(
ADVectorTimeDerivative,
ADVectorTimeKernel,
params.addClassDescription("The time derivative operator with the weak form of $(\\psi_i, "
"\\frac{\\partial u_h}{\\partial t})$."););

template <ComputeStage compute_stage>
ADVectorTimeDerivative<compute_stage>::ADVectorTimeDerivative(const InputParameters & parameters)
: ADVectorTimeKernel<compute_stage>(parameters)
{
}

template <ComputeStage compute_stage>
ADResidual
ADVectorTimeDerivative<compute_stage>::computeQpResidual()
{
return _test[_i][_qp] * _u_dot[_qp];
}

adBaseClass(ADVectorTimeDerivative);
@@ -0,0 +1,56 @@
[Mesh]
type = GeneratedMesh
dim = 2
nx = 10
ny = 10
[]

[MeshModifiers]
[./block]
type = SubdomainBoundingBox
bottom_left = '0.4 0.4 -1'
top_right = '0.6 0.6 1'
block_id = 1
[../]
[]

[Variables]
[./u]
family = LAGRANGE_VEC
[../]
[]

[ICs]
[./u]
type = VectorConstantIC
variable = u
x_value = 1
y_value = 2
z_value = 3
block = 1
[../]
[]

[Kernels]
[./diff]
type = ADVectorDiffusion
variable = u
[../]
[./time]
type = ADVectorTimeDerivative
variable = u
[../]
[]

[Executioner]
type = Transient
num_steps = 20
dt = 0.01
solve_type = NEWTON
petsc_options_iname = '-pc_type -pc_hypre_type'
petsc_options_value = 'hypre boomeramg'
[]

[Outputs]
exodus = true
[]
@@ -1,19 +1,41 @@
[Tests]
issues = '#5658 #12633'
design = 'ADTimeDerivative.md'
[./test]
[./ad_transient_diffusion]
type = 'Exodiff'
input = 'ad_transient_diffusion.i'
exodiff = 'ad_transient_diffusion_out.e'
requirement = 'We shall be able to reproduce the simple_transient_diffusion results with ADTimeDerivative'
issues = '#5658 #12633'
design = 'ADTimeDerivative.md'
[../]
[./jac_test]
[./jac_ad_transient_diffusion]
type = 'PetscJacobianTester'
input = 'ad_transient_diffusion.i'
cli_args = 'Outputs/exodus=false Mesh/nx=3 Mesh/ny=3 Executioner/num_steps=3'
run_sim = True
ratio_tol = 1e-7
difference_tol = 1e-6
requirement = 'The Jacobian from ADTimeDerivative shall be perfect'
issues = '#5658 #12633'
design = 'ADTimeDerivative.md'
[../]

[./ad_transient_vector_diffusion]
type = 'Exodiff'
input = 'ad_transient_vector_diffusion.i'
exodiff = 'ad_transient_vector_diffusion_out.e'
requirement = 'We shall be able to reproduce the simple_transient_diffusion results with ADTimeDerivative'
issues = '#13017'
design = 'ADVectorTimeDerivative.md'
[../]
[./jac_ad_transient_vector_diffusion]
type = 'PetscJacobianTester'
input = 'ad_transient_vector_diffusion.i'
cli_args = 'Outputs/exodus=false Mesh/nx=3 Mesh/ny=3 Executioner/num_steps=3'
run_sim = True
ratio_tol = 1e-7
difference_tol = 1e-6
requirement = 'The Jacobian from ADVectorTimeDerivative shall be perfect'
issues = '#13017'
design = 'ADVectorTimeDerivative.md'
[../]
[]

0 comments on commit 19a3d82

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