Line data Source code
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 : 12 : // MOOSE includes 13 : #include "Moose.h" 14 : #include "MooseEnum.h" 15 : #include "MooseTypes.h" 16 : #include "Restartable.h" 17 : 18 : // Forward Declarations 19 : class InputParameters; 20 : class SubProblem; 21 : class UserObject; 22 : 23 : namespace libMesh 24 : { 25 : class Point; 26 : } 27 : 28 : template <typename T> 29 : InputParameters validParams(); 30 : 31 : /** 32 : * This base class computes volume integrals of a variable storing 33 : * partial sums for the specified number of intervals in a direction 34 : * (x,y,z). 35 : */ 36 : class LayeredBase : private Restartable 37 : { 38 : public: 39 : static InputParameters validParams(); 40 : 41 : LayeredBase(const InputParameters & parameters); 42 : 43 : /** 44 : * Given a Point return the integral value associated with the layer that point falls in. 45 : * 46 : * @param p The point to look for in the layers. 47 : */ 48 : virtual Real integralValue(const Point & p) const; 49 : 50 : /** 51 : * Get the value for a given layer 52 : * @param layer The layer index 53 : * @return The value for the given layer 54 : */ 55 : virtual Real getLayerValue(unsigned int layer) const; 56 : 57 : /** 58 : * Helper function to return the layer the point lies in. 59 : * @param p The point. 60 : * @return The layer the Point is found in. 61 : */ 62 : virtual unsigned int getLayer(const Point & p) const; 63 : 64 : /** 65 : * Get the center coordinates for the layers (along given direction) 66 : */ 67 156 : const std::vector<Real> & getLayerCenters() const { return _layer_centers; } 68 : 69 : /** 70 : * Get direction of the layers 71 : * @return layer direction 72 : */ 73 156 : unsigned int direction() const { return _direction; } 74 : 75 : virtual void initialize(); 76 : virtual void finalize(); 77 : virtual void threadJoin(const UserObject & y); 78 : 79 : protected: 80 : /** 81 : * Set the value for a particular layer 82 : * @param layer The layer you are setting the value for 83 : * @param value The value to set 84 : */ 85 : void setLayerValue(unsigned int layer, Real value); 86 : 87 : /** 88 : * Whether or not a layer has a value. 89 : */ 90 53175 : bool layerHasValue(unsigned int layer) const { return _layer_has_value[layer]; } 91 : 92 : /** 93 : * Compute bounds, restricted to blocks if given 94 : */ 95 : void getBounds(); 96 : 97 : /** 98 : * Compute the center points for each layer 99 : */ 100 : void computeLayerCenters(); 101 : 102 : /// Name of this object 103 : std::string _layered_base_name; 104 : 105 : /// Params for this object 106 : const InputParameters & _layered_base_params; 107 : 108 : /// The MooseEnum direction the layers are going in 109 : MooseEnum _direction_enum; 110 : 111 : /// The component direction the layers are going in. We cache this for speed (so we're not always going through the MooseEnum) 112 : unsigned int _direction; 113 : 114 : /// Whether or not this object is based on equally spaced intervals or "bounds" 115 : bool _interval_based; 116 : 117 : /// Number of layers to split the mesh into 118 : unsigned int _num_layers; 119 : 120 : /// The boundaries of the layers 121 : std::vector<Real> _layer_bounds; 122 : 123 : /// How to sample the values 124 : unsigned int _sample_type; 125 : 126 : /// How many layers both above and below the found layer will be used in the average 127 : unsigned int _average_radius; 128 : 129 : /// true if this object operates on the displaced mesh, otherwise false 130 : bool _using_displaced_mesh; 131 : 132 : /// center coordinates of each layer 133 : std::vector<Real> _layer_centers; 134 : 135 : Real _direction_min; 136 : Real _direction_max; 137 : 138 : /// Value of the integral for each layer 139 : std::vector<Real> & _layer_values; 140 : 141 : /// Whether or not each layer has had any value summed into it 142 : std::vector<int> & _layer_has_value; 143 : 144 : /// Whether the values are cumulative over the layers 145 : bool _cumulative; 146 : 147 : /// Whether the cumulative values should be summed in the positive or negative direction 148 : const bool _positive_cumulative_direction; 149 : 150 : private: 151 : /// Subproblem for the child object 152 : SubProblem & _layered_base_subproblem; 153 : 154 : /// List of SubdomainIDs, if given 155 : std::vector<SubdomainID> _layer_bounding_blocks; 156 : 157 : /// whether the max/min coordinate in the direction is known from user input 158 : bool _has_direction_max_min; 159 : };