TRUST 1.9.8
HPC thermohydraulic platform
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 // Recherche de la direction de periodicite:
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 // Deuxieme coordonnee non nulle, vecteur direction n'est pas aligne sur un axe
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 // Creation d'un tableau d'indices parallele sur toutes les faces frontieres
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 // Nombre de faces virtuelles de cette frontiere:
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 // On remplit la partie reele du tableau face_associee pour la frontiere qui nous interesse:
85 // et la partie reele du tableau "associee"
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 // On echange espace virtuel avec traduction des indices:
96 Scatter::construire_espace_virtuel_traduction(md_faces_front, md_faces_front, tab_face_associee, 1 /* erreurs fatales */);
97 // Tableau qui donne pour chaque face virtuelle du domaine, -1 si ce n'est pas une
98 // face frontiere, sinon son indice dans les les frontieres.
99 const ArrOfInt& ind_faces_virt_bord = domaine.ind_faces_virt_bord();
100 // Creation d'un tableau qui donne, pour chaque face virtuelle des frontieres (toutes frontieres)
101 // l'indice de la face dans la frontiere periodique courante (-1 sinon)
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); // Indice d'une face du domaine
109 const int face_front = ind_faces_virt_bord[face_domaine - nb_faces_domaine]; // Indice dans les frontieres
110 index[face_front] = nb_faces + i;
111 }
112
113 // Remplissage du tableau "face_front_associee_"
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 // Face virtuelle :
125 const int face_domaine = frontiere.face_virt(i - nb_faces); // Indice de la face du domaine
126 const int face_front = ind_faces_virt_bord[face_domaine - nb_faces_domaine]; // Indice dans les frontieres
127 // Indice de la face associee dans le tableau face_associee:
128 const int face_front_associee = tab_face_associee[face_front];
129 if (face_front_associee >= 0)
130 {
131 // Indice de la face associee dans la frontiere:
132 const int face_asso = index[face_front_associee];
133 assert(face_asso >= 0);
134 resu = face_asso;
135 }
136 else
137 {
138 // La face virtuelle associee n'est pas dans le domaine
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}
classe Cond_lim_base Classe de base pour la hierarchie des classes qui representent les differentes c...
Domaine_Cl_dis_base & domaine_Cl_dis()
Renvoie le domaine des conditions aux limites discretisee dont l'objet fait partie.
virtual Frontiere_dis_base & frontiere_dis()
Renvoie la frontiere discretisee a laquelle les conditions aux limites s'appliquent.
Domaine_dis_base & domaine_dis()
Renvoie une reference sur le domaine discretise associe aux conditions aux limites.
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
Renvoie le domaine associe a la frontiere.
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
Donne le nom de l'Objet_U Methode a surcharger : renvoie "neant" dans cette implementation.
Definition Frontiere.h:49
int_t nb_faces() const
Renvoie le nombre de faces de la frontiere.
Definition Frontiere.h:59
const Frontiere & frontiere() const
Renvoie la frontiere geometrique associee.
: Cette classe est un OWN_PTR mais l'objet pointe est partage entre plusieurs
Definition MD_Vector.h:48
const Nom & que_suis_je() const
renvoie la chaine identifiant la classe.
Definition Objet_U.cpp:104
virtual Entree & readOn(Entree &)
Lecture d'un Objet_U sur un flot d'entree Methode a surcharger.
Definition Objet_U.cpp:293
static double precision_geom
Definition Objet_U.h:86
virtual Sortie & printOn(Sortie &) const
Ecriture de l'objet sur un flot de sortie Methode a surcharger.
Definition Objet_U.cpp:282
classe Periodique Cette classe represente une condition aux limites periodique.
Definition Periodique.h:31
void completer() override
NE FAIT RIEN A surcharger dans les classes derivees.
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)
Routine de sortie de TRUST dans une region Kokkos.
Definition Process.cpp:455
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)
Construit la structure items_communs + espaces virtuels d'un tableau contenant des indices d'items ge...
Definition Scatter.cpp:1624
Classe de base des flux de sortie.
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