www.mooseframework.org
Public Member Functions | Protected Types | 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 Real computeCavityVolume ()
 
virtual void initialize ()
 
virtual void finalize ()
 
Real getValue (const MooseEnum &quantity) const
 

Protected Types

enum  CAVITY_PRESSURE_USEROBJECT_QUANTITY { INITIAL_MOLES, CAVITY_PRESSURE }
 

Protected Attributes

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

Detailed Description

Definition at line 15 of file CavityPressureUserObject.h.

Member Enumeration Documentation

◆ CAVITY_PRESSURE_USEROBJECT_QUANTITY

Constructor & Destructor Documentation

◆ CavityPressureUserObject()

CavityPressureUserObject::CavityPressureUserObject ( const InputParameters &  parameters)

Definition at line 45 of file CavityPressureUserObject.C.

46  : GeneralUserObject(params),
47  _cavity_pressure(declareRestartableData<Real>("cavity_pressure", 0)),
48  _n0(declareRestartableData<Real>("initial_moles", 0)),
49  _initial_pressure(getParam<Real>("initial_pressure")),
51  _R(getParam<Real>("R")),
52  _temperature(getPostprocessorValue("temperature")),
53  _init_temp_given(isParamValid("initial_temperature")),
54  _init_temp(_init_temp_given ? getParam<Real>("initial_temperature") : 0),
55  _start_time(0),
56  _startup_time(getParam<Real>("startup_time")),
57  _initialized(declareRestartableData<bool>("initialized", false))
58 {
59  if (isParamValid("material_input"))
60  {
61  std::vector<PostprocessorName> ppn =
62  params.get<std::vector<PostprocessorName>>("material_input");
63  for (unsigned int i = 0; i < ppn.size(); ++i)
64  _material_input.push_back(&getPostprocessorValueByName(ppn[i]));
65  }
66 
67  std::vector<PostprocessorName> ppn = params.get<std::vector<PostprocessorName>>("volume");
68  for (unsigned int i = 0; i < ppn.size(); ++i)
69  _volume.push_back(&getPostprocessorValueByName(ppn[i]));
70 }
std::vector< const PostprocessorValue * > _volume
std::vector< const PostprocessorValue * > _material_input

◆ ~CavityPressureUserObject()

virtual CavityPressureUserObject::~CavityPressureUserObject ( )
inlinevirtual

Definition at line 20 of file CavityPressureUserObject.h.

20 {}

Member Function Documentation

◆ computeCavityVolume()

Real CavityPressureUserObject::computeCavityVolume ( )
virtual

Definition at line 129 of file CavityPressureUserObject.C.

Referenced by execute(), and initialize().

130 {
131  Real volume = 0;
132  for (unsigned int i = 0; i < _volume.size(); ++i)
133  volume += *_volume[i];
134 
135  return volume;
136 }
std::vector< const PostprocessorValue * > _volume

◆ execute()

void CavityPressureUserObject::execute ( )
virtual

Definition at line 115 of file CavityPressureUserObject.C.

116 {
117  Real volume = computeCavityVolume();
118  Real mat = 0;
119 
120  for (unsigned int i = 0; i < _material_input.size(); ++i)
121  mat += *_material_input[i];
122 
123  const Real pressure = (_n0 + mat) * _R * _temperature / volume;
124  const Real factor = _t >= _start_time + _startup_time ? 1.0 : (_t - _start_time) / _startup_time;
125  _cavity_pressure = factor * pressure;
126 }
std::vector< const PostprocessorValue * > _material_input
const std::string pressure
Definition: NS.h:26

◆ finalize()

virtual void CavityPressureUserObject::finalize ( )
inlinevirtual

Definition at line 33 of file CavityPressureUserObject.h.

33 {}

◆ getValue()

Real CavityPressureUserObject::getValue ( const MooseEnum &  quantity) const

Definition at line 73 of file CavityPressureUserObject.C.

Referenced by CavityPressurePostprocessor::getValue().

74 {
75  Real value = 0;
76  if (quantity == INITIAL_MOLES)
77  {
78  if (_n0 < 0.0)
79  mooseError("Negative number of moles calculated as an input for the cavity pressure");
80 
81  value = _n0;
82  }
83  else if (quantity == CAVITY_PRESSURE)
84  value = _cavity_pressure;
85  else
86  mooseError("Unknown quantity in " + name());
87 
88  return value;
89 }
const std::string name
Definition: Setup.h:22

◆ initialize()

void CavityPressureUserObject::initialize ( )
virtual

Definition at line 92 of file CavityPressureUserObject.C.

93 {
94  if (!_initialized)
95  {
96  Real volume = computeCavityVolume();
97  Real init_temp = _temperature;
98  if (_init_temp_given)
99  init_temp = _init_temp;
100 
101  if (MooseUtils::absoluteFuzzyLessEqual(init_temp, 0.0))
102  mooseError("Cannot have initial temperature of zero when initializing cavity pressure. "
103  "Does the supplied Postprocessor for temperature execute at initial?");
104 
105  _n0 = _initial_pressure * volume / (_R * init_temp);
106  _start_time = _t - _dt;
107  const Real factor =
108  _t >= _start_time + _startup_time ? 1.0 : (_t - _start_time) / _startup_time;
110  _initialized = true;
111  }
112 }

◆ initialSetup()

virtual void CavityPressureUserObject::initialSetup ( )
inlinevirtual

Definition at line 22 of file CavityPressureUserObject.h.

22 {}

◆ residualSetup()

virtual void CavityPressureUserObject::residualSetup ( )
inlinevirtual

Definition at line 24 of file CavityPressureUserObject.h.

24 {}

◆ timestepSetup()

virtual void CavityPressureUserObject::timestepSetup ( )
inlinevirtual

Definition at line 26 of file CavityPressureUserObject.h.

26 {}

Member Data Documentation

◆ _cavity_pressure

Real& CavityPressureUserObject::_cavity_pressure
protected

Definition at line 44 of file CavityPressureUserObject.h.

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

◆ _init_temp

const Real CavityPressureUserObject::_init_temp
protected

Definition at line 56 of file CavityPressureUserObject.h.

Referenced by initialize().

◆ _init_temp_given

const bool CavityPressureUserObject::_init_temp_given
protected

Definition at line 55 of file CavityPressureUserObject.h.

Referenced by initialize().

◆ _initial_pressure

const Real CavityPressureUserObject::_initial_pressure
protected

Definition at line 47 of file CavityPressureUserObject.h.

Referenced by initialize().

◆ _initialized

bool& CavityPressureUserObject::_initialized
protected

Definition at line 61 of file CavityPressureUserObject.h.

Referenced by initialize().

◆ _material_input

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

Definition at line 49 of file CavityPressureUserObject.h.

Referenced by CavityPressureUserObject(), and execute().

◆ _n0

Real& CavityPressureUserObject::_n0
protected

Definition at line 45 of file CavityPressureUserObject.h.

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

◆ _R

const Real CavityPressureUserObject::_R
protected

Definition at line 52 of file CavityPressureUserObject.h.

Referenced by execute(), and initialize().

◆ _start_time

Real CavityPressureUserObject::_start_time
protected

Definition at line 58 of file CavityPressureUserObject.h.

Referenced by execute(), and initialize().

◆ _startup_time

const Real CavityPressureUserObject::_startup_time
protected

Definition at line 59 of file CavityPressureUserObject.h.

Referenced by execute(), and initialize().

◆ _temperature

const Real& CavityPressureUserObject::_temperature
protected

Definition at line 54 of file CavityPressureUserObject.h.

Referenced by execute(), and initialize().

◆ _volume

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

Definition at line 50 of file CavityPressureUserObject.h.

Referenced by CavityPressureUserObject(), and computeCavityVolume().


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