TRUST 1.9.8
HPC thermohydraulic platform
Loading...
Searching...
No Matches
Check_espace_virtuel.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 Check_espace_virtuel_H
17#define Check_espace_virtuel_H
18
19#include <Comm_Group.h>
20#include <TRUSTVect.h>
21
22// Renvoie 1 si l'espace virtuel de v est a jour, 0 sinon
23int check_espace_virtuel_vect(const DoubleVect& v);
24int check_espace_virtuel_vect(const IntVect& v);
25void assert_invalide_items_non_calcules(DoubleVect& v, double valeur = 0.);
26
27template <typename _TYPE_>
28extern void remplir_items_non_calcules_(TRUSTVect<_TYPE_>& v, _TYPE_ valeur);
29
30/*! @brief Remplit les "items non calcules" du tableau avec une valeur invalide.
31 *
32 * Ce sont tous les items qui ne sont pas repertories dans v.get_md_vector().valeurs().get_blocs_items_to_compute(). (items non calcules par les operations par defaut sur les vecteurs, en general ce sont les items virtuels)
33 * Il est conseille d'appliquer cette methode a la fin des fonctions qui ne renvoient pas un espace virtuel a jour avec declare_espace_virtuel_invalide(...))
34 * de sorte a provoquer une erreur si l'espace virtuel est utilise.
35 *
36 */
37template<typename _TYPE_>
38inline void remplir_items_non_calcules(TRUSTVect<_TYPE_>& v, _TYPE_ valeur = 0)
39{
40 remplir_items_non_calcules_(v, valeur);
41}
42
43/*! @brief en mode comm_check_enabled(), verifie si l'espace virtuel du vecteur est a jour, si ce n'est pas le cas, exit().
44 *
45 * Ce test n'est fait qu'en mode comm_check_enabled() car il necessite des communications.
46 *
47 */
48template<typename _TYPE_>
49inline void assert_espace_virtuel_vect(const TRUSTVect<_TYPE_>& v)
50{
52 {
53 if (! check_espace_virtuel_vect(v))
54 {
55 Cerr << "Fatal error in assert_espace_virtuel_vect: virtual space of this vector is not up to date." << finl;
58 }
59 }
60}
61
62/*! @brief When compiled without NDEBUG or when running with check_enabled flag, fills all "not computed" items with an invalid value (ie, items that are not VECT_REAL_ITEMS, usually, these are the virtual items).
63 *
64 * You should call this method whenever you compute some field values but you don't compute or update the virtual space.
65 *
66 */
67template<typename _TYPE_>
68inline void declare_espace_virtuel_invalide(TRUSTVect<_TYPE_>& v)
69{
70 const _TYPE_ valeur = (std::is_same<_TYPE_,double>::value) ? -98765.4321 : -1999999999;
71#ifdef NDEBUG
73 remplir_items_non_calcules(v, valeur);
74#else
75 remplir_items_non_calcules(v, valeur);
76#endif
77}
78
79#endif /* Check_espace_virtuel_H */
static int check_enabled()
Definition Comm_Group.h:159
static void barrier()
Synchronise tous les processeurs du groupe courant (attend que tous les processeurs soient arrives a ...
Definition Process.cpp:136
static void exit(int exit_code=-1)
Routine de sortie de TRUST dans une region Kokkos.
Definition Process.cpp:455