TrioCFD 1.9.8
TrioCFD documentation
Loading...
Searching...
No Matches
grad_Champ_Face_PolyMAC_MPFA.cpp
1/****************************************************************************
2* Copyright (c) 2024, 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 <grad_Champ_Face_PolyMAC_MPFA.h>
17#include <Champ_Fonc_Elem_PolyMAC_CDO.h>
18#include <Frottement_impose_base.h>
19#include <Champ_Face_PolyMAC_MPFA.h>
20
21
22#include <Dirichlet.h>
23#include <EChaine.h>
24
25Implemente_instanciable(grad_Champ_Face_PolyMAC_MPFA, "grad_Champ_Face_PolyMAC_MPFA", Champ_Fonc_Face_PolyMAC_CDO);
26
27Sortie& grad_Champ_Face_PolyMAC_MPFA::printOn(Sortie& s) const { return s << que_suis_je() << " " << le_nom(); }
28
30
32{
33 const Champ_Fonc_base& self = ref_cast(Champ_Fonc_base, *this);
35
36 assert(n < 0);
37
38 const MD_Vector& md = domaine.mdv_ch_face;
39 // Probleme: nb_comp vaut 2 mais on ne veut qu'une dimension !!!
40 // HACK :
41 int old_nb_compo = nb_compo_;
44 nb_compo_ = old_nb_compo;
45 return n;
46}
47
49{
50 if (temps() != tps)
51 me_calculer(tps);
53}
54
56{
57 is_init = 1;
58 return;
59}
60
62{
63 if (!is_init)
64 init_grad();
65 update_tab_grad(0); // calcule les coefficients de fgrad requis pour le calcul du champ aux faces
67 update_ge(); // calcule le champ aux elements a partir du champ aux faces
69}
70
72{
73 const IntTab& f_cl = champ_a_deriver().fcl();
75 const Conds_lim& cls = champ_a_deriver().domaine_Cl_dis().les_conditions_limites(); // CAL du champ a deriver
76
77 domaine.fgrad(champ_a_deriver().valeurs().line_size(), 0, cls, f_cl, nullptr, nullptr, 1, full_stencil, gradve_d, gradve_e, gradve_w);
78}
79
81{
84
85 const IntTab& fcl = champ_a_deriver().fcl();
86 const Conds_lim& cls = ch.domaine_Cl_dis().les_conditions_limites(); // CAL du champ a deriver
87
88 /* const IntTab& fcl = fcl_g;
89 const Conds_lim& cls = cls_g;*/
90 int f, n;
91 int d_U; //coordonnee de la vitesse
92 int D = dimension;
93 int N = champ_a_deriver().valeurs().line_size(); //nombre phases
94 int ne_tot = domaine.nb_elem_tot(), nf_tot = domaine.nb_faces_tot(), nf = domaine.nb_faces();
95
96 const DoubleTab& tab_ch = ch.passe();
97 DoubleTab& val = valeurs();
98
99 for (f = 0; f < nf; f++)
100 {
101 for (d_U = 0; d_U < D; d_U++)
102 for (n = 0; n < N; n++) // Coordonnees de la vitesse et phase
103 {
104 val(f, d_U + n * D) = 0;
105 for (int j = gradve_d(f); j < gradve_d(f + 1); j++)
106 {
107 int e = gradve_e(j);
108 int f_bord;
109 if (e < ne_tot) //contrib d'un element
110 {
111 double val_e = tab_ch(nf_tot + d_U + e * D, n);
112 val(f, d_U + n * D) += gradve_w(j, n) * val_e;
113 }
114 else if (fcl(f_bord = e - ne_tot, 0) == 3) //contrib d'un bord : seul Dirichlet contribue
115 {
116 double val_f_bord = ref_cast(Dirichlet, cls[fcl(f_bord, 1)].valeur()).val_imp(fcl(f_bord, 2), N * d_U + n);
117 val(f, d_U + n * D) += gradve_w(j, n) * val_f_bord;
118 }
119 }
120 }
121 }
122
123}
124
126{
127 DoubleTab& val = valeurs();
129 const DoubleVect& ve = domaine.volumes(), &fs = domaine.face_surfaces();
130 const IntTab& e_f = domaine.elem_faces(), &f_e = domaine.face_voisins();
131 const DoubleTab& xp = domaine.xp(), &xv = domaine.xv();
132 int e, f, j, d, D = dimension, n, N = val.line_size(), ne_tot = domaine.nb_elem_tot(), nf_tot = domaine.nb_faces_tot();
133 double fac;
134
135 for (e = 0; e < ne_tot; e++)
136 {
137 for (d = 0; d < D; d++)
138 for (n = 0; n < N; n++)
139 val(nf_tot + D * e + d, n) = 0;
140 for (j = 0; j < e_f.dimension(1) && (f = e_f(e, j)) >= 0; j++)
141 for (fac = (e == f_e(f, 0) ? 1 : -1) * fs(f) / ve(e), d = 0; d < D; d++)
142 for (n = 0; n < N; n++)
143 val(nf_tot + D * e + d, n) += fac * (xv(f, d) - xp(e, d)) * val(f, n);
144 }
145}
146
150
151void grad_Champ_Face_PolyMAC_MPFA::update_ge2(DoubleTab& val, int incr) const
152{
153}
DoubleTab & valeurs() override
Surcharge Champ_base::valeurs() Renvoie le tableau des valeurs.
: class Champ_Face_PolyMAC_MPFA
const IntTab & fcl() const
classe Champ_Fonc_base Classe de base des champs qui sont fonction d'une grandeur calculee
virtual const Domaine & domaine() const
virtual const Domaine_VF & domaine_vf() const
void mettre_a_jour(double temps) override
Mise a jour en temps du champ.
virtual void creer_tableau_distribue(const MD_Vector &, RESIZE_OPTIONS=RESIZE_OPTIONS::COPY_INIT)
const Domaine_dis_base & domaine_dis_base() const override
DoubleTab & passe(int i=1) override
Renvoie les valeurs du champs a l'instant t-i.
const Domaine_Cl_dis_base & domaine_Cl_dis() const
DoubleTab & valeurs() override
Renvoie le tableau des valeurs du champ au temps courant.
double temps() const
Renvoie le temps du champ.
classe Conds_lim Cette classe represente un vecteur de conditions aux limites.
Definition Conds_lim.h:32
classe Dirichlet Cette classe est la classe de base de la hierarchie des conditions aux limites de ty...
Definition Dirichlet.h:31
const Cond_lim & les_conditions_limites(int) const
Renvoie la i-ieme condition aux limites.
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
const Nom & le_nom() const override
Renvoie le nom du champ.
int nb_compo_
Definition Field_base.h:95
: Cette classe est un OWN_PTR mais l'objet pointe est partage entre plusieurs
Definition MD_Vector.h:48
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
Classe de base des flux de sortie.
Definition Sortie.h:52
_SIZE_ dimension(int d) const
Definition TRUSTTab.tpp:133
int line_size() const
Definition TRUSTVect.tpp:67
virtual void echange_espace_virtuel(IsExchangeBlocking exchange_type=IsExchangeBlocking::DefaultBlocking, const std::string kernel_name="noname")
class grad_Champ_Face_PolyMAC_MPFA for the calculation of the gradient This field is a Champ_Fonc_Fac...
void update_ge2(DoubleTab &val, int incr=0) const
int fixer_nb_valeurs_nodales(int n) override
Fixe le nombre de degres de liberte par composante.
void mettre_a_jour(double) override
Mise a jour en temps du champ.
virtual Champ_Face_PolyMAC_MPFA & champ_a_deriver()