Loading [MathJax]/extensions/tex2jax.js
Cardinal
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
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 "GeneralUserObject.h"
22 #include "NekFieldInterface.h"
23 #include "NekBase.h"
24 #include "SpatialBinUserObject.h"
25 
31 class NekSpatialBinUserObject : public GeneralUserObject, public NekBase, public NekFieldInterface
32 {
33 public:
34  static InputParameters validParams();
35 
36  NekSpatialBinUserObject(const InputParameters & parameters);
37 
38  virtual ~NekSpatialBinUserObject();
39 
40  virtual void initialize() {}
41  virtual void finalize() {}
42  virtual void execute() override;
43 
49  virtual void executeUserObject() = 0;
50 
51  virtual Real spatialValue(const Point & p) const override final;
52 
60  virtual Real spatialValue(const Point & p, const unsigned int & component) const = 0;
61 
62  virtual const unsigned int bin(const Point & p) const;
63 
64  virtual const unsigned int num_bins() const;
65 
66  virtual const std::vector<Point> spatialPoints() const override { return _points; }
67 
69  virtual void computeBinVolumes() final;
70 
72  virtual void getBinVolumes() = 0;
73 
79  const std::vector<unsigned int> unrolledBin(const unsigned int & total_bin_index) const;
80 
87  Point nekPoint(const int & local_elem_id, const int & local_node_id) const;
88 
89 protected:
91  void computePoints1D();
92 
94  void computePoints2D();
95 
97  void computePoints3D();
98 
100  void resetPartialStorage();
101 
107  void fillCoordinates(const std::vector<unsigned int> & indices, Point & p) const;
108 
110  const unsigned int & _interval;
111 
114 
116  const std::vector<UserObjectName> & _bin_names;
117 
122  const bool & _map_space_by_qp;
123 
130 
132  std::vector<const SpatialBinUserObject *> _bins;
133 
135  std::vector<bool> _has_direction;
136 
138  std::vector<unsigned int> _bin_providing_direction;
139 
141  unsigned int _n_bins;
142 
144  std::vector<Point> _points;
145 
147  std::vector<Point> _velocity_bin_directions;
148 
150  double * _bin_values;
151 
153  double * _bin_values_x;
154  double * _bin_values_y;
155  double * _bin_values_z;
156 
158  double * _bin_volumes;
159 
164  int * _bin_counts;
165 
168 
171 };
std::vector< unsigned int > _bin_providing_direction
For each x, y, z direction, which bin provides that direction.
Definition: NekSpatialBinUserObject.h:138
NekSpatialBinUserObject(const InputParameters &parameters)
double * _bin_values_y
Definition: NekSpatialBinUserObject.h:154
bool _fixed_mesh
Whether the mesh this userobject operates on is fixed, allowing caching of volumes and areas.
Definition: NekSpatialBinUserObject.h:113
double * _bin_volumes
Volumes of each bin.
Definition: NekSpatialBinUserObject.h:158
int * _bin_partial_counts
Partial-sum of bin count per Nek rank.
Definition: NekSpatialBinUserObject.h:170
virtual const unsigned int num_bins() const
virtual Real spatialValue(const Point &p) const override final
Definition: SpatialBinUserObject.h:26
void computePoints1D()
Get the output points for a single bin.
int * _bin_counts
Definition: NekSpatialBinUserObject.h:164
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:141
std::vector< bool > _has_direction
For each x, y, z direction, whether the combined distribution covers that direction.
Definition: NekSpatialBinUserObject.h:135
std::vector< const SpatialBinUserObject * > _bins
Userobjects providing the bins.
Definition: NekSpatialBinUserObject.h:132
const bool & _map_space_by_qp
Definition: NekSpatialBinUserObject.h:122
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.
void fillCoordinates(const std::vector< unsigned int > &indices, Point &p) const
const unsigned int & _interval
Interval with which to evaluate the user object.
Definition: NekSpatialBinUserObject.h:110
const std::vector< UserObjectName > & _bin_names
Names of the userobjects providing the bins.
Definition: NekSpatialBinUserObject.h:116
virtual void execute() override
std::vector< Point > _points
points at which to output the user object to give unique values
Definition: NekSpatialBinUserObject.h:144
double * _bin_values_z
Definition: NekSpatialBinUserObject.h:155
std::vector< Point > _velocity_bin_directions
velocity direction to use for each bin
Definition: NekSpatialBinUserObject.h:147
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:66
virtual void initialize()
Definition: NekSpatialBinUserObject.h:40
Definition: NekBase.h:25
const bool & _check_zero_contributions
Definition: NekSpatialBinUserObject.h:129
Definition: NekSpatialBinUserObject.h:31
virtual void executeUserObject()=0
Definition: NekFieldInterface.h:7
virtual void finalize()
Definition: NekSpatialBinUserObject.h:41
virtual ~NekSpatialBinUserObject()
double * _bin_values_x
temporary storage space to hold the results of component-wise evaluations
Definition: NekSpatialBinUserObject.h:153
double * _bin_values
values of the userobject in each bin
Definition: NekSpatialBinUserObject.h:150
double * _bin_partial_values
Partial-sum of bin value per Nek rank.
Definition: NekSpatialBinUserObject.h:167
void resetPartialStorage()
Reset the scratch space storage to zero values.
Definition: CardinalEnums.h:81
Point nekPoint(const int &local_elem_id, const int &local_node_id) const