TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Periodique.cpp
1/****************************************************************************
2* Copyright (c) 2024, 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#include <Reordonner_faces_periodiques.h>
17#include <Domaine_Cl_dis_base.h>
18
19#include <Domaine_VF.h>
20#include <Periodique.h>
21#include <Domaine.h>
22#include <Scatter.h>
23
24Implemente_instanciable(Periodique, "Periodique", Cond_lim_base);
25// XD periodic condlim_base periodique INHERITS_BRACE 1). For Navier-Stokes equations, this keyword is used to indicate
26// XD_CONT that the horizontal inlet velocity values are the same as the outlet velocity values, at every moment. As
27// XD_CONT regards meshing, the inlet and outlet edges bear the same name.; 2). For scalar transport equation, this
28// XD_CONT keyword is used to set a periodic condition on scalar. The two edges dealing with this periodic condition
29// XD_CONT bear the same name.
30
31Sortie& Periodique::printOn(Sortie& s) const { return s << que_suis_je() << finl; }
32
34{
35 le_champ_front.typer("Champ_front_uniforme");
36 return s;
37}
38
40{
41 Frontiere& frontiere = frontiere_dis().frontiere();
42 Cerr << "Initialization for periodic on " << frontiere.le_nom() << finl;
43
44 // Search for the periodicity direction:
45 ArrOfDouble erreur;
46 int ok = Reordonner_faces_periodiques::check_faces_periodiques(frontiere, direction_perio_, erreur, true /* verbose */);
47 if (!ok)
48 exit();
49
50 distance_ = norme_array(direction_perio_);
51 int i;
52 const int dim = direction_perio_.size_array();
53 direction_xyz_ = -2;
54 for (i = 0; i < dim; i++)
55 {
56 if (std::fabs(direction_perio_[i]) > precision_geom)
57 {
58 if (direction_xyz_ == -2)
60 else
61 // Second non-zero coordinate: direction vector is not aligned on an axis
62 direction_xyz_ = -1;
63 }
64 }
65 if (direction_xyz_ < 0)
66 Cerr << "Periodic direction not aligned on an axis" << finl;
67 else
68 Cerr << "Periodic direction aligned on the axis " << direction_xyz_ << finl;
69
70 const Domaine& domaine = frontiere.domaine();
71
72 // Create an index array spanning all boundary faces
73 IntTab tab_face_associee;
74 const Domaine_VF& domainevf = ref_cast(Domaine_VF, domaine_Cl_dis().domaine_dis());
75 domainevf.creer_tableau_faces_bord(tab_face_associee, RESIZE_OPTIONS::NOCOPY_NOINIT);
76 tab_face_associee = -1;
77
78 // Number of virtual faces on this boundary:
79 const int nb_faces = frontiere.nb_faces();
80 const int nb_faces_2_ = nb_faces / 2;
81 const ArrOfInt& faces_virt = frontiere.get_faces_virt();
82 const int nb_faces_virt = faces_virt.size_array();
83
84 // Fill the real part of the face_associee array for the boundary of interest:
85 // and the real part of the "associee" array
86 const int i_premiere_face = frontiere.num_premiere_face();
87 for (i = 0; i < nb_faces_2_; i++)
88 {
89 const int i1 = i_premiere_face + i;
90 const int i2 = i_premiere_face + i + nb_faces_2_;
91 tab_face_associee[i1] = i2;
92 tab_face_associee[i2] = i1;
93 }
94 const MD_Vector& md_faces_front = tab_face_associee.get_md_vector();
95 // Exchange virtual space with index translation:
96 Scatter::construire_espace_virtuel_traduction(md_faces_front, md_faces_front, tab_face_associee, 1 /* fatal errors */);
97 // Array giving for each virtual face of the domain -1 if it is not a
98 // boundary face, otherwise its index in the boundaries.
99 const ArrOfInt& ind_faces_virt_bord = domaine.ind_faces_virt_bord();
100 // Create an array giving, for each virtual face of the boundaries (all boundaries)
101 // the index of the face in the current periodic boundary (-1 otherwise)
102 const int nb_faces_front_tot = tab_face_associee.size_totale();
103 ArrOfInt index(nb_faces_front_tot);
104 index = -2;
105 const int nb_faces_domaine = domaine_Cl_dis().domaine_dis().face_sommets().dimension(0);
106 for (i = 0; i < nb_faces_virt; i++)
107 {
108 const int face_domaine = frontiere.face_virt(i); // Index of a face in the domain
109 const int face_front = ind_faces_virt_bord[face_domaine - nb_faces_domaine]; // Index in the boundaries
110 index[face_front] = nb_faces + i;
111 }
112
113 // Fill the "face_front_associee_" array
114 face_front_associee_.resize_array(nb_faces + nb_faces_virt);
115 for (i = 0; i < nb_faces + nb_faces_virt; i++)
116 {
117 int resu = -1;
118 if (i < nb_faces_2_)
119 resu = i + nb_faces_2_;
120 else if (i < nb_faces)
121 resu = i - nb_faces_2_;
122 else
123 {
124 // Virtual face:
125 const int face_domaine = frontiere.face_virt(i - nb_faces); // Index of the face in the domain
126 const int face_front = ind_faces_virt_bord[face_domaine - nb_faces_domaine]; // Index in the boundaries
127 // Index of the associated face in the face_associee array:
128 const int face_front_associee = tab_face_associee[face_front];
129 if (face_front_associee >= 0)
130 {
131 // Index of the associated face in the boundary:
132 const int face_asso = index[face_front_associee];
133 assert(face_asso >= 0);
134 resu = face_asso;
135 }
136 else
137 {
138 // The associated virtual face is not in the domain
139 Cerr << "Error in Periodique::completer()" << finl;
140 exit();
141 }
142 }
143 face_front_associee_[i] = resu;
144 }
145}
146
148{
150 {
151 Cerr << "Error in Periodique::direction_periodicite():\n" << " An algorithm seems to assume that the periodic direction is aligned in X, Y or Z\n" << " and this is not the case !" << finl;
152 exit();
153 }
154 return direction_xyz_;
155}
class Cond_lim_base Base class for the hierarchy of classes that represent the different boundary con...
Domaine_Cl_dis_base & domaine_Cl_dis()
Returns the domain of discretized boundary conditions to which the object belongs.
virtual Frontiere_dis_base & frontiere_dis()
Returns the discretized boundary to which the boundary conditions apply.
Domaine_dis_base & domaine_dis()
Returns a reference to the discretized domain associated with the boundary conditions.
class Domaine_VF
Definition Domaine_VF.h:44
void creer_tableau_faces_bord(Array_base &, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT) const
virtual IntTab & face_sommets()
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
const ArrOfInt_t & get_faces_virt() const
Definition Frontiere.h:69
const Domaine_t & domaine() const
Returns the domain associated with the boundary (const version).
int_t face_virt(int_t i) const
Definition Frontiere.h:65
int_t num_premiere_face() const
Definition Frontiere.h:67
const Nom & le_nom() const override
Returns the name of the Objet_U. Virtual method to override: returns "neant" in this implementation.
Definition Frontiere.h:49
int_t nb_faces() const
Returns the number of faces of the boundary.
Definition Frontiere.h:59
const Frontiere & frontiere() const
Returns the associated geometric boundary.
: This class is an OWN_PTR but the pointed object is shared among multiple
Definition MD_Vector.h:48
const Nom & que_suis_je() const
Returns the string identifying the class.
Definition Objet_U.cpp:104
virtual Entree & readOn(Entree &)
Reads an Objet_U from an input stream. Virtual method to override.
Definition Objet_U.cpp:289
static double precision_geom
Definition Objet_U.h:81
virtual Sortie & printOn(Sortie &) const
Writes the object to an output stream. Virtual method to override.
Definition Objet_U.cpp:278
class Periodique This class represents a periodic boundary condition.
Definition Periodique.h:31
void completer() override
DOES NOTHING must be overridden in derived classes.
double distance_
Definition Periodique.h:47
ArrOfDouble direction_perio_
Definition Periodique.h:46
int est_periodique_selon_un_axe() const
Definition Periodique.h:40
ArrOfInt face_front_associee_
Definition Periodique.h:45
int direction_periodicite() const
int direction_xyz_
Definition Periodique.h:49
static void exit(int exit_code=-1)
Exit routine for TRUST within a Kokkos region.
Definition Process.cpp:466
static int check_faces_periodiques(const Frontiere_32_64< int > &frontiere, ArrOfDouble &vecteur_delta, ArrOfDouble &erreur, bool verbose=false)
static void construire_espace_virtuel_traduction(const MD_Vector &md_indice, const MD_Vector &md_valeur, IntTab &tableau, const int error_is_fatal=1)
Builds the items_communs + virtual space structure of an array containing indices of geometric items,...
Definition Scatter.cpp:1621
Base class for output streams.
Definition Sortie.h:52
_SIZE_ size_array() const
_SIZE_ dimension(int d) const
Definition TRUSTTab.tpp:133
_SIZE_ size_totale() const
Definition TRUSTVect.tpp:61
virtual const MD_Vector & get_md_vector() const
Definition TRUSTVect.h:123