TRUST 1.9.8
HPC thermohydraulic platform
Loading...
Searching...
No Matches
Champ_implementation_sommet.cpp
1/****************************************************************************
2* Copyright (c) 2022, 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_implementation_sommet.h>
17#include <Champ_base.h>
18#include <TRUSTTrav.h>
19#include <Domaine_VF.h>
20#include <Domaine.h>
21
22DoubleVect& Champ_implementation_sommet::valeur_a_elem(const DoubleVect& position, DoubleVect& result, int poly) const
23{
24 const Champ_base& ch_base = le_champ();
25 int nb_components = ch_base.nb_comp();
26 const DoubleTab& values = ch_base.valeurs();
27 assert(result.size() == nb_components);
28 assert(position.size() == Objet_U::dimension);
29 DoubleTab positions;
30 positions = position;
31 DoubleTab resu(1, nb_components);
32 ArrOfInt polys(1);
33 polys[0] = poly;
34 value_interpolation(positions, polys, values, resu);
35 for (int j = 0; j < nb_components; j++) result(j) = resu(j, 0);
36 return result;
37}
38
39double Champ_implementation_sommet::valeur_a_elem_compo(const DoubleVect& position, int poly, int ncomp) const
40{
41 const Champ_base& ch_base = le_champ();
42 const DoubleTab& values = ch_base.valeurs();
43 assert(ncomp >= 0);
44 assert(ncomp < ch_base.nb_comp());
45 assert(position.size() == Objet_U::dimension);
46 DoubleTab positions;
47 positions = position;
48 DoubleTab resu(1, 1);
49 ArrOfInt polys(1);
50 polys[0] = poly;
51 value_interpolation(positions, polys, values, resu, ncomp);
52 return resu(0, 0);
53}
54
55DoubleTab& Champ_implementation_sommet::valeur_aux_elems(const DoubleTab& positions, const IntVect& polys, DoubleTab& result) const
56{
57 const Champ_base& ch_base = le_champ();
58 const DoubleTab& values = ch_base.valeurs();
59 assert((result.dimension(0) == polys.size()) || (result.dimension_tot(0) == polys.size()));
60 assert(positions.dimension(1) == Objet_U::dimension);
61 value_interpolation(positions, polys, values, result);
62 return result;
63}
64
65DoubleVect& Champ_implementation_sommet::valeur_aux_elems_compo(const DoubleTab& positions, const IntVect& polys, DoubleVect& result, int ncomp) const
66{
67 const Champ_base& ch_base = le_champ();
68 const DoubleTab& values = ch_base.valeurs();
69 int nb_polys = polys.size();
70
71 assert(ncomp >= 0);
72 assert(ncomp < ch_base.nb_comp());
73 assert(result.size() == nb_polys);
74 assert(positions.dimension(1) == Objet_U::dimension);
75 DoubleTab resu(nb_polys, 1);
76 value_interpolation(positions, polys, values, resu);
77 for (int i = 0; i < nb_polys; i++) result(i) = resu(i, 0);
78 return result;
79}
80
82{
83 const Domaine_VF& domaine = get_domaine_dis();
84 const IntTab& f_s = domaine.face_sommets();
85 const DoubleTab& val = le_champ().valeurs();
86 int i, f, fb, s, ns, n, N = val.line_size();
87 DoubleTrav result(domaine.xv_bord().dimension_tot(0), N);
88 for (f = 0; f < domaine.nb_faces_tot(); f++)
89 if ((fb = domaine.fbord(f)) >= 0)
90 {
91 for (ns = 0, i = 0; i < f_s.dimension(1) && (s = f_s(f, i)) >= 0; i++)
92 for (ns++, n = 0; n < N; n++)
93 result(fb, n) += val(s, n);
94 for (n = 0; n < N; n++) result(fb, n) /= ns;
95 }
96 return result;
97}
98
99DoubleTab& Champ_implementation_sommet::remplir_coord_noeuds(DoubleTab& positions) const
100{
101 const Domaine& domaine = get_domaine_geom();
102 positions.resize(domaine.nb_som(), Objet_U::dimension);
103 positions = domaine.les_sommets();
104 return positions;
105}
106
107int Champ_implementation_sommet::remplir_coord_noeuds_et_polys(DoubleTab& positions, IntVect& polys) const
108{
109 const Domaine& domaine = get_domaine_geom();
110 positions.resize(domaine.nb_som(), Objet_U::dimension);
111 positions = domaine.les_sommets();
112 domaine.chercher_elements(positions, polys);
113 return 1;
114}
115
117{
118 const Champ_base& ch_base = le_champ();
119 const DoubleTab& values = ch_base.valeurs();
120 const int size = values.dimension(0), N = values.line_size();
121
122 assert((result.dimension(0) == size) || (result.dimension_tot(0) == size));
123 assert(result.line_size() == N);
124 for (int i = 0; i < size; i++)
125 for (int n = 0; n < N; n++)
126 result(i, n) = values(i, n);
127
128 return result;
129}
130
131DoubleVect& Champ_implementation_sommet::valeur_aux_sommets_compo_impl(DoubleVect& result, int ncomp) const
132{
133 const Champ_base& ch_base = le_champ();
134 const DoubleTab& values = ch_base.valeurs();
135 int size = values.dimension(0);
136
137 assert(ncomp >= 0);
138 assert(ncomp < ch_base.nb_comp());
139 assert(result.size() == size);
140 assert(values.nb_dim() == 2);
141 assert(values.dimension(1) == ch_base.nb_comp());
142
143 for (int i = 0; i < size; i++) result(i) = values(i, ncomp);
144
145 return result;
146}
virtual DoubleTab & valeurs()=0
classe Champ_base Cette classe est la base de la hierarchie des champs.
Definition Champ_base.h:43
DoubleTab & valeur_aux_elems(const DoubleTab &positions, const IntVect &polys, DoubleTab &result) const override
DoubleTab & valeur_aux_sommets_impl(DoubleTab &result) const override
DoubleVect & valeur_aux_elems_compo(const DoubleTab &positions, const IntVect &polys, DoubleVect &result, int ncomp) const override
virtual void value_interpolation(const DoubleTab &positions, const ArrOfInt &cells, const DoubleTab &values, DoubleTab &resu, int ncomp=-1) const =0
DoubleTab & remplir_coord_noeuds(DoubleTab &positions) const override
double valeur_a_elem_compo(const DoubleVect &position, int poly, int ncomp) const override
DoubleVect & valeur_a_elem(const DoubleVect &position, DoubleVect &result, int poly) const override
DoubleVect & valeur_aux_sommets_compo_impl(DoubleVect &result, int ncomp) const override
int remplir_coord_noeuds_et_polys(DoubleTab &positions, IntVect &polys) const override
const Domaine & get_domaine_geom() const
virtual Champ_base & le_champ()=0
const Domaine_VF & get_domaine_dis() const
class Domaine_VF
Definition Domaine_VF.h:44
virtual int nb_comp() const
Definition Field_base.h:56
static int dimension
Definition Objet_U.h:99
int nb_dim() const
Definition TRUSTTab.h:199
void resize(_SIZE_ n, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT)
Definition TRUSTTab.tpp:469
_SIZE_ dimension_tot(int) const override
Definition TRUSTTab.tpp:160
_SIZE_ dimension(int d) const
Definition TRUSTTab.tpp:133
_SIZE_ size() const
Definition TRUSTVect.tpp:45
int line_size() const
Definition TRUSTVect.tpp:67