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 #include "Tools/Logger.h"
30 
31 bool Solver::postTreatmentScene(Scene* scene, std::vector<Source>& sources,
32  std::vector<Recepteur>& recepteurs)
33 {
34  return true;
35 }
36 
37 double Solver::leafTreatment(std::vector<Intersection>& primitives)
38 {
39  return -1.0;
40 }
41 
43 {
44  return false;
45 }
46 
48 {
49  valid_rays.push_back(r);
50  return true;
51 }
52 
54 {
55  // Clear valid_rays completely and delete the corresponding rays
56  while (!valid_rays.empty())
57  {
58  Ray* r = valid_rays.back();
59  valid_rays.pop_back();
60  delete r;
61  }
62 }
63 
65 {
66  return;
67 }
68 
70 {
71  // Each invalidated ray is deleted
72  delete r;
73  return true;
74 }
75 
77 {
78  return true;
79 }
80 
81 bool BasicSolver::postTreatmentScene(Scene* scene, std::vector<Source>& sources,
82  std::vector<Recepteur>& recepteurs)
83 {
87 
88  if (AcousticRaytracerConfiguration::get()->UsePostFilters)
89  {
90  if (AcousticRaytracerConfiguration::get()->DebugUseCloseEventSelector)
91  {
93  }
94  if (AcousticRaytracerConfiguration::get()->DebugUseDiffractionAngleSelector)
95  {
97  }
98  if (AcousticRaytracerConfiguration::get()->DebugUseDiffractionPathSelector)
99  {
102  }
103  if (AcousticRaytracerConfiguration::get()->DebugUseFermatSelector)
104  {
106  }
107  if (AcousticRaytracerConfiguration::get()->DebugUseFaceSelector)
108  {
110  }
111  }
112 
117 
118  // Ajoute des cylindres sur les arretes diffractantes
120 
121  return true;
122 }
123 
125 {
126  if (r->getNbEvents() > static_cast<unsigned int>(AcousticRaytracerConfiguration::get()->MaxProfondeur))
127  {
128  return false;
129  }
130 
131  bool isValid = false;
132 
133  // cas d'un triangle (sol)
134  if ((inter->forme == TRIANGLE) &&
135  (r->getReflex() < static_cast<unsigned int>(AcousticRaytracerConfiguration::get()->MaxReflexion)) &&
137  {
139  }
140 
141  // cas du cylindre (arrete de diffraction)
142  else if (inter->forme == CYLINDRE &&
143  r->getDiff() < static_cast<unsigned int>(AcousticRaytracerConfiguration::get()->MaxDiffraction))
144  {
145  isValid = ValidRay::validCylindreWithDiffraction(r, inter);
146  }
147 
148 #ifdef _ALLOW_TARGETING_
149  if (isValid && AcousticRaytracerConfiguration::get()->EnableFullTargets)
150  {
151  ValidRay::appendDirectionToEvent(r->events.back(), targetManager);
152  }
153 #endif //_ALLOW_TARGETING_
154 
155  return (isValid); //(isValid && selectorManagerIntersection.appendData(r));
156 }
157 
159 {
161 #ifdef _DEBUG
162  if (selectorManagerValidation.getSelectedData().size() % 1000 == 0)
163  {
164  std::cout << "Nombre de rayon valides = " << selectorManagerValidation.getSelectedData().size()
165  << std::endl;
166  }
167 
168 #endif
169  return true;
170 }
171 
173 {
174  if (!AcousticRaytracerConfiguration::get()->KeepDebugRay)
175  {
176  delete r;
177  r = NULL;
178  }
179  else
180  {
181  debug_rays.push_back(r);
182  }
183 
184  return true;
185 }
186 
188 {
189  std::map<unsigned long long int, Ray*> selectedData = selectorManagerValidation.getSelectedData();
190 
191  for (std::map<unsigned long long, Ray*>::iterator it = selectedData.begin(); it != selectedData.end();
192  it++)
193  {
194  valid_rays.push_back(it->second);
195  }
196 
199 
200  return;
201 }
@ 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:187
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:172
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:124
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:158
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:81
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:47
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:31
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:42
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:37
virtual bool loadParameters()
Load the computation parameters.
Definition: Solver.cpp:76
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:69
virtual void finish()
End the operations.
Definition: Solver.cpp:64
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:53
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