TrioCFD 1.9.8
TrioCFD documentation
Loading...
Searching...
No Matches
Tensors_Computation_VDF.cpp
1/****************************************************************************
2* Copyright (c) 2025, 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 <Tensors_Computation_VDF.h>
17#include <TRUSTTab.h>
18#include <Domaine_VDF.h>
19#include <Domaine_Cl_VDF.h>
20#include <Champ_Face_VDF.h>
21#include <Probleme_base.h>
22
23using TCV = Tensors_Computation_VDF;
24
26 const Domaine_Cl_VDF& dom_BC_VDF,
27 const DoubleTab& velocity,
28 Champ_Face_VDF& ch_vit,
30 DoubleTab& enstrophy) const
31{
32 // Get gradient of velocity
33 const int nb_elem_tot = dom_VDF.nb_elem_tot();
34 const int dimension = Objet_U::dimension;
35 DoubleTab gradient_elem(nb_elem_tot, dimension*dimension);
36 gradient_elem = 0.;
37
38 if (ns_turb.has_champ("gradient_vitesse")) //if the gradient is already computed (post_processing)
39 gradient_elem.ref(ns_turb.get_champ("gradient_vitesse").valeurs());
40 else
41 ch_vit.calcul_grad_u(velocity, gradient_elem, dom_BC_VDF);
42
43 antisym_enstrophy(dom_VDF, gradient_elem, enstrophy);
44}
45
47 const Domaine_Cl_VDF& dom_BC_VDF,
48 const DoubleTab& velocity,
49 Champ_Face_VDF& ch_vit,
51 DoubleTab& strain_invariant) const
52{
53 // Get gradient of velocity
54 const int nb_elem_tot = dom_VDF.nb_elem_tot();
55 const int dimension = Objet_U::dimension;
56 DoubleTab gradient_elem(nb_elem_tot, dimension*dimension);
57 gradient_elem = 0.;
58
59 if (ns_turb.has_champ("gradient_vitesse")) //if the gradient is already computed (post_processing)
60 gradient_elem.ref(ns_turb.get_champ("gradient_vitesse").valeurs());
61 else
62 ch_vit.calcul_grad_u(velocity, gradient_elem, dom_BC_VDF);
63
64 antisym_strain_invariant(dom_VDF, gradient_elem, strain_invariant);
65}
66
68 const DoubleTab& gradient_elem,
69 DoubleTab& strain_invariant) const
70{
71 const int nb_elem = dom_VDF.nb_elem();
72 for (int elem=0; elem<nb_elem; elem++)
73 {
74 double SijSij=0;
75 if (Objet_U::dimension==2)
76 {
77 const double du_dx= gradient_elem(elem,0);
78 const double du_dy= gradient_elem(elem,1);
79 const double dv_dx= gradient_elem(elem,2);
80 const double dv_dy= gradient_elem(elem,3);
81 SijSij = du_dx*du_dx
82 +0.5*(du_dy+dv_dx)*(du_dy+dv_dx)
83 +dv_dy*dv_dy ;
84 }
86 {
87 const double du_dx= gradient_elem(elem,0);
88 const double du_dy= gradient_elem(elem,1);
89 const double du_dz= gradient_elem(elem,2);
90 const double dv_dx= gradient_elem(elem,3);
91 const double dv_dy= gradient_elem(elem,4);
92 const double dv_dz= gradient_elem(elem,5);
93 const double dw_dx= gradient_elem(elem,6);
94 const double dw_dy= gradient_elem(elem,7);
95 const double dw_dz= gradient_elem(elem,8);
96
97 SijSij = du_dx*du_dx
98 +0.5*(du_dy+dv_dx)*(du_dy+dv_dx)
99 +dv_dy*dv_dy+
100 0.5*(du_dz+dw_dx)*(du_dz+dw_dx)
101 + 0.5*(dv_dz+dw_dy)*(dv_dz+dw_dy)
102 + dw_dz*dw_dz ;
103 }
104 strain_invariant(elem) = sqrt(2*SijSij);
105 }
106}
107
109 const DoubleTab& gradient_elem,
110 DoubleTab& enstrophy) const
111{
112 const int nb_elem = dom_VDF.nb_elem();
113 for (int elem=0; elem<nb_elem; elem++)
114 {
115 double tmp=0.;
116 if (Objet_U::dimension==2)
117 {
118 const double du_dy= gradient_elem(elem,1);
119 const double dv_dx= gradient_elem(elem,2);
120 tmp = 0.5*((du_dy - dv_dx)*(du_dy - dv_dx) +
121 (dv_dx - du_dy)*(dv_dx - du_dy));
122 }
123 if(Objet_U::dimension==3)
124 {
125 const double du_dy= gradient_elem(elem,1);
126 const double dv_dx= gradient_elem(elem,3);
127
128 const double du_dz= gradient_elem(elem,2);
129 const double dv_dz= gradient_elem(elem,5);
130 const double dw_dx= gradient_elem(elem,6);
131 const double dw_dy= gradient_elem(elem,7);
132
133 tmp = 0.5*( (du_dy - dv_dx)*(du_dy - dv_dx) +
134 (dv_dx - du_dy)*(dv_dx - du_dy) +
135 (du_dz - dw_dx)*(du_dz - dw_dx) +
136 (dv_dz - dw_dy)*(dv_dz - dw_dy) +
137 (dw_dx - du_dz)*(dw_dx - du_dz) +
138 (dw_dy - dv_dz)*(dw_dy - dv_dz)
139 );
140
141
142 }
143 enstrophy(elem) = sqrt(tmp);
144 }
145}
146
class Champ_Face_VDF Cette classe sert a representer un champ vectoriel dont on ne calcule
void calcul_grad_u(const DoubleTab &, DoubleTab &, const Domaine_Cl_VDF &)
virtual DoubleTab & valeurs()=0
class Domaine_Cl_VDF
class Domaine_VDF
Definition Domaine_VDF.h:64
int nb_elem_tot() const
classe Navier_Stokes_Turbulent Cette classe represente l'equation de la dynamique pour un fluide
const Champ_base & get_champ(const Motcle &nom) const override
bool has_champ(const Motcle &nom, OBS_PTR(Champ_base) &ref_champ) const override
static int dimension
Definition Objet_U.h:99
virtual void ref(const TRUSTTab &)
Definition TRUSTTab.tpp:308
void antisym_strain_invariant(const Domaine_VDF &dom_VDF, const DoubleTab &gradient_elem, DoubleTab &strain_invariant) const
void compute_strain_invariant(const Domaine_VDF &, const Domaine_Cl_VDF &, const DoubleTab &velocity, Champ_Face_VDF &ch_vit, Navier_Stokes_Turbulent &ns_turb, DoubleTab &strain_invariant) const
void compute_enstrophy(const Domaine_VDF &, const Domaine_Cl_VDF &, const DoubleTab &velocity, Champ_Face_VDF &ch_vit, Navier_Stokes_Turbulent &ns_turb, DoubleTab &enstrophy) const
void antisym_enstrophy(const Domaine_VDF &dom_VDF, const DoubleTab &gradient_elem, DoubleTab &enstrophy) const