Commit 43daed5d authored by Ron Rahaman's avatar Ron Rahaman

Added examples from MOOSE heat conduction module

parent 6c1dbf37
# This test solves a 1D transient heat equation
# The error is caclulated by comparing to the analytical solution
# The problem setup and analytical solution are taken from "Advanced Engineering
# Mathematics, 10th edition" by Erwin Kreyszig.
# http://www.amazon.com/Advanced-Engineering-Mathematics-Erwin-Kreyszig/dp/0470458364
# It is Example 1 in section 12.6 on page 561
[Mesh]
type = GeneratedMesh
dim = 1
nx = 160
xmax = 80
[]
[Variables]
[./T]
[../]
[]
[ICs]
[./T_IC]
type = FunctionIC
variable = T
function = '100*sin(3.14159*x/80)'
[../]
[]
[Kernels]
[./HeatDiff]
type = HeatConduction
variable = T
[../]
[./HeatTdot]
type = HeatConductionTimeDerivative
variable = T
[../]
[]
[BCs]
[./left]
type = DirichletBC
variable = T
boundary = left
value = 0
[../]
[./right]
type = DirichletBC
variable = T
boundary = right
value = 0
[../]
[]
[Materials]
[./k]
type = GenericConstantMaterial
prop_names = 'thermal_conductivity'
prop_values = '0.95' #copper in cal/(cm sec C)
block = 0
[../]
[./cp]
type = GenericConstantMaterial
prop_names = 'specific_heat'
prop_values = '0.092' #copper in cal/(g C)
block = 0
[../]
[./rho]
type = GenericConstantMaterial
prop_names = 'density'
prop_values = '8.92' #copper in g/(cm^3)
block = 0
[../]
[]
[Postprocessors]
[./error]
type = NodalL2Error
function = '100*sin(3.14159*x/80)*exp(-0.95/(0.092*8.92)*3.14159^2/80^2*t)' #T(x,t) = 100sin(pix/L)exp(-rho/(cp k) pi^2/L^2 t)
variable = T
[../]
[]
[Executioner]
type = Transient
scheme = bdf2
nl_rel_tol = 1e-12
l_tol = 1e-6
dt = 2
end_time = 100
petsc_options_iname = '-pc_type -pc_hypre_type'
petsc_options_value = 'hypre boomeramg'
[]
[Outputs]
exodus = true
print_perf_log = true
[]
# This test solves a 2D steady state heat equation
# The error is found by comparing to the analytical solution
# Note that the thermal conductivity, specific heat, and density in this problem
# Are set to 1, and need to be changed to the constants of the material being
# Analyzed
[Mesh]
type = GeneratedMesh
dim = 2
nx = 30
ny = 30
xmax = 2
ymax = 2
[]
[Variables]
[./T]
[../]
[]
[Functions]
[./analytical_sol]
type = ParsedFunction
value = 10/(sinh(pi))*sin(pi*x*0.5)*sinh(pi*y*0.5)
[../]
[./top_bound]
type = ParsedFunction
value = 10*sin(pi*x*0.5)
[../]
[]
[Kernels]
active = 'HeatDiff'
[./HeatDiff]
type = HeatConduction
variable = T
[../]
[./HeatTdot]
type = HeatConductionTimeDerivative
variable = T
[../]
[]
[BCs]
[./left]
type = DirichletBC
variable = T
boundary = left
value = 0
[../]
[./right]
type = DirichletBC
variable = T
boundary = right
value = 0
[../]
[./bottom]
type = DirichletBC
variable = T
boundary = bottom
value = 0
[../]
[./top]
type = FunctionDirichletBC
variable = T
boundary = top
function = top_bound
[../]
[]
[Materials]
[./k]
type = GenericConstantMaterial
prop_names = thermal_conductivity
prop_values = 1 # this values is changed based on the material property
block = 0
[../]
[./cp]
type = GenericConstantMaterial
prop_names = specific_heat
prop_values = 1 # this value is changed based on material properties
block = 0
[../]
[./rho]
type = GenericConstantMaterial
prop_names = density
prop_values = 1 # this values is changed based on material properties
block = 0
[../]
[]
[Postprocessors]
[./nodal_error]
type = NodalL2Error
function = 'analytical_sol'
variable = T
[../]
[./elemental_error]
type = ElementL2Error
function = 'analytical_sol'
variable = T
[../]
[]
[Executioner]
type = Steady
nl_rel_tol = 1e-12
l_tol = 1e-6
petsc_options_iname = '-pc_type -pc_hypre_type'
petsc_options_value = 'hypre boomeramg'
[]
[Outputs]
exodus = true
print_perf_log = true
[]
###############################################################################
################### MOOSE Application Standard Makefile #######################
###############################################################################
#
# Optional Environment variables
# MOOSE_DIR - Root directory of the MOOSE project
# MODULE_DIR - Location of the MOOSE modules directory
# FRAMEWORK_DIR - Location of the MOOSE framework
#
###############################################################################
MODULE_DIR ?= $(shell dirname `pwd`)
MOOSE_DIR ?= $(shell dirname $(MODULE_DIR))/src/moose
FRAMEWORK_DIR ?= $(MOOSE_DIR)/framework
###############################################################################
# framework
include $(FRAMEWORK_DIR)/build.mk
include $(FRAMEWORK_DIR)/moose.mk
# dep apps
APPLICATION_DIR := $(MODULE_DIR)/heat_conduction
APPLICATION_NAME := heat_conduction
BUILD_EXEC := yes
DEP_APPS := $(shell $(FRAMEWORK_DIR)/scripts/find_dep_apps.py $(APPLICATION_NAME))
include $(FRAMEWORK_DIR)/app.mk
###############################################################################
# Additional special case targets should be added here
This app is taken from moose/modules/heat_conduction/tests.
The source code for HeatConduction module itself
(moose/modules/heat_conduction) is copied here. Likewise, the HeatConduction
module itself be recompiled when compiling this example, even HeatConduction
was compiled with the rest of the MOOSE framework. This is redundant and can
surely be elminated with some refinements to the example's Makefile (TODO).
The following config files are also taken from moose/modules/heat_conduction/tests/heat_conduction:
* 1D_transient.i
* 2d_steady_state_final_prob.i
Theese config files are for coupling with Nek5000:
* 2d_transient_square.i
* 2d_transient_circle.i
* 3d_transient_cylinder.i
/****************************************************************/
/* MOOSE - Multiphysics Object Oriented Simulation Environment */
/* */
/* All contents are licensed under LGPL V2.1 */
/* See LICENSE for full restrictions */
/****************************************************************/
#ifndef ADDSLAVEFLUXVECTORACTION_H
#define ADDSLAVEFLUXVECTORACTION_H
#include "MooseObjectAction.h"
#include <string>
class AddSlaveFluxVectorAction : public Action
{
public:
AddSlaveFluxVectorAction(const InputParameters & params);
virtual void act();
};
template<>
InputParameters validParams<AddSlaveFluxVectorAction>();
#endif // ADDSLAVEFLUXVECTORACTION_H
/****************************************************************/
/* MOOSE - Multiphysics Object Oriented Simulation Environment */
/* */
/* All contents are licensed under LGPL V2.1 */
/* See LICENSE for full restrictions */
/****************************************************************/
#ifndef THERMALCONTACTAUXBCSACTION_H
#define THERMALCONTACTAUXBCSACTION_H
#include "Action.h"
class ThermalContactAuxBCsAction : public Action
{
public:
ThermalContactAuxBCsAction(const InputParameters & params);
virtual ~ThermalContactAuxBCsAction(){}
virtual void act();
};
template<>
InputParameters validParams<ThermalContactAuxBCsAction>();
#endif
/****************************************************************/
/* MOOSE - Multiphysics Object Oriented Simulation Environment */
/* */
/* All contents are licensed under LGPL V2.1 */
/* See LICENSE for full restrictions */
/****************************************************************/
#ifndef THERMALCONTACTAUXVARSACTION_H
#define THERMALCONTACTAUXVARSACTION_H
#include "Action.h"
class ThermalContactAuxVarsAction : public Action
{
public:
ThermalContactAuxVarsAction(const InputParameters & params);
virtual ~ThermalContactAuxVarsAction(){}
virtual void act();
static std::string
getGapValueName(const InputParameters & param)
{
return "paired_" + param.get<NonlinearVariableName>("variable");
}
static std::string
getGapConductivityName(const InputParameters & param)
{
return "paired_k_" + param.get<NonlinearVariableName>("variable");
}
};
template<>
InputParameters validParams<ThermalContactAuxVarsAction>();
#endif
/****************************************************************/
/* MOOSE - Multiphysics Object Oriented Simulation Environment */
/* */
/* All contents are licensed under LGPL V2.1 */
/* See LICENSE for full restrictions */
/****************************************************************/
#ifndef THERMALCONTACTBCSACTION_H
#define THERMALCONTACTBCSACTION_H
#include "Action.h"
class ThermalContactBCsAction : public Action
{
public:
ThermalContactBCsAction( const InputParameters & params);
virtual ~ThermalContactBCsAction(){}
virtual void act();
};
template<>
InputParameters validParams<ThermalContactBCsAction>();
#endif
/****************************************************************/
/* MOOSE - Multiphysics Object Oriented Simulation Environment */
/* */
/* All contents are licensed under LGPL V2.1 */
/* See LICENSE for full restrictions */
/****************************************************************/
#ifndef THERMALCONTACTDIRACKERNELSACTION_H
#define THERMALCONTACTDIRACKERNELSACTION_H
#include "Action.h"
class ThermalContactDiracKernelsAction : public Action
{
public:
ThermalContactDiracKernelsAction(const InputParameters & params);
virtual ~ThermalContactDiracKernelsAction(){}
virtual void act();
};
template<>
InputParameters validParams<ThermalContactDiracKernelsAction>();
#endif
/****************************************************************/
/* MOOSE - Multiphysics Object Oriented Simulation Environment */
/* */
/* All contents are licensed under LGPL V2.1 */
/* See LICENSE for full restrictions */
/****************************************************************/
#ifndef THERMALCONTACTMATERIALSACTION_H
#define THERMALCONTACTMATERIALSACTION_H
#include "Action.h"
class ThermalContactMaterialsAction : public Action
{
public:
ThermalContactMaterialsAction( const InputParameters & params);
virtual ~ThermalContactMaterialsAction(){}
virtual void act();
};
template<>
InputParameters validParams<ThermalContactMaterialsAction>();
#endif
/****************************************************************/
/* MOOSE - Multiphysics Object Oriented Simulation Environment */
/* */
/* All contents are licensed under LGPL V2.1 */
/* See LICENSE for full restrictions */
/****************************************************************/
#ifndef HEAT_CONDUCTIONAPP_H
#define HEAT_CONDUCTIONAPP_H
#include "MooseApp.h"
class HeatConductionApp;
template<>
InputParameters validParams<HeatConductionApp>();
class HeatConductionApp : public MooseApp
{
public:
HeatConductionApp(const InputParameters & parameters);
virtual ~HeatConductionApp();
static void registerApps();
static void registerObjects(Factory & factory);
static void associateSyntax(Syntax & syntax, ActionFactory & action_factory);
};
#endif /* HEAT_CONDUCTIONAPP_H */
/****************************************************************/
/* MOOSE - Multiphysics Object Oriented Simulation Environment */
/* */
/* All contents are licensed under LGPL V2.1 */
/* See LICENSE for full restrictions */
/****************************************************************/
#ifndef CONVECTIVEFLUXFUNCTION_H
#define CONVECTIVEFLUXFUNCTION_H
#include "IntegratedBC.h"
class ConvectiveFluxFunction : public IntegratedBC
{
public:
ConvectiveFluxFunction(const InputParameters & parameters);
virtual ~ConvectiveFluxFunction() {}
protected:
virtual Real computeQpResidual();
virtual Real computeQpJacobian();
Function & _T_infinity;
const Real _coefficient;
Function * const _coef_func;
};
template<>
InputParameters validParams<ConvectiveFluxFunction>();
#endif //CONVECTIVEFLUXFUNCTION_H
/****************************************************************/
/* MOOSE - Multiphysics Object Oriented Simulation Environment */
/* */
/* All contents are licensed under LGPL V2.1 */
/* See LICENSE for full restrictions */
/****************************************************************/
#ifndef COUPLEDCONVECTIVEFLUX_H
#define COUPLEDCONVECTIVEFLUX_H
#include "IntegratedBC.h"
class CoupledConvectiveFlux : public IntegratedBC
{
public:
CoupledConvectiveFlux(const InputParameters & parameters);
virtual ~CoupledConvectiveFlux() {}
protected:
virtual Real computeQpResidual();
virtual Real computeQpJacobian();
const VariableValue & _T_infinity;
const Real _coefficient;
};
template<>
InputParameters validParams<CoupledConvectiveFlux>();
#endif //COUPLEDCONVECTIVEFLUX_H
/****************************************************************/
/* MOOSE - Multiphysics Object Oriented Simulation Environment */
/* */
/* All contents are licensed under LGPL V2.1 */
/* See LICENSE for full restrictions */
/****************************************************************/
#ifndef GAPHEATTRANSFER_H
#define GAPHEATTRANSFER_H
#include "IntegratedBC.h"
#include "GapConductance.h"
//Forward Declarations
class GapHeatTransfer;
template<>
InputParameters validParams<GapHeatTransfer>();
class GapHeatTransfer : public IntegratedBC
{
public:
GapHeatTransfer(const InputParameters & parameters);
virtual ~GapHeatTransfer(){}
protected:
/**
* Generic gap heat transfer model, with h_gap = h_conduction + h_contact + h_radiation
*/
virtual void computeResidual();
virtual Real computeQpResidual();
virtual Real computeQpJacobian();
virtual Real computeQpOffDiagJacobian(unsigned jvar);
virtual Real gapLength() const;
virtual Real dgapLength(Real normalComponent) const;
virtual Real computeSlaveFluxContribution(Real grad_t);
virtual void computeGapValues();
bool _gap_geometry_params_set;
GapConductance::GAP_GEOMETRY _gap_geometry_type;
bool _quadrature;
NumericVector<Number> * _slave_flux;
const MaterialProperty<Real> & _gap_conductance;
const MaterialProperty<Real> & _gap_conductance_dT;
const Real _min_gap;
const Real _max_gap;
Real _gap_temp;
Real _gap_distance;
Real _radius;
Real _r1;
Real _r2;
/**
* This is a factor that is used to gradually taper down the conductance if the
* contact point is off the face and tangential_tolerance is nonzero.
*/
Real _edge_multiplier;
bool _has_info;
const bool _xdisp_coupled;
const bool _ydisp_coupled;
const bool _zdisp_coupled;
const unsigned int _xdisp_var;
const unsigned int _ydisp_var;
const unsigned int _zdisp_var;
const VariableValue & _gap_distance_value;
const VariableValue & _gap_temp_value;
PenetrationLocator * _penetration_locator;
const bool _warnings;
Point _p1;
Point _p2;
};
#endif //GAPHEATTRANSFER_H
/****************************************************************/
/* MOOSE - Multiphysics Object Oriented Simulation Environment */
/* */
/* All contents are licensed under LGPL V2.1 */
/* See LICENSE for full restrictions */
/****************************************************************/
#ifndef HEATCONDUCTIONBC_H
#define HEATCONDUCTIONBC_H
#include "FluxBC.h"
class HeatConductionBC;
template<>
InputParameters validParams<HeatConductionBC>();
/**
*
*/
class HeatConductionBC : public FluxBC
{
public:
HeatConductionBC(const InputParameters & parameters);
virtual ~HeatConductionBC();
protected:
virtual RealGradient computeQpFluxResidual();
virtual RealGradient computeQpFluxJacobian();
const MaterialProperty<Real> & _k;
};
#endif /* HEATCONDUCTIONBC_H */
/****************************************************************/
/* MOOSE - Multiphysics Object Oriented Simulation Environment */
/* */
/* All contents are licensed under LGPL V2.1 */
/* See LICENSE for full restrictions */
/****************************************************************/
#ifndef GAPCONDUCTANCECONSTRAINT_H
#define GAPCONDUCTANCECONSTRAINT_H
#include "FaceFaceConstraint.h"
class GapConductanceConstraint;
template<>
InputParameters validParams<GapConductanceConstraint>();
/**
*
*/
class GapConductanceConstraint : public FaceFaceConstraint
{
public:
GapConductanceConstraint(const InputParameters & parameters);
virtual ~GapConductanceConstraint();
protected:
virtual Real computeQpResidual();
virtual Real computeQpResidualSide(Moose::ConstraintType res_type);
virtual Real computeQpJacobian();
virtual Real computeQpJacobianSide(Moose::ConstraintJacobianType jac_type);
Real distance(const Point & a, const Point & b);
Real _k;
};