TrioCFD 1.9.8
TrioCFD documentation
Loading...
Searching...
No Matches
Champ_Fonc_Face_VDF.cpp
1/****************************************************************************
2* Copyright (c) 2023, 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_Uniforme_Morceaux.h>
17#include <Champ_Fonc_Face_VDF.h>
18#include <Champ_Uniforme.h>
19#include <Champ_Don_lu.h>
20
21Implemente_instanciable(Champ_Fonc_Face_VDF, "Champ_Fonc_Face|Champ_Fonc_Face_VDF", Champ_Fonc_base);
22
23Sortie& Champ_Fonc_Face_VDF::printOn(Sortie& s) const { return s << que_suis_je() << " " << le_nom(); }
24
26
28{
29 assert(nb_noeuds == domaine_vdf().nb_faces());
31 // HACK (le meme que dans Champ_Face_VDF.cpp)
32 int old_nb_compo = nb_compo_;
35 nb_compo_ = old_nb_compo;
36 return nb_noeuds;
37}
38
43
44DoubleTab& Champ_Fonc_Face_VDF::trace(const Frontiere_dis_base& fr, DoubleTab& x, double tps, int distant) const
45{
46 return Champ_Face_VDF_implementation::trace(fr, valeurs(), x, distant);
47}
48
49int Champ_Fonc_Face_VDF::imprime(Sortie& os, int ncomp) const
50{
51 imprime_Face(os, ncomp);
52 return 1;
53}
54
56{
57 const DoubleTab& v = ch.valeurs();
58 DoubleTab& val = valeurs();
59 const Domaine_VDF& domaine_VDF = domaine_vdf();
60 int nb_faces = domaine_VDF.nb_faces();
61 const IntVect& orientation = domaine_VDF.orientation();
62 int ori, n0, n1;
63
64 if (sub_type(Champ_Uniforme, ch))
65 {
66 for (int num_face = 0; num_face < nb_faces; num_face++)
67 val(num_face) = v(0, orientation(num_face));
68 }
69 else if ((sub_type(Champ_Uniforme_Morceaux, ch)) || (sub_type(Champ_Don_lu, ch)))
70 {
71 int ndeb_int = domaine_VDF.premiere_face_int();
72 const IntTab& face_voisins = domaine_VDF.face_voisins();
73 int num_face;
74
75 for (num_face = 0; num_face < ndeb_int; num_face++)
76 {
77 ori = orientation(num_face);
78 n0 = face_voisins(num_face, 0);
79 if (n0 != -1)
80 val(num_face) = v(n0, ori);
81 else
82 val(num_face) = v(face_voisins(num_face, 1), ori);
83 }
84
85 for (num_face = ndeb_int; num_face < nb_faces; num_face++)
86 {
87 ori = orientation(num_face);
88 n0 = face_voisins(num_face, 0);
89 n1 = face_voisins(num_face, 1);
90 val(num_face) = 0.5 * (v(n0, ori) + v(n1, ori));
91 }
92 }
93 else
94 {
95 // int ndeb_int = domaine_VDF.premiere_face_int();
96 // const IntTab& face_voisins = domaine_VDF.face_voisins();
97 DoubleTab positionX(domaine_VDF.nb_faces_X(), dimension);
98 DoubleVect U(domaine_VDF.nb_faces_X());
99 DoubleTab positionY(domaine_VDF.nb_faces_Y(), dimension);
100 DoubleVect V(domaine_VDF.nb_faces_Y());
101 DoubleTab positionZ(domaine_VDF.nb_faces_Z(), dimension);
102 DoubleVect W(domaine_VDF.nb_faces_Z());
103 const DoubleTab& xv = domaine_VDF.xv();
104 int nbx = 0;
105 int nby = 0;
106 int nbz = 0;
107 int num_face, k;
108
109 for (num_face = 0; num_face < nb_faces; num_face++)
110 {
111 ori = orientation(num_face);
112 switch(ori)
113 {
114 case 0:
115 for (k = 0; k < dimension; k++)
116 positionX(nbx, k) = xv(num_face, k);
117 nbx++;
118 break;
119 case 1:
120 for (k = 0; k < dimension; k++)
121 positionY(nby, k) = xv(num_face, k);
122 nby++;
123 break;
124 case 2:
125 for (k = 0; k < dimension; k++)
126 positionZ(nbz, k) = xv(num_face, k);
127 nbz++;
128 break;
129 }
130 }
131
132 ch.valeur_aux_compo(positionX, U, 0);
133 ch.valeur_aux_compo(positionY, V, 1);
134 if (dimension == 3)
135 ch.valeur_aux_compo(positionZ, W, 2);
136 nbx = nby = nbz = 0;
137 for (num_face = 0; num_face < nb_faces; num_face++)
138 {
139 ori = orientation(num_face);
140 switch(ori)
141 {
142 case 0:
143 val(num_face) = U(nbx++);
144 break;
145 case 1:
146 val(num_face) = V(nby++);
147 break;
148 case 2:
149 val(num_face) = W(nbz++);
150 break;
151 }
152 }
153 }
154 return *this;
155}
156
157DoubleVect& Champ_Fonc_Face_VDF::valeur_aux_compo(const DoubleTab& positions, DoubleVect& tab_valeurs, int ncomp) const
158{
159 const Domaine& madomaine = domaine_dis_base().domaine();
160 IntVect les_polys(positions.dimension(0));
161 madomaine.chercher_elements(positions, les_polys);
162 return valeur_aux_elems_compo(positions, les_polys, tab_valeurs, ncomp);
163}
DoubleTab & valeurs() override
Surcharge Champ_base::valeurs() Renvoie le tableau des valeurs.
: class Champ_Don_lu Cette classe represente un champ de donnees que l'on lit dans un fichier avec le...
DoubleTab & trace(const Frontiere_dis_base &fr, const DoubleTab &y, DoubleTab &x, int distant) const
classe Champ_Fonc_Face_VDF
int imprime(Sortie &os, int ncomp) const override
NE FAIT RIEN.
DoubleVect & valeur_aux_elems_compo(const DoubleTab &positions, const IntVect &les_polys, DoubleVect &tab_valeurs, int ncomp) const override
provoque une erreur ! doit etre surchargee par les classes derivees
void mettre_a_jour(double) override
Mise a jour en temps du champ.
const Domaine_VDF & domaine_vdf() const override
int fixer_nb_valeurs_nodales(int) override
Fixe le nombre de degres de liberte par composante.
DoubleVect & valeur_aux_compo(const DoubleTab &positions, DoubleVect &tab_valeurs, int ncomp) const override
Idem que valeur_aux(const DoubleTab &, DoubleTab &), mais calcule uniquement la composante compo du c...
DoubleTab & trace(const Frontiere_dis_base &, DoubleTab &, double, int distant) const override
Calcule la trace d'un champ sur une frontiere au temps tps.
Champ_base & affecter_(const Champ_base &) override
Affecte un Champ_base dans un Champ_Fonc_base.
classe Champ_Fonc_base Classe de base des champs qui sont fonction d'une grandeur calculee
void mettre_a_jour(double temps) override
Mise a jour en temps du champ.
virtual void creer_tableau_distribue(const MD_Vector &, RESIZE_OPTIONS=RESIZE_OPTIONS::COPY_INIT)
const Domaine_dis_base & domaine_dis_base() const override
virtual DoubleTab & valeurs()=0
classe Champ_Uniforme_Morceaux Cette classe represente champ constant par morceaux dans l'espace
classe Champ_Uniforme Represente un champ constant dans l'espace et dans le temps.
Champ_base()
Constructeur par defaut d'un Champ_base.
virtual DoubleVect & valeur_aux_compo(const DoubleTab &positions, DoubleVect &valeurs, int ncomp) const
Idem que valeur_aux(const DoubleTab &, DoubleTab &), mais calcule uniquement la composante compo du c...
SmallArrOfTID_t & chercher_elements(const DoubleTab &pos, SmallArrOfTID_t &elem, int reel=0) const
Recherche des elements contenant les points dont les coordonnees sont specifiees.
Definition Domaine.cpp:405
class Domaine_VDF
Definition Domaine_VDF.h:64
int nb_faces_Z() const
int nb_faces_Y() const
int orientation(int) const override
inline DoubleVect& Domaine_VDF::porosite_face() {
int nb_faces_X() const
int nb_faces() const
renvoie le nombre global de faces.
Definition Domaine_VF.h:471
const MD_Vector & md_vector_faces() const
Definition Domaine_VF.h:158
double xv(int num_face, int k) const
Definition Domaine_VF.h:76
int premiere_face_int() const
une face est interne ssi elle separe deux elements.
Definition Domaine_VF.h:463
int face_voisins(int num_face, int i) const
renvoie l'element voisin de numface dans la direction i.
Definition Domaine_VF.h:418
const Domaine & domaine() const
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
classe Frontiere_dis_base Classe representant une frontiere discretisee.
: Cette classe est un OWN_PTR mais l'objet pointe est partage entre plusieurs
Definition MD_Vector.h:48
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
virtual Sortie & printOn(Sortie &) const
Ecriture de l'objet sur un flot de sortie Methode a surcharger.
Definition Objet_U.cpp:282
Classe de base des flux de sortie.
Definition Sortie.h:52
_SIZE_ dimension(int d) const
Definition TRUSTTab.tpp:133