TrioCFD 1.9.9_beta
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 // Loop over boundaries to process boundary conditions
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 : skip computation if champ_front_var is not initialized
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())) // Homogeneous Dirichlet case, i.e. zero value at the wall
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); // If correctly oriented
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); // If oriented in reverse
104 }
105 else { /* Do nothing */ }
106 }
107 else if (sub_type(Neumann_paroi, la_cl.valeur())) // Neumann_paroi case
108 {
109 const Neumann_paroi& cl = ref_cast(Neumann_paroi, la_cl.valeur());
110 // XXX Elie Saikali : skip computation if champ_front_var is not initialized
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); // If correctly oriented
116 else
117 secmem(num_face, k) += cl.flux_impose(num_face_cl, k); // If oriented in reverse
118 }
119 }
120 else if (!sub_type(Neumann_homogene, la_cl.valeur())) // In homogeneous Neumann, i.e. symmetry, the face derivative is zero => do nothing
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 // Loop over internal faces
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
Returns the array of field values at the current time.
virtual double get_temps_defaut() const
virtual bool has_valeurs_au_temps(double temps) const
Champ_front_base & champ_front()
class Cond_lim Generic class used to represent any class
Definition Cond_lim.h:31
Classe Dirichlet_homogene This class is the base class of the hierarchy of homogeneous Dirichlet-type...
Dirichlet This class is the base class of the hierarchy of Dirichlet-type boundary conditions.
Definition Dirichlet.h:31
virtual double val_imp(int i) const
Returns the imposed value on the i-th component of the field at the boundary at the default time of c...
Definition Dirichlet.cpp:35
class Domaine_Cl_VDF
const Cond_lim & les_conditions_limites(int) const
Returns the i-th boundary condition.
class Domaine_VDF
Definition Domaine_VDF.h:61
virtual const DoubleVect & face_surfaces() const
Definition Domaine_VF.h:51
int nb_faces() const
Returns the total number of 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
Returns the index of the i-th face of element num_elem; the face numbering convention is.
Definition Domaine_VF.h:542
int premiere_face_int() const
A face is internal if and only if it separates two elements.
Definition Domaine_VF.h:463
int nb_front_Cl() const
Echange_impose_base: This boundary condition is used only for the energy equation.
virtual double T_ext(int num) const
Returns the value of the imposed temperature on the i-th component of the boundary field.
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
Returns the reference to the equation pointed to by MorEqn::mon_equation.
Definition MorEqn.h:62
Classe Neumann_homogene This class is the base class of the hierarchy of homogeneous Neumann-type bou...
Classe Neumann_paroi This boundary condition corresponds to an imposed flux for the.
virtual double flux_impose(int i) const
Returns the value of the imposed flux on the i-th component of the field representing the flux at the...
Definition Neumann.cpp:35
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
class Op_Grad_P0_to_Face This class represents the gradient operator
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
class Periodique This class represents a periodic boundary condition.
Definition Periodique.h:31
Base class for output streams.
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")