From 35616ba717b72b44dd19eaa0420c5995f4ff10f0 Mon Sep 17 00:00:00 2001 From: micahjohnson150 Date: Tue, 1 Jul 2014 13:00:23 -0600 Subject: [PATCH] Added temporally scale heat equation which is tested against the original problem that is not scaled --- include/kernels/HeatEquationSourceMMS.h | 8 +- src/kernels/HeatEquationSourceMMS.C | 22 ++- tests/heat_equation/mms/mms_heat_equation.i | 1 + .../mms/mms_heat_equation_dphi_dt.i | 1 + .../mms/mms_scaled_heat_equation.i | 130 ++++++++++++++++++ tests/heat_equation/mms/tests | 8 ++ 6 files changed, 165 insertions(+), 5 deletions(-) create mode 100644 tests/heat_equation/mms/mms_scaled_heat_equation.i diff --git a/include/kernels/HeatEquationSourceMMS.h b/include/kernels/HeatEquationSourceMMS.h index 2787c476..8271dbfc 100644 --- a/include/kernels/HeatEquationSourceMMS.h +++ b/include/kernels/HeatEquationSourceMMS.h @@ -17,6 +17,8 @@ // MOOSE includes #include "Kernel.h" +//Pika Includes +#include "PropertyUserObjectInterface.h" // Forward declarations class HeatEquationSourceMMS; @@ -28,7 +30,9 @@ InputParameters validParams(); * 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: @@ -48,6 +52,8 @@ class HeatEquationSourceMMS : public Kernel const MaterialProperty & _L_sg; const VariableValue & _phi; bool _use_dphi_dt; + bool _use_scale; + const Real & _xi; }; diff --git a/src/kernels/HeatEquationSourceMMS.C b/src/kernels/HeatEquationSourceMMS.C index a45c0bfc..6c97e41a 100644 --- a/src/kernels/HeatEquationSourceMMS.C +++ b/src/kernels/HeatEquationSourceMMS.C @@ -9,16 +9,20 @@ InputParameters validParams() params.addParam("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("use_dphi_dt", true, "Include the dphi_dt portion of the forcing function"); + params.addParam("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(getParam("conductivity_name"))), _c(getMaterialProperty(getParam("heat_capacity_name"))), _L_sg(getMaterialProperty(getParam("latent_heat_name"))), _phi(coupledValue("phase_variable")), - _use_dphi_dt(getParam("use_dphi_dt")) + _use_dphi_dt(getParam("use_dphi_dt")), + _use_scale(getParam("use_time_scaling")), + _xi(_property_uo.getParam("temporal_scaling")) { } @@ -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; } diff --git a/tests/heat_equation/mms/mms_heat_equation.i b/tests/heat_equation/mms/mms_heat_equation.i index c7106b40..7f5e884b 100644 --- a/tests/heat_equation/mms/mms_heat_equation.i +++ b/tests/heat_equation/mms/mms_heat_equation.i @@ -51,6 +51,7 @@ phase_variable = phi block = 0 use_dphi_dt = false + use_time_scaling = false [../] [./phi_time] type = PikaTimeDerivative diff --git a/tests/heat_equation/mms/mms_heat_equation_dphi_dt.i b/tests/heat_equation/mms/mms_heat_equation_dphi_dt.i index 74d1cb8c..088b5837 100644 --- a/tests/heat_equation/mms/mms_heat_equation_dphi_dt.i +++ b/tests/heat_equation/mms/mms_heat_equation_dphi_dt.i @@ -49,6 +49,7 @@ variable = T phase_variable = phi block = 0 + use_time_scaling = false [../] [./phi_time] type = PikaTimeDerivative diff --git a/tests/heat_equation/mms/mms_scaled_heat_equation.i b/tests/heat_equation/mms/mms_scaled_heat_equation.i new file mode 100644 index 00000000..432c2b5a --- /dev/null +++ b/tests/heat_equation/mms/mms_scaled_heat_equation.i @@ -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 + [../] +[] + diff --git a/tests/heat_equation/mms/tests b/tests/heat_equation/mms/tests index 2651eaa8..acd14e31 100644 --- a/tests/heat_equation/mms/tests +++ b/tests/heat_equation/mms/tests @@ -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' + [../] + []