www.mooseframework.org
LayeredAverage.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 "LayeredAverage.h"
11 
13 
16 {
18  params.addClassDescription("Computes averages of variables over layers");
19 
20  return params;
21 }
22 
24 {
26 }
27 
28 void
30 {
32 
33  for (auto & vol : _layer_volumes)
34  vol = 0.0;
35 }
36 
37 void
39 {
41 
42  unsigned int layer = getLayer(_current_elem->vertex_average());
44 }
45 
46 void
48 {
50 
52 
53  // Compute the average for each layer
54  for (unsigned int i = 0; i < _layer_volumes.size(); i++)
55  if (layerHasValue(i))
57 }
58 
59 void
61 {
63  const auto & la = static_cast<const LayeredAverage &>(y);
64  for (unsigned int i = 0; i < _layer_volumes.size(); i++)
65  _layer_volumes[i] += la._layer_volumes[i];
66 }
virtual void execute() override
Execute method.
registerMooseObject("MooseApp", LayeredAverage)
This UserObject computes volume integrals of a variable storing partial sums for the specified number...
LayeredAverage(const InputParameters &parameters)
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
virtual void initialize() override
static InputParameters validParams()
const Real & _current_elem_volume
The current element volume (available during execute())
std::vector< Real > _layer_volumes
Value of the volume for each layer.
This UserObject computes averages of a variable storing partial sums for the specified number of inte...
virtual void execute() override
Execute method.
virtual void initialize() override
bool layerHasValue(unsigned int layer) const
Whether or not a layer has a value.
Definition: LayeredBase.h:90
void gatherSum(T &value)
Gather the parallel sum of the variable passed in.
Definition: UserObject.h:125
virtual Real getLayerValue(unsigned int layer) const
Get the value for a given layer.
Definition: LayeredBase.C:293
void setLayerValue(unsigned int layer, Real value)
Set the value for a particular layer.
Definition: LayeredBase.C:407
virtual void threadJoin(const UserObject &y) override
static InputParameters validParams()
unsigned int _num_layers
Number of layers to split the mesh into.
Definition: LayeredBase.h:118
const Elem *const & _current_elem
The current element pointer (available during execute())
virtual unsigned int getLayer(Point p) const
Helper function to return the layer the point lies in.
Definition: LayeredBase.C:348
virtual void threadJoin(const UserObject &y) override
virtual void finalize() override
void addClassDescription(const std::string &doc_string)
This method adds a description of the class that will be displayed in the input file syntax dump...
Base class for user-specific data.
Definition: UserObject.h:39
virtual void finalize() override