TrioCFD 1.9.9_beta
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 (same as in 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
Overrides Champ_base::valeurs() Returns the array of values.
: class Champ_Don_lu This class represents a data field read from a file with the following conventio...
DoubleTab & trace(const Frontiere_dis_base &fr, const DoubleTab &y, DoubleTab &x, int distant) const
class Champ_Fonc_Face_VDF
int imprime(Sortie &os, int ncomp) const override
DOES NOTHING.
DoubleVect & valeur_aux_elems_compo(const DoubleTab &positions, const IntVect &les_polys, DoubleVect &tab_valeurs, int ncomp) const override
Causes an error! Must be overridden by derived classes.
void mettre_a_jour(double) override
Time update of the field.
const Domaine_VDF & domaine_vdf() const override
int fixer_nb_valeurs_nodales(int) override
Sets the number of degrees of freedom per component.
DoubleVect & valeur_aux_compo(const DoubleTab &positions, DoubleVect &tab_valeurs, int ncomp) const override
Same as valeur_aux(const DoubleTab &, DoubleTab &), but computes only the component compo of the fiel...
DoubleTab & trace(const Frontiere_dis_base &, DoubleTab &, double, int distant) const override
Computes the trace of a field on a boundary at time tps.
Champ_base & affecter_(const Champ_base &) override
Assigns a Champ_base to a Champ_Fonc_base.
class Champ_Fonc_base Base class of fields that are functions of a calculated quantity
void mettre_a_jour(double temps) override
Time update of the field.
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
Champ_Uniforme_Morceaux This class represents a piecewise constant-in-space field.
Champ_Uniforme Represents a field that is constant in space and time.
Champ_base()
Default constructor of a Champ_base.
virtual DoubleVect & valeur_aux_compo(const DoubleTab &positions, DoubleVect &valeurs, int ncomp) const
Same as valeur_aux(const DoubleTab &, DoubleTab &), but computes only the component compo of the fiel...
SmallArrOfTID_t & chercher_elements(const DoubleTab &pos, SmallArrOfTID_t &elem, int reel=0) const
Searches for the elements containing the points whose coordinates are specified.
Definition Domaine.cpp:404
class Domaine_VDF
Definition Domaine_VDF.h:61
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
Returns the total number of 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
A face is internal if and only if it separates two elements.
Definition Domaine_VF.h:463
int face_voisins(int num_face, int i) const
Returns the neighbouring element of num_face in 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
Returns the name of the field.
int nb_compo_
Definition Field_base.h:95
class Frontiere_dis_base Class representing a discretized boundary.
: This class is an OWN_PTR but the pointed object is shared among multiple
Definition MD_Vector.h:48
static int dimension
Definition Objet_U.h:94
const Nom & que_suis_je() const
Returns the string identifying the class.
Definition Objet_U.cpp:104
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
Base class for output streams.
Definition Sortie.h:52
_SIZE_ dimension(int d) const
Definition TRUSTTab.tpp:133