TrioCFD 1.9.8
TrioCFD documentation
Loading...
Searching...
No Matches
Champ_Fonc_Tabule_Elem_PolyMAC_CDO.cpp
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#include <Champ_Fonc_Tabule_Elem_PolyMAC_CDO.h>
17#include <Domaine_VF.h>
18#include <Table.h>
19
20Implemente_instanciable(Champ_Fonc_Tabule_Elem_PolyMAC_CDO, "Champ_Fonc_Tabule_Elem_PolyMAC_CDO", Champ_Fonc_Elem_PolyMAC_CDO);
21
22Sortie& Champ_Fonc_Tabule_Elem_PolyMAC_CDO::printOn(Sortie& s) const { return s << que_suis_je() << " " << le_nom(); }
23
25
27{
28 les_ch_param = les_champs;
29 la_table = une_table;
30}
31
33{
34 const Domaine_VF& zvf = le_dom_VF.valeur();
35 const Table& table = la_table.valeur();
36 DoubleTab& mes_valeurs = valeurs();
37 const int nb_elem = zvf.nb_elem(), nb_elem_tot = zvf.nb_elem_tot(), nb_param = les_ch_param.size();
38 DoubleTabs val_params_aux_elems;
39 for (int i = 0; i < nb_param; i++)
40 {
41 assert(les_ch_param[i]->valeurs().dimension(1) == 1 || les_ch_param[i]->valeurs().dimension(1) == mes_valeurs.dimension(1));
42 DoubleTab vp(nb_elem_tot, les_ch_param[i]->valeurs().dimension(1));
43 val_params_aux_elems.add(vp);
44 }
45 const DoubleTab& centres_de_gravites = zvf.xp();
46 IntVect les_polys(nb_elem_tot);
47 for (int elem = 0; elem < nb_elem_tot; elem++)
48 les_polys(elem) = elem;
49
50 // Estimate the field parameter on cells:
51 for (int i = 0; i < nb_param; i++)
52 les_ch_param[i]->valeur_aux_elems(centres_de_gravites, les_polys, val_params_aux_elems[i]);
53 // Compute the field according to the parameter field
54 if (table.isfonction() != 2)
55 {
56 const int nbcomp = mes_valeurs.dimension(1);
57 std::vector<double> vals;
58 vals.reserve(nb_param); // Pre-allocate space once
59 for (int num_elem = 0; num_elem < nb_elem; num_elem++)
60 for (int ncomp = 0; ncomp < nbcomp; ncomp++)
61 {
62 vals.clear(); // Just clear the vector, keeping the allocated memory
63 for (int n = 0; n < nb_param; n++)
64 vals.push_back(val_params_aux_elems[n](num_elem, les_ch_param[n]->valeurs().dimension(1) == 1 ? 0 : ncomp));
65 mes_valeurs(num_elem, ncomp) = table.val(vals, ncomp);
66 }
67 }
68 else
69 {
70 abort();
71 table.valeurs(val_params_aux_elems[0], centres_de_gravites, t, mes_valeurs);
72 }
73
75}
76
DoubleTab & valeurs() override
Surcharge Champ_base::valeurs() Renvoie le tableau des valeurs.
DoubleTab & valeur_aux_elems(const DoubleTab &positions, const IntVect &polys, DoubleTab &result) const override
provoque une erreur ! doit etre surchargee par les classes derivees
void mettre_a_jour(double) override
Mise a jour en temps du champ.
VECT(OBS_PTR(Champ_base)) les_ch_param
int initialiser(const double temps) override
NE FAIT RIEN.
void associer_param(const VECT(OBS_PTR(Champ_base))&, const Table &)
void mettre_a_jour(double temps) override
Mise a jour en temps du champ.
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.
class Domaine_VF
Definition Domaine_VF.h:44
double xp(int num_elem, int k) const
Definition Domaine_VF.h:77
int nb_elem_tot() const
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
const Nom & le_nom() const override
Renvoie le nom du champ.
static int dimension
Definition Objet_U.h:99
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 Sortie & printOn(Sortie &) const
Ecriture de l'objet sur un flot de sortie Methode a surcharger.
Definition Objet_U.cpp:282
static void abort()
Routine de sortie de Trio-U sur une erreur abort().
Definition Process.cpp:570
Classe de base des flux de sortie.
Definition Sortie.h:52
_SIZE_ dimension(int d) const
Definition TRUSTTab.tpp:133
value_type & add()=delete
Definition Table.h:29
double val(const double val_param, int ncomp=0) const
Definition Table.cpp:145
const int & isfonction() const
Definition Table.h:74
DoubleTab & valeurs(const DoubleTab &val_param, const DoubleTab &pos, const double tps, DoubleTab &val) const
Definition Table.cpp:292