TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Op_Rot_VEFP1B.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 <Champ_P1_isoP1Bulle.h>
17#include <Op_Div_VEFP1B_Elem.h>
18
19#include <Domaine_Cl_VEF.h>
20#include <Op_Rot_VEFP1B.h>
21#include <Matrice_Morse.h>
22
23#include <TRUSTList.h>
24#include <Front_VF.h>
25#include <Domaine.h>
26
27Implemente_instanciable(Op_Rot_VEFP1B, "Op_Rot_VEFPreP1B_P1NC", Operateur_base);
28
29Sortie& Op_Rot_VEFP1B::printOn(Sortie& s) const { return s << que_suis_je(); }
30
31Entree& Op_Rot_VEFP1B::readOn(Entree& s) { return s; }
32
33void Op_Rot_VEFP1B::associer_coins(const ArrOfInt& arr) { coins = arr; }
34
35int est_un_coin(int num, const ArrOfInt& coins)
36{
37 for (int i = 0; i < coins.size_array(); i++)
38 if (num == coins[i])
39 return 1;
40 return 0;
41}
42
43void Op_Rot_VEFP1B::associer(const Domaine_dis_base& domaine_dis, const Domaine_Cl_dis_base& domaine_Cl_dis, const Champ_Inc_base&)
44{
45 le_dom_vef = ref_cast(Domaine_VEF, domaine_dis);
46 la_zcl_vef = ref_cast(Domaine_Cl_VEF, domaine_Cl_dis);
47}
48
49DoubleTab& Op_Rot_VEFP1B::calculer(const DoubleTab& vorticite, DoubleTab& rot) const
50{
51 rot = 0;
52 return ajouter(vorticite, rot);
53
54}
55
56//Method for computing the curl of the vorticity.
57DoubleTab& Op_Rot_VEFP1B::ajouter(const DoubleTab& vorticite, DoubleTab& rot) const
58{
59 const Domaine_VEF& domaine_VEF = le_dom_vef.valeur();
60 const Domaine& domaine = domaine_VEF.domaine();
61 const IntTab& face_voisins = domaine_VEF.face_voisins();
62
63 int elem0, elem1;
64 int sommet_global, face_opp;
65
66 //Some useful variables
67 DoubleTab vecteur_normal_elem0(dimension);
68 DoubleTab vecteur_normal_elem1(dimension);
69 DoubleTab vecteur_normal_opp_elem0(dimension);
70 DoubleTab vecteur_normal_opp_elem1(dimension);
71
72 IntList sommets_elem0, sommets_elem1;
73 IntList faces_opp_elem0, faces_opp_elem1;
74
75 // Process the boundary conditions:
76 // for now, no boundary conditions for the vorticity.
77 // Free outlet = no boundary conditions ????
78
79 // Process the internal faces, i.e. without boundary conditions
80 int premiere_face_int = domaine_VEF.premiere_face_int();
81 int nb_faces = domaine_VEF.nb_faces();
82
83 if (dimension > 2)
84 {
85 Cerr << "Error OpRot: only the 2D case is supported at the moment" << finl;
87 }
88
89 for (int face = premiere_face_int; face < nb_faces; face++)
90 {
91 int modulo;
92 elem0 = face_voisins(face, 0);
93 elem1 = face_voisins(face, 1);
94
95 // Compute the curl of the vorticity: P0 part of the unknown
96
97 /* Compute the appropriate tangent vector for the P0 part of the unknown */
98 vecteur_normal_elem0 = vecteur_normal(face, elem0);
99 vecteur_normal_elem1 = vecteur_normal(face, elem1);
100
101 /* Compute the curl of the vorticity properly */
102 /* P0 part */
103 for (int composante = 0; composante < dimension; composante++)
104 {
105 modulo = (1 + composante) % dimension;
106 rot(face, composante) += pow(-1., modulo) * (vorticite(elem0) * vecteur_normal_elem0(modulo) + vorticite(elem1) * vecteur_normal_elem1(modulo));
107
108 }
109
110 // Compute the curl of the vorticity: P1 part of the unknown
111
112 /* We need for each triangle to know the list */
113 /* of vertices belonging to it and the faces */
114 /* opposite to these vertices */
115 if (!sommets_elem0.est_vide())
116 sommets_elem0.vide();
117 if (!sommets_elem1.est_vide())
118 sommets_elem1.vide();
119 if (!faces_opp_elem0.est_vide())
120 faces_opp_elem0.vide();
121 if (!faces_opp_elem1.est_vide())
122 faces_opp_elem1.vide();
123
124 for (int i = 0; i < domaine.nb_som_elem(); i++)
125 {
126 sommets_elem0.add_if_not(domaine.sommet_elem(elem0, i));
127 faces_opp_elem0.add_if_not(domaine_VEF.elem_faces(elem0, i));
128 sommets_elem1.add_if_not(domaine.sommet_elem(elem1, i));
129 faces_opp_elem1.add_if_not(domaine_VEF.elem_faces(elem1, i));
130 }
131
132 /* Now, compute the contribution to the curl */
133 /* for the P1 part of the unknown */
134 /* WARNING: given the definition of the vector space */
135 /* generating omega, the vertex with the LARGEST index */
136 /* must NOT be taken into account */
137 for (int composante = 0; composante < dimension; composante++)
138 {
139 modulo = (1 + composante) % dimension;
140
141 ///////////////////////////////
142 /* Partie (w,curl Psi_c e_i) */
143 //////////////////////////////
144 double sommation_sommets = 0.;
145 //Compute for "elem0"
146 for (int i = 0; i < sommets_elem0.size(); i++)
147 {
148 sommet_global = sommets_elem0[i];
149
150 //To eliminate the last vertex
151 if (sommet_global != domaine.nb_som() - 1)
152 sommation_sommets += vorticite(domaine.nb_elem() + sommet_global);
153 }
154
155 rot(face, composante) += -pow(-1., modulo) / (dimension + 1) * vecteur_normal_elem0(modulo) * sommation_sommets;
156
157 //Compute for "elem1"
158 sommation_sommets = 0.;
159 for (int i = 0; i < sommets_elem1.size(); i++)
160 {
161 sommet_global = sommets_elem1[i];
162
163 //To eliminate the last vertex
164 if (sommet_global != domaine.nb_som() - 1)
165 sommation_sommets += vorticite(domaine.nb_elem() + sommet_global);
166 }
167
168 rot(face, composante) += -pow(-1., modulo) / (dimension + 1) * vecteur_normal_elem1(modulo) * sommation_sommets;
169
170 //////////////////////////////////////
171 /* End of (w,curl Psi_c e_i) part */
172 /////////////////////////////////////
173 ///////////////////////////////
174 /* (curl w,Psi_c e_i) part */
175 //////////////////////////////
176 //Compute for "elem0"
177 sommation_sommets = 0.;
178 for (int i = 0; i < sommets_elem0.size(); i++)
179 {
180 sommet_global = sommets_elem0[i];
181
182 //To eliminate the last vertex
183 if (sommet_global != domaine.nb_som() - 1)
184 {
185 face_opp = faces_opp_elem0[i];
186 vecteur_normal_opp_elem0 = vecteur_normal(face_opp, elem0);
187
188 sommation_sommets += vorticite(domaine.nb_elem() + sommet_global) * vecteur_normal_opp_elem0(modulo);
189 }
190
191 }
192
193 rot(face, composante) += pow(-1., modulo) / (dimension * (dimension + 1)) * sommation_sommets;
194
195 //Compute for "elem1"
196 sommation_sommets = 0.;
197 for (int i = 0; i < sommets_elem1.size(); i++)
198 {
199 sommet_global = sommets_elem1[i];
200
201 //To eliminate the last vertex
202 if (sommet_global != domaine.nb_som() - 1)
203 {
204 face_opp = faces_opp_elem1[i];
205 vecteur_normal_opp_elem1 = vecteur_normal(face_opp, elem1);
206
207 sommation_sommets += vorticite(domaine.nb_elem() + sommet_global) * vecteur_normal_opp_elem1(modulo);
208 }
209
210 }
211
212 // C_h^t
213 rot(face, composante) += pow(-1., modulo) / (dimension * (dimension + 1)) * sommation_sommets;
214
215 //////////////////////////////////////
216 /* End of (curl w,Psi_c e_i) part */
217 /////////////////////////////////////
218 } //end of for loop over "composante" for the P1 part of the unknown
219
220 } //end of for loop over "face"
221
222 return rot;
223
224}
225
226DoubleTab Op_Rot_VEFP1B::vecteur_normal(const int face, const int elem) const
227{
228 assert(dimension == 2);
229
230 const Domaine_VEF& domaine_VEF = le_dom_vef.valeur();
231 DoubleTab le_vecteur_normal(dimension);
232
233 for (int composante = 0; composante < dimension; composante++)
234 le_vecteur_normal(composante) = domaine_VEF.face_normales(face, composante) * domaine_VEF.oriente_normale(face, elem);
235
236 return le_vecteur_normal;
237}
Class Champ_Inc_base.
class Domaine_Cl_dis_base Domaine_Cl_dis_base objects represent discretized boundary conditions
class Domaine_VEF
Definition Domaine_VEF.h:53
int nb_faces() const
Returns the total number of faces.
Definition Domaine_VF.h:471
virtual double face_normales(int face, int comp) const
Definition Domaine_VF.h:47
int elem_faces(int i, int j) const
Returns the index of the i-th face of element num_elem; the face numbering convention is.
Definition Domaine_VF.h:542
int oriente_normale(int f, int e) const
Definition Domaine_VF.h:194
int premiere_face_int() const
A face is internal if and only if it separates two elements.
Definition Domaine_VF.h:463
int face_voisins(int num_face, int i) const
Returns the neighbouring element of num_face in direction i.
Definition Domaine_VF.h:418
class Domaine_dis_base This class is the base of the hierarchy of discretized domains.
const Domaine & domaine() const
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
static int dimension
Definition Objet_U.h:94
const Nom & que_suis_je() const
Returns the string identifying the class.
Definition Objet_U.cpp:104
virtual Entree & readOn(Entree &)
Reads an Objet_U from an input stream. Virtual method to override.
Definition Objet_U.cpp:289
virtual Sortie & printOn(Sortie &) const
Writes the object to an output stream. Virtual method to override.
Definition Objet_U.cpp:278
void associer_coins(const ArrOfInt &)
DoubleTab vecteur_normal(const int face, const int elem) const
void associer(const Domaine_dis_base &, const Domaine_Cl_dis_base &, const Champ_Inc_base &) override
DoubleTab & ajouter(const DoubleTab &, DoubleTab &) const override
DoubleTab & calculer(const DoubleTab &, DoubleTab &) const override
class Operateur_base This class is the base of the hierarchy of objects representing an
static void exit(int exit_code=-1)
Exit routine for TRUST within a Kokkos region.
Definition Process.cpp:466
Base class for output streams.
Definition Sortie.h:52
_SIZE_ size_array() const
int est_vide() const
TRUSTList & add_if_not(_TYPE_)
Ajout d'un element a la liste ssi il n'existe pas deja.
void vide()
Vide la liste.
int size() const
Definition TRUSTList.h:68