TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Terme_Source_Canal_perio_VDF_Face.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 <Terme_Source_Canal_perio_VDF_Face.h>
17#include <Fluide_Dilatable_base.h>
18#include <Pb_Thermohydraulique.h>
19#include <Neumann_sortie_libre.h>
20#include <Dirichlet_homogene.h>
21#include <Domaine_Cl_VDF.h>
22#include <Periodique.h>
23#include <Dirichlet.h>
24#include <Symetrie.h>
25#include <Domaine_VDF.h>
26
27Implemente_instanciable(Terme_Source_Canal_perio_VDF_Face, "Canal_perio_VDF_Face", Terme_Source_Canal_perio);
28Implemente_instanciable(Terme_Source_Canal_perio_QC_VDF_Face, "Canal_perio_QC_VDF_Face", Terme_Source_Canal_perio_VDF_Face);
29
31
33
35
37
39{
40 le_dom_VDF = ref_cast(Domaine_VDF, domaine_dis);
41 le_dom_Cl_VDF = ref_cast(Domaine_Cl_VDF, domaine_Cl_dis);
42}
43
44void Terme_Source_Canal_perio_VDF_Face::ajouter_blocs(matrices_t matrices, DoubleTab& secmem, const tabs_t& semi_impl) const
45{
46 const Domaine_VF& domaine_VF = le_dom_VDF.valeur();
47 const Domaine_Cl_dis_base& domaine_Cl_dis = le_dom_Cl_VDF.valeur();
48 const IntVect& orientation = le_dom_VDF->orientation();
49 const DoubleVect& porosite_surf = equation().milieu().porosite_face();
50 const DoubleVect& volumes_entrelaces = domaine_VF.volumes_entrelaces();
51 int ncomp;
52 ArrOfDouble s(source());
53
54 // Loop over boundary conditions to process boundary faces
55 int n_bord, ndeb, nfin;
56 for (n_bord = 0; n_bord < domaine_VF.nb_front_Cl(); n_bord++)
57 {
58
59 // for each boundary condition, check its type
60 // If Dirichlet or Symmetry face, do nothing
61 // If Neumann face, compute the contribution to the source term
62
63 const Cond_lim& la_cl = domaine_Cl_dis.les_conditions_limites(n_bord);
64
65 if (sub_type(Neumann_sortie_libre,la_cl.valeur()) || sub_type(Periodique, la_cl.valeur()) || sub_type(Symetrie, la_cl.valeur()))
66 {
67
68 const Front_VF& le_bord = ref_cast(Front_VF, la_cl->frontiere_dis());
69 ndeb = le_bord.num_premiere_face();
70 nfin = ndeb + le_bord.nb_faces();
71
72 for (int num_face = ndeb; num_face < nfin; num_face++)
73 {
74 double vol = volumes_entrelaces(num_face) * porosite_surf(num_face);
75 ncomp = orientation(num_face);
76 secmem(num_face) += s[ncomp] * vol;
77 }
78 }
79 else if ((sub_type(Dirichlet, la_cl.valeur())) || (sub_type(Dirichlet_homogene, la_cl.valeur())))
80 {
81 // do nothing
82 }
83 }
84
85 // Loop over internal faces
86 ndeb = domaine_VF.premiere_face_int();
87 int nb_faces = domaine_VF.nb_faces();
88 for (int num_face = ndeb; num_face < nb_faces; num_face++)
89 {
90 double vol = volumes_entrelaces(num_face) * porosite_surf(num_face);
91 ncomp = orientation(num_face);
92 secmem(num_face) += s[ncomp] * vol;
93 }
94
95}
96
98{
99 const Domaine_VF& domaine_VF = le_dom_VDF.valeur();
100 const Domaine_Cl_dis_base& domaine_Cl_dis = le_dom_Cl_VDF.valeur();
101 const DoubleTab& vitesse = equation().inconnue().valeurs();
102 const DoubleVect& porosite_surf = equation().milieu().porosite_face();
103 int ndeb, nfin, num_face;
104 int nb_bords = domaine_VF.nb_front_Cl();
105 for (int n_bord = 0; n_bord < nb_bords; n_bord++)
106 {
107 const Cond_lim& la_cl = domaine_Cl_dis.les_conditions_limites(n_bord);
108
109 if (sub_type(Periodique, la_cl.valeur()))
110 {
111 const Periodique& perio = ref_cast(Periodique, la_cl.valeur());
112 const Front_VF& le_bord = ref_cast(Front_VF, la_cl->frontiere_dis());
113 if (bord_periodique_ == le_bord.le_nom())
114 {
115 int axe = perio.direction_periodicite();
116 assert(axe == direction_ecoulement_);
117 debit_e = 0.;
118 ndeb = le_bord.num_premiere_face();
119 nfin = ndeb + le_bord.nb_faces() / 2;
120
121 if (equation().probleme().is_dilatable() == 1)
122 {
123 // In Quasi/Weakly Compressible mode, the mass flow rate must be conserved
124 // rather than the volumetric flow rate.
125 // This is why, in the QC/WC case, the velocity vectors are multiplied
126 // by the density discretized at the faces so that when integrating over the surface,
127 // a mass flow rate is obtained rather than a volumetric flow rate.
128 const DoubleTab& tab_rho_face = ref_cast(Fluide_Dilatable_base,equation().milieu()).rho_discvit();
129
130 for (num_face = ndeb; num_face < nfin; num_face++)
131 {
132 double debit_face = porosite_surf[num_face] * vitesse[num_face] * std::fabs(domaine_VF.face_normales(num_face, axe));
133 debit_e += tab_rho_face[num_face] * debit_face;
134 }
135 }
136 else
137 {
138 for (num_face = ndeb; num_face < nfin; num_face++)
139 {
140 double debit_face = porosite_surf[num_face] * vitesse[num_face] * std::fabs(domaine_VF.face_normales(num_face, axe));
141 debit_e += debit_face;
142 }
143 }
144 }
145 }
146 }
147 debit_e = mp_sum(debit_e);
148}
149
DoubleTab & valeurs() override
Returns the array of field values at the current time.
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
class Domaine_Cl_VDF
class Domaine_Cl_dis_base Domaine_Cl_dis_base objects represent discretized boundary conditions
const Cond_lim & les_conditions_limites(int) const
Returns the i-th boundary condition.
class Domaine_VDF
Definition Domaine_VDF.h:61
class Domaine_VF
Definition Domaine_VF.h:44
int nb_faces() const
Returns the total number of faces.
Definition Domaine_VF.h:471
DoubleVect & volumes_entrelaces()
Definition Domaine_VF.h:99
virtual double face_normales(int face, int comp) const
Definition Domaine_VF.h:47
int premiere_face_int() const
A face is internal if and only if it separates two elements.
Definition Domaine_VF.h:463
class Domaine_dis_base This class is the base of the hierarchy of discretized domains.
int nb_front_Cl() const
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
virtual const Milieu_base & milieu() const =0
virtual const Champ_Inc_base & inconnue() const =0
Base class for a dilatable fluid, inheriting from Fluide_base.
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 Nom & le_nom() const override
Returns the name of the geometric boundary.
DoubleVect & porosite_face()
Definition Milieu_base.h:62
const Equation_base & equation() const
Returns the reference to the equation pointed to by MorEqn::mon_equation.
Definition MorEqn.h:62
Neumann_sortie_libre This class represents an open boundary without imposed velocity.
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 Periodique This class represents a periodic boundary condition.
Definition Periodique.h:31
int direction_periodicite() const
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
Symetrie On symmetry faces, the following properties hold:
Definition Symetrie.h:37
void ajouter_blocs(matrices_t matrices, DoubleTab &secmem, const tabs_t &semi_impl) const override
void associer_domaines(const Domaine_dis_base &, const Domaine_Cl_dis_base &) override
Source term to keep a constant flow rate in a channel with periodic boundary conditions.
ArrOfDouble source() const
Term source calculation (called by VDF and VEF implementations) TODO: returning an ArrOfDouble is baa...