TRUST 1.9.8
HPC thermohydraulic platform
Loading...
Searching...
No Matches
Champ_Don_Face_lu.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_Don_Face_lu.h>
17#include <Probleme_base.h>
18#include <Domaine_VDF.h>
19#include <ArrOfBit.h>
20#include <EFichier.h>
21
22// Fonction utilisee par le readOn
23int meme_point(const ArrOfInt& x, const DoubleTab& tab, int rang_tab)
24{
25 int dime = x.size_array();
26 assert(tab.dimension(1) == dime);
27 int k;
28 for (k = 0; k < dime; k++)
29 if (std::fabs(x[k] - tab(rang_tab, k)) >= 1.e-12)
30 break;
31 return (k == dime);
32}
33
34Implemente_instanciable(Champ_Don_Face_lu, "Champ_Don_Face_lu", Champ_Fonc_Face_VDF);
35
37{
38 const DoubleTab& tab = valeurs();
39 os << tab.size() << " ";
40 for (int i = 0; i < tab.size(); i++)
41 os << tab(0, i);
42 return os;
43}
44
46{
47 int dim;
48 //Motcle motlu;
49 Nom nom;
50 is >> nom;
51 Probleme_base& pb = ref_cast(Probleme_base, Interprete::objet(nom));
53 const Domaine_VDF& zvdf = ref_cast(Domaine_VDF, domaine_dis_base());
54 int nb_faces = zvdf.nb_faces();
55 is >> dim;
56 dimensionner(nb_faces, dim);
57 is >> nom;
58 Cerr << "Champ_Don_Face_lu: lecture du fichier " << nom << finl;
59 EFichier fic(nom);
60 fic.set_check_types(1); //Remplace UFichier
61
62 // Lecture des valeurs dans le fichier fic
63 DoubleTab& mes_val = valeurs();
64 const DoubleTab& xv = zvdf.xv();
65 ArrOfInt point(dimension);
66 ArrOfInt val_lu(dim);
67 ArrOfBit flag(nb_faces);
68 flag = 0;
69
70 int nb_val_lues = 0;
71 fic >> nb_val_lues;
72 int num_face = -1;
73 int nb_faces_affectees = 0;
74 int i;
75 for (i = 0; i < nb_val_lues; i++)
76 {
77 int k;
78 for (k = 0; k < dimension; k++)
79 fic >> point[k];
80 for (k = 0; k < dim; k++)
81 fic >> val_lu[k];
82
83 // On cherche la face correspondante en partant de la derniere trouvee.
84 for (int j = 0; j < nb_faces; j++)
85 {
86 num_face++;
87 if (num_face >= nb_faces)
88 num_face = 0;
89
90 if (meme_point(point, xv, num_face))
91 {
92 if (dim == 1)
93 mes_val(num_face) = val_lu[0];
94 else
95 for (k = 0; k < dim; k++)
96 mes_val(num_face, k) = val_lu[k];
97 if (!flag.testsetbit(num_face))
98 nb_faces_affectees++;
99 break;
100 }
101 }
102 }
103
104 int erreur = static_cast<int>(mp_sum(nb_faces - nb_faces_affectees)); // should remain small
105 if (erreur)
106 {
107 Cerr << "Erreur dans Champ_Don_Face_lu.\n" << erreur << " faces n'ont pas ete affectees.\n" << "Voir la liste des faces dans les fichiers .log" << finl;
108 Journal() << "Champ_Don_Face_lu. Liste des faces non affectees :\n";
109 for (i = 0; i < nb_faces; i++)
110 if (!flag[i])
111 Journal() << i << " " << xv(i, 0) << " " << xv(i, 1) << " " << ((dimension == 3) ? xv(i, 3) : 0.) << finl;
112 barrier(); // Attend que tout le monde ait fini d'ecrire
113 exit();
114 }
115 return is;
116}
class Champ_Don_Face_lu Cette classe represente un champ de donnees que l'on lit
void dimensionner(int, int)
Fixe le nombre de composantes et le nombre de valeurs nodales.
DoubleTab & valeurs() override
Surcharge Champ_base::valeurs() Renvoie le tableau des valeurs.
classe Champ_Fonc_Face_VDF
void associer_domaine_dis_base(const Domaine_dis_base &) override
const Domaine_dis_base & domaine_dis_base() const override
int nb_faces() const
renvoie le nombre global de faces.
Definition Domaine_VF.h:471
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
static Objet_U & objet(const Nom &)
Voir Interprete_bloc::objet_global() BM: la classe Interprete n'est pas le meilleur endroit pour cett...
static int dimension
Definition Objet_U.h:99
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
const Domaine_dis_base & domaine_dis() const
Renvoie le domaine discretise associe au probleme.
static Sortie & Journal(int message_level=0)
Renvoie un objet statique de type Sortie qui sert de journal d'evenements.
Definition Process.cpp:588
static double mp_sum(double)
Calcule la somme de x sur tous les processeurs du groupe courant.
Definition Process.cpp:146
static void barrier()
Synchronise tous les processeurs du groupe courant (attend que tous les processeurs soient arrives a ...
Definition Process.cpp:136
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
_SIZE_ size_array() const
_SIZE_ dimension(int d) const
Definition TRUSTTab.tpp:133
_SIZE_ size() const
Definition TRUSTVect.tpp:45