TRUST 1.9.8
HPC thermohydraulic platform
Loading...
Searching...
No Matches
Perte_Charge_Singuliere_PolyMAC_CDO_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_PolyMAC_CDO_Face.h>
17#include <Domaine_PolyMAC_CDO.h>
18#include <Matrice_Morse.h>
19#include <Equation_base.h>
20#include <Probleme_base.h>
21#include <Motcle.h>
22#include <Domaine.h>
23#include <Param.h>
24
25Implemente_instanciable(Perte_Charge_Singuliere_PolyMAC_CDO_Face, "Perte_Charge_Singuliere_Face_PolyMAC_CDO", Perte_Charge_PolyMAC_CDO_Face);
26
28
30{
33 if (regul_) //fichier de sortie si regulation
34 {
35 bilan().resize(3); //K deb cible
36 set_fichier(Nom("K_") + identifiant_);
37 set_description(Nom("Regulation du Ksing de la surface ") + identifiant_);
38 Noms col_names;
39 col_names.add("K");
40 col_names.add("Flow_rate");
41 col_names.add("Target_Flow_rate");
42 set_col_names(col_names);
43 }
44 return s;
45}
46
48{
49 const Domaine& le_domaine = equation().probleme().domaine();
50 const Domaine_PolyMAC_CDO& domaine_PolyMAC_CDO = ref_cast(Domaine_PolyMAC_CDO,equation().domaine_dis());
51 int taille_bloc = domaine_PolyMAC_CDO.nb_elem();
52 num_faces.resize(taille_bloc);
53 lire_surfaces(s,le_domaine,domaine_PolyMAC_CDO,num_faces, sgn);
54 // int nfac_tot = mp_sum(num_faces.size());
55 int nfac_max = (int)mp_max(num_faces.size()); // not to count several (number of processes) times the same face
56
57 if(je_suis_maitre() && nfac_max == 0)
58 {
59 Cerr << "Error when defining the surface plane for the singular porosity :" << finl;
60 Cerr << "No mesh faces has been found for the surface plane." << finl;
61 Cerr << "Check the coordinate of the surface plane which should match mesh coordinates." << finl;
62 exit();
63 }
64}
65
67{
68 if (has_interface_blocs()) return Source_base::ajouter(resu);
69
70 const Domaine_PolyMAC_CDO& domaine_PolyMAC_CDO = le_dom_PolyMAC_CDO.valeur();
71 //const DoubleVect& volumes_entrelaces = domaine_PolyMAC_CDO.volumes_entrelaces();
72 const DoubleVect& p_f = equation().milieu().porosite_face();
73 const DoubleTab& vit = la_vitesse->valeurs();
74
75 for (int i = 0, f; i < num_faces.size(); i++)
76 if ((f = num_faces(i)) < domaine_PolyMAC_CDO.nb_faces())
77 {
78 double Ud = vit(f) * p_f(f),
79 surf = direction_perte_charge() < 0 ? domaine_PolyMAC_CDO.face_surfaces(f) : std::fabs(domaine_PolyMAC_CDO.face_normales(f,direction_perte_charge())); // Taking account of inclined plane
80 resu(f) -= 0.5 * surf * p_f(f) * K() * Ud * std::fabs(Ud);
81 }
82 return resu;
83}
84
86{
87 resu = 0.;
88 return ajouter(resu);
89}
90
92{
94 {
95 Source_base::contribuer_a_avec(inco, matrice);
96 return;
97 }
98
99 const Domaine_PolyMAC_CDO& domaine_PolyMAC_CDO = le_dom_PolyMAC_CDO.valeur();
100 const DoubleVect& p_f = equation().milieu().porosite_face();
101 const DoubleTab& vit = la_vitesse->valeurs();
102
103 for (int i = 0, f; i < num_faces.size(); i++)
104 if ((f = num_faces(i)) < domaine_PolyMAC_CDO.nb_faces())
105 {
106 double Ud = vit(f) * p_f(f),
107 surf = direction_perte_charge() < 0 ? domaine_PolyMAC_CDO.face_surfaces(f) : std::fabs(domaine_PolyMAC_CDO.face_normales(f,direction_perte_charge())); // Taking account of inclined plane
108 matrice.coef(f, f) += surf * p_f(f) * K() * p_f(f) * std::fabs(Ud);
109 }
110}
111
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
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()
Renvoie le probleme associe a l'equation.
Classe Matrice_Morse Represente une matrice M (creuse), non necessairement carree.
double coef(int i, int j) const
DoubleVect & porosite_face()
Definition Milieu_base.h:62
const Equation_base & equation() const
Renvoie la reference sur l'equation pointe par MorEqn::mon_equation.
Definition MorEqn.h:62
friend class Entree
Definition Objet_U.h:76
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
void mettre_a_jour(double) override
DOES NOTHING - to override in derived classes.
class Perte_Charge_Singuliere_PolyMAC_CDO_Face
void contribuer_a_avec(const DoubleTab &, Matrice_Morse &) const override
contribution a la matrice implicite des termes sources par defaut pas de contribution
void mettre_a_jour(double temps) override
DOES NOTHING - to override in derived classes.
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)
int direction_perte_charge() const
Renvoie la direction de perte de charge.
const Domaine & domaine() const
Renvoie le domaine associe au probleme.
static double mp_max(double)
Definition Process.cpp:376
static void exit(int exit_code=-1)
Routine de sortie de TRUST dans une region Kokkos.
Definition Process.cpp:455
static int je_suis_maitre()
renvoie 1 si on est sur le processeur maitre du groupe courant (c'est a dire me() == 0),...
Definition Process.cpp:86
Classe de base des flux de sortie.
Definition Sortie.h:52
void set_fichier(const Nom &)
DoubleVect & bilan()
Definition Source_base.h:88
virtual void contribuer_a_avec(const DoubleTab &, Matrice_Morse &) const
contribution a la matrice implicite des termes sources par defaut pas de contribution
void set_col_names(const Noms &col_names)
Definition Source_base.h:84
void set_description(const Nom &nom)
Definition Source_base.h:83
virtual int has_interface_blocs() const
Definition Source_base.h:68
virtual DoubleTab & ajouter(DoubleTab &) const
void resize(_SIZE_, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT)
Definition TRUSTVect.tpp:91