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
21Implemente_instanciable(Terme_Source_Constituant_Vortex_VEF_Face, "Source_Constituant_Vortex_VEF_P1NC", Terme_Source_Constituant_VEF_Face);
22
24{
25 Cerr << "Reading Terme_Source_Constituant_Vortex_VEF_Face\n"
26 << " (parameters for expression are (x,y,z,u,v,w) where u,v,w is the interface sensor position)" << finl;
27 senseur_.associer_pb(equation().probleme());
28 Param param(que_suis_je());
29 integrale_ = -1.;
30 param.ajouter("rayon_spot", &rayon_spot_, Param::REQUIRED);
31 param.ajouter("delta_spot", &delta_spot_, Param::REQUIRED);
32 param.ajouter("integrale", &integrale_, Param::REQUIRED);
33 param.ajouter("debit", &debit_, Param::REQUIRED);
34 param.ajouter("senseur_interface", &senseur_, Param::REQUIRED);
35
36 param.lire_avec_accolades_depuis(is);
37
38 const int dim = dimension;
39
40 if (delta_spot_.size_array() != dim || rayon_spot_ <= 0.)
41 {
42 Cerr << "Error: wrong segments dimension or nb_points_tests" << finl;
44 }
45 return is;
46}
47
49{
50 return os;
51}
52
56
58{
59 const Equation_base& eq = equation();
60 const Domaine_VEF& domaine_vef = ref_cast(Domaine_VEF, eq.domaine_dis());
61 const Domaine_Cl_VEF& domaine_cl_vef = ref_cast(Domaine_Cl_VEF, eq.domaine_Cl_dis());
62 const DoubleVect& volumes = domaine_vef.volumes_entrelaces();
63 const DoubleVect& volumes_cl = domaine_cl_vef.volumes_entrelaces_Cl();
64 const int premiere_face_std = domaine_vef.premiere_face_std();
65 const DoubleVect& porosites = equation().milieu().porosite_face();
66 const DoubleTab& xv = domaine_vef.xv(); // Coord des centres des faces
67 const int nb_faces = domaine_vef.nb_faces();
68 const int dim = Objet_U::dimension;
69 const ArrOfInt& faces_doubles = domaine_vef.faces_doubles();
70
71 // Pour chaque colonne de xv, a quelle variable faut-il attribuer cette valeur ?
72 // On met dans expr le terme source et on calcule l'integrale
73 double integrale = 0.;
74 const double omega = 4. / (rayon_spot_ * rayon_spot_);
75 for (int i_face = 0; i_face < nb_faces; i_face++)
76 {
77 double f;
78 {
79 double x = xv(i_face, 0) - position_spot_[0];
80 double y = xv(i_face, 1) - position_spot_[1];
81 double z = (dim == 3) ? (xv(i_face, 2) - position_spot_[2]) : 0.;
82 f = exp((-x*x-y*y-z*z) * omega);
83 }
84 double volume = (i_face < premiere_face_std) ? volumes_cl[i_face] : volumes[i_face];
85 double por = porosites(i_face);
86 double x = f * volume * por;
87 tab(i_face) = x;
88 double facteur = 1.;
89 if (faces_doubles[i_face])
90 facteur = 0.5;
91 integrale += x * facteur;
92 }
93
94 integrale = mp_sum(integrale);
95 if (integrale_ > 0. && integrale > 0.)
96 {
97 const double facteur = integrale_ / integrale;
98 tab *= facteur;
99 }
100 return tab;
101}
102
104{
105 const int n = tab.dimension(0);
106 // On doit de toutes facons creer un tableau temporaire pour pouvoir renormaliser la source.
107 // tableau tmp de la bonne taille mais non initialise:
108 DoubleTab tmp;
109 tmp.resize(n);
110 calculer(tmp);
111 for (int i = 0; i < n; i++)
112 tab(i) += tmp(i);
113 return tab;
114}
115
117{
118 senseur_.calculer_position(position_spot_);
120 Cerr << "Source_Constituant_Vortex "
121 << position_spot_[0] << " " << position_spot_[1] << " "
122 << ((position_spot_.size_array()==3)?position_spot_[2]:0.)
123 << finl;
124}
125
126void Terme_Source_Constituant_Vortex_VEF_Face::ajouter_terme_div_u(DoubleVect& secmem_pression, double dt) const
127{
128 const Equation_base& eq = equation();
129 const Domaine_VEF& domaine_vef = ref_cast(Domaine_VEF, eq.domaine_dis());
130 const DoubleVect& volumes = domaine_vef.volumes();
131 const DoubleTab& xp = domaine_vef.xp(); // Centres des elements
132 const int nb_elem = domaine_vef.domaine().nb_elem();
133 const int dim = xp.dimension(1);
134
135 // GF mieux comme cela
136 const int n = secmem_pression.size_totale();
137 ArrOfDouble tmp;
138 tmp.resize_array(n);
139 double integrale = 0.;
140 const double omega = 4. / (rayon_spot_ * rayon_spot_);
141 int elem;
142 for (elem = 0; elem < nb_elem; elem++)
143 {
144 double x = xp(elem, 0) - position_spot_[0];
145 double y = xp(elem, 1) - position_spot_[1];
146 double z = (dim == 3) ? (xp(elem, 2) - position_spot_[2]) : 0.;
147 double f = exp((-x*x-y*y-z*z) * omega) * volumes[elem];
148 integrale += f;
149 tmp[elem] = f;
150 }
151 integrale = mp_sum(integrale);
152 double facteur = 0.;
153 if (integrale > 0.)
154 // Le facteur 1./dimension est du a l'operateur div en vef
155 facteur = debit_ / Objet_U::dimension / integrale / dt;
156
157 Cerr << "Terme_Source_Constituant_Vortex_VEF_Face::ajouter_terme_div_u " << integrale << finl;
158 for (elem = 0; elem < nb_elem; elem++)
159 secmem_pression[elem] += tmp[elem] * facteur;
160}
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