TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Champ_front_instationnaire_base.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_front_instationnaire_base.h>
17
18Implemente_base(Champ_front_instationnaire_base,"Champ_front_instationnaire_base",Champ_front_base);
19
20/*! @brief Reads the time of the unsteady field from an input stream.
21 *
22 * @param (Entree& is) an input stream
23 * @return (Entree&) the modified input stream
24 */
26{
27 return is;
28}
29
30/*! @brief Writes the time of the unsteady field to an output stream.
31 *
32 * @param (Sortie& os) an output stream
33 * @return (Sortie&) the modified output stream
34 */
36{
37 return os;
38}
39
41{
42 if (!Champ_front_base::initialiser(temps,inco))
43 return 0;
44
45 temps_defaut=temps;
46 changer_temps_futur(temps,0);
47
48 for(int i=0; i<les_valeurs->nb_cases(); i++)
49 {
50 les_valeurs[i].valeurs().resize(1,nb_comp());
51 }
53 return 1;
54}
55
56
57/*! @brief Overrides Champ_front_base::fixer_nb_valeurs_temporelles
58 *
59 */
61{
62 les_valeurs->fixer_nb_cases(nb_cases);
63}
64
65inline void print(const Roue_ptr& les_valeurs)
66{
67 Cerr << "The times available are :" << finl;
68 for(int i=1; i<les_valeurs->nb_cases(); i++)
69 Cerr << " " << les_valeurs[i].temps() << finl;
70}
71
73{
74 for (int i = 0; i < les_valeurs->nb_cases(); i++)
75 if (est_egal(les_valeurs[i].temps(), temps))
76 {
77 if (les_valeurs->valeurs().size() > 0)
78 return true;
79 else return false;
80 }
81
82 return false;
83}
84
85/*! @brief Returns the values at the desired time.
86 *
87 * Otherwise, exits with an error.
88 *
89 */
91{
92
93 for(int i=0; i<les_valeurs->nb_cases(); i++)
94 {
95 if(est_egal(les_valeurs[i].temps(),temps))
96 return les_valeurs[i].valeurs();
97 }
98
99 Cerr << "In Champ_front_instationnaire_base::valeurs(double), "
100 << "time " << temps << " not found." << finl;
101 print(les_valeurs);
102 exit();
103 return valeurs(); // For compilers
104}
105
106/*! @brief Returns the values at the desired time.
107 *
108 * Otherwise, exits with an error.
109 *
110 */
111const DoubleTab& Champ_front_instationnaire_base::valeurs_au_temps(double temps) const
112{
113
114 for(int i=0; i<les_valeurs->nb_cases(); i++)
115 {
116 if(est_egal(les_valeurs[i].temps(),temps))
117 return les_valeurs[i].valeurs();
118 }
119
120 Cerr << "In Champ_front_instationnaire_base::valeurs(double), "
121 << "time " << temps << " not found." << finl;
122 print(les_valeurs);
123 exit();
124 return valeurs(); // For compilers
125}
126
127/*! @brief Advances to the desired time.
128 *
129 * Otherwise, exits with an error.
130 *
131 */
133{
134 // Is it indeed an advance in time?
135 assert(temps>les_valeurs->temps());
136
137 for(int i=1; i<les_valeurs->nb_cases(); i++)
138 {
139 if(est_egal(les_valeurs[i].temps(),temps))
140 {
142 return 1;
143 }
144 }
145 Cerr << "In Champ_front_instationnaire_base::avancer(double), "
146 << "time " << temps << " not found." << finl;
147 print(les_valeurs);
148 exit();
149 return 0;
150}
151
152/*! @brief Goes back to the desired time.
153 *
154 * Otherwise, exits with an error.
155 *
156 */
158{
159
160 // Is it indeed a rewind in time?
161 assert(temps<les_valeurs->temps());
162
163 for(int i=les_valeurs->nb_cases()-1; i>=1; i++)
164 {
165 if(est_egal(les_valeurs[i].temps(),temps))
166 {
168 return 1;
169 }
170 }
171 Cerr << "In Champ_front_instationnaire_base::reculer(double), "
172 << "time " << temps << " not found." << finl;
173 print(les_valeurs);
174 exit();
175 return 0;
176}
177
178void Champ_front_instationnaire_base::valeurs_face(int face,DoubleVect& var) const
179{
180 var.resize(nb_compo_);
181 int i;
182 for (i=0 ; i<nb_compo_ ; i++)
183 var(i) = valeurs()(0,i);
184}
Class Champ_Inc_base.
class Champ_front_base Base class for the hierarchy of boundary fields.
virtual int initialiser(double temps, const Champ_Inc_base &inco)
Initialization at the beginning of calculation.
virtual void changer_temps_futur(double temps, int i)
Changes the time value for the i-th temporal value after the present.
virtual DoubleTab & valeurs() override
Returns the array of field values.
virtual void set_instationnaire(bool flag)
class Champ_front_base Base class for unsteady boundary Fields,
void valeurs_face(int, DoubleVect &) const override
Returns the vector of field values for the given face.
int avancer(double temps) override
Advances to the desired time.
int initialiser(double temps, const Champ_Inc_base &inco) override
Initialization at the beginning of calculation.
void fixer_nb_valeurs_temporelles(int nb_cases) override
Overrides Champ_front_base::fixer_nb_valeurs_temporelles.
bool has_valeurs_au_temps(double temps) const override
int reculer(double temps) override
Goes back to the desired time.
DoubleTab & valeurs_au_temps(double temps) override
Returns the values at the desired time.
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
int nb_compo_
Definition Field_base.h:95
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
static void exit(int exit_code=-1)
Exit routine for TRUST within a Kokkos region.
Definition Process.cpp:466
int nb_cases() const
Returns the number of slots in the Roue.
Definition Roue.h:188
Base class for output streams.
Definition Sortie.h:52
void resize(_SIZE_, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT)
Definition TRUSTVect.tpp:91
Pointer to a wheel.
Definition Roue.h:33