https://mooseframework.inl.gov
LayeredIntegralBase.h
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 #pragma once
11 
13 #include "LayeredBase.h"
14 #include "InputParameters.h"
15 
19 template <typename UserObjectType>
20 class LayeredIntegralBase : public SpatialUserObjectFunctor<UserObjectType>, public LayeredBase
21 {
22 public:
24 
25  LayeredIntegralBase(const InputParameters & parameters);
26 
32  virtual Real spatialValue(const Point & p) const override { return integralValue(p); }
33 
34  virtual const std::vector<Point> spatialPoints() const override;
35 
36  virtual void initialize() override;
37  virtual void execute() override;
38  virtual void finalize() override;
39  virtual void threadJoin(const UserObject & y) override;
40 
41 protected:
42  using UserObjectType::_current_elem;
43  using UserObjectType::computeIntegral;
44 };
45 
46 template <typename UserObjectType>
49 {
51  params += LayeredBase::validParams();
52  return params;
53 }
54 
55 template <typename UserObjectType>
57  : SpatialUserObjectFunctor<UserObjectType>(parameters), LayeredBase(parameters)
58 {
59  if (parameters.isParamValid("block") && parameters.isParamValid("boundary"))
60  mooseError("Both block and boundary cannot be specified for a layered integral user object. If "
61  "you want to define the geometric bounds of the layers from a specified block set "
62  "layer_bounding_block instead.");
63 }
64 
65 template <typename UserObjectType>
66 void
68 {
69  UserObjectType::initialize();
71 }
72 
73 template <typename UserObjectType>
74 void
76 {
77  const auto integral_value = computeIntegral();
78 
79  const auto layer = getLayer(_current_elem->vertex_average());
80 
81  setLayerValue(layer, getLayerValue(layer) + integral_value);
82 }
83 
84 template <typename UserObjectType>
85 void
87 {
89 }
90 
91 template <typename UserObjectType>
92 void
94 {
95  UserObjectType::threadJoin(y);
97 }
98 
99 template <typename UserObjectType>
100 const std::vector<Point>
102 {
103  std::vector<Point> points;
104 
105  for (const auto & l : _layer_centers)
106  {
107  Point pt(0.0, 0.0, 0.0);
108  pt(_direction) = l;
109  points.push_back(pt);
110  }
111 
112  return points;
113 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:302
virtual void finalize() override
virtual Real spatialValue(const Point &p) const override
Given a Point return the integral value associated with the layer that point falls in...
static InputParameters validParams()
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
static InputParameters validParams()
Definition: LayeredBase.C:22
virtual void threadJoin(const UserObject &y)
Definition: LayeredBase.C:339
Base class for computing layered side integrals.
virtual Real integralValue(const Point &p) const
Given a Point return the integral value associated with the layer that point falls in...
Definition: LayeredBase.C:182
virtual void initialize()
Definition: LayeredBase.C:301
virtual void finalize()
Definition: LayeredBase.C:314
virtual void execute() override
LayeredIntegralBase(const InputParameters &parameters)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
This base class computes volume integrals of a variable storing partial sums for the specified number...
Definition: LayeredBase.h:36
Base class for creating a user object with the SpatialUserObject and Moose::Functor APIs...
virtual void threadJoin(const UserObject &y) override
virtual void initialize() override
virtual const std::vector< Point > spatialPoints() const override
Base class for user-specific data.
Definition: UserObject.h:40
static InputParameters validParams()
bool isParamValid(const std::string &name) const
This method returns parameters that have been initialized in one fashion or another, i.e.