Code_TYMPAN  4.4.0
Industrial site acoustic simulation
Solver.cpp
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 #include "Solver.h"
18 #include "Acoustic/ValidRay.h"
19 #include "Acoustic/PostTreatment.h"
20 #include "Tools/FaceSelector.h"
21 #include "Tools/LengthSelector.h"
25 #include "Tools/FermatSelector.h"
28 #include "Tools/CleanerSelector.h"
29 
30 bool Solver::postTreatmentScene(Scene* scene, std::vector<Source>& sources,
31  std::vector<Recepteur>& recepteurs)
32 {
33  return true;
34 }
35 
36 double Solver::leafTreatment(std::vector<Intersection>& primitives)
37 {
38  return -1.0;
39 }
40 
42 {
43  return false;
44 }
45 
47 {
48  valid_rays.push_back(r);
49  return true;
50 }
51 
53 {
54  // Clear valid_rays completely and delete the corresponding rays
55  while (!valid_rays.empty())
56  {
57  Ray* r = valid_rays.back();
58  valid_rays.pop_back();
59  delete r;
60  }
61 }
62 
64 {
65  return;
66 }
67 
69 {
70  // Each invalidated ray is deleted
71  delete r;
72  return true;
73 }
74 
76 {
77  return true;
78 }
79 
80 bool BasicSolver::postTreatmentScene(Scene* scene, std::vector<Source>& sources,
81  std::vector<Recepteur>& recepteurs)
82 {
86 
87  if (AcousticRaytracerConfiguration::get()->UsePostFilters)
88  {
89  if (AcousticRaytracerConfiguration::get()->DebugUseCloseEventSelector)
90  {
92  }
93  if (AcousticRaytracerConfiguration::get()->DebugUseDiffractionAngleSelector)
94  {
96  }
97  if (AcousticRaytracerConfiguration::get()->DebugUseDiffractionPathSelector)
98  {
101  }
102  if (AcousticRaytracerConfiguration::get()->DebugUseFermatSelector)
103  {
105  }
106  if (AcousticRaytracerConfiguration::get()->DebugUseFaceSelector)
107  {
109  }
110  }
111 
116 
117  // Ajoute des cylindres sur les arretes diffractantes
119 
120  return true;
121 }
122 
124 {
125  if (r->getNbEvents() > static_cast<unsigned int>(AcousticRaytracerConfiguration::get()->MaxProfondeur))
126  {
127  return false;
128  }
129 
130  bool isValid = false;
131 
132  // cas d'un triangle (sol)
133  if ((inter->forme == TRIANGLE) &&
134  (r->getReflex() < static_cast<unsigned int>(AcousticRaytracerConfiguration::get()->MaxReflexion)) &&
136  {
138  }
139 
140  // cas du cylindre (arrete de diffraction)
141  else if (inter->forme == CYLINDRE &&
142  r->getDiff() < static_cast<unsigned int>(AcousticRaytracerConfiguration::get()->MaxDiffraction))
143  {
144  isValid = ValidRay::validCylindreWithDiffraction(r, inter);
145  }
146 
147 #ifdef _ALLOW_TARGETING_
148  if (isValid && AcousticRaytracerConfiguration::get()->EnableFullTargets)
149  {
150  ValidRay::appendDirectionToEvent(r->events.back(), targetManager);
151  }
152 #endif //_ALLOW_TARGETING_
153 
154  return (isValid); //(isValid && selectorManagerIntersection.appendData(r));
155 }
156 
158 {
160 #ifdef _DEBUG
161  if (selectorManagerValidation.getSelectedData().size() % 1000 == 0)
162  {
163  std::cout << "Nombre de rayon valides = " << selectorManagerValidation.getSelectedData().size()
164  << std::endl;
165  }
166 
167 #endif
168  return true;
169 }
170 
172 {
173  if (!AcousticRaytracerConfiguration::get()->KeepDebugRay)
174  {
175  delete r;
176  r = NULL;
177  }
178  else
179  {
180  debug_rays.push_back(r);
181  }
182 
183  return true;
184 }
185 
187 {
188  std::map<unsigned long long int, Ray*> selectedData = selectorManagerValidation.getSelectedData();
189 
190  for (std::map<unsigned long long, Ray*>::iterator it = selectedData.begin(); it != selectedData.end();
191  it++)
192  {
193  valid_rays.push_back(it->second);
194  }
195 
198 
199  return;
200 }
@ HISTORY_PRIMITIVE
Definition: FaceSelector.h:26
@ TRIANGLE
Definition: Shape.h:36
@ CYLINDRE
Definition: Shape.h:37
unsigned int MaxReflexion
Maximal reflection events.
unsigned int MaxDiffraction
Maximal diffraction events.
unsigned int MaxProfondeur
Maximal number of events for ray validation in ANIME3D solver.
static AcousticRaytracerConfiguration * get()
Get access to the configuration.
SelectorManager< Ray > selectorManagerIntersection
Definition: Solver.h:163
virtual void finish()
End the operations.
Definition: Solver.cpp:186
virtual bool invalidRayon(Ray *r)
Method to arrange the invalid rays. The invalid rays are put away into a debug_ray array in order to ...
Definition: Solver.cpp:171
virtual bool valideIntersection(Ray *r, Intersection *inter)
Validation function for an intersection. If the intersection is validated, an event is created and ad...
Definition: Solver.cpp:123
virtual bool valideRayon(Ray *r)
Ray validation. The developer may, for instance, choose a filtering on the rays and only validate sin...
Definition: Solver.cpp:157
virtual bool postTreatmentScene(Scene *scene, std::vector< Source > &sources, std::vector< Recepteur > &recepteurs)
Virtual function to post-process the Scene. It has two phases: transform the meta-objects and load th...
Definition: Solver.cpp:80
SelectorManager< Ray > selectorManagerValidation
Definition: Solver.h:164
Clean DoNothing events from ray events list \ --> After ray validation DoNothing events are no longer...
Rejects a ray if two of its events occur on the same shape (for example a diffraction close to a refl...
: Select diffracted rays that are launched in the shadow zone of the obstacle (closed angle) Other ar...
: Rejects rays if the cumulative length added by the diffractions events in comparison to the length ...
: To disable ray with a number of diffraction events greater than a threshold value
: To keep only one from two or more rays which have the same history (events on the same primitive)
Definition: FaceSelector.h:34
: Rays can be seen as long cones that get thicker as their length increases based on their associated...
: Rejects rays which have traveled a distance greater than a given length
: Describes a ray by a pair of unsigned int. The first one gives the source number (in the range 0-40...
Definition: Ray.h:38
unsigned int getReflex() const
Return the reflections number encountered by the ray.
Definition: Ray.h:176
std::vector< boost::shared_ptr< Event > > events
Events list for the ray.
Definition: Ray.h:517
unsigned int getDiff() const
Return the diffractions number encountered by the ray.
Definition: Ray.h:166
unsigned int getNbEvents() const
Return the total number of events.
Definition: Ray.h:185
: To disable the rays which have a number of reflection events greater than a given threshold or refl...
This class mainly define a mesh (list of Shape) used by the Simulation object.
Definition: Scene.h:51
bool appendData(T *data)
Append data (typically a ray) and loop on Selectors to filter.
void reset()
Reset all the Selector and clear the local data.
void addSelector(Selector< T > *selector)
Add a Selector to the list.
std::map< unsigned long long, T * > & getSelectedData()
Get the selected data.
bool isSol() const
Get/Set the flag _isSol (ground or not)
Definition: Shape.h:194
virtual bool valideRayon(Ray *r)
Ray validation. The developer may, for instance, choose a filtering on the rays and only validate sin...
Definition: Solver.cpp:46
virtual bool postTreatmentScene(Scene *scene, std::vector< Source > &sources, std::vector< Recepteur > &recepteurs)
Virtual function to post-process the Scene. It has two phases: transform the meta-objects and load th...
Definition: Solver.cpp:30
virtual bool valideIntersection(Ray *r, Intersection *inter)
Validation function for an intersection. If the intersection is validated, an event is created and ad...
Definition: Solver.cpp:41
std::deque< Ray * > valid_rays
Rays list which are validated by the solver.
Definition: Solver.h:129
virtual double leafTreatment(std::vector< Intersection > &primitives)
Leaf treatment function for accelerators. The default is to keep only the first intersection....
Definition: Solver.cpp:36
virtual bool loadParameters()
Load the computation parameters.
Definition: Solver.cpp:75
virtual bool invalidRayon(Ray *r)
Method to arrange the invalid rays. The invalid rays are put away into a debug_ray array in order to ...
Definition: Solver.cpp:68
virtual void finish()
End the operations.
Definition: Solver.cpp:63
std::deque< Ray * > debug_rays
Rays list which are invalidated by the solver.
Definition: Solver.h:130
virtual void clean()
Delete the valid rays array.
Definition: Solver.cpp:52
bool constructEdge(Scene *scene)
Build the edges list of a scene.
bool validTriangleWithSpecularReflexion(Ray *r, Intersection *inter)
Definition: ValidRay.cpp:46
bool validCylindreWithDiffraction(Ray *r, Intersection *inter)
Definition: ValidRay.cpp:184
Intersection struct.
Definition: Shape.h:46
FORM forme
Definition: Shape.h:50
Shape * p
Definition: Shape.h:49