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