TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Robin_VEF.cpp
1/****************************************************************************
2* Copyright (c) 2026, 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_dis_base.h>
17#include <Navier_Stokes_std.h>
18#include <Equation_base.h>
19#include <Robin_VEF.h>
20#include <Front_VF.h>
21#include <Param.h>
22
23Implemente_instanciable( Robin_VEF, "Robin_VEF", Cond_lim_base ) ;
24// XD robin_vef condlim_base robin_vef BRACE Robin condition at the boundary (edge)
25
27{
28 return Cond_lim_base::printOn( os );
29}
30
32{
33 Param param(que_suis_je());
34
35 param.ajouter("alpha", &alpha_robin_cl_, Param::REQUIRED); // XD_ADD_P floattant
36 // XD_CONT Robin coefficient for the normal field
37 param.ajouter("beta" , &beta_robin_cl_ , Param::REQUIRED); // XD_ADD_P floattant
38 // XD_CONT Robin coefficient for the tangent field
39 param.ajouter("champ_front_normal_et_tangentiel_robin",&le_champ_front,Param::REQUIRED); // XD_ADD_P front_field_base
40 // XD_CONT The boundary field
41 param.lire_avec_accolades_depuis(is);
42
43
44 Cerr << "Reading Robin boundary condition, the value of the normal Robin coefficient is "
45 << alpha_robin_cl_ << " and the tangential Robin coefficient is " << beta_robin_cl_ << finl;
46
48 Process::exit("Error of Robin boundary conditions : Alpha and Beta parameters should be positive. \n ") ;
49
50 if (supp_discs.size() == 0)
51 supp_discs = { Nom("VEF") , Nom("VEFPreP1B") };
52
53 if (app_domains.size() == 0)
54 app_domains = { Motcle("Hydraulique") };
55
56 return is; //Cond_lim_base::readOn(is);
57}
58
60{
62
63 assert( mon_dom_cl_dis);
64
65 if (!sub_type(Navier_Stokes_std, mon_dom_cl_dis->equation()))
66 Process::exit("Robin_VEF is not yet coded on scalar equations ... \n");
67
68 // for now ....
69 if (mon_dom_cl_dis->equation().operateur(0).l_op_base().que_suis_je() != "Op_Diff_VEF_P1NC")
70 Process::exit("Robin_VEF is now only available for the laminar Op_Diff_VEF_P1NC operator ... \n");
71}
72
73/*! @brief Returns the value of the imposed normal and tangential Robin flux on the (i,j)-th component of the field representing the flux at the boundary.
74 *
75 * @param (int i) index along the first dimension of the field
76 * @param (int j) index along the second dimension of the field (j=1 returns the normal component, and for j>1, returns the (j-1)-th tangential component)
77 * @return (double) the imposed value on the specified field component
78 */
80{
81 // if dim = 2 : le_champ_front has 1+2 dimensions : 1 column for the localisation of the field + 1 column for the normal field value, and 1 column for the tangential field value
82 // if dim = 3 : le_champ_front has 1+4 dimensions : 1 column for the localisation of the field + 1 column for the normal field value, and 3 column for the tangential field value
83
84 if ((le_champ_front->valeurs().dimension(1)==2 && dimension == 2) || (le_champ_front->valeurs().dimension(1)==4 && dimension == 3))
85 {
86 if (le_champ_front->valeurs().dimension(0)==1) // has a single value identical on all boundary cells
87 return le_champ_front->valeurs()(0,j);
88 else
89 return le_champ_front->valeurs()(i,j);
90 }
91 else
92 Cerr << "Robin::flux_robin_normal_et_tangentiel error" << finl;
94 return 0.;
95}
96
97/*! @brief Returns the value of the imposed normal flux on the i-th component of the field representing the flux at the boundary.
98 *
99 * @param (int i) index along the first dimension of the field
100 * @return (double) the imposed value on the specified field component
101 */
102
104
105/*! @brief Returns the value of the imposed tangential flux on the (i,j)-th component of the field representing the tangential flux at the boundary.
106 *
107 * @param (int i) index along the first dimension of the field
108 * @param (int j) index along the second dimension of the field
109 * @return (double) the imposed value on the specified field component
110 */
111double Robin_VEF::flux_tangentiel_imp(int i, int j ) const
112{
113 if ((dimension==2 && j<2) || (dimension ==3 && j<4))
115 else
116 Cerr << " Robin::flux_tangentiel_imp error, dimension does not match" << finl;
118 return 0.;
119}
120
121void Robin_VEF::mettre_a_jour(double temps)
122{
123 le_champ_front->mettre_a_jour(temps);
124}
125
126// for domain decomposition, not implemented yet
127double Robin_VEF::flux_robin_imp_au_temps(double temps, int i) const
128{
129 return 0.;
130
131}
132
133// for domain decomposition, not implemented yet
134double Robin_VEF::flux_robin_imp_au_temps(double temps, int i, int j ) const
135{
136 return 0.;
137}
138
139/*! @brief Updates and returns the imposed flux array.
140 *
141 * This function checks the total number of faces in the boundary and resizes the
142 * `flux_normal_impose_` array if necessary. It updates the values based on the imposed
143 * flux from the front field if the field is unsteady or if the dimensions have changed.
144 *
145 * @return const DoubleTab& Reference to the updated imposed flux array.
146 */
147const DoubleTab& Robin_VEF::flux_robin_normal_imp() const
148{
149 const Front_VF& le_bord = ref_cast(Front_VF, frontiere_dis());
150 int nb_faces_tot = le_bord.nb_faces_tot();
151 if (nb_faces_tot>0)
152 {
153 if (flux_normal_impose_.dimension(0) != nb_faces_tot)
154 flux_normal_impose_.resize(nb_faces_tot, 1);
155 int size = flux_normal_impose_.dimension(0);
156 //int nb_comp = flux_robin_impose_.dimension(1);
157 for (int i = 0; i < size; i++)
158 //for (int j = 0; j < nb_comp; j++)
160 }
161 return flux_normal_impose_;
162}
163
164
165/*! @brief Updates and returns the imposed flux array.
166 *
167 * This function checks the total number of faces in the boundary and resizes the
168 * `flux_tangentiel_impose_` array if necessary. It updates the values based on the imposed
169 * flux from the front field if the field is unsteady or if the dimensions have changed.
170 *
171 * @return const DoubleTab& Reference to the updated imposed flux array.
172 */
174{
175 const Front_VF& le_bord = ref_cast(Front_VF, frontiere_dis());
176 int nb_faces_tot = le_bord.nb_faces_tot();
177 if (nb_faces_tot>0)
178 {
179 if (flux_tangentiel_impose_.dimension(0) != nb_faces_tot)
180 flux_tangentiel_impose_.resize(nb_faces_tot, le_champ_front->valeurs().dimension(1));
181 int size = flux_tangentiel_impose_.dimension(0);
182 int nb_comp = flux_tangentiel_impose_.dimension(1);
183 for (int i = 0; i < size; i++)
184 for (int j = 0; j < nb_comp; j++)
186 }
188}
189
class Cond_lim_base Base class for the hierarchy of classes that represent the different boundary con...
std::vector< Nom > supp_discs
virtual void completer()
DOES NOTHING must be overridden in derived classes.
std::vector< Motcle > app_domains
virtual Frontiere_dis_base & frontiere_dis()
Returns the discretized boundary to which the boundary conditions apply.
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
class Front_VF
Definition Front_VF.h:36
int nb_faces_tot() const
Definition Front_VF.h:58
Navier_Stokes_std This class carries the terms of the momentum equation.
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
@ REQUIRED
Definition Param.h:115
static void exit(int exit_code=-1)
Exit routine for TRUST within a Kokkos region.
Definition Process.cpp:466
Class Robin_VEF for Robin boundary conditions.
Definition Robin_VEF.h:44
double flux_tangentiel_imp(int i, int j) const
Returns the value of the imposed tangential flux on the (i,j)-th component of the field representing ...
double flux_robin_imp_au_temps(double temps, int i) const
const DoubleTab & flux_robin_tangentiel_imp() const
Updates and returns the imposed flux array.
double flux_robin_normal_et_trangentiel_imp(int i, int j) const
Returns the value of the imposed normal and tangential Robin flux on the (i,j)-th component of the fi...
Definition Robin_VEF.cpp:79
DoubleTab flux_normal_impose_
Definition Robin_VEF.h:82
void completer() override
DOES NOTHING must be overridden in derived classes.
Definition Robin_VEF.cpp:59
DoubleTab flux_tangentiel_impose_
Definition Robin_VEF.h:83
const DoubleTab & flux_robin_normal_imp() const
Updates and returns the imposed flux array.
double alpha_robin_cl_
Definition Robin_VEF.h:78
double flux_normal_imp(int i) const
Returns the value of the imposed normal flux on the i-th component of the field representing the flux...
void mettre_a_jour(double temps) override
Performs a time update of the boundary condition.
double beta_robin_cl_
Definition Robin_VEF.h:79
Base class for output streams.
Definition Sortie.h:52