TrioCFD 1.9.8
TrioCFD documentation
Loading...
Searching...
No Matches
Field_uniform_keps_from_ud.cpp
1/****************************************************************************
2* Copyright (c) 2015 - 2016, 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 <Field_uniform_keps_from_ud.h>
17#include <Param.h>
18
19Implemente_instanciable(Field_uniform_keps_from_ud,"Field_uniform_keps_from_ud",Champ_Uniforme);
20
21
22
23/*! @brief Imprime le champ sur flot de sortie.
24 *
25 * Imprime la taille du champ et la valeur (constante) sur le domaine
26 *
27 * @param (Sortie& os) un flot de sortie
28 * @return (Sortie&) le flot de sortie modifie
29 */
31{
32 const DoubleTab& tab=valeurs();
33 os << tab.size() << " ";
34 for(int i=0; i<tab.size(); i++)
35 os << tab(0,i);
36 return os;
37}
38
39
40/*! @brief Lit le champ a partir d'un flot d'entree.
41 *
42 * Format:
43 * Field_uniform_keps_from_ud nb_compo u_value d_value
44 * we expect that nb_compo=2 (one for u and one for d)
45 *
46 * @param (Entree& is) un flot d'entree
47 * @return (Entree& is) le flot d'entree modifie
48 */
50{
51 DoubleTab& tab=valeurs();
52 double u=0,d=0;
53 Param param(que_suis_je());
54 param.ajouter("U", &u, Param::REQUIRED);
55 param.ajouter("D", &d, Param::REQUIRED);
56 param.lire_avec_accolades(is);
57
58 int keps_size=2;// k and eps
59 tab.resize(1,keps_size);
60 fixer_nb_comp(keps_size);
61
62 //Now compute associated K and Eps by appling formula given by :
63 //http://en.wikipedia.org/wiki/Turbulence_kinetic_energy
64 //http://www.cfd-online.com/Wiki/Turbulence_length_
65 //http://support.esi-cfd.com/esi-users/turb_parameters/
66
67 //Hypothesis:
68 //Cmu=0.09 : k-eps parameter
69 //l=0.038 Dh where Dh is the hydraulic diameter
70 //Note that Cmu^(3/4)=0.1643
71 double I=0.05; //: initial turbulence intensity
72
73 //in 3D we have
74 //k = 3/2*(u*I)^2
75 //in 2D we have
76 //k = (u*I)^2
77 //with u = initial velocity magnitude
78 //eps = Cmu^(3/4) * k^(3/2) * l^(-1)
79 //where l is the turbulence length scale which can be expressed as 0.038 Dh
80 //Dh is the hydraulic diameter
81 double l=0.038*d;
82 double k = ( dimension == 2 ? 1 : 3./2. )*(u*I)*(u*I);
83
84 double eps = 0.1643*pow(k,1.5)/l;
85 tab(0,0)=k;
86 tab(0,1)=eps;
87
88 return is;
89}
DoubleTab & valeurs() override
Surcharge Champ_base::valeurs() Renvoie le tableau des valeurs.
classe Champ_Uniforme Represente un champ constant dans l'espace et dans le temps.
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.
classe Field_uniform_keps_from_ud Classe derivee de Champ_uniforme which is for uniform fields
static int dimension
Definition Objet_U.h:99
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
@ REQUIRED
Definition Param.h:115
Classe de base des flux de sortie.
Definition Sortie.h:52
void resize(_SIZE_ n, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT)
Definition TRUSTTab.tpp:469
_SIZE_ size() const
Definition TRUSTVect.tpp:45