TrioCFD 1.9.8
TrioCFD documentation
Loading...
Searching...
No Matches
Integrale_tps_Champ.cpp
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#include <Integrale_tps_Champ.h>
17
18Implemente_instanciable(Integrale_tps_Champ, "Integrale_tps_Champ", Objet_U);
19
21{
22 return s << que_suis_je() << " " << le_nom();
23}
24
26{
27 return s;
28}
29
30/*! @brief Mets a jour l'integrale.
31 *
32 * Verifie que le temps de l'integrale est inferieur a celui du champ associe et poursuit l'integration jusqu'au temps courant.
33 * si la borne superieure de l'integrale n'est pas depassee.
34 *
35 */
37{
38 OWN_PTR(Champ_base) espace_stockage_source;
39 const Champ_base& source = le_champ_ref_->get_champ(espace_stockage_source);
40 double t_courant = le_champ_ref_->get_time();
41
42 if (t_fin_ < t_debut_)
43 {
44 Cerr << " Statistic begining and ending times are not coherent " << finl;
45 Cerr << " t_fin_=" << t_fin_ << " < t_debut_=" << t_debut_ << finl;
46 exit();
47 }
48 if (inf_ou_egal(t_debut_, t_courant) && inf_ou_egal(t_courant, t_fin_))
49 {
50 double dt = t_courant - tps_integrale_;
51 if (dt > 0)
52 {
53 const DoubleTab& val = source.valeurs();
54 DoubleTab& mes_val = le_champ_->valeurs();
55 if (val.isDataOnDevice()) mapToDevice(mes_val); // If source is on device, integral will be computed on device
56 if (puissance_ == 1)
57 mes_val.ajoute(dt, val);
58 else if (puissance_ == 2)
59 mes_val.ajoute_carre(dt, val);
60 else
61 for (int i = 0; i < val.size(); i++)
62 mes_val[i] += dt * pow(val[i], puissance_);
63 tps_integrale_ = t_courant;
65 }
66 }
67}
68
70{
71 le_champ_.typer(typ);
72}
virtual DoubleTab & valeurs()=0
classe Champ_base Cette classe est la base de la hierarchie des champs.
Definition Champ_base.h:43
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
void typer_champ(const Nom &)
OWN_PTR(Champ_Fonc_base) le_champ_
virtual void mettre_a_jour_integrale()
Mets a jour l'integrale.
class Nom Une chaine de caractere pour nommer les objets de TRUST
Definition Nom.h:31
classe Objet_U Cette classe est la classe de base des Objets de TRUST
Definition Objet_U.h:73
const Nom & que_suis_je() const
renvoie la chaine identifiant la classe.
Definition Objet_U.cpp:104
virtual Entree & readOn(Entree &)
Lecture d'un Objet_U sur un flot d'entree Methode a surcharger.
Definition Objet_U.cpp:293
virtual const Nom & le_nom() const
Donne le nom de l'Objet_U Methode a surcharger : renvoie "neant" dans cette implementation.
Definition Objet_U.cpp:319
virtual Sortie & printOn(Sortie &) const
Ecriture de l'objet sur un flot de sortie Methode a surcharger.
Definition Objet_U.cpp:282
static void exit(int exit_code=-1)
Routine de sortie de TRUST dans une region Kokkos.
Definition Process.cpp:455
Classe de base des flux de sortie.
Definition Sortie.h:52
bool isDataOnDevice() const
_SIZE_ size() const
Definition TRUSTVect.tpp:45
void ajoute_carre(_SCALAR_TYPE_ alpha, const TRUSTVect &y, Mp_vect_options opt=VECT_ALL_ITEMS)
void ajoute(_SCALAR_TYPE_ alpha, const TRUSTVect &y, Mp_vect_options opt=VECT_ALL_ITEMS)
Definition TRUSTVect.tpp:52