Skip to content
This repository has been archived by the owner on Jan 10, 2023. It is now read-only.

Commit

Permalink
Added temporally scale heat equation which is tested against the orig…
Browse files Browse the repository at this point in the history
…inal problem that is not scaled
  • Loading branch information
micahjohnson150 committed Jul 1, 2014
1 parent 8d811c9 commit 35616ba
Show file tree
Hide file tree
Showing 6 changed files with 165 additions and 5 deletions.
8 changes: 7 additions & 1 deletion include/kernels/HeatEquationSourceMMS.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

// MOOSE includes
#include "Kernel.h"
//Pika Includes
#include "PropertyUserObjectInterface.h"

// Forward declarations
class HeatEquationSourceMMS;
Expand All @@ -28,7 +30,9 @@ InputParameters validParams<HeatEquationSourceMMS>();
* A kernel for adding forcing function for the MMS tests of the heat
* transport equation, Eq. (34)
*/
class HeatEquationSourceMMS : public Kernel
class HeatEquationSourceMMS :
public Kernel,
PropertyUserObjectInterface
{
public:

Expand All @@ -48,6 +52,8 @@ class HeatEquationSourceMMS : public Kernel
const MaterialProperty<Real> & _L_sg;
const VariableValue & _phi;
bool _use_dphi_dt;
bool _use_scale;
const Real & _xi;

};

Expand Down
22 changes: 18 additions & 4 deletions src/kernels/HeatEquationSourceMMS.C
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,20 @@ InputParameters validParams<HeatEquationSourceMMS>()
params.addParam<std::string>("latent_heat_name", "latent_heat", "The name of the material property that contains the latent heat coefficient for sublimation (L_sg)");
params.addRequiredCoupledVar("phase_variable", "Phase-field variable, phi");
params.addParam<bool>("use_dphi_dt", true, "Include the dphi_dt portion of the forcing function");
params.addParam<bool>("use_time_scaling", true, "Temporally scale this term");
return params;
}

HeatEquationSourceMMS::HeatEquationSourceMMS(const std::string & name, InputParameters parameters) :
Kernel(name, parameters),
PropertyUserObjectInterface(name,parameters),
_k(getMaterialProperty<Real>(getParam<std::string>("conductivity_name"))),
_c(getMaterialProperty<Real>(getParam<std::string>("heat_capacity_name"))),
_L_sg(getMaterialProperty<Real>(getParam<std::string>("latent_heat_name"))),
_phi(coupledValue("phase_variable")),
_use_dphi_dt(getParam<bool>("use_dphi_dt"))
_use_dphi_dt(getParam<bool>("use_dphi_dt")),
_use_scale(getParam<bool>("use_time_scaling")),
_xi(_property_uo.getParam<Real>("temporal_scaling"))
{
}

Expand All @@ -35,12 +39,22 @@ HeatEquationSourceMMS::computeQpResidual()
Real L_sg = _L_sg[_qp];
Real pi = libMesh::pi;
Real phi = _phi[_qp];
Real f,term1,term2,term3;
term1 = c*sin(2.0*pi*x)*sin(2.0*pi*y);
term2 = 8.0*pow(pi, 2)*k*t*sin(2.0*pi*x)*sin(2.0*pi*y);
term3 = 0.5*L_sg*pow(x*y, 2.0);


Real f =
c*sin(2.0*pi*x)*sin(2.0*pi*y) + 8.0*pow(pi, 2)*k*t*sin(2.0*pi*x)*sin(2.0*pi*y);
if (_use_scale)
{
term2=_xi*term2;
term3=_xi*term3;
}

f=term1+term2;

if (_use_dphi_dt)
f+= 0.5*L_sg*pow(x*y, 2.0);
f+=term3;

return -_test[_i][_qp] * f;
}
1 change: 1 addition & 0 deletions tests/heat_equation/mms/mms_heat_equation.i
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
phase_variable = phi
block = 0
use_dphi_dt = false
use_time_scaling = false
[../]
[./phi_time]
type = PikaTimeDerivative
Expand Down
1 change: 1 addition & 0 deletions tests/heat_equation/mms/mms_heat_equation_dphi_dt.i
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
variable = T
phase_variable = phi
block = 0
use_time_scaling = false
[../]
[./phi_time]
type = PikaTimeDerivative
Expand Down
130 changes: 130 additions & 0 deletions tests/heat_equation/mms/mms_scaled_heat_equation.i
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
[Mesh]
type = GeneratedMesh
dim = 2
nx = 15
ny = 15
uniform_refine = 1
elem_type = QUAD8
[]

[Variables]
[./T]
order = SECOND
[../]
[]

[AuxVariables]
[./phi]
order = SECOND
[../]
[./abs_error]
[../]
[]

[Functions]
[./phi_func]
type = ParsedFunction
value = -t*(x*y)*(x*y)
[../]
[./T_func]
type = ParsedFunction
value = t*sin(2.0*pi*x)*sin(2.0*pi*y)
[../]
[]

[Kernels]
[./T_time]
type = PikaTimeDerivative
variable = T
property = heat_capacity
block = 0
scale = 1.0
[../]
[./T_diff]
type = PikaScaledMatDiffusion
variable = T
block = 0
diffusivity = conductivity
[../]
[./mms]
type = HeatEquationSourceMMS
variable = T
phase_variable = phi
block = 0
[../]
[./phi_time]
type = PikaScaledTimeDerivative
variable = T
scale = -0.5
differentiated_variable = phi
property = latent_heat
[../]
[]

[AuxKernels]
[./phi_kernel]
type = FunctionAux
variable = phi
function = phi_func
[../]
[./error_aux]
type = ErrorFunctionAux
variable = abs_error
function = T_func
solution_variable = T
[../]
[]

[BCs]
[./all]
type = FunctionDirichletBC
variable = T
boundary = 'bottom left right top'
function = T_func
[../]
[]

[PikaMaterials]
phi = phi
temperature = T
temporal_scaling = 1e-4
[]

[Postprocessors]
[./L2_errror]
type = ElementL2Error
variable = T
function = T_func
[../]
[]

[Executioner]
type = Transient
num_steps = 2
dt = .1
[]

[Outputs]
active = ''
output_initial = true
exodus = true
[./oversample]
refinements = 2
oversample = true
type = Exodus
[../]
[]

[ICs]
[./T_ic]
function = T_func
variable = T
type = FunctionIC
[../]
[./phi_ic]
function = phi_func
variable = phi
type = FunctionIC
[../]
[]

8 changes: 8 additions & 0 deletions tests/heat_equation/mms/tests
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,12 @@
exodiff = 'mms_heat_equation_dphi_dt_out.e'
prereq = 'test'
[../]
[./test_temporally_scaled]
# MMS test for dT/dt - Div(D grad(T) + 1/2 dphi/dt = 0
type = 'Exodiff'
input = 'mms_scaled_heat_equation.i'
exodiff = 'mms_heat_equation_dphi_dt_out.e'
prereq = 'test'
[../]

[]

0 comments on commit 35616ba

Please sign in to comment.