TrioCFD 1.9.8
TrioCFD documentation
Loading...
Searching...
No Matches
OpConvCentre2IJK.cpp
1/****************************************************************************
2* Copyright (c) 2015 - 2016, 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 <OpConvCentre2IJK.h>
17#include <Perf_counters.h>
18Implemente_instanciable_sans_constructeur(OpConvCentre2IJK_double, "OpConvCentre2IJK_double", Operateur_IJK_faces_conv_base_double);
19
20OpConvCentre2IJK_double::OpConvCentre2IJK_double()
21{
22 div_rho_u_=nullptr;
24}
25
27{
28 return os;
29}
30
32{
33 return is;
34}
35
36void OpConvCentre2IJK_double::calcul_g(const double& dxam, const double& dx, const double& dxav, double& g1, double& g2, double& g3, double& g4)
37{
38 g1 = 0.0;
39 g2 = 0.5;
40 g3 = 0.5;
41 g4 = 0.0;
42}
43
44
45
46// g contains one line per flux computed in the z direction.
47// The first flux at index 0 is juste before the first face owned by the processor.
48// offset is the index in the global mesh of the first element on this processor in direction z
49// istart, iend: index of the first and last fluxes computed with 4-th order, others are 2-nd order.
50// is_z_component: shall we compute coefficients for interpolation for velocity_z or for velocity_x and velocity_y?
51// is_z_periodic: is the mesh periodic in the z direction?
52// delta_z is the size of the cells on this processor, we need 2 ghost cells
53void OpConvCentre2IJK_double::fill_g_compo(DoubleTab& g, int nb_values, int offset,
54 int istart, int iend,
55 const ArrOfDouble_with_ghost& delta_z, bool is_z_component, bool is_z_periodic)
56{
57 g.resize(nb_values, 4);
58 for (int i = 0; i < nb_values; i++)
59 {
60 if ((!is_z_periodic) && (i + offset < istart || i + offset > iend))
61 {
62 // We are in the wall or in the first layer: degenerate coefficients for 2nd order interpolation
63 g(i,0) = 0.;
64 g(i,1) = 0.5;
65 g(i,2) = 0.5;
66 g(i,3) = 0.;
67 }
68 else
69 {
70 double d1, d2, d3;
71 if (is_z_component)
72 {
73 // Filtering coefficients for faces oriented in z: interval between faces is the cell size
74 d1 = delta_z[i-2];
75 d2 = delta_z[i-1];
76 d3 = delta_z[i];
77 }
78 else
79 {
80 // Filtering coefficients for faces oriented in x or y: interval between centers of faces is this:
81 d1 = (delta_z[i-2] + delta_z[i-1]) * 0.5;
82 d2 = (delta_z[i-1] + delta_z[i]) * 0.5;
83 d3 = (delta_z[i] + delta_z[i+1]) * 0.5;
84 }
85 calcul_g(d1, d2, d3, g(i,0), g(i,1), g(i,2), g(i,3));
86 }
87 }
88}
89
91{
93
94 // Fill 4-th order filtering coefficients for z direction:
95 const int nb_xfaces = splitting.get_nb_faces_local(0 /* for component x */, 2 /* in direction z */);
96 const int nb_zfaces = splitting.get_nb_faces_local(2 /* for component z */, 2 /* in direction z */);
97 // number of flux values computed on this processor in direction k
98 // equals the number of faces owned by the processor, plus 1
99
100 const int offset_to_global_k_layer = channel_data_.offset_to_global_k_layer();
101 const ArrOfDouble_with_ghost& delta_z = channel_data_.get_delta_z();
102
103 bool perio_k = channel_data_.is_k_periodic();
104
105 // first flux computed with 4th order is 1 layer after the first non zero flux, after the wall.
106 // SPECIFIC FOR CHANNEL WITH WALLS IN K DIRECTION !
107 int istart, iend;
108 istart = channel_data_.first_global_k_layer_flux(0 /* compo */, 2 /* dir */) + 1;
109 iend = channel_data_.last_global_k_layer_flux(0 /* compo */, 2 /* dir */) - 1;
110 fill_g_compo(g_compo_xy_dir_z_, nb_xfaces + 1, offset_to_global_k_layer, istart, iend, delta_z, false, perio_k);
111
112 istart = channel_data_.first_global_k_layer_flux(2 /* compo */, 2 /* dir */) + 1;
113 iend = channel_data_.last_global_k_layer_flux(2 /* compo */, 2 /* dir */) - 1;
114 fill_g_compo(g_compo_z_dir_z_, nb_zfaces + 1, offset_to_global_k_layer, istart, iend, delta_z, true, perio_k);
115}
116
117void OpConvCentre2IJK_double::calculer(const IJK_Field_double& inputx, const IJK_Field_double& inputy, const IJK_Field_double& inputz,
118 const IJK_Field_double& vx, const IJK_Field_double& vy, const IJK_Field_double& vz,
119 IJK_Field_double& dvx, IJK_Field_double& dvy, IJK_Field_double& dvz)
120{
121 Operateur_IJK_faces_conv_base_double::calculer(inputx, inputy, inputz, vx, vy, vz, dvx, dvy, dvz);
122 div_rho_u_ = 0;
123
124
125}
126
127void OpConvCentre2IJK_double::ajouter(const IJK_Field_double& inputx, const IJK_Field_double& inputy, const IJK_Field_double& inputz,
128 const IJK_Field_double& vx, const IJK_Field_double& vy, const IJK_Field_double& vz,
129 IJK_Field_double& dvx, IJK_Field_double& dvy, IJK_Field_double& dvz)
130{
131 Operateur_IJK_faces_conv_base_double::ajouter(inputx, inputy, inputz, vx, vy, vz, dvx, dvy, dvz);
132 div_rho_u_ = 0;
133}
134
135// Calcule, sur la couche k_layer de mailles, l'integrale sur la maille de div(rho_v)
136// On calcule une epaisseur de mailles ghost a gauche dans les directions i et j
137// (pour calcul de div(rhou) aux faces)
138// On suppose que c'est periodique en i en j
139void OpConvCentre2IJK_double::calculer_div_rhou(const IJK_Field_double& rhovx, const IJK_Field_double& rhovy, const IJK_Field_double& rhovz,
140 IJK_Field_double& resu, int k_layer, const Operateur_IJK_data_channel& channel)
141{
142 statistics().begin_count(STD_COUNTERS::convection,statistics().get_last_opened_counter_level()+1);
143 const double surface_x = channel.get_delta_y() * channel.get_delta_z()[k_layer];
144 const double surface_y = channel.get_delta_x() * channel.get_delta_z()[k_layer];
145 const double surface_z = channel.get_delta_x() * channel.get_delta_y();
146 const int ni = resu.ni();
147 const int nj = resu.nj();
148 // codage simple, non vectorise:
149 for (int j = -1; j < nj; j++)
150 for (int i = -1; i < ni; i++)
151 {
152 double divergence =
153 (rhovx(i+1,j,k_layer) - rhovx(i,j,k_layer)) * surface_x
154 + (rhovy(i,j+1,k_layer) - rhovy(i,j,k_layer)) * surface_y
155 + (rhovz(i,j,k_layer+1) - rhovz(i,j,k_layer)) * surface_z;
156 resu(i,j,k_layer) = divergence;
157 }
158 statistics().end_count(STD_COUNTERS::convection);
159
160}
161
162void OpConvCentre2IJK_double::calculer_avec_u_div_rhou(const IJK_Field_double& rhovx, const IJK_Field_double& rhovy, const IJK_Field_double& rhovz,
163 const IJK_Field_double& vx, const IJK_Field_double& vy, const IJK_Field_double& vz,
164 IJK_Field_double& dvx, IJK_Field_double& dvy, IJK_Field_double& dvz,
165 IJK_Field_double& div_rho_u)
166{
167 statistics().begin_count(STD_COUNTERS::convection,statistics().get_last_opened_counter_level()+1);
168
169 vx_ = &vx;
170 vy_ = &vy;
171 vz_ = &vz;
172 inputx_ = &rhovx;
173 inputy_ = &rhovy;
174 inputz_ = &rhovz;
175 div_rho_u_ = &div_rho_u;
177 calculer_div_rhou(*inputx_, *inputy_, *inputz_, *div_rho_u_, -1, channel_data_);
178
179 compute_set(dvx, dvy, dvz);
180
181 vx_ = vy_ = vz_ = inputx_ = inputy_ = inputz_ = 0;
182 div_rho_u_ = 0;
183 statistics().end_count(STD_COUNTERS::convection);
184
185}
186
187void OpConvCentre2IJK_double::ajouter_avec_u_div_rhou(const IJK_Field_double& rhovx, const IJK_Field_double& rhovy, const IJK_Field_double& rhovz,
188 const IJK_Field_double& vx, const IJK_Field_double& vy, const IJK_Field_double& vz,
189 IJK_Field_double& dvx, IJK_Field_double& dvy, IJK_Field_double& dvz,
190 IJK_Field_double& div_rho_u)
191{
192 statistics().begin_count(STD_COUNTERS::convection,statistics().get_last_opened_counter_level()+1);
193
194 vx_ = &vx;
195 vy_ = &vy;
196 vz_ = &vz;
197 inputx_ = &rhovx;
198 inputy_ = &rhovy;
199 inputz_ = &rhovz;
200 div_rho_u_ = &div_rho_u;
202 calculer_div_rhou(*inputx_, *inputy_, *inputz_, *div_rho_u_, -1, channel_data_);
203
204 compute_add(dvx, dvy, dvz);
205
206 vx_ = vy_ = vz_ = inputx_ = inputy_ = inputz_ = 0;
207 div_rho_u_ = 0;
208 statistics().end_count(STD_COUNTERS::convection);
209
210}
This class encapsulates all the information related to the eulerian mesh for TrioIJK.
Definition Domaine_IJK.h:47
int get_nb_faces_local(int compo, int direction) const
Returns the number, in requested direction, of faces that are oriented in direction of "compo".
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
virtual Entree & readOn(Entree &)
Lecture d'un Objet_U sur un flot d'entree Methode a surcharger.
Definition Objet_U.cpp:293
virtual Sortie & printOn(Sortie &) const
Ecriture de l'objet sur un flot de sortie Methode a surcharger.
Definition Objet_U.cpp:282
void calculer_avec_u_div_rhou(const IJK_Field_double &rhovx, const IJK_Field_double &rhovy, const IJK_Field_double &rhovz, const IJK_Field_double &vx, const IJK_Field_double &vy, const IJK_Field_double &vz, IJK_Field_double &dvx, IJK_Field_double &dvy, IJK_Field_double &dvz, IJK_Field_double &div_rho_u) override
void fill_g_compo(DoubleTab &g, int nb_values, int offset, int istart, int iend, const ArrOfDouble_with_ghost &delta_z, bool is_z_component, bool is_z_periodic)
void ajouter(const IJK_Field_double &inputx, const IJK_Field_double &inputy, const IJK_Field_double &inputz, const IJK_Field_double &vx, const IJK_Field_double &vy, const IJK_Field_double &vz, IJK_Field_double &dvx, IJK_Field_double &dvy, IJK_Field_double &dvz)
void initialize(const Domaine_IJK &splitting) override
void calculer(const IJK_Field_double &inputx, const IJK_Field_double &inputy, const IJK_Field_double &inputz, const IJK_Field_double &vx, const IJK_Field_double &vy, const IJK_Field_double &vz, IJK_Field_double &dvx, IJK_Field_double &dvy, IJK_Field_double &dvz)
void ajouter_avec_u_div_rhou(const IJK_Field_double &rhovx, const IJK_Field_double &rhovy, const IJK_Field_double &rhovz, const IJK_Field_double &vx, const IJK_Field_double &vy, const IJK_Field_double &vz, IJK_Field_double &dvx, IJK_Field_double &dvy, IJK_Field_double &dvz, IJK_Field_double &div_rho_u) override
void calcul_g(const double &dxam, const double &dx, const double &dxav, double &g1, double &g2, double &g3, double &g4)
IJK_Field_double * div_rho_u_
const ArrOfDouble_with_ghost & get_delta_z() const
void compute_set(IJK_Field_double &dvx, IJK_Field_double &dvy, IJK_Field_double &dvz)
void compute_add(IJK_Field_double &dvx, IJK_Field_double &dvy, IJK_Field_double &dvz)
void ajouter(const IJK_Field_double &inputx, const IJK_Field_double &inputy, const IJK_Field_double &inputz, const IJK_Field_double &vx, const IJK_Field_double &vy, const IJK_Field_double &vz, IJK_Field_double &dvx, IJK_Field_double &dvy, IJK_Field_double &dvz)
virtual void initialize(const Domaine_IJK &splitting)
void calculer(const IJK_Field_double &inputx, const IJK_Field_double &inputy, const IJK_Field_double &inputz, const IJK_Field_double &vx, const IJK_Field_double &vy, const IJK_Field_double &vz, IJK_Field_double &dvx, IJK_Field_double &dvy, IJK_Field_double &dvz)
void end_count(const std::string &custom_count_name, int count_increment=1, long int quantity_increment=0)
End the count of a counter and update the counter values.
Classe de base des flux de sortie.
Definition Sortie.h:52
void resize(_SIZE_ n, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT)
Definition TRUSTTab.tpp:469