https://mooseframework.inl.gov
Loading...
Searching...
No Matches
InternalVolume.C
Go to the documentation of this file.
1//* This file is part of the MOOSE framework
2//* https://mooseframework.inl.gov
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
70void
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)
97 "With cylindrical coordinates, the component must be 0 or 1 in InternalVolume.");
98 }
99 }
100 }
101}
102
103Real
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
130Real
registerMooseObject("MiscApp", InternalVolume)
Real scale
void ErrorVector unsigned int
virtual const std::set< BoundaryID > & boundaryIDs() const
virtual Real value(Real t, const Point &p) const
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
void addClassDescription(const std::string &doc_string)
T & set(const std::string &name, bool quiet_mode=false)
void addRangeCheckedParam(const std::string &name, const T &value, const std::string &parsed_function, const std::string &doc_string)
This class computes the volume of an interior space.
InternalVolume(const InputParameters &parameters)
const unsigned int _component
virtual Real getValue() const override
const Function & _addition
static InputParameters validParams()
const Real _scale
virtual void initialSetup() override
virtual Real computeQpIntegral() override
void mooseError(Args &&... args) const
const std::set< BoundaryID > & getSubdomainBoundaryIds(const SubdomainID subdomain_id) const
const std::set< SubdomainID > & meshSubdomains() const
static InputParameters validParams()
virtual void initialSetup() override
virtual Real getValue() const override
const MooseArray< Point > & _q_point
const MooseArray< Point > & _normals
Moose::CoordinateSystemType getCoordSystem(SubdomainID sid) const
FEProblemBase & _fe_problem
const Moose::CoordinateSystemType & _coord_sys
CoordinateSystemType
COORD_RSPHERICAL