TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Iterateur_Source_EF_Som.h
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#ifndef Iterateur_Source_EF_Som_included
17#define Iterateur_Source_EF_Som_included
18
19#include <Iterateur_Source_base.h>
20#include <Champ_Uniforme.h>
21#include <TRUSTSingle.h>
22#include <Milieu_base.h>
23#include <Domaine_EF.h>
24
25template<typename _TYPE_>
27{
28 inline unsigned taille_memoire() const override { throw; }
29
30 inline int duplique() const override
31 {
33 if (!xxx) Process::exit("Not enough memory !");
34 return xxx->numero();
35 }
36
37public:
40
41 inline Evaluateur_Source& evaluateur() override
42 {
44 return eval;
45 }
46
47 void completer_() override { nb_elems = le_dom->domaine().nb_elem_tot(); }
48
49 DoubleTab& ajouter(DoubleTab&) const override;
50 int impr(Sortie&) const override;
51
52protected:
55 mutable double coef = -1.;
56 mutable DoubleVect bilan;
57
58 template <typename Type_Double>
59 DoubleTab& ajouter_elems_standard(const int , DoubleTab& ) const;
60};
61
62template<typename _TYPE_>
63DoubleTab& Iterateur_Source_EF_Som<_TYPE_>::ajouter(DoubleTab& resu) const
64{
65 ((_TYPE_&) (evaluateur_source_elem)).mettre_a_jour();
66
67 assert(resu.nb_dim() < 3);
68 const int ncomp = resu.line_size();
69
70 bilan.resize(ncomp);
71 bilan = 0;
72 coef = 1;
74 {
75 const Milieu_base& milieu = la_zcl->equation().milieu();
76 const Champ_base& rho = milieu.masse_volumique();
77 if (sub_type(Champ_Uniforme, rho))
78 coef = rho.valeurs()(0, 0);
79 else
80 {
81 Cerr << "Cas non prevu dans Iterateur_Source_EF_Som<_TYPE_>::ajouter(DoubleTab& resu) const" << finl;
83 }
84 }
85
86 (ncomp == 1) ? ajouter_elems_standard<SingleDouble>(ncomp, resu) : ajouter_elems_standard<ArrOfDouble>(ncomp, resu);
87
88 return resu;
89}
90
91template<typename _TYPE_> template<typename Type_Double>
92DoubleTab& Iterateur_Source_EF_Som<_TYPE_>::ajouter_elems_standard(const int ncomp, DoubleTab& resu) const
93{
94 Type_Double source(ncomp);
95 const IntTab& elems = le_dom->domaine().les_elems();
96 const DoubleTab& IPhi_thilde = ref_cast(Domaine_EF,le_dom.valeur()).IPhi_thilde();
97 int nb_som_elem = le_dom->domaine().nb_som_elem();
98 for (int num_elem = 0; num_elem < nb_elems; num_elem++)
99 {
100 evaluateur_source_elem.calculer_terme_source(num_elem, source);
101 for (int k = 0; k < ncomp; k++)
102 for (int i = 0; i < nb_som_elem; i++)
103 {
104 double src = source[k]; // XXX : ATTENTION : ON CHANGE PAS source[k] !!!
105 src *= IPhi_thilde(num_elem, i);
106 bilan(k) += coef * src;
107 resu(elems(num_elem, i),k) += src;
108 }
109 }
110 return resu;
111}
112
113template<typename _TYPE_>
115{
116 for (int k = 0; k < bilan.size(); k++)
117 {
118 bilan(k) = Process::mp_sum(bilan(k));
119 if (je_suis_maitre())
120 os << " : " << bilan(k) << finl;
121 }
122 return 1;
123}
124
125#endif /* Iterateur_Source_EF_Som_included */
virtual DoubleTab & valeurs()=0
Champ_Uniforme Represents a field that is constant in space and time.
class Champ_base This class is the base of the fields hierarchy.
Definition Champ_base.h:43
class Domaine_EF
Definition Domaine_EF.h:56
virtual const Milieu_base & milieu() const =0
Iterateur_Source_EF_Som(const Iterateur_Source_EF_Som &iter)
int impr(Sortie &) const override
DoubleTab & ajouter_elems_standard(const int, DoubleTab &) const
DoubleTab & ajouter(DoubleTab &) const override
Evaluateur_Source & evaluateur() override
Milieu_base This class is the base of the (physical) medium hierarchy.
Definition Milieu_base.h:50
virtual const Equation_base & equation(const std::string &nom_inc) const
virtual const Champ_base & masse_volumique() const
Returns the mass density of the medium (const version).
virtual int duplique() const =0
virtual unsigned taille_memoire() const =0
int numero() const
Returns the index of the object in Memoire::data.
Definition Objet_U.cpp:264
friend class Sortie
Definition Objet_U.h:70
static double mp_sum(double)
Computes the sum of x over all processors in the current group.
Definition Process.cpp:145
static void exit(int exit_code=-1)
Exit routine for TRUST within a Kokkos region.
Definition Process.cpp:466
static int je_suis_maitre()
Returns 1 if on the master processor of the current group (i.e. me() == 0), 0 otherwise.
Definition Process.cpp:82
Base class for output streams.
Definition Sortie.h:52
int nb_dim() const
Definition TRUSTTab.h:199
int line_size() const
Definition TRUSTVect.tpp:67