Permalink
Browse files

Merge pull request #12648 from tophmatthews/ad_dt_12633

Added ADHeatConductionTimeDerivative
  • Loading branch information...
lindsayad committed Feb 7, 2019
2 parents a6b8660 + c5e53e3 commit aa1248f2e6752add12b1ab58b164e8e23f146987
@@ -0,0 +1,26 @@
# ADHeatConductionTimeDerivative

## Description

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

\begin{equation}
\underbrace{\rho c_p \frac{\partial u}{\partial t}}_{\textrm{ADHeatConductionTimeDerivative}} +
\sum_{i=1}^n \beta_i = 0 \in \Omega.
\end{equation}
where $\rho$ is the material density, $c_p$ is the specific heat, and the second term on the left hand side corresponds to the strong forms of
other kernels. The corresponding `ADHeatConductionTimeDerivative` weak form using inner-product notation is

\begin{equation}
R_i(u_h) = (\psi_i, \rho c_p\frac{\partial u_h}{\partial t}) \quad \forall \psi_i,
\end{equation}
where $u_h$ is the approximate solution and $\psi_i$ is a finite element test function.

The Jacobian is given by automatic differentiation, and should be perfect as long as $c_p$ and $\rho$
are provided using `ADMaterial` derived objects.

!syntax parameters /ADKernels/ADHeatConductionTimeDerivative<RESIDUAL>

!syntax inputs /ADKernels/ADHeatConductionTimeDerivative<RESIDUAL>

!syntax children /ADKernels/ADHeatConductionTimeDerivative<RESIDUAL>
@@ -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 ADHEATCONDUCTIONTIMEDERIVATIVE_H
#define ADHEATCONDUCTIONTIMEDERIVATIVE_H

#include "ADTimeDerivative.h"

template <ComputeStage compute_stage>
class ADHeatConductionTimeDerivative;

declareADValidParams(ADHeatConductionTimeDerivative);

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

protected:
virtual ADResidual computeQpResidual() override;

/// Specific heat material property
const MaterialProperty<Real> & _specific_heat;

/// Density material property
const MaterialProperty<Real> & _density;

usingTimeKernelMembers;
};

#endif // ADHEATCONDUCTIONTIMEDERIVATIVE_H
@@ -14,7 +14,8 @@ defineADValidParams(ADHeatConduction,
ADDiffusion,
params.addRequiredParam<MaterialPropertyName>(
"thermal_conductivity",
"the name of the thermal conductivity material property"););
"the name of the thermal conductivity material property");
params.set<bool>("use_displaced_mesh") = true;);

template <ComputeStage compute_stage>
ADHeatConduction<compute_stage>::ADHeatConduction(const InputParameters & parameters)
@@ -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.htmlo
#include "ADHeatConductionTimeDerivative.h"

registerADMooseObject("HeatConductionApp", ADHeatConductionTimeDerivative);

defineADValidParams(
ADHeatConductionTimeDerivative,
ADTimeDerivative,
params.addClassDescription(
"AD Time derivative term $\\rho c_p \\frac{\\partial T}{\\partial t}$ of "
"the heat equation for quasi-constant specific heat $c_p$ and the density $\\rho$.");
params.set<bool>("use_displaced_mesh") = true;
params.addParam<MaterialPropertyName>("specific_heat",
"specific_heat",
"Property name of the specific heat material property");
params.addParam<MaterialPropertyName>("density_name",
"density",
"Property name of the density material property"););

template <ComputeStage compute_stage>
ADHeatConductionTimeDerivative<compute_stage>::ADHeatConductionTimeDerivative(
const InputParameters & parameters)
: ADTimeDerivative<compute_stage>(parameters),
_specific_heat(adGetADMaterialProperty<Real>("specific_heat")),
_density(adGetADMaterialProperty<Real>("density_name"))
{
}

template <ComputeStage compute_stage>
ADResidual
ADHeatConductionTimeDerivative<compute_stage>::computeQpResidual()
{
return _specific_heat[_qp] * _density[_qp] * ADTimeDerivative<compute_stage>::computeQpResidual();
}
@@ -4,25 +4,18 @@
[Mesh]
type = GeneratedMesh
dim = 2
nx = 3
ny = 3
nx = 5
ny = 5
xmax = 0.001
ymax = 0.001
[]

[Variables]
[./T]
initial_condition = 1.5
[../]
[./c]
[../]
[]

[ICs]
[./T_IC]
type = RandomIC
variable = T
[../]
[./c_IC]
type = RandomIC
variable = c
initial_condition = 1.5
[../]
[]

@@ -32,12 +25,49 @@
variable = T
thermal_conductivity = thermal_conductivity
[../]
[./heat_dt]
type = ADHeatConductionTimeDerivative
variable = T
specific_heat = thermal_conductivity
density_name = thermal_conductivity
[../]
[./c]
type = ADDiffusion
variable = c
[../]
[]

[Kernels]
[./c]
type = Diffusion
[./c_dt]
type = TimeDerivative
variable = c
[../]
[]

[BCs]
[./left_c]
type = DirichletBC
variable = c
boundary = left
value = 2
[../]
[./right_c]
type = DirichletBC
variable = c
boundary = right
value = 1
[../]
[./left_T]
type = DirichletBC
variable = T
boundary = top
value = 1
[../]
[./right_T]
type = DirichletBC
variable = T
boundary = bottom
value = 2
[../]
[]

@@ -1,5 +1,5 @@
[Tests]
[./stateful_jacobian]
[./jacobian_test]
type = 'PetscJacobianTester'
input = 'test.i'
ratio_tol = 1e-7
@@ -31,12 +31,11 @@
variable = T
thermal_conductivity = thermal_conductivity
[../]
[]

[Kernels]
[./HeatTdot]
type = HeatConductionTimeDerivative
[./heat_dt]
type = ADHeatConductionTimeDerivative
variable = T
specific_heat = specific_heat
density_name = density
[../]
[]

0 comments on commit aa1248f

Please sign in to comment.