www.mooseframework.org
InternalVolume.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
3 //*
4 //* All rights reserved, see COPYRIGHT for full restrictions
5 //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6 //*
7 //* Licensed under LGPL 2.1, please see LICENSE for details
8 //* https://www.gnu.org/licenses/lgpl-2.1.html
9 
10 #include "InternalVolume.h"
11 
12 #include "MooseMesh.h"
13 #include "Function.h"
14 
16 
19 {
21  params.addClassDescription("Computes the volume of an enclosed area by "
22  "performing an integral over a user-supplied boundary.");
23  params.addRangeCheckedParam<unsigned int>(
24  "component", 0, "component<3", "The component to use in the integration");
25  params.addParam<Real>(
26  "scale_factor", 1, "A scale factor to be applied to the internal volume calculation");
27  params.addParam<FunctionName>("addition",
28  0,
29  "An additional volume to be included in the "
30  "internal volume calculation. A time-dependent "
31  "function is expected.");
32  params.set<bool>("use_displaced_mesh") = true;
33  return params;
34 }
35 
37  : SideIntegralPostprocessor(parameters),
38  _component(getParam<unsigned int>("component")),
39  _scale(getParam<Real>("scale_factor")),
40  _addition(getFunction("addition"))
41 {
42 }
43 
44 // / /
45 // | |
46 // | div(F) dV = | F dot n dS
47 // | |
48 // / V / dS
49 //
50 // with
51 // F = a field
52 // n = the normal at the surface
53 // V = the volume of the domain
54 // S = the surface of the domain
55 //
56 // If we choose F as [x 0 0]^T, then
57 // div(F) = 1.
58 // So,
59 //
60 // / /
61 // | |
62 // | dV = | x * n[0] dS
63 // | |
64 // / V / dS
65 //
66 // That is, the volume of the domain is the integral over the surface of the domain
67 // of the x position of the surface times the x-component of the normal of the
68 // surface.
69 
70 void
72 {
74 
75  const std::set<SubdomainID> & subdomains = _mesh.meshSubdomains();
76  std::set<SubdomainID>::const_iterator iter = subdomains.begin();
77  const std::set<SubdomainID>::const_iterator iter_end = subdomains.end();
78  for (; iter != iter_end; ++iter)
79  {
80  const std::set<BoundaryID> & boundaries = _mesh.getSubdomainBoundaryIds(*iter);
81  std::set<BoundaryID>::const_iterator bnd = boundaries.begin();
82  const std::set<BoundaryID>::const_iterator bnd_end = boundaries.end();
83  for (; bnd != bnd_end; ++bnd)
84  {
85  const std::set<BoundaryID> & b = boundaryIDs();
86  std::set<BoundaryID>::const_iterator bit = b.begin();
87  const std::set<BoundaryID>::const_iterator bit_end = b.end();
88  for (; bit != bit_end; ++bit)
89  if (*bit == *bnd)
90  {
92  if (_component != 0 && coord_sys == Moose::COORD_RSPHERICAL)
93  mooseError("With spherical coordinates, the component must be 0 in InternalVolume.");
94 
95  if (_component > 1 && coord_sys == Moose::COORD_RZ)
96  mooseError(
97  "With cylindrical coordinates, the component must be 0 or 1 in InternalVolume.");
98  }
99  }
100  }
101 }
102 
103 Real
105 {
106  // Default scale factor is 1
107  Real scale = 1.0;
109  {
110  // MOOSE will multiply by 4*pi*r*r
111  scale = 1.0 / 3.0;
112  }
113  else if (_coord_sys == Moose::COORD_RZ && _component == 0)
114  {
115  // MOOSE will multiply by 2*pi*r
116  // Will integrate over z giving 0.5*2*pi*r*r*height
117  scale = 0.5;
118  }
119  else if (_coord_sys == Moose::COORD_RZ && _component == 1)
120  {
121  // MOOSE will multiply by 2*pi*r
122  // Will integrate over r:
123  // integral(2*pi*r*height) over r:
124  // pi*r*r*height
125  scale = 1.0;
126  }
128 }
129 
130 Real
132 {
134 }
const Function & _addition
const std::set< BoundaryID > & getSubdomainBoundaryIds(const SubdomainID subdomain_id) const
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
static InputParameters validParams()
void scale(MeshBase &mesh, const Real xs, const Real ys=0., const Real zs=0.)
T & set(const std::string &name, bool quiet_mode=false)
const Real _scale
const MooseArray< Point > & _q_point
COORD_RSPHERICAL
virtual void initialSetup() override
InternalVolume(const InputParameters &parameters)
virtual Real getValue() const override
virtual void initialSetup() override
This class computes the volume of an interior space.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
const Moose::CoordinateSystemType & _coord_sys
virtual Real computeQpIntegral() override
CoordinateSystemType
virtual Real getValue() const override
FEProblemBase & _fe_problem
const MooseArray< Point > & _normals
void mooseError(Args &&... args) const
void addClassDescription(const std::string &doc_string)
static InputParameters validParams()
Moose::CoordinateSystemType getCoordSystem(SubdomainID sid) const
void addRangeCheckedParam(const std::string &name, const T &value, const std::string &parsed_function, const std::string &doc_string)
virtual Real value(Real t, const Point &p) const
registerMooseObject("MiscApp", InternalVolume)
virtual const std::set< BoundaryID > & boundaryIDs() const
void ErrorVector unsigned int
const std::set< SubdomainID > & meshSubdomains() const
const unsigned int _component