Code_TYMPAN  4.4.0
Industrial site acoustic simulation
TYChemin.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 "TYChemin.h"
18 
19 TYChemin::TYChemin() : _typeChemin(CHEMIN_DIRECT), _longueur(0.0), _distance(0.0)
20 {
21  _attenuation = OSpectreComplex::getEmptyLinSpectre();
22  _eq_path = new acoustic_path();
23 }
24 
25 TYChemin::TYChemin(const TYChemin& other)
26 {
27  *this = other;
28 }
29 
31 {
32  if (tympan::SolverConfiguration::get()->KeepRays == false && _eq_path != nullptr)
33  {
35  }
36 }
37 
39 {
40  if (this != &other)
41  {
42  _typeChemin = other._typeChemin;
43  _distance = other._distance;
44  _longueur = other._longueur;
45  _eq_path = other._eq_path;
46  _attenuation = other._attenuation;
47  }
48 
49  return *this;
50 }
51 
52 bool TYChemin::operator==(const TYChemin& other) const
53 {
54  if (this != &other)
55  {
56  if (_typeChemin != other._typeChemin)
57  {
58  return false;
59  }
60  if (_distance != other._distance)
61  {
62  return false;
63  }
64  if (_longueur != other._longueur)
65  {
66  return false;
67  }
68  if (_eq_path != other._eq_path)
69  {
70  return false;
71  };
72  if (_attenuation != other._attenuation)
73  {
74  return false;
75  }
76  }
77 
78  return true;
79 }
80 
81 bool TYChemin::operator!=(const TYChemin& other) const
82 {
83  return !operator==(other);
84 }
85 
86 void TYChemin::calcAttenuation(const TYTabEtape& tabEtapes, const AtmosphericConditions& atmos)
87 {
88  unsigned int i = 0;
89 
90  OSpectre phase = OSpectre::getEmptyLinSpectre(); // Reference de phase
91 
92  switch (_typeChemin)
93  {
94  case CHEMIN_DIRECT: // S*A*e^(i.k.Rd) avec A =attenuation atmosphere et S=directivite de la source
95  _attenuation = tabEtapes[0]._Absorption; // directivite de la source (S)
96  // _attenuation = _attenuation.mult(atmos.getAtt(_longueur)); // S*A (A = attenuation
97  // atmospherique)
99  atmos.compute_length_absorption(_longueur)); // S*A (A = attenuation atmospherique)
100 
101  // phase = atmos.getKAcoust().mult(_longueur); // = kRd
102  phase = atmos.get_k().mult(_longueur); // = kRd
103  _attenuation.setPhase(phase); // =e^(i.kRd) //*/
104 
105  break;
106 
107  case CHEMIN_SOL: // S*A*Q*e^(i.k.Rr)/Rr //avec Q absorption du sol
108  _attenuation = tabEtapes[0]._Absorption; // directivite de la source (S)
110  atmos.compute_length_absorption(_longueur)); // S*A (A = attenuation atmospherique)
111 
112  _attenuation = _attenuation.mult(tabEtapes[1]._Absorption); // S*A*Q
113  _attenuation = _attenuation.mult(_distance / _longueur); // S*A*Q*Rd / Rr
114 
115  phase = atmos.get_k().mult(_longueur); // = kRr
116  phase = phase.sum(
117  tabEtapes[1]
118  ._Absorption.getPhase()); // kRr + epsilon (epsilon = phase du coeff de reflexion du sol
119 
120  _attenuation.setPhase(phase);
121 
122  break;
123 
124  case CHEMIN_ECRAN: //= S*A*Q/D*e^(i.k.Rd + eps) avec Q=module du coefficient de reflexion du sol et
125  // D=attenuation diffraction
126  _attenuation = tabEtapes[0]._Absorption; // S = Directivite de la source
128  atmos.compute_length_absorption(_longueur)); // S*A (A = attenuation atmospherique)
129 
130  phase = atmos.get_k().mult(_longueur); // = kRr
131 
132  // On fait le produit des absorptions des etapes a partir de la seconde jusqu'a l'avant derniere
133  // la derniere portant l'effet de diffraction
134  for (i = 1; i < tabEtapes.size() - 1; i++)
135  {
136  _attenuation = _attenuation.mult(tabEtapes[i]._Absorption); // S.A.Q
137  phase = phase.sum(tabEtapes[i]._Absorption.getPhase()); // kRr + Somme des epsilon i
138  }
139 
140  _attenuation = _attenuation.div(tabEtapes[tabEtapes.size() - 1]._Attenuation); // S.A.Q/D
141 
142  _attenuation.setPhase(phase);
143  break;
144 
145  case CHEMIN_REFLEX: // S*A*Q*e^(i.k.Rr + eps)/Rr avec Q coefficient de reflexion de la paroi, eps = 0
146  _attenuation = tabEtapes[0]._Absorption; // S = Directivite de la source
148  atmos.compute_length_absorption(_longueur)); // S*A (A = attenuation atmospherique)
149 
150  phase = atmos.get_k().mult(_longueur); // = kRr
151 
152  // On fait le produit des absorptions des etapes ) partir de la deuxieme
153  for (i = 1; i < tabEtapes.size(); i++)
154  {
155  _attenuation = _attenuation.mult(tabEtapes[i]._Absorption); // Produit des modules
156  phase = phase.sum(tabEtapes[i]._Absorption.getPhase()); // Somme des phases
157  }
158 
160  _distance /
161  _longueur); // <== MODIFIE ON DIVISE PAR Rd² au niveau du solveur (a cause des ecrans)
162 
163  _attenuation.setPhase(phase);
164 
165  break;
166 
167  default:
168  break;
169  }
170 
171  build_eq_path(tabEtapes);
172 }
173 
174 void TYChemin::build_eq_path(const TYTabEtape& tabEtapes)
175 {
176 
177  for (size_t i = 0; i < tabEtapes.size(); i++)
178  {
179  _eq_path->addEvent(tabEtapes[i].asEvent());
180  }
181 }
182 
184 {
185  acoustic_event* receptor_event = new acoustic_event();
186  receptor_event->pos = ptR;
187  receptor_event->type = TYRECEPTEUR;
188  _eq_path->addEvent(receptor_event);
189  return _eq_path;
190 }
std::deque< TYEtape > TYTabEtape
TYEtape collection.
Definition: TYEtape.h:193
Representation of one of the most optimal path between source and receptor: S—>R.
@ CHEMIN_DIRECT
Definition: TYChemin.h:33
@ TYRECEPTEUR
Definition: acoustic_path.h:29
Class for the definition of atmospheric conditions.
OSpectre compute_length_absorption(double length) const
const OSpectre & get_k() const
Get the wave number spectrum.
The 3D point class.
Definition: 3d.h:487
OSpectreAbstract & sum(const OSpectreAbstract &spectre) const
Arithmetic sum of two spectrums in one-third Octave.
Definition: spectre.cpp:219
OSpectreAbstract & div(const OSpectreAbstract &spectre) const
Division of two spectrums.
Definition: spectre.cpp:273
OSpectreAbstract & mult(const OSpectreAbstract &spectre) const
Multiplication of two spectrums.
Definition: spectre.cpp:243
static OSpectre getEmptyLinSpectre(const double &valInit=1.0E-20)
Create a physical quantity spectrum.
Definition: spectre.cpp:1115
Representation of one of the most optimal path between source and receptor: S—>R. The class TYChemin ...
Definition: TYChemin.h:71
double _distance
Direct distance between source and receptor.
Definition: TYChemin.h:236
void calcAttenuation(const TYTabEtape &tabEtapes, const AtmosphericConditions &atmos, double dp=0.0, double hs=0.0, double hr=0.0, double Gs=0.5, double Gm=0.5, double Gr=0.5)
Definition: TYChemin.cpp:87
TYChemin()
Constructor.
Definition: TYChemin.cpp:19
bool operator==(const TYChemin &other) const
Operator ==.
Definition: TYChemin.cpp:53
virtual ~TYChemin()
Destructor.
Definition: TYChemin.cpp:30
TYTypeChemin _typeChemin
Path type (has an influence on the algorithm)
Definition: TYChemin.h:230
acoustic_path * _eq_path
Equivalent acoustic_path.
Definition: TYChemin.h:246
bool operator!=(const TYChemin &other) const
Operator !=.
Definition: TYChemin.cpp:82
OSpectreOctave _attenuation
Definition: TYChemin.h:243
TYChemin & operator=(const TYChemin &other)
Operator =.
Definition: TYChemin.cpp:39
void build_eq_path(const TYTabEtape &tabEtapes)
Definition: TYChemin.cpp:187
acoustic_path * get_ray(OPoint3D ptR)
Definition: TYChemin.cpp:196
double _longueur
Total path length.
Definition: TYChemin.h:233
This class store data and provide functions to manipulate event in the acoustic context.
Definition: acoustic_path.h:40
ACOUSTIC_EVENT_TYPES type
Event type.
Definition: acoustic_path.h:60
OPoint3D pos
Event position.
Definition: acoustic_path.h:53
Acoustic path.
Definition: acoustic_path.h:78
virtual void cleanEventsTab()
clean tab of events
virtual void addEvent(acoustic_event *TYEvent)
Add an event to the events list of the ray.
static LPSolverConfiguration get()
Get the configuration.
Definition: config.cpp:93
This file provides class for solver configuration.