TrioCFD 1.9.8
TrioCFD documentation
Loading...
Searching...
No Matches
IJK_One_Dimensional_Subproblems_Interfaces_Fields.cpp
1/****************************************************************************
2* Copyright (c) 2024, 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 <IJK_One_Dimensional_Subproblems_Interfaces_Fields.h>
17#include <Probleme_FTD_IJK.h>
18#include <IJK_One_Dimensional_Subproblems.h>
19#include <IJK_Navier_Stokes_tools.h>
20
21Implemente_instanciable_sans_constructeur( IJK_One_Dimensional_Subproblems_Interfaces_Fields, "IJK_One_Dimensional_Subproblems_Interfaces_Fields", Objet_U ) ;
22
23IJK_One_Dimensional_Subproblems_Interfaces_Fields::IJK_One_Dimensional_Subproblems_Interfaces_Fields()
24{
25
26}
27
29 IJK_One_Dimensional_Subproblems& thermal_local_subproblems,
30 const int& debug)
31{
32 thermal_local_subproblems_ = &thermal_local_subproblems;
33 debug_ = debug;
34
35 tmp_ft_field_val_.allocate(ref_ijk_ft_->get_domaine_ft(), Domaine_IJK::ELEM, 1);
36 tmp_ft_field_val_.data() = 0.;
37 tmp_ft_field_val_.echange_espace_virtuel(tmp_ft_field_val_.ghost());
38
39 tmp_field_val_.allocate(splitting, Domaine_IJK::ELEM, 1);
40 tmp_field_val_.data() = 0.;
41 tmp_field_val_.echange_espace_virtuel(tmp_field_val_.ghost());
42}
43
45{
46 /*
47 * interface_field_type_ = 0 - Do Nothing
48 * interface_field_type_ = 1 - GFM
49 * interface_field_type_ = 2 - Subres
50 */
51 interface_field_type_ = interface_field_type;
52}
53
55{
57 {
58 /*
59 * TODO : PB interface at time (n+1) only
60 * Need a copy
61 * There's a problem with Intersections_Elem_Facettes_Data which is a pointer
62 * Need a usr-defined destructor for the current class...
63 */
64 // const IJK_Interfaces& interfaces = ref_ijk_ft_->itfce();
65 // const Maillage_FT_IJK& maillage = interfaces.maillage_ft_ijk();
66 // const Intersections_Elem_Facettes& intersections = maillage.intersections_elem_facettes();
67 // const ArrOfDouble& surface_facettes = maillage.get_update_surface_facettes();
68 // const IntTab& facettes = maillage.facettes();
69 // intersections_ = intersections;
70 // surface_facettes_ = surface_facettes;
71 // facettes_ = facettes;
72 }
73}
74
86
88{
89 Objet_U::printOn( os );
90 return os;
91}
92
94{
95 Objet_U::readOn( is );
96 return is;
97}
98
104
106{
107 liste.add("FT_INTERFACIAL_HEAT_FLUX");
108 liste.add("FT_INTERFACIAL_VELOCITY_MAGNITUDE");
109 liste.add("FT_INTERFACIAL_TEMPERATURE");
110}
111
112
114 const char *lata_name,
115 const int lata_step)
116{
117 int n = 0;
119 {
120 const Nom interf_heat_flux("FT_INTERFACIAL_HEAT_FLUX_DENSITY");
121 if (liste_post_instantanes.contient_(interf_heat_flux))
122 {
123 bool is_updated = retrieve_interfacial_surface_quantities(interf_heat_flux);
124 if (is_updated)
125 n++, dumplata_ft_field(lata_name, "INTERFACES", interf_heat_flux, "SOM", interfacial_heat_flux_sol_, lata_step);
126 }
127
128 const Nom interf_heat_flux_interp("FT_INTERFACIAL_HEAT_FLUX_DENSITY_INTERP");
129 if (liste_post_instantanes.contient_(interf_heat_flux_interp))
130 {
131 bool is_updated = retrieve_interfacial_surface_quantities(interf_heat_flux_interp);
132 if (is_updated)
133 n++, dumplata_ft_field(lata_name, "INTERFACES", interf_heat_flux_interp, "SOM", interfacial_heat_flux_, lata_step);
134 }
135
136 const Nom interf_velocity_magnitude("FT_INTERFACIAL_VELOCITY_MAGNITUDE");
137 if (liste_post_instantanes.contient_(interf_velocity_magnitude))
138 {
139 bool is_updated = retrieve_interfacial_surface_quantities(interf_velocity_magnitude);
140 if (is_updated)
141 n++, dumplata_ft_field(lata_name, "INTERFACES", interf_velocity_magnitude, "SOM", velocity_magnitude_, lata_step);
142 }
143
144 const Nom interf_temperature("FT_INTERFACIAL_TEMPERATURE");
145 if (liste_post_instantanes.contient_(interf_temperature))
146 {
147 bool is_updated = retrieve_interfacial_surface_quantities(interf_temperature);
148 if (is_updated)
149 n++, dumplata_ft_field(lata_name, "INTERFACES", interf_temperature, "SOM", temperature_sol_, lata_step);
150 }
151
152 const Nom interf_temperature_gradient("FT_INTERFACIAL_TEMPERATURE_GRADIENT");
153 if (liste_post_instantanes.contient_(interf_temperature_gradient))
154 {
155 bool is_updated = retrieve_interfacial_surface_quantities(interf_temperature_gradient);
156 if (is_updated)
157 n++, dumplata_ft_field(lata_name, "INTERFACES", interf_temperature_gradient, "SOM", temperature_gradient_sol_, lata_step);
158 }
159
160 const Nom interf_temperature_interp("FT_INTERFACIAL_TEMPERATURE_INTERP");
161 if (liste_post_instantanes.contient_(interf_temperature_interp))
162 {
163 bool is_updated = retrieve_interfacial_surface_quantities(interf_temperature_interp);
164 if (is_updated)
165 n++, dumplata_ft_field(lata_name, "INTERFACES", interf_temperature_interp, "SOM", temperature_, lata_step);
166 }
167
168 const Nom interf_temperature_gradient_interp("FT_INTERFACIAL_TEMPERATURE_GRADIENT_INTERP");
169 if (liste_post_instantanes.contient_(interf_temperature_gradient_interp))
170 {
171 bool is_updated = retrieve_interfacial_surface_quantities(interf_temperature_gradient_interp);
172 if (is_updated)
173 n++, dumplata_ft_field(lata_name, "INTERFACES", interf_temperature_gradient_interp, "SOM", temperature_gradient_, lata_step);
174 }
175
176 reset_flags();
177 }
178 return n;
179}
180
182{
183 if (surface_post_name == Nom("FT_INTERFACIAL_HEAT_FLUX_DENSITY"))
185 else if (surface_post_name == Nom("FT_INTERFACIAL_VELOCITY_MAGNITUDE"))
187 else if (surface_post_name == Nom("FT_INTERFACIAL_TEMPERATURE"))
189 else if (surface_post_name == Nom("FT_INTERFACIAL_TEMPERATURE_GRADIENT"))
191 else if (surface_post_name == Nom("FT_INTERFACIAL_TEMPERATURE_INTERP"))
193 else if (surface_post_name == Nom("FT_INTERFACIAL_TEMPERATURE_GRADIENT_INTERP"))
195 else if (surface_post_name == Nom("FT_INTERFACIAL_HEAT_FLUX_DENSITY_INTERP"))
197 else
198 return false;
199}
200
201bool IJK_One_Dimensional_Subproblems_Interfaces_Fields::retrieve_interfacial_surface_quantity(ArrOfDouble& surface_quantity, bool& has_been_updated, const int& val_index)
202{
203 int counter_val_elem = 0;
204 int counter_val_interf = 0;
205 static const double invalid_value = INVALID_TEST;
206 if (!has_been_updated)
207 {
208 vertices_surface_.reset();
209 eulerian_values_.reset();
210 surface_quantity.reset();
211 tmp_field_val_.data() = invalid_value * 1.1;
212 tmp_ft_field_val_.data() = invalid_value * 1.1;
213 if (!counter_call_)
214 elem_crossed_.reset();
215 const int dim = 3;
216 const IJK_Interfaces& interfaces = ref_ijk_ft_->get_interface();
217 const Domaine_IJK& splitting = ref_ijk_ft_->get_domaine_ft();
218
219 const Domaine_dis_base& mon_dom_dis = interfaces.get_domaine_dis();
220 const Maillage_FT_IJK& maillage = interfaces.maillage_ft_ijk();
221 const Intersections_Elem_Facettes& intersections = maillage.intersections_elem_facettes();
222 const ArrOfInt& index_elem = intersections.index_elem();
223 const ArrOfDouble& surface_facettes = maillage.get_update_surface_facettes();
224 const ArrOfInt& sommet_elem = maillage.sommet_elem();
225 const IntTab& facettes = maillage.facettes();
226 const DoubleTab& sommets = maillage.sommets();
227
228 /*
229 * TODO : PB interface at time (n+1) only
230 */
231 // const Intersections_Elem_Facettes& intersections= intersections_;
232 // const ArrOfInt& index_elem = intersections.index_elem();
233 // const ArrOfDouble& surface_facettes = surface_facettes_;
234 // const IntTab& facettes = facettes_;
235 // const ArrOfInt& sommets_elems = maillage.sommet_elem();
236 const int nb_vertices = sommets.dimension(0);
237 const int nb_vertices_elem = sommet_elem.size_array();
238 if (debug_)
239 {
240 Cerr << "Nb vertices: " << nb_vertices << finl;
241 Cerr << "Nb vertices elem: " << nb_vertices_elem << finl;
242 }
243 vertices_surface_.resize(nb_vertices);
244 surface_quantity.resize(nb_vertices);
245 vertices_surface_ *= 0.;
246 surface_quantity *= 0.;
247
248 int index_i, index_j, index_k;
249 const int nb_subproblems = thermal_local_subproblems_->get_effective_subproblems_counter();
250 for (int m = 0; m < nb_subproblems; m++)
251 {
252 const double eulerian_value = thermal_local_subproblems_->get_thermal_subproblem_value_at_ijk_index(m, index_i, index_j, index_k, val_index);
253 tmp_field_val_(index_i, index_j, index_k) = eulerian_value;
254 eulerian_values_.append_array(eulerian_value);
255 if (!counter_call_)
256 {
257 const int elem = splitting.convert_ijk_cell_to_packed(index_i, index_j, index_k);
258 elem_crossed_.append_array(elem);
259 }
260 }
261
262 ref_ijk_ft_->eq_ns().redistribute_to_splitting_ft_elem(tmp_field_val_, tmp_ft_field_val_);
263 tmp_ft_field_val_.echange_espace_virtuel(tmp_ft_field_val_.ghost());
264
265 const int nb_elem = mon_dom_dis.domaine().nb_elem();
266
267 // const int nb_elem = (int) elem_crossed_.size_array();
268 for (int elem = 0; elem < nb_elem; elem++)
269 {
270 // const int local_elem = elem_crossed_[elem];
271 // int index = index_elem[local_elem];
272 // const double eulerian_value = eulerian_values_[elem];
273 int index = index_elem[elem];
274 if (index >= 0)
275 {
276 double eulerian_value = 0.;
277 const Int3 num_elem_ijk = splitting.convert_packed_to_ijk_cell(elem);
278 const int& i = num_elem_ijk[DIRECTION_I];
279 const int& j = num_elem_ijk[DIRECTION_J];
280 const int& k = num_elem_ijk[DIRECTION_K];
281 get_surrounding_value(i, j, k, eulerian_value);
282 // Loop on the facets which cross the element
283 while (index >= 0)
284 {
285 const Intersections_Elem_Facettes_Data& data = intersections.data_intersection(index);
286 const int num_facette = data.numero_facette_;
287 const double surface = data.fraction_surface_intersection_ * surface_facettes[num_facette];
288 if (abs(surface) > MIN_SURFACE)
289 for (int l = 0; l < dim; l++)
290 {
291 const int som = facettes(num_facette, l);
292 vertices_surface_[som] += surface;
293 const double surface_value = eulerian_value;
294 surface_quantity[som] += (surface_value * surface);
295 counter_val_interf++;
296 }
297 else if (debug_)
298 Cerr << "Small surface intersection detected: " << surface << finl;
299 index = data.index_facette_suivante_;
300 }
301 counter_val_elem++;
302 }
303 }
304 averaged_by_vertex_surface(surface_quantity);
305 has_been_updated = true;
306 counter_call_ += 1;
307 }
308 if (debug_)
309 {
310 Cerr << "Elems contributing to interfacial post-processing: " << counter_val_elem << finl;
311 Cerr << "Facets contributing to interfacial post-processing: " << counter_val_interf << finl;
312 }
313 return true && has_been_updated;
314}
315
317{
318 const int size_array = (int) vertices_surface_.size_array();
319 for (int m=0; m<size_array; m++)
320 {
321 const double surface_quantity_tmp = surface_quantity[m];
322 const double surface_tot_som = vertices_surface_[m];
323 if (abs(surface_tot_som) > MIN_SURFACE)
324 surface_quantity[m] = surface_quantity_tmp / surface_tot_som;
325 else if (debug_)
326 {
327 Cerr << "Small interface portion detected" << finl;
328 Cerr << "Surface value of: " << surface_tot_som << finl;
329 }
330 }
331}
332
333void IJK_One_Dimensional_Subproblems_Interfaces_Fields::get_surrounding_value(const int& i, const int& j, const int& k, double& eulerian_value)
334{
335 static const double invalid_value = INVALID_TEST;
336 eulerian_value = tmp_ft_field_val_(i,j,k);
337 if (eulerian_value < invalid_value)
338 {
339 // double max_val = 0.;
340 double avg_val = 0.;
341 int nb_avg = 0;
342 for (int c=0; c<3; c++)
343 for (int l=-1; l<=1; l++)
344 {
345 const int ii = select_dir(c, l, 0, 0);
346 const int jj = select_dir(c, 0, l, 0);
347 const int kk = select_dir(c, 0, 0, l);
348 const double local_val = tmp_ft_field_val_(i+ii, j+jj, k+kk);
349 if (local_val > INVALID_TEST)
350 {
351 // max_val = (abs(local_val) > abs(max_val) ? local_val : max_val);
352 avg_val += local_val;
353 nb_avg++;
354 }
355 }
356 if (nb_avg)
357 avg_val /= nb_avg;
358 // tmp_ft_field_val_(i, j, k) = avg_val;
359 eulerian_value = avg_val;
360 }
361}
362
int_t nb_elem() const
Definition Domaine.h:131
This class encapsulates all the information related to the eulerian mesh for TrioIJK.
Definition Domaine_IJK.h:47
int convert_ijk_cell_to_packed(const FixedVector< int, 3 > ijk) const
Converts the ijk index of an element to a cell index.
FixedVector< int, 3 > convert_packed_to_ijk_cell(int index) const
Convert the local index of an element to a vector with IJK indices.
classe Domaine_dis_base Cette classe est la base de la hierarchie des domaines discretisees.
const Domaine & domaine() const
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
: class IJK_Interfaces
const Domaine_dis_base & get_domaine_dis() const
const Maillage_FT_IJK & maillage_ft_ijk() const
bool retrieve_interfacial_surface_quantity(ArrOfDouble &surface_quantity, bool &has_been_updated, const int &val_index)
void initialise(const Domaine_IJK &splitting, IJK_One_Dimensional_Subproblems &thermal_local_subproblems, const int &debug)
void get_surrounding_value(const int &i, const int &j, const int &k, double &eulerian_value)
int posttraiter_champs_instantanes(const Motcles &liste_post_instantanes, const char *lata_name, const int lata_step)
: class Intersections_Elem_Facettes
const ArrOfInt & index_elem() const
Renvoie un tableau de taille domaine.
const Intersections_Elem_Facettes_Data & data_intersection(int index) const
Renvoie les donnees de l'intersection stockee a l'indice "index" dans le tableau "data" ( 0 <= index ...
const DoubleTab & sommets() const
renvoie le tableau des sommets (reels et virtuels) dimension(0) = nombre de sommets,
const Intersections_Elem_Facettes & intersections_elem_facettes() const
virtual const ArrOfDouble & get_update_surface_facettes() const
Calcule la grandeur demandee, stocke le resultat dans un tableau interne a la classe et renvoie le re...
const IntTab & facettes() const
renvoie le tableau des facettes (reelles et virtuelles) dimension(0) = nombre de facettes,
const ArrOfInt & sommet_elem() const
pour postraitement, renvoie sommet_elem_
: class Maillage_FT_IJK
Un tableau d'objets de la classe Motcle.
Definition Motcle.h:63
int contient_(const char *const ch) const
Definition Motcle.cpp:333
class Nom Une chaine de caractere pour nommer les objets de TRUST
Definition Nom.h:31
classe Objet_U Cette classe est la classe de base des Objets de TRUST
Definition Objet_U.h:73
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
Motcles get_liste_post_instantanes() const
const Postprocessing_IJK & get_post() const
Classe de base des flux de sortie.
Definition Sortie.h:52
virtual void reset()
Definition TRUSTArray.h:240
_SIZE_ size_array() const
void resize(_SIZE_ new_size, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT)
Definition TRUSTArray.h:156
_SIZE_ dimension(int d) const
Definition TRUSTTab.tpp:133