TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
EDO_Pression_th_VDF.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 <Loi_Etat_Multi_GP_WC.h>
17#include <Loi_Etat_Multi_GP_QC.h>
18#include <EDO_Pression_th_VDF.h>
19#include <Domaine_VDF.h>
20
21Implemente_base(EDO_Pression_th_VDF, "EDO_Pression_th_VDF", EDO_Pression_th_base);
22
24
26
27/*! @brief @brief Returns the computed pressure value that conserves mass.
28 *
29 * @return Computed pressure value.
30 */
31double EDO_Pression_th_VDF::masse_totale(double P, const DoubleTab& T)
32{
33 ToDo_Kokkos("critical");
34 int elem, nb_elem = le_dom->nb_elem();
35 const DoubleVect& volumes = le_dom->volumes();
36 const Loi_Etat_base& loi_ = ref_cast(Loi_Etat_base, le_fluide_->loi_etat().valeur());
37 double M = 0.;
38 if (!sub_type(Loi_Etat_Multi_GP_QC, loi_))
39 {
40 for (elem = 0; elem < nb_elem; elem++)
41 {
42 double v = volumes(elem);
43 M += v * loi_.calculer_masse_volumique(P, T[elem]);
44 }
45 }
46 else
47 {
48 const Loi_Etat_Multi_GP_QC& loi_mel_GP = ref_cast(Loi_Etat_Multi_GP_QC, loi_);
49 const DoubleTab& Masse_mol_mel = loi_mel_GP.masse_molaire();
50
51 for (elem = 0; elem < nb_elem; elem++)
52 {
53 double v = volumes(elem);
54 double r = 8.3143 / Masse_mol_mel(elem);
55 M += v * loi_mel_GP.calculer_masse_volumique(P, T[elem], r);
56 }
57 }
58 M = Process::mp_sum(M);
59 return M;
60}
61
62double EDO_Pression_th_VDF::masse_totale(const DoubleTab& P, const DoubleTab& T)
63{
64 ToDo_Kokkos("critical");
65 int elem, nb_elem = le_dom->nb_elem();
66 const DoubleVect& volumes = le_dom->volumes();
67 const Loi_Etat_base& loi_ = ref_cast(Loi_Etat_base, le_fluide_->loi_etat().valeur());
68 double M = 0.;
69 if (!sub_type(Loi_Etat_Multi_GP_WC, loi_))
70 {
71 for (elem = 0; elem < nb_elem; elem++)
72 {
73 double v = volumes(elem);
74 M += v * loi_.calculer_masse_volumique(P(elem), T(elem));
75 }
76 }
77 else
78 {
79 const Loi_Etat_Multi_GP_WC& loi_mel_GP = ref_cast(Loi_Etat_Multi_GP_WC, loi_);
80 const DoubleTab& Masse_mol_mel = loi_mel_GP.masse_molaire();
81
82 for (elem = 0; elem < nb_elem; elem++)
83 {
84 double v = volumes(elem);
85 double r = 8.3143 / Masse_mol_mel(elem);
86 M += v * loi_mel_GP.calculer_masse_volumique(P(elem), T(elem), r);
87 }
88 }
89 M = Process::mp_sum(M);
90 return M;
91}
92
93void EDO_Pression_th_VDF::calculer_grad(const DoubleTab& inco, DoubleTab& resu)
94{
95 int face, n0, n1, ori;
96 double coef;
97 const Domaine_VDF& dom = ref_cast(Domaine_VDF, le_dom.valeur());
98
99 const IntTab& face_voisins = dom.face_voisins();
100 const IntVect& orientation = dom.orientation();
101 const DoubleVect& porosite_surf = le_fluide_->porosite_face();
102 const DoubleTab& xp = dom.xp();
103 const DoubleVect& volume_entrelaces = le_dom->volumes_entrelaces();
104
105 // Loop over internal faces
106 ToDo_Kokkos("critical");
107 for (face = dom.premiere_face_int(); face < dom.nb_faces(); face++)
108 {
109 n0 = face_voisins(face, 0);
110 n1 = face_voisins(face, 1);
111 ori = orientation(face);
112 coef = volume_entrelaces(face) * porosite_surf(face);
113 coef = 1;
114 resu(face) += coef * (inco(n1) - inco(n0)) / (xp(n1, ori) - xp(n0, ori));
115 }
116}
class Domaine_VDF
Definition Domaine_VDF.h:61
int orientation(int) const override
inline DoubleVect& Domaine_VDF::porosite_face() {
int nb_faces() const
Returns the total number of faces.
Definition Domaine_VF.h:471
double xp(int num_elem, int k) const
Definition Domaine_VF.h:77
int premiere_face_int() const
A face is internal if and only if it separates two elements.
Definition Domaine_VF.h:463
int face_voisins(int num_face, int i) const
Returns the neighbouring element of num_face in direction i.
Definition Domaine_VF.h:418
class EDO_Pression_th_VDF This class represents the ODE for pressure associated with the
void calculer_grad(const DoubleTab &, DoubleTab &)
double masse_totale(double P, const DoubleTab &T) override
Returns the computed pressure value that conserves mass.
Base class of the ODE hierarchy for thermodynamic pressure associated with the scheme resolution for ...
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
State law class for a mixture of ideal gases in the quasi-compressible (QC) framework.
void calculer_masse_volumique() override
Recomputes the density.
State law class for a mixture of ideal gases in the weakly compressible (WC) framework.
void calculer_masse_volumique() override
Recomputes the density.
const DoubleTab & masse_molaire() const
Base class for the state law hierarchy defining a dilatable fluid.
virtual void calculer_masse_volumique()
Recomputes the density (masse volumique).
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
static double mp_sum(double)
Computes the sum of x over all processors in the current group.
Definition Process.cpp:145
Base class for output streams.
Definition Sortie.h:52