TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Frontiere_ouverte_rho_u_impose.cpp
1/****************************************************************************
2* Copyright (c) 2025, 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 <Frontiere_ouverte_rho_u_impose.h>
17#include <Fluide_Dilatable_base.h>
18#include <Frontiere_dis_base.h>
19#include <Equation_base.h>
20
21Implemente_instanciable(Frontiere_ouverte_rho_u_impose, "Frontiere_ouverte_rho_u_impose", Entree_fluide_vitesse_imposee_libre);
22// XD frontiere_ouverte_rho_u_impose frontiere_ouverte_vitesse_imposee_sortie frontiere_ouverte_rho_u_impose INHERITS_BRACE This keyword is used to designate a condition of imposed mass rate at an open boundary called bord (edge). The imposed mass rate field at the inlet is vectorial and the imposed velocity values are expressed in kg.s-1. This boundary condition can be used only with the Quasi compressible model.
23
24
25Sortie& Frontiere_ouverte_rho_u_impose::printOn(Sortie& s) const { return s << que_suis_je() << finl; }
26
28
30{
31 le_fluide = ref_cast(Fluide_Dilatable_base, mon_dom_cl_dis->equation().milieu());
32}
33
35{
36 if (!sub_type(Fluide_Dilatable_base, mon_dom_cl_dis->equation().milieu()))
37 {
38 Cerr << "The boundary condition Frontiere_ouverte_rho_u_impose is only applicable for dialtable fluids and not a fluid of type " << mon_dom_cl_dis->equation().milieu().que_suis_je() << finl;
40 }
41
43}
44
45double Frontiere_ouverte_rho_u_impose::val_imp_au_temps(double temps, int i) const
46{
47 Cerr << "Access to a boundary condition in rho.u without specifying the component" << finl;
49 return 0;
50}
51
52double Frontiere_ouverte_rho_u_impose::val_imp_au_temps(double temps, int i, int j) const
53{
54 double rho_u;
55 int ndeb = le_champ_front->frontiere_dis().frontiere().num_premiere_face();
56 const DoubleTab& tab_rho_u = le_champ_front->valeurs_au_temps(temps);
57 assert(tab_rho_u.nb_dim() == 2);
58
59 if (tab_rho_u.dimension(0) == 1)
60 rho_u = tab_rho_u(0, j);
61 else
62 rho_u = tab_rho_u(i, j);
63
64 double rho = le_fluide->rho_face_np1()(i + ndeb);
65 return rho_u / rho;
66}
67
68const DoubleTab& Frontiere_ouverte_rho_u_impose::tab_val_imp(double temps) const
69{
70 if (temps==DMAXFLOAT) temps = le_champ_front->get_temps_defaut();
71 const Front_VF& le_bord = ref_cast(Front_VF, frontiere_dis());
72 // ToDo factorize in Champ_front_base::valeurs_face()
73 int size = le_champ_front->valeurs().dimension(0) == 1 ? le_bord.nb_faces_tot() : le_champ_front->valeurs().dimension_tot(0);
74 if (size>0)
75 {
76 bool update = le_champ_front->instationnaire();
77 if (tab_.dimension(0) != size)
78 {
79 tab_.resize(size, le_champ_front->valeurs().dimension(1));
80 update = true;
81 }
82 update = true; // Provisoire
83 if (update)
84 {
85 int ndeb = le_champ_front->frontiere_dis().frontiere().num_premiere_face();
86 int nb_comp = tab_.dimension(1);
87 CDoubleTabView rho_u = le_champ_front->valeurs_au_temps(temps).view_ro();
88 CDoubleArrView rho_face_np1 = static_cast<const ArrOfDouble&>(le_fluide->rho_face_np1()).view_ro();
89 DoubleTabView tab = tab_.view_wo();
90 bool uniform = (int)rho_u.extent(0) == 1;
91 Kokkos::parallel_for(start_gpu_timer(__KERNEL_NAME__), size, KOKKOS_LAMBDA (const int face)
92 {
93 for (int comp = 0; comp < nb_comp; comp++)
94 tab(face, comp) = rho_u(uniform ? 0 : face, comp) / rho_face_np1(face + ndeb);
95 });
96 end_gpu_timer(__KERNEL_NAME__);
97 }
98 }
99 return tab_;
100}
101
virtual int compatible_avec_eqn(const Equation_base &) const
virtual Frontiere_dis_base & frontiere_dis()
Returns the discretized boundary to which the boundary conditions apply.
DoubleTab tab_
Definition Dirichlet.h:42
Entree_fluide_vitesse_imposee_libre Special case of the class Entree_fluide_vitesse_imposee for impos...
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
class Equation_base The role of an equation is the calculation of one or more fields....
virtual const Milieu_base & milieu() const =0
Base class for a dilatable fluid, inheriting from Fluide_base.
class Front_VF
Definition Front_VF.h:36
int nb_faces_tot() const
Definition Front_VF.h:58
Open boundary on which the mass flux rho.U is imposed instead of the velocity U.
void completer() override
DOES NOTHING must be overridden in derived classes.
const DoubleTab & tab_val_imp(double temps=DMAXFLOAT) const override
double val_imp_au_temps(double temps, int i) const override
Returns the imposed value on the i-th component of the field at the boundary at the specified time.
int compatible_avec_eqn(const Equation_base &) const override
virtual const Equation_base & equation(const std::string &nom_inc) const
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
static void exit(int exit_code=-1)
Exit routine for TRUST within a Kokkos region.
Definition Process.cpp:466
Base class for output streams.
Definition Sortie.h:52
int nb_dim() const
Definition TRUSTTab.h:199
_SIZE_ dimension(int d) const
Definition TRUSTTab.tpp:133