TrioCFD 1.9.8
TrioCFD documentation
Loading...
Searching...
No Matches
TRUSTProblem_Concentration_Gen.h
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#ifndef TRUSTProblem_Concentration_Gen_included
17#define TRUSTProblem_Concentration_Gen_included
18
19#include <Convection_Diffusion_Concentration.h>
20#include <Pb_Thermohydraulique.h>
21#include <Champ_Uniforme.h>
22#include <Constituant.h>
23#include <EChaine.h>
24#include <sstream>
25#include <iomanip>
26
27template <typename _DERIVED_TYPE_, typename _EQUATION_TYPE_, typename _MEDIUM_TYPE_>
28class TRUSTProblem_Concentration_Gen : public _DERIVED_TYPE_
29{
30protected:
31 std::vector<_MEDIUM_TYPE_> mil_constituants_;
32 LIST(_EQUATION_TYPE_) list_eq_concentration_;
33 int nb_consts_ = -123;
34
35 Sortie& printOn(Sortie& os) const override { return _DERIVED_TYPE_::printOn(os); }
36
37 inline int nb_equations_multi() { return list_eq_concentration_.size(); }
38 inline int nb_equations_multi() const { return list_eq_concentration_.size(); }
39
40public:
41 int nombre_d_equations() const override
42 {
43 return (_DERIVED_TYPE_::nombre_d_equations() + nb_equations_multi());
44 }
45
46 const Equation_base& equation(int i) const override
47 {
48 if (i >= nombre_d_equations())
49 Process::exit("Error in TRUSTProblem_Concentration_Gen<_DERIVED_TYPE_, _EQUATION_TYPE_, _MEDIUM_TYPE_>::equation => wrong equation number !");
50
51 const int nb_eq_mere = _DERIVED_TYPE_::nombre_d_equations();
52 if (i < nb_eq_mere)
53 return _DERIVED_TYPE_::equation(i);
54 else
55 return list_eq_concentration_(i - nb_eq_mere);
56 }
57
58 Equation_base& equation(int i) override
59 {
60 if (i >= nombre_d_equations())
61 Process::exit("Error in TRUSTProblem_Concentration_Gen<_DERIVED_TYPE_, _EQUATION_TYPE_, _MEDIUM_TYPE_>::equation => wrong equation number !");
62
63 const int nb_eq_mere = _DERIVED_TYPE_::nombre_d_equations();
64 if (i < nb_eq_mere)
65 return _DERIVED_TYPE_::equation(i);
66 else
67 return list_eq_concentration_(i - nb_eq_mere);
68 }
69
70 void rename_equation_unknown(const int i, _EQUATION_TYPE_& eqn)
71 {
72 if (nb_consts_ > 1)
73 {
74 Nom nom_inco = "concentration", nom_eq = eqn.que_suis_je();
75 nom_inco += Nom(i), nom_eq += Nom(i);
76 Cerr << "The unknown name of the " << eqn.que_suis_je() << " equation " << i << " is modified => " << nom_inco << finl;
77 eqn.inconnue().nommer(nom_inco);
78 Cerr << "The " << eqn.que_suis_je() << " equation name, of number " << i << ", is modified => " << nom_eq << finl;
79 eqn.nommer(nom_eq);
80
81 // et pour champs_compis ....
82 eqn.get_champ_compris().clear_champs_compris();
83 eqn.get_champ_compris().ajoute_champ(eqn.inconnue());
84 }
85 }
86
88 {
89 _DERIVED_TYPE_::milieu_vect().resize(2);
90 for (int i = 0; i < 2; i++) is >> _DERIVED_TYPE_::milieu_vect()[i];
91 _DERIVED_TYPE_::associer_milieu_base(_DERIVED_TYPE_::milieu_vect().front().valeur()); // NS : On l'associe a chaque equations (methode virtuelle pour chaque pb ...)
92
93 /*
94 * XXX : Elie Saikali :
95 * - le_milieu_[0] => Fluide incompressible et le_milieu_[1] => constituants (n compos).
96 * - le_milieu_[1] pas associe a l'equation car n compos
97 * - this->mil_constituants_ contient le milieu associe a chaque equation
98 */
99 const Constituant& les_consts = ref_cast(_MEDIUM_TYPE_, _DERIVED_TYPE_::milieu_vect().back().valeur());
100 nb_consts_ = les_consts.nb_constituants();
102
103 if (!sub_type(Champ_Uniforme, les_consts.diffusivite_constituant()))
104 {
105 Cerr << "Error in TRUSTProblem_Concentration_Gen<_DERIVED_TYPE_, _EQUATION_TYPE_, _MEDIUM_TYPE_>::lire_resize_medium. You can not use a diffusion coefficient of type " << les_consts.diffusivite_constituant().que_suis_je() << " !!!" << finl;
106 Cerr << "We only accept uniform fields for the moment ... Fix your data set or call the 911 !!!" << finl;
108 }
109 return is;
110 }
111
113 {
114 const Constituant& les_consts = ref_cast(_MEDIUM_TYPE_, _DERIVED_TYPE_::milieu_vect().back().valeur());
115 const DoubleTab& vals = les_consts.diffusivite_constituant().valeurs();
116
117 for (int i = 0; i < nb_consts_; i++)
118 {
119 std::ostringstream oss;
120 oss << std::scientific << std::setprecision(15) << vals(0, i); // Setting precision to 3 decimal places
121
122 Nom str = "{ coefficient_diffusion Champ_Uniforme 1 ";
123 str += oss.str().c_str();
124 str += " }";
125
126 EChaine const1(str);
127 const1 >> mil_constituants_[i];
128 }
129 }
130};
131
132#endif /* TRUSTProblem_Concentration_Gen_included */
DoubleTab & valeurs() override
Surcharge Champ_base::valeurs() Renvoie le tableau des valeurs.
classe Champ_Uniforme Represente un champ constant dans l'espace et dans le temps.
classe Constituant Cette classe represente le(s) constituant(s) d'un fluide.
Definition Constituant.h:30
int nb_constituants() const
Definition Constituant.h:57
const Champ_Don_base & diffusivite_constituant() const
Definition Constituant.h:36
Une entree dont la source est une chaine de caracteres.
Definition EChaine.h:31
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
classe Equation_base Le role d'une equation est le calcul d'un ou plusieurs champs....
class Nom Une chaine de caractere pour nommer les objets de TRUST
Definition Nom.h:31
virtual void nommer(const Nom &)
Donne un nom a l'Objet_U Methode virtuelle a surcharger.
Definition Objet_U.cpp:329
const Nom & que_suis_je() const
renvoie la chaine identifiant la classe.
Definition Objet_U.cpp:104
static void exit(int exit_code=-1)
Routine de sortie de TRUST dans une region Kokkos.
Definition Process.cpp:455
Classe de base des flux de sortie.
Definition Sortie.h:52
std::vector< _MEDIUM_TYPE_ > mil_constituants_
Sortie & printOn(Sortie &os) const override
const Equation_base & equation(int i) const override
LIST(_EQUATION_TYPE_) list_eq_concentration_
Equation_base & equation(int i) override
void rename_equation_unknown(const int i, _EQUATION_TYPE_ &eqn)