openPSTD  2.0
Open source simulation for sound propagation in urban environments
PSTDKernel.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:
22 // 18-7-2015
23 //
24 // Authors:
25 // Michiel Fortuijn
26 // Louis van Harten
27 // Omar Richardson
28 //
29 // Purpose:
30 // The PSTDKernel is the interface between the front- and backend
31 // of the program.
32 //
34 
35 #ifndef OPENPSTD_KERNELFACADE_H
36 #define OPENPSTD_KERNELFACADE_H
37 
38 #include <string>
39 #include "Solver.h"
40 #include "core/Scene.h"
41 #include "KernelInterface.h"
42 
43 namespace OpenPSTD {
44  namespace Kernel {
45 
52  class PSTDKernel : public KernelInterface {
53  private:
55  std::shared_ptr<PSTDConfiguration> config;
57  std::shared_ptr<PSTDSettings> settings;
59  std::shared_ptr<Kernel::Scene> scene;
61  const float default_alpha = 1.f;
62 
66  void initialize_scene();
67 
69  std::shared_ptr<Kernel::WisdomCache> wnd;
70 
77  void add_domains();
78 
79  /*
80  * Computes the location of the speakers and creates new objects for them.
81  * Expects real world coordinates from the scene descriptor file
82  * Note that speakers are not bound to grid coordinates.
83  * We find the corresponding grid by flooring the location divided by the grid size.
84  */
85  void add_speakers();
86 
87  /*
88  * Computes the location of the receivers and creates new objects for them.
89  * Expects real world coordinates from the scene descriptor file
90  * @see add_speakers();
91  */
92  void add_receivers();
93 
99  std::vector<float> scale_to_grid(QVector2D world_vector);
100 
106  std::vector<float> scale_to_grid(QVector3D world_vector);
107 
111  std::vector<int> round_off(std::vector<float>);
112 
116  std::map<Kernel::Direction, Kernel::EdgeParameters> translate_edge_parameters(DomainConf domain);
117 
118 
119  public:
120 
126  void initialize_kernel(std::shared_ptr<PSTDConfiguration> config) override;
127 
132  void run(KernelCallback *callback) override;
133 
137  SimulationMetadata get_metadata() override;
138 
143  std::shared_ptr<Kernel::Scene> get_scene();
144  };
145 
146  }
147 }
148 
149 #endif //OPENPSTD_KERNELFACADE_H
This is the general namespace of the OpenPSTD application.
Definition: Boundary.cpp:33
The kernel API.
Definition: KernelInterface.h:265
The API with methods that run the simulation from a PSTDFile.
Definition: PSTDKernel.h:52
void initialize_kernel(std::shared_ptr< PSTDConfiguration > config) override
Sets the configuration, also initializes the kernel and the scene, constructs the domains and sets th...
Definition: PSTDKernel.cpp:41
void run(KernelCallback *callback) override
Runs the kernel.
Definition: PSTDKernel.cpp:110
Interface representation of the domain.
Definition: KernelInterface.h:166
Data not obtained in running openPSTD but necessary for representing the information.
Definition: KernelInterface.h:242
SimulationMetadata get_metadata() override
Query the kernel for metadata about the simulation that is configured.
Definition: PSTDKernel.cpp:141
Callback interface for communication with the CLI or the GUI.
Definition: KernelInterface.h:212
std::shared_ptr< Kernel::Scene > get_scene()
Return the scene of the simulation.
Definition: PSTDKernel.cpp:137