https://mooseframework.inl.gov
Loading...
Searching...
No Matches
LevelSetVolume.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 "LevelSetVolume.h"
11
13
16{
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
35void
40
41void
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
63void
68
69Real
71{
72 return _volume;
73}
74
75void
77{
78 const auto & pps = static_cast<const LevelSetVolume &>(y);
79 _volume += pps._volume;
80}
const std::vector< double > y
registerMooseObject("LevelSetApp", LevelSetVolume)
static InputParameters validParams()
const VariableValue & _u
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)
Postprocessor to compute the area/volume inside and outside of a level set contour.
virtual void execute() override
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()
virtual Real getValue() const override
virtual void finalize() override
Real _volume
The accumulated volume to return as a PostprocessorValue.
LevelSetVolume(const InputParameters &parameters)
virtual void initialize() override
virtual void threadJoin(const UserObject &y) override