TrioCFD 1.9.8
TrioCFD documentation
Loading...
Searching...
No Matches
Traitement_particulier_NS_THI.cpp
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#include <Traitement_particulier_NS_THI.h>
17#include <MD_Vector_tools.h>
18#include <ArrOfBit.h>
19#include <Scatter.h>
20#include <Domaine.h>
21
22Implemente_base(Traitement_particulier_NS_THI,"Traitement_particulier_NS_THI",Traitement_particulier_NS_base);
23// XD thi traitement_particulier_base thi INHERITS_BRACE Keyword for a THI (Homogeneous Isotropic Turbulence)
24// XD_CONT calculation.
25// XD attr init_Ec entier init_Ec REQ Keyword to renormalize initial velocity so that kinetic energy equals to the value
26// XD_CONT given by keyword val_Ec.
27// XD attr val_Ec floattant val_Ec OPT Keyword to impose a value for kinetic energy by velocity renormalizated if
28// XD_CONT init_Ec value is 1.
29// XD attr facon_init entier(into=["0","1"]) facon_init OPT Keyword to specify how kinetic energy is computed (0 or 1).
30// XD attr calc_spectre entier(into=["0","1"]) calc_spectre OPT Calculate or not the spectrum of kinetic energy. NL2
31// XD_CONT Files called Sorties_THI are written with inside four columns : NL2 time:t global_kinetic_energy:Ec
32// XD_CONT enstrophy:D skewness:S NL2 If calc_spectre is set to 1, a file Sorties_THI2_2 is written with three columns :
33// XD_CONT NL2 time:t kinetic_energy_at_kc=32 enstrophy_at_kc=32 NL2 If calc_spectre is set to 1, a file spectre_xxxxx
34// XD_CONT is written with two columns at each time xxxxx : NL2 frequency:k energy:E(k).
35// XD attr periode_calc_spectre floattant periode_calc_spectre OPT Period for calculating spectrum of kinetic energy
36// XD attr spectre_3D entier(into=["0","1"]) Spectre_3D OPT Calculate or not the 3D spectrum
37// XD attr spectre_1D entier(into=["0","1"]) Spectre_1D OPT Calculate or not the 1D spectrum
38// XD attr conservation_Ec rien conservation_Ec OPT If set to 1, velocity field will be changed as to have a constant
39// XD_CONT kinetic energy (default 0)
40// XD attr longueur_boite floattant longueur_boite OPT Length of the calculation domain
41
43{
44 return is;
45}
46
48{
49 return is;
50}
51
53{
54 Motcle accouverte = "{" , accfermee = "}" ;
55 Motcle valec="val_Ec";
56 Motcle facon="facon_init";
57 Motcle motbidon, motlu;
58 is >> motbidon ;
59 if (motbidon == accouverte)
60 {
61 Motcles les_mots(2);
62 {
63 les_mots[0] = "init_Ec";
64 les_mots[1] = "calc_spectre";
65 }
66 {
67 is >> motlu;
68 while(motlu != accfermee)
69 {
70 int rang=les_mots.search(motlu);
71 switch(rang)
72 {
73 case 0 :
74 {
75 is >> init; // init_Ec = 1
76 if (init!=0)
77 {
78 is >> motlu;
79 if (motlu==valec)
80 {
81 is >> Ec_init; // on lit la valeur de Ec_init
82 Cerr << "Avec Initialisation de l Energie Cinetique Ec_init= " << Ec_init << finl;
83 is >> motlu;
84 if (motlu==facon)
85 {
86 is >> fac_init; // Sur quelle valeur se base l initialisation??
87 Cerr << "Avec Initialisation de l Energie Cinetique sur Ecspat (init_fac==0) ou Ecspec (init_fac==1) : fac_init=" << fac_init << finl;
88 }
89 }
90 else
91 {
92 Cerr << "Erreur dans la lecture de Traitement_particulier_NS_THI_VDF" << finl;
93 Cerr << "Le seul mot cle possible ici est : val_Ec" << finl;
94 Cerr << "Vous avez lu :" << motlu << finl;
95 exit();
96 }
97 }
98 break;
99 }
100 case 1 :
101 {
102 is >> oui_calc_spectre;
103 if (oui_calc_spectre!=0) Cerr << "Calcul des spectres." << finl;
104 break;
105 }
106
107 default :
108 {
109 Cerr << "Erreur dans la lecture de Traitement_particulier_NS_THI";
110 Cerr << "Les mots cles possibles sont : init_Ec, calc_spectre, { et }" << finl;
111 Cerr << "Vous avez lu :" << motlu << finl;
112 exit();
113 break;
114 }
115 }
116 is >> motlu;
117 }
118 is >> motlu;
119 if (motlu != accfermee)
120 {
121 Cerr << "Erreur dans la lecture de Traitement_particulier_NS_THI";
122 Cerr << "On attendait une }" << finl;
123 exit();
124 }
125 }
126 }
127 else
128 {
129 Cerr << "Erreur dans la lecture de Traitement_particulier_NS_THI";
130 Cerr << "On attendait une {" << finl;
131 exit();
132 }
133 return is;
134}
135
136
146
154
155void Traitement_particulier_NS_THI::en_cours_de_resolution(int nb_op, DoubleTab& u, DoubleTab& u_av, double dt)
156{
157 // il n'est en fait jamais appele cf. ci-dessous
158 if (oui_transf == 1)
159 {
160 calcul_spectre_operateur( nb_op, u, u_av,dt);
161 }
162 return;
163}
164
166{
167 const char* methode_actuelle="Traitement_particulier_NS_THI::calcul_nb_som_dir";
168
169 // Sert a calculer le nombre de sommet commun en parallele
170 ArrOfBit unused;
171 trustIdType nb_som = domaine.les_sommets().get_md_vector()->get_sequential_items_flags(unused);
172 // Somme sur tous les processeurs
173 nb_som = mp_sum(nb_som);
174
175 // [ABN] OMG, the below is so ugly ... how could this ever work?!
176 double nb=pow(static_cast<double>(nb_som),1./3.);
177 nb_som_dir = static_cast<int>(nb);
178 if (nb_som_dir*nb_som_dir*nb_som_dir != nb_som)
179 {
181 if (nb_som_dir*nb_som_dir*nb_som_dir != nb_som)
182 msg_erreur_maillage(methode_actuelle);
183 }
185 return nb_som_dir;
186}
187
189{
190 const char* methode_actuelle="Traitement_particulier_NS_THI::calcul_nb_elem_dir";
191 trustIdType nb_elem = domaine.nb_elem();
192
193 // Somme sur tous les processeurs
194 nb_elem=mp_sum(nb_elem);
195
196 // [ABN] (same as above) -> OMG, the below is so ugly ... how could this ever work?!
197 double nb=pow(static_cast<double>(nb_elem),1./3.);
198 nb_elem_dir = static_cast<int>(nb);
199 if (nb_elem_dir*nb_elem_dir*nb_elem_dir != nb_elem)
200 {
202 if (nb_elem_dir*nb_elem_dir*nb_elem_dir != nb_elem)
203 msg_erreur_maillage(methode_actuelle);
204 }
205 return nb_elem_dir;
206}
207
209{
210 if (je_suis_maitre())
211 {
212 Cerr << finl;
213 Cerr << "Probleme dans " << methode_actuelle << " :" << finl;
214 Cerr << "Votre maillage ne semble pas comporter le meme nombre de noeuds" << finl;
215 Cerr << "suivant toutes les directions. Verifiez votre jeu de donnee... " << finl << finl;
216 // Abort pour les cas paralleles !
217 abort();
218 }
219}
220
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
Une chaine de caractere (Nom) en majuscules.
Definition Motcle.h:26
Un tableau d'objets de la classe Motcle.
Definition Motcle.h:63
int search(const Motcle &t) const
Definition Motcle.cpp:321
friend class Entree
Definition Objet_U.h:76
virtual Entree & readOn(Entree &)
Lecture d'un Objet_U sur un flot d'entree Methode a surcharger.
Definition Objet_U.cpp:293
virtual Sortie & printOn(Sortie &) const
Ecriture de l'objet sur un flot de sortie Methode a surcharger.
Definition Objet_U.cpp:282
static void abort()
Routine de sortie de Trio-U sur une erreur abort().
Definition Process.cpp:570
static double mp_sum(double)
Calcule la somme de x sur tous les processeurs du groupe courant.
Definition Process.cpp:146
static void exit(int exit_code=-1)
Routine de sortie de TRUST dans une region Kokkos.
Definition Process.cpp:455
static int je_suis_maitre()
renvoie 1 si on est sur le processeur maitre du groupe courant (c'est a dire me() == 0),...
Definition Process.cpp:86
Classe de base des flux de sortie.
Definition Sortie.h:52
classe Traitement_particulier_THI Cette classe permet de faire les traitements particuliers
virtual void calcul_spectre_operateur(int, DoubleTab &, DoubleTab &, double)=0
virtual void init_calc_spectre()=0
virtual void calcul_spectre()=0
virtual void sorties_globales()=0
void en_cours_de_resolution(int, DoubleTab &, DoubleTab &, double) override
classe Traitement_particulier_NS_base Derive de Support_Champ_Masse_Volumique: utilisation de rho