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