www.mooseframework.org
Public Member Functions | Protected Attributes | List of all members
CavityPressureUserObject Class Reference

#include <CavityPressureUserObject.h>

Inheritance diagram for CavityPressureUserObject:
[legend]

Public Member Functions

 CavityPressureUserObject (const InputParameters &parameters)
 
virtual ~CavityPressureUserObject ()
 
virtual void initialSetup ()
 
virtual void residualSetup ()
 
virtual void timestepSetup ()
 
virtual void execute ()
 
virtual void initialize ()
 
virtual void finalize ()
 
Real getValue (const std::string &quantity) const
 

Protected Attributes

Real & _cavity_pressure
 
Real & _n0
 
const Real _initial_pressure
 
std::vector< const PostprocessorValue * > _material_input
 
const Real _R
 
const Real & _temperature
 
const bool _init_temp_given
 
const Real _init_temp
 
const Real & _volume
 
Real _start_time
 
const Real _startup_time
 
bool & _initialized
 

Detailed Description

Definition at line 12 of file CavityPressureUserObject.h.

Constructor & Destructor Documentation

CavityPressureUserObject::CavityPressureUserObject ( const InputParameters &  parameters)

Definition at line 37 of file CavityPressureUserObject.C.

38  : GeneralUserObject(params),
39  _cavity_pressure(declareRestartableData<Real>("cavity_pressure", 0)),
40  _n0(declareRestartableData<Real>("initial_moles", 0)),
41  _initial_pressure(getParam<Real>("initial_pressure")),
43  _R(getParam<Real>("R")),
44  _temperature(getPostprocessorValue("temperature")),
45  _init_temp_given(isParamValid("initial_temperature")),
46  _init_temp(_init_temp_given ? getParam<Real>("initial_temperature") : 0),
47  _volume(getPostprocessorValue("volume")),
48  _start_time(0),
49  _startup_time(getParam<Real>("startup_time")),
50  _initialized(declareRestartableData<bool>("initialized", false))
51 {
52  if (isParamValid("material_input"))
53  {
54  std::vector<PostprocessorName> ppn =
55  params.get<std::vector<PostprocessorName>>("material_input");
56  const unsigned int len = ppn.size();
57  for (unsigned int i = 0; i < len; ++i)
58  _material_input.push_back(&getPostprocessorValueByName(ppn[i]));
59  }
60 }
std::vector< const PostprocessorValue * > _material_input
virtual CavityPressureUserObject::~CavityPressureUserObject ( )
inlinevirtual

Definition at line 17 of file CavityPressureUserObject.h.

17 {}

Member Function Documentation

void CavityPressureUserObject::execute ( )
virtual

Definition at line 104 of file CavityPressureUserObject.C.

Referenced by timestepSetup().

105 {
106  Real mat = 0;
107  for (unsigned int i = 0; i < _material_input.size(); ++i)
108  mat += *_material_input[i];
109 
110  const Real pressure = (_n0 + mat) * _R * _temperature / _volume;
111  const Real factor = _t >= _start_time + _startup_time ? 1.0 : (_t - _start_time) / _startup_time;
112  _cavity_pressure = factor * pressure;
113 }
std::vector< const PostprocessorValue * > _material_input
const std::string pressure
Definition: NS.h:24
virtual void CavityPressureUserObject::finalize ( )
inlinevirtual

Definition at line 28 of file CavityPressureUserObject.h.

28 {}
Real CavityPressureUserObject::getValue ( const std::string &  quantity) const

Definition at line 63 of file CavityPressureUserObject.C.

Referenced by finalize(), and CavityPressurePostprocessor::getValue().

64 {
65  Real value = 0;
66  if ("initial_moles" == quantity)
67  {
68  if (_n0 < 0.0)
69  mooseError("Negative number of moles calculated as an input for the cavity pressure");
70 
71  value = _n0;
72  }
73  else if ("cavity_pressure" == quantity)
74  value = _cavity_pressure;
75  else
76  mooseError("Unknown quantity in " + name());
77 
78  return value;
79 }
void CavityPressureUserObject::initialize ( )
virtual

Definition at line 82 of file CavityPressureUserObject.C.

Referenced by timestepSetup().

83 {
84  if (!_initialized)
85  {
86  Real init_temp = _temperature;
87  if (_init_temp_given)
88  init_temp = _init_temp;
89 
90  if (MooseUtils::absoluteFuzzyLessEqual(init_temp, 0.0))
91  mooseError("Cannot have initial temperature of zero when initializing cavity pressure. "
92  "Does the supplied Postprocessor for temperature execute at initial?");
93 
94  _n0 = _initial_pressure * _volume / (_R * init_temp);
95  _start_time = _t - _dt;
96  const Real factor =
97  _t >= _start_time + _startup_time ? 1.0 : (_t - _start_time) / _startup_time;
99  _initialized = true;
100  }
101 }
virtual void CavityPressureUserObject::initialSetup ( )
inlinevirtual

Definition at line 19 of file CavityPressureUserObject.h.

19 {}
virtual void CavityPressureUserObject::residualSetup ( )
inlinevirtual

Definition at line 21 of file CavityPressureUserObject.h.

21 {}
virtual void CavityPressureUserObject::timestepSetup ( )
inlinevirtual

Definition at line 23 of file CavityPressureUserObject.h.

23 {}

Member Data Documentation

Real& CavityPressureUserObject::_cavity_pressure
protected

Definition at line 33 of file CavityPressureUserObject.h.

Referenced by execute(), getValue(), and initialize().

const Real CavityPressureUserObject::_init_temp
protected

Definition at line 44 of file CavityPressureUserObject.h.

Referenced by initialize().

const bool CavityPressureUserObject::_init_temp_given
protected

Definition at line 43 of file CavityPressureUserObject.h.

Referenced by initialize().

const Real CavityPressureUserObject::_initial_pressure
protected

Definition at line 36 of file CavityPressureUserObject.h.

Referenced by initialize().

bool& CavityPressureUserObject::_initialized
protected

Definition at line 51 of file CavityPressureUserObject.h.

Referenced by initialize().

std::vector<const PostprocessorValue *> CavityPressureUserObject::_material_input
protected

Definition at line 38 of file CavityPressureUserObject.h.

Referenced by CavityPressureUserObject(), and execute().

Real& CavityPressureUserObject::_n0
protected

Definition at line 34 of file CavityPressureUserObject.h.

Referenced by execute(), getValue(), and initialize().

const Real CavityPressureUserObject::_R
protected

Definition at line 40 of file CavityPressureUserObject.h.

Referenced by execute(), and initialize().

Real CavityPressureUserObject::_start_time
protected

Definition at line 48 of file CavityPressureUserObject.h.

Referenced by execute(), and initialize().

const Real CavityPressureUserObject::_startup_time
protected

Definition at line 49 of file CavityPressureUserObject.h.

Referenced by execute(), and initialize().

const Real& CavityPressureUserObject::_temperature
protected

Definition at line 42 of file CavityPressureUserObject.h.

Referenced by execute(), and initialize().

const Real& CavityPressureUserObject::_volume
protected

Definition at line 46 of file CavityPressureUserObject.h.

Referenced by execute(), and initialize().


The documentation for this class was generated from the following files: