Code_TYMPAN  4.4.0
Industrial site acoustic simulation
Simulation.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) <2012> <EDF-R&D> <FRANCE>
3  * This program is free software; you can redistribute it and/or modify
4  * it under the terms of the GNU General Public License as published by
5  * the Free Software Foundation; either version 2 of the License, or
6  * (at your option) any later version.
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10  * See the GNU General Public License for more details.
11  * You should have received a copy of the GNU General Public License along
12  * with this program; if not, write to the Free Software Foundation, Inc.,
13  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
14  */
15 
16 #ifndef SIMULATION_H
17 #define SIMULATION_H
18 
19 #include "Base.h"
20 #include "Geometry/Scene.h"
21 #include "Acoustic/Solver.h"
22 #include "Acoustic/Source.h"
23 #include "Acoustic/Recepteur.h"
24 #include "Acoustic/Material.h"
25 #include "Tools/Logger.h"
27 #include "DefaultEngine.h"
28 #include "ParallelDefaultEngine.h"
29 
31 {
32  DEFAULT = 0,
34  GPU
35 };
36 
44 class Simulation : public Base
45 {
46 
47 public:
50  {
51  compteurSource = 0;
54  }
56  Simulation(const Simulation& other)
57  {
58  solver = new Solver(other.solver);
59  engine = NULL;
60  engineC = other.engineC;
64  *configuration = *other.configuration;
65  }
67  virtual ~Simulation() {}
68 
75  {
76  return &scene;
77  }
78 
79 #ifdef TEST_ACCELERATION_RECEPTORS
85  {
86  return &receptors_landscape;
87  }
88 #endif
89 
94  void setSolver(Solver* _solver)
95  {
96  solver = _solver;
97  }
98 
105  {
106  return solver;
107  }
108 
115  {
116  return engine;
117  }
118 
123  void clean();
124 
132  bool launchSimulation();
133 
139  void addSource(const Source& s)
140  {
141  sources.push_back(s);
142  sources.back().setId(compteurSource);
143  compteurSource++;
144  }
150  std::vector<Source>& getSources()
151  {
152  return sources;
153  }
154 
161  {
162  recepteurs.push_back(r);
163  recepteurs.back().setId(compteurRecepteur);
164 #ifdef TEST_ACCELERATION_RECEPTORS
165  Recepteur* rcpt = new Recepteur(r);
166  rcpt->setId(compteurRecepteur);
168 #endif
170  }
176  std::vector<Recepteur>& getRecepteurs()
177  {
178  return recepteurs;
179  }
180 
182  void setMaterialManager(MaterialManager* _materialManager)
183  {
184  materialManager = _materialManager;
185  }
187  {
188  return materialManager;
189  }
190 
193  {
194  engineC = engine;
195  }
196 
199  {
200  return configuration;
201  }
202 
203  // void runBenchmark() { engine = new DefaultEngine(&scene, &sources, solver, &recepteurs);
204  // engine->runStructureBenchmark(); }
205 
206 protected:
208 #ifdef TEST_ACCELERATION_RECEPTORS
210 #endif
211 
214 
215  std::vector<Source> sources;
216  std::vector<Recepteur> recepteurs;
217 
220 
221  unsigned int compteurSource;
222  unsigned int compteurRecepteur;
223 
225 };
226 #endif
NxReal s
Definition: NxVec3.cpp:317
engineChoice
Definition: Simulation.h:31
@ DEFAULT
Definition: Simulation.h:32
@ GPU
Definition: Simulation.h:34
@ PARALLELDEFAULT
Definition: Simulation.h:33
Class defining the configuration of the acoustic ray tracer.
static AcousticRaytracerConfiguration * get()
Get access to the configuration.
Base class of Event, Material, PostFilter, Ray, Repere, Scene, Shape, Simulation, Source.
Definition: Base.h:25
Base class for engines (DefaultEngine, ParallelDefaultEngine,...)
Definition: Engine.h:36
A manager class for Material.
Definition: Material.h:69
Receptor inherits from a Sphere Shape.
Definition: Recepteur.h:28
void setId(unsigned int _id)
Definition: Recepteur.h:64
This class mainly define a mesh (list of Shape) used by the Simulation object.
Definition: Scene.h:51
void addShape(Shape *shape)
Add a shape to the list.
Definition: Scene.h:68
Class hosting all the informations needed for ray tracing. It contains the function to launch the ray...
Definition: Simulation.h:45
engineChoice engineC
Enum giving the Engine choice.
Definition: Simulation.h:219
void setSolver(Solver *_solver)
Tool function to set the acoustic solver for the simulation.
Definition: Simulation.h:94
Solver * solver
Pointer to a solver (acoustic method)
Definition: Simulation.h:212
Scene scene
Description of the geometry in an accelerated structure.
Definition: Simulation.h:207
AcousticRaytracerConfiguration * getConfiguration()
Get the configuration.
Definition: Simulation.h:198
void clean()
Clean the simulation: the scene, sources, and receptors and all the rays are deleted.
Definition: Simulation.cpp:17
void addRecepteur(Recepteur &r)
Tool function to add quickly a receptor for the simulation.
Definition: Simulation.h:160
Engine * getEngine()
Get the engine.
Definition: Simulation.h:114
void addSource(const Source &s)
Tool function to add a source to the simulation.
Definition: Simulation.h:139
std::vector< Recepteur > recepteurs
All the acoustic receptors for the Simulation.
Definition: Simulation.h:216
Engine * engine
Pointer to the selected Engine.
Definition: Simulation.h:218
Simulation()
Constructor.
Definition: Simulation.h:49
void setMaterialManager(MaterialManager *_materialManager)
Set/Get the pointer to the MaterialManager.
Definition: Simulation.h:182
MaterialManager * materialManager
Pointer to a MaterialManager object.
Definition: Simulation.h:213
Solver * getSolver()
Get the acoustic solver.
Definition: Simulation.h:104
virtual ~Simulation()
Destructor.
Definition: Simulation.h:67
void setEngine(engineChoice engine=DEFAULT)
Set the engine (by default, the DefaultEngine)
Definition: Simulation.h:192
std::vector< Source > sources
All the acoustic sources for the Simulation.
Definition: Simulation.h:215
Scene * getScene()
Get a pointer to the scene.
Definition: Simulation.h:74
std::vector< Recepteur > & getRecepteurs()
Return a vector of all receptors of the scene.
Definition: Simulation.h:176
Simulation(const Simulation &other)
Copy constructor.
Definition: Simulation.h:56
std::vector< Source > & getSources()
Return the sources list of the scene.
Definition: Simulation.h:150
MaterialManager * getMaterialManager()
Definition: Simulation.h:186
bool launchSimulation()
Program main loop. Extract all the rays from the sources then treat them. The loop finishes when the ...
Definition: Simulation.cpp:30
Scene receptors_landscape
Geometric distribution of receptors.
Definition: Simulation.h:209
AcousticRaytracerConfiguration * configuration
Pointer to the Acoustic RayTracer configuration.
Definition: Simulation.h:224
unsigned int compteurRecepteur
Receptor counter.
Definition: Simulation.h:222
Scene * get_receptors_landscape()
Return the geometric distribution of receptors.
Definition: Simulation.h:84
unsigned int compteurSource
Source counter.
Definition: Simulation.h:221
The Solver class gives an interface to the developer to add easily a new acoustic method using ray tr...
Definition: Solver.h:45
Acoustic source class.
Definition: Source.h:33