TrioCFD 1.9.8
TrioCFD documentation
Loading...
Searching...
No Matches
OpConvQuickIJKScalar_cut_cell.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 <OpConvQuickIJKScalar_cut_cell.h>
17#include <IJK_Navier_Stokes_tools_cut_cell.h>
18
19Implemente_instanciable_sans_constructeur(OpConvQuickIJKScalar_cut_cell_double, "OpConvQuickIJKScalar_cut_cell_double", Operateur_IJK_elem_conv_base_double);
20
22{
23 return os;
24}
25
27{
28 return is;
29}
30
31void OpConvQuickIJKScalar_cut_cell_double::correct_flux(IJK_Field_local_double *const flux, int k_layer, const int dir)
32{
33 if (dir == 0)
34 {
35 correct_flux_<DIRECTION::X>(flux, k_layer);
36 }
37 else if (dir == 1)
38 {
39 correct_flux_<DIRECTION::Y>(flux, k_layer);
40 }
41 else if (dir == 2)
42 {
43 correct_flux_<DIRECTION::Z>(flux, k_layer);
44 }
45 else
46 {
47 Cerr << "Unexpected value of dir in OpConvQuickIJKScalar_cut_cell_double::correct_flux" << finl;
49 }
50
51 // Fluxes are stored in the flux variable (IJK_Field_local_double) for pure cells
52 // as well as within the cut_cell_flux_ variable for cut cells.
53 // The two variables must agrees for the fluxes between pure and cut cells.
54 assert((*cut_cell_flux_)[dir].verify_consistency_within_layer(dir, k_layer, *flux));
55
56
57
59 {
60 Cut_field_vector3_double& cut_field_current_fluxes = static_cast<Cut_field_vector3_double&>(*current_fluxes_);
61 Cut_field_vector3_double& cut_field_RK3_F_fluxes = static_cast<Cut_field_vector3_double&>(*RK3_F_fluxes_);
62
63 assert(&(*cut_cell_flux_)[0].get_cut_cell_disc() == &(*cut_cell_flux_)[1].get_cut_cell_disc());
64 assert(&(*cut_cell_flux_)[0].get_cut_cell_disc() == &(*cut_cell_flux_)[2].get_cut_cell_disc());
65 const Cut_cell_FT_Disc& cut_cell_disc = (*cut_cell_flux_)[0].get_cut_cell_disc();
66
67 {
68 int ni = (dir == 0) ? flux->ni() : flux->ni() - 1;
69 int nj = (dir == 1) ? flux->nj() : flux->nj() - 1;
70 for (int j = 0; j < nj; j++)
71 {
72 for (int i = 0; i < ni; i++)
73 {
74 cut_field_current_fluxes[dir].pure_(i,j,k_layer) = (*flux)(i,j,0);
75 int n = cut_cell_disc.get_n(i, j, k_layer);
76 if (n >= 0)
77 {
78 cut_field_current_fluxes[dir].diph_l_(n) = (*cut_cell_flux_)[dir].diph_l_(n);
79 cut_field_current_fluxes[dir].diph_v_(n) = (*cut_cell_flux_)[dir].diph_v_(n);
80 }
81 }
82 }
83 }
84
85 {
86 int ni = (dir == 0) ? flux->ni() : flux->ni() - 1;
87 int nj = (dir == 1) ? flux->nj() : flux->nj() - 1;
88 for (int j = 0; j < nj; j++)
89 {
90 for (int i = 0; i < ni; i++)
91 {
92 int n = cut_cell_disc.get_n(i, j, k_layer);
93 if (n >= 0)
94 {
95 const DoubleTabFT_cut_cell_vector3& indicatrice_surfacique = cut_cell_disc.get_interfaces().get_indicatrice_surfacique_efficace_face();
96 double indicatrice_surface = indicatrice_surfacique(n,dir);
97
98 cut_field_RK3_F_fluxes[dir].diph_l_(n) = cut_field_RK3_F_fluxes[dir].diph_l_(n)*indicatrice_surface;
99 cut_field_RK3_F_fluxes[dir].diph_v_(n) = cut_field_RK3_F_fluxes[dir].diph_v_(n)*(1 -indicatrice_surface);
100 }
101 }
102 }
103 }
104
105 runge_kutta3_update_surfacic_fluxes(cut_field_current_fluxes[dir], cut_field_RK3_F_fluxes[dir], rk_step_, k_layer, dir, dt_tot_, *cellule_rk_restreint_conv_main_);
106
107 {
108 int ni = (dir == 0) ? flux->ni() : flux->ni() - 1;
109 int nj = (dir == 1) ? flux->nj() : flux->nj() - 1;
110 for (int j = 0; j < nj; j++)
111 {
112 for (int i = 0; i < ni; i++)
113 {
114 (*flux)(i,j,0) = cut_field_current_fluxes[dir].pure_(i,j,k_layer);
115 int n = cut_cell_disc.get_n(i, j, k_layer);
116 if (n >= 0)
117 {
118 (*cut_cell_flux_)[dir].diph_l_(n) = cut_field_current_fluxes[dir].diph_l_(n);
119 (*cut_cell_flux_)[dir].diph_v_(n) = cut_field_current_fluxes[dir].diph_v_(n);
120 }
121 }
122 }
123 }
124
125 {
126 int ni = (dir == 0) ? flux->ni() : flux->ni() - 1;
127 int nj = (dir == 1) ? flux->nj() : flux->nj() - 1;
128 for (int j = 0; j < nj; j++)
129 {
130 for (int i = 0; i < ni; i++)
131 {
132 int n = cut_cell_disc.get_n(i, j, k_layer);
133 if (n >= 0)
134 {
135 const DoubleTabFT_cut_cell_vector3& indicatrice_surfacique = cut_cell_disc.get_interfaces().get_indicatrice_surfacique_efficace_face();
136 double indicatrice_surface = indicatrice_surfacique(n,dir);
137
138 cut_field_RK3_F_fluxes[dir].diph_l_(n) = (indicatrice_surface == 0.) ? 0. : cut_field_RK3_F_fluxes[dir].diph_l_(n)/indicatrice_surface;
139 cut_field_RK3_F_fluxes[dir].diph_v_(n) = ((1 - indicatrice_surface) == 0.) ? 0. : cut_field_RK3_F_fluxes[dir].diph_v_(n)/(1 -indicatrice_surface);
140 }
141 }
142 }
143 }
144 }
145
146 assert((*cut_cell_flux_)[dir].verify_consistency_within_layer(dir, k_layer, *flux));
147}
148
150 const IJK_Field_local_double& flux_x,
151 const IJK_Field_local_double& flux_y,
152 const IJK_Field_local_double& flux_zmin,
153 const IJK_Field_local_double& flux_zmax,
154 IJK_Field_double& resu, int k_layer, bool add)
155{
156 assert(&(cut_cell_flux[0].get_cut_cell_disc()) == &(cut_cell_flux[1].get_cut_cell_disc()));
157 assert(&(cut_cell_flux[0].get_cut_cell_disc()) == &(cut_cell_flux[2].get_cut_cell_disc()));
158 const Cut_cell_FT_Disc& cut_cell_disc = cut_cell_flux[0].get_cut_cell_disc();
159
160 Cut_field_double& cut_field_resu = static_cast<Cut_field_double&>(resu);
161
162 for (int index = cut_cell_disc.get_k_value_index(k_layer); index < cut_cell_disc.get_k_value_index(k_layer+1); index++)
163 {
164 int n = cut_cell_disc.get_n_from_k_index(index);
165 Int3 ijk = cut_cell_disc.get_ijk(n);
166
167 int i = ijk[0];
168 int j = ijk[1];
169 int k = ijk[2];
170
171 if (!cut_cell_disc.get_domaine().within_ghost(i, j, k, 0, 0))
172 continue;
173
174 if (flux_determined_by_wall_<DIRECTION::Z>(k))
175 {
176 Cerr << "Le cas d'une cellule diphasique avec flux de paroi n'est pas traite" << finl;
178 }
179 else
180 {
181 for (int phase = 0; phase < 2; phase++)
182 {
183 const DoubleTabFT_cut_cell& diph_flux_x = (phase == 0) ? cut_cell_flux[0].diph_v_ : cut_cell_flux[0].diph_l_;
184 const DoubleTabFT_cut_cell& diph_flux_y = (phase == 0) ? cut_cell_flux[1].diph_v_ : cut_cell_flux[1].diph_l_;
185 const DoubleTabFT_cut_cell& diph_flux_z = (phase == 0) ? cut_cell_flux[2].diph_v_ : cut_cell_flux[2].diph_l_;
186 DoubleTabFT_cut_cell& diph_resu = (phase == 0) ? cut_field_resu.diph_v_ : cut_field_resu.diph_l_;
187
188 int n_ip1 = cut_cell_disc.get_n(i+1,j,k);
189 int n_jp1 = cut_cell_disc.get_n(i,j+1,k);
190 int n_kp1 = cut_cell_disc.get_n(i,j,k+1);
191
192 double fx_centre = diph_flux_x(n);
193 double fy_centre = diph_flux_y(n);
194 double fz_centre = diph_flux_z(n);
195
196 double fx_right = (n_ip1 < 0) ? (cut_cell_disc.indic_pure(i+1,j,k) == phase)*flux_x(i+1,j,0) : diph_flux_x(n_ip1);
197 double fy_right = (n_jp1 < 0) ? (cut_cell_disc.indic_pure(i,j+1,k) == phase)*flux_y(i,j+1,0) : diph_flux_y(n_jp1);
198 double fz_right = (n_kp1 < 0) ? (cut_cell_disc.indic_pure(i,j,k+1) == phase)*flux_zmax(i,j,0) : diph_flux_z(n_kp1);
199
200 double r = 0;
201 r += fx_centre - fx_right;
202 r += fy_centre - fy_right;
203 r += fz_centre - fz_right;
204
205 if (add)
206 {
207 r += diph_resu(n);
208 }
209 diph_resu(n) = r;
210 }
211 }
212 }
213}
const Domaine_IJK & get_domaine() const
const IJK_Interfaces & get_interfaces() const
int get_n_from_k_index(int index) const
Int3 get_ijk(int n) const
int get_k_value_index(int k) const
double indic_pure(const int i, const int j, const int k) const
int get_n(int i, int j, int k) const
TRUSTTabFT_cut_cell< _TYPE_ > diph_l_
Definition Cut_field.h:49
TRUSTTabFT_cut_cell< _TYPE_ > diph_v_
Definition Cut_field.h:50
bool within_ghost(int i, int j, int k, int negative_ghost_size, int positive_ghost_size) const
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
const DoubleTabFT_cut_cell_vector3 & get_indicatrice_surfacique_efficace_face() const
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 compute_cut_cell_divergence(const FixedVector< Cut_cell_double, 3 > &cut_cell_flux, const IJK_Field_local_double &flux_x, const IJK_Field_local_double &flux_y, const IJK_Field_local_double &flux_zmin, const IJK_Field_local_double &flux_zmax, IJK_Field_double &resu, int k_layer, bool add)
static void exit(int exit_code=-1)
Routine de sortie de TRUST dans une region Kokkos.
Definition Process.cpp:455
Classe de base des flux de sortie.
Definition Sortie.h:52