TrioCFD 1.9.8
TrioCFD documentation
Loading...
Searching...
No Matches
Iterateur_Source_Elem.h
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#ifndef Iterateur_Source_Elem_included
17#define Iterateur_Source_Elem_included
18
19#include <Iterateur_Source_base.h>
20#include <Champ_Uniforme.h>
21#include <TRUSTSingle.h>
22
23template <class _TYPE_>
25{
26 inline unsigned taille_memoire() const override { throw; }
27
28 inline int duplique() const override
29 {
31 if(!xxx) Process::exit("Not enough memory !");
32 return xxx->numero();
33 }
34
35public:
36 DoubleTab& ajouter(DoubleTab& ) const override;
37
38 void completer_() override { nb_elem_ = le_dom->nb_elem(); }
39 inline Evaluateur_Source& evaluateur() override
40 {
41 Evaluateur_Source& eval = static_cast<Evaluateur_Source&>(evaluateur_source_elem);
42 return eval;
43 }
44
45private:
46 _TYPE_ evaluateur_source_elem;
47 int nb_elem_;
48
49 template <typename Type_Double> DoubleTab& ajouter_(const int, DoubleTab& ) const;
50};
51
52template<class _TYPE_>
53DoubleTab& Iterateur_Source_Elem<_TYPE_>::ajouter(DoubleTab& resu) const
54{
55 ((_TYPE_&) (evaluateur_source_elem)).mettre_a_jour();
56 assert(resu.nb_dim() < 3);
57 const int ncomp = resu.line_size();
58 DoubleVect& bilan = so_base->bilan();
59 bilan = 0;
60
61 (ncomp == 1) ? ajouter_<SingleDouble>(ncomp, resu) : ajouter_<ArrOfDouble>(ncomp, resu);
62 return resu;
63}
64
65template<class _TYPE_> template<typename Type_Double>
66DoubleTab& Iterateur_Source_Elem<_TYPE_>::ajouter_(const int ncomp, DoubleTab& resu) const
67{
68 Type_Double source(ncomp);
69 DoubleVect& bilan = so_base->bilan();
70 for (int num_elem = 0; num_elem < nb_elem_; num_elem++)
71 {
72 evaluateur_source_elem.calculer_terme_source(num_elem, source);
73 for (int k = 0; k < ncomp; k++)
74 {
75 resu(num_elem, k) += source[k];
76 bilan(k) += source[k];
77 }
78 }
79 return resu;
80}
81
82#endif /* Iterateur_Source_Elem_included */
Evaluateur_Source & evaluateur() override
DoubleTab & ajouter(DoubleTab &) const override
virtual int duplique() const =0
virtual unsigned taille_memoire() const =0
int numero() const
Renvoie l'indice de l'objet dans Memoire::data.
Definition Objet_U.cpp:268
static void exit(int exit_code=-1)
Routine de sortie de TRUST dans une region Kokkos.
Definition Process.cpp:455
int nb_dim() const
Definition TRUSTTab.h:199
int line_size() const
Definition TRUSTVect.tpp:67