TRUST 1.9.8
HPC thermohydraulic platform
Loading...
Searching...
No Matches
Eval_Puiss_Th_VEF_Face.h
1/****************************************************************************
2* Copyright (c) 2025, 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 Eval_Puiss_Th_VEF_Face_included
17#define Eval_Puiss_Th_VEF_Face_included
18
19#include <Evaluateur_Source_VEF_Face.h>
20#include <Champ_Uniforme.h>
21#include <TRUST_Ref.h>
22
23#include <TRUSTTab.h>
25{
26public:
27 void completer() override;
28 void associer_champs(const Champ_Don_base& );
29 void mettre_a_jour() override { }
30
31protected:
32 OBS_PTR(Champ_Don_base) la_puissance;
33 DoubleTab tab_puissance;
34 DoubleVect tab_volumes;
35 mutable int nb_faces_elem = 0;
36};
37
38// ToDo simplify coding, better on GPU and lisibility !
39/*
40bool unif = puissance.dimension(0)==1;
41int elem0 = unif ? 0 : face_voisins(num_face, 0);
42int elem1 = unif ? 0 : face_voisins(num_face, 1);
43for (int i = 0; i < size; i++)
44 source[i] = ((puissance(elem0, 0) * volumes(elem0) + puissance(elem1, 0) * volumes(elem1)) / (nb_faces_elem)) * porosite_surf[num_face];
45*/
46
47// Device compatible ligthweight class (only views and device functions)
48// When the object if copied to the device no parent stuff is copied
50{
51public:
52 virtual bool has_view() const override { return true; }
53 void set(const Eval_Puiss_Th_VEF_Face_View& eval) const
54 {
56 puissance_ = eval.tab_puissance.view_ro();
57 volumes_ = eval.tab_volumes.view_ro();
58 face_voisins_ = eval.face_voisins.view_ro();
59 volumes_entrelaces_ = eval.volumes_entrelaces.view_ro();
60 volumes_entrelaces_Cl_ = eval.volumes_entrelaces_Cl.view_ro();
61 porosite_surf_ = eval.porosite_surf.view_ro();
62 };
63 KOKKOS_INLINE_FUNCTION
64 void calculer_terme_source_standard_view(int num_face, DoubleArrView source) const
65 {
66 const int size = (int)source.size();
67 if (size > 1) Process::Kokkos_exit("Eval_Puiss_Th_VEF_Face::calculer_terme_source_standard not available for multi-inco !");
68 if (puissance_.extent(0)==1)
69 for (int i = 0; i < size; i++)
70 source(i) = puissance_(0, 0) * volumes_entrelaces_(num_face) * porosite_surf_(num_face);
71 else
72 {
73 int elem0 = face_voisins_(num_face, 0);
74 int elem1 = face_voisins_(num_face, 1);
75 for (int i = 0; i < size; i++)
76 {
77 source(i) = ((puissance_(elem0, 0) * volumes_(elem0) + puissance_(elem1, 0) * volumes_(elem1)) /
78 (nb_faces_elem)) * porosite_surf_(num_face);
79 }
80 }
81 }
82 KOKKOS_INLINE_FUNCTION
83 void calculer_terme_source_non_standard_view(int num_face, DoubleArrView source) const
84 {
85 const int size = (int)source.size();
86 if (size > 1) Process::Kokkos_exit("Eval_Puiss_Th_VEF_Face::calculer_terme_source_non_standard not available for multi-inco !");
87
88 if (puissance_.extent(0)==1)
89 for (int i = 0; i < size; i++)
90 source[i] = puissance_(0, 0) * volumes_entrelaces_Cl_[num_face]; // ToDo porosite_surf missing ?
91 else
92 {
93 int elem0 = face_voisins_(num_face, 0);
94 int elem1 = face_voisins_(num_face, 1);
95 if (elem1 != -1)
96 for (int i = 0; i < size; i++)
97 source[i] = ((puissance_(elem0, 0) * volumes_(elem0) + puissance_(elem1, 0) * volumes_(elem1)) / (nb_faces_elem)) * porosite_surf_[num_face];
98 else
99 for (int i = 0; i < size; i++)
100 source[i] = ((puissance_(elem0, 0) * volumes_(elem0)) / (nb_faces_elem)) * porosite_surf_[num_face];
101 }
102 }
103private:
104 // Views
105 mutable CDoubleTabView puissance_;
106 mutable CDoubleArrView volumes_;
107 mutable CIntTabView face_voisins_;
108 mutable CDoubleArrView volumes_entrelaces_;
109 mutable CDoubleArrView volumes_entrelaces_Cl_;
110 mutable CDoubleArrView porosite_surf_;
111};
112#endif /* Eval_Puiss_Th_VEF_Face_included */
classe Champ_Don_base classe de base des Champs donnes (non calcules)
virtual bool has_view() const override
void set(const Eval_Puiss_Th_VEF_Face_View &eval) const
KOKKOS_INLINE_FUNCTION void calculer_terme_source_non_standard_view(int num_face, DoubleArrView source) const
KOKKOS_INLINE_FUNCTION void calculer_terme_source_standard_view(int num_face, DoubleArrView source) const
void associer_champs(const Champ_Don_base &)
OBS_PTR(Champ_Don_base) la_puissance
static KOKKOS_INLINE_FUNCTION void Kokkos_exit(const char *)
Routine de sortie de TRUST dans une region Kokkos.
Definition Process.h:173
std::enable_if_t< is_default_exec_space< EXEC_SPACE >, ConstView< _TYPE_, _SHAPE_ > > view_ro() const
Definition TRUSTTab.h:261