www.mooseframework.org
LevelSetVolume.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 "LevelSetVolume.h"
11 
12 registerMooseObject("LevelSetApp", LevelSetVolume);
13 
16 {
18  params.addClassDescription(
19  "Compute the area or volume of the region inside or outside of a level set contour.");
20  params.addParam<Real>(
21  "threshold", 0.0, "The level set threshold to consider for computing area/volume.");
22 
23  MooseEnum loc("inside=0 outside=1", "inside");
24  params.addParam<MooseEnum>("location", loc, "The location of the area/volume to be computed.");
25  return params;
26 }
27 
29  : ElementVariablePostprocessor(parameters),
30  _threshold(getParam<Real>("threshold")),
31  _inside(getParam<MooseEnum>("location") == "inside")
32 {
33 }
34 
35 void
37 {
38  _volume = 0;
39 }
40 
41 void
43 {
44  Real cnt = 0;
45  Real n = _u.size();
46 
47  // Perform the check for inside/outside outside the qp loop for speed
48  if (_inside)
49  {
50  for (_qp = 0; _qp < n; ++_qp)
51  if (_u[_qp] <= _threshold)
52  cnt++;
53  }
54  else
55  {
56  for (_qp = 0; _qp < n; ++_qp)
57  if (_u[_qp] > _threshold)
58  cnt++;
59  }
60  _volume += cnt / n * _current_elem_volume;
61 }
62 
63 void
65 {
67 }
68 
69 Real
71 {
72  return _volume;
73 }
74 
75 void
77 {
78  const auto & pps = static_cast<const LevelSetVolume &>(y);
79  _volume += pps._volume;
80 }
virtual Real getValue() const override
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
const VariableValue & _u
Real _volume
The accumulated volume to return as a PostprocessorValue.
const std::vector< double > y
static InputParameters validParams()
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. ...
static InputParameters validParams()
Postprocessor to compute the area/volume inside and outside of a level set contour.
virtual void threadJoin(const UserObject &y) override
virtual void execute() override
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
void addClassDescription(const std::string &doc_string)
virtual void initialize() override
LevelSetVolume(const InputParameters &parameters)
virtual void finalize() override
registerMooseObject("LevelSetApp", LevelSetVolume)