Commit a3b3f4dd authored by Matthew Ellis's avatar Matthew Ellis

Addition of objects for LegendreFourier reconstruction and

example problem utilizing objects.
parent 7c6995cb
......@@ -25,9 +25,22 @@
family = SCALAR
order = FIFTH
[../]
[./temp_bc_scalar_f_0_l]
family = SCALAR
order = FIFTH
[../]
[./temp_bc_scalar_f_1_l]
family = SCALAR
order = FIFTH
[../]
[]
[ICs]
[./v_ic]
type = ScalarComponentIC
variable = 'temp_bc_scalar_f_0_l'
values = '1.0 0.0 0.0 0.0 0.0'
[../]
[./temp_ic]
type = FunctionIC
variable = temp
......@@ -35,22 +48,6 @@
[../]
[]
[Functions]
[./exact_fn]
type = ParsedFunction
value = t
[../]
[./a_fn]
type = ParsedFunction
value = t
[../]
[./b_fn]
type = ParsedFunction
value = (4-t)/2
[../]
[]
[Kernels]
[./HeatSource]
type = HeatSource
......@@ -79,7 +76,16 @@
[../]
[./fourier_function]
type = FourierPolynomial
[./]
[../]
[./fl_reconstruction]
type = FourierLegendreReconstruction
l_order = 5
f_order = 2
l_direction = 2
legendre_function_name = 'legendre_function'
fourier_function_name = 'fourier_function'
poly_scalars = 'temp_bc_scalar_f_0_l temp_bc_scalar_f_1_l'
[../]
[]
[BCs]
......@@ -99,8 +105,14 @@
type = FunctionDirichletBC
variable = temp
boundary = 'wall'
function = bc_func
function = fl_reconstruction
[../]
#[./wall]
# type = FunctionDirichletBC
# variable = temp
# boundary = 'wall'
# function = bc_func
#[../]
[]
[Materials]
......@@ -137,6 +149,7 @@
f_order = 0
aux_scalar_name = heat_flux_scalar_f_0_l
diffusion_coefficient_name = 'thermal_conductivity'
surface_area_pp = 'surf_area'
[../]
[./nek_f_0_l_1]
type = NekSideIntegralVariableUserObject
......@@ -149,6 +162,7 @@
f_order = 0
aux_scalar_name = heat_flux_scalar_f_0_l
diffusion_coefficient_name = 'thermal_conductivity'
surface_area_pp = 'surf_area'
[../]
[./nek_f_0_l_2]
type = NekSideIntegralVariableUserObject
......@@ -161,6 +175,7 @@
f_order = 0
aux_scalar_name = heat_flux_scalar_f_0_l
diffusion_coefficient_name = 'thermal_conductivity'
surface_area_pp = 'surf_area'
[../]
[./nek_f_0_l_3]
type = NekSideIntegralVariableUserObject
......@@ -173,6 +188,7 @@
f_order = 0
aux_scalar_name = heat_flux_scalar_f_0_l
diffusion_coefficient_name = 'thermal_conductivity'
surface_area_pp = 'surf_area'
[../]
[./nek_f_0_l_4]
type = NekSideIntegralVariableUserObject
......@@ -185,6 +201,7 @@
f_order = 0
aux_scalar_name = heat_flux_scalar_f_0_l
diffusion_coefficient_name = 'thermal_conductivity'
surface_area_pp = 'surf_area'
[../]
# Legendre functions with Fourier order 1
[./nek_f_1_l_0]
......@@ -198,6 +215,7 @@
f_order = 1
aux_scalar_name = heat_flux_scalar_f_1_l
diffusion_coefficient_name = 'thermal_conductivity'
surface_area_pp = 'surf_area'
[../]
[./nek_f_1_l_1]
type = NekSideIntegralVariableUserObject
......@@ -210,6 +228,7 @@
f_order = 1
aux_scalar_name = heat_flux_scalar_f_1_l
diffusion_coefficient_name = 'thermal_conductivity'
surface_area_pp = 'surf_area'
[../]
[./nek_f_1_l_2]
type = NekSideIntegralVariableUserObject
......@@ -222,6 +241,7 @@
f_order = 1
aux_scalar_name = heat_flux_scalar_f_1_l
diffusion_coefficient_name = 'thermal_conductivity'
surface_area_pp = 'surf_area'
[../]
[./nek_f_1_l_3]
type = NekSideIntegralVariableUserObject
......@@ -234,6 +254,7 @@
f_order = 1
aux_scalar_name = heat_flux_scalar_f_1_l
diffusion_coefficient_name = 'thermal_conductivity'
surface_area_pp = 'surf_area'
[../]
[./nek_f_1_l_4]
type = NekSideIntegralVariableUserObject
......@@ -246,6 +267,15 @@
f_order = 1
aux_scalar_name = heat_flux_scalar_f_1_l
diffusion_coefficient_name = 'thermal_conductivity'
surface_area_pp = 'surf_area'
[../]
[]
[Postprocessors]
[./surf_area]
type = AreaPostprocessor
boundary = wall
execute_on = timestep_begin
[../]
[]
......
/****************************************************************/
/* DO NOT MODIFY THIS HEADER */
/* MOOSE - Multiphysics Object Oriented Simulation Environment */
/* */
/* (c) 2010 Battelle Energy Alliance, LLC */
/* ALL RIGHTS RESERVED */
/* */
/* Prepared by Battelle Energy Alliance, LLC */
/* Under Contract No. DE-AC07-05ID14517 */
/* With the U. S. Department of Energy */
/* */
/* See COPYRIGHT for full restrictions */
/****************************************************************/
#ifndef FOURIERLEGENDRERECONSTRUCTION_H
#define FOURIERLEGENDRERECONSTRUCTION_H
#include "Function.h"
#include "math.h"
#include "FourierPolynomial.h"
#include "LegendrePolynomial.h"
class FourierLegendreReconstruction : public Function
{
public:
FourierLegendreReconstruction(const InputParameters & parameters);
virtual ~FourierLegendreReconstruction();
virtual Real value(Real t, const Point & p);
protected:
/// Debug flag to print debug output
bool _dbg;
/// The coordinate directions of the integration for Legendre polynomial
int _l_direction;
/// The coordinate directions of the itnegration for Fourier polynomials
int _f_direction_1;
int _f_direction_2;
/// The order of the Legendre expansion
int _l_order;
/// The order of the Fourier expansion
int _f_order;
/// The vector of scalar variables holding the coefficients
std::vector<VariableValue *> _poly_scalars;
/// Legendre polynomial object. TODO address dynamic casting of this object
LegendrePolynomial & _legendre_poly_function;
/// Fourier polynomial object. TODO address dynamic casting of this object
FourierPolynomial & _fourier_poly_function;
private:
};
template<>
InputParameters validParams<FourierLegendreReconstruction>();
#endif
......@@ -42,9 +42,9 @@ protected:
/// Holds the solution at current quadrature points
const VariableValue & _u;
/// Legendre polynomial object. TODO move this into a user object
/// Legendre polynomial object. TODO address dynamic casting of this object
LegendrePolynomial & _legendre_poly_function;
/// Fourier polynomial object. TODO move this into a user object
/// Fourier polynomial object. TODO address dynamic casting of this object
FourierPolynomial & _fourier_poly_function;
/// The coordinate directions of the integration for Legendre polynomial
int _l_direction;
......@@ -61,7 +61,8 @@ protected:
const VariableGradient & _coupled_grad;
/// Thermal conductivity (diffusion coefficient)
const MaterialProperty<Real> & _diffusion_coefficient;
/// The name of the post processor that calculates the surface area
const PostprocessorValue & _surface_area_pp;
};
#endif
......@@ -6,6 +6,7 @@
#include "CoupledGradAux.h"
#include "LegendrePolynomial.h"
#include "FourierPolynomial.h"
#include "FourierLegendreReconstruction.h"
#include "NekSideIntegralVariableUserObject.h"
template<>
......@@ -54,8 +55,10 @@ MoonApp::registerObjects(Factory & factory)
// Functions registration
registerFunction(LegendrePolynomial);
registerFunction(FourierPolynomial);
registerFunction(FourierLegendreReconstruction);
// UserObjects registration
registerUserObject(NekSideIntegralVariableUserObject);
}
// External entry point for dynamic syntax association
......
/****************************************************************/
/* DO NOT MODIFY THIS HEADER */
/* MOOSE - Multiphysics Object Oriented Simulation Environment */
/* */
/* (c) 2010 Battelle Energy Alliance, LLC */
/* ALL RIGHTS RESERVED */
/* */
/* Prepared by Battelle Energy Alliance, LLC */
/* Under Contract No. DE-AC07-05ID14517 */
/* With the U. S. Department of Energy */
/* */
/* See COPYRIGHT for full restrictions */
/****************************************************************/
#include "FourierLegendreReconstruction.h"
template<>
InputParameters validParams<FourierLegendreReconstruction>()
{
InputParameters params = validParams<Function>();
params.addParam<bool>("dbg", false, "Print debug output");
params.addRequiredParam<int>("l_order", "The order of the Legendre expansion");
params.addRequiredParam<int>("f_order", "The order of the Fourier expansion");
params.addRequiredParam<int>("l_direction", "Direction of integration for Legendre polynomial");
params.addRequiredParam<std::string>("legendre_function_name", "Name of function to compute Legendre polynomial value at a point");
params.addRequiredParam<std::string>("fourier_function_name", "Name of function to compute Fourier polynomial value at a point");
params.addRequiredCoupledVar("poly_scalars", "Name of aux variable containing the Zernike coefficients");
return params;
}
FourierLegendreReconstruction::FourierLegendreReconstruction(const InputParameters & parameters) :
Function(parameters),
_dbg(parameters.get<bool>("dbg")),
_l_direction(parameters.get<int>("l_direction")),
_l_order(parameters.get<int>("l_order")),
_f_order(parameters.get<int>("f_order")),
_legendre_poly_function(dynamic_cast<LegendrePolynomial&>(_mci_feproblem.getFunction(parameters.get<std::string>("legendre_function_name")))),
_fourier_poly_function(dynamic_cast<FourierPolynomial&>(_mci_feproblem.getFunction(parameters.get<std::string>("fourier_function_name"))))
{
// For now hard code that l_direction better be 2
// TODO come back and put logic in to determine f diections given l directions
if ( _l_direction == 2)
{
_f_direction_1 = 0;
_f_direction_2 = 1;
}
else
{
mooseError("Need to implement logic for l direction not equal to 2");
}
// Get the coupled scalar variables storing the expansion coefficients
for(int i=0; i < _f_order; i++)
_poly_scalars.push_back(&coupledScalarValue("poly_scalars",i));
}
FourierLegendreReconstruction::~FourierLegendreReconstruction()
{
}
Real
FourierLegendreReconstruction::value(Real t, const Point & p)
{
Real val = 0.0;
for (int f=0; f<_f_order; f++)
{
for (int l=0; l<_l_order; l++)
{
val += (*_poly_scalars[f])[l]
* _legendre_poly_function.getPolynomialValue(t,p(_l_direction),l)
* _fourier_poly_function.getPolynomialValue(t,p(_f_direction_1),p(_f_direction_2),f);
}
}
return val;
}
......@@ -61,9 +61,9 @@ LegendrePolynomial::getPolynomialValue(Real t, Real p, int n)
}
// 0th order
if (n == 0) // O order
return 1.0 / _dz;
return 1.0 / sqrt(2.0);
if (n == 1) // 1 order
return 3.0 / _dz * z;
return sqrt(3.0 / 2.0) * z;
else
{
plm2 = 1.0;
......@@ -76,6 +76,6 @@ LegendrePolynomial::getPolynomialValue(Real t, Real p, int n)
}
if(_dbg)
Moose::out<<"Legendre total value = "<<(plm * (2.0 * n + 1.0) / _dz)<<std::endl;
return (plm * (2.0 * n + 1.0) / _dz);
return (plm * sqrt((2.0 * n + 1.0) / 2.0));
}
}
......@@ -28,6 +28,7 @@ InputParameters validParams<NekSideIntegralVariableUserObject>()
params.addParam<MaterialPropertyName>("diffusion_coefficient_name",
"thermal_conductivity",
"Property name of the diffusivity (Default: thermal_conductivity)");
params.addRequiredParam<std::string>("surface_area_pp", "The name of the post processor that calculates surface area");
return params;
}
......@@ -44,7 +45,8 @@ NekSideIntegralVariableUserObject::NekSideIntegralVariableUserObject(const Input
_f_order(parameters.get<int>("f_order")),
_aux_scalar_name(parameters.get<std::string>("aux_scalar_name")),
_coupled_grad(coupledGradient("variable")),
_diffusion_coefficient(getMaterialProperty<Real>("diffusion_coefficient_name"))
_diffusion_coefficient(getMaterialProperty<Real>("diffusion_coefficient_name")),
_surface_area_pp(getPostprocessorValueByName(parameters.get<std::string>("surface_area_pp")))
{
addMooseVariableDependency(mooseVariable());
......@@ -69,8 +71,10 @@ NekSideIntegralVariableUserObject::computeQpIntegral()
{
Real l_poly_val = _legendre_poly_function.getPolynomialValue(_t,_q_point[_qp](_l_direction),_l_order);
Real f_poly_val = _fourier_poly_function.getPolynomialValue(_t,_q_point[_qp](_f_direction_1),_q_point[_qp](_f_direction_2), _f_order);
//return _u[_qp] * l_poly_val * f_poly_val;
return -_diffusion_coefficient[_qp] * _coupled_grad[_qp].norm() * l_poly_val * f_poly_val;
// There is an added correction factor that accounts for the surface area of the pin
// The analytic expression is (2 / R / delta z) but we compute numerically as
// (2 / (Surf Area / (2*PI) ) ) = 4PI / Surf Area
return -_diffusion_coefficient[_qp] * _coupled_grad[_qp].norm() * l_poly_val * f_poly_val * 4.0 / M_PI / _surface_area_pp;
}
void
NekSideIntegralVariableUserObject::finalize()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment