openPSTD  2.0
Open source simulation for sound propagation in urban environments
Scene.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: Model a scene (a collections of rectangular domains).
28 //
29 //
31 
32 #ifndef OPENPSTD_KERNELSCENE_H
33 #define OPENPSTD_KERNELSCENE_H
34 
35 #include <Eigen/Dense>
36 #include <map>
37 #include <string>
38 #include <sstream>
39 #include "kernel_functions.h"
40 #include "Domain.h"
41 #include "Geometry.h"
42 #include "Speaker.h"
43 #include "Receiver.h"
44 #include "Boundary.h"
45 #include "../KernelInterface.h"
46 
47 namespace OpenPSTD {
48  namespace Kernel {
55  class Scene {
56  public:
58  std::vector<std::shared_ptr<Domain>> domain_list;
60  std::shared_ptr<PSTDSettings> settings;
62  Point top_left;Initial sound pressure.
67 
68  std::vector<std::shared_ptr<Boundary>> boundary_list;
69  std::vector<std::shared_ptr<Receiver>> receiver_list;
70  std::vector<std::shared_ptr<Speaker>> speaker_list;
71  private:
73  std::map<Direction, EdgeParameters> default_edge_parameters; // Uninitialized
74  int number_of_domains;
75  public:
76 
81  Scene(std::shared_ptr<PSTDSettings> settings);
82 
92  void add_receiver(const float x, const float y, const float z);
93 
103  void add_speaker(const float x, const float y, const float z);
104 
110  void add_domain(std::shared_ptr<Domain> domain);
111 
115  void compute_pml_matrices();
116 
121  void add_pml_domains();
122 
126  void apply_pml_matrices();
127 
132  Eigen::ArrayXXf get_pressure_field();
133 
139  std::shared_ptr<Domain> get_domain(int id);
140 
144  int get_new_id();
145 
146  private:
147 
151  Eigen::ArrayXXf get_field(char field_type);
152 
157  std::vector<int> get_corner_points(std::shared_ptr<Domain> domain);
158 
164  bool should_merge_domains(std::shared_ptr<Domain> domain1, std::shared_ptr<Domain> domain2);
165 
170  std::shared_ptr<Domain> get_singular_parent_domain(std::shared_ptr<Domain> domain);
171  };
172 
173  std::ostream &operator<<(std::ostream &str, Scene const &v);
174  }
175 }
176 
177 #endif //OPENPSTD_KERNELSCENE_H
This is the general namespace of the OpenPSTD application.
Definition: Boundary.cpp:33
void apply_pml_matrices()
Applies the layer coefficients for each domain in the scene.
Definition: Scene.cpp:286
std::vector< std::shared_ptr< Domain > > domain_list
List with domains.
Definition: Scene.h:58
Scene(std::shared_ptr< PSTDSettings > settings)
Constructor of Scene object.
Definition: Scene.cpp:33
void add_pml_domains()
Add the necessary perfectly matched layer domain to the current scene, checks which layers belong to ...
Definition: Scene.cpp:41
Point size
Difference between top left and bottom right.
Definition: Scene.h:66
Point top_left
Top left of the most top left domain.
Definition: Scene.h:62
Collection of the rectangular domains.
Definition: Scene.h:55
void add_speaker(const float x, const float y, const float z)
Adds a speaker to the scene.
Definition: Scene.cpp:267
The points of the grid, represented by 2D integer vectors.
Definition: Geometry.h:43
Initial sound pressure Point bottom_right
Bottom right of the most bottom right domain.
Definition: Scene.h:64
std::shared_ptr< Domain > get_domain(int id)
Fetch a domain with specified ID, if existing.
Definition: Scene.cpp:401
std::shared_ptr< PSTDSettings > settings
Settings for the simulation.
Definition: Scene.h:60
void add_receiver(const float x, const float y, const float z)
Adds a receiver to the scene.
Definition: Scene.cpp:253
void compute_pml_matrices()
Computes the perfectly matched layer matrix coefficients for each domain in the scene.
Definition: Scene.cpp:278
Eigen::ArrayXXf get_pressure_field()
Obtains the global pressure field by summing the pressure in each domain.
Definition: Scene.cpp:378
int get_new_id()
Returns a new domain ID integer.
Definition: Scene.cpp:419
void add_domain(std::shared_ptr< Domain > domain)
Add domain to the scene.
Definition: Scene.cpp:294