TrioCFD 1.9.9_beta
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
19// XD field_uniform_keps_from_ud field_base field_uniform_keps_from_ud BRACE field which allows to impose on a domain K
20// XD_CONT and EPS values derived from U velocity and D hydraulic diameter
21Implemente_instanciable(Field_uniform_keps_from_ud,"Field_uniform_keps_from_ud",Champ_Uniforme);
22
23
24
25/*! @brief Imprime le champ sur flot de sortie.
26 *
27 * Imprime la taille du champ et la valeur (constante) sur le domaine
28 *
29 * @param (Sortie& os) un flot de sortie
30 * @return (Sortie&) le flot de sortie modifie
31 */
33{
34 const DoubleTab& tab=valeurs();
35 os << tab.size() << " ";
36 for(int i=0; i<tab.size(); i++)
37 os << tab(0,i);
38 return os;
39}
40
41
42/*! @brief Lit le champ a partir d'un flot d'entree.
43 *
44 * Format:
45 * Field_uniform_keps_from_ud nb_compo u_value d_value
46 * we expect that nb_compo=2 (one for u and one for d)
47 *
48 * @param (Entree& is) un flot d'entree
49 * @return (Entree& is) le flot d'entree modifie
50 */
52{
53 DoubleTab& tab=valeurs();
54 double u=0,d=0;
55 Param param(que_suis_je());
56 param.ajouter("U", &u, Param::REQUIRED); // XD_ADD_P floattant
57 // XD_CONT value of velocity specified in boundary condition.
58 param.ajouter("D", &d, Param::REQUIRED); // XD_ADD_P floattant
59 // XD_CONT value of hydraulic diameter specified in boundary condition
60 param.lire_avec_accolades(is);
61
62 int keps_size=2;// k and eps
63 tab.resize(1,keps_size);
64 fixer_nb_comp(keps_size);
65
66 //Now compute associated K and Eps by appling formula given by :
67 //http://en.wikipedia.org/wiki/Turbulence_kinetic_energy
68 //http://www.cfd-online.com/Wiki/Turbulence_length_
69 //http://support.esi-cfd.com/esi-users/turb_parameters/
70
71 //Hypothesis:
72 //Cmu=0.09 : k-eps parameter
73 //l=0.038 Dh where Dh is the hydraulic diameter
74 //Note that Cmu^(3/4)=0.1643
75 double I=0.05; //: initial turbulence intensity
76
77 //in 3D we have
78 //k = 3/2*(u*I)^2
79 //in 2D we have
80 //k = (u*I)^2
81 //with u = initial velocity magnitude
82 //eps = Cmu^(3/4) * k^(3/2) * l^(-1)
83 //where l is the turbulence length scale which can be expressed as 0.038 Dh
84 //Dh is the hydraulic diameter
85 double l=0.038*d;
86 double k = ( dimension == 2 ? 1 : 3./2. )*(u*I)*(u*I);
87
88 double eps = 0.1643*pow(k,1.5)/l;
89 tab(0,0)=k;
90 tab(0,1)=eps;
91
92 return is;
93}
DoubleTab & valeurs() override
Overrides Champ_base::valeurs() Returns the array of values.
Champ_Uniforme Represents a field that is constant in space and time.
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)
Sets the number of components of the field.
classe Field_uniform_keps_from_ud Classe derivee de Champ_uniforme which is for uniform fields
static int dimension
Definition Objet_U.h:94
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
virtual Sortie & printOn(Sortie &) const
Writes the object to an output stream. Virtual method to override.
Definition Objet_U.cpp:278
@ REQUIRED
Definition Param.h:115
Base class for output streams.
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