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