TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Neumann.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_dis_base.h>
17#include <Front_VF.h>
18#include <Neumann.h>
19
20Implemente_base(Neumann, "Neumann", Cond_lim_base);
21// XD neumann condlim_base neumann INHERITS_BRACE Neumann condition at the boundary called bord (edge) : 1). For
22// XD_CONT Navier-Stokes equations, constraint imposed at the boundary; 2). For scalar transport equation, flux imposed
23// XD_CONT at the boundary.
24
25Sortie& Neumann::printOn(Sortie& s) const { return s << que_suis_je() << finl; }
26
28
29/*! @brief Returns the value of the imposed flux on the i-th component of the field representing the flux at the boundary.
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 Neumann::flux_impose(int i) const
36{
37 if (le_champ_front->valeurs().size() == 1)
38 return le_champ_front->valeurs()(0, 0);
39 else if (le_champ_front->valeurs().dimension(1) == 1)
40 return le_champ_front->valeurs()(i, 0);
41 else
42 Cerr << "Neumann::flux_impose error" << finl;
44 return 0.;
45}
46
47/*! @brief Returns the value of the imposed flux on the (i,j)-th component of the field representing the flux at the boundary.
48 *
49 * @param (int i) index along the first dimension of the field
50 * @param (int j) index along the second dimension of the field
51 * @return (double) the imposed value on the specified field component
52 */
53double Neumann::flux_impose(int i, int j) const
54{
55 if (le_champ_front->valeurs().dimension(0) == 1)
56 return le_champ_front->valeurs()(0, j);
57 else
58 return le_champ_front->valeurs()(i, j);
59}
60
61/*! @brief Updates and returns the imposed flux array.
62 *
63 * This function checks the total number of faces in the boundary and resizes the
64 * `flux_impose_` array if necessary. It updates the values based on the imposed
65 * flux from the front field if the field is unsteady or if the dimensions have changed.
66 *
67 * @return const DoubleTab& Reference to the updated imposed flux array.
68 */
69const DoubleTab& Neumann::flux_impose(bool with_virtual_faces) const
70{
71 const Front_VF& le_bord = ref_cast(Front_VF, frontiere_dis());
72 // ToDo factorize in Champ_front_base::valeurs_face()
73 int size;
74 if (with_virtual_faces)
75 size = le_champ_front->valeurs().dimension(0) == 1 ? le_bord.nb_faces_tot() : le_champ_front->valeurs().dimension_tot(0);
76 else
77 size = le_champ_front->valeurs().dimension(0) == 1 ? le_bord.nb_faces() : le_champ_front->valeurs().dimension(0);
78
79 if (size>0)
80 {
81 bool update = le_champ_front->instationnaire();
82 if (flux_impose_.dimension(0) != size)
83 {
84 int nb_comp = le_champ_front->valeurs().nb_dim() == 1 ? 1 : le_champ_front->valeurs().dimension(1);
85 flux_impose_.resize(size, nb_comp);
86 update = true;
87 }
88 update = true; // Provisoire (ecarts sur Quasi_Comp_Obst_GP_VEF_Pmoy ???)
89 if (update)
90 {
91 int nb_comp = flux_impose_.dimension(1);
92 for (int i = 0; i < size; i++)
93 for (int j = 0; j < nb_comp; j++)
94 flux_impose_(i, j) = flux_impose(i, j);
95 }
96 }
97 return flux_impose_;
98}
99
100
class Cond_lim_base Base class for the hierarchy of classes that represent the different boundary con...
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() const
Definition Front_VF.h:53
int nb_faces_tot() const
Definition Front_VF.h:58
Classe Neumann This class is the base class of the hierarchy of Neumann-type boundary conditions.
Definition Neumann.h:31
virtual double flux_impose(int i) const
Returns the value of the imposed flux on the i-th component of the field representing the flux at the...
Definition Neumann.cpp:35
DoubleTab flux_impose_
Definition Neumann.h:39
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