www.mooseframework.org
LevelSetVolume.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 
8 #include "LevelSetVolume.h"
9 
10 template <>
11 InputParameters
13 {
14  InputParameters params = validParams<ElementVariablePostprocessor>();
15  params.addClassDescription(
16  "Compute the area or volume of the region inside or outside of a level set contour.");
17  params.addParam<Real>(
18  "threshold", 0.0, "The level set threshold to consider for computing area/volume.");
19 
20  MooseEnum loc("inside=0 outside=1", "inside");
21  params.addParam<MooseEnum>("location", loc, "The location of the area/volume to be computed.");
22  return params;
23 }
24 
25 LevelSetVolume::LevelSetVolume(const InputParameters & parameters)
26  : ElementVariablePostprocessor(parameters),
27  _threshold(getParam<Real>("threshold")),
28  _inside(getParam<MooseEnum>("location") == "inside")
29 {
30 }
31 
32 void
34 {
35  _volume = 0;
36 }
37 
38 void
40 {
41  Real cnt = 0;
42  Real n = _u.size();
43 
44  // Perform the check for inside/outside outside the qp loop for speed
45  if (_inside)
46  {
47  for (_qp = 0; _qp < n; ++_qp)
48  if (_u[_qp] <= _threshold)
49  cnt++;
50  }
51  else
52  {
53  for (_qp = 0; _qp < n; ++_qp)
54  if (_u[_qp] > _threshold)
55  cnt++;
56  }
57  _volume += cnt / n * _current_elem_volume;
58 }
59 
60 void
62 {
63  gatherSum(_volume);
64 }
65 
66 Real
68 {
69  return _volume;
70 }
71 
72 void
73 LevelSetVolume::threadJoin(const UserObject & y)
74 {
75  const LevelSetVolume & pps = static_cast<const LevelSetVolume &>(y);
76  _volume += pps._volume;
77 }
Real _volume
The accumulated volume to return as a PostprocessorValue.
const bool _inside
Flag for triggering the internal volume calculation.
const Real & _threshold
The level set contour to consider for computing inside vs. outside of the volume. ...
Postprocessor to compute the area/volume inside and outside of a level set contour.
InputParameters validParams< LevelSetVolume >()
virtual void threadJoin(const UserObject &y) override
virtual void execute() override
virtual Real getValue() override
virtual void initialize() override
LevelSetVolume(const InputParameters &parameters)
virtual void finalize() override