openPSTD  2.0
Open source simulation for sound propagation in urban environments
Receiver.h
1 // This file is part of openPSTD. //
3 // //
4 // openPSTD is free software: you can redistribute it and/or modify //
5 // it under the terms of the GNU General Public License as published by //
6 // the Free Software Foundation, either version 3 of the License, or //
7 // (at your option) any later version. //
8 // //
9 // openPSTD is distributed in the hope that it will be useful, //
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of //
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
12 // GNU General Public License for more details. //
13 // //
14 // You should have received a copy of the GNU General Public License //
15 // along with openPSTD. If not, see <http://www.gnu.org/licenses/>. //
16 // //
18 
20 //
21 // Date: 17-9-15
22 //
23 //
24 // Authors: Omar Richardson
25 //
26 //
27 // Purpose: This class models a receiver; a way to measure the sound
28 // pressure and velocity on a fixed location within the domain.
29 //
30 //
32 #ifndef OPENPSTD_RECEIVER_H
33 #define OPENPSTD_RECEIVER_H
34 
35 #include <vector>
36 #include <iostream>
37 #include <memory>
38 #include "../KernelInterface.h"
39 #include "Geometry.h"
40 #include "Domain.h"
41 #include <string>
42 #include "kernel_functions.h"
43 #include "WisdomCache.h"
44 
45 namespace OpenPSTD {
46  namespace Kernel {
56  class Receiver {
57 
58  public:
59  const float x;
60  const float y;
61  const float z;
62  int id;
63 
67  std::vector<float> location;
68 
73 
77  std::vector<float> grid_offset;
78 
82  std::shared_ptr<PSTDSettings> config;
83 
87  std::shared_ptr<Domain> container_domain;
88 
93  std::vector<float> received_values;
94 
102  Receiver(std::vector<float> location, std::shared_ptr<PSTDSettings> config, int id,
103  std::shared_ptr<Domain> container);
104 
113  float compute_local_pressure();
114 
115  private:
119  Eigen::ArrayXcf get_fft_factors(Point size, CalcDirection bt);
120 
125  float compute_with_nn();
126 
131  float compute_with_si();
132 
136  Eigen::ArrayXXf calc_domain_fields(std::shared_ptr<Domain> container, CalcDirection bt);
137 
138  };
139 
140  }
141 }
142 
143 #endif //OPENPSTD_RECEIVER_H
This is the general namespace of the OpenPSTD application.
Definition: Boundary.cpp:33
Receiver(std::vector< float > location, std::shared_ptr< PSTDSettings > config, int id, std::shared_ptr< Domain > container)
Initializes a receiver on coordinates (x,y,z) in grid space (not fixed to integers) ...
Definition: Receiver.cpp:34
std::shared_ptr< PSTDSettings > config
Config file containing the receiver parameters.
Definition: Receiver.h:82
CalcDirection
Helper enums - used to distinguish horizontal boundaries from vertical boundaries.
Definition: kernel_functions.h:71
std::vector< float > location
Unrounded (grid) location.
Definition: Receiver.h:67
Point grid_location
Integer grid location.
Definition: Receiver.h:72
float compute_local_pressure()
Calculates the sound pressure at the receiver at the current time step.
Definition: Receiver.cpp:46
std::shared_ptr< Domain > container_domain
Domain containing the receiver.
Definition: Receiver.h:87
The points of the grid, represented by 2D integer vectors.
Definition: Geometry.h:43
std::vector< float > received_values
Vector of observed pressure values in the receiver.
Definition: Receiver.h:93
Measure pressure values on a fixed location in the scene.
Definition: Receiver.h:56
std::vector< float > grid_offset
Distance from the receiver to the top left of the cell.
Definition: Receiver.h:77