ECOGEN 6.0
Evolutive, Compressible, Open, Genuine, Easy, N-phase
Loading...
Searching...
No Matches
Mesh.h
Go to the documentation of this file.
1//
2// ,---. ,--, .---. ,--, ,---. .-. .-.
3// | .-' .' .') / .-. ) .' .' | .-' | \| |
4// | `-. | |(_) | | |(_) | | __ | `-. | | |
5// | .-' \ \ | | | | \ \ ( _) | .-' | |\ |
6// | `--. \ `-. \ `-' / \ `-) ) | `--. | | |)|
7// /( __.' \____\ )---' )\____/ /( __.' /( (_)
8// (__) (_) (__) (__) (__)
9// Official webSite: https://code-mphi.github.io/ECOGEN/
10//
11// This file is part of ECOGEN.
12//
13// ECOGEN is the legal property of its developers, whose names
14// are listed in the copyright file included with this source
15// distribution.
16//
17// ECOGEN is free software: you can redistribute it and/or modify
18// it under the terms of the GNU General Public License as published
19// by the Free Software Foundation, either version 3 of the License,
20// or (at your option) any later version.
21//
22// ECOGEN is distributed in the hope that it will be useful,
23// but WITHOUT ANY WARRANTY; without even the implied warranty of
24// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25// GNU General Public License for more details.
26//
27// You should have received a copy of the GNU General Public License
28// along with ECOGEN (file LICENSE).
29// If not, see <http://www.gnu.org/licenses/>.
30
31#ifndef MESH_H
32#define MESH_H
33
34#include <ctime>
35#include <fstream>
37#include "../Order1/Cell.h"
38#include "../Order1/CellGhost.h"
43#include "../Maths/Coord.h"
48
49#include "../InputOutput/IntTypes.h" // Use same integer types than those used to write output files
50
54class Mesh
55{
56 public:
57 Mesh();
58 virtual ~Mesh();
59
60 virtual void assignLimits(std::vector<BoundCond*>& boundCond) = 0;
62 TypeMeshContainer<Cell*>& cellsGhost,
64 const int& resumeSimulation,
65 bool pretraitementParallele = true,
66 SimulationOrder schemeOrder = SimulationOrder::first) = 0;
67 virtual std::string whoAmI() const
68 {
69 Errors::errorMessage("whoAmI not available for considered mesh");
70 return std::string("");
71 };
72 virtual void setImmersedBoundaries(TypeMeshContainer<CellInterface*>* /*cellInterfacesLvl*/, SimulationOrder /*schemeOrder*/) const {};
73
74 //Accessors
75 //---------
76 const int& getProblemDimension() const { return m_problemDimension; };
77 const int& getNumberCells() const { return m_numberCellsCalcul; };
78 const int& getNumberCellsTotal() const { return m_numberCellsTotal; };
79 const int& getNumberFaces() const { return m_numberFacesTotal; };
80 const int& getNumFichier() const { return m_numFile; };
81 const TypeM& getType() const { return m_type; };
82 virtual int getNumberCellsX() const { return 0; };
83 virtual int getNumberCellsY() const { return 0; };
84 virtual int getNumberCellsZ() const { return 0; };
85 virtual int getNumberCellsXGlobal() const { return 0; };
86 virtual int getNumberCellsYGlobal() const { return 0; };
87 virtual int getNumberCellsZGlobal() const { return 0; };
88 virtual int getOffsetX() const { return 0; };
89 virtual int getOffsetY() const { return 0; };
90 virtual int getOffsetZ() const { return 0; };
91 virtual int getNumberCpuX() const { return 0; };
92 virtual int getNumberCpuY() const { return 0; };
93 virtual int getNumberCpuZ() const { return 0; };
94
95 virtual int getLvlMax() const { return 0; };
96
97 //Printing
98 //--------
99 void writeResultsGnuplot(std::vector<Cell*>* cellsLvl, std::ofstream& fileStream, GeometricObject* objet = 0, bool recordPsat = false) const;
100 virtual void writeHeaderPiece(std::ofstream& /*fileStream*/, std::vector<Cell*>* /*cellsLvl*/) const
101 {
102 Errors::errorMessage("writeHeaderPiece not available for considered mesh");
103 };
104 virtual std::string getStringExtent(bool /*global*/ = false) const
105 {
106 Errors::errorMessage("getStringExtent not available for considered mesh");
107 return std::string("");
108 };
109
110 virtual std::array<int, 6> getArrayGlobalExtent() const
111 {
112 Errors::errorMessage("getArrayGlobalExtent not available for considered mesh");
113 return {0, 0, 0, 0, 0, 0};
114 };
115
117 virtual void getCoord(std::vector<double>& /*dataset*/, Axis /*axis*/, bool global = false) const
118 {
119 (void)global; // Parameter is intentionally unused: suppresses warning
120 Errors::errorMessage("getCoord not available for considered mesh");
121 };
122
125 virtual size_t getNodes(std::vector<double>& /*dataset*/, std::vector<Cell*>* /*cellsLvl*/) const
126 {
127 Errors::errorMessage("getNodes not available for considered mesh");
128 return 0;
129 };
130
136 virtual size_t getConnectivity(std::vector<double>& /*dataset*/, std::vector<Cell*>* /*cellsLvl*/) const
137 {
138 Errors::errorMessage("getConnectivity not available for considered mesh");
139 return 0;
140 };
141
145 virtual size_t getConnectivity(std::vector<int64_t>& /*dataset*/, std::vector<Cell*>* /*cellsLvl*/) const
146 {
147 Errors::errorMessage("getConnectivity not available for considered mesh and storage in 'int' vector");
148 return 0;
149 };
150
154 virtual size_t getConnectivity(std::vector<int32_t>& /*dataset*/, std::vector<Cell*>* /*cellsLvl*/) const
155 {
156 Errors::errorMessage("getConnectivity not available for considered mesh and storage in 'int' vector");
157 return 0;
158 };
159
164 virtual void getOffsets(std::vector<double>& /*dataset*/, std::vector<Cell*>* /*cellsLvl*/) const
165 {
166 Errors::errorMessage("getOffsets not available for considered mesh");
167 };
168
170 virtual void getOffsets(std::vector<int64_t>& /*dataset*/, std::vector<Cell*>* /*cellsLvl*/) const
171 {
172 Errors::errorMessage("getOffsets not available for considered mesh and storage in 'int64_t' vector");
173 };
174
176 virtual void getOffsets(std::vector<int32_t>& /*dataset*/, std::vector<Cell*>* /*cellsLvl*/) const
177 {
178 Errors::errorMessage("getOffsets not available for considered mesh and storage in 'int32_t' vector");
179 };
180
181 virtual void getTypeCell(std::vector<double>& /*dataset*/, std::vector<Cell*>* /*cellsLvl*/) const
182 {
183 Errors::errorMessage("getTypeCell not available for considered mesh");
184 };
185 virtual void getTypeCell(std::vector<unsigned char>& /*dataset*/, std::vector<Cell*>* /*cellsLvl*/) const
186 {
187 Errors::errorMessage("'getTypeCell' not available for considered mesh and storage in 'unsigned char' vector");
188 };
189
196 virtual void getData(std::vector<Cell*>* /*cellsLvl*/, std::vector<double>& /*dataset*/, const int /*var*/, int /*phase*/) const
197 {
198 Errors::errorMessage("getData not available for considered mesh");
199 };
200 virtual void getData(std::vector<Cell*>* /*cellsLvl*/, std::vector<float>& /*dataset*/, const int /*var*/, int /*phase*/) const
201 {
202 Errors::errorMessage("getData not available for considered mesh");
203 };
204
211 virtual void setDataSet(std::vector<double>& /*dataset*/, std::vector<Cell*>* /*cellsLvl*/, const int /*var*/, int /*phase*/) const
212 {
213 Errors::errorMessage("setDataSet not available for requested mesh");
214 };
215 virtual void refineCellAndCellInterfaces(Cell* /*cell*/, const std::vector<AddPhys*>& /*addPhys*/, int& /*nbCellsTotalAMR*/)
216 {
217 Errors::errorMessage("refineCellAndCellInterfaces not available for requested mesh");
218 };
219
223 virtual void extractAbsVelocityMRF(std::vector<Cell*>* /*cellsLvl*/, std::vector<double>& /*dataset*/, Source* /*sourceMRF*/) const
224 {
225 Errors::errorMessage("extractAbsVeloxityMRF not available for considered mesh");
226 };
227 virtual void extractAbsVelocityMRF(std::vector<Cell*>* /*cellsLvl*/, std::vector<float>& /*dataset*/, Source* /*sourceMRF*/) const
228 {
229 Errors::errorMessage("extractAbsVeloxityMRF not available for considered mesh");
230 };
231
232 virtual void extractReferenceLength(std::vector<Cell*>* /*cellsLvl*/, std::vector<double>& /*dataset*/) const
233 {
234 Errors::errorMessage("extractReferenceLength not available for considered mesh");
235 };
236 virtual void extractReferenceLength(std::vector<Cell*>* /*cellsLvl*/, std::vector<float>& /*dataset*/) const
237 {
238 Errors::errorMessage("extractReferenceLength not available for considered mesh");
239 };
240
241 virtual void printDomainDecomposition(std::ofstream& /*fileStream*/) {};
242 virtual void readDomainDecomposition(std::ifstream& /*fileStream*/) {};
243
244 //Specific to AMR method
245 //----------------------
246 virtual void procedureRaffinementInitialization(std::vector<Cell*>* /*cellsLvl*/,
247 TypeMeshContainer<Cell*>* /*cellsLvlGhost*/,
248 std::vector<CellInterface*>* /*cellInterfacesLvl*/,
249 const std::vector<AddPhys*>& /*addPhys*/,
250 int& nbCellsTotalAMR,
251 std::vector<GeometricalDomain*>& /*domains*/,
252 Eos** /*eos*/,
253 const int& /*resumeSimulation*/,
254 SimulationOrder /*schemeOrder*/,
255 std::vector<GeometricalDomain*>& /*solidDomains*/)
256 {
257 nbCellsTotalAMR = m_numberCellsCalcul;
258 };
259 virtual void procedureRaffinement(std::vector<Cell*>* /*cellsLvl*/,
260 TypeMeshContainer<Cell*>* /*cellsLvlGhost*/,
261 std::vector<CellInterface*>* /*cellInterfacesLvl*/,
262 const int& /*lvl*/,
263 const std::vector<AddPhys*>& /*addPhys*/,
264 int& /*nbCellsTotalAMR*/,
265 Eos** /*eos*/) {};
266
267 //Specific for parallel
268 //---------------------
270 virtual void finalizeParallele(const int& lvlMax);
271 virtual void parallelLoadBalancingAMR(std::vector<Cell*>* /*cellsLvl*/,
272 TypeMeshContainer<Cell*>* /*cellsLvlGhost*/,
273 std::vector<CellInterface*>* /*cellInterfacesLvl*/,
274 SimulationOrder /*schemeOrder*/,
275 const std::vector<AddPhys*>& /*addPhys*/,
276 Eos** /*eos*/,
277 int& /*nbCellsTotalAMR*/,
278 std::vector<GeometricalDomain*>& /*solidDomains*/,
279 bool /*init*/ = false) {};
280
281 //Specific for mesh mapping restart
282 //---------------------------------
283 virtual std::string getMeshExtension() const
284 {
285 Errors::errorMessage("getMeshExtension not available for requested mesh");
286 return std::string("");
287 };
288
290 virtual void initCpuMeshSequential(TypeMeshContainer<Cell*>& /*cells*/, SimulationOrder& /*schemeOrder*/)
291 {
292 Errors::errorMessage("initCpuMeshSequential not available for requested mesh");
293 }
294
296 virtual void initCpuMeshParallel(TypeMeshContainer<Cell*>& /*cells*/, SimulationOrder& /*schemeOrder*/, int /*cpu*/)
297 {
298 Errors::errorMessage("initCpuMeshParallel not available for requested mesh");
299 }
300
301 protected:
302 mutable int m_numFile;
303
304 int m_problemDimension; /*indicator 1D/2D/3D*/
305 int m_numberElements; /*Total element count (internal computing cells of dimension n + boundary elements of dimension n-1 + ghost cells of dimension n)*/
306 int m_numberFacesTotal; /*Count of faces at cells interfaces or between cells and boundaries */
307 int m_numberCellsCalcul; /*Count of computing cells (domain-internal cells) at level 0*/
308 int m_numberCellsTotal; /*Count of internal + ghosts cells (for parallel communications) at level 0*/
309
311
319 template <typename T> void getData_body(Cell* cell, std::vector<T>& dataset, const int var, const int phase, const bool isAMR) const;
320};
321#endif // MESH_H
TypeM
Enumeration for the type of mesh (REC: rectilinear, UNS: unstructured, AMR: adaptative mesh refinemen...
Definition Tools.h:65
std::vector< Type > TypeMeshContainer
Template for the type of the mesh container (std::list for now, but may change to something else if w...
Definition Tools.h:194
SimulationOrder
Enumeration for the scheme order of the simulation.
Definition Tools.h:148
@ first
Definition Tools.h:149
Axis
Enumeration for the axes (X, Y and Z for the axes in the x-, y- and z-direction).
Definition Tools.h:49
Base class for a mesh cell.
Definition Cell.h:59
General class for Equation of State (EOS).
Definition Eos.h:62
static void errorMessage(const std::string &message_)
Definition Errors.cpp:56
Abstract class for geometric object.
Definition GeometricObject.h:41
virtual void getOffsets(std::vector< int64_t > &, std::vector< Cell * > *) const
Store offsets in connectivity array of mesh cells.
Definition Mesh.h:170
void writeResultsGnuplot(std::vector< Cell * > *cellsLvl, std::ofstream &fileStream, GeometricObject *objet=0, bool recordPsat=false) const
Definition Mesh.cpp:43
virtual size_t getConnectivity(std::vector< int32_t > &, std::vector< Cell * > *) const
Store connectivities of mesh cells in a flat vector of 'ECOGEN_VTKHDF_intType' integers.
Definition Mesh.h:154
virtual void setDataSet(std::vector< double > &, std::vector< Cell * > *, const int, int) const
Extracting data for printing results.
Definition Mesh.h:211
virtual void getData(std::vector< Cell * > *, std::vector< float > &, const int, int) const
Definition Mesh.h:200
int m_numFile
Definition Mesh.h:302
virtual void parallelLoadBalancingAMR(std::vector< Cell * > *, TypeMeshContainer< Cell * > *, std::vector< CellInterface * > *, SimulationOrder, const std::vector< AddPhys * > &, Eos **, int &, std::vector< GeometricalDomain * > &, bool=false)
Definition Mesh.h:271
const TypeM & getType() const
Definition Mesh.h:81
virtual int getNumberCellsX() const
Definition Mesh.h:82
virtual int getOffsetY() const
Definition Mesh.h:89
virtual void getCoord(std::vector< double > &, Axis, bool global=false) const
For structured grid, get coordinates along a given axis.
Definition Mesh.h:117
virtual size_t getConnectivity(std::vector< double > &, std::vector< Cell * > *) const
Store connectivities of mesh cells in a flat vector of double.
Definition Mesh.h:136
TypeM m_type
Definition Mesh.h:310
Mesh()
Definition Mesh.cpp:35
virtual int getNumberCpuX() const
Definition Mesh.h:91
const int & getNumberCellsTotal() const
Definition Mesh.h:78
virtual void getOffsets(std::vector< double > &, std::vector< Cell * > *) const
Store offsets in connectivity array of mesh cells.
Definition Mesh.h:164
virtual void finalizeParallele(const int &lvlMax)
Definition Mesh.cpp:93
virtual int getNumberCpuZ() const
Definition Mesh.h:93
void getData_body(Cell *cell, std::vector< T > &dataset, const int var, const int phase, const bool isAMR) const
Access data of cell cell and append the wanted variable cell in dataset vector.
Definition Mesh.cpp:97
virtual std::string getStringExtent(bool=false) const
Definition Mesh.h:104
virtual size_t getNodes(std::vector< double > &, std::vector< Cell * > *) const
Store coordinates of mesh nodes in a flat vector.
Definition Mesh.h:125
const int & getNumberCells() const
Definition Mesh.h:77
virtual void assignLimits(std::vector< BoundCond * > &boundCond)=0
virtual int getLvlMax() const
Definition Mesh.h:95
virtual std::string getMeshExtension() const
Definition Mesh.h:283
virtual void getOffsets(std::vector< int32_t > &, std::vector< Cell * > *) const
Store offsets in connectivity array of mesh cells.
Definition Mesh.h:176
virtual void initCpuMeshSequential(TypeMeshContainer< Cell * > &, SimulationOrder &)
Initialize mesh of a single partition for restart with mesh mapping option.
Definition Mesh.h:290
virtual std::array< int, 6 > getArrayGlobalExtent() const
For structured grid, get global grid extent under the form of an array.
Definition Mesh.h:110
virtual ~Mesh()
Definition Mesh.cpp:39
virtual void getTypeCell(std::vector< unsigned char > &, std::vector< Cell * > *) const
Definition Mesh.h:185
virtual void extractReferenceLength(std::vector< Cell * > *, std::vector< double > &) const
Definition Mesh.h:232
virtual int getNumberCellsZGlobal() const
Definition Mesh.h:87
virtual int getNumberCellsY() const
Definition Mesh.h:83
virtual void printDomainDecomposition(std::ofstream &)
Definition Mesh.h:241
virtual void extractAbsVelocityMRF(std::vector< Cell * > *, std::vector< double > &, Source *) const
Extracting absolute velocity for specific Moving Reference Frame computations.
Definition Mesh.h:223
virtual void readDomainDecomposition(std::ifstream &)
Definition Mesh.h:242
const int & getProblemDimension() const
Definition Mesh.h:76
virtual int getNumberCellsYGlobal() const
Definition Mesh.h:86
virtual int getNumberCpuY() const
Definition Mesh.h:92
int m_numberCellsCalcul
Definition Mesh.h:307
virtual void extractAbsVelocityMRF(std::vector< Cell * > *, std::vector< float > &, Source *) const
Definition Mesh.h:227
virtual void procedureRaffinementInitialization(std::vector< Cell * > *, TypeMeshContainer< Cell * > *, std::vector< CellInterface * > *, const std::vector< AddPhys * > &, int &nbCellsTotalAMR, std::vector< GeometricalDomain * > &, Eos **, const int &, SimulationOrder, std::vector< GeometricalDomain * > &)
Definition Mesh.h:246
const int & getNumberFaces() const
Definition Mesh.h:79
int m_numberElements
Definition Mesh.h:305
virtual void setImmersedBoundaries(TypeMeshContainer< CellInterface * > *, SimulationOrder) const
Definition Mesh.h:72
virtual void getData(std::vector< Cell * > *, std::vector< double > &, const int, int) const
Extracting data for printing results.
Definition Mesh.h:196
virtual size_t getConnectivity(std::vector< int64_t > &, std::vector< Cell * > *) const
Store connectivities of mesh cells in a flat vector of 'ECOGEN_VTKHDF_intType' integers.
Definition Mesh.h:145
int m_problemDimension
Definition Mesh.h:304
virtual void writeHeaderPiece(std::ofstream &, std::vector< Cell * > *) const
Definition Mesh.h:100
virtual void refineCellAndCellInterfaces(Cell *, const std::vector< AddPhys * > &, int &)
Definition Mesh.h:215
virtual void extractReferenceLength(std::vector< Cell * > *, std::vector< float > &) const
Definition Mesh.h:236
virtual void procedureRaffinement(std::vector< Cell * > *, TypeMeshContainer< Cell * > *, std::vector< CellInterface * > *, const int &, const std::vector< AddPhys * > &, int &, Eos **)
Definition Mesh.h:259
virtual void getTypeCell(std::vector< double > &, std::vector< Cell * > *) const
Definition Mesh.h:181
virtual int initializeGeometrie(TypeMeshContainer< Cell * > &cells, TypeMeshContainer< Cell * > &cellsGhost, TypeMeshContainer< CellInterface * > &cellInterfaces, const int &resumeSimulation, bool pretraitementParallele=true, SimulationOrder schemeOrder=SimulationOrder::first)=0
renvoi le number de dimensions (1,2 ou 3)
virtual int getNumberCellsZ() const
Definition Mesh.h:84
int m_numberFacesTotal
Definition Mesh.h:306
virtual std::string whoAmI() const
Definition Mesh.h:67
virtual void initializePersistentCommunications(const TypeMeshContainer< Cell * > &cells, SimulationOrder schemeOrder)
Definition Mesh.cpp:54
virtual int getOffsetZ() const
Definition Mesh.h:90
const int & getNumFichier() const
Definition Mesh.h:80
virtual int getOffsetX() const
Definition Mesh.h:88
virtual int getNumberCellsXGlobal() const
Definition Mesh.h:85
virtual void initCpuMeshParallel(TypeMeshContainer< Cell * > &, SimulationOrder &, int)
Initialize mesh of a single partition of a partionned mesh for restart with mesh mapping option.
Definition Mesh.h:296
int m_numberCellsTotal
Definition Mesh.h:308
Abstract class for source terms.
Definition Source.h:43