TrioCFD 1.9.8
TrioCFD documentation
Loading...
Searching...
No Matches
Ch_front_input.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 <Ch_front_input.h>
17#include <Probleme_base.h>
18#include <Schema_Temps_base.h>
19#include <Interprete.h>
20#include <Domaine.h>
21#include <Frontiere_dis_base.h>
22#include <communications.h>
23#include <Convert_ICoCoTrioField.h>
24
25Implemente_instanciable(Ch_front_input,"Ch_front_input",Ch_front_var_instationnaire_dep);
26// XD ch_front_input front_field_base ch_front_input BRACE not_set
27// XD attr nb_comp entier nb_comp REQ not_set
28// XD attr nom chaine nom REQ not_set
29// XD attr initial_value list initial_value OPT not_set
30// XD attr probleme chaine probleme REQ not_set
31// XD attr sous_zone ref_sous_zone sous_zone OPT not_set
32
33
35{
36 sous_domaine_ok=false;
37 read(is);
38 mon_pb->addInputField(*this);
39 return is;
40}
41
43{
44 return os;
45}
46
48{
50}
51
53{
54 nommer(name);
55}
56
58{
59 return le_nom();
60}
61
62/*! @brief Provides afield with a name, a time interval, components, and no field ownership.
63 *
64 * The geometry includes all nodes of the domain and all faces of the boundary.
65 * WEC : optimization possible here
66 *
67 */
68void Ch_front_input::getTemplate(TrioField& afield) const
69{
70
71 afield.clear();
72 afield.setName(le_nom().getChar());
73
74 afield._time1=mon_pb->presentTime();
75 afield._time2=mon_pb->futureTime();
76
77 afield._nb_field_components=nb_comp();
78
79 int org=1;
80 if (faces_.dimension(1)==4) org=0;
81 org=0;
82 // en mettant org a o1 on revient a l'ancien codage
83
84
85 const DoubleTab& sommets=org==1?mon_pb->domaine().les_sommets():sommets_;
86 const IntTab& faces=org==1?frontiere_dis().frontiere().faces().les_sommets():faces_;
87
88 assert(sommets.nb_dim()==2);
89 assert(faces.nb_dim()==2);
90
91 afield._space_dim=sommets.dimension(1);
92 afield._mesh_dim=afield._space_dim-1;
93 afield._nbnodes=sommets.dimension(0);
94 afield._nodes_per_elem = mp_max(faces.dimension(1));
95 afield._nb_elems=faces.dimension(0);
96
97 // Includes all the nodes, even those not used in connectivity
98 // order is x y z x y z x y z
99 affecte_double_avec_doubletab(&afield._coords,sommets);
100
101 affecte_int_avec_inttab(&afield._connectivity,faces);
102}
103
104// In the case of a mobile mesh (ALE frame) we need to call this function after each displacement of the mesh
106{
107 const DoubleTab& sommets_org=(mon_pb->domaine().les_sommets());
108 DoubleTab& sommets=sommets_;
109 sommets.resize(sommets_org.dimension_tot(0),sommets_org.dimension(1));
110
111
112 IntTab& faces=faces_;
113 const IntTab& faces_org=(frontiere_dis().frontiere().faces().les_sommets());
114 faces=faces_org;
115 int ntot=0;
116 ArrOfInt marqueur(sommets_org.dimension(0));
117 marqueur=-1;
118 for (int f=0; f<faces.dimension(0); f++)
119 {
120 for (int s=0; s<faces.dimension(1); s++)
121 {
122 int som=faces(f,s);
123 if (som >= 0 && marqueur[som]==-1)
124 {
125
126 marqueur[som]=ntot;
127 for (int dir=0; dir<dimension; dir++)
128 {
129 sommets(ntot,dir)=sommets_org(som,dir);
130 }
131 ntot++;
132 }
133 }
134 }
135 sommets.resize(ntot,dimension);
136
137
138 // on refait les faces
139 for (int f=0; f<faces.dimension(0); f++)
140 for (int s=0; s<faces.dimension(1); s++)
141 faces(f,s) = faces_org(f, s) >= 0 ? marqueur[faces_org(f,s)] : -1;
142
143}
144
145/*! @brief Uses the first value in afield as uniform value, regardless of geometry.
146 *
147 */
148void Ch_front_input::setValue(const TrioField& afield)
149{
150 for (int i=1; i<les_valeurs->nb_cases(); i++)
152 calculer_derivee_en_temps(afield._time1,afield._time2);
153}
154
155int Ch_front_input::initialiser(double temps, const Champ_Inc_base& inco)
156{
158 return 0;
159
160 /*
161 if (nb_comp()==1)
162 for (int i=0;i<les_valeurs->nb_cases();i++)
163 les_valeurs[i].valeurs()=9.9e5;
164 */
165
167
168 return 1;
169}
170
171// setDoubleValue: actually set a field value, provided it has size 1.
172void Ch_front_input::setDoubleValue(const double val)
173{
174 assert(les_valeurs[0].valeurs().size() == 1);
175 for (int i=1; i<les_valeurs->nb_cases(); i++)
176 les_valeurs[i].valeurs()(0,0) = val;
177}
178
class Ch_front_input
void buildSommetsFaces() const
void setDoubleValue(const double val) override
DoubleTab sommets_
void getTemplate(TrioField &afield) const override
Provides afield with a name, a time interval, components, and no field ownership.
void setValue(const TrioField &afield) override
Uses the first value in afield as uniform value, regardless of geometry.
void set_nb_comp(int i) override
virtual const Nom & get_name() const
int initialiser(double temps, const Champ_Inc_base &inco) override
Initialisation en debut de calcul.
void set_name(const Nom &) override
classe Ch_front_var_instationnaire_dep Cette classe abstraite represente un champ sur une frontiere,
int initialiser(double temps, const Champ_Inc_base &inco) override
Initialisation en debut de calcul.
Classe Champ_Inc_base.
void setValueOnTab(const TrioField &afield, DoubleTab &tab)
void read(Entree &is)
Lecture d'un champ input dans un flot d'entree Factorisation des readOn des differents Champ_input.
virtual const Frontiere_dis_base & frontiere_dis() const
Renvoie la frontiere discretisee associee au champ.
virtual DoubleTab & valeurs() override
Renvoie le tableau des valeurs du champ.
virtual void calculer_derivee_en_temps(double t1, double t2)
Calcule le taux d'accroissement du champ entre t1 et t2 et le stocke dans Gpoint_.
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
const IntTab_t & les_sommets() const
Renvoie le tableau des sommets de toutes les faces.
Definition Faces.h:74
virtual void fixer_nb_comp(int i)
Fixe le nombre de composantes du champ.
const Nom & le_nom() const override
Renvoie le nom du champ.
void nommer(const Nom &) override
Donne un nom au champ.
virtual int nb_comp() const
Definition Field_base.h:56
const Faces_t & faces() const
Definition Frontiere.h:54
const Frontiere & frontiere() const
Renvoie la frontiere geometrique associee.
class Nom Une chaine de caractere pour nommer les objets de TRUST
Definition Nom.h:31
static int dimension
Definition Objet_U.h:99
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 double mp_max(double)
Definition Process.cpp:376
Classe de base des flux de sortie.
Definition Sortie.h:52
int nb_dim() const
Definition TRUSTTab.h:199
void resize(_SIZE_ n, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT)
Definition TRUSTTab.tpp:469
_SIZE_ dimension_tot(int) const override
Definition TRUSTTab.tpp:160
_SIZE_ dimension(int d) const
Definition TRUSTTab.tpp:133