www.mooseframework.org
InternalVolume.C
Go to the documentation of this file.
1 /****************************************************************/
2 /* MOOSE - Multiphysics Object Oriented Simulation Environment */
3 /* */
4 /* All contents are licensed under LGPL V2.1 */
5 /* See LICENSE for full restrictions */
6 /****************************************************************/
7 #include "InternalVolume.h"
8 
9 #include "MooseMesh.h"
10 
11 template <>
12 InputParameters
14 {
15  InputParameters params = validParams<SideIntegralPostprocessor>();
16  params.addClassDescription("Computes the volume of an enclosed area by "
17  "performing an integral over a user-supplied boundary.");
18  params.addRangeCheckedParam<unsigned int>(
19  "component", 0, "component<3", "The component to use in the integration");
20  params.addParam<Real>(
21  "scale_factor", 1, "A scale factor to be applied to the internal volume calculation");
22  params.addParam<Real>(
23  "addition", 0, "An additional volume to be included in the internal volume calculation");
24  params.set<bool>("use_displaced_mesh") = true;
25  return params;
26 }
27 
28 InternalVolume::InternalVolume(const InputParameters & parameters)
29  : SideIntegralPostprocessor(parameters),
30  _component(getParam<unsigned int>("component")),
31  _scale(getParam<Real>("scale_factor")),
32  _addition(getParam<Real>("addition"))
33 {
34 }
35 
36 // / /
37 // | |
38 // | div(F) dV = | F dot n dS
39 // | |
40 // / V / dS
41 //
42 // with
43 // F = a field
44 // n = the normal at the surface
45 // V = the volume of the domain
46 // S = the surface of the domain
47 //
48 // If we choose F as [x 0 0]^T, then
49 // div(F) = 1.
50 // So,
51 //
52 // / /
53 // | |
54 // | dV = | x * n[0] dS
55 // | |
56 // / V / dS
57 //
58 // That is, the volume of the domain is the integral over the surface of the domain
59 // of the x position of the surface times the x-component of the normal of the
60 // surface.
61 
62 void
64 {
65  SideIntegralPostprocessor::initialSetup();
66 
67  const std::set<SubdomainID> & subdomains = _mesh.meshSubdomains();
68  std::set<SubdomainID>::const_iterator iter = subdomains.begin();
69  const std::set<SubdomainID>::const_iterator iter_end = subdomains.end();
70  for (; iter != iter_end; ++iter)
71  {
72  const std::set<BoundaryID> & boundaries = _mesh.getSubdomainBoundaryIds(*iter);
73  std::set<BoundaryID>::const_iterator bnd = boundaries.begin();
74  const std::set<BoundaryID>::const_iterator bnd_end = boundaries.end();
75  for (; bnd != bnd_end; ++bnd)
76  {
77  const std::set<BoundaryID> & b = boundaryIDs();
78  std::set<BoundaryID>::const_iterator bit = b.begin();
79  const std::set<BoundaryID>::const_iterator bit_end = b.end();
80  for (; bit != bit_end; ++bit)
81  if (*bit == *bnd)
82  {
83  Moose::CoordinateSystemType coord_sys = _fe_problem.getCoordSystem(*iter);
84  if (_component != 0 && coord_sys == Moose::COORD_RSPHERICAL)
85  mooseError("With spherical coordinates, the component must be 0 in InternalVolume.");
86 
87  if (_component > 1 && coord_sys == Moose::COORD_RZ)
88  mooseError(
89  "With cylindrical coordinates, the component must be 0 or 1 in InternalVolume.");
90  }
91  }
92  }
93 }
94 
95 Real
97 {
98  // Default scale factor is 1
99  Real scale = 1.0;
100  if (_coord_sys == Moose::COORD_RSPHERICAL)
101  {
102  // MOOSE will multiply by 4*pi*r*r
103  scale = 1.0 / 3.0;
104  }
105  else if (_coord_sys == Moose::COORD_RZ && _component == 0)
106  {
107  // MOOSE will multiply by 2*pi*r
108  // Will integrate over z giving 0.5*2*pi*r*r*height
109  scale = 0.5;
110  }
111  else if (_coord_sys == Moose::COORD_RZ && _component == 1)
112  {
113  // MOOSE will multiply by 2*pi*r
114  // Will integrate over r:
115  // integral(2*pi*r*height) over r:
116  // pi*r*r*height
117  scale = 1.0;
118  }
119  return -scale * _q_point[_qp](_component) * _normals[_qp](_component);
120 }
121 
122 Real
124 {
125  return _scale * SideIntegralPostprocessor::getValue() + _addition;
126 }
virtual Real getValue()
const Real _addition
const Real _scale
InternalVolume(const InputParameters &parameters)
virtual Real computeQpIntegral()
InputParameters validParams< InternalVolume >()
const unsigned int _component