TRUST 1.9.8
HPC thermohydraulic platform
Loading...
Searching...
No Matches
Champ_Q4_implementation.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_Q4_implementation.h>
17#include <Champ_base.h>
18#include <Domaine.h>
19
20DoubleVect& Champ_Q4_implementation::valeur_a_elem(const DoubleVect& position, DoubleVect& val, int num_elem) const
21{
22 val = 0.;
23 const Champ_base& cha = le_champ();
24 const DoubleTab& ch = cha.valeurs();
25 int nb_compo_ = cha.nb_comp();
26
27 int j, ncomp, num_som, nb_som_elem = get_domaine_geom().nb_som_elem();
28 if (nb_compo_ == 1)
29 {
30 for (j = 0; j < nb_som_elem; j++)
31 {
32 num_som = get_domaine_geom().sommet_elem(num_elem, j);
33 val(0) += ch(num_som);
34 }
35 val(0) /= nb_som_elem;
36 }
37 else
38 {
39 for (ncomp = 0; ncomp < nb_compo_; ncomp++)
40 {
41 for (j = 0; j < nb_som_elem; j++)
42 {
43 num_som = get_domaine_geom().sommet_elem(num_elem, j);
44 val(ncomp) += ch(num_som, ncomp);
45 }
46 val(ncomp) /= nb_som_elem;
47 }
48 }
49
50 return val;
51}
52double Champ_Q4_implementation::valeur_a_elem_compo(const DoubleVect& position, int num_elem, int ncomp) const
53{
54 double val = 0.;
55 const Champ_base& cha = le_champ();
56 const DoubleTab& ch = cha.valeurs();
57 int nb_compo_ = cha.nb_comp();
58
59 int j, num_som, nb_som_elem = get_domaine_geom().nb_som_elem();
60 if (nb_compo_ == 1)
61 {
62 assert(ncomp == 0);
63 for (j = 0; j < nb_som_elem; j++)
64 {
65 num_som = get_domaine_geom().sommet_elem(num_elem, j);
66 val += ch(num_som);
67 }
68 val /= nb_som_elem;
69 }
70 else
71 {
72 for (j = 0; j < nb_som_elem; j++)
73 {
74 num_som = get_domaine_geom().sommet_elem(num_elem, j);
75 val += ch(num_som, ncomp);
76 }
77 val /= nb_som_elem;
78 }
79
80 return val;
81}
82
83DoubleTab& Champ_Q4_implementation::valeur_aux_elems(const DoubleTab&, const IntVect& les_elems, DoubleTab& val) const
84{
85 val = 0.;
86 const Champ_base& cha = le_champ();
87 const DoubleTab& ch = cha.valeurs();
88 int nb_compo_ = cha.nb_comp();
89
90 int j, ncomp, num_som, nb_som_elem = get_domaine_geom().nb_som_elem(), ielem, num_elem, nb_elems = les_elems.size();
91 assert(val.size_totale() >= nb_elems);
92 if (nb_compo_ == 1)
93 {
94 for (ielem = 0; ielem < nb_elems; ielem++)
95 {
96 num_elem = les_elems(ielem);
97 for (j = 0; j < nb_som_elem; j++)
98 {
99 num_som = get_domaine_geom().sommet_elem(num_elem, j);
100 val(ielem, 0) += ch(num_som);
101 }
102 val(ielem, 0) /= nb_som_elem;
103 }
104 }
105 else
106 {
107 for (ielem = 0; ielem < nb_elems; ielem++)
108 {
109 num_elem = les_elems(ielem);
110 for (ncomp = 0; ncomp < nb_compo_; ncomp++)
111 {
112 for (j = 0; j < nb_som_elem; j++)
113 {
114 num_som = get_domaine_geom().sommet_elem(num_elem, j);
115 val(ielem, ncomp) += ch(num_som, ncomp);
116 }
117 val(ielem, ncomp) /= nb_som_elem;
118 }
119 }
120 }
121
122 return val;
123}
124
125DoubleVect& Champ_Q4_implementation::valeur_aux_elems_compo(const DoubleTab&, const IntVect& les_elems, DoubleVect& val, int ncomp) const
126{
127 val = 0.;
128 const Champ_base& cha = le_champ();
129 const DoubleTab& ch = cha.valeurs();
130 int nb_compo_ = cha.nb_comp();
131
132 int j, num_som, nb_som_elem = get_domaine_geom().nb_som_elem(), ielem, num_elem, nb_elems = les_elems.size();
133 assert(val.size_totale() >= nb_elems);
134 if (nb_compo_ == 1)
135 {
136 assert(ncomp == 0);
137 for (ielem = 0; ielem < nb_elems; ielem++)
138 {
139 num_elem = les_elems(ielem);
140 for (j = 0; j < nb_som_elem; j++)
141 {
142 num_som = get_domaine_geom().sommet_elem(num_elem, j);
143 val(ielem) += ch(num_som);
144 }
145 val(ielem) /= nb_som_elem;
146 }
147 }
148 else
149 {
150 for (ielem = 0; ielem < nb_elems; ielem++)
151 {
152 num_elem = les_elems(ielem);
153 for (j = 0; j < nb_som_elem; j++)
154 {
155 num_som = get_domaine_geom().sommet_elem(num_elem, j);
156 val(ielem) += ch(num_som, ncomp);
157 }
158 val(ielem) /= nb_som_elem;
159 }
160 }
161
162 return val;
163}
164
165DoubleTab& Champ_Q4_implementation::valeur_aux_sommets(const Domaine& dom, DoubleTab& val) const
166{
167 const Champ_base& cha = le_champ();
168 const DoubleTab& ch = cha.valeurs();
169 //val = cha.valeurs();
170 int nb_compo_ = cha.nb_comp();
171
172 if (nb_compo_ == 1)
173 {
174 int isom, nbsom = ch.size();
175 for (isom = 0; isom < nbsom; isom++)
176 {
177 val(isom, 0) = ch(isom);
178 }
179 }
180 else
181 {
182 int isom, nbsom = ch.size();
183 for (int ncomp = 0; ncomp < nb_compo_; ncomp++)
184 {
185 for (isom = 0; isom < nbsom; isom++)
186 {
187 val(isom, ncomp) = ch(isom, ncomp);
188 }
189 }
190 }
191 return val;
192}
193DoubleVect& Champ_Q4_implementation::valeur_aux_sommets_compo(const Domaine& dom, DoubleVect& val, int ncomp) const
194{
195 const Champ_base& cha = le_champ();
196 const DoubleTab& ch = cha.valeurs();
197 int nb_compo_ = cha.nb_comp();
198
199 if (nb_compo_ == 1)
200 {
201 assert(ncomp == 0);
202 int isom, nbsom = ch.size();
203 for (isom = 0; isom < nbsom; isom++)
204 {
205 val(isom) = ch(isom);
206 }
207 }
208 else
209 {
210 int isom, nbsom = ch.size();
211 for (isom = 0; isom < nbsom; isom++)
212 {
213 val(isom) = ch(isom, ncomp);
214 }
215 }
216 return val;
217}
218
219DoubleTab& Champ_Q4_implementation::remplir_coord_noeuds(DoubleTab& positions) const
220{
221 const DoubleTab& coordsom = get_domaine_geom().coord_sommets();
222 positions = coordsom;
223 return positions;
224}
225
226int Champ_Q4_implementation::remplir_coord_noeuds_et_polys(DoubleTab& positions, IntVect& polys) const
227{
228 Cerr << "Champ_Q4_implementation::remplir_coord_noeuds_et_polys not implemented" << finl;
229 assert(0);
230
231 int nb_elem = get_domaine_geom().nb_elem();
232 polys.resize(nb_elem);
233 for (int i = 0; i < nb_elem; i++)
234 polys(i) = i;
235 return 1;
236}
237
239{
240 const Champ_base& cha = le_champ();
241 int nb_compo_ = cha.nb_comp();
242 const Domaine& le_dom = get_domaine_geom();
243 int nb_som_tot = le_dom.nb_som_tot();
244 const DoubleTab& val = cha.valeurs();
245 int som;
246 // On recalcule les centres de gravite :
247 const DoubleTab pos_som = le_dom.coord_sommets();
248 os << nb_som_tot << finl;
249 for (som = 0; som < nb_som_tot; som++)
250 {
251 if (Objet_U::dimension == 3)
252 os << pos_som(som, 0) << " " << pos_som(som, 1) << " " << pos_som(som, 2) << " ";
253 if (Objet_U::dimension == 2)
254 os << pos_som(som, 0) << " " << pos_som(som, 1) << " ";
255 if (nb_compo_ == 1)
256 os << val(som) << finl;
257 else
258 os << val(som, ncomp) << finl;
259 }
260 os << finl;
261 Cout << "Champ_Q4_implementation::imprime_Q4 END >>>>>>>>>> " << finl;
262 return 1;
263}
virtual DoubleTab & valeurs()=0
DoubleTab & valeur_aux_sommets(const Domaine &, DoubleTab &) const override
DoubleVect & valeur_aux_elems_compo(const DoubleTab &positions, const IntVect &les_polys, DoubleVect &valeurs, int ncomp) const override
double valeur_a_elem_compo(const DoubleVect &position, int le_poly, int ncomp) const override
int imprime_Q4(Sortie &, int) const
DoubleTab & valeur_aux_elems(const DoubleTab &positions, const IntVect &les_polys, DoubleTab &valeurs) const override
int remplir_coord_noeuds_et_polys(DoubleTab &positions, IntVect &polys) const override
DoubleVect & valeur_a_elem(const DoubleVect &position, DoubleVect &val, int le_poly) const override
DoubleVect & valeur_aux_sommets_compo(const Domaine &, DoubleVect &, int) const override
DoubleTab & remplir_coord_noeuds(DoubleTab &positions) const override
classe Champ_base Cette classe est la base de la hierarchie des champs.
Definition Champ_base.h:43
const Domaine & get_domaine_geom() const
virtual Champ_base & le_champ()=0
int nb_som_elem() const
Renvoie le nombre de sommets des elements geometriques constituants le domaine.
Definition Domaine.h:474
int_t nb_elem() const
Definition Domaine.h:131
const DoubleTab_t & coord_sommets() const
Definition Domaine.h:112
int_t nb_som_tot() const
Renvoie le nombre total de sommets du domaine i.e. le nombre de sommets reels et virtuels sur le proc...
Definition Domaine.h:123
int_t sommet_elem(int_t i, int j) const
Renvoie le numero (global) du j-ieme sommet du i-ieme element.
Definition Domaine.h:136
virtual int nb_comp() const
Definition Field_base.h:56
static int dimension
Definition Objet_U.h:99
Classe de base des flux de sortie.
Definition Sortie.h:52
_SIZE_ size() const
Definition TRUSTVect.tpp:45
_SIZE_ size_totale() const
Definition TRUSTVect.tpp:61
void resize(_SIZE_, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT)
Definition TRUSTVect.tpp:91