TrioCFD 1.9.8
TrioCFD documentation
Loading...
Searching...
No Matches
Integrale_tps_produit_champs.cpp
1/****************************************************************************
2* Copyright (c) 2026, 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_produit_champs.h>
17#include <Domaine_VF.h>
18#include <TRUSTTab.h>
19
20Implemente_instanciable(Integrale_tps_produit_champs, "Integrale_tps_produit_champs", Integrale_tps_Champ);
21
23{
24 return s << que_suis_je() << " " << le_nom();
25}
26
28{
29 return s;
30}
31
32/*! @brief Mets a jour l'integrale.
33 *
34 * Verifie que le temps de l'integrale est inferieur a celui du champ associe et poursuit l'integration jusqu'au temps courant.
35 * si la borne superieure de l'integrale n'est pas depassee.
36 *
37 */
39{
40 OWN_PTR(Champ_base) espace_stockage_source, espace_stockage_source2;
41 const Champ_base& source = mon_premier_champ()->get_champ(espace_stockage_source);
42 const Champ_base& source2 = mon_second_champ()->get_champ(espace_stockage_source2);
43 const Noms nom = mon_premier_champ()->get_property("nom");
44 const Noms nom2 = mon_second_champ()->get_property("nom");
45 double t_courant = mon_premier_champ()->get_time();
46
47 if (t_courant != mon_second_champ()->get_time())
48 {
49 Cerr << "Integrale_tps_produit_champs::mettre_a_jour_integrale()" << finl;
50 Cerr << "the current time of the field named " << nom[0] << " =" << t_courant << finl;
51 Cerr << "is different of the second field current time " << nom2[0] << " =" << source2.temps() << finl;
52 exit();
53 }
54 if (t_fin_ < t_debut_)
55 {
56 Cerr << " Statistics begining and ending times are not coherent " << finl;
57 Cerr << " t_fin_=" << t_fin_ << " < t_debut_=" << t_debut_ << finl;
58 exit();
59 }
60 if (inf_ou_egal(t_debut_, t_courant) && inf_ou_egal(t_courant, t_fin_))
61 {
62 double dt = t_courant - tps_integrale_;
63 if (dt > 0)
64 {
65 if (premiere_puissance() == 1 && seconde_puissance() == 1)
66 {
67 const DoubleTab& val1 = source.valeurs();
68 const DoubleTab& val2 = source2.valeurs();
69 DoubleTab& mes_val = le_champ_->valeurs();
70 if (val1.isDataOnDevice() && val2.isDataOnDevice())
71 mapToDevice(mes_val); // If sources are on device, integral will be computed on device
72 ajoute_produit_tensoriel(dt, source, source2);
73 }
74 else
75 {
76 Cerr << "Integrale_tps_produit_champs::mettre_a_jour_integrale() : case not coded." << finl;
77 }
78 tps_integrale_ = t_courant;
80 }
81 }
82}
83
85{
87 {
88 ToDo_Kokkos("Use DoubleTrav and don't resize...");
89 // On ramene au centre des elements
90 const DoubleTab& xp = ref_cast(Domaine_VF,le_champ_->domaine_dis_base()).xp();
91 int nb_elem_tot = xp.dimension_tot(0);
92 DoubleTab val_a, val_b;
93 // Le jour ou les champs seront mieux foutus, on n'aura
94 // pas a faire ca:
95 val_a.resize(nb_elem_tot, a.nb_comp());
96 val_b.resize(nb_elem_tot, b.nb_comp());
97 a.valeur_aux(xp, val_a);
98 b.valeur_aux(xp, val_b);
99 le_champ_->valeurs().ajoute_produit_tensoriel(alpha, val_a, val_b);
100 le_champ_->valeurs().echange_espace_virtuel();
101 }
102 else
103 {
104 const DoubleTab& val_a = a.valeurs(), &val_b = b.valeurs();
105 le_champ_->valeurs().ajoute_produit_tensoriel(alpha, val_a, val_b);
106 }
107}
virtual DoubleTab & valeurs()=0
classe Champ_base Cette classe est la base de la hierarchie des champs.
Definition Champ_base.h:43
double temps() const
Renvoie le temps du champ.
virtual DoubleTab & valeur_aux(const DoubleTab &positions, DoubleTab &valeurs) const
Provoque une erreur ! Doit etre surchargee par les classes derivees.
class Domaine_VF
Definition Domaine_VF.h:44
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
virtual int nb_comp() const
Definition Field_base.h:56
OWN_PTR(Champ_Fonc_base) le_champ_
classe Integrale_tps_produit_champs Cette classe represente l'integrale en temps d'un produit de 2 ch...
void mettre_a_jour_integrale() override
Mets a jour l'integrale.
void ajoute_produit_tensoriel(double, const Champ_base &, const Champ_base &)
Un tableau de chaine de caracteres (VECT(Nom)).
Definition Noms.h:26
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
void resize(_SIZE_ n, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT)
Definition TRUSTTab.tpp:469
void ajoute_produit_tensoriel(_T_ alpha, const TRUSTTab< _T_, _SIZE_ > &, const TRUSTTab< _T_, _SIZE_ > &)
Definition TRUSTTab.tpp:760
_SIZE_ dimension_tot(int) const override
Definition TRUSTTab.tpp:160