Evita  0.16
evFeatureDetector.h
Go to the documentation of this file.
1 /*
2  *
3  * EVITA: Efficient Visualization of Terascale Datasets
4  * Copyright (C) 2000-2016 Team Evita
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Library General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Library General Public License for more details.
15  *
16  * You should have received a copy of the GNU Library General Public
17  * License along with this library; if not, write to the
18  * Free Software Foundation, Inc., 675 Mass Ave, Cambridge,
19  * MA 02139, USA.
20  *
21  */
22 
23 
24 #ifndef __evFeatureDetector_h
25 #define __evFeatureDetector_h
26 
27 
28 #include "evProcessObject.h"
29 #include "evDataset.h"
30 
31 
32 #define EVCOMPONENT_DENSITY 0
33 #define EVCOMPONENTNAME_DENSITY "Density"
34 #define EVCOMPONENT_VELOCITY 1
35 #define EVCOMPONENTNAME_VELOCITY "Velocity"
36 #define EVCOMPONENT_ENERGY 2
37 #define EVCOMPONENTNAME_ENERGY "Energy"
38 /*
39 #define EVCOMPONENT_GRID 0
40 #define EVCOMPONENTNAME_GRID "Grid"
41 #define EVCOMPONENT_DENSITY 1
42 #define EVCOMPONENTNAME_DENSITY "Density"
43 #define EVCOMPONENT_VELOCITY 2
44 #define EVCOMPONENTNAME_VELOCITY "Velocity"
45 #define EVCOMPONENT_ENERGY 3
46 #define EVCOMPONENTNAME_ENERGY "Energy"
47 */
48 
49 
51 {
52 public:
53  evFeatureDetector(void);
54  virtual ~evFeatureDetector(void);
55 
56  virtual const evString GetClassName(void) const
57  {
58  return(evString("evFeatureDetector"));
59  }
60 
61  virtual int DetectFeatures(const evDataset &dataset,
62  evScalarField &significance_map) const = 0;
63 
64 protected:
65 
66  // const evVectorField &GetGrid(const evDataset &dataset) const;
67  void CalculateGrid(const evDataset &dataset, evVectorField &grid) const;
68 
69  const evVectorField &GetDensity(const evDataset &dataset) const;
70  const evVectorField &GetVelocity(const evDataset &dataset) const;
71  const evVectorField &GetEnergy(const evDataset &dataset) const;
72 
73  void CalculatePressure(const evDataset &dataset,
74  evScalarField &pressure) const;
75 
76  void CalculateXYZGradients(const evVectorField &grid_field,
77  evVectorField &psi_gradient,
78  evVectorField &eta_gradient) const;
79  void CalculateGradient(const evScalarField &field,
80  const evVectorField &psi_gradient,
81  const evVectorField &eta_gradient,
82  evVectorField &gradient) const;
83  void CalculateGradient(const evVectorField &field,
84  const unsigned int component,
85  const evVectorField &psi_gradient,
86  const evVectorField &eta_gradient,
87  evVectorField &gradient) const;
88  double CalculateSoundSpeed(const double pressure,
89  const double density) const;
90  int CalculateSoundSpeed(const evScalarField &pressure,
91  const evScalarField &density,
92  evScalarField &sound_speed) const;
93  double CalculateMachNumber(const evVector &velocity,
94  const double pressure,
95  const double density) const;
96  int CalculateMachNumber(const evVectorField &velocity,
97  const evScalarField &pressure,
98  const evScalarField &density,
99  evScalarField &mach_number) const;
100  double CalculateNormalMachNumber(const evVector &velocity,
101  const evVector &pressure_gradient,
102  const double pressure,
103  const double density) const;
104  int CalculateNormalMachNumber(const evVectorField &velocity,
105  const evVectorField &pressure_gradient,
106  const evScalarField &pressure,
107  const evVectorField &density,
108  evScalarField &normal_mach_number) const;
109 
110 private:
111 
112  void Initialize(void);
113 
114 };
115 
116 
117 /*
118 inline const evVectorField &evFeatureDetector::GetGrid(const evDataset
119  &dataset) const
120 {
121  const evROI &roi = *dataset.GetROIList()->GetFirst();
122  return(*roi.GetComponent(EVCOMPONENT_GRID));
123 }
124 */
125 
127  &dataset) const
128 {
129  unsigned int density_component = EVCOMPONENT_DENSITY;
130 
131  /*
132  unsigned int density_component =
133  (dataset.HasExplicitGrid()) ?
134  EVCOMPONENT_DENSITY : EVCOMPONENT_DENSITY - 1;
135  */
136 
137  return(*dataset.GetROIList()->GetFirst()->GetComponent(density_component));
138 }
139 
140 
142  &dataset) const
143 {
144  unsigned int velocity_component = EVCOMPONENT_VELOCITY;
145 
146  /*
147  unsigned int velocity_component =
148  (dataset.HasExplicitGrid()) ?
149  EVCOMPONENT_VELOCITY : EVCOMPONENT_VELOCITY - 1;
150  */
151 
152  return(*dataset.GetROIList()->GetFirst()->GetComponent(velocity_component));
153 }
154 
155 
157  &dataset) const
158 {
159  unsigned int energy_component = EVCOMPONENT_ENERGY;
160 
161  /*
162  unsigned int energy_component =
163  (dataset.HasExplicitGrid()) ?
164  EVCOMPONENT_ENERGY : EVCOMPONENT_ENERGY - 1;
165  */
166 
167  return(*dataset.GetROIList()->GetFirst()->GetComponent(energy_component));
168 }
169 
170 
171 inline double evFeatureDetector::CalculateSoundSpeed(const double pressure,
172  const double density)
173  const
174 {
175  const double gamma = 1.4;
176  return(sqrt((gamma) * (pressure / density)));
177 }
178 
179 
180 inline double evFeatureDetector::CalculateMachNumber(const evVector &velocity,
181  const double pressure,
182  const double density)
183  const
184 {
185  return(velocity.Norm() / this->CalculateSoundSpeed(pressure, density));
186 }
187 
188 
190  &velocity,
191  const evVector
192  &pressure_gradient,
193  const double
194  pressure,
195  const double
196  density)
197  const
198 {
199  return(velocity * pressure_gradient /
200  (QccMathMax(pressure_gradient.Norm(), 0.001) *
201  this->CalculateSoundSpeed(pressure, density)));
202 }
203 
204 
205 #endif
double CalculateMachNumber(const evVector &velocity, const double pressure, const double density) const
Definition: evFeatureDetector.h:180
#define EVCOMPONENT_VELOCITY
Definition: evFeatureDetector.h:34
const evVectorField & GetDensity(const evDataset &dataset) const
Definition: evFeatureDetector.h:126
void CalculateXYZGradients(const evVectorField &grid_field, evVectorField &psi_gradient, evVectorField &eta_gradient) const
Definition: evFeatureDetector.h:50
void CalculatePressure(const evDataset &dataset, evScalarField &pressure) const
#define EVCOMPONENT_DENSITY
Definition: evFeatureDetector.h:32
const evVectorField & GetVelocity(const evDataset &dataset) const
Definition: evFeatureDetector.h:141
Definition: evVector.h:36
Definition: evDataset.h:34
void CalculateGrid(const evDataset &dataset, evVectorField &grid) const
#define EVCOMPONENT_ENERGY
Definition: evFeatureDetector.h:36
void CalculateGradient(const evScalarField &field, const evVectorField &psi_gradient, const evVectorField &eta_gradient, evVectorField &gradient) const
void Initialize(void)
evROIList * GetROIList(void)
Definition: evDataset.h:210
Definition: evVectorField.h:32
virtual ~evFeatureDetector(void)
double CalculateNormalMachNumber(const evVector &velocity, const evVector &pressure_gradient, const double pressure, const double density) const
Definition: evFeatureDetector.h:189
double Norm(void) const
Definition: evVector.h:395
virtual int DetectFeatures(const evDataset &dataset, evScalarField &significance_map) const =0
const evVectorField & GetEnergy(const evDataset &dataset) const
Definition: evFeatureDetector.h:156
Definition: evScalarField.h:31
Definition: evProcessObject.h:31
virtual const evString GetClassName(void) const
Definition: evFeatureDetector.h:56
evROI * GetFirst(void) const
Definition: evROIList.h:57
Definition: evString.h:30
evVectorField * GetComponent(unsigned int component) const
Definition: evROI.h:533
double CalculateSoundSpeed(const double pressure, const double density) const
Definition: evFeatureDetector.h:171