TrioCFD 1.9.9_beta
TrioCFD documentation
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// Function used by 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: reading file " << nom << finl;
59 EFichier fic(nom);
60 fic.set_check_types(1); //Remplace UFichier
61
62 // Reading values from file 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 // Search for the corresponding face starting from the last one found.
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 << "Error in Champ_Don_Face_lu.\n" << erreur << " faces were not assigned.\n" << "See the list of faces in the .log files" << finl;
108 Journal() << "Champ_Don_Face_lu. List of unassigned faces:\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(); // Wait for everyone to finish writing
113 exit();
114 }
115 return is;
116}
class Champ_Don_Face_lu This class represents a data field that is read
void dimensionner(int, int)
Sets the number of components and the number of nodal values.
DoubleTab & valeurs() override
Overrides Champ_base::valeurs() Returns the array of values.
class 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
Returns the total number of 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 &)
See Interprete_bloc::objet_global(). BM: the Interprete class is not the best place for this.
static int dimension
Definition Objet_U.h:94
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
const Domaine_dis_base & domaine_dis() const
Returns the discretized domain associated with the problem (const version).
static Sortie & Journal(int message_level=0)
Returns a static Sortie object used as an event journal.
Definition Process.cpp:592
static double mp_sum(double)
Computes the sum of x over all processors in the current group.
Definition Process.cpp:145
static void barrier()
Synchronizes all processors in the current group (waits until all processors have reached the barrier...
Definition Process.cpp:133
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
_SIZE_ dimension(int d) const
Definition TRUSTTab.tpp:133
_SIZE_ size() const
Definition TRUSTVect.tpp:45