Cardinal
NekSpatialBinUserObject.h
Go to the documentation of this file.
1 /********************************************************************/
2 /* SOFTWARE COPYRIGHT NOTIFICATION */
3 /* Cardinal */
4 /* */
5 /* (c) 2021 UChicago Argonne, LLC */
6 /* ALL RIGHTS RESERVED */
7 /* */
8 /* Prepared by UChicago Argonne, LLC */
9 /* Under Contract No. DE-AC02-06CH11357 */
10 /* With the U. S. Department of Energy */
11 /* */
12 /* Prepared by Battelle Energy Alliance, LLC */
13 /* Under Contract No. DE-AC07-05ID14517 */
14 /* With the U. S. Department of Energy */
15 /* */
16 /* See LICENSE for full restrictions */
17 /********************************************************************/
18 
19 #pragma once
20 
21 #include "NekUserObject.h"
22 #include "SpatialBinUserObject.h"
23 
30 {
31 public:
32  static InputParameters validParams();
33 
34  NekSpatialBinUserObject(const InputParameters & parameters);
35 
36  virtual ~NekSpatialBinUserObject();
37 
38  virtual Real spatialValue(const Point & p) const override final;
39 
47  virtual Real spatialValue(const Point & p, const unsigned int & component) const = 0;
48 
49  virtual const unsigned int bin(const Point & p) const;
50 
51  virtual const unsigned int num_bins() const;
52 
53  virtual const std::vector<Point> spatialPoints() const override { return _points; }
54 
56  virtual void computeBinVolumes() final;
57 
59  virtual void getBinVolumes() = 0;
60 
66  const std::vector<unsigned int> unrolledBin(const unsigned int & total_bin_index) const;
67 
72  const field::NekFieldEnum & field() const { return _field; }
73 
80  Point nekPoint(const int & local_elem_id, const int & local_node_id) const;
81 
82 protected:
84  void computePoints1D();
85 
87  void computePoints2D();
88 
90  void computePoints3D();
91 
93  void resetPartialStorage();
94 
100  void fillCoordinates(const std::vector<unsigned int> & indices, Point & p) const;
101 
103  const std::vector<UserObjectName> & _bin_names;
104 
107 
112  const bool & _map_space_by_qp;
113 
120 
122  std::vector<const SpatialBinUserObject *> _bins;
123 
125  std::vector<bool> _has_direction;
126 
128  std::vector<unsigned int> _bin_providing_direction;
129 
136 
138  unsigned int _n_bins;
139 
141  std::vector<Point> _points;
142 
144  std::vector<Point> _velocity_bin_directions;
145 
147  double * _bin_values;
148 
150  double * _bin_values_x;
151  double * _bin_values_y;
152  double * _bin_values_z;
153 
155  double * _bin_volumes;
156 
161  int * _bin_counts;
162 
165 
168 };
std::vector< unsigned int > _bin_providing_direction
For each x, y, z direction, which bin provides that direction.
Definition: NekSpatialBinUserObject.h:128
NekSpatialBinUserObject(const InputParameters &parameters)
double * _bin_values_y
Definition: NekSpatialBinUserObject.h:151
double * _bin_volumes
Volumes of each bin.
Definition: NekSpatialBinUserObject.h:155
int * _bin_partial_counts
Partial-sum of bin count per Nek rank.
Definition: NekSpatialBinUserObject.h:167
virtual const unsigned int num_bins() const
virtual Real spatialValue(const Point &p) const override final
void computePoints1D()
Get the output points for a single bin.
int * _bin_counts
Definition: NekSpatialBinUserObject.h:161
virtual const unsigned int bin(const Point &p) const
virtual void computeBinVolumes() final
Compute the volume of each bin and check for zero contributions.
unsigned int _n_bins
total number of bins
Definition: NekSpatialBinUserObject.h:138
std::vector< bool > _has_direction
For each x, y, z direction, whether the combined distribution covers that direction.
Definition: NekSpatialBinUserObject.h:125
std::vector< const SpatialBinUserObject * > _bins
Userobjects providing the bins.
Definition: NekSpatialBinUserObject.h:122
const bool & _map_space_by_qp
Definition: NekSpatialBinUserObject.h:112
const std::vector< unsigned int > unrolledBin(const unsigned int &total_bin_index) const
static InputParameters validParams()
virtual void getBinVolumes()=0
Get the volume of each bin, used for normalizing in derived classes.
Definition: CardinalEnums.h:86
void fillCoordinates(const std::vector< unsigned int > &indices, Point &p) const
Definition: NekUserObject.h:30
const field::NekFieldEnum _field
field to postprocess with the bins
Definition: NekSpatialBinUserObject.h:106
const std::vector< UserObjectName > & _bin_names
Names of the userobjects providing the bins.
Definition: NekSpatialBinUserObject.h:103
std::vector< Point > _points
points at which to output the user object to give unique values
Definition: NekSpatialBinUserObject.h:141
double * _bin_values_z
Definition: NekSpatialBinUserObject.h:152
std::vector< Point > _velocity_bin_directions
velocity direction to use for each bin
Definition: NekSpatialBinUserObject.h:144
void computePoints3D()
Get the output points for three combined bins.
void computePoints2D()
Get the output points for two combined bins.
virtual const std::vector< Point > spatialPoints() const override
Definition: NekSpatialBinUserObject.h:53
BinnedVelocityComponentEnum
Directions in which to evaluate velocity.
Definition: CardinalEnums.h:79
const bool & _check_zero_contributions
Definition: NekSpatialBinUserObject.h:119
Definition: NekSpatialBinUserObject.h:29
NekFieldEnum
Enumeration of possible fields to read from nekRS.
Definition: CardinalEnums.h:89
virtual ~NekSpatialBinUserObject()
double * _bin_values_x
temporary storage space to hold the results of component-wise evaluations
Definition: NekSpatialBinUserObject.h:150
double * _bin_values
values of the userobject in each bin
Definition: NekSpatialBinUserObject.h:147
double * _bin_partial_values
Partial-sum of bin value per Nek rank.
Definition: NekSpatialBinUserObject.h:164
void resetPartialStorage()
Reset the scratch space storage to zero values.
component::BinnedVelocityComponentEnum _velocity_component
Definition: NekSpatialBinUserObject.h:135
Definition: CardinalEnums.h:76
Point nekPoint(const int &local_elem_id, const int &local_node_id) const