TrioCFD 1.9.8
TrioCFD documentation
Loading...
Searching...
No Matches
OpConvCentre2IJKScalar.tpp
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#ifndef OpConvCentre2IJKScalar_TPP_included
17#define OpConvCentre2IJKScalar_TPP_included
18
19#include <OpConvCentre2IJKScalar.h>
20
21#ifndef OpConvCentre2IJKScalar_included
22#error __FILE__ should only be included from corresponding header
23#endif
24#include <IJK_Field.h>
25#include <ConstIJK_ptr.h>
26#include <IJK_Field_local_template.h>
27#include <IJK_ptr.h>
28#include <Operateur_IJK_base.h>
29#include <Simd_template.h>
30
31template <DIRECTION _DIR_>
32void OpConvCentre2IJKScalar_double::compute_flux_(IJK_Field_local_double& resu, const int k_layer)
33{
34 Simd_double velocity(1.);
35 if (is_grad_ && !is_flux_)
36 {
37 /*
38 * TODO: Associate pointers to create a dummy field
39 * May be dangerous but I don't want to create multiple copy
40 * or instantiate a dummy field ! What do you think ?
41 */
45 }
46 ConstIJK_double_ptr velocity_dir(get_input_velocity(_DIR_), 0, 0, k_layer);
47 ConstIJK_double_ptr input_field(*input_field_, 0, 0, k_layer);
48 IJK_double_ptr resu_ptr(resu, 0, 0, 0);
49 const int nx = _DIR_==DIRECTION::X ? input_field_->ni() + 1 : input_field_->ni();
50 const int ny = _DIR_==DIRECTION::Y ? input_field_->nj() + 1 : input_field_->nj();
51 double surface = 1.;
52 if (!is_grad_ || is_flux_)
53 surface = channel_data_.get_surface(k_layer, 1, (int) _DIR_);
54 else
55 {
56 switch(_DIR_)
57 {
58 case DIRECTION::X:
59 surface = 1 / channel_data_.get_delta_x();
60 break;
61 case DIRECTION::Y:
62 surface = 1 / channel_data_.get_delta_y();
63 break;
64 case DIRECTION::Z:
65 break;
66 }
67 }
68
69 if(_DIR_ == DIRECTION::Z)
70 {
71 // Are we on the wall ?
72 const int global_k_layer = k_layer + channel_data_.offset_to_global_k_layer();
73 // global index of the layer of flux of the wall
74 // (assume one walls at zmin and zmax)
75 const int first_global_k_layer = 0;
76 const int last_global_k_layer = channel_data_.nb_elem_k_tot();
77
78 // GB 21/12/2020 : Similarly to velocity, we make the same adjustments.
79 // if (global_k_layer == first_global_k_layer || global_k_layer == last_global_k_layer) {
80 // ie (i) replace the former "==" by "<=" and ">=" to be identic to the condition in OpCentre4IJK
81 // and (ii) add the condition on perio_k
82 if (!perio_k_ && (global_k_layer <= first_global_k_layer || global_k_layer >= last_global_k_layer))
83 {
84 // We are on (or worse inside) the wall, zero flux
85 putzero(resu);
86 return;
87 }
88 }
89
90 const double velocity_frame = velocity_frame_of_reference_[(int) _DIR_];
91
92 const int imax = nx;
93 const int jmax = ny;
94 const int vsize = Simd_double::size();
95 for (int j = 0; ; j++)
96 {
97 for (int i = 0; i < imax; i += vsize)
98 {
99 if (!is_grad_ || is_flux_)
100 velocity_dir.get_center(i, velocity);
101 Simd_double T0, T1; // scalar value at left and at right of the computed flux
102 input_field.get_left_center(_DIR_, i, T0, T1);
103 Simd_double flux = (T0 + T1) * 0.5;
104 flux = flux * (velocity - velocity_frame) * surface;
105 resu_ptr.put_val(i, flux);
106 }
107 // do not execute end_iloop at last iteration (because of assert on valid j+1)
108 if (j+1==jmax)
109 break;
110 input_field.next_j();
111 if (!is_grad_)
112 velocity_dir.next_j();
113 resu_ptr.next_j();
114 }
115
116 if(_DIR_ == DIRECTION::Z)
117 {
118 // store curv and fram for next layer of fluxes in z direction
121 }
122}
123
124#endif
125
126
const IJK_Field_double & get_input_velocity(DIRECTION _DIR_)
void shift_curv_fram(IJK_Field_local_double &tmp_curv_fram)