Code_TYMPAN  4.4.0
Industrial site acoustic simulation
acoustic_problem_model.hpp
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 
25 #ifndef TYMPAN__ACOUSTIC_PROBLEM_MODEL_H__INCLUDED
26 #define TYMPAN__ACOUSTIC_PROBLEM_MODEL_H__INCLUDED
27 
28 #include <string>
29 #include <memory>
30 
31 #include "data_model_common.hpp"
32 #include "entities.hpp"
33 
34 namespace tympan
35 {
48 std::deque<triangle_idx> scene_volume_intersection(const triangle_pool_t& triangles,
49  const nodes_pool_t& nodes, float l, float h,
50  OPoint3D source, OPoint3D receptor); // L
55 {
56 public:
58  virtual ~AcousticProblemModel(){};
59 
65  node_idx make_node(const Point& point);
67  node_idx make_node(double x, double y, double z)
68  {
69  return make_node(Point(x, y, z));
70  }
71 
73 
74  size_t npoints() const // TODO move to implementation file
75  {
76  return all_nodes.size();
77  }
78 
79  size_t ntriangles() const // TODO move to implementation file
80  {
81  return all_triangles.size();
82  }
83 
84  size_t nsources() const // TODO move to implementation file
85  {
86  return all_sources.size();
87  }
88 
89  size_t nreceptors() const // TODO move to implementation file
90  {
91  return all_receptors.size();
92  }
93 
95  {
96  return all_triangles.at(tri_idx);
97  }
98 
99  const AcousticTriangle& triangle(triangle_idx tri_idx) const
100  {
101  return all_triangles.at(tri_idx);
102  }
103 
105  {
106  return all_nodes.at(idx);
107  }
108 
109  const Point& node(node_idx idx) const
110  {
111  return all_nodes.at(idx);
112  }
113 
115  {
116  return all_sources.at(idx);
117  }
118 
119  const AcousticSource& source(source_idx idx) const
120  {
121  return all_sources.at(idx);
122  }
123 
125  {
126  return all_receptors.at(idx);
127  }
128 
130  {
131  return all_receptors.at(idx);
132  }
133 
134  size_t nmaterials() const // TODO move to implementation file
135  {
136  return all_materials.size();
137  }
138 
139  const AcousticMaterialBase& material(size_t mat_idx) const
140  {
141  return *all_materials.at(mat_idx);
142  }
143 
145  {
146  return *all_materials.at(mat_idx);
147  }
148 
159  material_ptr_t make_material(const string& name, double resistivity, double deviation, double length,
160  double factor_g);
161 
168  material_ptr_t make_material(const string& name, const ComplexSpectrum& spectrum);
169 
177  source_idx make_source(const Point& point_, const Spectrum& spectrum_,
178  SourceDirectivityInterface* directivity);
179 
183  receptor_idx make_receptor(const Point& position_);
184 
185  const nodes_pool_t& nodes() const
186  {
187  return all_nodes;
188  }
189  const triangle_pool_t& triangles() const
190  {
191  return all_triangles;
192  }
193  const material_pool_t& materials() const
194  {
195  return all_materials;
196  }
197  const source_pool_t& sources() const
198  {
199  return all_sources;
200  }
201  const receptor_pool_t& receptors() const
202  {
203  return all_receptors;
204  }
205 
206 public: // XXX Could / should be protected but this complicates testing
207  /*
208  // Comparison utilities
209  static bool equal_to (const node_idx & lhs, const node_idx & rhs)
210  { return *lhs == *rhs; };
211  static bool equal_to (const Point& point, const node_idx & pnode)
212  { return point == *pnode; }
213  static bool equal_to (const node_idx & pnode, const Point& point)
214  { return equal_to(point, pnode); };
215 
216  static bool less_than (const node_idx & lhs, const node_idx & rhs);
217  static bool less_than (const Point& lhs, const Point& rhs);
218  */
219 
220 protected: // data members
226 }; // class AcousticProblemModel
227 
228 std::unique_ptr<AcousticProblemModel> make_AcousticProblemModel();
229 
230 } // namespace tympan
231 
232 #endif // TYMPAN__ACOUSTIC_PROBLEM_MODEL_H__INCLUDED
const char * name
The 3D point class.
Definition: 3d.h:487
Base class for material.
Definition: entities.hpp:37
Class to describe the acoustic problem.
source_pool_t all_sources
Array of all sources.
virtual ~AcousticProblemModel()
Constructor.
AcousticMaterialBase & material(size_t mat_idx)
Return a material by its id.
receptor_idx make_receptor(const Point &position_)
Push a new acoustic receptor into the model.
triangle_idx make_triangle(node_idx n1, node_idx n2, node_idx n3)
const source_pool_t & sources() const
Return array of sources.
AcousticReceptor & receptor(receptor_idx idx)
Return a receptor by its id.
node_idx make_node(const Point &point)
Destructor.
AcousticTriangle & triangle(triangle_idx tri_idx)
Return a triangle by its id.
const receptor_pool_t & receptors() const
Return array of receptors.
size_t ntriangles() const
Return the total number of triangles.
const Point & node(node_idx idx) const
Return a node by its id.
material_ptr_t make_material(const string &name, double resistivity, double deviation, double length, double factor_g)
Push a representation of a ground material into the model. If an instance of a ground material with s...
AcousticSource & source(source_idx idx)
Return a source by its id.
material_pool_t all_materials
Array of all materials.
nodes_pool_t all_nodes
Array of all nodes.
const AcousticSource & source(source_idx idx) const
Return a source by its id.
const material_pool_t & materials() const
Return array of materials.
receptor_pool_t all_receptors
Array of all receptors.
size_t npoints() const
Return the total number of nodes.
node_idx make_node(double x, double y, double z)
Call make_node(Point) with a point given by its coordinates.
const AcousticReceptor & receptor(receptor_idx idx) const
Return a receptor by its id.
size_t nsources() const
Return the total number of sources.
const AcousticTriangle & triangle(triangle_idx tri_idx) const
Return a triangle by its id.
const AcousticMaterialBase & material(size_t mat_idx) const
Return a material by its id.
size_t nreceptors() const
Return the total number of receptors.
const nodes_pool_t & nodes() const
Return array of nodes.
Point & node(node_idx idx)
Return a node by its id.
triangle_pool_t all_triangles
Array of all triangles.
source_idx make_source(const Point &point_, const Spectrum &spectrum_, SourceDirectivityInterface *directivity)
Push a new acoustic source into the model.
size_t nmaterials() const
Return the total number of materials.
const triangle_pool_t & triangles() const
Return array of triangles.
Describes an acoustic receptor.
Definition: entities.hpp:403
Describes an acoustic source.
Definition: entities.hpp:381
Describing a triangle.
Definition: entities.hpp:204
Interface for source directivity classes (SphericalSourceDirectivity, CommonFaceDirectivity,...
Definition: entities.hpp:223
Common utilities and includes for all data models.
This file provides the declaration of the entities of the model, which inherit from BaseEntity.
std::deque< AcousticSource > source_pool_t
Array of sources.
Definition: entities.hpp:395
size_t triangle_idx
Definition: entities.hpp:215
size_t source_idx
Definition: entities.hpp:396
std::deque< AcousticReceptor > receptor_pool_t
Array of receptors.
Definition: entities.hpp:412
OPoint3D Point
std::deque< triangle_idx > scene_volume_intersection(const triangle_pool_t &triangle_soup, const nodes_pool_t &nodes, float w, float h, OPoint3D source, OPoint3D receptor)
Find the intersection between some triangles (triangles, nodes) and a volume given by a width,...
std::deque< Point > nodes_pool_t
size_t receptor_idx
Definition: entities.hpp:413
std::unique_ptr< AcousticProblemModel > make_AcousticProblemModel()
std::deque< material_ptr_t > material_pool_t
Definition: entities.hpp:56
shared_ptr< AcousticMaterialBase > material_ptr_t
Definition: entities.hpp:55
std::deque< AcousticTriangle > triangle_pool_t
Array of AcousticTriangle.
Definition: entities.hpp:214
size_t node_idx