TrioCFD 1.9.8
TrioCFD documentation
Loading...
Searching...
No Matches
Champ_Fonc_P0_VDF.cpp
1/****************************************************************************
2* Copyright (c) 2022, 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_Fonc_P0_VDF.h>
17#include <LecFicDiffuse.h>
18#include <Domaine_VF.h>
19
20Implemente_instanciable(Champ_Fonc_P0_VDF, "Champ_Fonc_P0_VDF", Champ_Fonc_P0_base);
21
22Sortie& Champ_Fonc_P0_VDF::printOn(Sortie& s) const { return s << que_suis_je() << " " << le_nom(); }
23
25
26/*! @brief Ecrit le champ sous la forme IJK
27 *
28 */
29int Champ_Fonc_P0_VDF::imprime(Sortie& os, int ncomp) const
30{
31 // valeur_au_ijk(xi,yj,zk,valeurs,ncomp);
32 // principe : creer un tableau points avec selon si champ_elem ou champ_faces
33 // une grille construite a partie de xi,yj,zk lu dans un fichier
34 // sub_type(Champ_P0, *this) : grille construite a partir de (xi+xi+1)/2,etc...
35 // Sinon : grille construite a partir de xi,xi+1,etc...
36 // Boucle sur ni,nj,nk
37 // K=
38 // I=1 I=2 I=3 I=4
39 // J=10 Vij
40 // J=9
41 // ...
42 int ni, nj, nk = -1;
43 int ii, jj, k;
44 int np, elem;
45 int cmax = 7;
46 DoubleVect xi, yj, zk;
47 DoubleTab Grille;
48 //Lecture de xi,yj,zk dans un fichier .xiyjzk
49 Nom nomfic(nom_du_cas());
50 nomfic += ".xiyjzk";
51 LecFicDiffuse ficijk(nomfic);
52 ficijk >> xi;
53 ni = xi.size();
54 ficijk >> yj;
55 nj = yj.size();
56 if (dimension == 3)
57 {
58 ficijk >> zk;
59 nk = zk.size();
60 }
61 if (ncomp == 1)
62 {
63 if (dimension == 3)
64 {
65 // Grille ordonnee sur les centres des elements
66 np = (ni - 1) * (nj - 1) * (nk - 1);
67 Grille.resize(np, dimension);
68 for (k = 0; k < nk - 1; k++)
69 for (ii = 0; ii < ni - 1; ii++)
70 for (jj = 0; jj < nj - 1; jj++)
71 {
72 elem = jj + (nj - 1) * (ii + k * (ni - 1));
73 Grille(elem, 0) = 0.5 * (xi(ii) + xi(ii + 1));
74 Grille(elem, 1) = 0.5 * (yj(jj) + yj(jj + 1));
75 Grille(elem, 2) = 0.5 * (zk(k) + zk(k + 1));
76 }
77 DoubleTab tab_valeurs(np, nb_compo_);
78 valeur_aux(Grille, tab_valeurs);
79 for (k = 0; k < nk - 1; k++)
80 {
81 os << finl;
82 os << "Coupe a K= " << k << finl;
83 int n1 = 0, n2 = 0;
84 while (n2 < ni - 1)
85 {
86 n1 = n2;
87 n2 = std::min(ni - 1, n2 + cmax);
88 os << finl;
89 os << "I= ";
90 for (int i = n1; i < n2; i++)
91 os << i << " ";
92 os << finl;
93 for (int j = nj - 2; j > -1; j--)
94 {
95 os << "J= " << j << " ";
96 for (int i = n1; i < n2; i++)
97 {
98 elem = j + (nj - 1) * (i + k * (ni - 1));
99 os << tab_valeurs(elem, 0) << " ";
100 }
101 os << finl;
102 }
103 }
104 }
105 }
106 else if (dimension == 2)
107 {
108 np = (ni - 1) * (nj - 1);
109 Grille.resize(np, dimension);
110 for (ii = 0; ii < ni - 1; ii++)
111 for (jj = 0; jj < nj - 1; jj++)
112 {
113 elem = jj + (nj - 1) * ii;
114 Grille(elem, 0) = 0.5 * (xi(ii) + xi(ii + 1));
115 Grille(elem, 1) = 0.5 * (yj(jj) + yj(jj + 1));
116 }
117 DoubleTab tab_valeurs(np, nb_compo_);
118 valeur_aux(Grille, tab_valeurs);
119 int n1 = 0, n2 = 0;
120 while (n2 < ni - 1)
121 {
122 n1 = n2;
123 n2 = std::min(ni - 1, n2 + cmax);
124 os << finl;
125 os << "I= ";
126 for (int i = n1; i < n2; i++)
127 os << i << " ";
128 os << finl;
129 for (int j = nj - 2; j > -1; j--)
130 {
131 os << "J= " << j << " ";
132 for (int i = n1; i < n2; i++)
133 {
134 elem = j + (nj - 1) * i;
135 os << tab_valeurs(elem, 0) << " ";
136 }
137 os << finl;
138 }
139 }
140 }
141 }
142 else
143 {
144 Cerr << "Champ_P0_implementation::imprime_P0_VDF avec nb_compo_>1 non code." << finl;
145 exit();
146 }
147 return 1;
148}
classe Champ_Fonc_P0_VDF
int imprime(Sortie &, int) const override
Ecrit le champ sous la forme IJK.
DoubleTab & valeur_aux(const DoubleTab &, DoubleTab &) const override
Provoque une erreur ! Doit etre surchargee par les classes derivees.
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
const Nom & le_nom() const override
Renvoie le nom du champ.
int nb_compo_
Definition Field_base.h:95
Cette classe implemente les operateurs et les methodes virtuelles de la classe EFichier de la facon s...
class Nom Une chaine de caractere pour nommer les objets de TRUST
Definition Nom.h:31
static int dimension
Definition Objet_U.h:99
const Nom & que_suis_je() const
renvoie la chaine identifiant la classe.
Definition Objet_U.cpp:104
virtual Entree & readOn(Entree &)
Lecture d'un Objet_U sur un flot d'entree Methode a surcharger.
Definition Objet_U.cpp:293
static const Nom & nom_du_cas()
Renvoie une reference constante vers le nom du cas.
Definition Objet_U.cpp:146
virtual Sortie & printOn(Sortie &) const
Ecriture de l'objet sur un flot de sortie Methode a surcharger.
Definition Objet_U.cpp:282
static void exit(int exit_code=-1)
Routine de sortie de TRUST dans une region Kokkos.
Definition Process.cpp:455
Classe de base des flux de sortie.
Definition Sortie.h:52
void resize(_SIZE_ n, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT)
Definition TRUSTTab.tpp:469
_SIZE_ size() const
Definition TRUSTVect.tpp:45