TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Champ_P1_isoP1Bulle.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_P1_isoP1Bulle.h>
17#include <TRUSTTab_parts.h>
18#include <Domaine.h>
19#include <Debog.h>
20
21Implemente_instanciable(Champ_P1_isoP1Bulle,"Champ_P1_isoP1Bulle",Champ_Inc_base);
22
23Sortie& Champ_P1_isoP1Bulle::printOn(Sortie& s ) const { return s << que_suis_je() << finl; }
24
26{
27 lire_donnees(is) ;
28 return is ;
29}
30
32{
33 // Do not specify nb_ddl!
34 assert(n < 0);
35 const Domaine_VEF& zvef = domaine_vef();
36 const MD_Vector& md = zvef.md_vector_p1b();
38 return n;
39}
40
41double Champ_P1_isoP1Bulle::norme_L2(const Domaine& dom) const
42{
43 const Domaine_VEF& zvef = domaine_vef();
44 const IntTab& som_elem = zvef.domaine().les_elems();
45 const DoubleVect& volumes = zvef.volumes();
46
47 int prs = zvef.numero_premier_sommet();
48 DoubleTab q(valeurs());
49 double norme = 0, s = 0;
50 double alpha = 1. / (dimension * (dimension + 1));
51 int i, k;
52 double somme = 0;
53 int sz = q.size();
54 for (i = prs; i < sz; i++)
55 somme += q(i);
56 somme /= (sz - prs);
57 for (i = 0; i < prs; i++)
58 q(i) += alpha * somme;
59 for (i = prs; i < sz; i++)
60 q(i) -= somme;
61 for (i = 0; i < prs; i++)
62 {
63 double m = 0;
64 for (k = 0; k < (dimension + 1); k++)
65 m += q(prs + som_elem(i, k));
66 m *= alpha;
67 m += q(i);
68 s += m * volumes(i);
69 norme += volumes(i);
70 }
71 Cerr << "norme L1 : " << s << finl;
72
73 s /= norme;
74 for (i = 0; i < prs; i++)
75 q(i) -= s;
76 s = norme = 0;
77 for (i = 0; i < prs; i++)
78 {
79 double m = 0;
80 for (k = 0; k < (dimension + 1); k++)
81 m += q(prs + som_elem(i, k));
82 m *= alpha;
83 m += q(i);
84 m *= m;
85 norme += volumes(i) * m;
86
87 for (k = 0; k < (dimension + 1); k++)
88 {
89 double v = 0;
90 for (int l = 0; l < (dimension + 1); l++)
91 {
92 if (k != l)
93 v += q(prs + som_elem(i, l));
94 }
95 v *= alpha;
96 v *= v;
97 v /= (dimension + 1);
98 norme += volumes(i) * v;
99 }
100 }
101 return sqrt(norme);
102}
104{
105 DoubleTab noeuds;
106 const Domaine_VEF& zvef = domaine_vef();
107
108 remplir_coord_noeuds(noeuds);
109
110 DoubleTab_parts parties_P(valeurs());
111 Debog::verifier("affecter::champ ch", ch.valeurs());
112 if (zvef.get_alphaE() && zvef.get_alphaS())
113 {
114
115 DoubleTab& Pk = parties_P[0]; // element part
116 DoubleTab& Ps = parties_P[1]; // vertex part
117
118 //const Domaine_VEF& zvef=domaine_vef();
119 const Domaine& le_dom = zvef.domaine();
120 const Domaine& dom = le_dom;
121 const DoubleTab& coord_sommets = dom.coord_sommets();
122 const DoubleTab& xg = zvef.xp();
123 ch.valeur_aux(xg, Pk);
124 ch.valeur_aux(coord_sommets, Ps);
125 }
126 else
127 ch.valeur_aux(noeuds, valeurs());
128
129 // abort();
130 Debog::verifier("affecter::champ brut", valeurs());
131 // GF: subtract the mean part from elements if both element and vertex supports
132 if (zvef.get_alphaE() && zvef.get_alphaS())
133 {
134
135 //int nb_som=zvef.nb_som();
136 DoubleVect& Pk = parties_P[0]; // element part
137 DoubleVect& Ps = parties_P[1]; // vertex part
138
139 /*
140 // if Ps equals 0, retrieve p at elements
141 // workaround ....
142 const DoubleTab& coord=zvef.domaine().coord_sommets();
143 for (int s=0;s<nb_som;s++)
144 if (Ps(s)==0)
145 {
146 abort();
147 double x=coord(s,0);
148 double y=coord(s,1);
149 double z=0;
150 if (dimension==3)
151 z=coord(s,2);
152 int elem=zvef.domaine().chercher_elements(x,y,z);
153 Ps(s)=valeurs()(elem);
154 }
155 */
156
157 // first subtract the vertex mean from each element
158 const IntTab& som_elem = zvef.domaine().les_elems();
159
160 int prs = zvef.numero_premier_sommet();
161 int i, k;
162 double alpha = 1. / (dimension);
163 //DoubleTab& p = valeurs();
164 for (i = 0; i < prs; i++)
165 {
166 double m = 0;
167 for (k = 0; k < (dimension + 1); k++)
168 m += Ps(som_elem(i, k));
169 m *= alpha;
170 Pk(i) -= m;
171 }
172 Debog::verifier("affecter::champ milieu", valeurs());
173 // Access arrays for Pk and Ps values
174
175 double moyenne_K = mp_moyenne_vect(Pk); // Compute the mean of the element field
176 Pk -= moyenne_K;
178
179 Debog::verifier("affecter::champ final", valeurs());
180 //Cerr<<"minPS "<<min_abs(Ps)<<finl;exit();
181 }
182
183 return *this;
184
185}
186
187DoubleTab& Champ_P1_isoP1Bulle::remplir_coord_noeuds(DoubleTab& coord) const
188{
190}
191
192DoubleVect& Champ_P1_isoP1Bulle::valeur_a_elem(const DoubleVect& position, DoubleVect& val, int le_poly) const
193{
194 return Champ_P1iP1B_implementation::valeur_a_elem(position, val, le_poly);
195}
196
197double Champ_P1_isoP1Bulle::valeur_a_elem_compo(const DoubleVect& position, int le_poly, int ncomp) const
198{
199 return Champ_P1iP1B_implementation::valeur_a_elem_compo(position, le_poly, ncomp);
200}
201
202DoubleTab& Champ_P1_isoP1Bulle::valeur_aux_elems(const DoubleTab& positions, const IntVect& les_polys, DoubleTab& val) const
203{
204 return Champ_P1iP1B_implementation::valeur_aux_elems(positions, les_polys, val);
205}
206
207DoubleVect& Champ_P1_isoP1Bulle::valeur_aux_elems_compo(const DoubleTab& positions, const IntVect& les_polys, DoubleVect& val, int ncomp) const
208{
209 return Champ_P1iP1B_implementation::valeur_aux_elems_compo(positions, les_polys, val, ncomp);
210}
211
212DoubleTab& Champ_P1_isoP1Bulle::trace(const Frontiere_dis_base& fr, DoubleTab& x, double tps, int distant) const
213{
214 if (!est_egal(temps_, tps))
215 {
216 Cerr << "The method Champ_P1_isoP1Bulle::trace performs an interpolation of the field values" << finl;
217 Cerr << "for which the trace on the boundary is requested" << finl;
218 Cerr << "This interpolation uses by default the values at the current time " << temps_ << finl;
219 Cerr << "of this field which does not match the time passed as parameter " << tps << finl;
220 exit();
221 }
222 return Champ_P1iP1B_implementation::trace(fr, valeurs(tps), x, distant);
223}
224
226{
227 const DoubleTab& val = valeurs();
228 const Domaine_VEF& domaine_VEF = domaine_vef();
229 const IntTab& face_voisins = domaine_VEF.face_voisins();
230 const IntTab& som_elem = domaine_VEF.domaine().les_elems();
231 int nps = domaine_VEF.numero_premier_sommet();
232
233 int elem = face_voisins(face, 0);
234 if (face_voisins(face, 1) != -1)
235 {
236 Cerr << "Error in Champ_P1_isoP1Bulle::valeur_au_bord." << finl;
237 Cerr << "The face is not a boundary face." << finl;
239 }
240
241 int som_opp = domaine_VEF.get_num_fac_loc(face, 0);
242 double la_val_bord = 0;
243 for (int i = 0; i < (dimension + 1); i++)
244 if (i != som_opp)
245 {
246 la_val_bord += val[nps + som_elem(elem, i)];
247 }
248 la_val_bord /= dimension;
249 return la_val_bord;
250}
251
Class Champ_Inc_base.
virtual void creer_tableau_distribue(const MD_Vector &, RESIZE_OPTIONS=RESIZE_OPTIONS::COPY_INIT)
int lire_donnees(Entree &)
Reads the field values from an input stream.
DoubleTab & valeurs() override
Returns the array of field values at the current time.
void completer(const Domaine_Cl_dis_base &zcl) override
const Domaine_VEF & domaine_vef() const override
DoubleVect & valeur_a_elem(const DoubleVect &position, DoubleVect &val, int le_poly) const override
Causes an error! Must be overridden by derived classes.
int fixer_nb_valeurs_nodales(int) override
double valeur_a_elem_compo(const DoubleVect &position, int le_poly, int ncomp) const override
Causes an error! Must be overridden by derived classes.
Champ_base & affecter_(const Champ_base &) override
Assignment of a generic OWN_PTR(Champ_base) (Champ_base) to an unknown field.
DoubleTab & trace(const Frontiere_dis_base &, DoubleTab &, double, int distant) const override
See Champ_base. Special case (unfortunately) of Champ_P0_VDF:
double norme_L2(const Domaine &dom) const
DoubleVect & valeur_aux_elems_compo(const DoubleTab &positions, const IntVect &les_polys, DoubleVect &valeurs, int ncomp) const override
Causes an error! Must be overridden by derived classes.
double valeur_au_bord(int face) const
DoubleTab & valeur_aux_elems(const DoubleTab &positions, const IntVect &les_polys, DoubleTab &valeurs) const override
Causes an error! Must be overridden by derived classes.
DoubleTab & remplir_coord_noeuds(DoubleTab &) const override
DoubleTab & valeur_aux_elems(const DoubleTab &positions, const IntVect &les_polys, DoubleTab &valeurs) const override
DoubleTab & remplir_coord_noeuds(DoubleTab &positions) const override
double valeur_a_elem_compo(const DoubleVect &position, int le_poly, int ncomp) const override
DoubleVect & valeur_a_elem(const DoubleVect &position, DoubleVect &val, int le_poly) const override
DoubleTab & trace(const Frontiere_dis_base &fr, const DoubleTab &y, DoubleTab &x, int distant) const
void completer(const Domaine_Cl_dis_base &zcl)
DoubleVect & valeur_aux_elems_compo(const DoubleTab &positions, const IntVect &les_polys, DoubleVect &valeurs, int ncomp) const override
virtual DoubleTab & valeurs()=0
double temps_
Definition Champ_base.h:123
Champ_base()
Default constructor of a Champ_base.
virtual DoubleTab & valeur_aux(const DoubleTab &positions, DoubleTab &valeurs) const
Causes an error! Must be overridden by derived classes.
static void verifier(const char *const msg, double)
Definition Debog.cpp:21
IntTab_t & les_elems()
Definition Domaine.h:129
const DoubleTab_t & coord_sommets() const
Definition Domaine.h:112
class Domaine_Cl_dis_base Domaine_Cl_dis_base objects represent discretized boundary conditions
class Domaine_VEF
Definition Domaine_VEF.h:53
int numero_premier_sommet() const
virtual const MD_Vector & md_vector_p1b() const
int get_alphaS() const
Definition Domaine_VEF.h:92
int get_alphaE() const
Definition Domaine_VEF.h:91
double volumes(int i) const
Definition Domaine_VF.h:113
const IntTab & get_num_fac_loc() const
Definition Domaine_VF.h:140
double xp(int num_elem, int k) const
Definition Domaine_VF.h:77
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
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
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() const
Definition TRUSTVect.tpp:45
virtual void echange_espace_virtuel(IsExchangeBlocking exchange_type=IsExchangeBlocking::DefaultBlocking, const std::string kernel_name="noname")