TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
TRUSTChamp_Don_generique.h
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#ifndef TRUSTChamp_Don_generique_included
17#define TRUSTChamp_Don_generique_included
18
19#include <Champ_Don_base.h>
20#include <Champ_Uniforme.h>
21#include <Parser_Eval.h>
22#include <TRUST_Ref.h>
23#include <Domaine.h>
24#include <Interprete.h>
25
26enum class Champ_Don_Type { XYZ , TXYZ , LU };
27
28template <Champ_Don_Type _TYPE_>
30{
31public:
32
33 Sortie& printOn(Sortie& os) const override;
34 void mettre_a_jour(double) override;
35 double valeur_a_compo(const DoubleVect& position, int ncomp) const override;
36
37 Domaine& interprete_get_domaine(const Nom& nom)
38 {
39 mon_domaine = ref_cast(Domaine, Interprete::objet(nom));
40 return mon_domaine.valeur();
41 }
42
43 // ERROR: it makes no sense to perform an assignment with a Champ_Don_Fonc_xyz/txyz.
45 {
47 return *this;
48 }
49
50 Champ_base& affecter_(const Champ_base& ch) override
51 {
52 static constexpr bool IS_LU = (_TYPE_ == Champ_Don_Type::LU);
53 if (IS_LU)
54 return Champ_Don_base::affecter_(ch); // throw
55 else
56 {
57 if (sub_type(Champ_Uniforme, ch)) valeurs() = ch.valeurs()(0, 0);
58 else valeurs() = ch.valeurs();
59 return *this;
60 }
61 }
62
63 DoubleVect& valeur_a(const DoubleVect& position, DoubleVect& vals) const override
64 {
65 return valeur_a_<_TYPE_>(position, vals);
66 }
67
68 DoubleVect& valeur_a_elem(const DoubleVect& position, DoubleVect& vals, int le_poly) const override
69 {
70 return valeur_a_elem_<_TYPE_>(position, vals, le_poly);
71 }
72
73 double valeur_a_elem_compo(const DoubleVect& position, int le_poly, int ncomp) const override
74 {
75 return valeur_a_elem_compo_<_TYPE_>(position, le_poly, ncomp);
76 }
77
78 DoubleTab& valeur_aux(const DoubleTab& positions, DoubleTab& vals) const override
79 {
80 return valeur_aux_<_TYPE_>(positions, vals);
81 }
82
83 DoubleVect& valeur_aux_compo(const DoubleTab& positions, DoubleVect& vals, int ncomp) const override
84 {
85 return valeur_aux_compo_<_TYPE_>(positions, vals, ncomp);
86 }
87
88 DoubleTab& valeur_aux_elems(const DoubleTab& positions, const IntVect& les_polys, DoubleTab& vals) const override
89 {
90 return valeur_aux_elems_<_TYPE_>(positions, les_polys, vals);
91 }
92
93 DoubleVect& valeur_aux_elems_compo(const DoubleTab& positions, const IntVect& les_polys, DoubleVect& vals, int ncomp) const override
94 {
95 return valeur_aux_elems_compo_<_TYPE_>(positions,les_polys,vals,ncomp);
96 }
97
98protected:
99 OBS_PTR(Domaine) mon_domaine;
100 void mettre_a_jour_positions(DoubleTab& );
101
102private:
103 /*
104 * SFINAE template functions : can not be implemented directly on overrided functions ==> internal methods ;-)
105 */
106 template<Champ_Don_Type T = _TYPE_> std::enable_if_t<T != Champ_Don_Type::LU, DoubleVect&>
107 valeur_a_(const DoubleVect& position, DoubleVect& valeurs) const;
108
109 template<Champ_Don_Type T = _TYPE_> std::enable_if_t<T == Champ_Don_Type::LU, DoubleVect&>
110 valeur_a_(const DoubleVect& position, DoubleVect& valeurs) const;
111
112 template<Champ_Don_Type T = _TYPE_> std::enable_if_t<T != Champ_Don_Type::LU, DoubleVect&>
113 valeur_a_elem_(const DoubleVect& position, DoubleVect& valeurs, int le_poly) const;
114
115 template<Champ_Don_Type T = _TYPE_> std::enable_if_t<T == Champ_Don_Type::LU, DoubleVect&>
116 valeur_a_elem_(const DoubleVect& position, DoubleVect& valeurs, int le_poly) const;
117
118 template <Champ_Don_Type T = _TYPE_> std::enable_if_t<T != Champ_Don_Type::TXYZ, double>
119 valeur_a_elem_compo_(const DoubleVect& position, int le_poly, int ncomp) const;
120
121 template <Champ_Don_Type T = _TYPE_> std::enable_if_t<T == Champ_Don_Type::TXYZ, double>
122 valeur_a_elem_compo_(const DoubleVect& position, int le_poly, int ncomp) const;
123
124 template <Champ_Don_Type T = _TYPE_> std::enable_if_t<T != Champ_Don_Type::LU, DoubleTab&>
125 valeur_aux_(const DoubleTab& positions, DoubleTab& valeurs) const;
126
127 template<Champ_Don_Type T = _TYPE_> std::enable_if_t<T == Champ_Don_Type::LU, DoubleTab&>
128 valeur_aux_(const DoubleTab& positions, DoubleTab& valeurs) const;
129
130 template<Champ_Don_Type T = _TYPE_> std::enable_if_t<T != Champ_Don_Type::LU, DoubleVect&>
131 valeur_aux_compo_(const DoubleTab& positions, DoubleVect& valeurs, int ncomp) const;
132
133 template<Champ_Don_Type T = _TYPE_> std::enable_if_t<T == Champ_Don_Type::LU, DoubleVect&>
134 valeur_aux_compo_(const DoubleTab& positions, DoubleVect& valeurs, int ncomp) const;
135
136 template<Champ_Don_Type T = _TYPE_> std::enable_if_t<T != Champ_Don_Type::LU, DoubleTab&>
137 valeur_aux_elems_(const DoubleTab& positions, const IntVect& les_polys, DoubleTab& valeurs) const;
138
139 template<Champ_Don_Type T = _TYPE_> std::enable_if_t<T == Champ_Don_Type::LU, DoubleTab&>
140 valeur_aux_elems_(const DoubleTab& positions, const IntVect& les_polys, DoubleTab& valeurs) const;
141
142 template<Champ_Don_Type T = _TYPE_> std::enable_if_t<T != Champ_Don_Type::LU, DoubleVect&>
143 valeur_aux_elems_compo_(const DoubleTab& positions, const IntVect& les_polys, DoubleVect& valeurs, int ncomp) const;
144
145 template<Champ_Don_Type T = _TYPE_> std::enable_if_t<T == Champ_Don_Type::LU, DoubleVect&>
146 valeur_aux_elems_compo_(const DoubleTab& positions, const IntVect& les_polys, DoubleVect& valeurs, int ncomp) const;
147};
148
149#include <TRUSTChamp_Don_generique.tpp>
150
151#endif /* TRUSTChamp_Don_generique_included */
class Champ_Don_base base class of Given Fields (not calculated)
Champ_base & affecter_(const Champ_base &) override
Causes an error! To be overridden by derived classes! Not a pure virtual for development convenience!
DoubleTab & valeurs() override
Overrides Champ_base::valeurs() Returns the array of values.
virtual DoubleTab & valeurs()=0
Champ_Uniforme Represents a field that is constant in space and time.
Champ_base()
Default constructor of a Champ_base.
void affecter_erreur()
static Objet_U & objet(const Nom &)
See Interprete_bloc::objet_global(). BM: the Interprete class is not the best place for this.
class Nom: a character string for naming TRUST objects.
Definition Nom.h:31
Parser_Eval class - Evaluates the values taken by an analytic function.
Definition Parser_Eval.h:29
Base class for output streams.
Definition Sortie.h:52
void mettre_a_jour(double) override
Time update.
DoubleTab & valeur_aux_elems(const DoubleTab &positions, const IntVect &les_polys, DoubleTab &vals) const override
Causes an error! Must be overridden by derived classes.
DoubleVect & valeur_a(const DoubleVect &position, DoubleVect &vals) const override
Computes the "values" of the field at the point with coordinates "pos".
Champ_base & affecter_(const Champ_base &ch) override
Causes an error! To be overridden by derived classes! Not a pure virtual for development convenience!
Domaine & interprete_get_domaine(const Nom &nom)
Champ_base & affecter(const Champ_base &ch)
DoubleVect & valeur_aux_elems_compo(const DoubleTab &positions, const IntVect &les_polys, DoubleVect &vals, int ncomp) const override
Causes an error! Must be overridden by derived classes.
OBS_PTR(Domaine) mon_domaine
Sortie & printOn(Sortie &os) const override
Writes the object to an output stream. Virtual method to override.
double valeur_a_compo(const DoubleVect &position, int ncomp) const override
Computes the point value of the component "compo" of the field at the point with coordinates pos.
DoubleVect & valeur_aux_compo(const DoubleTab &positions, DoubleVect &vals, int ncomp) const override
Same as valeur_aux(const DoubleTab &, DoubleTab &), but computes only the component compo of the fiel...
double valeur_a_elem_compo(const DoubleVect &position, int le_poly, int ncomp) const override
Causes an error! Must be overridden by derived classes.
DoubleTab & valeur_aux(const DoubleTab &positions, DoubleTab &vals) const override
Causes an error! Must be overridden by derived classes.
DoubleVect & valeur_a_elem(const DoubleVect &position, DoubleVect &vals, int le_poly) const override
Causes an error! Must be overridden by derived classes.