Code_TYMPAN  4.4.0
Industrial site acoustic simulation
Simulation.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) <2012-2024> <EDF-DTG> <FRANCE>
3  * This file is part of Code_TYMPAN (R).
4  * Code_TYMPAN (R) 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  * Code_TYMPAN (R) is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11  * See the GNU General Public License for more details.
12  * You should have received a copy of the GNU General Public License along
13  * with Code_TYMPAN (R). If not, see <https://www.gnu.org/licenses/>.
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"
26 #include "DefaultEngine.h"
27 #include "ParallelDefaultEngine.h"
28 
30 {
31  DEFAULT = 0,
33  GPU
34 };
35 
43 class Simulation : public Base
44 {
45 
46 public:
49  {
50  compteurSource = 0;
53  }
55  Simulation(const Simulation& other)
56  {
57  solver = new Solver(other.solver);
58  engine = NULL;
59  engineC = other.engineC;
63  *configuration = *other.configuration;
64  }
66  virtual ~Simulation() {}
67 
74  {
75  return &scene;
76  }
77 
78 #ifdef TEST_ACCELERATION_RECEPTORS
84  {
85  return &receptors_landscape;
86  }
87 #endif
88 
93  void setSolver(Solver* _solver)
94  {
95  solver = _solver;
96  }
97 
104  {
105  return solver;
106  }
107 
114  {
115  return engine;
116  }
117 
122  void clean();
123 
131  bool launchSimulation();
132 
138  void addSource(const Source& s)
139  {
140  sources.push_back(s);
141  sources.back().setId(compteurSource);
142  compteurSource++;
143  }
149  std::vector<Source>& getSources()
150  {
151  return sources;
152  }
153 
160  {
161  recepteurs.push_back(r);
162  recepteurs.back().setId(compteurRecepteur);
163 #ifdef TEST_ACCELERATION_RECEPTORS
164  Recepteur* rcpt = new Recepteur(r);
165  rcpt->setId(compteurRecepteur);
167 #endif
169  }
175  std::vector<Recepteur>& getRecepteurs()
176  {
177  return recepteurs;
178  }
179 
181  void setMaterialManager(MaterialManager* _materialManager)
182  {
183  materialManager = _materialManager;
184  }
186  {
187  return materialManager;
188  }
189 
192  {
193  engineC = engine;
194  }
195 
198  {
199  return configuration;
200  }
201 
202  // void runBenchmark() { engine = new DefaultEngine(&scene, &sources, solver, &recepteurs);
203  // engine->runStructureBenchmark(); }
204 
205 protected:
207 #ifdef TEST_ACCELERATION_RECEPTORS
209 #endif
210 
213 
214  std::vector<Source> sources;
215  std::vector<Recepteur> recepteurs;
216 
219 
220  unsigned int compteurSource;
221  unsigned int compteurRecepteur;
222 
224 };
225 #endif
NxReal s
Definition: NxVec3.cpp:317
engineChoice
Definition: Simulation.h:30
@ DEFAULT
Definition: Simulation.h:31
@ GPU
Definition: Simulation.h:33
@ PARALLELDEFAULT
Definition: Simulation.h:32
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:44
engineChoice engineC
Enum giving the Engine choice.
Definition: Simulation.h:218
void setSolver(Solver *_solver)
Tool function to set the acoustic solver for the simulation.
Definition: Simulation.h:93
Solver * solver
Pointer to a solver (acoustic method)
Definition: Simulation.h:211
Scene scene
Description of the geometry in an accelerated structure.
Definition: Simulation.h:206
AcousticRaytracerConfiguration * getConfiguration()
Get the configuration.
Definition: Simulation.h:197
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:159
Engine * getEngine()
Get the engine.
Definition: Simulation.h:113
void addSource(const Source &s)
Tool function to add a source to the simulation.
Definition: Simulation.h:138
std::vector< Recepteur > recepteurs
All the acoustic receptors for the Simulation.
Definition: Simulation.h:215
Engine * engine
Pointer to the selected Engine.
Definition: Simulation.h:217
Simulation()
Constructor.
Definition: Simulation.h:48
void setMaterialManager(MaterialManager *_materialManager)
Set/Get the pointer to the MaterialManager.
Definition: Simulation.h:181
MaterialManager * materialManager
Pointer to a MaterialManager object.
Definition: Simulation.h:212
Solver * getSolver()
Get the acoustic solver.
Definition: Simulation.h:103
virtual ~Simulation()
Destructor.
Definition: Simulation.h:66
void setEngine(engineChoice engine=DEFAULT)
Set the engine (by default, the DefaultEngine)
Definition: Simulation.h:191
std::vector< Source > sources
All the acoustic sources for the Simulation.
Definition: Simulation.h:214
Scene * getScene()
Get a pointer to the scene.
Definition: Simulation.h:73
std::vector< Recepteur > & getRecepteurs()
Return a vector of all receptors of the scene.
Definition: Simulation.h:175
Simulation(const Simulation &other)
Copy constructor.
Definition: Simulation.h:55
std::vector< Source > & getSources()
Return the sources list of the scene.
Definition: Simulation.h:149
MaterialManager * getMaterialManager()
Definition: Simulation.h:185
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:208
AcousticRaytracerConfiguration * configuration
Pointer to the Acoustic RayTracer configuration.
Definition: Simulation.h:223
unsigned int compteurRecepteur
Receptor counter.
Definition: Simulation.h:221
Scene * get_receptors_landscape()
Return the geometric distribution of receptors.
Definition: Simulation.h:83
unsigned int compteurSource
Source counter.
Definition: Simulation.h:220
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