TrioCFD 1.9.9_beta
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 Updates the integral.
33 *
34 * @brief Checks that the integral time is less than or equal to the current time of the associated field and continues
35 * the integration up to the current time, if the upper bound of the integral has not been exceeded.
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 // Bring values back to element centers
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 // Once fields have a cleaner interface, this workaround will not be needed:
94 val_a.resize(nb_elem_tot, a.nb_comp());
95 val_b.resize(nb_elem_tot, b.nb_comp());
96 a.valeur_aux(xp, val_a);
97 b.valeur_aux(xp, val_b);
98 le_champ_->valeurs().ajoute_produit_tensoriel(alpha, val_a, val_b);
99 le_champ_->valeurs().echange_espace_virtuel();
100 }
101 else
102 {
103 const DoubleTab& val_a = a.valeurs(), &val_b = b.valeurs();
104 le_champ_->valeurs().ajoute_produit_tensoriel(alpha, val_a, val_b);
105 }
106}
virtual DoubleTab & valeurs()=0
class Champ_base This class is the base of the fields hierarchy.
Definition Champ_base.h:43
double temps() const
Returns the time of the field.
virtual DoubleTab & valeur_aux(const DoubleTab &positions, DoubleTab &valeurs) const
Causes an error! Must be overridden by derived classes.
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_
class Integrale_tps_produit_champs
void mettre_a_jour_integrale() override
Updates the integral.
void ajoute_produit_tensoriel(double, const Champ_base &, const Champ_base &)
An array of character strings (VECT(Nom)).
Definition Noms.h:26
const Nom & que_suis_je() const
Returns the string identifying the class.
Definition Objet_U.cpp:104
virtual Entree & readOn(Entree &)
Reads an Objet_U from an input stream. Virtual method to override.
Definition Objet_U.cpp:289
virtual const Nom & le_nom() const
Returns the name of the Objet_U. Virtual method to override: returns "neant" in this implementation.
Definition Objet_U.cpp:317
virtual Sortie & printOn(Sortie &) const
Writes the object to an output stream. Virtual method to override.
Definition Objet_U.cpp:278
static void exit(int exit_code=-1)
Exit routine for TRUST within a Kokkos region.
Definition Process.cpp:466
Base class for output streams.
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