TrioCFD 1.9.8
TrioCFD documentation
Loading...
Searching...
No Matches
Source_Trainee.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 <Source_Trainee.h>
17#include <Probleme_base.h>
18#include <Fluide_Diphasique.h>
19
20Implemente_instanciable(Source_Trainee,"Trainee",Source_Action_Particules);
21
22
24{
25 return s << que_suis_je() ;
26}
27
28
30{
31 return s;
32}
33
34//L expression codee est precisee dans l entete de la classe
35DoubleTab& Source_Trainee::ajouter(DoubleTab& resu) const
36{
37
38 const DoubleTab& vitesse_f = vitesse_fluide();
39 const DoubleTab& rho_f = rho_fluide();
40 const DoubleTab& visco_dyn_f = visco_dyn_fluide();
41 const DoubleTab& vitesse_p = vitesse_particules();
42 const DoubleTab& diametre_p = diametre_particules();
43 const DoubleTab& rho_p = rho_particules();
44
45 double grav = 0.;
46 double sigma = 0.;
47 double Cd_p, Cd_diph;
48 Cd_p = 0.;
49 Cd_diph = 0.;
50
51 const Equation_base& eq_ns = equation().probleme().equation(0);
52 const Milieu_base& mil = eq_ns.milieu();
53 if (sub_type(Fluide_Diphasique,mil))
54 {
55 const Fluide_Diphasique& fluide = ref_cast(Fluide_Diphasique,mil);
56 if (fluide.a_gravite())
57 {
58 const DoubleTab& gravite = fluide.gravite().valeurs();
59 assert((gravite.nb_dim() == 2) && (gravite.dimension(1) == dimension));
60 for (int j=0; j<dimension; j++)
61 grav += gravite(0,j)*gravite(0,j);
62 grav = sqrt(grav);
63 }
64
65 ////grav=9.81;
66
67 sigma = fluide.sigma();
68 }
69
70 const int dim0 = vitesse_p.dimension(0);
71 const int dim1 = vitesse_p.dimension(1);
72 assert(vitesse_p.dimension(0)==vitesse_f.dimension(0));
73
74 double norme_delta_v, Reynolds_p, Cd, Surface;
75 using Kokkos::numbers::pi;
76
77 DoubleVect deltav(Objet_U::dimension);
78
79 for (int i=0; i<dim0; i++)
80 {
81 norme_delta_v = 0.;
82 for (int j=0; j<dim1; j++)
83 {
84 deltav[j] = vitesse_p(i,j)-vitesse_f(i,j);
85 norme_delta_v += deltav[j]*deltav[j];
86 }
87 norme_delta_v = sqrt(norme_delta_v);
88
89 Reynolds_p = rho_f(i)*norme_delta_v*diametre_p(i,0)/visco_dyn_f(i);
90 Cd_p =24/std::max(1e-12,Reynolds_p);
91
92 if (sub_type(Fluide_Diphasique,mil))
93 {
94 Cd_diph = std::min((2./3.)*sqrt((diametre_p(i,0)*diametre_p(i,0))*grav*(std::fabs(rho_f(i)-rho_p(i,0)))/sigma),8./3.);
95 }
96
97 Cd = std::max(Cd_p,Cd_diph);
98
99 Surface = (dim1==3?pi*diametre_p(i,0)*diametre_p(i,0)/4.:diametre_p(i,0));
100
101 for (int j=0; j<dim1; j++)
102 resu(i,j) += -0.5*Cd*rho_f(i)*Surface*norme_delta_v*deltav[j];
103 }
104
105 return resu;
106}
107
108
109DoubleTab& Source_Trainee::calculer(DoubleTab& resu) const
110{
111 resu = 0;
112 return ajouter(resu);
113}
114
115
DoubleTab & valeurs() override
Surcharge Champ_base::valeurs() Renvoie le tableau des valeurs.
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
classe Equation_base Le role d'une equation est le calcul d'un ou plusieurs champs....
virtual const Milieu_base & milieu() const =0
Probleme_base & probleme()
Renvoie le probleme associe a l'equation.
classe Milieu_base Cette classe est la base de la hierarchie des milieux (physiques)
Definition Milieu_base.h:50
virtual int a_gravite() const
Renvoie 1 si la gravite a ete initialisee.
virtual const Champ_Don_base & gravite() const
Renvoie la gravite du milieu si elle a ete associe provoque une erreur sinon.
const Equation_base & equation() const
Renvoie la reference sur l'equation pointe par MorEqn::mon_equation.
Definition MorEqn.h:62
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
virtual const Equation_base & equation(int) const =0
Classe de base des flux de sortie.
Definition Sortie.h:52
Classe Source_Action_Particules Classe mere des classes designant une force exercee par le fluide sur...
const DoubleTab & rho_particules() const
const DoubleTab & vitesse_fluide() const
const DoubleTab & visco_dyn_fluide() const
const DoubleTab & rho_fluide() const
const DoubleTab & vitesse_particules() const
const DoubleTab & diametre_particules() const
class Source_Trainee
DoubleTab & calculer(DoubleTab &) const override
DoubleTab & ajouter(DoubleTab &) const override
int nb_dim() const
Definition TRUSTTab.h:199
_SIZE_ dimension(int d) const
Definition TRUSTTab.tpp:133