TrioCFD 1.9.8
TrioCFD documentation
Loading...
Searching...
No Matches
OpGradQuickIJKScalar.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 <OpGradQuickIJKScalar.h>
17
18Implemente_instanciable_sans_constructeur( OpGradQuickIJKScalar_double, "OpGradQuickIJKScalar_double", OpConvQuickIJKScalar_double ) ;
19
21{
22 Objet_U::printOn( os );
23 return os;
24}
25
27{
28 Objet_U::readOn( is );
29 return is;
30}
31
32void OpGradQuickIJKScalar_double::calculer_grad(const IJK_Field_double& field,
33 IJK_Field_vector3_double& result)
34{
35 input_field_ = &field;
36 const int ni = field.ni();
37 const int nj = field.nj();
38 tmp_curv_fram_.allocate(ni, nj, 4, 1);
39 compute_grad(result);
40 input_field_ = nullptr;
41 input_velocity_x_ = nullptr;
42 input_velocity_y_ = nullptr;
43 input_velocity_z_ = nullptr;
44}
45
46void OpGradQuickIJKScalar_double::calculer_grad_x(const IJK_Field_double& field,
47 IJK_Field_double& result)
48{
49 input_field_ = &field;
50 const int ni = field.ni();
51 const int nj = field.nj();
52 tmp_curv_fram_.allocate(ni, nj, 4, 1);
53 compute_grad_x(result);
54 input_field_ = nullptr;
55 input_velocity_x_ = nullptr;
56 input_velocity_y_ = nullptr;
57 input_velocity_z_ = nullptr;
58}
59
60void OpGradQuickIJKScalar_double::calculer_grad_y(const IJK_Field_double& field,
61 IJK_Field_double& result)
62{
63 input_field_ = &field;
64 const int ni = field.ni();
65 const int nj = field.nj();
66 tmp_curv_fram_.allocate(ni, nj, 4, 1);
67 compute_grad_y(result);
68 input_field_ = nullptr;
69 input_velocity_x_ = nullptr;
70 input_velocity_y_ = nullptr;
71 input_velocity_z_ = nullptr;
72}
73
74void OpGradQuickIJKScalar_double::calculer_grad_z(const IJK_Field_double& field,
75 IJK_Field_double& result)
76{
77 input_field_ = &field;
78 const int ni = field.ni();
79 const int nj = field.nj();
80 tmp_curv_fram_.allocate(ni, nj, 4, 1);
81 compute_grad_z(result);
82 input_field_ = nullptr;
83 input_velocity_x_ = nullptr;
84 input_velocity_y_ = nullptr;
85 input_velocity_z_ = nullptr;
86}
87
88void OpGradQuickIJKScalar_double::fill_grad_field_x_y_(IJK_Field_local_double& flux, IJK_Field_double& resu, int k, int dir)
89{
90 int ni = resu.ni();
91 int nj = resu.nj();
92 switch(dir)
93 {
94 case 0:
95 for (int i=0; i < ni; i++)
96 for (int j=0; j < nj; j++)
97 resu(i,j,k) = flux(i+1,j,0) - flux(i,j,0);
98 break;
99 case 1:
100 for (int i=0; i < ni; i++)
101 for (int j=0; j < nj; j++)
102 resu(i,j,k) = flux(i,j+1,0) - flux(i,j,0);
103 break;
104 }
105}
106
107void OpGradQuickIJKScalar_double::fill_grad_field_z_(IJK_Field_local_double& flux_min, IJK_Field_local_double& flux_max, IJK_Field_double& resu, int k)
108{
109 int ni = resu.ni();
110 int nj = resu.nj();
111 for (int i=0; i < ni; i++)
112 for (int j=0; j < nj; j++)
113 {
114 // TODO: What happen if dz is not constant ? The FD operator is no longer define
115 double dz_inv = is_flux_ ? 1.: 1 / channel_data_.get_delta_z()[k];
116 resu(i,j,k) = (flux_max(i,j,0) - flux_min(i,j,0)) * dz_inv;
117 }
118}
119
120Implemente_instanciable_sans_constructeur( OpGradFluxQuickIJKScalar_double, "OpGradFluxQuickIJKScalar_double", OpGradQuickIJKScalar_double ) ;
121
123{
124 return os;
125}
126
128{
129 return is;
130}
131
133 const IJK_Field_double& vx,
134 const IJK_Field_double& vy,
135 const IJK_Field_double& vz,
136 IJK_Field_vector3_double& result)
137{
138 input_velocity_x_ = &vx;
139 input_velocity_y_ = &vy;
140 input_velocity_z_ = &vz;
141 calculer_grad(field, result);
142 result.echange_espace_virtuel();
143}
144
145void OpGradFluxQuickIJKScalar_double::fill_grad_field_x_y_(IJK_Field_local_double& flux, IJK_Field_double& resu, int k, int dir)
146{
147 int ni = resu.ni();
148 int nj = resu.nj();
149 for (int i=0; i < ni; i++)
150 for (int j=0; j < nj; j++)
151 resu(i,j,k) = flux(i,j,0);
152}
153
154void OpGradFluxQuickIJKScalar_double::fill_grad_field_z_(IJK_Field_local_double& flux_min,
155 IJK_Field_local_double& flux_max,
156 IJK_Field_double& resu, int k)
157{
158 fill_grad_field_x_y_(flux_min, resu, k, 2);
159}
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 fill_grad_field_x_y_(IJK_Field_local_double &flux, IJK_Field_double &resu, int k, int dir) override
void calculer_grad_flux(const IJK_Field_double &field, const IJK_Field_double &vx, const IJK_Field_double &vy, const IJK_Field_double &vz, IJK_Field_vector3_double &result)
void fill_grad_field_z_(IJK_Field_local_double &flux_min, IJK_Field_local_double &flux_max, IJK_Field_double &resu, int k) override
void fill_grad_field_x_y_(IJK_Field_local_double &flux, IJK_Field_double &resu, int k, int dir) override
void calculer_grad_y(const IJK_Field_double &field, IJK_Field_double &result)
void calculer_grad_x(const IJK_Field_double &field, IJK_Field_double &result)
void fill_grad_field_z_(IJK_Field_local_double &flux_min, IJK_Field_local_double &flux_max, IJK_Field_double &resu, int k) override
void calculer_grad(const IJK_Field_double &field, IJK_Field_vector3_double &result)
void calculer_grad_z(const IJK_Field_double &field, IJK_Field_double &result)
virtual void compute_grad(IJK_Field_vector3_double &dx)
virtual void compute_grad_x(IJK_Field_double &dx)
virtual void compute_grad_y(IJK_Field_double &dx)
virtual void compute_grad_z(IJK_Field_double &dx)
Classe de base des flux de sortie.
Definition Sortie.h:52