TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Dirichlet.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 <Domaine_Cl_dis_base.h>
17#include <Equation_base.h>
18#include <Dirichlet.h>
19
20Implemente_base(Dirichlet, "Dirichlet", Cond_lim_base);
21// XD dirichlet condlim_base dirichlet INHERITS_BRACE Dirichlet condition at the boundary called bord (edge) : 1). For
22// XD_CONT Navier-Stokes equations, velocity imposed at the boundary; 2). For scalar transport equation, scalar imposed
23// XD_CONT at the boundary.
24
25Sortie& Dirichlet::printOn(Sortie& s) const { return s << que_suis_je() << finl; }
26
28
29/*! @brief Returns the imposed value on the i-th component of the field at the boundary at the default time of champ_front.
30 *
31 * @param (int i) index along the first dimension of the field
32 * @return (double) the imposed value on the specified field component
33 * @throws second dimension of the boundary field greater than 1
34 */
35double Dirichlet::val_imp(int i) const
36{
37 return val_imp_au_temps(le_champ_front->get_temps_defaut(), i);
38}
39
40/*! @brief Returns the imposed value on the (i,j)-th component of the field at the boundary at the default time of champ_front.
41 *
42 * @param (int i) index along the first dimension of the field
43 * @param (int j) index along the second dimension of the field
44 * @return (double) the imposed value on the specified field component
45 */
46double Dirichlet::val_imp(int i, int j) const
47{
48 return val_imp_au_temps(le_champ_front->get_temps_defaut(), i, j);
49}
50
51/*! @brief Returns the imposed value on the i-th component of the field at the boundary at the specified time.
52 *
53 */
54double Dirichlet::val_imp_au_temps(double temps, int i) const
55{
56 const DoubleTab& tab = le_champ_front->valeurs_au_temps(temps);
57 if (tab.size() == 1)
58 return tab(0, 0);
59 if (tab.line_size() == 1)
60 return tab(i, 0);
61 else
62 Cerr << "Dirichlet::val_imp error" << finl;
63 exit();
64 return 0.;
65}
66
67/**
68 * @class Dirichlet
69 * @brief Implements Dirichlet boundary conditions for fields.
70 *
71 * This class defines the Dirichlet boundary condition, which imposes specific values
72 * on the field at the boundary. It provides methods to retrieve the imposed values
73 * at specified times and components of the field.
74 */
75const DoubleTab& Dirichlet::tab_val_imp(double temps) const
76{
77 if (temps==DMAXFLOAT) temps = le_champ_front->get_temps_defaut();
78 const Front_VF& le_bord = ref_cast(Front_VF, frontiere_dis());
79 // ToDo factorize in Champ_front_base::valeurs_face()
80 int size = le_champ_front->valeurs().dimension(0) == 1 ? le_bord.nb_faces_tot() : le_champ_front->valeurs().dimension_tot(0);
81 if (size>0)
82 {
83 bool update = le_champ_front->instationnaire();
84 if (tab_.dimension(0) != size)
85 {
86 tab_.resize(size, le_champ_front->valeurs().dimension(1));
87 update = true;
88 }
89 update = true; // Provisoire
90 if (update)
91 {
92 int nb_comp = tab_.dimension(1);
93 for (int face = 0; face < size; face++)
94 for (int comp = 0; comp < nb_comp; comp++)
95 tab_(face, comp) = val_imp_au_temps(temps, face, comp);
96 }
97 }
98 return tab_;
99}
100
101/*! @brief Returns the imposed value on the (i,j)-th component of the field at the boundary at the specified time.
102 *
103 */
104double Dirichlet::val_imp_au_temps(double temps, int i, int j) const
105{
106 const DoubleTab& tab = le_champ_front->valeurs_au_temps(temps);
107 if (tab.dimension(0) == 1)
108 return tab(0, j);
109 else
110 return tab(i, j);
111}
112
114{
115 if (le_champ_front)
116 {
117 const Equation_base& eq = domaine_Cl_dis().equation();
118 const int nb_comp = le_champ_front->nb_comp();
119 eq.verifie_ch_init_nb_comp_cl(eq.inconnue(), nb_comp, *this);
120 }
121}
class Cond_lim_base Base class for the hierarchy of classes that represent the different boundary con...
Domaine_Cl_dis_base & domaine_Cl_dis()
Returns the domain of discretized boundary conditions to which the object belongs.
virtual Frontiere_dis_base & frontiere_dis()
Returns the discretized boundary to which the boundary conditions apply.
Dirichlet This class is the base class of the hierarchy of Dirichlet-type boundary conditions.
Definition Dirichlet.h:31
DoubleTab tab_
Definition Dirichlet.h:42
virtual double val_imp(int i) const
Returns the imposed value on the i-th component of the field at the boundary at the default time of c...
Definition Dirichlet.cpp:35
virtual double val_imp_au_temps(double temps, int i) const
Returns the imposed value on the i-th component of the field at the boundary at the specified time.
Definition Dirichlet.cpp:54
void verifie_ch_init_nb_comp() const override
Calls the verification of the field read through the equation for which the boundary condition is con...
virtual const DoubleTab & tab_val_imp(double temps=DMAXFLOAT) const
Definition Dirichlet.cpp:75
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 Champ_Inc_base & inconnue() const =0
virtual void verifie_ch_init_nb_comp_cl(const Champ_Inc_base &ch_ref, const int nb_comp, const Cond_lim_base &cl) const
class Front_VF
Definition Front_VF.h:36
int nb_faces_tot() const
Definition Front_VF.h:58
const Equation_base & equation() const
Returns the reference to the equation pointed to by MorEqn::mon_equation.
Definition MorEqn.h:62
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
_SIZE_ dimension(int d) const
Definition TRUSTTab.tpp:133
_SIZE_ size() const
Definition TRUSTVect.tpp:45
int line_size() const
Definition TRUSTVect.tpp:67