TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Perte_Charge_Singuliere_VEF_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 <Perte_Charge_Singuliere_VEF_Face.h>
17#include <Domaine_VEF.h>
18#include <Equation_base.h>
19#include <Probleme_base.h>
20#include <Motcle.h>
21#include <Domaine.h>
22#include <Matrice_Morse.h>
23
24Implemente_instanciable(Perte_Charge_Singuliere_VEF_Face,"Perte_Charge_Singuliere_VEF_P1NC",Perte_Charge_VEF_Face);
25
26//// printOn
27//
28
30{
31 return s << que_suis_je() ;
32}
33
34//// readOn
35//
36
38{
41 if (regul_) //output file if regulation is active
42 {
43 bilan().resize(3); //K deb cible
44 set_fichier(Nom("K_") + identifiant_);
45 set_description(Nom("Regulation du Ksing de la surface ") + identifiant_ + "\nt K deb cible");
46 }
47 return s;
48}
49
50
51/////////////////////////////////////////////////////////////////////
52//
53// Implementation of member functions
54//
55// of class Perte_Charge_Singuliere_VEF_Face
56//
57////////////////////////////////////////////////////////////////////
58
60{
61 const Domaine& le_domaine = equation().probleme().domaine();
62 const Domaine_VEF& domaine_VEF = ref_cast(Domaine_VEF,equation().domaine_dis());
63 int taille_bloc = domaine_VEF.nb_elem();
64 num_faces.resize(taille_bloc);
65 lire_surfaces(s,le_domaine,domaine_VEF,num_faces, sgn);
66 // int nfac_tot = mp_sum(num_faces.size());
67 int nfac_tot = (int)mp_max(num_faces.size()); // not to count several (number of processes) times the same face
68
69 if(je_suis_maitre())
70 {
71 Cerr << "Faces number found in Perte_Charge_Singuliere_VEF_Face : " << nfac_tot << finl;
72
73 if (nfac_tot==0)
74 {
75 Cerr << "Error when defining the surface plane for the singular porosity :" << finl;
76 Cerr << "No mesh faces has been found for the surface plane." << finl;
77 Cerr << "Check the coordinate of the surface plane which should match mesh coordinates." << finl;
78 exit();
79 }
80 }
81}
82
83DoubleTab& Perte_Charge_Singuliere_VEF_Face::ajouter(DoubleTab& resu) const
84{
85 const Domaine_VEF& domaine_VEF = le_dom_VEF.valeur();
86 //const DoubleVect& volumes_entrelaces = domaine_VEF.volumes_entrelaces();
87 const DoubleVect& porosite_surf = equation().milieu().porosite_face();
88 const DoubleTab& vit = la_vitesse->valeurs();
89
90 int nb_faces = num_faces.size();
91 int numfa;
92 double Ud; // bulk velocity
93 double area;
94 double coefK; // pressure loss
95
96 for (int i=0; i<nb_faces; i++)
97 {
98 numfa = num_faces[i];
99
100 for (int j=0; j<dimension; j++)
101 {
102 Ud = vit(numfa,j)*porosite_surf[numfa];
103 // area=domaine_VEF.face_surfaces(numfa);
104 area=direction_perte_charge() < 0 ? domaine_VEF.face_surfaces(numfa) : std::fabs(domaine_VEF.face_normales(numfa,direction_perte_charge())); // Taking account of inclined plane
105 coefK=K();
106 // if (j!=direction_perte_charge()) coefK=0.;
107 resu(numfa,j) -= 0.5*coefK*Ud*std::fabs(Ud)*area*porosite_surf[numfa];
108 }
109 }
110 return resu;
111}
112
114{
115 const Domaine_VEF& domaine_VEF = le_dom_VEF.valeur();
116 const DoubleVect& porosite_surf = equation().milieu().porosite_face();
117 const DoubleTab& vit = la_vitesse->valeurs();
118
119 int nb_faces = num_faces.size();
120 int numfa;
121 double Ud; // bulk velocity
122 double area;
123 double coefK; // pressure loss
124
125 for (int i=0; i<nb_faces; i++)
126 {
127 numfa = num_faces[i];
128
129 for (int j=0; j<dimension; j++)
130 {
131 // Ud = vit(numfa,j)*porosite_surf[numfa];
132 Ud = porosite_surf[numfa];
133 double Ud2= vit(numfa,j)*porosite_surf[numfa];
134 int n0=numfa*dimension+j;
135 // area=domaine_VEF.face_surfaces(numfa);
136 area=direction_perte_charge() < 0 ? domaine_VEF.face_surfaces(numfa) : std::fabs(domaine_VEF.face_normales(numfa,direction_perte_charge())); // Taking account of inclined plane
137 coefK=K();
138 // if (j!=direction_perte_charge()) coefK=0.;
139 matrice.coef(n0,n0)+= 0.5*coefK*Ud*std::fabs(Ud2)*area*porosite_surf[numfa];
140 }
141 }
142}
143
class Domaine_VEF
Definition Domaine_VEF.h:53
virtual const DoubleVect & face_surfaces() const
Definition Domaine_VF.h:51
virtual double face_normales(int face, int comp) const
Definition Domaine_VF.h:47
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
Probleme_base & probleme()
Returns the problem associated with the equation.
Matrice_Morse class - Represents a (sparse) matrix M, not necessarily square,.
double coef(int i, int j) const
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
friend class Entree
Definition Objet_U.h:71
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 Perte_Charge_Singuliere_VEF_Face
void mettre_a_jour(double temps) override
DOES NOTHING - to override in derived classes.
DoubleTab & ajouter(DoubleTab &) const override
void contribuer_a_avec(const DoubleTab &, Matrice_Morse &) const override
contribution to the implicit matrix of source terms, by default no contribution
void update_K(const Equation_base &eqn, double deb, DoubleVect &bilan)
double calculate_Q(const Equation_base &eqn, const IntVect &num_faces, const IntVect &sgn) const
virtual void lire_surfaces(Entree &, const Domaine &, const Domaine_dis_base &, IntVect &, IntVect &, int lire_derniere_accolade=1)
class Perte_Charge_VEF_Face
void mettre_a_jour(double) override
DOES NOTHING - to override in derived classes.
int direction_perte_charge() const
Returns the pressure drop direction.
const Domaine & domaine() const
Returns the domain associated with the problem.
static double mp_max(double)
Definition Process.cpp:379
static void exit(int exit_code=-1)
Exit routine for TRUST within a Kokkos region.
Definition Process.cpp:466
static int je_suis_maitre()
Returns 1 if on the master processor of the current group (i.e. me() == 0), 0 otherwise.
Definition Process.cpp:82
Base class for output streams.
Definition Sortie.h:52
void set_fichier(const Nom &)
DoubleVect & bilan()
Definition Source_base.h:88
void set_description(const Nom &nom)
Definition Source_base.h:83
void resize(_SIZE_, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT)
Definition TRUSTVect.tpp:91