TRUST 1.9.8
HPC thermohydraulic platform
Loading...
Searching...
No Matches
Champ_front_bruite.cpp
1/****************************************************************************
2* Copyright (c) 2023, 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 <Champ_front_bruite.h>
17#include <Frontiere_dis_base.h>
18#include <Frontiere.h>
19#include <Motcle.h>
20
21Implemente_instanciable(Champ_front_bruite,"Champ_front_bruite",Ch_front_var_instationnaire_indep);
22// XD champ_front_bruite front_field_base champ_front_bruite NO_BRACE Field which is variable in time and space in a
23// XD_CONT random manner.
24// XD attr nb_comp entier nb_comp REQ Number of field components.
25// XD attr bloc bloc_lecture bloc REQ { [N val L val ] Moyenne m_1.....[m_i ] Amplitude A_1.....[A_ i ]}: Random nois:
26// XD_CONT If N and L are not defined, the ith component of the field varies randomly around an average value m_i with a
27// XD_CONT maximum amplitude A_i. NL2 White noise: If N and L are defined, these two additional parameters correspond to
28// XD_CONT L, the domain length and N, the number of nodes in the domain. Noise frequency will be between 2*Pi/L and
29// XD_CONT 2*Pi*N/(4*L). NL2 For example, formula for velocity: u=U0(t) v=U1(t)Uj(t)=Mj+2*Aj*bruit_blanc where
30// XD_CONT bruit_blanc (white_noise) is the formula given in the mettre_a_jour (update) method of the Champ_front_bruite
31// XD_CONT (noise_boundary_field) (Refer to the Champ_front_bruite.cpp file).
32
33/*! @brief Impression sur un flot de sortie au format: taille
34 *
35 * valeur(0) ... valeur(i) ... valeur(taille-1)
36 *
37 * @param (Sortie& os) un flot de sortie
38 * @return (Sortie&) le flot de sortie modifie
39 */
41{
42 const DoubleTab& tab=valeurs();
43 os << tab.size() << " ";
44 for(int i=0; i<tab.size(); i++)
45 os << tab(0,i);
46 return os;
47}
48
49/*! @brief Lecture a partir d'un flot d'entree au format: nombre_de_composantes
50 *
51 * moyenne moyenne(0) ... moyenne(nombre_de_composantes-1)
52 * moyenne amplitude(0) ... amplitude(nombre_de_composantes-1)
53 *
54 * @param (Entree& is) un flot d'entree
55 * @return (Entree&) le flot d'entree modifie
56 * @throws accolade ouvrante attendue
57 * @throws mot clef inconnu a cet endroit
58 * @throws accolade fermante attendue
59 */
61{
62 int dim;
64 Motcle motlu;
65 Motcles les_mots(4);
66 les_mots[0]="moyenne";
67 les_mots[1]="amplitude";
68 les_mots[2]="L";
69 les_mots[3]="N";
70 is >> motlu;
71 if (motlu != "{")
72 {
73 Cerr << "Error while reading a Champ_front_bruite" << finl;
74 Cerr << "We expected a { instead of " << motlu << finl;
75 exit();
76 }
77 is >> motlu;
78 while (motlu!="}")
79 {
80 int rang=les_mots.search(motlu);
81 switch(rang)
82 {
83 case 0 :
84 {
85 moyenne.resize(dim);
86 fixer_nb_comp(dim);
87 for(int i=0; i<dim; i++)
88 is >> moyenne(i);
89 break;
90 }
91 case 1:
92 {
93 amplitude.resize(dim);
94 for(int i=0; i<dim; i++)
95 is >> amplitude(i);
96 break;
97 }
98 case 2:
99 {
100 is >> lx;
101 break;
102 }
103 case 3:
104 {
105 is >> nx;
106 break;
107 }
108 default :
109 {
110 Cerr << "Error while reading a Champ_front_bruite" << finl;
111 Cerr << motlu << "is not understand here "<< finl;
112 Cerr << "We were expecting a word from " << les_mots << finl;
113 exit();
114 }
115 }
116 is >> motlu;
117 }
118 return is;
119}
120
121
122/*! @brief Pas code !!
123 *
124 * @param (Champ_front_base& ch)
125 * @return (Champ_front_base&)
126 */
131
132/*! @brief Mise a jour du temps et retirage aleatoire des valeurs du bruit.
133 *
134 * @param (double temps) le temps de mise a jour
135 */
137{
138 const Frontiere& front=la_frontiere_dis->frontiere();
139 int nb_faces=front.nb_faces();
140 DoubleTab& tab=valeurs_au_temps(temps);
141
142 if (nx!=0)
143 {
144 //
145 // N!=0 modelisation du bruit blanc (R. Howard)
146 //
147 double onde, bruit_blanc, pi, invx, d_x, tot_vel;
148 pi=2.*acos(0.);
149 invx=1./nx;
150 d_x=lx/nx;
151 for(int i=0; i<nb_faces; i++)
152 for(int j=0; j<nb_comp(); j++)
153 {
154 tot_vel=moyenne(j)+amplitude(j);
155 onde=0.;
156 for (int in_x=0; in_x<nx; in_x++)
157 onde=onde+sin((2.*pi*temps/(4*d_x+in_x*d_x)+(10.2*i+5.3*j))*tot_vel+5.6*pi);
158
159 bruit_blanc=onde*invx;
160 tab(i,j)=moyenne(j)+2.*amplitude(j)*bruit_blanc;
161 }
162 }
163 else
164 //
165 // N=0 donc modelisation bruit aleatoire
166 //
167 for(int i=0; i<nb_faces; i++)
168 for(int j=0; j<nb_comp(); j++)
169 {
170 tab(i,j)=moyenne(j)+amplitude(j)*(-1.+2.*drand48());
171 }
173}
174
175
classe Ch_front_var_instationnaire_indep Cette classe abstraite represente un champ sur une frontiere...
int lire_dimension(Entree &, const Nom &)
Verification de la dimension du champ Renvoie la dimension du champ.
classe Champ_front_base Classe de base pour la hierarchie des champs aux frontieres.
virtual DoubleTab & valeurs() override
Renvoie le tableau des valeurs du champ.
classe Champ_front_bruite Classe derivee de Champ_front_base qui represente les
void mettre_a_jour(double temps) override
Mise a jour du temps et retirage aleatoire des valeurs du bruit.
Champ_front_base & affecter_(const Champ_front_base &ch) override
Pas code !!
DoubleTab & valeurs_au_temps(double temps) override
Renvoie les valeurs au temps desire.
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
virtual void fixer_nb_comp(int i)
Fixe le nombre de composantes du champ.
virtual int nb_comp() const
Definition Field_base.h:56
int_t nb_faces() const
Renvoie le nombre de faces de la frontiere.
Definition Frontiere.h:59
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
virtual Sortie & printOn(Sortie &) const
Ecriture de l'objet sur un flot de sortie Methode a surcharger.
Definition Objet_U.cpp:282
static void exit(int exit_code=-1)
Routine de sortie de TRUST dans une region Kokkos.
Definition Process.cpp:455
Classe de base des flux de sortie.
Definition Sortie.h:52
_SIZE_ size() const
Definition TRUSTVect.tpp:45
virtual void echange_espace_virtuel(IsExchangeBlocking exchange_type=IsExchangeBlocking::DefaultBlocking, const std::string kernel_name="noname")