TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Champ_Fonc_Tabule_Morceaux_Interp.cpp
1/****************************************************************************
2* Copyright (c) 2023, 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_Morceaux_Interp.h>
17#include <TRUSTTab_parts.h>
18#include <Domaine_VF.h>
19#include <TRUSTTrav.h>
20#include <Domaine.h>
21#include <EChaine.h>
22
23Implemente_instanciable(Champ_Fonc_Tabule_Morceaux_Interp, "Champ_Fonc_Tabule_Morceaux_Interp", Champ_Fonc_Tabule_Morceaux);
24// XD Champ_Fonc_Tabule_Morceaux_Interp Champ_Fonc_Tabule_Morceaux Champ_Fonc_Tabule_Morceaux_Interp NO_BRACE Field
25// XD_CONT defined by tabulated data in each sub-domaine. It makes possible the definition of a field which is a
26// XD_CONT function of other fields. Here we use MEDCoupling to interpolate fields between the two domains.
27// XD attr domain_name suppress_param domain_name REQ del.
28// XD attr problem_name ref_Pb_base problem_name REQ Name of the problem.
29
32{
33 is_interp_ = true;
36}
37
39{
40 /* fill ch_param_interp (champ_fonc_interp) and i_ch (fields used by each piece) */
41 std::vector<std::array<std::string, 3>> v_pb_ch(s_pb_ch.begin(), s_pb_ch.end()); //set -> vector
42
43 ch_param_interp.resize(v_pb_ch.size());
44 for (int i = 0; i < (int)v_pb_ch.size(); i++)
45 {
46 Nom ch_int = Nom("{ pb_loc ") + ref_pb->le_nom() + " pb_dist " + Nom(v_pb_ch[i][0]) + " nom_champ " + Nom(v_pb_ch[i][1]) + " nature " + Nom(v_pb_ch[i][2]) + " }";
47 EChaine ech(ch_int);
48 ech >> ch_param_interp[i];
49 }
50
51 for (auto &&pch : ch_param_interp)
52 pch.initialiser(tps);
53
54 for (int i = 0; i < (int) m_pb_ch.size(); i++)
55 for (auto && pb_ch : m_pb_ch[i]) /* indices */
56 morceaux[i].i_ch.push_back((int)(std::lower_bound(v_pb_ch.begin(), v_pb_ch.end(), pb_ch) - v_pb_ch.begin()));
57
58 m_pb_ch.clear();
59 s_pb_ch.clear();
60
62}
63
65{
66
67 DoubleTab& tab = valeurs();
68 std::vector<const DoubleTab* > pval; /* parameter values */
69 std::vector<bool> is_multi; /* true if the corresponding field is multi-component */
70 pval.reserve(ch_param_interp.size()), is_multi.reserve(ch_param_interp.size());
71 for (auto &&pch : ch_param_interp)
72 {
73 pch.mettre_a_jour(time);
74 pval.push_back(&pch.valeurs());
75 is_multi.push_back(pval.back()->dimension(1) > 1);
76 }
77 std::vector<double> vals(ch_param_interp.size());
78 for (int e = 0; e < mon_domaine->nb_elem(); e++)
79 {
80 const CHTAB& mor = morceaux[i_mor(e)];
81 int N = tab.dimension(1), M = (int) mor.i_ch.size();
82 if (N == 1 && M == 1)
83 tab(e, 0) = mor.la_table.val_simple((*pval[mor.i_ch[0]])(e, 0));
84 else for (int n = 0, m; n < N; n++)
85 {
86 for (vals.clear(), m = 0; m < M; m++) vals.push_back((*pval[mor.i_ch[m]])(e, n * is_multi[mor.i_ch[m]])); /* if the parameter field is multi-component, take the same component as the field */
87 tab(e, n) = mor.la_table.val(vals, n);
88 }
89 }
91}
DoubleTab & valeurs() override
Overrides Champ_base::valeurs() Returns the array of values.
Champ_Fonc_Tabule_Morceaux_Interp This class represents a field taking piecewise values as functions.
std::vector< Champ_Fonc_Interp > ch_param_interp
int initialiser(const double temps) override
DOES NOTHING.
void mettre_a_jour(double temps) override
Time update.
class Champ_Fonc_Tabule_Morceaux
std::vector< std::vector< ArrStr > > m_pb_ch
An input stream whose source is a character string.
Definition EChaine.h:31
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
class Nom: a character string for naming TRUST objects.
Definition Nom.h:31
const Nom & le_nom() const override
Returns *this.
Definition Nom.cpp:555
virtual Entree & readOn(Entree &)
Reads an Objet_U from an input stream. Virtual method to override.
Definition Objet_U.cpp:289
virtual Sortie & printOn(Sortie &) const
Writes the object to an output stream. Virtual method to override.
Definition Objet_U.cpp:278
Base class for output streams.
Definition Sortie.h:52
int initialiser(const double temps) override
DOES NOTHING.
_SIZE_ dimension(int d) const
Definition TRUSTTab.tpp:133
virtual void echange_espace_virtuel(IsExchangeBlocking exchange_type=IsExchangeBlocking::DefaultBlocking, const std::string kernel_name="noname")
double val_simple(double vals_param) const
Definition Table.cpp:128
double val(const double val_param, int ncomp=0) const
Definition Table.cpp:143