TrioCFD 1.9.8
TrioCFD documentation
Loading...
Searching...
No Matches
ALE_ProjectionManager.cpp
1/****************************************************************************
2* Copyright (c) 2015 - 2018, 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#include <ALE_ProjectionManager.h>
16#include <Domaine_VEF.h>
17#include <Navier_Stokes_std.h>
18#include <Operateur_Diff.h>
19#include <Operateur_Grad.h>
20#include <communications.h>
21#include <Process.h>
22#include <Schema_Temps_base.h>
23#include <Probleme_base.h>
24#include <Equation_base.h>
25#include <Objet_U.h>
26
28{
29 field_ALE_projection_ = Champs_front_ALE_projection();
30 name_ALE_boundary_projection_ = Noms();
31 name_boundary_with_Neumann_BC_ = Noms();
32}
33
35{
36 Motcle accolade_ouverte("{"), accolade_fermee("}"), motlu;
37 Nom nomlu;
38 int nb_projection;
39
40 is >> motlu;
41 if (motlu != accolade_ouverte)
42 {
43 Cerr << "Error reading 'Projection_ALE_boundary': expected "
44 << accolade_ouverte << ", got " << motlu << finl;
46 }
47
48 is >> nb_projection;
49 Cerr << "Number of ALE projection boundaries : " << nb_projection << finl;
50 field_ALE_projection_.dimensionner(nb_projection);
51
52 int compteur = 0;
53 while (1)
54 {
55 is >> nomlu;
56 motlu = nomlu;
57 if (motlu == accolade_fermee) break;
58 name_ALE_boundary_projection_.add(nomlu);
59 is >> field_ALE_projection_[compteur++];
60 }
61}
62
64{
65 Motcle accolade_ouverte("{"), accolade_fermee("}"), motlu;
66 Nom nomlu;
67 int nb_boundary;
68
69 is >> motlu;
70 if (motlu != accolade_ouverte)
71 {
72 Cerr << "Error reading 'ALE_Neumann_BC_for_grid_problem': expected "
73 << accolade_ouverte << ", got " << motlu << finl;
75 }
76
77 is >> nb_boundary;
78 Cerr << "Number of Neumann BC boundaries for grid problem : " << nb_boundary << finl;
79
80 while (1)
81 {
82 is >> nomlu;
83 motlu = nomlu;
84 if (motlu == accolade_fermee) break;
85 name_boundary_with_Neumann_BC_.add(nomlu);
86 }
87
88 if (nb_boundary != name_boundary_with_Neumann_BC_.size())
89 {
90 Cerr << "Error in ALE_Neumann_BC_for_grid_problem: declared count ("
91 << nb_boundary << ") differs from list size ("
92 << name_boundary_with_Neumann_BC_.size() << ")." << finl;
94 }
95}
96
98{
99 for (int i = 0; i < name_boundary_with_Neumann_BC_.size(); i++)
100 if (nom == name_boundary_with_Neumann_BC_[i])
101 return true;
102 return false;
103}
104
106 int nb_bords_ALE, const Bords& les_bords_ALE,
107 const Nom& nom_cas, Equation_base& eqn)
108{
109 const int size = field_ALE_projection_.size();
110 if (size == 0) return;
111
112 Cerr << "ALE_ProjectionManager::update" << finl;
113
114 const Navier_Stokes_std& eqn_hydr = ref_cast(Navier_Stokes_std, eqn);
115 const Operateur_base& op_grad = eqn_hydr.operateur_gradient().l_op_base();
116 const Operateur_base& op_diff = eqn_hydr.operateur_diff().l_op_base();
117 const Domaine_VEF& le_dom_vef = ref_cast(Domaine_VEF, op_grad.equation().domaine_dis());
118 const DoubleTab& xv = le_dom_vef.xv();
119 DoubleTab& flux_bords_grad = op_grad.flux_bords();
120 DoubleTab& flux_bords_diff = op_diff.flux_bords();
121
122 DoubleVect modalForce(size);
123 modalForce = 0.;
124 int dimension=Objet_U::dimension;
125
126 for (int n = 0; n < nb_bords_ALE; n++)
127 {
128 const Nom& le_nom_bord = les_bords_ALE(n).le_nom();
129 for (int i = 0; i < size; i++)
130 {
131 if (name_ALE_boundary_projection_[i] != le_nom_bord) continue;
132 if (flux_bords_grad.size() != flux_bords_diff.size() || flux_bords_grad.size() == 0)
133 continue;
134
135 const int ndeb = les_bords_ALE(n).num_premiere_face();
136 const int nfin = ndeb + les_bords_ALE(n).nb_faces();
137
138 for (int face = ndeb; face < nfin; face++)
139 for (int comp = 0; comp < dimension; comp++)
140 {
141 const double phi = field_ALE_projection_[i].evaluate(
142 temps, xv(face,0), xv(face,1), xv(face,2), comp);
143 modalForce[i] += (flux_bords_grad(face, comp) + flux_bords_diff(face, comp)) * phi;
144 }
145 }
146 }
147
149
151 {
152 const bool first_writing = (!eqn_hydr.probleme().reprise_effectuee() &&
153 eqn_hydr.probleme().schema_temps().nb_pas_dt() == 0);
154 Nom filename(nom_cas);
155 filename += "_ModalFluideForce.out";
156
157 if (!modalForceProjectionALE_.is_open())
158 {
159 modalForceProjectionALE_.ouvrir(filename, (first_writing ? ios::out : ios::app));
160 modalForceProjectionALE_.setf(ios::scientific);
161 }
162
163 if (first_writing)
164 {
165 modalForceProjectionALE_ << "# Time t Boundary ";
166 for (int i = 0; i < size; i++)
167 modalForceProjectionALE_ << name_ALE_boundary_projection_[i] << " ";
168 modalForceProjectionALE_ << finl;
169 }
170
171 modalForceProjectionALE_ << temps << " ";
172 for (int i = 0; i < size; i++)
173 modalForceProjectionALE_ << modalForce[i] << " ";
174 modalForceProjectionALE_ << finl;
175 }
176}
177
179 Nom& name_ALE_boundary_projection,
180 Champ_front_ALE_projection& field_ALE_projection,
181 int nb_mode,
182 int nb_bords_ALE, const Bords& les_bords_ALE,
183 const Nom& nom_cas, Equation_base& eqn)
184{
185 Cerr << "ALE_ProjectionManager::update (single boundary)" << finl;
186
187 const Navier_Stokes_std& eqn_hydr = ref_cast(Navier_Stokes_std, eqn);
188 const Operateur_base& op_grad = eqn_hydr.operateur_gradient().l_op_base();
189 const Operateur_base& op_diff = eqn_hydr.operateur_diff().l_op_base();
190 const Domaine_VEF& le_dom_vef = ref_cast(Domaine_VEF, op_grad.equation().domaine_dis());
191 const DoubleTab& xv = le_dom_vef.xv();
192 DoubleTab& flux_bords_grad = op_grad.flux_bords();
193 DoubleTab& flux_bords_diff = op_diff.flux_bords();
194
195 double modalForce = 0.;
196 int dimension=Objet_U::dimension;
197 for (int n = 0; n < nb_bords_ALE; n++)
198 {
199 if (les_bords_ALE(n).le_nom() != name_ALE_boundary_projection) continue;
200 if (flux_bords_grad.size() != flux_bords_diff.size() || flux_bords_grad.size() == 0)
201 continue;
202
203 const int ndeb = les_bords_ALE(n).num_premiere_face();
204 const int nfin = ndeb + les_bords_ALE(n).nb_faces();
205
206 for (int face = ndeb; face < nfin; face++)
207 for (int comp = 0; comp < dimension; comp++)
208 {
209 const double phi = field_ALE_projection.evaluate(
210 temps, xv(face,0), xv(face,1), xv(face,2), comp);
211 modalForce += (flux_bords_grad(face, comp) + flux_bords_diff(face, comp)) * phi;
212 }
213 }
214
215 Process::mp_sum(modalForce);
216
218 {
219 const bool first_writing = (!eqn_hydr.probleme().reprise_effectuee() &&
220 eqn_hydr.probleme().schema_temps().nb_pas_dt() == 0);
221 Nom filename(nom_cas);
222 filename += "_ModalFluideForce_";
223 filename += name_ALE_boundary_projection;
224 filename += "_";
225 filename += std::to_string(nb_mode);
226 filename += ".out";
227
228 if (!modalForceProjectionALE_.is_open())
229 {
230 modalForceProjectionALE_.ouvrir(filename, (first_writing ? ios::out : ios::app));
231 modalForceProjectionALE_.setf(ios::scientific);
232 }
233
234 if (first_writing)
235 modalForceProjectionALE_ << "# Time t Boundary "
236 << name_ALE_boundary_projection << finl;
237
238 modalForceProjectionALE_ << temps << " " << modalForce << " " << finl;
239 }
240}
void read_projection_boundary(Entree &is)
void update(double temps, int nb_bords_ALE, const Bords &les_bords_ALE, const Nom &nom_cas, Equation_base &eqn)
bool is_neumann_boundary(const Nom &nom) const
int_t nb_faces() const
Renvoie le nombre total de faces de tous les bords de la liste.
Definition Bords.cpp:42
double evaluate(double, double, double, int)
class Domaine_VEF
Definition Domaine_VEF.h:54
double xv(int num_face, int k) const
Definition Domaine_VF.h:76
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
classe Equation_base Le role d'une equation est le calcul d'un ou plusieurs champs....
Probleme_base & probleme()
Renvoie le probleme associe a l'equation.
Domaine_dis_base & domaine_dis()
Renvoie le domaine discretise associe a l'equation.
const Equation_base & equation() const
Renvoie la reference sur l'equation pointe par MorEqn::mon_equation.
Definition MorEqn.h:62
Une chaine de caractere (Nom) en majuscules.
Definition Motcle.h:26
classe Navier_Stokes_std Cette classe porte les termes de l'equation de la dynamique
Operateur_Grad & operateur_gradient()
Renvoie l'operateur de calcul du gradient associe a l'equation.
Operateur_Diff & operateur_diff()
class Nom Une chaine de caractere pour nommer les objets de TRUST
Definition Nom.h:31
Un tableau de chaine de caracteres (VECT(Nom)).
Definition Noms.h:26
static int dimension
Definition Objet_U.h:99
Operateur_base & l_op_base() override
Renvoie l'objet sous-jacent upcaste en Operateur_base.
Operateur_base & l_op_base() override
Renvoie l'objet sous-jacent upcaste en Operateur_base.
classe Operateur_base Classe est la base de la hierarchie des objets representant un
DoubleTab & flux_bords()
const Schema_Temps_base & schema_temps() const
Renvoie le schema en temps associe au probleme.
static void mp_sum_for_each_item(TRUSTArray< _TYPE_ > &x, int n=-1)
Definition Process.cpp:193
static double mp_sum(double)
Calcule la somme de x sur tous les processeurs du groupe courant.
Definition Process.cpp:146
static void exit(int exit_code=-1)
Routine de sortie de TRUST dans une region Kokkos.
Definition Process.cpp:455
static int je_suis_maitre()
renvoie 1 si on est sur le processeur maitre du groupe courant (c'est a dire me() == 0),...
Definition Process.cpp:86
int nb_pas_dt() const
Renvoie le nombre de pas de temps effectues.
_SIZE_ size() const
Definition TRUSTVect.tpp:45