TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Traitement_particulier_NS_chmoy_faceperio_VEF.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 <Traitement_particulier_NS_chmoy_faceperio_VEF.h>
17#include <Domaine_VEF.h>
18#include <Periodique.h>
19#include <Champ_P1NC.h>
20#include <Champ_Uniforme.h>
21#include <Convection_Diffusion_Temperature.h>
22#include <Probleme_base.h>
23#include <EcrFicPartage.h>
24#include <Navier_Stokes_std.h>
25
26Implemente_instanciable(Traitement_particulier_NS_chmoy_faceperio_VEF,"Traitement_particulier_NS_chmoy_faceperio_VEF",Traitement_particulier_NS_chmoy_faceperio);
27
28
29/*! @brief Prints the object to an output stream.
30 *
31 * @param (Sortie& is) output stream
32 * @return (Sortie&) modified output stream
33 */
35{
36 return is;
37}
38
39
40/*! @brief Reads the object from an input stream.
41 *
42 * @param (Entree& is) input stream
43 * @return (Entree&) modified input stream
44 */
46{
47 return is;
48}
49
51{
52 const Domaine_dis_base& zdisbase=mon_equation->inconnue().domaine_dis_base();
53 const Domaine_VEF& domaine_VEF=ref_cast(Domaine_VEF, zdisbase);
54 const Domaine_Cl_VEF& domaine_Cl_VEF = ref_cast(Domaine_Cl_VEF,mon_equation->domaine_Cl_dis() );
55 const DoubleTab& xv = domaine_VEF.xv(); // face centers of gravity
56 // Print to a file the periodic faces (index + center coordinates)
57 int nb_front=domaine_VEF.nb_front_Cl();
58 for (int n_bord=0; n_bord<nb_front; n_bord++)
59 {
60 const Cond_lim& la_cl = domaine_Cl_VEF.les_conditions_limites(n_bord);
61 if (sub_type(Periodique,la_cl.valeur()))
62 {
63 const Front_VF& le_bord = ref_cast(Front_VF,la_cl->frontiere_dis());
64 if (le_bord.nb_faces())
65 {
68 EcrFicPartage fic("geom_face_perio");
69 fic.setf(ios::scientific);
71 trustIdType nb_faces_bord = mp_sum(le_bord.nb_faces());
72 if (Process::je_suis_maitre()) fic<<nb_faces_bord<<finl;
73 int num1 = le_bord.num_premiere_face();
74 int num2 = num1 + le_bord.nb_faces();
75 for (int num_face=num1; num_face<num2; num_face++)
76 fic<<num_face<<" "<<xv(num_face,0)<<" "<<xv(num_face,1)<<" "<<xv(num_face,2)<<finl;
77 fic.syncfile();
78 fic.close();
79 }
80 }
81 }
82}
83
84void Traitement_particulier_NS_chmoy_faceperio_VEF::calcul_chmoy_faceperio(double un_temps_deb, double temps, double dt)
85{
86 const Domaine_dis_base& zdisbase=mon_equation->inconnue().domaine_dis_base();
87 const Domaine_VEF& domaine_VEF=ref_cast(Domaine_VEF, zdisbase);
88 const Domaine_Cl_VEF& domaine_Cl_VEF = ref_cast(Domaine_Cl_VEF,mon_equation->domaine_Cl_dis() );
89 const DoubleTab& vitesse = mon_equation->inconnue().valeurs();
90
91 // Compute the temporal average of velocity on periodic boundaries:
92 // avg(U)=1/(temps-temps_deb)*Integral(t=temps_deb to temps)(U(t)*dt)
93 chmoy_faceperio*=(temps-un_temps_deb-dt);
94 int test_proc=0;
95 int nb_front=domaine_VEF.nb_front_Cl();
96 for (int n_bord=0; n_bord<nb_front; n_bord++)
97 {
98 const Cond_lim& la_cl = domaine_Cl_VEF.les_conditions_limites(n_bord);
99 if (sub_type(Periodique,la_cl.valeur()))
100 {
101 const Front_VF& le_bord = ref_cast(Front_VF,la_cl->frontiere_dis());
102 int num1 = le_bord.num_premiere_face();
103 int num2 = num1 + le_bord.nb_faces();
104 for (int num_face=num1; num_face<num2; num_face++)
105 {
106 for(int i=0; i<Objet_U::dimension; i++)
107 chmoy_faceperio(num_face,i)+=dt*vitesse(num_face,i);
108 test_proc=1;
109 }
110 }
111 }
112
113 chmoy_faceperio/=(temps-un_temps_deb);
114
115 if (test_proc)
116 {
117 EcrFicPartage fic("chmoy_face_perio");
118 fic.setf(ios::scientific);
120 for (int n_bord=0; n_bord<nb_front; n_bord++)
121 {
122 const Cond_lim& la_cl = domaine_Cl_VEF.les_conditions_limites(n_bord);
123 if (sub_type(Periodique,la_cl.valeur()))
124 {
125 const Front_VF& le_bord = ref_cast(Front_VF,la_cl->frontiere_dis());
126 int num1 = le_bord.num_premiere_face();
127 int num2 = num1 + le_bord.nb_faces();
128 trustIdType nb_faces_bord = mp_sum(le_bord.nb_faces());
129 if (Process::je_suis_maitre()) fic<<nb_faces_bord<<finl;
130 for (int num_face=num1; num_face<num2; num_face++)
131 fic<<num_face<<" "<<chmoy_faceperio(num_face,0)<<" "<<chmoy_faceperio(num_face,1)<<" "<<chmoy_faceperio(num_face,2)<<finl;
132 }
133 }
134 fic.syncfile();
135 fic.close();
136 }
137}
class Cond_lim Generic class used to represent any class
Definition Cond_lim.h:31
const Cond_lim & les_conditions_limites(int) const
Returns the i-th boundary condition.
class Domaine_VEF
Definition Domaine_VEF.h:53
double xv(int num_face, int k) const
Definition Domaine_VF.h:76
class Domaine_dis_base This class is the base of the hierarchy of discretized domains.
int nb_front_Cl() const
Sortie & syncfile() override
Triggers writing to disk of the data accumulated on the different processors since the last call to s...
void precision(int) override
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 num_premiere_face() const
Definition Front_VF.h:63
static int dimension
Definition Objet_U.h:94
virtual Entree & readOn(Entree &)
Reads an Objet_U from an input stream. Virtual method to override.
Definition Objet_U.cpp:289
static int format_precision_geom
Definition Objet_U.h:95
virtual Sortie & printOn(Sortie &) const
Writes the object to an output stream. Virtual method to override.
Definition Objet_U.cpp:278
class Periodique This class represents a periodic boundary condition.
Definition Periodique.h:31
static double mp_sum(double)
Computes the sum of x over all processors in the current group.
Definition Process.cpp:145
static int je_suis_maitre()
Returns 1 if on the master processor of the current group (i.e. me() == 0), 0 otherwise.
Definition Process.cpp:82
void setf(IOS_FORMAT code) override
Base class for output streams.
Definition Sortie.h:52
class Traitement_particulier_NS_chmoy_faceperio_VEF This class performs special post-processing
Traitement_particulier_chmoy_faceperio This class performs specific post-processing treatments.