TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Domaine_VF.h
1/****************************************************************************
2* Copyright (c) 2026, CEA
3* All rights reserved.
4*
5* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
6* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
7* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
8* 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
9*
10* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
11* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
12* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
13*
14*****************************************************************************/
15
16#ifndef Domaine_VF_included
17#define Domaine_VF_included
18
19#include <Domaine_dis_base.h>
20#include <Domaine_forward.h>
21#include <TRUSTArrays.h>
22#include <Front_VF.h>
23
24#include <medcoupling++.h>
25
26#ifdef MEDCOUPLING_
27#include <MEDCouplingFieldTemplate.hxx>
28#include <MEDCouplingCMesh.hxx>
29using MEDCoupling::MEDCouplingCMesh;
30using MEDCoupling::MCAuto;
31using MEDCoupling::MEDCouplingFieldDouble;
32#endif
33
35
36/*! @brief class Domaine_VF
37 *
38 * This abstract class contains the geometric information
39 * common to Finite Volume methods (VDF and VEF methods for example)
40 *
41 * @sa Domaine_dis_base
42 */
44{
45 Declare_base(Domaine_VF);
46public :
47 virtual double face_normales(int face, int comp) const { return face_normales_(face,comp); }
48 virtual DoubleTab& face_normales() { return face_normales_; }
49 virtual const DoubleTab& face_normales() const { return face_normales_; }
50 void calculer_face_surfaces(const DoubleVect& surfaces) { face_surfaces_ = surfaces; }
51 virtual const DoubleVect& face_surfaces() const { return face_surfaces_; }
52 virtual inline double face_surfaces(int i) const { return face_surfaces_(i); }
53 virtual inline double surface(int i) const { return face_surfaces(i); }
54
55 void discretiser() override;
56 void discretiser_no_face() override;
57 void typer_discretiser_ss_domaine(int i) override;
58 void infobord();
59 void info_elem_som();
61 virtual void typer_elem(Domaine&) {}
62
64 virtual Faces* creer_faces();
65 inline int nb_joints() const { return domaine().nb_joints(); }
66 inline int premiere_face_int() const;
67 inline int nb_faces() const;
68 inline int nb_faces_tot() const;
69 inline int nb_som_face() const;
70 inline int nb_arete_face() const;
71 inline int nb_faces_bord() const;
72 inline int nb_faces_bord_tot() const;
73 inline int premiere_face_bord() const;
74 inline int nb_faces_internes() const;
75
76 inline double xv(int num_face,int k) const { return xv_(num_face,k); }
77 inline double xp(int num_elem,int k) const { return xp_(num_elem,k); }
78 inline double xa(int num_arete,int k) const { return xa_(num_arete,k); }
79
80 inline int face_numero_bord(int num_face) const;
81 inline IntTab& face_numero_bord() { return face_numero_bord_; }
82 inline const IntTab& face_numero_bord() const { return face_numero_bord_; }
84
85 inline ArrOfInt& est_face_bord() { return est_face_bord_; }
86 inline const ArrOfInt& est_face_bord() const { return est_face_bord_; }
87
88 inline virtual const IntVect& orientation() const;
89 inline virtual int orientation(int ) const;
90 inline virtual int orientation_si_definie(int) const;
91
92 DoubleTab normalized_boundaries_outward_vector(int global_face_number, double scale_factor) const;
93 inline DoubleTab& xv() { return xv_;}
94 inline const DoubleTab& xv() const { return xv_;}
95 inline DoubleTab& xp() { return xp_; }
96 inline const DoubleTab& xp() const { return xp_; }
97 inline DoubleTab& xa() { return xa_; }
98 inline const DoubleTab& xa() const { return xa_; }
99 inline DoubleVect& volumes_entrelaces() { return volumes_entrelaces_; }
100 inline const DoubleVect& volumes_entrelaces() const { return volumes_entrelaces_; }
101 inline double volumes_entrelaces(int num_face) const { return volumes_entrelaces_[num_face]; }
102 inline const DoubleTab& volumes_entrelaces_dir() const { return volumes_entrelaces_dir_; }
103 inline DoubleTab& volumes_entrelaces_dir() { return volumes_entrelaces_dir_; } // returns the array of interlaced volumes per side.
104
105 inline const Joint& joint(int i) const { return domaine().joint(i); }
106 inline Joint& joint(int i) { return domaine().joint(i); }
107
108 inline Frontiere_dis_base& frontiere_dis(int ) override;
109 inline const Frontiere_dis_base& frontiere_dis(int ) const override;
110
111 inline int nb_frontiere_dis() const { return les_bords_.size(); }
112 inline const Front_VF& front_VF(int i) const { return les_bords_[i]; } // returns the i-th discrete boundary.
113 inline double volumes(int i) const { return volumes_[i]; }
114 inline double inverse_volumes(int i) const { return inverse_volumes_[i]; }
115 inline int face_voisins(int num_face,int i) const;
116 inline int elem_faces(int i,int j) const;
117 inline int face_sommets(int i,int j) const;
118
119 inline DoubleVect& volumes() { return volumes_; }
120 inline DoubleVect& inverse_volumes() { return inverse_volumes_; } // Array to optimize the code
121 inline const DoubleVect& volumes() const { return volumes_; }
122 inline const DoubleVect& inverse_volumes() const { return inverse_volumes_; } // Array to optimize the code
123 inline IntTab& face_voisins() override;
124 inline const IntTab& face_voisins() const override;
125 inline const IntTab& face_voisins_fictifs() const { return face_voisins_fictifs_; }
126 inline void face_voisins_reel_fictif(int face,int& el0,int& elf) const;
127 inline IntTab& elem_faces();
128 inline const IntTab& elem_faces() const;
129 inline ArrOfInt& faces_doubles();
130 inline const ArrOfInt& faces_doubles() const;
131 inline IntTab& face_sommets() override;
132 inline const IntTab& face_sommets() const override;
133 inline IntTab& face_aretes() override;
134 inline const IntTab& face_aretes() const override;
135 void modifier_pour_Cl(const Conds_lim&) override;
136
137 int numero_face_local(int face, int elem) const;
138 inline int numero_sommet_local(int som, int elem) const;
139
140 inline const IntTab& get_num_fac_loc() const { return num_fac_loc_; }
141 inline int get_num_fac_loc(int, int) const;
143
144 inline const ArrOfInt& ind_faces_virt_bord() const { return domaine().ind_faces_virt_bord(); }
145 inline int est_une_face_virt_bord(int) const;
146 inline int fbord(int f) const //returns the boundary face index of f if f is a boundary face, -1 otherwise
147 {
148 return f < premiere_face_int() ? f : f < nb_faces() ? -1 : ind_faces_virt_bord()[f - nb_faces()];
149 }
150
152 const IntTab& face_virt_pe_num() const;
153
154 void creer_tableau_faces(Array_base&, RESIZE_OPTIONS opt = RESIZE_OPTIONS::COPY_INIT) const;
155 void creer_tableau_aretes(Array_base&, RESIZE_OPTIONS opt = RESIZE_OPTIONS::COPY_INIT) const;
156 void creer_tableau_faces_bord(Array_base&, RESIZE_OPTIONS opt = RESIZE_OPTIONS::COPY_INIT) const;
158 const MD_Vector& md_vector_faces() const { return md_vector_faces_; }
159 // Warning: if edges are not filled, md_vector_ is null
161
162 virtual const DoubleTab& xv_bord() const;
163 DoubleTab calculer_xgr() const;
164
165 virtual void get_position(DoubleTab& positions) const;
166 virtual double compute_L1_norm(const DoubleVect& val_source, const bool basis_function, const int order) const;
167 virtual double compute_L2_norm(const DoubleVect& val_source, const bool basis_function, const int order) const;
168 virtual void compute_average(const DoubleVect& val_source, double& sum, double& volume, const bool basis_function, const int order) const;
169 virtual void compute_average_porosity(const DoubleVect& val_source, const DoubleVect& porosity, double& sum, double& volume, const bool basis_function, const int order) const;
170 virtual void get_nb_integ_points(IntTab& nelem) const;
171 virtual void get_ind_integ_points(IntTab& nelem) const;
172 virtual int get_max_nb_integ_points() const;
173
174 //dot product (a - ma).(b - mb)
175 inline double dot (const double *a, const double *b, const double *ma = nullptr, const double *mb = nullptr) const;
176
177 //cross product
178 inline std::array<double, 3> cross(int dima, int dimb, const double *a, const double *b, const double *ma = nullptr, const double *mb = nullptr) const;
179
180 inline virtual double dist_norm(int ) const { Cerr << __func__ << " method should be overrided in a derived class !! " << finl; throw; }
181 inline virtual double dist_norm_bord(int ) const { Cerr << __func__ << " method should be overrided in a derived class !! " << finl; throw; }
182 inline virtual double dist_face_elem0(int ,int ) const { Cerr << __func__ << " method should be overrided in a derived class !! " << finl; throw; }
183 inline virtual double dist_face_elem1(int ,int ) const { Cerr << __func__ << " method should be overrided in a derived class !! " << finl; throw; }
184 inline virtual double dist_face_elem0_period(int ,int ,double ) const { Cerr << __func__ << " method should be overrided in a derived class !! " << finl; throw; }
185 inline virtual double dist_face_elem1_period(int ,int ,double ) const { Cerr << __func__ << " method should be overrided in a derived class !! " << finl; throw; }
186
187// Methods for computing and calling the distance to the nearest solid boundary; the input is the array of momentum equation BCs
188 void init_dist_paroi_globale(const Conds_lim& conds_lim) override;
189 const DoubleTab& normale_paroi_elem() const {return n_y_elem_;}
190 const DoubleTab& normale_paroi_faces() const {return n_y_faces_;}
191
192 void build_mc_face_mesh() const;
193 void build_mc_dual_mesh() const;
194 inline int oriente_normale(int f, int e) const { return (face_voisins(f, 0) == e) ? 1 : -1; }
195 inline const IntTab& get_face_voisins_dual() const { return face_dual_; }
196 inline int get_face_voisins_dual(const int i, const int j) const { return face_dual_(i,j); }
197
198#ifdef MEDCOUPLING_
199 inline const MEDCouplingUMesh* get_mc_face_mesh() const;
200 inline const MEDCouplingUMesh* get_mc_dual_mesh() const;
201#endif
202
203private:
204 DoubleVect face_surfaces_; // face surfaces
205
206protected:
207
208 DoubleVect volumes_; // element volumes
209 DoubleVect inverse_volumes_; // inverse of element volumes
210 DoubleVect volumes_entrelaces_; // interlaced volumes for momentum integration
211 DoubleTab volumes_entrelaces_dir_; // interlaced volumes per side
212 DoubleTab face_normales_; // face normals
213
214 inline double volume_entrelace_axi(double r_face, double r_elem, double axis_length) const;
215
216 IntTab face_voisins_; // face/element connectivity
217 IntTab face_voisins_fictifs_; // face/fictitious element connectivity
218 DoubleTab xp_; // element centres of gravity
219 DoubleTab xv_; // face centres of gravity
220 mutable DoubleTab xv_bord_; //xv_, but boundary faces only (created on demand)
221
222 IntTab elem_faces_; // element/face connectivity
223 IntTab face_sommets_; // face vertices
224 IntTab face_aretes_; // face edges
225 DoubleTab xa_; // edge centres of gravity
226 IntTab face_numero_bord_; // face/boundary_number connectivity
227
228 // Parallel descriptor for face arrays (size() == nb_faces())
230 // Same for boundary faces (size() == nb_faces_front())
232 // The one for edges
234
235 VECT(Front_VF) les_bords_;
236
237 IntTab num_fac_loc_; // returns for a face its local number within the element
238 //ArrOfInt faces_perio_; // periodic faces (useful when looping from 0 to nb_faces_tot)
239 ArrOfInt faces_doubles_; // faces with double contribution (periodic faces and shared items). Useful when looping from 0 to nb_faces for a subsequent reduction
240 ArrOfInt est_face_bord_; // returns for a real or virtual face: 0 if internal, 1 if non-periodic boundary face, 2 if periodic boundary face
241
242 // For each virtual face i with nb_faces_<=i<nb_faces_tot:
243 // face_virt_pe_num_(i-nb_faces_,0) = number of the PE that owns the face
244 // face_virt_pe_num_(i-nb_faces_,1) = local number of this face on the PE that owns it
246
247 DoubleTab n_y_elem_ ; // normal vector between the nearest boundary and the element
248 DoubleTab n_y_faces_; // normal vector between the nearest boundary and the face
249
250 int nb_elem_std_=-10; // number of standard elements
251 int nb_faces_std_=-10; // number of standard faces
252 IntVect rang_elem_non_std_; // rang_elem_non_std_= -1 if the element is standard
253 // rang_elem_non_std_= rank of the element in the arrays
254 // relating to non-standard elements
255
256 //
257 // Dual mesh management:
258 //
259#ifdef MEDCOUPLING_
260 ///! MEDCoupling version of the face domain - stored in Domaine_dis since faces are built here:
261 mutable MCAuto<MEDCouplingUMesh> mc_face_mesh_;
262 mutable MCAuto<MEDCouplingUMesh> mc_dual_mesh_;
263 mutable bool mc_face_mesh_ready_ = false;
264 mutable bool mc_dual_mesh_ready_ = false;
265#endif
266
267 mutable IntTab face_dual_; ///< For each face f, face_dual_(f, j) returns the element built on the left and right of the face in the dual mesh. Same sorting as face_voisins_
268
269 void order_faces(Faces& les_faces);
270 virtual void prepare_elem_non_std(Faces& les_faces);
271 virtual void compute_sort_key(Faces& les_faces, IntTab& sort_key);
272 void sort_along_zcurve(const Faces& les_faces, IntTab& sort_key) const;
273 virtual void renumber_faces(Faces& les_faces, IntTab& sort_key);
274
275 /*
276 * XXX Elie Saikali
277 *
278 * If requested, build a structured mesh of type MEDCouplingCMesh and the associated elem/face/node maps (CART -> TRUST) !
279 *
280 */
281public:
282 void build_map_mc_Cmesh(const bool with_faces) override;
283
284
285#ifdef MEDCOUPLING_
286private:
287 MCAuto<MEDCouplingCMesh> mc_Cmesh_;
288 std::vector<int> mc_Cmesh_elemCorrespondence_, mc_Cmesh_nodesCorrespondence_;
289 std::vector<int> mc_Cmesh_facesXCorrespondence_, mc_Cmesh_facesYCorrespondence_, mc_Cmesh_facesZCorrespondence_;
290 std::vector<double> mc_Cmesh_x_coords_, mc_Cmesh_y_coords_, mc_Cmesh_z_coords_;
291
292 bool mc_Cmesh_ready_ = false, mc_Cmesh_with_faces_corr_ = false;
293
294 void build_mc_Cmesh();
295 void build_mc_Cmesh_nodesCorrespondence();
296 void build_mc_Cmesh_correspondence(bool withFace);
297
298 template <typename TYPE>
299 TYPE Cmesh_error(const char * nom_funct) const
300 {
301 cerr << "Domaine_VF::" << nom_funct << " should not be called since the MEDCouplingCMesh of Domaine_VF is not yet filled !!!" << endl;
302 Cerr << "Add the interpret Build_Map_to_Structured in your data file !!!" << finl;
303 throw;
304 }
305
306public:
307
308 inline const MEDCouplingCMesh* get_mc_CMesh() const
309 {
310 if (mc_Cmesh_ready_) return mc_Cmesh_;
311 else return Cmesh_error<MEDCouplingCMesh*>(__func__);
312 }
313
314 const std::vector<int>& get_mc_Cmesh_elemCorrespondence() const
315 {
316 if (mc_Cmesh_ready_) return mc_Cmesh_elemCorrespondence_;
317 else return Cmesh_error<std::vector<int>&>(__func__);
318 }
319
320 const std::vector<int>& get_mc_Cmesh_facesXCorrespondence() const
321 {
322 if (mc_Cmesh_ready_ && mc_Cmesh_with_faces_corr_) return mc_Cmesh_facesXCorrespondence_;
323 else return Cmesh_error<std::vector<int>&>(__func__);
324 }
325
326 const std::vector<int>& get_mc_Cmesh_facesYCorrespondence() const
327 {
328 if (mc_Cmesh_ready_ && mc_Cmesh_with_faces_corr_) return mc_Cmesh_facesYCorrespondence_;
329 else return Cmesh_error<std::vector<int>&>(__func__);
330 }
331
332 const std::vector<int>& get_mc_Cmesh_facesZCorrespondence() const
333 {
334 if (mc_Cmesh_ready_ && mc_Cmesh_with_faces_corr_) return mc_Cmesh_facesZCorrespondence_;
335 else return Cmesh_error<std::vector<int>&>(__func__);
336 }
337
338 const std::vector<int>& get_mc_Cmesh_nodesCorrespondence() const
339 {
340 if (mc_Cmesh_ready_) return mc_Cmesh_nodesCorrespondence_;
341 else return Cmesh_error<std::vector<int>&>(__func__);
342 }
343
344 const std::vector<double>& get_mc_Cmesh_x_coords() const
345 {
346 if (mc_Cmesh_ready_) return mc_Cmesh_x_coords_;
347 else return Cmesh_error<std::vector<double>&>(__func__);
348 }
349
350 const std::vector<double>& get_mc_Cmesh_y_coords() const
351 {
352 if (mc_Cmesh_ready_) return mc_Cmesh_y_coords_;
353 else return Cmesh_error<std::vector<double>&>(__func__);
354 }
355
356 const std::vector<double>& get_mc_Cmesh_z_coords() const
357 {
358 if (mc_Cmesh_ready_) return mc_Cmesh_z_coords_;
359 else return Cmesh_error<std::vector<double>&>(__func__);
360 }
361
362 // Note: n_som i, not elem!
363 int get_mc_Cmesh_ni() const
364 {
365 if (mc_Cmesh_ready_) return static_cast<int>(mc_Cmesh_x_coords_.size());
366 else return Cmesh_error<int>(__func__);
367 }
368
369 // Note: n_som j, not elem!
370 int get_mc_Cmesh_nj() const
371 {
372 if (mc_Cmesh_ready_) return static_cast<int>(mc_Cmesh_y_coords_.size());
373 else return Cmesh_error<int>(__func__);
374 }
375
376 // Note: n_som k, not elem!
377 int get_mc_Cmesh_nk() const
378 {
379 if (mc_Cmesh_ready_) return static_cast<int>(mc_Cmesh_z_coords_.size());
380 else return Cmesh_error<int>(__func__);
381 }
382
383#endif
384
385};
386
387// Returns the local face number from a global face number and a local element index (0 or 1)
388// Much faster method than Domaine_VF::numero_face_local(face,elem)
389inline int Domaine_VF::get_num_fac_loc(int face,int voisin) const
390{
391 assert(voisin==0 || voisin==1);
392 return num_fac_loc_(face,voisin);
393}
394
395inline int Domaine_VF::numero_sommet_local(int som, int elem) const
396{
397 int nse=domaine().nb_som_elem();
398 const IntTab& les_elems=domaine().les_elems();
399 for(int som_loc=0; som_loc<nse; som_loc++)
400 {
401 if(les_elems(elem, som_loc)==som)
402 return som_loc;
403 }
404 return -1;
405}
406
407/*! @brief Returns the neighbouring element of num_face in direction i.
408 *
409 * i=0 : in the direction opposite to the axis orthogonal to face num_face.
410 * i=1 : in the direction of the axis orthogonal to face num_face.
411 * example:
412 *
413 * | 0 | 1 |
414 * numface
415 * Returns -1 if the element does not exist (at the boundary).
416 *
417 */
418inline int Domaine_VF::face_voisins(int num_face,int i) const
419{
420 return face_voisins_(num_face,i);
421}
422
423/*! @brief Returns the face-element connectivity array; see above.
424 *
425 */
427{
428 return face_voisins_;
429}
430
431/*! @brief See above.
432 *
433 */
434inline const IntTab& Domaine_VF::face_voisins() const
435{
436 return face_voisins_;
437}
438
439/*! @brief Returns in el0 the index of the interior element; returns in elf the index of the fictitious element (-1 if it does not exist).
440 *
441 *
442 *
443 */
444inline void Domaine_VF::face_voisins_reel_fictif(int face,int& el0,int& elf) const
445{
446 assert(face<premiere_face_int());
447 el0 = face_voisins(face,0);
448 elf = face_voisins(face,1);
449 if (el0==-1)
450 {
451 el0=elf;
452 elf=face_voisins_fictifs_(face,0);
453 }
454 if (elf==-1) elf=face_voisins_fictifs_(face,1);
455
456}
457
458/*! @brief A face is internal if and only if it separates two elements.
459 *
460 * Returns the index of the first internal face.
461 *
462 */
464{
465 return nb_faces_bord();
466}
467
468/*! @brief Returns the total number of faces.
469 *
470 */
471inline int Domaine_VF::nb_faces() const
472{
473 return face_sommets_.dimension(0);
474}
475
476/*! @brief Returns the total number of faces.
477 *
478 * That is, real faces + virtual faces.
479 *
480 */
481inline int Domaine_VF::nb_faces_tot() const
482{
483 return face_sommets_.dimension_tot(0);
484}
485
486
487/*! @brief Returns the number of vertices per face.
488 *
489 * Note: it is assumed that all faces have the same number of vertices,
490 * which excludes elements such as prisms.
491 *
492 */
493inline int Domaine_VF::nb_som_face() const
494{
495 return face_sommets_.dimension(1);
496}
497
498/*! @brief Returns the number of edges per face.
499 *
500 *
501 */
503{
504 return face_aretes_.dimension(1);
505}
506
507/*! @brief Returns the number of faces on which boundary conditions are applied:
508 *
509 * boundaries, connectors, plates.
510 *
511 */
513{
514 return domaine().nb_faces_frontiere();
515}
516
517/*! @brief Returns the index of the first face on which boundary conditions are applied:
518 *
519 * boundaries, connectors, plates.
520 *
521 */
523{
524 return 0;
525}
526
527/*! @brief A face is internal if and only if it separates two elements.
528 *
529 * Returns the number of internal faces.
530 *
531 */
533{
534 return nb_faces()- nb_faces_bord();
535}
536
537/*! @brief Returns the index of the i-th face of element num_elem; the face numbering convention is
538 *
539 * left to the responsibility of derived classes.
540 *
541 */
542inline int Domaine_VF::elem_faces(int num_elem, int i) const
543{
544 return elem_faces_(num_elem, i);
545}
546
547/*! @brief Returns the element/face connectivity array.
548 *
549 */
551{
552 return elem_faces_;
553}
554
555/*! @brief See above.
556 *
557 */
558inline const IntTab& Domaine_VF::elem_faces() const
559{
560 return elem_faces_;
561}
562
563/*! @brief Returns 1 for faces belonging to a periodic boundary or a shared item, 0 by default.
564 *
565 */
567{
568 return faces_doubles_;
569}
570
571/*! @brief See above.
572 *
573 */
574inline const ArrOfInt& Domaine_VF::faces_doubles() const
575{
576 return faces_doubles_;
577}
578
579/*! @brief Returns the index of the i-th vertex of face num_face.
580 *
581 */
582inline int Domaine_VF::face_sommets(int num_face, int i) const
583{
584 return face_sommets_(num_face, i);
585}
586
587/*! @brief Returns the face/vertex connectivity array.
588 *
589 */
591{
592 return face_sommets_;
593}
594
595/*! @brief See above.
596 *
597 */
598inline const IntTab& Domaine_VF::face_sommets() const
599{
600 return face_sommets_;
601}
602
603/*! @brief Returns the face/edge connectivity array.
604 *
605 */
607{
608 return face_aretes_;
609}
610
611/*! @brief See above.
612 *
613 */
614inline const IntTab& Domaine_VF::face_aretes() const
615{
616 return face_aretes_;
617}
618
619/*! @brief Returns the i-th discrete boundary.
620 *
621 */
623{
624 return les_bords_[i];
625}
626
627/*! @brief Returns the i-th discrete boundary.
628 *
629 */
631{
632 return les_bords_[i];
633}
634
635/*! @brief Returns the total number of faces (real + virtual) on which boundary conditions are applied:
636 *
637 * boundaries, connectors, plates.
638 *
639 */
641{
643}
644
645inline const IntVect& Domaine_VF::orientation() const
646{
647 Cerr<<"Try using orientation(num_face) instead of orientation() if the mesh is axis oriented."<< finl;
648 exit();
649 throw;
650 //return orientation();
651}
652
653inline int Domaine_VF::orientation_si_definie(int num_face) const
654{
655 for (int dir=0; dir<dimension; dir++)
656 {
657 if (est_egal(std::fabs(face_normales(num_face, dir)), face_surfaces(num_face)))
658 return dir;
659 }
660 return -1;
661}
662
663inline int Domaine_VF::orientation(int num_face) const
664{
665 for (int dir=0; dir<dimension; dir++)
666 {
667 if (est_egal(std::fabs(face_normales(num_face, dir)), face_surfaces(num_face)))
668 return dir;
669 }
670 Cerr<<"Your mesh is not axis oriented."<<finl;
671 Cerr<<"Try recoding using face_normales(). Example for g(face)=gravite[orientation[face]];" << finl;
672 Cerr<<"Compute something like: g(face)=Sum(i=0;i<gravite.size();i++) of gravite[i]*face_normales(face,i)/surface(face);" << finl;
673 exit();
674 return -1;
675}
676
677/*! @brief Returns 1 if face is a virtual boundary face, 0 otherwise.
678 *
679 */
680inline int Domaine_VF::est_une_face_virt_bord(int face) const
681{
682 if (face<nb_faces() || ind_faces_virt_bord()[face-nb_faces()]==-1)
683 return 0;
684 else
685 return 1;
686}
687
688inline int Domaine_VF::face_numero_bord(int num_face) const
689{
690 assert(num_face < nb_faces());
691 return face_numero_bord_(num_face);
692}
693
694/* dot product of two vectors */
695inline double Domaine_VF::dot(const double *a, const double *b, const double *ma, const double *mb) const
696{
697 double res = 0;
698 for (int i = 0; i < dimension; i++) res += (a[i] - (ma ? ma[i] : 0)) * (b[i] - (mb ? mb[i] : 0));
699 return res;
700}
701
702inline double Domaine_VF::volume_entrelace_axi(double r_face, double r_elem, double axis_length) const
703{
704 const double dr = std::fabs(r_elem - r_face);
705 const double r = (r_elem < r_face) ? r_elem : r_face;
706 return 2. * M_PI * (r * dr + 0.5 * dr * dr) * axis_length;
707}
708
709/* cross product of two vectors (always 3D, even in 2D) */
710inline std::array<double, 3> Domaine_VF::cross(int dima, int dimb, const double *a, const double *b, const double *ma, const double *mb) const
711{
712 std::array<double, 3> va = {{ 0, 0, 0 }}, vb = {{ 0, 0, 0 }}, res;
713 for (int i = 0; i < dima; i++) va[i] = a[i] - (ma ? ma[i] : 0);
714 for (int i = 0; i < dimb; i++) vb[i] = b[i] - (mb ? mb[i] : 0);
715 for (int i = 0; i < 3; i++) res[i] = va[(i + 1) % 3] * vb[(i + 2) % 3] - va[(i + 2) % 3] * vb[(i + 1) % 3];
716 // note : in 2D, the relevant results corresponding to the determinant is res[2]
717 return res;
718}
719
720#ifdef MEDCOUPLING_
721
722inline const MEDCouplingUMesh* Domaine_VF::get_mc_face_mesh() const
723{
724 if (!mc_face_mesh_ready_) build_mc_face_mesh();
725 return mc_face_mesh_;
726}
727
728inline const MEDCouplingUMesh* Domaine_VF::get_mc_dual_mesh() const
729{
730 if (!mc_dual_mesh_ready_) build_mc_dual_mesh();
731 return mc_dual_mesh_;
732}
733
734#endif
735
736#endif /* Domaine_VF_included */
Empty class used as a base for all the arrays.
Definition Array_base.h:41
class Conds_lim This class represents a vector of boundary conditions.
Definition Conds_lim.h:32
int nb_som_elem() const
Returns the number of vertices of the geometric elements that make up the domain.
Definition Domaine.h:474
int_t nb_faces_frontiere() const
Returns the number of boundary faces of the domain (sum of boundaries, connections,...
Definition Domaine.h:488
const ArrOfInt_t & ind_faces_virt_bord() const
Definition Domaine.h:362
int nb_joints() const
Definition Domaine.h:259
IntTab_t & les_elems()
Definition Domaine.h:129
Joint_t & joint(int i)
Definition Domaine.h:261
class Domaine_Cl_dis_base Domaine_Cl_dis_base objects represent discretized boundary conditions
class Domaine_VF
Definition Domaine_VF.h:44
int premiere_face_bord() const
Returns the index of the first face on which boundary conditions are applied:
Definition Domaine_VF.h:522
IntTab face_virt_pe_num_
Definition Domaine_VF.h:245
void info_elem_som()
IntVect rang_elem_non_std_
Definition Domaine_VF.h:252
void creer_tableau_aretes(Array_base &, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT) const
virtual const DoubleVect & face_surfaces() const
Definition Domaine_VF.h:51
int nb_faces() const
Returns the total number of faces.
Definition Domaine_VF.h:471
DoubleTab xp_
Definition Domaine_VF.h:218
virtual double compute_L1_norm(const DoubleVect &val_source, const bool basis_function, const int order) const
void build_mc_face_mesh() const
Build the MEDCoupling face mesh. It is always made of polygons (in 3D) for simplicity purposes....
void build_map_mc_Cmesh(const bool with_faces) override
IntTab & face_sommets() override
Returns the face/vertex connectivity array.
Definition Domaine_VF.h:590
virtual const DoubleTab & xv_bord() const
virtual double dist_face_elem1(int, int) const
Definition Domaine_VF.h:183
const IntTab & face_numero_bord() const
Definition Domaine_VF.h:82
virtual double compute_L2_norm(const DoubleVect &val_source, const bool basis_function, const int order) const
IntTab face_numero_bord_
Definition Domaine_VF.h:226
void init_dist_paroi_globale(const Conds_lim &conds_lim) override
Method inspired by Raccord_distant_homogene::initialise.
DoubleVect volumes_entrelaces_
Definition Domaine_VF.h:210
const MD_Vector & md_vector_faces() const
Definition Domaine_VF.h:158
void order_faces(Faces &les_faces)
This method (that may be overriden in various discretisations) is used to order faces according to th...
const MD_Vector & md_vector_aretes() const
Definition Domaine_VF.h:160
DoubleTab xa_
Definition Domaine_VF.h:225
virtual void get_ind_integ_points(IntTab &nelem) const
int nb_faces_bord_tot() const
Returns the total number of faces (real + virtual) on which boundary conditions are applied:
Definition Domaine_VF.h:640
const DoubleTab & xv() const
Definition Domaine_VF.h:94
const DoubleVect & volumes() const
Definition Domaine_VF.h:121
const DoubleTab & xa() const
Definition Domaine_VF.h:98
double volume_entrelace_axi(double r_face, double r_elem, double axis_length) const
Definition Domaine_VF.h:702
const IntTab & get_face_voisins_dual() const
Definition Domaine_VF.h:195
DoubleVect & volumes_entrelaces()
Definition Domaine_VF.h:99
int nb_faces_tot() const
Returns the total number of faces.
Definition Domaine_VF.h:481
void face_voisins_reel_fictif(int face, int &el0, int &elf) const
Returns in el0 the index of the interior element; returns in elf the index of the fictitious element ...
Definition Domaine_VF.h:444
virtual Faces * creer_faces()
Returns new(Faces)! It is overridden by Domaine_VDF for example.
double xa(int num_arete, int k) const
Definition Domaine_VF.h:78
double dot(const double *a, const double *b, const double *ma=nullptr, const double *mb=nullptr) const
Definition Domaine_VF.h:695
void creer_tableau_faces(Array_base &, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT) const
void sort_along_zcurve(const Faces &les_faces, IntTab &sort_key) const
Tweak the face sorting keys so that internal faces (=standard faces) follow a Z-curve indexing scheme...
int nb_arete_face() const
Returns the number of edges per face.
Definition Domaine_VF.h:502
IntTab face_dual_
For each face f, face_dual_(f, j) returns the element built on the left and right of the face in the ...
Definition Domaine_VF.h:267
DoubleTab xv_
Definition Domaine_VF.h:219
virtual double face_normales(int face, int comp) const
Definition Domaine_VF.h:47
int nb_elem_std_
Definition Domaine_VF.h:250
const DoubleTab & volumes_entrelaces_dir() const
Definition Domaine_VF.h:102
IntTab face_sommets_
Definition Domaine_VF.h:223
int nb_faces_internes() const
A face is internal if and only if it separates two elements.
Definition Domaine_VF.h:532
double xv(int num_face, int k) const
Definition Domaine_VF.h:76
virtual double dist_face_elem1_period(int, int, double) const
Definition Domaine_VF.h:185
void infobord()
MD_Vector md_vector_faces_
Definition Domaine_VF.h:229
void discretiser_no_face() override
int nb_faces_std_
Definition Domaine_VF.h:251
virtual void prepare_elem_non_std(Faces &les_faces)
Identify non-standard elements (will be used later to identify non standard faces) Some discretisatio...
int nb_joints() const
Definition Domaine_VF.h:65
int nb_frontiere_dis() const
Definition Domaine_VF.h:111
const Joint & joint(int i) const
Definition Domaine_VF.h:105
ArrOfInt & faces_doubles()
Returns 1 for faces belonging to a periodic boundary or a shared item, 0 by default.
Definition Domaine_VF.h:566
DoubleTab & xa()
Definition Domaine_VF.h:97
double volumes(int i) const
Definition Domaine_VF.h:113
const DoubleTab & normale_paroi_elem() const
Definition Domaine_VF.h:189
void remplir_face_numero_bord()
virtual void compute_sort_key(Faces &les_faces, IntTab &sort_key)
Generate an IntTab (sort_key) with two columns allowing to sort the faces along a specific order....
virtual int get_max_nb_integ_points() const
virtual double dist_face_elem0_period(int, int, double) const
Definition Domaine_VF.h:184
void creer_tableau_faces_bord(Array_base &, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT) const
DoubleVect inverse_volumes_
Definition Domaine_VF.h:209
const IntTab & get_num_fac_loc() const
Definition Domaine_VF.h:140
Joint & joint(int i)
Definition Domaine_VF.h:106
void discretiser() override
Generates the faces and builds the boundaries.
void modifier_pour_Cl(const Conds_lim &) override
DoubleTab & xv()
Definition Domaine_VF.h:93
int numero_sommet_local(int som, int elem) const
Definition Domaine_VF.h:395
void build_mc_dual_mesh() const
Build the dual mesh of the domain for post-processing of face fields.
DoubleTab n_y_elem_
Definition Domaine_VF.h:247
VECT(Front_VF) les_bords_
const ArrOfInt & ind_faces_virt_bord() const
Definition Domaine_VF.h:144
DoubleTab n_y_faces_
Definition Domaine_VF.h:248
IntTab & face_numero_bord()
Definition Domaine_VF.h:81
void construire_face_virt_pe_num()
Fills in the face_virt_pe_num_ array (see comment in Domaine_VF.h).
IntTab & elem_faces()
Returns the element/face connectivity array.
Definition Domaine_VF.h:550
IntTab & face_aretes() override
Returns the face/edge connectivity array.
Definition Domaine_VF.h:606
int get_face_voisins_dual(const int i, const int j) const
Definition Domaine_VF.h:196
ArrOfInt est_face_bord_
Definition Domaine_VF.h:240
virtual void typer_elem(Domaine &)
Definition Domaine_VF.h:61
virtual void get_position(DoubleTab &positions) const
int numero_face_local(int face, int elem) const
virtual double surface(int i) const
Definition Domaine_VF.h:53
const DoubleVect & inverse_volumes() const
Definition Domaine_VF.h:122
int est_une_face_virt_bord(int) const
Returns 1 if face is a virtual boundary face, 0 otherwise.
Definition Domaine_VF.h:680
virtual double dist_norm(int) const
Definition Domaine_VF.h:180
IntTab num_fac_loc_
Definition Domaine_VF.h:237
int nb_som_face() const
Returns the number of vertices per face.
Definition Domaine_VF.h:493
DoubleVect volumes_
Definition Domaine_VF.h:208
Frontiere_dis_base & frontiere_dis(int) override
Returns the i-th discrete boundary.
Definition Domaine_VF.h:630
DoubleTab normalized_boundaries_outward_vector(int global_face_number, double scale_factor) const
Compute the normalized boundary outward vector associated to the face global_face_number and eventual...
virtual double face_surfaces(int i) const
Definition Domaine_VF.h:52
virtual const IntVect & orientation() const
Definition Domaine_VF.h:645
IntTab face_voisins_
Definition Domaine_VF.h:216
const IntTab & face_virt_pe_num() const
IntTab elem_faces_
Definition Domaine_VF.h:222
const ArrOfInt & est_face_bord() const
Definition Domaine_VF.h:86
DoubleTab xv_bord_
Definition Domaine_VF.h:220
IntTab face_aretes_
Definition Domaine_VF.h:224
const IntTab & face_voisins_fictifs() const
Definition Domaine_VF.h:125
double xp(int num_elem, int k) const
Definition Domaine_VF.h:77
DoubleVect & volumes()
Definition Domaine_VF.h:119
ArrOfInt & est_face_bord()
Definition Domaine_VF.h:85
virtual void renumber_faces(Faces &les_faces, IntTab &sort_key)
Re-index faces according to the new order given by 'sort_key'.
std::array< double, 3 > cross(int dima, int dimb, const double *a, const double *b, const double *ma=nullptr, const double *mb=nullptr) const
Definition Domaine_VF.h:710
void calculer_face_surfaces(const DoubleVect &surfaces)
Definition Domaine_VF.h:50
virtual void remplir_face_voisins_fictifs(const Domaine_Cl_dis_base &)
DoubleTab face_normales_
Definition Domaine_VF.h:212
const DoubleTab & normale_paroi_faces() const
Definition Domaine_VF.h:190
virtual int orientation_si_definie(int) const
Definition Domaine_VF.h:653
IntTab face_voisins_fictifs_
Definition Domaine_VF.h:217
DoubleTab & volumes_entrelaces_dir()
Definition Domaine_VF.h:103
int oriente_normale(int f, int e) const
Definition Domaine_VF.h:194
void construire_num_fac_loc()
MD_Vector md_vector_faces_front_
Definition Domaine_VF.h:231
DoubleTab calculer_xgr() const
Computes the xgr array for the computation of moments of forces at boundaries.
int fbord(int f) const
Definition Domaine_VF.h:146
int premiere_face_int() const
A face is internal if and only if it separates two elements.
Definition Domaine_VF.h:463
virtual const DoubleTab & face_normales() const
Definition Domaine_VF.h:49
MD_Vector md_vector_aretes_
Definition Domaine_VF.h:233
DoubleTab volumes_entrelaces_dir_
Definition Domaine_VF.h:211
DoubleTab & xp()
Definition Domaine_VF.h:95
int nb_faces_bord() const
Returns the number of faces on which boundary conditions are applied:
Definition Domaine_VF.h:512
virtual void compute_average_porosity(const DoubleVect &val_source, const DoubleVect &porosity, double &sum, double &volume, const bool basis_function, const int order) const
const DoubleTab & xp() const
Definition Domaine_VF.h:96
const MD_Vector & md_vector_faces_bord() const
Definition Domaine_VF.h:157
virtual void compute_average(const DoubleVect &val_source, double &sum, double &volume, const bool basis_function, const int order) const
virtual double dist_face_elem0(int, int) const
Definition Domaine_VF.h:182
DoubleVect & inverse_volumes()
Definition Domaine_VF.h:120
ArrOfInt faces_doubles_
Definition Domaine_VF.h:239
virtual double dist_norm_bord(int) const
Definition Domaine_VF.h:181
virtual DoubleTab & face_normales()
Definition Domaine_VF.h:48
virtual void get_nb_integ_points(IntTab &nelem) const
const DoubleVect & volumes_entrelaces() const
Definition Domaine_VF.h:100
const Front_VF & front_VF(int i) const
Definition Domaine_VF.h:112
void typer_discretiser_ss_domaine(int i) override
double volumes_entrelaces(int num_face) const
Definition Domaine_VF.h:101
IntTab & face_voisins() override
Returns the face-element connectivity array; see above.
Definition Domaine_VF.h:426
double inverse_volumes(int i) const
Definition Domaine_VF.h:114
void marquer_faces_double_contrib(const Conds_lim &)
class Domaine_dis_base This class is the base of the hierarchy of discretized domains.
const Domaine & domaine() const
class Front_VF
Definition Front_VF.h:36
class Frontiere_dis_base Class representing a discretized boundary.
virtual int get_nb_items_tot() const
: This class is an OWN_PTR but the pointed object is shared among multiple
Definition MD_Vector.h:48
static int dimension
Definition Objet_U.h:94
static void exit(int exit_code=-1)
Exit routine for TRUST within a Kokkos region.
Definition Process.cpp:466