Permalink
Browse files

Merge pull request #12644 from tophmatthews/ad_heat_gen_12633

Cleaned up HeatSourceBar and Added ADMatHeatSource
  • Loading branch information...
moosebuild committed Jan 8, 2019
2 parents 35aaa1b + 04ad8de commit 1dfc441860757cf01379493a4848023c3918fc6c
Binary file not shown.

This file was deleted.

Oops, something went wrong.

This file was deleted.

Oops, something went wrong.

This file was deleted.

Oops, something went wrong.
@@ -0,0 +1,30 @@
# ADMatHeatSource

## Description

`ADMatHeatSource` implements a force term in thermal transport to represent a
heat source. The strong form, given adomain $\Omega$ is defined as

\begin{equation}
\underbrace{-f}_{\textrm{BodyForce}} + \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 `BodyForce`
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$).

Here, $f$ is given as a material property with an optional constant scalar. The
Jacobian is calculated automatically via automatic differentiation.

!syntax parameters /ADKernels/ADMatHeatSource<RESIDUAL>

!syntax inputs /ADKernels/ADMatHeatSource<RESIDUAL>

!syntax children /ADKernels/ADMatHeatSource<RESIDUAL>

!bibtex bibliography
@@ -0,0 +1,34 @@
//* 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 ADMATHEATSOURCE_H
#define ADMATHEATSOURCE_H

#include "ADKernel.h"

template <ComputeStage>
class ADMatHeatSource;

declareADValidParams(ADMatHeatSource);

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

protected:
virtual ADResidual computeQpResidual();

const Real _scalar;
const ADMaterialProperty(Real) & _material_property;

usingKernelMembers;
};

#endif // ADMATHEATSOURCE_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 "ADMatHeatSource.h"

registerADMooseObject("HeatConductionApp", ADMatHeatSource);

defineADValidParams(
ADMatHeatSource,
ADKernel,
params.addParam<Real>("scalar", 1.0, "Scalar multiplied by the body force term");
params.addRequiredParam<MaterialPropertyName>("material_property",
"Material property describing the body force"););

template <ComputeStage compute_stage>
ADMatHeatSource<compute_stage>::ADMatHeatSource(const InputParameters & parameters)
: ADKernel<compute_stage>(parameters),
_scalar(adGetParam<Real>("scalar")),
_material_property(adGetADMaterialProperty<Real>("material_property"))
{
}

template <ComputeStage compute_stage>
ADResidual
ADMatHeatSource<compute_stage>::computeQpResidual()
{
return -_scalar * _material_property[_qp] * _test[_i][_qp];
}
@@ -0,0 +1,89 @@
# This is a simple 1D test of the volumetric heat source with material properties
# of a representative ceramic material. A bar is uniformly heated, and a temperature
# boundary condition is applied to the left side of the bar.

# Important properties of problem:
# Length: 0.01 m
# Thermal conductivity = 3.0 W/(mK)
# Specific heat = 300.0 J/K
# density = 10431.0 kg/m^3
# Prescribed temperature on left side: 600 K

# When it has reached steady state, the temperature as a function of position is:
# T = -q/(2*k) (x^2 - 2*x*length) + 600
# or
# T = -6.3333e+7 * (x^2 - 0.02*x) + 600
# on left side: T=600, on right side, T=6933.3

[Mesh]
type = GeneratedMesh
dim = 1
xmax = 0.01
nx = 20
[]

[Variables]
[./temp]
initial_condition = 300.0
[../]
[]

[ADKernels]
[./heat]
type = ADHeatConduction
variable = temp
thermal_conductivity = thermal_conductivity
[../]
[./heatsource]
type = ADMatHeatSource
material_property = volumetric_heat
variable = temp
scalar = 10
[../]
[]

[BCs]
[./lefttemp]
type = PresetBC
boundary = left
variable = temp
value = 600
[../]
[]

[Materials]
[./density]
type = GenericConstantMaterial
prop_names = 'density thermal_conductivity volumetric_heat '
prop_values = '10431.0 3.0 3.8e7'
[../]
[]

[Preconditioning]
[./full]
type = SMP
full = true
[../]
[]

[Executioner]
type = Steady
[]

[Postprocessors]
[./right]
type = SideAverageValue
variable = temp
boundary = right
[../]
[./error]
type = NodalL2Error
function = '-3.8e+8/(2*3) * (x^2 - 2*x*0.01) + 600'
variable = temp
[../]
[]

[Outputs]
execute_on = FINAL
exodus = true
[]
Oops, something went wrong.

0 comments on commit 1dfc441

Please sign in to comment.