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

Commit

Permalink
Merge pull request #33 from micahjohnson150/update_mms_tests-30
Browse files Browse the repository at this point in the history
 Updated mms tests
  • Loading branch information
aeslaughter committed Jun 20, 2014
2 parents 2d4288c + 1c19c0a commit 67555c7
Show file tree
Hide file tree
Showing 13 changed files with 104 additions and 40 deletions.
13 changes: 5 additions & 8 deletions src/kernels/MassTransportSourceMMS.C
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ template<>
InputParameters validParams<MassTransportSourceMMS>()
{
InputParameters params = validParams<Kernel>();
params.addParam<std::string>("water_vapor_diffusion_coefficient_name", "water_vapor_diffusion_coefficient", "The name of the material property that contains the water vapor diffusion coefficient (D_v)");
params.addParam<std::string>("diffusion_coefficient_name", "diffusion_coefficient", "The name of the phase dependent material property that contains the water vapor diffusion coefficient (D_v)");
params.addRequiredCoupledVar("phi", "Phase-field variable, phi");
params.addParam<bool>("use_dphi_dt", true, "Include the dphi_dt portion of the forcing function");
return params;
}

MassTransportSourceMMS::MassTransportSourceMMS(const std::string & name, InputParameters parameters) :
Kernel(name, parameters),
_D_v(getMaterialProperty<Real>(getParam<std::string>("water_vapor_diffusion_coefficient_name"))),
_D_v(getMaterialProperty<Real>(getParam<std::string>("diffusion_coefficient_name"))),
_phi(coupledValue("phi")),
_use_dphi_dt(getParam<bool>("use_dphi_dt"))
{
Expand All @@ -26,15 +26,12 @@ MassTransportSourceMMS::computeQpResidual()
Real t = _t;
Real x = _q_point[_qp](0);
Real y = _q_point[_qp](1);
Real D_v = _D_v[_qp];
Real D = _D_v[_qp];
Real Pi = libMesh::pi;
Real phi = _phi[_qp];

Real f = sin(2.*Pi*x)*cos(2.*Pi*y)
+ D_v*t*t*y*cos(2.*Pi*x)*Pi*cos(2.*Pi*y)
+ 8.*D_v*(0.5-0.5*t*x*y)*t*sin(2.*Pi*x)*Pi*Pi*cos(2.*Pi*y)
- D_v*t*t*sin(2.*Pi*x)*sin(2.*Pi*y)*Pi;

Real f =
8.0*pow(pi, 2)*D*t*sin(2.0*pi*x)*cos(2.0*pi*y) + sin(2.0*pi*x)*cos(2.0*pi*y);
if (_use_dphi_dt)
f += 0.5*x*y;

Expand Down
Binary file modified tests/heat_equation/mms/gold/mms_heat_equation_dphi_dt_out.e
Binary file not shown.
Binary file modified tests/heat_equation/mms/gold/mms_heat_equation_out.e
Binary file not shown.
1 change: 0 additions & 1 deletion tests/heat_equation/mms/mms_heat_equation.i
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@
active = ''
output_initial = true
exodus = true
file_base = mms_heat_equation_out
[./oversample]
refinements = 2
oversample = true
Expand Down
1 change: 0 additions & 1 deletion tests/heat_equation/mms/mms_heat_equation_dphi_dt.i
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@
active = ''
output_initial = true
exodus = true
file_base = mms_heat_equation_dphi_dt_out
[./oversample]
refinements = 2
oversample = true
Expand Down
68 changes: 68 additions & 0 deletions tests/mass_transport/mms/MassTransportMMS.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
'''***************************************
* Generating Method of MFG-ed *
* Solutions applied to the Heat *
* equation (eqn 34) in Kaempfer 2009 *
* *
* Compile: *
* python MassTransportMMS.py *
* *
***************************************'''
#!/usr/bin/python

from sympy import *
from sympy.utilities.codegen import codegen
init_printing()

x = symbols('x')
y = symbols('y')
t = symbols('t')

phi = t*x*y
u = t*sin(2.0*pi*x)*cos(2.0*pi*y)
print '\n'
print 'u =\n '
pprint(u)
print '\n'

#Chemical diffusion
D = symbols('D')

#Simplifying Math terms
du_dt = diff(u,t)
grad_u = [diff(u,x), diff(u,y)]
diffuse_D_grad_u =((diff(D*grad_u[0],x) + diff(D*grad_u[1],y)))

dPhi_dt = diff(phi,t)

term1 = du_dt
term2 = diffuse_D_grad_u
term3 =-0.5*(dPhi_dt) #yes it is negative in the original eq.

# Eq. (35) without dPhi_dt
f = term1-term2

#Print out equation
print '\n'
print ' F = \n'
pprint(f)
print '\n'
print '\n'
print ' -phi_term = \n'
pprint(-term3)
print '\n'


#Generate the C/C++ version of the code.
print('Equation 35 Code : \n')
[(c_name, c_code), (h_name, c_header)] = codegen(
("f", f), "C", "test", header=False, empty=False)
print(c_code)
print('\n')

#Generate C/C++ code for term 4
print('-dPhi_dt term Code : \n')
[(c_name, c_code), (h_name, c_header)] = codegen(
("f", -term3), "C", "test", header=False, empty=False)
print(c_code)
print('\n')

Binary file modified tests/mass_transport/mms/gold/mms_mass_transport_dphi_dt_out.e
Binary file not shown.
Binary file modified tests/mass_transport/mms/gold/mms_mass_transport_out.e
Binary file not shown.
37 changes: 16 additions & 21 deletions tests/mass_transport/mms/mms_mass_transport.i
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
dim = 2
nx = 10
ny = 10
uniform_refine = 1
elem_type = QUAD8
[]

Expand All @@ -14,6 +15,7 @@

[AuxVariables]
[./phi]
order = SECOND
[../]
[./abs_error]
[../]
Expand All @@ -26,7 +28,7 @@
[../]
[./u_func]
type = ParsedFunction
value = t*sin(2*pi*x)*cos(2*pi*y)
value = t*sin(2.0*pi*x)*cos(2.0*pi*y)
[../]
[]

Expand All @@ -49,14 +51,14 @@
use_dphi_dt = false
[../]
[./phi_time]
type = UserForcingFunction
type = PikaTimeDerivative
variable = u
function = dphi_dt_func
coefficient = 0.5
differentiated_variable = phi
[../]
[]

[AuxKernels]
active = 'error_aux phi_kernel'
[./phi_kernel]
type = FunctionAux
variable = phi
Expand All @@ -68,11 +70,6 @@
function = u_func
solution_variable = u
[../]
[./u_exact]
type = FunctionAux
variable = u_exact
function = u_func
[../]
[]

[BCs]
Expand All @@ -84,13 +81,10 @@
[../]
[]

[../]
[]

[PikaMaterials]
phi = phi
temperature = 273.15
[../]
[]

[Postprocessors]
[./L2_errror]
Expand All @@ -102,19 +96,19 @@

[Executioner]
type = Transient
num_steps = 10
dt = 0.1
num_steps = 2
dt = .25
[]

[Adaptivity]
[]

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

Expand All @@ -130,3 +124,4 @@
type = FunctionIC
[../]
[]

10 changes: 6 additions & 4 deletions tests/mass_transport/mms/mms_mass_transport_dphi_dt.i
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
[../]
[./u_func]
type = ParsedFunction
value = t*sin(2*pi*x)*cos(2*pi*y)
value = t*sin(2.0*pi*x)*cos(2.0*pi*y)
[../]
[]

Expand All @@ -49,9 +49,10 @@
use_dt_dphi = true
[../]
[./phi_time]
type = UserForcingFunction
type = PikaTimeDerivative
variable = u
function = -0.5*x*y
coefficient = 0.5
differentiated_variable = phi
[../]
[]

Expand Down Expand Up @@ -93,7 +94,7 @@

[Executioner]
type = Transient
num_steps = 4
num_steps = 2
dt = 0.25
[]

Expand Down Expand Up @@ -121,3 +122,4 @@
type = FunctionIC
[../]
[]

14 changes: 9 additions & 5 deletions tests/mass_transport/mms/mms_mass_transport_no_pika_material.i
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
dim = 2
nx = 10
ny = 10
uniform_refine = 1
elem_type = QUAD8
[]

Expand All @@ -14,6 +15,7 @@

[AuxVariables]
[./phi]
order = SECOND
[../]
[./abs_error]
[../]
Expand All @@ -26,7 +28,7 @@
[../]
[./u_func]
type = ParsedFunction
value = t*sin(2*pi*x)*cos(2*pi*y)
value = t*sin(2.0*pi*x)*cos(2.0*pi*y)
[../]
[]

Expand All @@ -49,9 +51,10 @@
use_dphi_dt = false
[../]
[./phi_time]
type = UserForcingFunction
type = PikaTimeDerivative
variable = u
function = dphi_dt_func
coefficient = 0.5
differentiated_variable = phi
[../]
[]

Expand Down Expand Up @@ -124,8 +127,8 @@

[Executioner]
type = Transient
num_steps = 10
dt = 0.1
num_steps = 2
dt = 0.25
[]

[Adaptivity]
Expand Down Expand Up @@ -155,3 +158,4 @@
type = FunctionIC
[../]
[]

Binary file modified tests/phase_evolution/mms/gold/mms_double_well_potential_out.e
Binary file not shown.
Binary file modified tests/phase_evolution/mms/gold/mms_phase_evolution_out.e
Binary file not shown.

0 comments on commit 67555c7

Please sign in to comment.