TrioCFD 1.9.9_beta
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 // Problem: nb_comp equals 2 but we only want one 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); // compute the fgrad coefficients required for the field computation at faces
67 update_ge(); // compute the field at elements from the field at 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(); // boundary conditions for the field to differentiate
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(); // boundary conditions for the field to differentiate
87
88 /* const IntTab& fcl = fcl_g;
89 const Conds_lim& cls = cls_g;*/
90 int f, n;
91 int d_U; //velocity coordinate
92 int D = dimension;
93 int N = champ_a_deriver().valeurs().line_size(); //number of 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++) // velocity coordinates and 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) //contribution from an 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) //contribution from a boundary: only Dirichlet contributes
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
Overrides Champ_base::valeurs() Returns the array of values.
: class Champ_Face_PolyMAC_MPFA
const IntTab & fcl() const
class Champ_Fonc_base Base class of fields that are functions of a calculated quantity
virtual const Domaine & domaine() const
virtual const Domaine_VF & domaine_vf() const
void mettre_a_jour(double temps) override
Time update of the field.
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
Returns field values at instant t-i.
const Domaine_Cl_dis_base & domaine_Cl_dis() const
DoubleTab & valeurs() override
Returns the array of field values at the current time.
double temps() const
Returns the time of the field.
class Conds_lim This class represents a vector of boundary conditions.
Definition Conds_lim.h:32
Dirichlet This class is the base class of the hierarchy of Dirichlet-type boundary conditions.
Definition Dirichlet.h:31
const Cond_lim & les_conditions_limites(int) const
Returns the i-th boundary condition.
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
const Nom & le_nom() const override
Returns the name of the field.
int nb_compo_
Definition Field_base.h:95
: This class is an OWN_PTR but the pointed object is shared among multiple
Definition MD_Vector.h:48
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
Base class for output streams.
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.
void update_ge2(DoubleTab &val, int incr=0) const
int fixer_nb_valeurs_nodales(int n) override
Sets the number of degrees of freedom per component.
void mettre_a_jour(double) override
Time update of the field.
virtual Champ_Face_PolyMAC_MPFA & champ_a_deriver()