TrioCFD 1.9.8
TrioCFD documentation
Loading...
Searching...
No Matches
Terme_Source_Constituant_Vortex_VEF_Face.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#include <Terme_Source_Constituant_Vortex_VEF_Face.h>
16#include <Param.h>
17#include <Transport_Interfaces_FT_Disc.h>
18#include <communications.h>
19#include <Probleme_base.h>
20
21// XD Source_Constituant_Vortex source_base Source_Constituant_Vortex INHERITS_BRACE Special treatment for the reactor
22// XD_CONT of vortex effect where reagents are injected just below the free surface in the liquid phase
23Implemente_instanciable(Terme_Source_Constituant_Vortex_VEF_Face, "Source_Constituant_Vortex_VEF_P1NC", Terme_Source_Constituant_VEF_Face);
24
26{
27 Cerr << "Reading Terme_Source_Constituant_Vortex_VEF_Face\n"
28 << " (parameters for expression are (x,y,z,u,v,w) where u,v,w is the interface sensor position)" << finl;
29 senseur_.associer_pb(equation().probleme());
30 Param param(que_suis_je());
31 integrale_ = -1.;
32 param.ajouter("rayon_spot", &rayon_spot_, Param::REQUIRED); // XD_ADD_P floattant
33 // XD_CONT defines the radius of the concentration spot (tracer) injected in the fluid
34 param.ajouter("delta_spot", &delta_spot_, Param::REQUIRED); // XD_ADD_P list
35 // XD_CONT dimensions of the injection (segment). the syntax is dim val1 val2 [val3]
36 param.ajouter("integrale", &integrale_, Param::REQUIRED); // XD_ADD_P floattant
37 // XD_CONT the molar flowrate of injection
38 param.ajouter("debit", &debit_, Param::REQUIRED); // XD_ADD_P floattant
39 // XD_CONT a normalization of the molar flow rate. Advice: keep this value to 1.
40 param.ajouter("senseur_interface", &senseur_, Param::REQUIRED); // XD_ADD_P bloc_lecture
41 // XD_CONT This is to be defined for the concentration equation of the reagents only and in the bloc of the sources.
42 // XD_CONT Here the user defines the position of the reagents injection.
43
44 param.lire_avec_accolades_depuis(is);
45
46 const int dim = dimension;
47
48 if (delta_spot_.size_array() != dim || rayon_spot_ <= 0.)
49 {
50 Cerr << "Error: wrong segments dimension or nb_points_tests" << finl;
52 }
53 return is;
54}
55
57{
58 return os;
59}
60
64
66{
67 const Equation_base& eq = equation();
68 const Domaine_VEF& domaine_vef = ref_cast(Domaine_VEF, eq.domaine_dis());
69 const Domaine_Cl_VEF& domaine_cl_vef = ref_cast(Domaine_Cl_VEF, eq.domaine_Cl_dis());
70 const DoubleVect& volumes = domaine_vef.volumes_entrelaces();
71 const DoubleVect& volumes_cl = domaine_cl_vef.volumes_entrelaces_Cl();
72 const int premiere_face_std = domaine_vef.premiere_face_std();
73 const DoubleVect& porosites = equation().milieu().porosite_face();
74 const DoubleTab& xv = domaine_vef.xv(); // Coord des centres des faces
75 const int nb_faces = domaine_vef.nb_faces();
76 const int dim = Objet_U::dimension;
77 const ArrOfInt& faces_doubles = domaine_vef.faces_doubles();
78
79 // Pour chaque colonne de xv, a quelle variable faut-il attribuer cette valeur ?
80 // On met dans expr le terme source et on calcule l'integrale
81 double integrale = 0.;
82 const double omega = 4. / (rayon_spot_ * rayon_spot_);
83 for (int i_face = 0; i_face < nb_faces; i_face++)
84 {
85 double f;
86 {
87 double x = xv(i_face, 0) - position_spot_[0];
88 double y = xv(i_face, 1) - position_spot_[1];
89 double z = (dim == 3) ? (xv(i_face, 2) - position_spot_[2]) : 0.;
90 f = exp((-x*x-y*y-z*z) * omega);
91 }
92 double volume = (i_face < premiere_face_std) ? volumes_cl[i_face] : volumes[i_face];
93 double por = porosites(i_face);
94 double x = f * volume * por;
95 tab(i_face) = x;
96 double facteur = 1.;
97 if (faces_doubles[i_face])
98 facteur = 0.5;
99 integrale += x * facteur;
100 }
101
102 integrale = mp_sum(integrale);
103 if (integrale_ > 0. && integrale > 0.)
104 {
105 const double facteur = integrale_ / integrale;
106 tab *= facteur;
107 }
108 return tab;
109}
110
112{
113 const int n = tab.dimension(0);
114 // On doit de toutes facons creer un tableau temporaire pour pouvoir renormaliser la source.
115 // tableau tmp de la bonne taille mais non initialise:
116 DoubleTab tmp;
117 tmp.resize(n);
118 calculer(tmp);
119 for (int i = 0; i < n; i++)
120 tab(i) += tmp(i);
121 return tab;
122}
123
125{
126 senseur_.calculer_position(position_spot_);
128 Cerr << "Source_Constituant_Vortex "
129 << position_spot_[0] << " " << position_spot_[1] << " "
130 << ((position_spot_.size_array()==3)?position_spot_[2]:0.)
131 << finl;
132}
133
134void Terme_Source_Constituant_Vortex_VEF_Face::ajouter_terme_div_u(DoubleVect& secmem_pression, double dt) const
135{
136 const Equation_base& eq = equation();
137 const Domaine_VEF& domaine_vef = ref_cast(Domaine_VEF, eq.domaine_dis());
138 const DoubleVect& volumes = domaine_vef.volumes();
139 const DoubleTab& xp = domaine_vef.xp(); // Centres des elements
140 const int nb_elem = domaine_vef.domaine().nb_elem();
141 const int dim = xp.dimension(1);
142
143 // GF mieux comme cela
144 const int n = secmem_pression.size_totale();
145 ArrOfDouble tmp;
146 tmp.resize_array(n);
147 double integrale = 0.;
148 const double omega = 4. / (rayon_spot_ * rayon_spot_);
149 int elem;
150 for (elem = 0; elem < nb_elem; elem++)
151 {
152 double x = xp(elem, 0) - position_spot_[0];
153 double y = xp(elem, 1) - position_spot_[1];
154 double z = (dim == 3) ? (xp(elem, 2) - position_spot_[2]) : 0.;
155 double f = exp((-x*x-y*y-z*z) * omega) * volumes[elem];
156 integrale += f;
157 tmp[elem] = f;
158 }
159 integrale = mp_sum(integrale);
160 double facteur = 0.;
161 if (integrale > 0.)
162 // Le facteur 1./dimension est du a l'operateur div en vef
163 facteur = debit_ / Objet_U::dimension / integrale / dt;
164
165 Cerr << "Terme_Source_Constituant_Vortex_VEF_Face::ajouter_terme_div_u " << integrale << finl;
166 for (elem = 0; elem < nb_elem; elem++)
167 secmem_pression[elem] += tmp[elem] * facteur;
168}
int_t nb_elem() const
Definition Domaine.h:131
DoubleVect & volumes_entrelaces_Cl()
class Domaine_VEF
Definition Domaine_VEF.h:54
int premiere_face_std() const
Definition Domaine_VEF.h:80
int nb_faces() const
renvoie le nombre global de faces.
Definition Domaine_VF.h:471
DoubleVect & volumes_entrelaces()
Definition Domaine_VF.h:99
double xv(int num_face, int k) const
Definition Domaine_VF.h:76
ArrOfInt & faces_doubles()
renvoie 1 pour les faces appartenant a un bord perio ou un item commun, 0 par defaut
Definition Domaine_VF.h:567
double volumes(int i) const
Definition Domaine_VF.h:113
double xp(int num_elem, int k) const
Definition Domaine_VF.h:77
const Domaine & domaine() const
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
virtual Domaine_Cl_dis_base & domaine_Cl_dis()
Renvoie le domaine des conditions aux limite discretisee associee a l'equation.
Domaine_dis_base & domaine_dis()
Renvoie le domaine discretise associe a l'equation.
DoubleVect & porosite_face()
Definition Milieu_base.h:62
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
@ REQUIRED
Definition Param.h:115
classe Probleme_base C'est un Probleme_U qui n'est pas un couplage.
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
Classe de base des flux de sortie.
Definition Sortie.h:52
void resize_array(_SIZE_ new_size, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT)
void resize(_SIZE_ n, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT)
Definition TRUSTTab.tpp:469
_SIZE_ dimension(int d) const
Definition TRUSTTab.tpp:133
_SIZE_ size_totale() const
Definition TRUSTVect.tpp:61
class Terme_Source_Constituant_VEF_Face
void mettre_a_jour(double temps) override
DOES NOTHING - to override in derived classes.
void ajouter_terme_div_u(DoubleVect &secmem_pression, double dt) const