TrioCFD 1.9.8
TrioCFD documentation
Loading...
Searching...
No Matches
Op_Grad_P0_to_Face.cpp
1/****************************************************************************
2* Copyright (c) 2025, 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 <Check_espace_virtuel.h>
17#include <Echange_impose_base.h>
18#include <Op_Grad_P0_to_Face.h>
19#include <Dirichlet_homogene.h>
20#include <Neumann_homogene.h>
21#include <Domaine_Cl_VDF.h>
22#include <Neumann_paroi.h>
23#include <Periodique.h>
24#include <Dirichlet.h>
25#include <Perf_counters.h>
26
27Implemente_instanciable(Op_Grad_P0_to_Face,"Op_Grad_P0_to_Face",Op_Grad_VDF_Face_base);
28
29Sortie& Op_Grad_P0_to_Face::printOn(Sortie& s) const { return s << que_suis_je(); }
31
32void Op_Grad_P0_to_Face::dimensionner_blocs(matrices_t matrices, const tabs_t& semi_impl) const { return; }
33
34void Op_Grad_P0_to_Face::ajouter_blocs(matrices_t matrices, DoubleTab& secmem, const tabs_t& semi_impl) const
35{
36 /* if (sub_type(Pb_Multiphase, equation().probleme()))
37 {
38 Cerr << "Op_Grad_P0_to_Face::" << __func__ << " is not yet compatible with Pb_Multiphase !" << finl;
39 Cerr << "You should instead use Op_Grad_VDF_Face ... Otherwise you should add the contripution of alpha to the secmem ..." << finl;
40 Process::exit();
41 }
42 */
43 const DoubleTab& inco = semi_impl.count("pression") ? semi_impl.at("pression") : equation().inconnue().valeurs();
44 assert_espace_virtuel_vect(inco);
45 const Domaine_VDF& zvdf = le_dom_vdf.valeur();
46 const Domaine_Cl_VDF& zclvdf = la_zcl_vdf.valeur();
47 const DoubleVect& face_surfaces = zvdf.face_surfaces();
48 const DoubleTab& xv = zvdf.xv();
49
50
51 int N = inco.line_size();
52
53 // Boucle sur les bords pour traiter les conditions aux limites
54 for (int n_bord = 0; n_bord < zvdf.nb_front_Cl(); n_bord++)
55 for (int k = 0; k < N; k++)
56 {
57 const Cond_lim& la_cl = zclvdf.les_conditions_limites(n_bord);
58 const Front_VF& le_bord = ref_cast(Front_VF, la_cl->frontiere_dis());
59 const int ndeb = le_bord.num_premiere_face(), nfin = ndeb + le_bord.nb_faces();
60
61 if (sub_type(Periodique, la_cl.valeur())) // Correction periodicite
62 for (int num_face = ndeb; num_face < nfin; num_face++)
63 {
64 const int n0 = face_voisins(num_face, 0), n1 = face_voisins(num_face, 1);
65 const double dist = volume_entrelaces(num_face) / face_surfaces(num_face);
66 secmem(num_face, k) -= (inco(n1, k) - inco(n0, k)) / dist;
67 }
68 else if (sub_type(Dirichlet, la_cl.valeur())) // Cas CL Dirichlet
69 {
70 const Dirichlet& cl = ref_cast(Dirichlet, la_cl.valeur());
71 // XXX Elie Saikali : on calcule pas si champ_front_var n'est pas initialise
73 for (int num_face = ndeb, num_face_cl = 0; num_face < nfin; num_face++, num_face_cl++)
74 {
75 int n0 = face_voisins(num_face, 0);
76 if (n0 < 0)
77 n0 = face_voisins(num_face, 1);
78 const int ori = orientation(num_face);
79 secmem(num_face, k) -= (inco(n0, k) - cl.val_imp(num_face_cl, k)) / (xp(n0, ori) - xv(num_face, ori));
80 }
81 }
82 else if (sub_type(Dirichlet_homogene, la_cl.valeur())) // Cas Dirichlet homogene, i.e. valeur nulle a la paroi
83 for (int num_face = ndeb; num_face < nfin; num_face++)
84 {
85 int n0 = face_voisins(num_face, 0);
86 if (n0 < 0)
87 n0 = face_voisins(num_face, 1);
88 const int ori = orientation(num_face);
89 secmem(num_face, k) -= inco(n0, k) / (xp(n0, ori) - xv(num_face, ori));
90 }
91 else if (sub_type(Echange_impose_base, la_cl.valeur())) // Cas Echange_impose_base
92 {
93 const Echange_impose_base& cl = ref_cast(Echange_impose_base, la_cl.valeur());
94 if (cl.has_h_imp_grad())
95 for (int num_face = ndeb, num_face_cl = 0; num_face < nfin; num_face++, num_face_cl++)
96 {
97 int n0 = face_voisins(num_face, 0);
98 if (n0 < 0)
99 n0 = face_voisins(num_face, 1);
100 if (face_voisins(num_face, 0) >= 0)
101 secmem(num_face, k) -= (inco(n0, k) - cl.T_ext(num_face_cl, k)) * cl.h_imp_grad(num_face_cl, k); // Si bien oriente
102 else
103 secmem(num_face, k) += (inco(n0, k) - cl.T_ext(num_face_cl, k)) * cl.h_imp_grad(num_face_cl, k); // Si oriente a envers
104 }
105 else { /* Do nothing */ }
106 }
107 else if (sub_type(Neumann_paroi, la_cl.valeur())) // Cas Neumann_paroi
108 {
109 const Neumann_paroi& cl = ref_cast(Neumann_paroi, la_cl.valeur());
110 // XXX Elie Saikali : on calcule pas si champ_front_var n'est pas initialise
112 for (int num_face = ndeb, num_face_cl = 0; num_face < nfin; num_face++, num_face_cl++)
113 {
114 if (face_voisins(num_face, 0) >= 0)
115 secmem(num_face, k) -= cl.flux_impose(num_face_cl, k); // Si bien oriente
116 else
117 secmem(num_face, k) += cl.flux_impose(num_face_cl, k); // Si oriente a envers
118 }
119 }
120 else if (!sub_type(Neumann_homogene, la_cl.valeur())) // En Neumann homogene, i.e. symetrie, la derivee a la face est nulle => on fait rien
121 for (int num_face = ndeb; num_face < nfin; num_face++)
122 {
123 int n0 = face_voisins(num_face, 0);
124 if (n0 < 0)
125 n0 = face_voisins(num_face, 1);
126
127 const int ori = orientation(num_face);
128 int face_opposee = zvdf.elem_faces(n0, ori);
129 if (face_opposee == num_face)
130 face_opposee = zvdf.elem_faces(n0, ori + dimension);
131
132 int n1 = face_voisins(face_opposee, 0);
133 if ((n1 < 0) || ((n1 == n0) && face_voisins(face_opposee, 1) >= 0))
134 n1 = face_voisins(face_opposee, 1);
135
136 if (n1 != n0)
137 secmem(num_face, k) -= (inco(n1, k) - inco(n0, k)) / (xp(n1, ori) - xp(n0, ori));
138 }
139 }
140
141 // Boucle sur les faces internes
142 for (int num_face = zvdf.premiere_face_int(); num_face < zvdf.nb_faces(); num_face++)
143 for (int k = 0; k < N; k++)
144 {
145 const int n0 = face_voisins(num_face, 0), n1 = face_voisins(num_face, 1), ori = orientation(num_face);
146 secmem(num_face, k) -= (inco(n1, k) - inco(n0, k)) / (xp(n1, ori) - xp(n0, ori));
147 }
148
149 secmem.echange_espace_virtuel();
150}
DoubleTab & valeurs() override
Renvoie le tableau des valeurs du champ au temps courant.
virtual double get_temps_defaut() const
virtual bool has_valeurs_au_temps(double temps) const
Champ_front_base & champ_front()
classe Cond_lim Classe generique servant a representer n'importe quelle classe
Definition Cond_lim.h:31
Classe Dirichlet_homogene Cette classe est la classe de base de la hierarchie des conditions aux limi...
classe Dirichlet Cette classe est la classe de base de la hierarchie des conditions aux limites de ty...
Definition Dirichlet.h:31
virtual double val_imp(int i) const
Renvoie la valeur imposee sur la i-eme composante du champ a la frontiere au temps par defaut du cham...
Definition Dirichlet.cpp:35
class Domaine_Cl_VDF
const Cond_lim & les_conditions_limites(int) const
Renvoie la i-ieme condition aux limites.
class Domaine_VDF
Definition Domaine_VDF.h:64
virtual const DoubleVect & face_surfaces() const
Definition Domaine_VF.h:51
int nb_faces() const
renvoie le nombre global de faces.
Definition Domaine_VF.h:471
double xv(int num_face, int k) const
Definition Domaine_VF.h:76
int elem_faces(int i, int j) const
renvoie le numero de le ieme face de la maille num_elem la facon dont ces faces sont numerotees est
Definition Domaine_VF.h:543
int premiere_face_int() const
une face est interne ssi elle separe deux elements.
Definition Domaine_VF.h:463
int nb_front_Cl() const
classe Echange_impose_base: Cette condition limite sert uniquement pour l'equation d'energie.
virtual double T_ext(int num) const
Renvoie la valeur de la temperature imposee sur la i-eme composante du champ de frontiere.
virtual bool has_h_imp_grad() const
virtual double h_imp_grad(int num) const
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
virtual const Champ_Inc_base & inconnue() const =0
class Front_VF
Definition Front_VF.h:36
int nb_faces() const
Definition Front_VF.h:53
int num_premiere_face() const
Definition Front_VF.h:63
const Equation_base & equation() const
Renvoie la reference sur l'equation pointe par MorEqn::mon_equation.
Definition MorEqn.h:62
Classe Neumann_homogene Cette classe est la classe de base de la hierarchie des conditions aux limite...
Classe Neumann_paroi Cette condition limite correspond a un flux impose pour l'equation de.
virtual double flux_impose(int i) const
Renvoie la valeur du flux impose sur la i-eme composante du champ representant le flux a la frontiere...
Definition Neumann.cpp:35
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
class Op_Grad_P0_to_Face Cette classe represente l'operateur de gradient
void ajouter_blocs(matrices_t matrices, DoubleTab &secmem, const tabs_t &semi_impl) const override
void dimensionner_blocs(matrices_t matrices, const tabs_t &semi_impl) const override
classe Periodique Cette classe represente une condition aux limites periodique.
Definition Periodique.h:31
Classe de base des flux de sortie.
Definition Sortie.h:52
int line_size() const
Definition TRUSTVect.tpp:67
virtual void echange_espace_virtuel(IsExchangeBlocking exchange_type=IsExchangeBlocking::DefaultBlocking, const std::string kernel_name="noname")